diff --git a/libultraship/libultraship/GameSettings.cpp b/libultraship/libultraship/GameSettings.cpp index 9b7543b7d..c2d876ab0 100644 --- a/libultraship/libultraship/GameSettings.cpp +++ b/libultraship/libultraship/GameSettings.cpp @@ -32,7 +32,7 @@ namespace Game { const std::string EnhancementSection = ENHANCEMENTS_SECTION; const std::string CosmeticsSection = COSMETICS_SECTION; const std::string CheatSection = CHEATS_SECTION; - + const std::string LanguagesSection = LANGUAGES_SECTION; void UpdateAudio() { Audio_SetGameVolume(SEQ_BGM_MAIN, CVar_GetFloat("gMainMusicVolume", 1)); diff --git a/libultraship/libultraship/GameSettings.h b/libultraship/libultraship/GameSettings.h index 4b9956d17..9d4e3e776 100644 --- a/libultraship/libultraship/GameSettings.h +++ b/libultraship/libultraship/GameSettings.h @@ -28,6 +28,7 @@ enum SeqPlayers { #define ENHANCEMENTS_SECTION "ENHANCEMENT SETTINGS" #define COSMETICS_SECTION "COSMETIC SETTINGS" #define CHEATS_SECTION "CHEATS SETTINGS" +#define LANGUAGES_SECTION "LANGUAGES SETTINGS" namespace Game { extern SoHConfigType Settings; diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 1d9927c23..bb13b7db6 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -56,6 +56,7 @@ namespace SohImGui { Console* console = new Console; bool p_open = false; bool needs_save = false; + int SelectedLanguage = CVar_GetS32("gLanguages", 0); //Default Language to 0=English 1=German 2=French float kokiri_col[3] = { 0.118f, 0.41f, 0.106f }; float goron_col[3] = { 0.392f, 0.078f, 0.0f }; float zora_col[3] = { 0.0f, 0.235f, 0.392f }; @@ -346,6 +347,24 @@ namespace SohImGui { } } + void EnhancementRadioButton(std::string text, std::string cvarName, int id) { + /*Usage : + EnhancementRadioButton("My Visible Name","gMyCVarName", MyID); + First arg is the visible name of the Radio button + Second is the cvar name where MyID will be saved. + Note: the CVar name should be the same to each Buddies. + Example : + EnhancementRadioButton("English", "gLanguages", 0); + EnhancementRadioButton("German", "gLanguages", 1); + EnhancementRadioButton("French", "gLanguages", 2); + */ + int val = CVar_GetS32(cvarName.c_str(), 0); + if (ImGui::RadioButton(text.c_str(), id==val)) { + CVar_SetS32(cvarName.c_str(), (int)id); + needs_save = true; + } + } + void EnhancementCheckbox(std::string text, std::string cvarName) { bool val = (bool)CVar_GetS32(cvarName.c_str(), 0); @@ -636,6 +655,20 @@ namespace SohImGui { ImGui::EndMenu(); } + if (CVar_GetS32("gLanguages", 0) == 0) { + SelectedLanguage = 0; + } else if (CVar_GetS32("gLanguages", 0) == 1) { + SelectedLanguage = 1; + } else if (CVar_GetS32("gLanguages", 0) == 2) { + SelectedLanguage = 2; + } + if (ImGui::BeginMenu("Languages")) { + EnhancementRadioButton("English", "gLanguages", 0); + EnhancementRadioButton("German", "gLanguages", 1); + EnhancementRadioButton("French", "gLanguages", 2); + ImGui::EndMenu(); + } + for (const auto& category : windowCategories) { if (ImGui::BeginMenu(category.first.c_str())) { for (const std::string& name : category.second) { diff --git a/libultraship/libultraship/SohImGuiImpl.h b/libultraship/libultraship/SohImGuiImpl.h index b2b29e3d5..c4fe3f825 100644 --- a/libultraship/libultraship/SohImGuiImpl.h +++ b/libultraship/libultraship/SohImGuiImpl.h @@ -61,10 +61,11 @@ namespace SohImGui { void Init(WindowImpl window_impl); void Update(EventImpl event); - + void EnhancementRadioButton(std::string text, std::string cvarName, int value); void EnhancementCheckbox(std::string text, std::string cvarName); void EnhancementSliderInt(std::string text, std::string id, std::string cvarName, int min, int max, std::string format); void EnhancementSliderFloat(std::string text, std::string id, std::string cvarName, float min, float max, std::string format, float defaultValue); + void DrawMainMenuAndCalculateGameSize(void); void DrawFramebufferAndGameInput(void); diff --git a/soh/soh/Enhancements/bootcommands.c b/soh/soh/Enhancements/bootcommands.c index da4276f77..03742dae9 100644 --- a/soh/soh/Enhancements/bootcommands.c +++ b/soh/soh/Enhancements/bootcommands.c @@ -29,6 +29,7 @@ void BootCommands_Init() CVar_RegisterS32("gUniformLR", 1); CVar_RegisterS32("gNewDrops", 0); CVar_RegisterS32("gVisualAgony", 0); + CVar_RegisterS32("gLanguages", 0); //0 = English / 1 = German / 2 = French } //void BootCommands_ParseBootArgs(char* str) diff --git a/soh/src/code/game.c b/soh/src/code/game.c index b69537fd8..eea895ce1 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -422,7 +422,9 @@ void GameState_Update(GameState* gameState) { int32_t prevTime = CVar_GetS32("gPrevTime", gSaveContext.dayTime); gSaveContext.dayTime = prevTime; } - + + //since our CVar is same value and properly default to 0 there is not problems doing this in single line. + gSaveContext.language = CVar_GetS32("gLanguages", 0); gameState->frames++; }