forked from OpenEnroth/OpenEnroth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96caaec
commit 28c1e8a
Showing
11 changed files
with
271 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
#pragma once | ||
|
||
#include "Engine/Tables/BuildingTable.h" | ||
#include "Engine/Objects/MonsterEnums.h" | ||
|
||
#include "Library/Serialization/SerializationFwd.h" | ||
|
||
MM_DECLARE_SERIALIZATION_FUNCTIONS(BuildingType) | ||
MM_DECLARE_SERIALIZATION_FUNCTIONS(HouseId) | ||
MM_DECLARE_SERIALIZATION_FUNCTIONS(MonsterType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
|
||
#include <cstdio> | ||
#include <cctype> | ||
#include <vector> | ||
#include <array> | ||
#include <string_view> | ||
#include <string> | ||
#include <algorithm> | ||
|
||
#include "Utility/Format.h" | ||
|
||
inline std::string toUpperCaseEnum(const std::string &string) { | ||
std::string result; | ||
for (char c : trim(string)) { | ||
if (std::isalnum(c)) { | ||
result += static_cast<char>(toupper(c)); | ||
} else if (std::isspace(c) || c == '/' || c == '-') { | ||
if (!result.ends_with('_')) | ||
result += '_'; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
template<size_t N> | ||
void dumpAligned(FILE *file, std::string_view prefix, const std::vector<std::array<std::string, N>> &table) { | ||
std::array<size_t, N> maxLengths; | ||
maxLengths.fill(0); | ||
|
||
for (const auto &line : table) | ||
for (size_t i = 0; i < line.size(); i++) | ||
maxLengths[i] = std::max(maxLengths[i], line[i].size()); | ||
|
||
for (const auto &line : table) { | ||
std::string output = std::string(prefix); | ||
for (size_t i = 0; i < line.size(); i++) { | ||
output += line[i]; | ||
output += std::string(maxLengths[i] - line[i].size(), ' '); | ||
} | ||
while (output.ends_with(' ')) // Note that we don't trim front. | ||
output.pop_back(); | ||
fmt::println(file, "{}", output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.