mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 17:00:56 +00:00
- update of language code from GZDoom.
This commit is contained in:
parent
7c89db69bd
commit
9606b09ddd
7 changed files with 56 additions and 3 deletions
|
@ -38,3 +38,6 @@ struct WadStuff
|
|||
extern FString endoomName;
|
||||
extern bool batchrun;
|
||||
extern float menuBlurAmount;
|
||||
extern bool generic_ui;
|
||||
|
||||
void UpdateGenericUI(bool cvar);
|
||||
|
|
|
@ -666,3 +666,5 @@ const char *StringMap::MatchString (const char *string) const
|
|||
}
|
||||
|
||||
FStringTable GStrings;
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue