mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- moved language switching code to 'common'.
This commit is contained in:
parent
a08d87beb3
commit
3a81c07ecf
6 changed files with 53 additions and 43 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)
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "v_font.h"
|
||||
#include "utf8.h"
|
||||
#include "gi.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
void I_UpdateWindowTitle();
|
||||
|
||||
|
@ -156,48 +157,7 @@ CUSTOM_CVAR(Float, teamdamage, 0.f, CVAR_SERVERINFO | CVAR_NOINITCALL)
|
|||
}
|
||||
}
|
||||
|
||||
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)) || ((gameinfo.gametype & GAME_Raven) && !strnicmp(language, "el", 2)));
|
||||
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);
|
||||
}
|
||||
|
||||
EXTERN_CVAR(Bool, ui_generic)
|
||||
|
||||
CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
|
|
|
@ -2967,4 +2967,3 @@ DEFINE_FIELD(DBaseStatusBar, itemflashFade);
|
|||
DEFINE_FIELD(DHUDFont, mFont);
|
||||
|
||||
DEFINE_GLOBAL(StatusBar);
|
||||
DEFINE_GLOBAL(generic_ui)
|
||||
|
|
Loading…
Reference in a new issue