From b19b0db150fb484860653f456f54f70faa5cc50b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 Oct 2022 17:59:02 +0200 Subject: [PATCH] - moved language CVAR to backend. --- src/common/engine/i_interface.cpp | 10 ++++++++++ src/common/engine/i_interface.h | 1 + src/common/fonts/v_text.cpp | 1 - src/d_main.cpp | 11 +++++++++++ src/g_cvars.cpp | 14 -------------- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/common/engine/i_interface.cpp b/src/common/engine/i_interface.cpp index 925ee1c7b8..580dde407c 100644 --- a/src/common/engine/i_interface.cpp +++ b/src/common/engine/i_interface.cpp @@ -3,6 +3,7 @@ #include "gamestate.h" #include "startupinfo.h" #include "c_cvars.h" +#include "gstrings.h" static_assert(sizeof(void*) == 8, "32 builds are not supported"); @@ -26,3 +27,12 @@ CVAR(Bool, queryiwad, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR(String, defaultiwad, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR(Bool, vid_fps, false, 0) +EXTERN_CVAR(Bool, ui_generic) + +CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +{ + GStrings.UpdateLanguage(self); + UpdateGenericUI(ui_generic); + if (sysCallbacks.LanguageChanged) sysCallbacks.LanguageChanged(self); +} + diff --git a/src/common/engine/i_interface.h b/src/common/engine/i_interface.h index 6d6f75ad3e..caea1c7c29 100644 --- a/src/common/engine/i_interface.h +++ b/src/common/engine/i_interface.h @@ -40,6 +40,7 @@ struct SystemCallbacks void (*HudScaleChanged)(); bool (*SetSpecialMenu)(FName& menu, int param); void (*OnMenuOpen)(bool makesound); + void (*LanguageChanged)(const char*); }; extern SystemCallbacks sysCallbacks; diff --git a/src/common/fonts/v_text.cpp b/src/common/fonts/v_text.cpp index e9ccb2a507..b7467a8abd 100644 --- a/src/common/fonts/v_text.cpp +++ b/src/common/fonts/v_text.cpp @@ -265,7 +265,6 @@ DEFINE_ACTION_FUNCTION(FFont, BreakLines) bool generic_ui; -EXTERN_CVAR(String, language) bool CheckFontComplete(FFont* font) { diff --git a/src/d_main.cpp b/src/d_main.cpp index f0f523d754..93614148de 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2769,6 +2769,16 @@ void System_ConsoleToggled(int state) D_ToggleHud(); } +void System_LanguageChanged(const char* lang) +{ + for (auto Level : AllLevels()) + { + // does this even make sense on secondary levels...? + if (Level->info != nullptr) Level->LevelName = Level->info->LookupLevelName(); + } + I_UpdateWindowTitle(); +} + //========================================================================== // // DoomSpecificInfo @@ -3543,6 +3553,7 @@ static int D_DoomMain_Internal (void) System_HudScaleChanged, M_SetSpecialMenu, OnMenuOpen, + System_LanguageChanged, }; diff --git a/src/g_cvars.cpp b/src/g_cvars.cpp index 2a1c9364fa..14c8325685 100644 --- a/src/g_cvars.cpp +++ b/src/g_cvars.cpp @@ -148,18 +148,4 @@ CUSTOM_CVAR(Float, teamdamage, 0.f, CVAR_SERVERINFO | CVAR_NOINITCALL) } } -EXTERN_CVAR(Bool, ui_generic) - -CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) -{ - GStrings.UpdateLanguage(self); - for (auto Level : AllLevels()) - { - // does this even make sense on secondary levels...? - if (Level->info != nullptr) Level->LevelName = Level->info->LookupLevelName(); - } - UpdateGenericUI(ui_generic); - I_UpdateWindowTitle(); -} - CVAR(Float, cl_scaleweaponfov, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)