Add autodowloading chinese font when needed
This commit is contained in:
parent
42c6156ce5
commit
1f48e7f723
@ -112,6 +112,19 @@ void D3dHook::ProcessFrame(void* ptr)
|
||||
{
|
||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
if (FontMgr::IsFontReloadRequired())
|
||||
{
|
||||
FontMgr::ReloadAll();
|
||||
if (gRenderer == Render_DirectX9)
|
||||
{
|
||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -87,7 +87,8 @@ void MenuThread(void* param)
|
||||
bool modloader = GetModuleHandle("modloader.asi");
|
||||
const char *path = PLUGIN_PATH((char*)"");
|
||||
Log::Print<eLogLevel::None>("Install location: {}", modloader && strstr(path, "modloader") ? "Modloader" : "Game directory");
|
||||
Log::Print<eLogLevel::None>("CLEO installed: {}", GetModuleHandle("cleo.asi") || GetModuleHandle("cleo_redux.asi") ? "True" : "False");
|
||||
Log::Print<eLogLevel::None>("Font support package: {}", FontMgr::IsSupportPackageInstalled() ? "True" : "False");
|
||||
Log::Print<eLogLevel::None>("\nCLEO installed: {}", GetModuleHandle("cleo.asi") || GetModuleHandle("cleo_redux.asi") ? "True" : "False");
|
||||
Log::Print<eLogLevel::None>("FLA installed: {}", GetModuleHandle("$fastman92limitAdjuster.asi") ? "True" : "False");
|
||||
Log::Print<eLogLevel::None>("Mixsets installed: {}", GetModuleHandle("MixSets.asi") ? "True" : "False");
|
||||
Log::Print<eLogLevel::None>("Modloader installed: {}", modloader ? "True" : "False");
|
||||
|
@ -51,7 +51,9 @@ ImFont* FontMgr::Load(const char* fontID, const char* path, float fontMul)
|
||||
|
||||
void FontMgr::UnloadAll()
|
||||
{
|
||||
ImGui::GetIO().Fonts->Clear();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.Fonts->Clear();
|
||||
io.Fonts->ClearFonts();
|
||||
}
|
||||
|
||||
void FontMgr::ReloadAll()
|
||||
@ -66,11 +68,12 @@ void FontMgr::ReloadAll()
|
||||
}
|
||||
io.FontDefault = Get("text");
|
||||
io.Fonts->Build();
|
||||
m_bFontReloadRequired = false;
|
||||
}
|
||||
|
||||
void FontMgr::Process()
|
||||
{
|
||||
if (curState != eStates::Idle)
|
||||
if (curState == eStates::Idle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -84,9 +87,20 @@ void FontMgr::Process()
|
||||
return;
|
||||
}
|
||||
|
||||
m_bFontReloadRequired = true;
|
||||
curState = eStates::Idle;
|
||||
}
|
||||
|
||||
bool FontMgr::IsSupportPackageInstalled()
|
||||
{
|
||||
return std::filesystem::file_size(MENU_DATA_PATH("fonts/text.ttf")) > 1000000; // 1 MB
|
||||
}
|
||||
|
||||
bool FontMgr::IsFontReloadRequired()
|
||||
{
|
||||
return m_bFontReloadRequired;
|
||||
}
|
||||
|
||||
void FontMgr::StartOptionalFontDownload()
|
||||
{
|
||||
if (curState == eStates::Idle)
|
||||
|
@ -23,6 +23,7 @@ private:
|
||||
};
|
||||
static inline std::vector<FontInfo> m_vecFonts;
|
||||
static inline eStates curState = eStates::Idle;
|
||||
static inline bool m_bFontReloadRequired = false;
|
||||
|
||||
public:
|
||||
FontMgr() = delete;
|
||||
@ -49,6 +50,12 @@ public:
|
||||
|
||||
// Downloads optional font package
|
||||
static void StartOptionalFontDownload();
|
||||
|
||||
// Returns true if font support package is already installed
|
||||
static bool IsSupportPackageInstalled();
|
||||
|
||||
// Returns true if font needs to be reloaded
|
||||
static bool IsFontReloadRequired();
|
||||
};
|
||||
|
||||
|
||||
|
@ -27,10 +27,9 @@ void Menu::ShowPage()
|
||||
{
|
||||
static int selected = Locale::GetCurrentLocaleIndex();
|
||||
static std::vector<std::string>& vec = Locale::GetLocaleList();
|
||||
static size_t fontSz = std::filesystem::file_size(MENU_DATA_PATH("fonts/text.ttf"));
|
||||
|
||||
if (Locale::GetLocaleList()[Locale::GetCurrentLocaleIndex()] == "Chinese"
|
||||
&& fontSz < 1000000) // Normal font size is < 1 MB
|
||||
&& !FontMgr::IsSupportPackageInstalled())
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Font support package is required to display this language! This may take a while depending on your connection.");
|
||||
|
Loading…
Reference in New Issue
Block a user