Update fontmgr

This commit is contained in:
Grinch_ 2022-08-02 07:48:27 +06:00
parent 1f48e7f723
commit 7b66de03c3
4 changed files with 29 additions and 14 deletions

View File

@ -205,6 +205,7 @@ QuickWepSpawnerCMDText = """
Spawn weapons by typing their model names. Spawn weapons by typing their model names.
Example: wep (wep_name)""" Example: wep (wep_name)"""
RAMUsage = "RAM usage: %.2f%%" RAMUsage = "RAM usage: %.2f%%"
ReloadFonts = "Reload fonts"
ResetConfig = "Reset config" ResetConfig = "Reset config"
ResetConfigMSG = "Config has been reset. Restart the game for it to take effect." ResetConfigMSG = "Config has been reset. Restart the game for it to take effect."
ResetSize = "Reset size" ResetSize = "Reset size"

View File

@ -107,4 +107,9 @@ void FontMgr::StartOptionalFontDownload()
{ {
curState = eStates::Downloading; curState = eStates::Downloading;
} }
}
void FontMgr::SetFontReloadRequired(bool state)
{
m_bFontReloadRequired = state;
} }

View File

@ -32,15 +32,17 @@ public:
// Returns font pointer from name // Returns font pointer from name
static ImFont* Get(const char* fontID); static ImFont* Get(const char* fontID);
// Loads a font into memory
static ImFont* Load(const char* fontID, const char* path = 0, float fontMul = 1.0f);
// Get the glyph ranges for our needed fonts // Get the glyph ranges for our needed fonts
static const ImWchar* GetGlyphRanges(); static const ImWchar* GetGlyphRanges();
// Unloads all the loaded fonts from fontmgr // Returns true if font needs to be reloaded
// ImGui::GetIO().Default font must be loaded after unloading all fonts static bool IsFontReloadRequired();
static void UnloadAll();
// Returns true if font support package is already installed
static bool IsSupportPackageInstalled();
// Loads a font into memory
static ImFont* Load(const char* fontID, const char* path = 0, float fontMul = 1.0f);
// Handles font downloading // Handles font downloading
static void Process(); static void Process();
@ -48,14 +50,15 @@ public:
// Reloads all the fonts // Reloads all the fonts
static void ReloadAll(); static void ReloadAll();
// Downloads optional font package // Sets if the font reloading is requried
static void SetFontReloadRequired(bool state);
// Downloads optional font package from GitHub reository
static void StartOptionalFontDownload(); static void StartOptionalFontDownload();
// Returns true if font support package is already installed // Unloads all the loaded fonts from fontmgr
static bool IsSupportPackageInstalled(); // ImGui::GetIO().Default font must be loaded after unloading all fonts
static void UnloadAll();
// Returns true if font needs to be reloaded
static bool IsFontReloadRequired();
}; };

View File

@ -43,14 +43,20 @@ void Menu::ShowPage()
{ {
Locale::SetDefaultLocale(); Locale::SetDefaultLocale();
selected = Locale::GetCurrentLocaleIndex(); selected = Locale::GetCurrentLocaleIndex();
CheatMenu::GenHeaderList();
} }
} }
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button(TEXT("Menu.ResetSize"), ImVec2(Widget::CalcSize(1)))) if (ImGui::Button(TEXT("Menu.ResetSize"), ImVec2(Widget::CalcSize(2))))
{ {
CheatMenu::ResetMenuSize(); CheatMenu::ResetMenuSize();
} }
ImGui::SameLine();
if (ImGui::Button(TEXT("Menu.ReloadFonts"), ImVec2(Widget::CalcSize(2))))
{
FontMgr::SetFontReloadRequired(true);
}
ImGui::Spacing(); ImGui::Spacing();