diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index a3476aae4..38d0eac7a 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -103,6 +103,8 @@ class CMenus : public CComponent void RenderColorPicker(); + void RefreshSkins(); + // new gui with gui elements template int DoButtonMenu(CUIElement &UIElement, const void *pID, T &&GetTextLambda, int Checked, const CUIRect *pRect, bool HintRequiresStringCheck, bool HintCanChangePositionOrSize = false, int Corners = IGraphics::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 70c178052..e851fe179 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -409,6 +409,18 @@ struct CUISkin bool operator==(const char *pOther) const { return !str_comp_nocase(m_pSkin->m_aName, pOther); } }; +void CMenus::RefreshSkins() +{ + auto SkinStartLoadTime = time_get_nanoseconds(); + m_pClient->m_Skins.Refresh([&](int) { + // if skin refreshing takes to long, swap to a loading screen + if(time_get_nanoseconds() - SkinStartLoadTime > 500ms) + { + RenderLoading(Localize("Loading skin files"), "", 0, false); + } + }); +} + void CMenus::RenderSettingsTee(CUIRect MainView) { CUIRect Button, Label, Dummy, DummyLabel, SkinList, QuickSearch, QuickSearchClearButton, SkinDB, SkinPrefix, SkinPrefixLabel, DirectoryButton, RefreshButton, Eyes, EyesLabel, EyesTee, EyesRight; @@ -470,6 +482,8 @@ void CMenus::RenderSettingsTee(CUIRect MainView) if(DoButton_CheckBox(&g_Config.m_ClDownloadSkins, Localize("Download skins"), g_Config.m_ClDownloadSkins, &DummyLabel)) { g_Config.m_ClDownloadSkins ^= 1; + RefreshSkins(); + s_InitSkinlist = true; } Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy); @@ -477,6 +491,8 @@ void CMenus::RenderSettingsTee(CUIRect MainView) if(DoButton_CheckBox(&g_Config.m_ClDownloadCommunitySkins, Localize("Download community skins"), g_Config.m_ClDownloadCommunitySkins, &DummyLabel)) { g_Config.m_ClDownloadCommunitySkins ^= 1; + RefreshSkins(); + s_InitSkinlist = true; } Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy); @@ -484,6 +500,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) if(DoButton_CheckBox(&g_Config.m_ClVanillaSkinsOnly, Localize("Vanilla skins only"), g_Config.m_ClVanillaSkinsOnly, &DummyLabel)) { g_Config.m_ClVanillaSkinsOnly ^= 1; + RefreshSkins(); s_InitSkinlist = true; } @@ -779,14 +796,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) // reset render flags for possible loading screen TextRender()->SetRenderFlags(0); TextRender()->SetCurFont(NULL); - auto SkinStartLoadTime = time_get_nanoseconds(); - m_pClient->m_Skins.Refresh([&](int) { - // if skin refreshing takes to long, swap to a loading screen - if(time_get_nanoseconds() - SkinStartLoadTime > 500ms) - { - RenderLoading(Localize("Loading skin files"), "", 0, false); - } - }); + RefreshSkins(); s_InitSkinlist = true; if(Client()->State() >= IClient::STATE_ONLINE) {