Skip to content

Commit

Permalink
last bit of misc options localisation (don't know why I never submitt…
Browse files Browse the repository at this point in the history
…ed this):

 - when option values are set via console to values not available in other listed options '#GameUI_Custom' is pulled from the dictionary and added into the dropdown
  • Loading branch information
AdamWillden committed Nov 1, 2020
1 parent 3173c96 commit 95fbe37
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cl_dll/ff/vgui/ff_miscoptions.cpp
Expand Up @@ -64,9 +64,11 @@ void CFFMiscOptions::Apply()
}
else if (ComboBox *cb = dynamic_cast <ComboBox *> (pChild))
{
char szCustomCaption[128];
vgui::localize()->ConvertUnicodeToANSI(vgui::localize()->Find("#GameUI_Custom"), szCustomCaption, sizeof(szCustomCaption));
// Only replace the cvar with this option if it is not a custom one
const char *pszValue = cb->GetActiveItemUserData()->GetString("value");
if (Q_strncmp(pszValue, "custom", 6) != 0)
if (Q_strcmp(pszValue, szCustomCaption) != 0)
pCvar->SetValue(pszValue);
}
else if (CFFInputSlider *slider = dynamic_cast <CFFInputSlider *> (pChild))
Expand Down Expand Up @@ -262,22 +264,25 @@ void CFFMiscOptions::Load()
else if (ComboBox *cb = dynamic_cast <ComboBox *> (pChild))
{
int option = GetComboBoxOption(cb, pCvar->GetString());
char szCustomCaption[128];
vgui::localize()->ConvertUnicodeToANSI(vgui::localize()->Find("#GameUI_Custom"), szCustomCaption, sizeof(szCustomCaption));


// Option doesn't exist, so add a "custom field"
if (option == -1)
{
int custom = GetComboBoxOption(cb, "custom");
int custom = GetComboBoxOption(cb, szCustomCaption);

// Need to add the custom field
if (custom == -1)
{
KeyValues *kvItem = new KeyValues("kvItem");
kvItem->SetString("value", "custom");
cb->AddItem("custom", kvItem);
kvItem->SetString("value", pCvar->GetString());
cb->AddItem(szCustomCaption, kvItem);
kvItem->deleteThis();
}

custom = GetComboBoxOption(cb, "custom");
custom = GetComboBoxOption(cb, szCustomCaption);
cb->ActivateItem(custom);
}
else
Expand All @@ -286,7 +291,7 @@ void CFFMiscOptions::Load()
cb->ActivateItem(option);

// However lets remove the custom row if it exists
int custom = GetComboBoxOption(cb, "custom");
int custom = GetComboBoxOption(cb, szCustomCaption);
if (custom != -1)
cb->DeleteItem(custom);
}
Expand Down

0 comments on commit 95fbe37

Please sign in to comment.