- moved language CVAR to backend.

This commit is contained in:
Christoph Oelckers 2022-10-02 17:59:02 +02:00
parent 73142ef2cf
commit b19b0db150
5 changed files with 22 additions and 15 deletions

View file

@ -3,6 +3,7 @@
#include "gamestate.h" #include "gamestate.h"
#include "startupinfo.h" #include "startupinfo.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "gstrings.h"
static_assert(sizeof(void*) == 8, "32 builds are not supported"); 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(String, defaultiwad, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
CVAR(Bool, vid_fps, false, 0) 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);
}

View file

@ -40,6 +40,7 @@ struct SystemCallbacks
void (*HudScaleChanged)(); void (*HudScaleChanged)();
bool (*SetSpecialMenu)(FName& menu, int param); bool (*SetSpecialMenu)(FName& menu, int param);
void (*OnMenuOpen)(bool makesound); void (*OnMenuOpen)(bool makesound);
void (*LanguageChanged)(const char*);
}; };
extern SystemCallbacks sysCallbacks; extern SystemCallbacks sysCallbacks;

View file

@ -265,7 +265,6 @@ DEFINE_ACTION_FUNCTION(FFont, BreakLines)
bool generic_ui; bool generic_ui;
EXTERN_CVAR(String, language)
bool CheckFontComplete(FFont* font) bool CheckFontComplete(FFont* font)
{ {

View file

@ -2769,6 +2769,16 @@ void System_ConsoleToggled(int state)
D_ToggleHud(); 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 // DoomSpecificInfo
@ -3543,6 +3553,7 @@ static int D_DoomMain_Internal (void)
System_HudScaleChanged, System_HudScaleChanged,
M_SetSpecialMenu, M_SetSpecialMenu,
OnMenuOpen, OnMenuOpen,
System_LanguageChanged,
}; };

View file

@ -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) CVAR(Float, cl_scaleweaponfov, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)