mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-16 10:02:59 -07:00
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:
parent
e646f80f41
commit
18d2bac409
6 changed files with 41 additions and 3 deletions
|
@ -32,7 +32,7 @@ namespace Game {
|
||||||
const std::string EnhancementSection = ENHANCEMENTS_SECTION;
|
const std::string EnhancementSection = ENHANCEMENTS_SECTION;
|
||||||
const std::string CosmeticsSection = COSMETICS_SECTION;
|
const std::string CosmeticsSection = COSMETICS_SECTION;
|
||||||
const std::string CheatSection = CHEATS_SECTION;
|
const std::string CheatSection = CHEATS_SECTION;
|
||||||
|
const std::string LanguagesSection = LANGUAGES_SECTION;
|
||||||
|
|
||||||
void UpdateAudio() {
|
void UpdateAudio() {
|
||||||
Audio_SetGameVolume(SEQ_BGM_MAIN, CVar_GetFloat("gMainMusicVolume", 1));
|
Audio_SetGameVolume(SEQ_BGM_MAIN, CVar_GetFloat("gMainMusicVolume", 1));
|
||||||
|
|
|
@ -28,6 +28,7 @@ enum SeqPlayers {
|
||||||
#define ENHANCEMENTS_SECTION "ENHANCEMENT SETTINGS"
|
#define ENHANCEMENTS_SECTION "ENHANCEMENT SETTINGS"
|
||||||
#define COSMETICS_SECTION "COSMETIC SETTINGS"
|
#define COSMETICS_SECTION "COSMETIC SETTINGS"
|
||||||
#define CHEATS_SECTION "CHEATS SETTINGS"
|
#define CHEATS_SECTION "CHEATS SETTINGS"
|
||||||
|
#define LANGUAGES_SECTION "LANGUAGES SETTINGS"
|
||||||
|
|
||||||
namespace Game {
|
namespace Game {
|
||||||
extern SoHConfigType Settings;
|
extern SoHConfigType Settings;
|
||||||
|
|
|
@ -56,6 +56,7 @@ namespace SohImGui {
|
||||||
Console* console = new Console;
|
Console* console = new Console;
|
||||||
bool p_open = false;
|
bool p_open = false;
|
||||||
bool needs_save = 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 kokiri_col[3] = { 0.118f, 0.41f, 0.106f };
|
||||||
float goron_col[3] = { 0.392f, 0.078f, 0.0f };
|
float goron_col[3] = { 0.392f, 0.078f, 0.0f };
|
||||||
float zora_col[3] = { 0.0f, 0.235f, 0.392f };
|
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)
|
void EnhancementCheckbox(std::string text, std::string cvarName)
|
||||||
{
|
{
|
||||||
bool val = (bool)CVar_GetS32(cvarName.c_str(), 0);
|
bool val = (bool)CVar_GetS32(cvarName.c_str(), 0);
|
||||||
|
@ -636,6 +655,20 @@ namespace SohImGui {
|
||||||
ImGui::EndMenu();
|
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) {
|
for (const auto& category : windowCategories) {
|
||||||
if (ImGui::BeginMenu(category.first.c_str())) {
|
if (ImGui::BeginMenu(category.first.c_str())) {
|
||||||
for (const std::string& name : category.second) {
|
for (const std::string& name : category.second) {
|
||||||
|
|
|
@ -61,10 +61,11 @@ namespace SohImGui {
|
||||||
void Init(WindowImpl window_impl);
|
void Init(WindowImpl window_impl);
|
||||||
void Update(EventImpl event);
|
void Update(EventImpl event);
|
||||||
|
|
||||||
|
void EnhancementRadioButton(std::string text, std::string cvarName, int value);
|
||||||
void EnhancementCheckbox(std::string text, std::string cvarName);
|
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 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 EnhancementSliderFloat(std::string text, std::string id, std::string cvarName, float min, float max, std::string format, float defaultValue);
|
||||||
|
|
||||||
void DrawMainMenuAndCalculateGameSize(void);
|
void DrawMainMenuAndCalculateGameSize(void);
|
||||||
|
|
||||||
void DrawFramebufferAndGameInput(void);
|
void DrawFramebufferAndGameInput(void);
|
||||||
|
|
|
@ -29,6 +29,7 @@ void BootCommands_Init()
|
||||||
CVar_RegisterS32("gUniformLR", 1);
|
CVar_RegisterS32("gUniformLR", 1);
|
||||||
CVar_RegisterS32("gNewDrops", 0);
|
CVar_RegisterS32("gNewDrops", 0);
|
||||||
CVar_RegisterS32("gVisualAgony", 0);
|
CVar_RegisterS32("gVisualAgony", 0);
|
||||||
|
CVar_RegisterS32("gLanguages", 0); //0 = English / 1 = German / 2 = French
|
||||||
}
|
}
|
||||||
|
|
||||||
//void BootCommands_ParseBootArgs(char* str)
|
//void BootCommands_ParseBootArgs(char* str)
|
||||||
|
|
|
@ -422,7 +422,9 @@ void GameState_Update(GameState* gameState) {
|
||||||
int32_t prevTime = CVar_GetS32("gPrevTime", gSaveContext.dayTime);
|
int32_t prevTime = CVar_GetS32("gPrevTime", gSaveContext.dayTime);
|
||||||
gSaveContext.dayTime = prevTime;
|
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++;
|
gameState->frames++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue