- update of language code from GZDoom.

This commit is contained in:
Christoph Oelckers 2020-10-05 00:46:24 +02:00
parent 7c89db69bd
commit 9606b09ddd
7 changed files with 56 additions and 3 deletions

View File

@ -38,3 +38,6 @@ struct WadStuff
extern FString endoomName;
extern bool batchrun;
extern float menuBlurAmount;
extern bool generic_ui;
void UpdateGenericUI(bool cvar);

View File

@ -666,3 +666,5 @@ const char *StringMap::MatchString (const char *string) const
}
FStringTable GStrings;

View File

@ -46,6 +46,7 @@
#include "gstrings.h"
#include "vm.h"
#include "serializer.h"
#include "c_cvars.h"
//==========================================================================
//
@ -240,3 +241,46 @@ DEFINE_ACTION_FUNCTION(FFont, BreakLines)
auto broken = V_BreakLines(self, maxwidth, text, true);
ACTION_RETURN_OBJECT(Create<DBrokenLines>(broken));
}
bool generic_ui;
EXTERN_CVAR(String, language)
bool CheckFontComplete(FFont* font)
{
// Also check if the SmallFont contains all characters this language needs.
// If not, switch back to the original one.
return font->CanPrint(GStrings["REQUIRED_CHARACTERS"]);
}
void UpdateGenericUI(bool cvar)
{
auto switchstr = GStrings["USE_GENERIC_FONT"];
generic_ui = (cvar || (switchstr && strtoll(switchstr, nullptr, 0)));
if (!generic_ui)
{
// Use the mod's SmallFont if it is complete.
// Otherwise use the stock Smallfont if it is complete.
// If none is complete, fall back to the VGA font.
// The font being set here will be used in 3 places: Notifications, centered messages and menu confirmations.
if (CheckFontComplete(SmallFont))
{
AlternativeSmallFont = SmallFont;
}
else if (OriginalSmallFont && CheckFontComplete(OriginalSmallFont))
{
AlternativeSmallFont = OriginalSmallFont;
}
else
{
AlternativeSmallFont = NewSmallFont;
}
// Todo: Do the same for the BigFont
}
}
CUSTOM_CVAR(Bool, ui_generic, false, CVAR_NOINITCALL) // This is for allowing to test the generic font system with all languages
{
UpdateGenericUI(self);
}

View File

@ -47,6 +47,7 @@
#include "gstrings.h"
#include "printf.h"
#include "s_music.h"
#include "i_interface.h"
//==========================================================================
@ -660,3 +661,4 @@ DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, loop);
DEFINE_GLOBAL_NAMED(PClass::AllClasses, AllClasses)
DEFINE_GLOBAL(Bindings)
DEFINE_GLOBAL(AutomapBindings)
DEFINE_GLOBAL(generic_ui)

View File

@ -66,6 +66,7 @@
#include "raze_music.h"
#include "gstrings.h"
#include "menustate.h"
#include "i_interface.h"
#define LEFTMARGIN 8
#define RIGHTMARGIN 8
@ -166,9 +167,6 @@ CVAR(Int, developer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
EXTERN_CVAR(Int, uiscale);
CVAR(Bool, generic_ui, false, CVAR_ARCHIVE)
struct History
{
struct History *Older;

View File

@ -78,9 +78,12 @@ CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVARD(Bool, invertmousex, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert horizontal mouse movement")
CVARD(Bool, invertmouse, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert vertical mouse movement")
EXTERN_CVAR(Bool, ui_generic)
CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
{
GStrings.UpdateLanguage(self);
UpdateGenericUI(ui_generic);
}
CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)

View File

@ -31,6 +31,7 @@ struct _ native // These are the global variables, the struct is only here to av
native int menuactive;
native @KeyBindings Bindings;
native @KeyBindings AutomapBindings;
native readonly bool generic_ui;
}