3#ifndef GAME_CLIENT_UI_H
4#define GAME_CLIENT_UI_H
56 virtual float ToRelative(
int AbsoluteValue,
int Min,
int Max)
const = 0;
57 virtual int ToAbsolute(
float RelativeValue,
int Min,
int Max)
const = 0;
62 float ToRelative(
int AbsoluteValue,
int Min,
int Max)
const override
64 return (AbsoluteValue - Min) / (float)(Max - Min);
66 int ToAbsolute(
float RelativeValue,
int Min,
int Max)
const override
68 return round_to_int(RelativeValue * (Max - Min) + Min + 0.1f);
81 float ToRelative(
int AbsoluteValue,
int Min,
int Max)
const override
89 return (std::log(AbsoluteValue) - std::log(Min)) / (float)(std::log(Max) - std::log(Min));
91 int ToAbsolute(
float RelativeValue,
int Min,
int Max)
const override
93 int ResultAdjustment = 0;
100 return round_to_int(std::exp(RelativeValue * (std::log(Max) - std::log(Min)) + std::log(Min))) + ResultAdjustment;
115 return ColorRGBA(0.15f, 0.15f, 0.15f, 0.25f);
117 return ColorRGBA(0.5f, 0.5f, 0.5f, 0.25f);
118 return ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f);
127 return ColorRGBA(1.0f, 1.0f, 1.0f, 0.4f);
129 return ColorRGBA(1.0f, 1.0f, 1.0f, 0.6f);
130 return ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f);
139 return ColorRGBA(0.9f, 0.9f, 0.9f, 1.0f);
141 return ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f);
142 return ColorRGBA(0.8f, 0.8f, 0.8f, 1.0f);
195 void Init(
CUi *pUI,
int RequestedRectCount);
564 void DoSmoothScrollLogic(
float *pScrollOffset,
float *pScrollOffsetChange,
float ViewPortSize,
float TotalSize,
bool SmoothClamp =
false,
float ScrollSpeed = 10.0f)
const;
Definition: textrender.h:204
IClient * Client() const
Definition: ui.cpp:96
IInput * Input() const
Definition: ui.cpp:98
static void Init(CUi *pUI)
Definition: ui.h:238
ITextRender * TextRender() const
Definition: ui.cpp:99
static CUi * s_pUI
Definition: ui.h:235
IGraphics * Graphics() const
Definition: ui.cpp:97
CUi * Ui() const
Definition: ui.h:244
CUi * m_pUI
Definition: ui.h:152
bool AreRectsInit()
Definition: ui.h:202
std::vector< SUIElementRect > m_vUIRects
Definition: ui.h:190
SUIElementRect * Rect(size_t Index)
Definition: ui.h:197
CUi * Ui() const
Definition: ui.h:189
CUIElement(CUi *pUI, int RequestedRectCount)
Definition: ui.h:154
void InitRects(int RequestedRectCount)
Definition: ui.cpp:29
void Init(CUi *pUI, int RequestedRectCount)
Definition: ui.cpp:21
float m_LastClickTime
Definition: ui.h:360
vec2 m_LastClickPos
Definition: ui.h:361
const void * m_pLastClickedId
Definition: ui.h:359
bool m_AnyPressed
Definition: ui.h:335
vec2 m_PrimaryDelta
Definition: ui.h:339
float m_SecondaryActivationTime
Definition: ui.h:331
bool m_SecondaryPressedNext
Definition: ui.h:330
bool m_PrimaryPressed
Definition: ui.h:336
bool m_SecondaryPressed
Definition: ui.h:337
vec2 m_PrimaryPosition
Definition: ui.h:338
vec2 m_ScrollAmount
Definition: ui.h:340
vec2 m_SecondaryActivationDelta
Definition: ui.h:332
CLineInputNumber m_NumberInput
Definition: ui.h:373
bool m_DidScroll
Definition: ui.h:371
float m_ScrollValue
Definition: ui.h:372
const void * m_pLastTextId
Definition: ui.h:374
int m_Button
Definition: ui.h:370
void DoPopupMenu(const SPopupMenuId *pId, float X, float Y, float Width, float Height, void *pContext, FPopupMenuFunction pfnFunc, const SPopupMenuProperties &Props={})
Definition: ui.cpp:1551
void ResetUIElement(CUIElement &UIElement) const
Definition: ui.cpp:143
void ClipEnable(const CUIRect *pRect)
Definition: ui.cpp:459
EEditState DoPickerLogic(const void *pId, const CUIRect *pRect, float *pX, float *pY)
Definition: ui.cpp:617
static const CLogarithmicScrollbarScale ms_LogarithmicScrollbarScale
Definition: ui.h:427
vec2 m_UpdatedMouseDelta
Definition: ui.h:379
void FinishCheck()
Definition: ui.h:525
void RenderProgressSpinner(vec2 Center, float OuterRadius, const SProgressSpinnerProperties &Props={}) const
Definition: ui.cpp:1509
bool OnInput(const IInput::CEvent &Event)
Definition: ui.cpp:387
int DoButton_PopupMenu(CButtonContainer *pButtonContainer, const char *pText, const CUIRect *pRect, float Size, int Align, float Padding=0.0f, bool TransparentInactive=false, bool Enabled=true)
Definition: ui.cpp:1132
CTouchState m_TouchState
Definition: ui.h:386
std::function< void()> FPopupMenuClosedCallback
Definition: ui.h:321
std::vector< SPopupMenu > m_vPopupMenus
Definition: ui.h:409
void EnableMouseLock(const void *pId)
Definition: ui.h:494
vec2 m_MousePos
Definition: ui.h:380
const void * HotItem() const
Definition: ui.h:519
void DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps={}) const
Definition: ui.cpp:791
void SetPopupMenuClosedCallback(FPopupMenuClosedCallback pfnCallback)
Definition: ui.cpp:1666
bool MouseInside(const CUIRect *pRect) const
Definition: ui.cpp:270
std::vector< CUIElement * > m_vpOwnUIElements
Definition: ui.h:422
void ResetMouseSlow()
Definition: ui.h:540
unsigned m_UpdatedMouseButtons
Definition: ui.h:383
IGraphics * m_pGraphics
Definition: ui.h:418
const void * m_pActiveItem
Definition: ui.h:347
bool IsPopupHovered() const
Definition: ui.cpp:1661
unsigned m_HotkeysPressed
Definition: ui.h:391
constexpr float ButtonColorMulHot() const
Definition: ui.h:547
void SetEnabled(bool Enabled)
Definition: ui.h:470
vec2 MousePos() const
Definition: ui.h:475
void SetActiveItem(const void *pId)
Definition: ui.h:502
EHotkey
Definition: ui.h:444
@ HOTKEY_TAB
Definition: ui.h:452
@ HOTKEY_PAGE_DOWN
Definition: ui.h:456
@ HOTKEY_DELETE
Definition: ui.h:451
@ HOTKEY_SCROLL_UP
Definition: ui.h:453
@ HOTKEY_ESCAPE
Definition: ui.h:446
@ HOTKEY_END
Definition: ui.h:458
@ HOTKEY_SCROLL_DOWN
Definition: ui.h:454
@ HOTKEY_ENTER
Definition: ui.h:445
@ HOTKEY_PAGE_UP
Definition: ui.h:455
@ HOTKEY_LEFT
Definition: ui.h:449
@ HOTKEY_RIGHT
Definition: ui.h:450
@ HOTKEY_DOWN
Definition: ui.h:448
@ HOTKEY_HOME
Definition: ui.h:457
@ HOTKEY_UP
Definition: ui.h:447
int DoDropDown(CUIRect *pRect, int CurSelection, const char **pStrs, int Num, SDropDownState &State)
Definition: ui.cpp:1860
bool IsClipped() const
Definition: ui.h:558
float PixelSize()
Definition: ui.cpp:454
CScrollRegion * m_pBecomingHotScrollRegion
Definition: ui.h:351
static const CLinearScrollbarScale ms_LinearScrollbarScale
Definition: ui.h:426
bool DoEditBox(CLineInput *pLineInput, const CUIRect *pRect, float FontSize, int Corners=IGraphics::CORNER_ALL, const std::vector< STextColorSplit > &vColorSplits={})
Definition: ui.cpp:887
bool IsPopupOpen() const
Definition: ui.cpp:1651
void DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps={}, int StrLen=-1, const CTextCursor *pReadCursor=nullptr) const
Definition: ui.cpp:831
void DebugRender(float X, float Y)
Definition: ui.cpp:261
constexpr float ButtonColorMulDefault() const
Definition: ui.h:548
~CUi()
Definition: ui.cpp:120
void OnCursorMove(float X, float Y)
Definition: ui.cpp:166
static vec2 CalcAlignedCursorPos(const CUIRect *pRect, vec2 TextSize, int Align, const float *pBiggestCharHeight=nullptr)
Definition: ui.cpp:764
vec2 m_MouseWorldPos
Definition: ui.h:382
static CUi::EPopupMenuFunctionResult PopupSelection(void *pContext, CUIRect View, bool Active)
Definition: ui.cpp:1781
vec2 UpdatedMousePos() const
Definition: ui.h:484
int64_t DoValueSelector(const void *pId, const CUIRect *pRect, const char *pLabel, int64_t Current, int64_t Min, int64_t Max, const SValueSelectorProperties &Props={})
Definition: ui.cpp:1144
vec2 m_MouseDelta
Definition: ui.h:381
FPopupMenuClosedCallback m_pfnPopupMenuClosedCallback
Definition: ui.h:410
bool ConsumeHotkey(EHotkey Hotkey)
Definition: ui.cpp:380
int m_ActiveDraggableButtonLogicButton
Definition: ui.h:355
void RenderProgressBar(CUIRect ProgressBar, float Progress)
Definition: ui.cpp:1501
void UpdateTouchState(CTouchState &State) const
Definition: ui.cpp:299
IClient * m_pClient
Definition: ui.h:417
static CUi::EPopupMenuFunctionResult PopupConfirm(void *pContext, CUIRect View, bool Active)
Definition: ui.cpp:1733
IClient * Client() const
Definition: ui.h:435
vec2 MouseWorldPos() const
Definition: ui.h:481
static const CDarkButtonColorFunction ms_DarkButtonColorFunction
Definition: ui.h:428
static const CScrollBarColorFunction ms_ScrollBarColorFunction
Definition: ui.h:430
bool Enabled() const
Definition: ui.h:471
ITextRender * m_pTextRender
Definition: ui.h:420
float MouseWorldX() const
Definition: ui.h:482
bool MouseHovered(const CUIRect *pRect) const
Definition: ui.h:537
unsigned m_MouseButtons
Definition: ui.h:384
IInput * Input() const
Definition: ui.h:437
void MapScreen()
Definition: ui.cpp:448
void DisableMouseLock()
Definition: ui.h:499
void ConvertMouseMove(float *pX, float *pY, IInput::ECursorType CursorType) const
Definition: ui.cpp:275
float MouseY() const
Definition: ui.h:477
float DoScrollbarV(const void *pId, const CUIRect *pRect, float Current)
Definition: ui.cpp:1276
bool m_ActiveItemValid
Definition: ui.h:352
float ButtonColorMul(const void *pId)
Definition: ui.cpp:432
ITextRender * TextRender() const
Definition: ui.h:438
float MouseDeltaY() const
Definition: ui.h:480
void AddUIElement(CUIElement *pElement)
Definition: ui.cpp:138
unsigned m_LastMouseButtons
Definition: ui.h:385
int MouseButton(int Index) const
Definition: ui.h:486
CScrollRegion * m_pHotScrollRegion
Definition: ui.h:350
int m_ActiveButtonLogicButton
Definition: ui.h:354
static CUi::EPopupMenuFunctionResult PopupMessage(void *pContext, CUIRect View, bool Active)
Definition: ui.cpp:1681
const void * m_pLastActiveItem
Definition: ui.h:348
bool MouseInsideClip() const
Definition: ui.h:536
int DoButton_Menu(CUIElement &UIElement, const CButtonContainer *pId, const std::function< const char *()> &GetTextLambda, const CUIRect *pRect, const SMenuButtonProperties &Props={})
Definition: ui.cpp:1030
void ShowPopupMessage(float X, float Y, SMessagePopupContext *pContext)
Definition: ui.cpp:1693
void ClosePopupMenu(const SPopupMenuId *pId, bool IncludeDescendants=false)
Definition: ui.cpp:1625
bool DoDoubleClickLogic(const void *pId)
Definition: ui.cpp:602
static const CLightButtonColorFunction ms_LightButtonColorFunction
Definition: ui.h:429
void ClearHotkeys()
Definition: ui.h:543
std::vector< CUIRect > m_vClips
Definition: ui.h:395
IGraphics * Graphics() const
Definition: ui.h:436
float m_ActiveScrollbarOffset
Definition: ui.h:365
void OnWindowResize()
Definition: ui.cpp:161
EPopupMenuFunctionResult(* FPopupMenuFunction)(void *pContext, CUIRect View, bool Active)
Definition: ui.h:316
const void * m_pLastEditingItem
Definition: ui.h:364
void UpdateClipping()
Definition: ui.cpp:491
static CUi::EPopupMenuFunctionResult PopupColorPicker(void *pContext, CUIRect View, bool Active)
Definition: ui.cpp:1904
vec2 UpdatedMouseDelta() const
Definition: ui.h:485
const CScrollRegion * HotScrollRegion() const
Definition: ui.h:522
vec2 m_UpdatedMousePos
Definition: ui.h:378
float MouseDeltaX() const
Definition: ui.h:479
void ShowPopupSelection(float X, float Y, SSelectionPopupContext *pContext)
Definition: ui.cpp:1831
@ SCROLLBAR_OPTION_MULTILINE
Definition: ui.h:639
@ SCROLLBAR_OPTION_INFINITE
Definition: ui.h:637
@ SCROLLBAR_OPTION_NOCLAMPVALUE
Definition: ui.h:638
bool m_MouseSlow
Definition: ui.h:387
void SetHotScrollRegion(CScrollRegion *pId)
Definition: ui.h:518
int MouseButtonClicked(int Index) const
Definition: ui.h:487
const void * ActiveItem() const
Definition: ui.h:521
int DoDraggableButtonLogic(const void *pId, int Checked, const CUIRect *pRect, bool *pClicked, bool *pAbrupted)
Definition: ui.cpp:541
const CUIRect * Screen()
Definition: ui.cpp:441
static const float ms_FontmodHeight
Definition: ui.h:432
CUi()
Definition: ui.cpp:112
IInput * m_pInput
Definition: ui.h:419
void ShowPopupConfirm(float X, float Y, SConfirmPopupContext *pContext)
Definition: ui.cpp:1720
float DoScrollbarH(const void *pId, const CUIRect *pRect, float Current, const ColorRGBA *pColorInner=nullptr)
Definition: ui.cpp:1346
std::vector< CUIElement * > m_vpUIElements
Definition: ui.h:423
vec2 MouseDelta() const
Definition: ui.h:478
const void * m_pBecomingHotItem
Definition: ui.h:349
void OnElementsReset()
Definition: ui.cpp:153
const CUIRect * ClipArea() const
Definition: ui.cpp:485
bool CheckActiveItem(const void *pId)
Definition: ui.h:509
CUIRect m_Screen
Definition: ui.h:393
const void * m_pMouseLockId
Definition: ui.h:389
void StartCheck()
Definition: ui.h:524
SEditResult< int64_t > DoValueSelectorWithState(const void *pId, const CUIRect *pRect, const char *pLabel, int64_t Current, int64_t Min, int64_t Max, const SValueSelectorProperties &Props={})
Definition: ui.cpp:1149
void Update(vec2 MouseWorldPos=vec2(-1.0f, -1.0f))
Definition: ui.cpp:177
int DoButtonLogic(const void *pId, int Checked, const CUIRect *pRect)
Definition: ui.cpp:506
constexpr float ButtonColorMulActive() const
Definition: ui.h:546
bool CheckMouseLock()
Definition: ui.h:488
void ClipDisable()
Definition: ui.cpp:478
void Init(IKernel *pKernel)
Definition: ui.cpp:101
EPopupMenuFunctionResult
Definition: ui.h:289
@ POPUP_KEEP_OPEN
Definition: ui.h:293
@ POPUP_CLOSE_CURRENT_AND_DESCENDANTS
Definition: ui.h:303
@ POPUP_CLOSE_CURRENT
Definition: ui.h:298
void SetHotItem(const void *pId)
Definition: ui.h:501
float MouseWorldY() const
Definition: ui.h:483
CUIElement * GetNewUIElement(int RequestedRectCount)
Definition: ui.cpp:129
bool DoEditBox_Search(CLineInput *pLineInput, const CUIRect *pRect, float FontSize, bool HotkeyEnabled)
Definition: ui.cpp:1011
bool DoClearableEditBox(CLineInput *pLineInput, const CUIRect *pRect, float FontSize, int Corners=IGraphics::CORNER_ALL, const std::vector< STextColorSplit > &vColorSplits={})
Definition: ui.cpp:990
CDoubleClickState m_DoubleClickState
Definition: ui.h:363
bool m_Enabled
Definition: ui.h:344
bool m_MouseLock
Definition: ui.h:388
void DoSmoothScrollLogic(float *pScrollOffset, float *pScrollOffsetChange, float ViewPortSize, float TotalSize, bool SmoothClamp=false, float ScrollSpeed=10.0f) const
Definition: ui.cpp:658
const void * NextHotItem() const
Definition: ui.h:520
void ShowPopupColorPicker(float X, float Y, SColorPickerPopupContext *pContext)
Definition: ui.cpp:2178
const void * m_pHotItem
Definition: ui.h:346
void RenderPopupMenus()
Definition: ui.cpp:1571
CValueSelectorState m_ActiveValueSelectorState
Definition: ui.h:376
void ClosePopupMenus()
Definition: ui.cpp:1640
float m_ProgressSpinnerOffset
Definition: ui.h:366
float MouseX() const
Definition: ui.h:476
bool DoScrollbarOption(const void *pId, int *pOption, const CUIRect *pRect, const char *pStr, int Min, int Max, const IScrollbarScale *pScale=&ms_LinearScrollbarScale, unsigned Flags=0u, const char *pSuffix="")
Definition: ui.cpp:1447
Definition: graphics.h:183
@ CORNER_ALL
Definition: graphics.h:430
Definition: textrender.h:312
T x
Definition: vmath.h:19
T y
Definition: vmath.h:23
constexpr int round_to_int(float f)
Definition: math.h:14
constexpr T maximum(T a, T b)
Definition: math.h:130
CUIElement * m_pParent
Definition: ui.h:159
float m_Y
Definition: ui.h:166
CTextCursor m_Cursor
Definition: ui.h:175
float m_Height
Definition: ui.h:168
float m_Width
Definition: ui.h:167
ColorRGBA m_TextColor
Definition: ui.h:177
int m_ReadCursorGlyphCount
Definition: ui.h:173
int m_UIRectQuadContainer
Definition: ui.h:162
ColorRGBA m_TextOutlineColor
Definition: ui.h:178
void Draw(const CUIRect *pRect, ColorRGBA Color, int Corners, float Rounding)
Definition: ui.cpp:57
std::string m_Text
Definition: ui.h:172
SUIElementRect()
Definition: ui.cpp:37
float m_Rounding
Definition: ui.h:169
void Reset()
Definition: ui.cpp:39
STextContainerIndex m_UITextContainer
Definition: ui.h:163
ColorRGBA m_QuadColor
Definition: ui.h:182
int m_Corners
Definition: ui.h:170
float m_X
Definition: ui.h:165
CUIElement m_UiElement
Definition: ui.h:756
CButtonContainer m_ButtonContainer
Definition: ui.h:757
bool m_Init
Definition: ui.h:758
SSelectionPopupContext m_SelectionPopupContext
Definition: ui.h:755
T m_Value
Definition: ui.h:35
EEditState m_State
Definition: ui.h:34
float m_MaxWidth
Definition: ui.h:212
std::vector< STextColorSplit > m_vColorSplits
Definition: ui.h:216
bool m_StopAtEnd
Definition: ui.h:213
bool m_EllipsisAtEnd
Definition: ui.h:214
bool m_EnableWidthCheck
Definition: ui.h:215
int m_Segments
Definition: ui.h:265
ColorRGBA m_Color
Definition: ui.h:264
float m_Progress
Definition: ui.h:263
Definition: textrender.h:293
std::chrono::nanoseconds m_Time
Definition: ui.h:44
bool m_ScaleLabel
Definition: ui.h:41
float m_Value
Definition: ui.h:45
float m_XOffset
Definition: ui.h:47
bool m_Active
Definition: ui.h:40
float m_HOffset
Definition: ui.h:50
float m_WOffset
Definition: ui.h:49
bool m_RepositionLabel
Definition: ui.h:42
float m_YOffset
Definition: ui.h:48
int64_t m_Step
Definition: ui.h:254
ColorRGBA m_Color
Definition: ui.h:258
float m_Scale
Definition: ui.h:255
int m_HexPrefix
Definition: ui.h:257
bool m_UseScroll
Definition: ui.h:253
bool m_IsHex
Definition: ui.h:256
EEditState
Definition: ui.h:23
vector2_base< float > vec2
Definition: vmath.h:158