Languages selection menu (#232)

* Adding Languages section

* Added LanguagesSection

* Register the Cvar

* Added switcher method

* Added Language selection menu + function

* function ref.

* Conflict fixes to be sure nothing else is modded

* space removed

* no need to have conditions since ID are the same
This commit is contained in:
Baoulettes 2022-05-03 00:24:12 +02:00 committed by GitHub
parent e646f80f41
commit 18d2bac409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 3 deletions

View File

@ -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));

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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)

View File

@ -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++;
}