mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Show the function of search and exclusion edit boxes when empty (Suggestion by Saavik)
This commit is contained in:
parent
5882dec451
commit
ebf331febb
|
@ -223,7 +223,7 @@ int CMenus::DoButton_CheckBox_Number(const void *pID, const char *pText, int Che
|
|||
return DoButton_CheckBox_Common(pID, pText, aBuf, pRect);
|
||||
}
|
||||
|
||||
int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners)
|
||||
int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners, const char *pEmptyText)
|
||||
{
|
||||
int Inside = UI()->MouseInside(pRect);
|
||||
bool ReturnValue = false;
|
||||
|
@ -326,9 +326,15 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
|
|||
const char *pDisplayStr = pStr;
|
||||
char aStars[128];
|
||||
|
||||
if(pDisplayStr[0] == '\0')
|
||||
{
|
||||
pDisplayStr = pEmptyText;
|
||||
TextRender()->TextColor(1, 1, 1, 0.75f);
|
||||
}
|
||||
|
||||
if(Hidden)
|
||||
{
|
||||
unsigned s = str_length(pStr);
|
||||
unsigned s = str_length(pDisplayStr);
|
||||
if(s >= sizeof(aStars))
|
||||
s = sizeof(aStars)-1;
|
||||
for(unsigned int i = 0; i < s; ++i)
|
||||
|
@ -366,6 +372,8 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
|
|||
|
||||
UI()->DoLabel(&Textbox, pDisplayStr, FontSize, -1);
|
||||
|
||||
TextRender()->TextColor(1, 1, 1, 1);
|
||||
|
||||
// render the cursor
|
||||
if(UI()->LastActiveItem() == pID && !JustGotActive)
|
||||
{
|
||||
|
|
|
@ -64,7 +64,7 @@ class CMenus : public CComponent
|
|||
static void ui_draw_checkbox(const void *id, const char *text, int checked, const CUIRect *r, const void *extra);
|
||||
static void ui_draw_checkbox_number(const void *id, const char *text, int checked, const CUIRect *r, const void *extra);
|
||||
*/
|
||||
int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden=false, int Corners=CUI::CORNER_ALL);
|
||||
int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden=false, int Corners=CUI::CORNER_ALL, const char *pEmptyText = "");
|
||||
//static int ui_do_edit_box(void *id, const CUIRect *rect, char *str, unsigned str_size, float font_size, bool hidden=false);
|
||||
|
||||
float DoScrollbarV(const void *pID, const CUIRect *pRect, float Current);
|
||||
|
|
|
@ -517,7 +517,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
|
||||
QuickSearch.VSplitLeft(QuickSearch.w-15.0f, &QuickSearch, &Button);
|
||||
static float Offset = 0.0f;
|
||||
if(DoEditBox(&g_Config.m_BrFilterString, &QuickSearch, g_Config.m_BrFilterString, sizeof(g_Config.m_BrFilterString), 12.0f, &Offset, false, CUI::CORNER_L))
|
||||
if(DoEditBox(&g_Config.m_BrFilterString, &QuickSearch, g_Config.m_BrFilterString, sizeof(g_Config.m_BrFilterString), 12.0f, &Offset, false, CUI::CORNER_L, Localize("Search")))
|
||||
Client()->ServerBrowserUpdate();
|
||||
}
|
||||
|
||||
|
@ -543,7 +543,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
QuickExclude.VSplitLeft(5.0f, 0, &QuickExclude);
|
||||
QuickExclude.VSplitLeft(QuickExclude.w-15.0f, &QuickExclude, &Button);
|
||||
static float Offset = 0.0f;
|
||||
if(DoEditBox(&g_Config.m_BrExcludeString, &QuickExclude, g_Config.m_BrExcludeString, sizeof(g_Config.m_BrExcludeString), 12.0f, &Offset, false, CUI::CORNER_L))
|
||||
if(DoEditBox(&g_Config.m_BrExcludeString, &QuickExclude, g_Config.m_BrExcludeString, sizeof(g_Config.m_BrExcludeString), 12.0f, &Offset, false, CUI::CORNER_L, Localize("Exclude")))
|
||||
Client()->ServerBrowserUpdate();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue