diff --git a/Source/UI/Buttons/UIRadioButton.h b/Source/UI/Buttons/UIRadioButton.h index d98b3ca7..87e9fc4d 100644 --- a/Source/UI/Buttons/UIRadioButton.h +++ b/Source/UI/Buttons/UIRadioButton.h @@ -24,6 +24,7 @@ public: /* 0150 */ std::function onSelect; void SetOnSelect(std::function callback); + void Slot25(int x, int y) override; }; class CUIRadioItem : public CUIControl { diff --git a/Source/UI/Window/UIControl.cpp b/Source/UI/Window/UIControl.cpp index 603daed8..85b8d6b8 100644 --- a/Source/UI/Window/UIControl.cpp +++ b/Source/UI/Window/UIControl.cpp @@ -689,6 +689,16 @@ void CUITextButton::Slot28(int, int) { reinterpret_cast(g_modeMgr.gameMode)->Show(this->fullText.c_str(), screenX, screenY, 0xFFFFFFFFu, 0, 1); } +// OFFSET: 0x009ED360 +// FUNCTION: fn_14571 +void CUITextButton::SetTextColors(std::uint32_t normal, std::uint32_t hover, std::uint32_t pressed, std::uint32_t disabled) { + this->textColors[0] = normal; + this->textColors[1] = hover; + this->textColors[2] = pressed; + this->disabledTextColor = disabled; + this->Invalidate(); +} + // OFFSET: 0x009ED430 // FUNCTION: fn_14574 void CUITextButton::SetOutline(bool enabled, std::uint32_t color) { @@ -710,6 +720,16 @@ void CUIBasicButton::Resize(int width, int height) { this->Slot53(0); } +// OFFSET: 0x009E1DE0 +// FUNCTION: fn_14403 +void CUIBasicButton::Create(int width, int height) { + this->defaultWidth = width; + this->SetAlign(6, 6); + this->Resize(width, height); + this->Slot15(width, height); + this->Slot16(); +} + // OFFSET: 0x009E1F90 // FUNCTION: fn_14405 void CUIBasicButton::Paint() { @@ -1595,6 +1615,34 @@ bool CUIPadding::CanHitTest() { return false; } +// OFFSET: 0x009EAE20 +// FUNCTION: fn_14543 +void CUIRadioButton::Slot25(int, int) { + if (this->disabled) { + return; + } + + g_windowMgr.SetCapture(this); + if (this->checked) { + return; + } + + if (this->parent) { + std::list UIWindow::*const children = &CUIRadioButton::m_children; + for (UIWindow* child : this->parent->*children) { + CUIRadioButton* button = dynamic_cast(child); + if (button) { + button->checked = this == button; + button->Invalidate(); + } + } + } + + if (this->onSelect) { + this->onSelect(this); + } +} + // OFFSET: 0x009EA1B0 // FUNCTION: fn_14514 void CUIPadding::Paint() { diff --git a/Source/UI/Window/UIControl.h b/Source/UI/Window/UIControl.h index 2a26ba7e..5c584e1c 100644 --- a/Source/UI/Window/UIControl.h +++ b/Source/UI/Window/UIControl.h @@ -135,13 +135,14 @@ public: void SetShadow(bool enabled, std::uint32_t color); void SetOutline(bool enabled, std::uint32_t color); void UpdateText(); - void SetAlign(int horizontal, int vertical); + __declspec(noinline) void SetAlign(int horizontal, int vertical); void SetOrientation(int value); void SetFitText(bool enabled); void SetBold(unsigned char enabled); void SetFontHeight(int height); void SetFont(const std::string& name); void SetText(const std::string& value); + void SetTextColors(std::uint32_t normal, std::uint32_t hover, std::uint32_t pressed, std::uint32_t disabled); /* 00F0 */ std::string text; /* 0108 */ std::string displayText; @@ -153,7 +154,9 @@ public: /* 0148 */ int fontIndex; /* 014C */ int fontHeight; /* 0150 */ unsigned char bold; - /* 0151 */ unsigned char unknown_0151[0x0F]; + /* 0151 */ unsigned char unknown_0151[0x03]; + /* 0154 */ std::map textColors; + /* 015C */ std::uint32_t disabledTextColor; /* 0160 */ unsigned char shadow; /* 0164 */ std::uint32_t shadowColor; /* 0168 */ unsigned char outline; @@ -185,8 +188,10 @@ public: void Paint() override; void Slot53(int resolveSkin) override; + void Create(int width, int height); + /* 0190 */ unsigned char unknown_0190; - /* 0194 */ int unknown_0194; + /* 0194 */ int defaultWidth; /* 0198 */ std::map> leftImages; /* 01A0 */ CResPtr disabledLeft; /* 01A4 */ std::map> middleImages;