Changing vanila skins option no longer requires restart

Fixes #1216
This commit is contained in:
Bojidar Marinov 2018-07-24 18:51:01 +03:00
parent b8b97eb740
commit d08f03fecf
No known key found for this signature in database
GPG key ID: 4D546A8F1E091856
2 changed files with 8 additions and 17 deletions

View file

@ -367,8 +367,6 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
{
CUIRect Button, Label, Button2, Dummy, DummyLabel, SkinList, QuickSearch, QuickSearchClearButton, SkinPrefix, SkinPrefixLabel;
bool CheckSettings = false;
static int s_ClVanillaSkinsOnly = g_Config.m_ClVanillaSkinsOnly;
static float s_ClSkinPrefix = 0.0f;
static bool s_InitSkinlist = true;
@ -424,7 +422,6 @@ 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;
CheckSettings = true;
}
Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy);
@ -440,14 +437,6 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
SkinPrefix.HSplitTop(20.0f, &SkinPrefixLabel, &SkinPrefix);
DoEditBox(g_Config.m_ClSkinPrefix, &SkinPrefixLabel, g_Config.m_ClSkinPrefix, sizeof(g_Config.m_ClSkinPrefix), 14.0f, &s_ClSkinPrefix);
if(CheckSettings)
{
if(s_ClVanillaSkinsOnly == g_Config.m_ClVanillaSkinsOnly)
m_NeedRestartSkins = false;
else
m_NeedRestartSkins = true;
}
Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy);
MainView.HSplitTop(50.0f, &Label, &MainView);

View file

@ -40,11 +40,6 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
str_copy(aFilenameWithoutPng, pName, sizeof(aFilenameWithoutPng));
aFilenameWithoutPng[str_length(aFilenameWithoutPng) - 4] = 0;
if(g_Config.m_ClVanillaSkinsOnly && !IsVanillaSkin(aFilenameWithoutPng))
{
return 0;
}
// Don't add duplicate skins (one from user's config directory, other from
// client itself)
for(int i = 0; i < pSelf->Num(); i++)
@ -203,10 +198,17 @@ int CSkins::FindImpl(const char *pName) const
for(int i = 0; i < m_aSkins.size(); i++)
{
if(str_comp(m_aSkins[i].m_aName, pName) == 0)
{
if(g_Config.m_ClVanillaSkinsOnly && !IsVanillaSkin(m_aSkins[i].m_aName))
{
return -1;
}
else
{
return i;
}
}
}
return -1;
}