mirror of
https://github.com/open-goal/jak-project
synced 2026-09-01 09:53:12 -04:00
Add PC Port settings to legit start menu (#1217)
* decompiler: support adding new strings to the game_text.txt file * gsrc: expand the pckernel type and functions to work better with the menu * gsrc: add new text-ids * gsrc: add new macros to help with menu code * gsrc: make a new type to generalize their list menu options * gsrc: add new menu options and enums * gsrc: cleanup and refactor the list menu option drawing code this allows us to easily add a new list menu option...well as easy as the rest is atleast (setting up static lists properly, etc) * gsrc: add and cleanup handling of new menu options * scripts: add checks with nice error messages for user facing taskfile recipes * lint: formatting * address simple feedback * gsrc: move modified files to `pc/` folder * gsrc: revert changes to originally decompiled files * gsrc: move modified and new files to `goal_src/pc` folder * gsrc: update paths in `all_files.gc`
This commit is contained in:
@@ -134,17 +134,18 @@ GameTextResult process_game_text(ObjectFileData& data, GameTextVersion version)
|
||||
}
|
||||
|
||||
std::string write_game_text(
|
||||
const Config& cfg,
|
||||
const std::unordered_map<int, std::unordered_map<int, std::string>>& data) {
|
||||
// first sort languages:
|
||||
std::vector<int> langauges;
|
||||
std::vector<int> languages;
|
||||
for (const auto& lang : data) {
|
||||
langauges.push_back(lang.first);
|
||||
languages.push_back(lang.first);
|
||||
}
|
||||
std::sort(langauges.begin(), langauges.end());
|
||||
std::sort(languages.begin(), languages.end());
|
||||
|
||||
// build map
|
||||
std::map<int, std::vector<std::string>> text_by_id;
|
||||
for (auto lang : langauges) {
|
||||
for (auto lang : languages) {
|
||||
for (auto& text : data.at(lang)) {
|
||||
text_by_id[text.first].push_back(text.second);
|
||||
}
|
||||
@@ -152,7 +153,7 @@ std::string write_game_text(
|
||||
|
||||
// write!
|
||||
std::string result; // = "\xEF\xBB\xBF"; // UTF-8 encode (don't need this anymore)
|
||||
result += fmt::format("(language-count {})\n", langauges.size());
|
||||
result += fmt::format("(language-count {})\n", languages.size());
|
||||
result += "(group-name \"common\")\n";
|
||||
for (auto& x : text_by_id) {
|
||||
result += fmt::format("(#x{:04x}\n ", x.first);
|
||||
@@ -162,6 +163,28 @@ std::string write_game_text(
|
||||
result += ")\n\n";
|
||||
}
|
||||
|
||||
// add our own custom text additions from new_strings.jsonc
|
||||
// - first add the strings that are the same across all languages
|
||||
for (auto const& [key, val] : cfg.new_strings_same_across_langs) {
|
||||
result += fmt::format("(#x{}\n ", key);
|
||||
for (int i = 0; i < languages.size(); i++) {
|
||||
result += fmt::format("\"{}\"\n ", val);
|
||||
}
|
||||
result += ")\n\n";
|
||||
}
|
||||
// - now add the ones that are different, if they do not have all languages defined, pad with
|
||||
// placeholders
|
||||
for (auto const& [key, val] : cfg.new_strings_different_across_langs) {
|
||||
result += fmt::format("(#x{}\n ", key);
|
||||
for (auto const& str : val) {
|
||||
result += fmt::format("\"{}\"\n ", str);
|
||||
}
|
||||
for (int i = 0; i < languages.size() - val.size(); i++) {
|
||||
result += fmt::format("\"{}\"\n ", "TODO");
|
||||
}
|
||||
result += ")\n\n";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
} // namespace decompiler
|
||||
|
||||
Reference in New Issue
Block a user