mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #419 from timakro/master
added quick search for skin selection
This commit is contained in:
commit
c2f3bcb11e
|
@ -21,6 +21,7 @@ MACRO_CONFIG_INT(ClCpuThrottleInactive, cl_cpu_throttle_inactive, 1, 0, 1, CFGFL
|
||||||
MACRO_CONFIG_INT(ClEditor, cl_editor, 0, 0, 1, CFGFLAG_CLIENT, "")
|
MACRO_CONFIG_INT(ClEditor, cl_editor, 0, 0, 1, CFGFLAG_CLIENT, "")
|
||||||
MACRO_CONFIG_INT(ClEditorUndo, cl_editorundo, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Undo function in editor")
|
MACRO_CONFIG_INT(ClEditorUndo, cl_editorundo, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Undo function in editor")
|
||||||
MACRO_CONFIG_INT(ClLoadCountryFlags, cl_load_country_flags, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Load and show country flags")
|
MACRO_CONFIG_INT(ClLoadCountryFlags, cl_load_country_flags, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Load and show country flags")
|
||||||
|
MACRO_CONFIG_STR(ClSkinFilterString, cl_skin_filter_string, 25, "", CFGFLAG_SAVE|CFGFLAG_CLIENT, "Skin filtering string")
|
||||||
|
|
||||||
MACRO_CONFIG_INT(ClAutoDemoRecord, cl_auto_demo_record, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Automatically record demos")
|
MACRO_CONFIG_INT(ClAutoDemoRecord, cl_auto_demo_record, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Automatically record demos")
|
||||||
MACRO_CONFIG_INT(ClAutoDemoMax, cl_auto_demo_max, 10, 0, 1000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Maximum number of automatically recorded demos (0 = no limit)")
|
MACRO_CONFIG_INT(ClAutoDemoMax, cl_auto_demo_max, 10, 0, 1000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Maximum number of automatically recorded demos (0 = no limit)")
|
||||||
|
|
|
@ -487,7 +487,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
||||||
QuickExclude.VSplitLeft(5.0f, 0, &QuickExclude);
|
QuickExclude.VSplitLeft(5.0f, 0, &QuickExclude);
|
||||||
// render quick search
|
// render quick search
|
||||||
{
|
{
|
||||||
const char *pLabel = Localize("⚲");
|
const char *pLabel = "⚲";
|
||||||
UI()->DoLabelScaled(&QuickSearch, pLabel, 12.0f, -1);
|
UI()->DoLabelScaled(&QuickSearch, pLabel, 12.0f, -1);
|
||||||
float w = TextRender()->TextWidth(0, 12.0f, pLabel, -1);
|
float w = TextRender()->TextWidth(0, 12.0f, pLabel, -1);
|
||||||
QuickSearch.VSplitLeft(w, 0, &QuickSearch);
|
QuickSearch.VSplitLeft(w, 0, &QuickSearch);
|
||||||
|
|
|
@ -609,7 +609,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
|
||||||
{
|
{
|
||||||
Bottom.VSplitLeft(240.0f, &QuickSearch, &Bottom);
|
Bottom.VSplitLeft(240.0f, &QuickSearch, &Bottom);
|
||||||
QuickSearch.HSplitTop(5.0f, 0, &QuickSearch);
|
QuickSearch.HSplitTop(5.0f, 0, &QuickSearch);
|
||||||
const char *pSearchLabel = Localize("⚲");
|
const char *pSearchLabel = "⚲";
|
||||||
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 14.0f, -1);
|
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 14.0f, -1);
|
||||||
float wSearch = TextRender()->TextWidth(0, 14.0f, pSearchLabel, -1);
|
float wSearch = TextRender()->TextWidth(0, 14.0f, pSearchLabel, -1);
|
||||||
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
|
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
|
||||||
|
|
|
@ -342,7 +342,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
||||||
|
|
||||||
void CMenus::RenderSettingsTee(CUIRect MainView)
|
void CMenus::RenderSettingsTee(CUIRect MainView)
|
||||||
{
|
{
|
||||||
CUIRect Button, Label, Button2, Dummy, DummyLabel;
|
CUIRect Button, Label, Button2, Dummy, DummyLabel, SkinList, QuickSearch, QuickSearchClearButton;
|
||||||
static bool s_InitSkinlist = true;
|
static bool s_InitSkinlist = true;
|
||||||
MainView.HSplitTop(10.0f, 0, &MainView);
|
MainView.HSplitTop(10.0f, 0, &MainView);
|
||||||
|
|
||||||
|
@ -479,6 +479,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
||||||
|
|
||||||
// skin selector
|
// skin selector
|
||||||
MainView.HSplitTop(20.0f, 0, &MainView);
|
MainView.HSplitTop(20.0f, 0, &MainView);
|
||||||
|
MainView.HSplitTop(230.0f, &SkinList, &MainView);
|
||||||
static sorted_array<const CSkins::CSkin *> s_paSkinList;
|
static sorted_array<const CSkins::CSkin *> s_paSkinList;
|
||||||
static float s_ScrollValue = 0.0f;
|
static float s_ScrollValue = 0.0f;
|
||||||
if(s_InitSkinlist)
|
if(s_InitSkinlist)
|
||||||
|
@ -487,16 +488,22 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
||||||
for(int i = 0; i < m_pClient->m_pSkins->Num(); ++i)
|
for(int i = 0; i < m_pClient->m_pSkins->Num(); ++i)
|
||||||
{
|
{
|
||||||
const CSkins::CSkin *s = m_pClient->m_pSkins->Get(i);
|
const CSkins::CSkin *s = m_pClient->m_pSkins->Get(i);
|
||||||
|
|
||||||
|
// filter quick search
|
||||||
|
if(g_Config.m_ClSkinFilterString[0] != '\0' && !str_find_nocase(s->m_aName, g_Config.m_ClSkinFilterString))
|
||||||
|
continue;
|
||||||
|
|
||||||
// no special skins
|
// no special skins
|
||||||
if((s->m_aName[0] == 'x' && s->m_aName[1] == '_'))
|
if((s->m_aName[0] == 'x' && s->m_aName[1] == '_'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
s_paSkinList.add(s);
|
s_paSkinList.add(s);
|
||||||
}
|
}
|
||||||
s_InitSkinlist = false;
|
s_InitSkinlist = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OldSelected = -1;
|
int OldSelected = -1;
|
||||||
UiDoListboxStart(&s_InitSkinlist, &MainView, 50.0f, Localize("Skins"), "", s_paSkinList.size(), 4, OldSelected, s_ScrollValue);
|
UiDoListboxStart(&s_InitSkinlist, &SkinList, 50.0f, Localize("Skins"), "", s_paSkinList.size(), 4, OldSelected, s_ScrollValue);
|
||||||
for(int i = 0; i < s_paSkinList.size(); ++i)
|
for(int i = 0; i < s_paSkinList.size(); ++i)
|
||||||
{
|
{
|
||||||
const CSkins::CSkin *s = s_paSkinList[i];
|
const CSkins::CSkin *s = s_paSkinList[i];
|
||||||
|
@ -555,6 +562,35 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
||||||
else
|
else
|
||||||
m_NeedSendinfo = true;
|
m_NeedSendinfo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// render quick search
|
||||||
|
{
|
||||||
|
MainView.HSplitBottom(ms_ButtonHeight, &MainView, &QuickSearch);
|
||||||
|
QuickSearch.VSplitLeft(240.0f, &QuickSearch, 0);
|
||||||
|
QuickSearch.HSplitTop(5.0f, 0, &QuickSearch);
|
||||||
|
const char *pSearchLabel = "⚲";
|
||||||
|
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 14.0f, -1);
|
||||||
|
float wSearch = TextRender()->TextWidth(0, 14.0f, pSearchLabel, -1);
|
||||||
|
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
|
||||||
|
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
|
||||||
|
QuickSearch.VSplitLeft(QuickSearch.w-15.0f, &QuickSearch, &QuickSearchClearButton);
|
||||||
|
static float Offset = 0.0f;
|
||||||
|
if(DoEditBox(&g_Config.m_ClSkinFilterString, &QuickSearch, g_Config.m_ClSkinFilterString, sizeof(g_Config.m_ClSkinFilterString), 14.0f, &Offset, false, CUI::CORNER_L, Localize("Search")))
|
||||||
|
s_InitSkinlist = true;
|
||||||
|
|
||||||
|
// clear button
|
||||||
|
{
|
||||||
|
static int s_ClearButton = 0;
|
||||||
|
RenderTools()->DrawUIRect(&QuickSearchClearButton, vec4(1,1,1,0.33f)*ButtonColorMul(&s_ClearButton), CUI::CORNER_R, 3.0f);
|
||||||
|
UI()->DoLabel(&QuickSearchClearButton, "×", QuickSearchClearButton.h*ms_FontmodHeight, 0);
|
||||||
|
if(UI()->DoButtonLogic(&s_ClearButton, "×", 0, &QuickSearchClearButton))
|
||||||
|
{
|
||||||
|
g_Config.m_ClSkinFilterString[0] = 0;
|
||||||
|
UI()->SetActiveItem(&g_Config.m_ClSkinFilterString);
|
||||||
|
s_InitSkinlist = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue