mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #4416
4416: Various UI/input refactoring r=def- a=Robyt3 Move duplicate `DoClearableEditBox` from menus and editor to `CUIEx`. Various minor refactoring. ## Checklist - [X] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [x] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robert.mueller@uni-siegen.de>
This commit is contained in:
commit
d456d4bc26
|
@ -60,7 +60,6 @@ bool CMenus::ms_ValueSelectorTextMode;
|
|||
|
||||
float CMenus::ms_ButtonHeight = 25.0f;
|
||||
float CMenus::ms_ListheaderHeight = 17.0f;
|
||||
float CMenus::ms_FontmodHeight = 0.8f;
|
||||
|
||||
IInput::CEvent CMenus::m_aInputEvents[MAX_INPUTEVENTS];
|
||||
int CMenus::m_NumInputEvents;
|
||||
|
@ -214,7 +213,7 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const
|
|||
|
||||
Text.HMargin(pRect->h >= 20.0f ? 2.0f : 1.0f, &Text);
|
||||
Text.HMargin((Text.h * FontFactor) / 2.0f, &Text);
|
||||
UI()->DoLabel(&Text, pText, Text.h * ms_FontmodHeight, 0, -1, AlignVertically);
|
||||
UI()->DoLabel(&Text, pText, Text.h * CUI::ms_FontmodHeight, 0, -1, AlignVertically);
|
||||
|
||||
if(MouseInsideColorPicker)
|
||||
return 0;
|
||||
|
@ -227,7 +226,7 @@ void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked,
|
|||
RenderTools()->DrawUIRect(pRect, ColorRGBA(1, 1, 1, 0.5f * UI()->ButtonColorMul(pID)), CUI::CORNER_ALL, 5.0f);
|
||||
CUIRect Temp;
|
||||
pRect->HMargin(1.0f, &Temp);
|
||||
UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0);
|
||||
UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, 0);
|
||||
}
|
||||
|
||||
int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, int AlignVertically)
|
||||
|
@ -306,7 +305,7 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co
|
|||
}
|
||||
|
||||
Rect.HMargin(2.0f, &Temp);
|
||||
UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0, -1, AlignVertically);
|
||||
UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, 0, -1, AlignVertically);
|
||||
|
||||
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
|
||||
}
|
||||
|
@ -319,7 +318,7 @@ int CMenus::DoButton_GridHeader(const void *pID, const char *pText, int Checked,
|
|||
RenderTools()->DrawUIRect(pRect, ColorRGBA(1, 1, 1, 0.5f), CUI::CORNER_T, 5.0f);
|
||||
CUIRect t;
|
||||
pRect->VSplitLeft(5.0f, 0, &t);
|
||||
UI()->DoLabel(&t, pText, pRect->h * ms_FontmodHeight, -1);
|
||||
UI()->DoLabel(&t, pText, pRect->h * CUI::ms_FontmodHeight, -1);
|
||||
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
|
||||
}
|
||||
|
||||
|
@ -340,13 +339,13 @@ int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const c
|
|||
{
|
||||
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT);
|
||||
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
|
||||
UI()->DoLabel(&c, "\xEE\x97\x8D", c.h * ms_FontmodHeight, 0, -1, 0);
|
||||
UI()->DoLabel(&c, "\xEE\x97\x8D", c.h * CUI::ms_FontmodHeight, 0, -1, 0);
|
||||
TextRender()->SetCurFont(NULL);
|
||||
}
|
||||
else
|
||||
UI()->DoLabel(&c, pBoxText, c.h * ms_FontmodHeight, 0, -1, 0);
|
||||
UI()->DoLabel(&c, pBoxText, c.h * CUI::ms_FontmodHeight, 0, -1, 0);
|
||||
TextRender()->SetRenderFlags(0);
|
||||
UI()->DoLabel(&t, pText, c.h * ms_FontmodHeight, -1);
|
||||
UI()->DoLabel(&t, pText, c.h * CUI::ms_FontmodHeight, -1);
|
||||
|
||||
return UI()->DoButtonLogic(pID, pText, 0, pRect);
|
||||
}
|
||||
|
@ -509,7 +508,7 @@ int CMenus::DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool
|
|||
if(ms_ValueSelectorTextMode && s_LastTextpID == pID)
|
||||
{
|
||||
static float s_NumberBoxID = 0;
|
||||
DoEditBox(&s_NumberBoxID, pRect, s_NumStr, sizeof(s_NumStr), 10.0f, &s_NumberBoxID, false, CUI::CORNER_ALL);
|
||||
UIEx()->DoEditBox(&s_NumberBoxID, pRect, s_NumStr, sizeof(s_NumStr), 10.0f, &s_NumberBoxID, false, CUI::CORNER_ALL);
|
||||
|
||||
UI()->SetActiveItem(&s_NumberBoxID);
|
||||
|
||||
|
@ -596,35 +595,6 @@ int CMenus::DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool
|
|||
return Current;
|
||||
}
|
||||
|
||||
int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners, const char *pEmptyText)
|
||||
{
|
||||
return m_UIEx.DoEditBox(pID, pRect, pStr, StrSize, FontSize, Offset, Hidden, Corners, pEmptyText);
|
||||
}
|
||||
|
||||
int CMenus::DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners, const char *pEmptyText)
|
||||
{
|
||||
bool ReturnValue = false;
|
||||
CUIRect EditBox;
|
||||
CUIRect ClearButton;
|
||||
pRect->VSplitRight(15.0f, &EditBox, &ClearButton);
|
||||
if(DoEditBox(pID, &EditBox, pStr, StrSize, FontSize, Offset, Hidden, Corners & ~CUI::CORNER_R, pEmptyText))
|
||||
{
|
||||
ReturnValue = true;
|
||||
}
|
||||
|
||||
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT);
|
||||
RenderTools()->DrawUIRect(&ClearButton, ColorRGBA(1, 1, 1, 0.33f * UI()->ButtonColorMul(pClearID)), Corners & ~CUI::CORNER_L, 3.0f);
|
||||
UI()->DoLabel(&ClearButton, "×", ClearButton.h * ms_FontmodHeight, 0, -1, 0);
|
||||
TextRender()->SetRenderFlags(0);
|
||||
if(UI()->DoButtonLogic(pClearID, "×", 0, &ClearButton))
|
||||
{
|
||||
pStr[0] = 0;
|
||||
UI()->SetActiveItem(pID);
|
||||
ReturnValue = true;
|
||||
}
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
int CMenus::DoKeyReader(void *pID, const CUIRect *pRect, int Key, int Modifier, int *NewModifier)
|
||||
{
|
||||
// process
|
||||
|
@ -1042,7 +1012,7 @@ void CMenus::OnInit()
|
|||
if(g_Config.m_ClSkipStartMenu)
|
||||
m_ShowStart = false;
|
||||
|
||||
m_UIEx.Init(UI(), Kernel(), RenderTools(), m_aInputEvents, &m_NumInputEvents);
|
||||
UIEx()->Init(UI(), Kernel(), RenderTools(), m_aInputEvents, &m_NumInputEvents);
|
||||
|
||||
m_RefreshButton.Init(UI(), -1);
|
||||
m_ConnectButton.Init(UI(), -1);
|
||||
|
@ -1308,7 +1278,7 @@ int CMenus::Render()
|
|||
|
||||
CUIRect Screen = *UI()->Screen();
|
||||
UI()->MapScreen();
|
||||
m_UIEx.ResetMouseSlow();
|
||||
UIEx()->ResetMouseSlow();
|
||||
|
||||
static int s_Frame = 0;
|
||||
if(s_Frame == 0)
|
||||
|
@ -1753,8 +1723,8 @@ int CMenus::Render()
|
|||
TextBox.VSplitLeft(20.0f, 0, &TextBox);
|
||||
TextBox.VSplitRight(60.0f, &TextBox, 0);
|
||||
UI()->DoLabel(&Label, Localize("Password"), 18.0f, -1);
|
||||
static float Offset = 0.0f;
|
||||
DoEditBox(&g_Config.m_Password, &TextBox, g_Config.m_Password, sizeof(g_Config.m_Password), 12.0f, &Offset, true);
|
||||
static float s_Offset = 0.0f;
|
||||
UIEx()->DoEditBox(&g_Config.m_Password, &TextBox, g_Config.m_Password, sizeof(g_Config.m_Password), 12.0f, &s_Offset, true);
|
||||
}
|
||||
else if(m_Popup == POPUP_CONNECTING)
|
||||
{
|
||||
|
@ -1984,8 +1954,8 @@ int CMenus::Render()
|
|||
TextBox.VSplitLeft(20.0f, 0, &TextBox);
|
||||
TextBox.VSplitRight(60.0f, &TextBox, 0);
|
||||
UI()->DoLabel(&Label, Localize("New name:"), 18.0f, -1);
|
||||
static float Offset = 0.0f;
|
||||
DoEditBox(&Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &Offset);
|
||||
static float s_Offset = 0.0f;
|
||||
UIEx()->DoEditBox(&s_Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &s_Offset);
|
||||
}
|
||||
#if defined(CONF_VIDEORECORDER)
|
||||
else if(m_Popup == POPUP_RENDER_DEMO)
|
||||
|
@ -2108,8 +2078,8 @@ int CMenus::Render()
|
|||
TextBox.VSplitLeft(20.0f, 0, &TextBox);
|
||||
TextBox.VSplitRight(60.0f, &TextBox, 0);
|
||||
UI()->DoLabel(&Label, Localize("Video name:"), 18.0f, -1);
|
||||
static float Offset = 0.0f;
|
||||
DoEditBox(&Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &Offset);
|
||||
static float s_Offset = 0.0f;
|
||||
UIEx()->DoEditBox(&s_Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &s_Offset);
|
||||
}
|
||||
else if(m_Popup == POPUP_REPLACE_VIDEO)
|
||||
{
|
||||
|
@ -2215,8 +2185,8 @@ int CMenus::Render()
|
|||
TextBox.VSplitLeft(20.0f, 0, &TextBox);
|
||||
TextBox.VSplitRight(60.0f, &TextBox, 0);
|
||||
UI()->DoLabel(&Label, Localize("Nickname"), 16.0f, -1);
|
||||
static float Offset = 0.0f;
|
||||
DoEditBox(&g_Config.m_PlayerName, &TextBox, g_Config.m_PlayerName, sizeof(g_Config.m_PlayerName), 12.0f, &Offset, false, CUI::CORNER_ALL, Client()->PlayerName());
|
||||
static float s_Offset = 0.0f;
|
||||
UIEx()->DoEditBox(&g_Config.m_PlayerName, &TextBox, g_Config.m_PlayerName, sizeof(g_Config.m_PlayerName), 12.0f, &s_Offset, false, CUI::CORNER_ALL, Client()->PlayerName());
|
||||
}
|
||||
else if(m_Popup == POPUP_POINTS)
|
||||
{
|
||||
|
@ -2355,7 +2325,7 @@ void CMenus::RenderThemeSelection(CUIRect MainView, bool Header)
|
|||
else // generic
|
||||
str_format(aName, sizeof(aName), "%s", Theme.m_Name.cstr());
|
||||
|
||||
UI()->DoLabel(&Item.m_Rect, aName, 16 * ms_FontmodHeight, -1);
|
||||
UI()->DoLabel(&Item.m_Rect, aName, 16 * CUI::ms_FontmodHeight, -1);
|
||||
}
|
||||
|
||||
bool ItemActive = false;
|
||||
|
@ -2410,7 +2380,7 @@ bool CMenus::OnMouseMove(float x, float y)
|
|||
if(!m_MenuActive)
|
||||
return false;
|
||||
|
||||
m_UIEx.ConvertMouseMove(&x, &y);
|
||||
UIEx()->ConvertMouseMove(&x, &y);
|
||||
|
||||
m_MousePos.x = clamp(m_MousePos.x + x, 0.f, (float)Graphics()->WindowWidth());
|
||||
m_MousePos.y = clamp(m_MousePos.y + y, 0.f, (float)Graphics()->WindowHeight());
|
||||
|
|
|
@ -75,6 +75,8 @@ class CMenus : public CComponent
|
|||
|
||||
CUIEx m_UIEx;
|
||||
|
||||
CUIEx *UIEx() { return &m_UIEx; }
|
||||
|
||||
int DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||
int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners);
|
||||
int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active);
|
||||
|
@ -91,9 +93,6 @@ class CMenus : public CComponent
|
|||
int DoButton_Icon(int ImageId, int SpriteId, const CUIRect *pRect);
|
||||
int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||
|
||||
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 = "");
|
||||
int DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden = false, int Corners = CUI::CORNER_ALL, const char *pEmptyText = "");
|
||||
|
||||
void DoButton_KeySelect(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||
int DoKeyReader(void *pID, const CUIRect *pRect, int Key, int Modifier, int *NewModifier);
|
||||
|
||||
|
@ -166,7 +165,7 @@ class CMenus : public CComponent
|
|||
if(pText == NULL)
|
||||
pText = GetTextLambda();
|
||||
NewRect.m_Text = pText;
|
||||
UI()->DoLabel(NewRect, &Text, pText, Text.h * ms_FontmodHeight, 0, -1, AlignVertically);
|
||||
UI()->DoLabel(NewRect, &Text, pText, Text.h * CUI::ms_FontmodHeight, 0, -1, AlignVertically);
|
||||
}
|
||||
}
|
||||
Graphics()->SetColor(1, 1, 1, 1);
|
||||
|
@ -305,7 +304,6 @@ protected:
|
|||
static float ms_ButtonHeight;
|
||||
static float ms_ListheaderHeight;
|
||||
static float ms_ListitemAdditionalHeight;
|
||||
static float ms_FontmodHeight;
|
||||
|
||||
// for settings
|
||||
bool m_NeedRestartGeneral;
|
||||
|
|
|
@ -190,7 +190,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
|
||||
static float s_ScrollValue = 0;
|
||||
|
||||
s_ScrollValue = m_UIEx.DoScrollbarV(&s_ScrollValue, &Scroll, s_ScrollValue);
|
||||
s_ScrollValue = UIEx()->DoScrollbarV(&s_ScrollValue, &Scroll, s_ScrollValue);
|
||||
|
||||
if(Input()->KeyPress(KEY_TAB) && m_pClient->m_GameConsole.IsClosed())
|
||||
{
|
||||
|
@ -528,11 +528,11 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
QuickSearch.VSplitLeft(SearchExcludeAddrStrMax, 0, &QuickSearch);
|
||||
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
|
||||
|
||||
static float Offset = 0.0f;
|
||||
if(Input()->KeyPress(KEY_F) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
|
||||
UI()->SetActiveItem(&g_Config.m_BrFilterString);
|
||||
static int s_ClearButton = 0;
|
||||
if(DoClearableEditBox(&g_Config.m_BrFilterString, &s_ClearButton, &QuickSearch, g_Config.m_BrFilterString, sizeof(g_Config.m_BrFilterString), 12.0f, &Offset, false, CUI::CORNER_ALL))
|
||||
static float s_Offset = 0.0f;
|
||||
if(UIEx()->DoClearableEditBox(&g_Config.m_BrFilterString, &s_ClearButton, &QuickSearch, g_Config.m_BrFilterString, sizeof(g_Config.m_BrFilterString), 12.0f, &s_Offset, false, CUI::CORNER_ALL))
|
||||
Client()->ServerBrowserUpdate();
|
||||
}
|
||||
|
||||
|
@ -553,10 +553,10 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
QuickExclude.VSplitLeft(5.0f, 0, &QuickExclude);
|
||||
|
||||
static int s_ClearButton = 0;
|
||||
static float Offset = 0.0f;
|
||||
static float s_Offset = 0.0f;
|
||||
if(Input()->KeyPress(KEY_X) && (Input()->KeyPress(KEY_LSHIFT) || Input()->KeyPress(KEY_RSHIFT)) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
|
||||
UI()->SetActiveItem(&g_Config.m_BrExcludeString);
|
||||
if(DoClearableEditBox(&g_Config.m_BrExcludeString, &s_ClearButton, &QuickExclude, g_Config.m_BrExcludeString, sizeof(g_Config.m_BrExcludeString), 12.0f, &Offset, false, CUI::CORNER_ALL))
|
||||
if(UIEx()->DoClearableEditBox(&g_Config.m_BrExcludeString, &s_ClearButton, &QuickExclude, g_Config.m_BrExcludeString, sizeof(g_Config.m_BrExcludeString), 12.0f, &s_Offset, false, CUI::CORNER_ALL))
|
||||
Client()->ServerBrowserUpdate();
|
||||
}
|
||||
|
||||
|
@ -589,8 +589,8 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
UI()->DoLabelScaled(&ServerAddr, Localize("Server address:"), 14.0f, -1);
|
||||
ServerAddr.VSplitLeft(SearchExcludeAddrStrMax + 5.0f + ExcludeSearchIconMax + 5.0f, NULL, &ServerAddr);
|
||||
static int s_ClearButton = 0;
|
||||
static float Offset = 0.0f;
|
||||
DoClearableEditBox(&g_Config.m_UiServerAddress, &s_ClearButton, &ServerAddr, g_Config.m_UiServerAddress, sizeof(g_Config.m_UiServerAddress), 12.0f, &Offset);
|
||||
static float s_Offset = 0.0f;
|
||||
UIEx()->DoClearableEditBox(&g_Config.m_UiServerAddress, &s_ClearButton, &ServerAddr, g_Config.m_UiServerAddress, sizeof(g_Config.m_UiServerAddress), 12.0f, &s_Offset);
|
||||
|
||||
// button area
|
||||
ButtonArea = ConnectButtons;
|
||||
|
@ -704,8 +704,8 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
|
|||
UI()->DoLabelScaled(&Button, Localize("Game types:"), FontSize, -1);
|
||||
Button.VSplitRight(60.0f, 0, &Button);
|
||||
ServerFilter.HSplitTop(3.0f, 0, &ServerFilter);
|
||||
static float Offset = 0.0f;
|
||||
if(DoEditBox(&g_Config.m_BrFilterGametype, &Button, g_Config.m_BrFilterGametype, sizeof(g_Config.m_BrFilterGametype), FontSize, &Offset))
|
||||
static float s_OffsetGametype = 0.0f;
|
||||
if(UIEx()->DoEditBox(&g_Config.m_BrFilterGametype, &Button, g_Config.m_BrFilterGametype, sizeof(g_Config.m_BrFilterGametype), FontSize, &s_OffsetGametype))
|
||||
Client()->ServerBrowserUpdate();
|
||||
|
||||
// server address
|
||||
|
@ -713,8 +713,8 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
|
|||
ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter);
|
||||
UI()->DoLabelScaled(&Button, Localize("Server address:"), FontSize, -1);
|
||||
Button.VSplitRight(60.0f, 0, &Button);
|
||||
static float OffsetAddr = 0.0f;
|
||||
if(DoEditBox(&g_Config.m_BrFilterServerAddress, &Button, g_Config.m_BrFilterServerAddress, sizeof(g_Config.m_BrFilterServerAddress), FontSize, &OffsetAddr))
|
||||
static float s_OffsetAddr = 0.0f;
|
||||
if(UIEx()->DoEditBox(&g_Config.m_BrFilterServerAddress, &Button, g_Config.m_BrFilterServerAddress, sizeof(g_Config.m_BrFilterServerAddress), FontSize, &s_OffsetAddr))
|
||||
Client()->ServerBrowserUpdate();
|
||||
|
||||
// player country
|
||||
|
@ -1347,7 +1347,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
|
|||
Button.VSplitLeft(80.0f, 0, &Button);
|
||||
static char s_aName[MAX_NAME_LENGTH] = {0};
|
||||
static float s_OffsetName = 0.0f;
|
||||
DoEditBox(&s_aName, &Button, s_aName, sizeof(s_aName), FontSize + 2, &s_OffsetName);
|
||||
UIEx()->DoEditBox(&s_aName, &Button, s_aName, sizeof(s_aName), FontSize + 2, &s_OffsetName);
|
||||
|
||||
ServerFriends.HSplitTop(3.0f, 0, &ServerFriends);
|
||||
ServerFriends.HSplitTop(19.0f, &Button, &ServerFriends);
|
||||
|
@ -1356,7 +1356,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
|
|||
Button.VSplitLeft(80.0f, 0, &Button);
|
||||
static char s_aClan[MAX_CLAN_LENGTH] = {0};
|
||||
static float s_OffsetClan = 0.0f;
|
||||
DoEditBox(&s_aClan, &Button, s_aClan, sizeof(s_aClan), FontSize + 2, &s_OffsetClan);
|
||||
UIEx()->DoEditBox(&s_aClan, &Button, s_aClan, sizeof(s_aClan), FontSize + 2, &s_OffsetClan);
|
||||
|
||||
ServerFriends.HSplitTop(3.0f, 0, &ServerFriends);
|
||||
ServerFriends.HSplitTop(20.0f, &Button, &ServerFriends);
|
||||
|
|
|
@ -158,8 +158,8 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
|||
TextBox.VSplitLeft(20.0f, 0, &TextBox);
|
||||
TextBox.VSplitRight(60.0f, &TextBox, 0);
|
||||
UI()->DoLabel(&Label, Localize("New name:"), 18.0f, -1);
|
||||
static float Offset = 0.0f;
|
||||
if(DoEditBox(&Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &Offset))
|
||||
static float s_Offset = 0.0f;
|
||||
if(UIEx()->DoEditBox(&s_Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &s_Offset))
|
||||
{
|
||||
m_aDemoPlayerPopupHint[0] = '\0';
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ void CMenus::UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHe
|
|||
if(Num == 0)
|
||||
gs_ListBoxScrollValue = 0;
|
||||
else
|
||||
gs_ListBoxScrollValue = m_UIEx.DoScrollbarV(pID, &Scroll, gs_ListBoxScrollValue);
|
||||
gs_ListBoxScrollValue = UIEx()->DoScrollbarV(pID, &Scroll, gs_ListBoxScrollValue);
|
||||
|
||||
// the list
|
||||
gs_ListBoxView = gs_ListBoxOriginalView;
|
||||
|
@ -1072,8 +1072,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
|||
ListBox.VSplitRight(20.0f, &ListBox, &Scroll);
|
||||
|
||||
static float s_ScrollValue = 0;
|
||||
|
||||
s_ScrollValue = m_UIEx.DoScrollbarV(&s_ScrollValue, &Scroll, s_ScrollValue);
|
||||
s_ScrollValue = UIEx()->DoScrollbarV(&s_ScrollValue, &Scroll, s_ScrollValue);
|
||||
|
||||
int PreviousIndex = m_DemolistSelectedIndex;
|
||||
HandleListInputs(ListBox, s_ScrollValue, 3.0f, &m_ScrollOffset, s_aCols[0].m_Rect.h, m_DemolistSelectedIndex, m_lDemos.size());
|
||||
|
|
|
@ -683,17 +683,13 @@ void CMenus::RenderServerControl(CUIRect MainView)
|
|||
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
|
||||
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
|
||||
static int s_ClearButton = 0;
|
||||
static float Offset = 0.0f;
|
||||
//static char aFilterString[25];
|
||||
static float s_Offset = 0.0f;
|
||||
if(m_ControlPageOpening || (Input()->KeyPress(KEY_F) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL))))
|
||||
{
|
||||
UI()->SetActiveItem(&m_aFilterString);
|
||||
m_ControlPageOpening = false;
|
||||
}
|
||||
if(DoClearableEditBox(&m_aFilterString, &s_ClearButton, &QuickSearch, m_aFilterString, sizeof(m_aFilterString), 14.0f, &Offset, false, CUI::CORNER_ALL, Localize("Search")))
|
||||
{
|
||||
// TODO: Implement here
|
||||
}
|
||||
UIEx()->DoClearableEditBox(&m_aFilterString, &s_ClearButton, &QuickSearch, m_aFilterString, sizeof(m_aFilterString), 14.0f, &s_Offset, false, CUI::CORNER_ALL, Localize("Search"));
|
||||
}
|
||||
|
||||
Bottom.VSplitRight(120.0f, &Bottom, &Button);
|
||||
|
@ -740,7 +736,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
|
|||
static float s_Offset = 0.0f;
|
||||
if(Input()->KeyPress(KEY_R) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
|
||||
UI()->SetActiveItem(&m_aCallvoteReason);
|
||||
DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), 14.0f, &s_Offset, false, CUI::CORNER_ALL);
|
||||
UIEx()->DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), 14.0f, &s_Offset, false, CUI::CORNER_ALL);
|
||||
|
||||
// extended features (only available when authed in rcon)
|
||||
if(Client()->RconAuthed())
|
||||
|
@ -811,11 +807,11 @@ void CMenus::RenderServerControl(CUIRect MainView)
|
|||
Bottom.VSplitLeft(5.0f, 0, &Bottom);
|
||||
Bottom.VSplitLeft(250.0f, &Button, &Bottom);
|
||||
static float s_OffsetDesc = 0.0f;
|
||||
DoEditBox(&s_aVoteDescription, &Button, s_aVoteDescription, sizeof(s_aVoteDescription), 14.0f, &s_OffsetDesc, false, CUI::CORNER_ALL);
|
||||
UIEx()->DoEditBox(&s_aVoteDescription, &Button, s_aVoteDescription, sizeof(s_aVoteDescription), 14.0f, &s_OffsetDesc, false, CUI::CORNER_ALL);
|
||||
|
||||
Bottom.VMargin(20.0f, &Button);
|
||||
static float s_OffsetCmd = 0.0f;
|
||||
DoEditBox(&s_aVoteCommand, &Button, s_aVoteCommand, sizeof(s_aVoteCommand), 14.0f, &s_OffsetCmd, false, CUI::CORNER_ALL);
|
||||
UIEx()->DoEditBox(&s_aVoteCommand, &Button, s_aVoteCommand, sizeof(s_aVoteCommand), 14.0f, &s_OffsetCmd, false, CUI::CORNER_ALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1035,12 +1031,11 @@ void CMenus::RenderGhost(CUIRect MainView)
|
|||
CUIRect Scroll;
|
||||
View.VSplitRight(20.0f, &View, &Scroll);
|
||||
|
||||
int NumGhosts = m_lGhosts.size();
|
||||
static float s_ScrollValue = 0;
|
||||
s_ScrollValue = UIEx()->DoScrollbarV(&s_ScrollValue, &Scroll, s_ScrollValue);
|
||||
|
||||
int NumGhosts = m_lGhosts.size();
|
||||
static int s_SelectedIndex = 0;
|
||||
|
||||
s_ScrollValue = m_UIEx.DoScrollbarV(&s_ScrollValue, &Scroll, s_ScrollValue);
|
||||
|
||||
HandleListInputs(View, s_ScrollValue, 1.0f, nullptr, s_aCols[0].m_Rect.h, s_SelectedIndex, NumGhosts);
|
||||
|
||||
// set clipping
|
||||
|
|
|
@ -161,7 +161,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Name plates size"), g_Config.m_ClNameplatesSize);
|
||||
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
|
||||
g_Config.m_ClNameplatesSize = (int)(m_UIEx.DoScrollbarH(&g_Config.m_ClNameplatesSize, &Button, g_Config.m_ClNameplatesSize / 100.0f) * 100.0f + 0.1f);
|
||||
g_Config.m_ClNameplatesSize = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClNameplatesSize, &Button, g_Config.m_ClNameplatesSize / 100.0f) * 100.0f + 0.1f);
|
||||
|
||||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClNameplatesTeamcolors, Localize("Use team colors for name plates"), g_Config.m_ClNameplatesTeamcolors, &Button))
|
||||
|
@ -179,7 +179,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Clan plates size"), g_Config.m_ClNameplatesClanSize);
|
||||
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
|
||||
g_Config.m_ClNameplatesClanSize = (int)(m_UIEx.DoScrollbarH(&g_Config.m_ClNameplatesClanSize, &Button, g_Config.m_ClNameplatesClanSize / 100.0f) * 100.0f + 0.1f);
|
||||
g_Config.m_ClNameplatesClanSize = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClNameplatesClanSize, &Button, g_Config.m_ClNameplatesClanSize / 100.0f) * 100.0f + 0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max demos"), "∞");
|
||||
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
|
||||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
g_Config.m_ClAutoDemoMax = static_cast<int>(m_UIEx.DoScrollbarH(&g_Config.m_ClAutoDemoMax, &Button, g_Config.m_ClAutoDemoMax / 1000.0f) * 1000.0f + 0.1f);
|
||||
g_Config.m_ClAutoDemoMax = static_cast<int>(UIEx()->DoScrollbarH(&g_Config.m_ClAutoDemoMax, &Button, g_Config.m_ClAutoDemoMax / 1000.0f) * 1000.0f + 0.1f);
|
||||
|
||||
Right.HSplitTop(SliderGroupMargin, 0, &Right);
|
||||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
|
@ -231,7 +231,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max Screenshots"), "∞");
|
||||
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
|
||||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
g_Config.m_ClAutoScreenshotMax = static_cast<int>(m_UIEx.DoScrollbarH(&g_Config.m_ClAutoScreenshotMax, &Button, g_Config.m_ClAutoScreenshotMax / 1000.0f) * 1000.0f + 0.1f);
|
||||
g_Config.m_ClAutoScreenshotMax = static_cast<int>(UIEx()->DoScrollbarH(&g_Config.m_ClAutoScreenshotMax, &Button, g_Config.m_ClAutoScreenshotMax / 1000.0f) * 1000.0f + 0.1f);
|
||||
}
|
||||
|
||||
Left.HSplitTop(10.0f, 0, &Left);
|
||||
|
@ -243,7 +243,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Refresh Rate"), "∞");
|
||||
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
|
||||
Left.HSplitTop(20.0f, &Button, &Left);
|
||||
g_Config.m_ClRefreshRate = static_cast<int>(m_UIEx.DoScrollbarH(&g_Config.m_ClRefreshRate, &Button, g_Config.m_ClRefreshRate / 10000.0f) * 10000.0f + 0.1f);
|
||||
g_Config.m_ClRefreshRate = static_cast<int>(UIEx()->DoScrollbarH(&g_Config.m_ClRefreshRate, &Button, g_Config.m_ClRefreshRate / 10000.0f) * 10000.0f + 0.1f);
|
||||
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
Left.HSplitTop(10.0f, 0, &Left);
|
||||
|
@ -297,7 +297,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
|
||||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
g_Config.m_ClAutoStatboardScreenshotMax =
|
||||
static_cast<int>(m_UIEx.DoScrollbarH(&g_Config.m_ClAutoStatboardScreenshotMax,
|
||||
static_cast<int>(UIEx()->DoScrollbarH(&g_Config.m_ClAutoStatboardScreenshotMax,
|
||||
&Button,
|
||||
g_Config.m_ClAutoStatboardScreenshotMax / 1000.0f) *
|
||||
1000.0f +
|
||||
|
@ -323,7 +323,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
|
||||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
g_Config.m_ClAutoCSVMax =
|
||||
static_cast<int>(m_UIEx.DoScrollbarH(&g_Config.m_ClAutoCSVMax,
|
||||
static_cast<int>(UIEx()->DoScrollbarH(&g_Config.m_ClAutoCSVMax,
|
||||
&Button,
|
||||
g_Config.m_ClAutoCSVMax / 1000.0f) *
|
||||
1000.0f +
|
||||
|
@ -366,7 +366,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name"));
|
||||
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
|
||||
static float s_OffsetName = 0.0f;
|
||||
if(DoEditBox(pName, &Button, pName, sizeof(g_Config.m_PlayerName), 14.0f, &s_OffsetName, false, CUI::CORNER_ALL, pNameFallback))
|
||||
if(UIEx()->DoEditBox(pName, &Button, pName, sizeof(g_Config.m_PlayerName), 14.0f, &s_OffsetName, false, CUI::CORNER_ALL, pNameFallback))
|
||||
{
|
||||
SetNeedSendInfo();
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Clan"));
|
||||
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
|
||||
static float s_OffsetClan = 0.0f;
|
||||
if(DoEditBox(pClan, &Button, pClan, sizeof(g_Config.m_PlayerClan), 14.0f, &s_OffsetClan))
|
||||
if(UIEx()->DoEditBox(pClan, &Button, pClan, sizeof(g_Config.m_PlayerClan), 14.0f, &s_OffsetClan))
|
||||
{
|
||||
SetNeedSendInfo();
|
||||
}
|
||||
|
@ -453,19 +453,17 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
{
|
||||
CUIRect Button, Label, Button2, Dummy, DummyLabel, SkinList, QuickSearch, QuickSearchClearButton, SkinDB, SkinPrefix, SkinPrefixLabel, DirectoryButton, RefreshButton;
|
||||
|
||||
static float s_ClSkinPrefix = 0.0f;
|
||||
|
||||
static bool s_InitSkinlist = true;
|
||||
MainView.HSplitTop(10.0f, 0, &MainView);
|
||||
|
||||
char *Skin = g_Config.m_ClPlayerSkin;
|
||||
char *pSkinName = g_Config.m_ClPlayerSkin;
|
||||
int *UseCustomColor = &g_Config.m_ClPlayerUseCustomColor;
|
||||
unsigned *ColorBody = &g_Config.m_ClPlayerColorBody;
|
||||
unsigned *ColorFeet = &g_Config.m_ClPlayerColorFeet;
|
||||
|
||||
if(m_Dummy)
|
||||
{
|
||||
Skin = g_Config.m_ClDummySkin;
|
||||
pSkinName = g_Config.m_ClDummySkin;
|
||||
UseCustomColor = &g_Config.m_ClDummyUseCustomColor;
|
||||
ColorBody = &g_Config.m_ClDummyColorBody;
|
||||
ColorFeet = &g_Config.m_ClDummyColorFeet;
|
||||
|
@ -473,7 +471,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
|
||||
// skin info
|
||||
CTeeRenderInfo OwnSkinInfo;
|
||||
const CSkin *pSkin = m_pClient->m_Skins.Get(m_pClient->m_Skins.Find(Skin));
|
||||
const CSkin *pSkin = m_pClient->m_Skins.Get(m_pClient->m_Skins.Find(pSkinName));
|
||||
OwnSkinInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin;
|
||||
OwnSkinInfo.m_ColorableRenderSkin = pSkin->m_ColorableSkin;
|
||||
OwnSkinInfo.m_SkinMetrics = pSkin->m_Metrics;
|
||||
|
@ -534,7 +532,8 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
SkinPrefix.HSplitTop(20.0f, &SkinPrefixLabel, &SkinPrefix);
|
||||
{
|
||||
static int s_ClearButton = 0;
|
||||
DoClearableEditBox(g_Config.m_ClSkinPrefix, &s_ClearButton, &SkinPrefixLabel, g_Config.m_ClSkinPrefix, sizeof(g_Config.m_ClSkinPrefix), 14.0f, &s_ClSkinPrefix);
|
||||
static float s_Offset = 0.0f;
|
||||
UIEx()->DoClearableEditBox(g_Config.m_ClSkinPrefix, &s_ClearButton, &SkinPrefixLabel, g_Config.m_ClSkinPrefix, sizeof(g_Config.m_ClSkinPrefix), 14.0f, &s_Offset);
|
||||
}
|
||||
|
||||
SkinPrefix.HSplitTop(2.0f, 0, &SkinPrefix);
|
||||
|
@ -563,10 +562,10 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
RenderTools()->RenderTee(pIdleState, &OwnSkinInfo, 0, vec2(1, 0), TeeRenderPos);
|
||||
Label.VSplitLeft(70.0f, 0, &Label);
|
||||
Label.HMargin(15.0f, &Label);
|
||||
// UI()->DoLabelScaled(&Label, Skin, 14.0f, -1, 150.0f);
|
||||
|
||||
static float s_OffsetSkin = 0.0f;
|
||||
static int s_ClearButton = 0;
|
||||
if(DoClearableEditBox(Skin, &s_ClearButton, &Label, Skin, sizeof(g_Config.m_ClPlayerSkin), 14.0f, &s_OffsetSkin, false, CUI::CORNER_ALL, "default"))
|
||||
if(UIEx()->DoClearableEditBox(pSkinName, &s_ClearButton, &Label, pSkinName, sizeof(g_Config.m_ClPlayerSkin), 14.0f, &s_OffsetSkin, false, CUI::CORNER_ALL, "default"))
|
||||
{
|
||||
SetNeedSendInfo();
|
||||
}
|
||||
|
@ -651,7 +650,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
{
|
||||
const CSkin *s = s_paSkinList[i].m_pSkin;
|
||||
|
||||
if(str_comp(s->m_aName, Skin) == 0)
|
||||
if(str_comp(s->m_aName, pSkinName) == 0)
|
||||
OldSelected = i;
|
||||
|
||||
CListboxItem Item = UiDoListboxNextItem(s_paSkinList[i].m_pSkin, OldSelected == i);
|
||||
|
@ -688,7 +687,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
const int NewSelected = UiDoListboxEnd(&s_ScrollValue, 0);
|
||||
if(OldSelected != NewSelected)
|
||||
{
|
||||
mem_copy(Skin, s_paSkinList[NewSelected].m_pSkin->m_aName, sizeof(g_Config.m_ClPlayerSkin));
|
||||
mem_copy(pSkinName, s_paSkinList[NewSelected].m_pSkin->m_aName, sizeof(g_Config.m_ClPlayerSkin));
|
||||
SetNeedSendInfo();
|
||||
}
|
||||
|
||||
|
@ -708,10 +707,10 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
|
||||
QuickSearch.VSplitLeft(QuickSearch.w - 15.0f, &QuickSearch, &QuickSearchClearButton);
|
||||
static int s_ClearButton = 0;
|
||||
static float Offset = 0.0f;
|
||||
static float s_Offset = 0.0f;
|
||||
if(Input()->KeyPress(KEY_F) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
|
||||
UI()->SetActiveItem(&g_Config.m_ClSkinFilterString);
|
||||
if(DoClearableEditBox(&g_Config.m_ClSkinFilterString, &s_ClearButton, &QuickSearch, g_Config.m_ClSkinFilterString, sizeof(g_Config.m_ClSkinFilterString), 14.0f, &Offset, false, CUI::CORNER_ALL, Localize("Search")))
|
||||
if(UIEx()->DoClearableEditBox(&g_Config.m_ClSkinFilterString, &s_ClearButton, &QuickSearch, g_Config.m_ClSkinFilterString, sizeof(g_Config.m_ClSkinFilterString), 14.0f, &s_Offset, false, CUI::CORNER_ALL, Localize("Search")))
|
||||
s_InitSkinlist = true;
|
||||
}
|
||||
|
||||
|
@ -921,7 +920,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
|
|||
Button.VSplitLeft(160.0f, &Label, &Button);
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Mouse sens."), g_Config.m_InpMousesens);
|
||||
UI()->DoLabel(&Label, aBuf, 14.0f * UI()->Scale(), -1);
|
||||
int NewValue = (int)(m_UIEx.DoScrollbarH(&g_Config.m_InpMousesens, &Button, (minimum(g_Config.m_InpMousesens, 500) - 1) / 500.0f) * 500.0f) + 1;
|
||||
int NewValue = (int)(UIEx()->DoScrollbarH(&g_Config.m_InpMousesens, &Button, (minimum(g_Config.m_InpMousesens, 500) - 1) / 500.0f) * 500.0f) + 1;
|
||||
if(g_Config.m_InpMousesens < 500 || NewValue < 500)
|
||||
g_Config.m_InpMousesens = minimum(NewValue, 500);
|
||||
MovementSettings.HSplitTop(20.0f, 0, &MovementSettings);
|
||||
|
@ -933,7 +932,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
|
|||
Button.VSplitLeft(160.0f, &Label, &Button);
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("UI mouse s."), g_Config.m_UiMousesens);
|
||||
UI()->DoLabel(&Label, aBuf, 14.0f * UI()->Scale(), -1);
|
||||
int NewValue = (int)(m_UIEx.DoScrollbarH(&g_Config.m_UiMousesens, &Button, (minimum(g_Config.m_UiMousesens, 500) - 1) / 500.0f) * 500.0f) + 1;
|
||||
int NewValue = (int)(UIEx()->DoScrollbarH(&g_Config.m_UiMousesens, &Button, (minimum(g_Config.m_UiMousesens, 500) - 1) / 500.0f) * 500.0f) + 1;
|
||||
if(g_Config.m_UiMousesens < 500 || NewValue < 500)
|
||||
g_Config.m_UiMousesens = minimum(NewValue, 500);
|
||||
MovementSettings.HSplitTop(20.0f, 0, &MovementSettings);
|
||||
|
@ -1277,7 +1276,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
|||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Refresh Rate"), "∞");
|
||||
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
|
||||
int NewRefreshRate = static_cast<int>(m_UIEx.DoScrollbarH(&g_Config.m_GfxRefreshRate, &Button, (minimum(g_Config.m_GfxRefreshRate, 1000)) / 1000.0f) * 1000.0f + 0.1f);
|
||||
int NewRefreshRate = static_cast<int>(UIEx()->DoScrollbarH(&g_Config.m_GfxRefreshRate, &Button, (minimum(g_Config.m_GfxRefreshRate, 1000)) / 1000.0f) * 1000.0f + 0.1f);
|
||||
if(g_Config.m_GfxRefreshRate <= 1000 || NewRefreshRate < 1000)
|
||||
g_Config.m_GfxRefreshRate = NewRefreshRate;
|
||||
|
||||
|
@ -1369,8 +1368,8 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||
UI()->DoLabelScaled(&Button, Localize("Sample rate"), 14.0f, -1);
|
||||
Button.VSplitLeft(190.0f, 0, &Button);
|
||||
static float Offset = 0.0f;
|
||||
DoEditBox(&g_Config.m_SndRate, &Button, aBuf, sizeof(aBuf), 14.0f, &Offset);
|
||||
static float s_Offset = 0.0f;
|
||||
UIEx()->DoEditBox(&g_Config.m_SndRate, &Button, aBuf, sizeof(aBuf), 14.0f, &s_Offset);
|
||||
g_Config.m_SndRate = maximum(1, str_toint(aBuf));
|
||||
m_NeedRestartSound = !s_SndEnable || s_SndRate != g_Config.m_SndRate;
|
||||
}
|
||||
|
@ -1382,7 +1381,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||
Button.VSplitLeft(190.0f, &Label, &Button);
|
||||
UI()->DoLabelScaled(&Label, Localize("Sound volume"), 14.0f, -1);
|
||||
g_Config.m_SndVolume = (int)(m_UIEx.DoScrollbarH(&g_Config.m_SndVolume, &Button, g_Config.m_SndVolume / 100.0f) * 100.0f);
|
||||
g_Config.m_SndVolume = (int)(UIEx()->DoScrollbarH(&g_Config.m_SndVolume, &Button, g_Config.m_SndVolume / 100.0f) * 100.0f);
|
||||
}
|
||||
|
||||
// volume slider game sounds
|
||||
|
@ -1392,7 +1391,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||
Button.VSplitLeft(190.0f, &Label, &Button);
|
||||
UI()->DoLabelScaled(&Label, Localize("Game sound volume"), 14.0f, -1);
|
||||
g_Config.m_SndGameSoundVolume = (int)(m_UIEx.DoScrollbarH(&g_Config.m_SndGameSoundVolume, &Button, g_Config.m_SndGameSoundVolume / 100.0f) * 100.0f);
|
||||
g_Config.m_SndGameSoundVolume = (int)(UIEx()->DoScrollbarH(&g_Config.m_SndGameSoundVolume, &Button, g_Config.m_SndGameSoundVolume / 100.0f) * 100.0f);
|
||||
}
|
||||
|
||||
// volume slider gui sounds
|
||||
|
@ -1402,7 +1401,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||
Button.VSplitLeft(190.0f, &Label, &Button);
|
||||
UI()->DoLabelScaled(&Label, Localize("Chat sound volume"), 14.0f, -1);
|
||||
g_Config.m_SndChatSoundVolume = (int)(m_UIEx.DoScrollbarH(&g_Config.m_SndChatSoundVolume, &Button, g_Config.m_SndChatSoundVolume / 100.0f) * 100.0f);
|
||||
g_Config.m_SndChatSoundVolume = (int)(UIEx()->DoScrollbarH(&g_Config.m_SndChatSoundVolume, &Button, g_Config.m_SndChatSoundVolume / 100.0f) * 100.0f);
|
||||
}
|
||||
|
||||
// volume slider map sounds
|
||||
|
@ -1412,7 +1411,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||
Button.VSplitLeft(190.0f, &Label, &Button);
|
||||
UI()->DoLabelScaled(&Label, Localize("Map sound volume"), 14.0f, -1);
|
||||
g_Config.m_SndMapSoundVolume = (int)(m_UIEx.DoScrollbarH(&g_Config.m_SndMapSoundVolume, &Button, g_Config.m_SndMapSoundVolume / 100.0f) * 100.0f);
|
||||
g_Config.m_SndMapSoundVolume = (int)(UIEx()->DoScrollbarH(&g_Config.m_SndMapSoundVolume, &Button, g_Config.m_SndMapSoundVolume / 100.0f) * 100.0f);
|
||||
}
|
||||
|
||||
// volume slider background music
|
||||
|
@ -1422,7 +1421,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||
Button.VSplitLeft(190.0f, &Label, &Button);
|
||||
UI()->DoLabelScaled(&Label, Localize("Background music volume"), 14.0f, -1);
|
||||
g_Config.m_SndBackgroundMusicVolume = (int)(m_UIEx.DoScrollbarH(&g_Config.m_SndBackgroundMusicVolume, &Button, g_Config.m_SndBackgroundMusicVolume / 100.0f) * 100.0f);
|
||||
g_Config.m_SndBackgroundMusicVolume = (int)(UIEx()->DoScrollbarH(&g_Config.m_SndBackgroundMusicVolume, &Button, g_Config.m_SndBackgroundMusicVolume / 100.0f) * 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2029,7 +2028,7 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool
|
|||
ColorInner = color_cast<ColorRGBA>(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], LightVal, *paComponent[3]));
|
||||
}
|
||||
|
||||
*paComponent[i] = m_UIEx.DoScrollbarH(&((char *)pColor)[i], &Button, *paComponent[i], &ColorInner);
|
||||
*paComponent[i] = UIEx()->DoScrollbarH(&((char *)pColor)[i], &Button, *paComponent[i], &ColorInner);
|
||||
}
|
||||
|
||||
*pColor = Color.Pack(Alpha);
|
||||
|
@ -2393,7 +2392,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
|
|||
str_format(aBuf, sizeof(aBuf), Localize("Default length: %d"), g_Config.m_ClReplayLength);
|
||||
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
|
||||
|
||||
int NewValue = (int)(m_UIEx.DoScrollbarH(&g_Config.m_ClReplayLength, &Button, (minimum(g_Config.m_ClReplayLength, 600) - 10) / 590.0f) * 590.0f) + 10;
|
||||
int NewValue = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClReplayLength, &Button, (minimum(g_Config.m_ClReplayLength, 600) - 10) / 590.0f) * 590.0f) + 10;
|
||||
if(g_Config.m_ClReplayLength < 600 || NewValue < 600)
|
||||
g_Config.m_ClReplayLength = minimum(NewValue, 600);
|
||||
|
||||
|
@ -2448,7 +2447,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
|
|||
Left.HSplitTop(20.0f, &Button, &Left);
|
||||
Button.VSplitLeft(120.0f, &Label, &Button);
|
||||
UI()->DoLabelScaled(&Label, Localize("Overlay entities"), 14.0f, -1);
|
||||
g_Config.m_ClOverlayEntities = (int)(m_UIEx.DoScrollbarH(&g_Config.m_ClOverlayEntities, &Button, g_Config.m_ClOverlayEntities / 100.0f) * 100.0f);
|
||||
g_Config.m_ClOverlayEntities = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClOverlayEntities, &Button, g_Config.m_ClOverlayEntities / 100.0f) * 100.0f);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2458,7 +2457,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
|
|||
|
||||
Button.VSplitLeft(50.0f, &Label, &Button);
|
||||
UI()->DoLabelScaled(&Label, Localize("Size"), 14.0f, -1);
|
||||
g_Config.m_ClTextEntitiesSize = (int)(m_UIEx.DoScrollbarH(&g_Config.m_ClTextEntitiesSize, &Button, g_Config.m_ClTextEntitiesSize / 100.0f) * 100.0f);
|
||||
g_Config.m_ClTextEntitiesSize = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClTextEntitiesSize, &Button, g_Config.m_ClTextEntitiesSize / 100.0f) * 100.0f);
|
||||
|
||||
if(DoButton_CheckBox(&g_Config.m_ClTextEntities, Localize("Show text entities"), g_Config.m_ClTextEntities, &LeftLeft))
|
||||
{
|
||||
|
@ -2473,7 +2472,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
|
|||
|
||||
Button.VSplitLeft(50.0f, &Label, &Button);
|
||||
UI()->DoLabelScaled(&Label, Localize("Alpha"), 14.0f, -1);
|
||||
g_Config.m_ClShowOthersAlpha = (int)(m_UIEx.DoScrollbarH(&g_Config.m_ClShowOthersAlpha, &Button, g_Config.m_ClShowOthersAlpha / 100.0f) * 100.0f);
|
||||
g_Config.m_ClShowOthersAlpha = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClShowOthersAlpha, &Button, g_Config.m_ClShowOthersAlpha / 100.0f) * 100.0f);
|
||||
|
||||
if(DoButton_CheckBox(&g_Config.m_ClShowOthers, Localize("Show others"), g_Config.m_ClShowOthers == 1, &LeftLeft))
|
||||
{
|
||||
|
@ -2500,7 +2499,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
|
|||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Default zoom"), g_Config.m_ClDefaultZoom);
|
||||
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
|
||||
g_Config.m_ClDefaultZoom = static_cast<int>(m_UIEx.DoScrollbarH(&g_Config.m_ClDefaultZoom, &Button, g_Config.m_ClDefaultZoom / 20.0f) * 20.0f + 0.1f);
|
||||
g_Config.m_ClDefaultZoom = static_cast<int>(UIEx()->DoScrollbarH(&g_Config.m_ClDefaultZoom, &Button, g_Config.m_ClDefaultZoom / 20.0f) * 20.0f + 0.1f);
|
||||
|
||||
Right.HSplitTop(20.0f, &Button, &Right);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClAntiPing, Localize("AntiPing"), g_Config.m_ClAntiPing, &Button))
|
||||
|
@ -2586,13 +2585,13 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
|
|||
ColorRGBA GreyDefault(0.5f, 0.5f, 0.5f, 1);
|
||||
DoLine_ColorPicker(&ResetID2, 25.0f, 194.0f, 13.0f, 5.0f, &Left, Localize("Entities Background color"), &g_Config.m_ClBackgroundEntitiesColor, GreyDefault, false);
|
||||
|
||||
static float s_Map = 0.0f;
|
||||
Left.VSplitLeft(5.0f, 0x0, &Left);
|
||||
Left.HSplitTop(25.0f, &Background, &Left);
|
||||
Background.HSplitTop(20.0f, &Background, 0);
|
||||
Background.VSplitLeft(100.0f, &Label, &TempLabel);
|
||||
UI()->DoLabelScaled(&Label, Localize("Map"), 14.0f, -1);
|
||||
DoEditBox(g_Config.m_ClBackgroundEntities, &TempLabel, g_Config.m_ClBackgroundEntities, sizeof(g_Config.m_ClBackgroundEntities), 14.0f, &s_Map);
|
||||
static float s_Map = 0.0f;
|
||||
UIEx()->DoEditBox(g_Config.m_ClBackgroundEntities, &TempLabel, g_Config.m_ClBackgroundEntities, sizeof(g_Config.m_ClBackgroundEntities), 14.0f, &s_Map);
|
||||
|
||||
Left.HSplitTop(20.0f, &Button, &Left);
|
||||
bool UseCurrentMap = str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP) == 0;
|
||||
|
|
|
@ -520,10 +520,10 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
|
|||
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
|
||||
QuickSearch.VSplitLeft(QuickSearch.w - 15.0f, &QuickSearch, &QuickSearchClearButton);
|
||||
static int s_ClearButton = 0;
|
||||
static float Offset = 0.0f;
|
||||
static float s_Offset = 0.0f;
|
||||
if(Input()->KeyPress(KEY_F) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
|
||||
UI()->SetActiveItem(&s_aFilterString[s_CurCustomTab]);
|
||||
if(DoClearableEditBox(&s_aFilterString[s_CurCustomTab], &s_ClearButton, &QuickSearch, s_aFilterString[s_CurCustomTab], sizeof(s_aFilterString[0]), 14.0f, &Offset, false, CUI::CORNER_ALL, Localize("Search")))
|
||||
if(UIEx()->DoClearableEditBox(&s_aFilterString[s_CurCustomTab], &s_ClearButton, &QuickSearch, s_aFilterString[s_CurCustomTab], sizeof(s_aFilterString[0]), 14.0f, &s_Offset, false, CUI::CORNER_ALL, Localize("Search")))
|
||||
s_InitCustomList[s_CurCustomTab] = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ void CGameClient::OnInit()
|
|||
m_pGraphics->AddWindowResizeListener(OnWindowResizeCB, this);
|
||||
|
||||
// propagate pointers
|
||||
m_UI.SetGraphics(Graphics(), TextRender());
|
||||
m_UI.Init(Graphics(), TextRender());
|
||||
|
||||
m_RenderTools.Init(Graphics(), UI(), this);
|
||||
|
||||
|
|
|
@ -42,6 +42,14 @@ void CUIElement::SUIElementRect::Reset()
|
|||
UI
|
||||
*********************************************************/
|
||||
|
||||
float CUI::ms_FontmodHeight = 0.8f;
|
||||
|
||||
void CUI::Init(class IGraphics *pGraphics, class ITextRender *pTextRender)
|
||||
{
|
||||
m_pGraphics = pGraphics;
|
||||
m_pTextRender = pTextRender;
|
||||
}
|
||||
|
||||
CUI::CUI()
|
||||
{
|
||||
m_pHotItem = 0;
|
||||
|
|
|
@ -197,12 +197,10 @@ class CUI
|
|||
std::vector<CUIElement *> m_UIElements;
|
||||
|
||||
public:
|
||||
static float ms_FontmodHeight;
|
||||
|
||||
// TODO: Refactor: Fill this in
|
||||
void SetGraphics(class IGraphics *pGraphics, class ITextRender *pTextRender)
|
||||
{
|
||||
m_pGraphics = pGraphics;
|
||||
m_pTextRender = pTextRender;
|
||||
}
|
||||
void Init(class IGraphics *pGraphics, class ITextRender *pTextRender);
|
||||
class IGraphics *Graphics() const { return m_pGraphics; }
|
||||
class ITextRender *TextRender() const { return m_pTextRender; }
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ float CUIEx::DoScrollbarH(const void *pID, const CUIRect *pRect, float Current,
|
|||
return ReturnValue;
|
||||
}
|
||||
|
||||
int CUIEx::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners, const char *pEmptyText)
|
||||
bool CUIEx::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners, const char *pEmptyText)
|
||||
{
|
||||
int Inside = UI()->MouseInside(pRect);
|
||||
bool ReturnValue = false;
|
||||
|
@ -334,11 +334,10 @@ int CUIEx::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSi
|
|||
|
||||
for(int i = 0; i < *m_pInputEventCount; i++)
|
||||
{
|
||||
int32_t ManipulateChanges = 0;
|
||||
int LastCursor = m_CurCursor;
|
||||
int Len = str_length(pStr);
|
||||
int NumChars = Len;
|
||||
ManipulateChanges = CLineInput::Manipulate(m_pInputEventsArray[i], pStr, StrSize, StrSize, &Len, &m_CurCursor, &NumChars, m_HasSelection ? CLineInput::LINE_INPUT_MODIFY_DONT_DELETE : 0, IsCtrlPressed ? KEY_LCTRL : 0);
|
||||
int Len, NumChars;
|
||||
str_utf8_stats(pStr, StrSize, StrSize, &Len, &NumChars);
|
||||
int32_t ManipulateChanges = CLineInput::Manipulate(m_pInputEventsArray[i], pStr, StrSize, StrSize, &Len, &m_CurCursor, &NumChars, m_HasSelection ? CLineInput::LINE_INPUT_MODIFY_DONT_DELETE : 0, IsCtrlPressed ? KEY_LCTRL : 0);
|
||||
ReturnValue |= (ManipulateChanges & (CLineInput::LINE_INPUT_CHANGE_STRING | CLineInput::LINE_INPUT_CHANGE_CHARACTERS_DELETE)) != 0;
|
||||
|
||||
// if cursor changed, reset selection
|
||||
|
@ -519,26 +518,26 @@ int CUIEx::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSi
|
|||
if(UI()->LastActiveItem() == pID && !JustGotActive && (UpdateOffset || *m_pInputEventCount))
|
||||
{
|
||||
float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, DispCursorPos, std::numeric_limits<float>::max());
|
||||
if(w - *Offset > Textbox.w)
|
||||
if(w - *pOffset > Textbox.w)
|
||||
{
|
||||
// move to the left
|
||||
float wt = TextRender()->TextWidth(0, FontSize, pDisplayStr, -1, std::numeric_limits<float>::max());
|
||||
do
|
||||
{
|
||||
*Offset += minimum(wt - *Offset - Textbox.w, Textbox.w / 3);
|
||||
} while(w - *Offset > Textbox.w + 0.0001f);
|
||||
*pOffset += minimum(wt - *pOffset - Textbox.w, Textbox.w / 3);
|
||||
} while(w - *pOffset > Textbox.w + 0.0001f);
|
||||
}
|
||||
else if(w - *Offset < 0.0f)
|
||||
else if(w - *pOffset < 0.0f)
|
||||
{
|
||||
// move to the right
|
||||
do
|
||||
{
|
||||
*Offset = maximum(0.0f, *Offset - Textbox.w / 3);
|
||||
} while(w - *Offset < -0.0001f);
|
||||
*pOffset = maximum(0.0f, *pOffset - Textbox.w / 3);
|
||||
} while(w - *pOffset < -0.0001f);
|
||||
}
|
||||
}
|
||||
UI()->ClipEnable(pRect);
|
||||
Textbox.x -= *Offset;
|
||||
Textbox.x -= *pOffset;
|
||||
|
||||
CTextCursor SelCursor;
|
||||
TextRender()->SetCursor(&SelCursor, 0, 0, 16, 0);
|
||||
|
@ -612,3 +611,23 @@ int CUIEx::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSi
|
|||
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
bool CUIEx::DoClearableEditBox(const void *pID, const void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners, const char *pEmptyText)
|
||||
{
|
||||
CUIRect EditBox;
|
||||
CUIRect ClearButton;
|
||||
pRect->VSplitRight(15.0f, &EditBox, &ClearButton);
|
||||
bool ReturnValue = DoEditBox(pID, &EditBox, pStr, StrSize, FontSize, pOffset, Hidden, Corners & ~CUI::CORNER_R, pEmptyText);
|
||||
|
||||
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT);
|
||||
RenderTools()->DrawUIRect(&ClearButton, ColorRGBA(1, 1, 1, 0.33f * UI()->ButtonColorMul(pClearID)), Corners & ~CUI::CORNER_L, 3.0f);
|
||||
UI()->DoLabel(&ClearButton, "×", ClearButton.h * CUI::ms_FontmodHeight, 0, -1, 0);
|
||||
TextRender()->SetRenderFlags(0);
|
||||
if(UI()->DoButtonLogic(pClearID, "×", 0, &ClearButton))
|
||||
{
|
||||
pStr[0] = 0;
|
||||
UI()->SetActiveItem(pID);
|
||||
ReturnValue = true;
|
||||
}
|
||||
return ReturnValue;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class CUIEx
|
|||
bool m_MouseSlow;
|
||||
int m_CurSelStart = 0;
|
||||
int m_CurSelEnd = 0;
|
||||
void *m_pSelItem = nullptr;
|
||||
const void *m_pSelItem = NULL;
|
||||
|
||||
int m_CurCursor = 0;
|
||||
|
||||
|
@ -57,7 +57,9 @@ public:
|
|||
|
||||
float DoScrollbarV(const void *pID, const CUIRect *pRect, float Current);
|
||||
float DoScrollbarH(const void *pID, const CUIRect *pRect, float Current, const ColorRGBA *pColorInner = NULL);
|
||||
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 = "");
|
||||
|
||||
bool DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = CUI::CORNER_ALL, const char *pEmptyText = "");
|
||||
bool DoClearableEditBox(const void *pID, const void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = CUI::CORNER_ALL, const char *pEmptyText = "");
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -304,33 +304,18 @@ void CEditor::EnvelopeEval(int TimeOffsetMillis, int Env, float *pChannels, void
|
|||
OTHER
|
||||
*********************************************************/
|
||||
|
||||
int CEditor::DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners)
|
||||
{
|
||||
bool ReturnValue = false;
|
||||
CUIRect EditBox;
|
||||
CUIRect ClearButton;
|
||||
pRect->VSplitRight(15.0f, &EditBox, &ClearButton);
|
||||
if(DoEditBox(pID, &EditBox, pStr, StrSize, FontSize, Offset, Hidden, Corners & ~CUI::CORNER_R))
|
||||
{
|
||||
ReturnValue = true;
|
||||
}
|
||||
|
||||
RenderTools()->DrawUIRect(&ClearButton, ColorRGBA(1, 1, 1, 0.33f * UI()->ButtonColorMul(pClearID)), Corners & ~CUI::CORNER_L, 3.0f);
|
||||
UI()->DoLabel(&ClearButton, "×", ClearButton.h * 0.8f, 0);
|
||||
if(UI()->DoButtonLogic(pClearID, "×", 0, &ClearButton))
|
||||
{
|
||||
pStr[0] = 0;
|
||||
UI()->SetActiveItem(pID);
|
||||
ReturnValue = true;
|
||||
}
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
int CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners)
|
||||
bool CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners)
|
||||
{
|
||||
if(UI()->LastActiveItem() == pID)
|
||||
m_EditBoxActive = 2;
|
||||
return m_UIEx.DoEditBox(pID, pRect, pStr, StrSize, FontSize, Offset, Hidden, Corners);
|
||||
return UIEx()->DoEditBox(pID, pRect, pStr, StrSize, FontSize, pOffset, Hidden, Corners);
|
||||
}
|
||||
|
||||
bool CEditor::DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners)
|
||||
{
|
||||
if(UI()->LastActiveItem() == pID)
|
||||
m_EditBoxActive = 2;
|
||||
return UIEx()->DoClearableEditBox(pID, pClearID, pRect, pStr, StrSize, FontSize, pOffset, Hidden, Corners);
|
||||
}
|
||||
|
||||
ColorRGBA CEditor::GetButtonColor(const void *pID, int Checked)
|
||||
|
@ -4163,8 +4148,8 @@ void CEditor::RenderFileDialog()
|
|||
if(m_FileDialogStorageType == IStorage::TYPE_SAVE)
|
||||
{
|
||||
// filebox
|
||||
static float s_FileBoxID = 0;
|
||||
UI()->DoLabel(&FileBoxLabel, "Filename:", 10.0f, -1, -1);
|
||||
static float s_FileBoxID = 0;
|
||||
if(DoEditBox(&s_FileBoxID, &FileBox, m_aFileDialogFileName, sizeof(m_aFileDialogFileName), 10.0f, &s_FileBoxID))
|
||||
{
|
||||
// remove '/' and '\'
|
||||
|
@ -4184,9 +4169,9 @@ void CEditor::RenderFileDialog()
|
|||
CUIRect ClearBox;
|
||||
FileBox.VSplitRight(15, &FileBox, &ClearBox);
|
||||
|
||||
static float s_SearchBoxID = 0;
|
||||
UI()->DoLabel(&FileBoxLabel, "Search:", 10.0f, -1, -1);
|
||||
str_copy(m_aFileDialogPrevSearchText, m_aFileDialogSearchText, sizeof(m_aFileDialogPrevSearchText));
|
||||
static float s_SearchBoxID = 0;
|
||||
DoEditBox(&s_SearchBoxID, &FileBox, m_aFileDialogSearchText, sizeof(m_aFileDialogSearchText), 10.0f, &s_SearchBoxID, false, CUI::CORNER_L);
|
||||
if(m_FileDialogOpening)
|
||||
UI()->SetActiveItem(&s_SearchBoxID);
|
||||
|
@ -4425,7 +4410,7 @@ void CEditor::RenderFileDialog()
|
|||
ButtonBar.VSplitLeft(70.0f, &Button, &ButtonBar);
|
||||
if(DoButton_Editor(&s_NewFolderButton, "New folder", 0, &Button, 0, 0))
|
||||
{
|
||||
m_FileDialogNewFolderName[0] = 0;
|
||||
m_aFileDialogNewFolderName[0] = 0;
|
||||
m_FileDialogErrString[0] = 0;
|
||||
static int s_NewFolderPopupID = 0;
|
||||
UiInvokePopupMenu(&s_NewFolderPopupID, 0, Width / 2.0f - 200.0f, Height / 2.0f - 100.0f, 400.0f, 200.0f, PopupNewFolder);
|
||||
|
@ -5200,9 +5185,6 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
}
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
static float s_ValNumber = 0;
|
||||
static float s_TimeNumber = 0;
|
||||
|
||||
CUIRect ToolBar1;
|
||||
CUIRect ToolBar2;
|
||||
|
||||
|
@ -5222,7 +5204,9 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
UI()->DoLabel(&Label2, "Time (in s):", 10.0f, -1, -1);
|
||||
}
|
||||
|
||||
static float s_ValNumber = 0;
|
||||
DoEditBox(&s_ValNumber, &ToolBar1, s_aStrCurValue, sizeof(s_aStrCurValue), 10.0f, &s_ValNumber);
|
||||
static float s_TimeNumber = 0;
|
||||
DoEditBox(&s_TimeNumber, &ToolBar2, s_aStrCurTime, sizeof(s_aStrCurTime), 10.0f, &s_TimeNumber);
|
||||
}
|
||||
}
|
||||
|
@ -6145,11 +6129,11 @@ void CEditor::Init()
|
|||
m_pStorage = Kernel()->RequestInterface<IStorage>();
|
||||
m_pSound = Kernel()->RequestInterface<ISound>();
|
||||
CGameClient *pGameClient = (CGameClient *)Kernel()->RequestInterface<IGameClient>();
|
||||
m_UI.Init(m_pGraphics, m_pTextRender);
|
||||
m_RenderTools.Init(m_pGraphics, &m_UI, pGameClient);
|
||||
m_UI.SetGraphics(m_pGraphics, m_pTextRender);
|
||||
m_Map.m_pEditor = this;
|
||||
|
||||
m_UIEx.Init(UI(), Kernel(), RenderTools(), Input()->GetEventsRaw(), Input()->GetEventCountRaw());
|
||||
UIEx()->Init(UI(), Kernel(), RenderTools(), Input()->GetEventsRaw(), Input()->GetEventCountRaw());
|
||||
|
||||
m_CheckerTexture = Graphics()->LoadTexture("editor/checker.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
m_BackgroundTexture = Graphics()->LoadTexture("editor/background.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
|
@ -6242,8 +6226,8 @@ void CEditor::UpdateAndRender()
|
|||
float rx = 0, ry = 0;
|
||||
{
|
||||
Input()->MouseRelative(&rx, &ry);
|
||||
m_UIEx.ConvertMouseMove(&rx, &ry);
|
||||
m_UIEx.ResetMouseSlow();
|
||||
UIEx()->ConvertMouseMove(&rx, &ry);
|
||||
UIEx()->ResetMouseSlow();
|
||||
|
||||
m_MouseDeltaX = rx;
|
||||
m_MouseDeltaY = ry;
|
||||
|
|
|
@ -868,7 +868,7 @@ public:
|
|||
int m_FileDialogFileType;
|
||||
float m_FileDialogScrollValue;
|
||||
int m_FilesSelectedIndex;
|
||||
char m_FileDialogNewFolderName[64];
|
||||
char m_aFileDialogNewFolderName[64];
|
||||
char m_FileDialogErrString[64];
|
||||
IGraphics::CTextureHandle m_FilePreviewImage;
|
||||
bool m_PreviewImageIsLoaded;
|
||||
|
@ -970,8 +970,8 @@ public:
|
|||
|
||||
int DoButton_ColorPicker(const void *pID, const CUIRect *pRect, ColorRGBA *pColor, const char *pToolTip = 0);
|
||||
|
||||
int DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners);
|
||||
int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden = false, int Corners = CUI::CORNER_ALL);
|
||||
bool DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = CUI::CORNER_ALL);
|
||||
bool DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners);
|
||||
|
||||
void RenderBackground(CUIRect View, IGraphics::CTextureHandle Texture, float Size, float Brightness);
|
||||
|
||||
|
|
|
@ -306,9 +306,9 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
{
|
||||
View.HSplitBottom(5.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static float s_Name = 0;
|
||||
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, -1, -1);
|
||||
Button.VSplitLeft(40.0f, 0, &Button);
|
||||
static float s_Name = 0;
|
||||
if(pEditor->DoEditBox(&s_Name, &Button, pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_aName, sizeof(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_aName), 10.0f, &s_Name))
|
||||
pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
|
@ -421,9 +421,9 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
{
|
||||
View.HSplitBottom(5.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static float s_Name = 0;
|
||||
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, -1, -1);
|
||||
Button.VSplitLeft(40.0f, 0, &Button);
|
||||
static float s_Name = 0;
|
||||
if(pEditor->DoEditBox(&s_Name, &Button, pEditor->GetSelectedLayer(0)->m_aName, sizeof(pEditor->GetSelectedLayer(0)->m_aName), 10.0f, &s_Name))
|
||||
pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
|
@ -987,7 +987,7 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
View.VMargin(40.0f, &View);
|
||||
View.HSplitBottom(20.0f, &View, &Label);
|
||||
static float s_FolderBox = 0;
|
||||
pEditor->DoEditBox(&s_FolderBox, &Label, pEditor->m_FileDialogNewFolderName, sizeof(pEditor->m_FileDialogNewFolderName), 15.0f, &s_FolderBox);
|
||||
pEditor->DoEditBox(&s_FolderBox, &Label, pEditor->m_aFileDialogNewFolderName, sizeof(pEditor->m_aFileDialogNewFolderName), 15.0f, &s_FolderBox);
|
||||
View.HSplitBottom(20.0f, &View, &Label);
|
||||
pEditor->UI()->DoLabel(&Label, "Name:", 10.0f, -1);
|
||||
|
||||
|
@ -998,10 +998,10 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
if(pEditor->DoButton_Editor(&s_CreateButton, "Create", 0, &Label, 0, 0) || pEditor->Input()->KeyPress(KEY_RETURN) || pEditor->Input()->KeyPress(KEY_KP_ENTER))
|
||||
{
|
||||
// create the folder
|
||||
if(*pEditor->m_FileDialogNewFolderName)
|
||||
if(pEditor->m_aFileDialogNewFolderName[0])
|
||||
{
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "%s/%s", pEditor->m_pFileDialogPath, pEditor->m_FileDialogNewFolderName);
|
||||
str_format(aBuf, sizeof(aBuf), "%s/%s", pEditor->m_pFileDialogPath, pEditor->m_aFileDialogNewFolderName);
|
||||
if(pEditor->Storage()->CreateFolder(aBuf, IStorage::TYPE_SAVE))
|
||||
{
|
||||
pEditor->FilelistPopulate(IStorage::TYPE_SAVE);
|
||||
|
|
Loading…
Reference in a new issue