diff --git a/Source/UI/Buttons/UITVTextButton.h b/Source/UI/Buttons/UITVTextButton.h index 1ca3f80c..0be3d2ef 100644 --- a/Source/UI/Buttons/UITVTextButton.h +++ b/Source/UI/Buttons/UITVTextButton.h @@ -16,6 +16,7 @@ public: void Slot31(int x, int y) override; void Slot32(int x, int y) override; void Slot33(int x, int y) override; + void ResizeToText(); protected: /* 00B4 */ unsigned char unknown_00B4; diff --git a/Source/UI/Buttons/UITextButton.cpp b/Source/UI/Buttons/UITextButton.cpp index ce5df2ab..f55dfd84 100644 --- a/Source/UI/Buttons/UITextButton.cpp +++ b/Source/UI/Buttons/UITextButton.cpp @@ -30,6 +30,8 @@ #include "UI/Lists/UIListBoxEx.h" #include "UI/Lists/UIListBoxID.h" #include "UI/Lists/UIScrollBar.h" +#include "UI/Lists/TableBox.h" +#include "UI/Window/WindowPolicy.h" #include "UI/Text/UITransBalloonText.h" #include "UI/Shortcuts/ShortcutVisibility.h" #include "UI/Text/UIString.h" @@ -49,7 +51,6 @@ #include #include #include -#include // GLOBAL: gl_24606 int g_screenHeight; @@ -149,7 +150,6 @@ void UITextButton::Slot28(int x, int y) { // OFFSET: 0x00891140 // FUNCTION: fn_11445 void UITextButton::Slot31(int x, int y) { - if (this->m_disabled != 0 || g_windowMgr.Capture() != this) { return; } @@ -626,6 +626,114 @@ void UIComboBox::Refresh() { this->verticalBar->Invalidate(); } +// OFFSET: 0x00896FA0 + +// OFFSET: 0x00897370 +// FUNCTION: fn_11526 +void UIChatHisBox3::Resize(int width, int height) { + UIWindow::Resize(width, height); + this->verticalBar->Resize(9, height); + this->verticalBar->Move(width - 10, 0); + this->horizontalBar->Resize(width - 10, 9); + this->horizontalBar->Move(0, height - 10); + this->Refresh(); +} + +// OFFSET: 0x008978A0 +// FUNCTION: fn_11536 +void UITVTextButton::ResizeToText() { + if (std::strcmp(this->label.c_str(), "") == 0) { + return; + } + + this->unknown_00DC = this->label; + const int width = + this->TextWidth(this->m_buttonContext->fonts, this->m_buttonContext->locale, this->label.c_str(), 0, this->m_fontFamily, this->m_fontHeight, this->m_outlined, 0); + const int border = this->m_border ? 2 : 0; + UIWindow::Resize(width + 2 + border, this->m_fontHeight + 2 + border); +} + +// OFFSET: 0x00897960 +// FUNCTION: fn_11537 +void UITextButton::ResizeToText() { + if (std::strcmp(this->label.c_str(), "") == 0) { + return; + } + + this->m_text = this->label; + const int width = this->TextWidth(this->m_buttonContext->fonts, this->m_buttonContext->locale, this->label.c_str(), 0, this->m_family, this->m_height, this->m_outline, 0); + UIWindow::Resize(width + 2, this->m_height + 2); +} + +// OFFSET: 0x00897A50 +// FUNCTION: fn_11539 +void UITabControl::FitToTabs() { + int length = 0; + + for (int index = 0; index < static_cast(this->labels.size()); ++index) { + length += this->widths[index] - 1; + } + + if (this->layout == 0 || this->layout == 2) { + this->Resize(this->tabHeight + 1, length + 1); + } else { + this->Resize(length + 1, this->tabHeight + 1); + } + + this->Invalidate(); +} + +// OFFSET: 0x00897BE0 +// FUNCTION: fn_11540 +int TableBox::SendMsg(UIWindow* sender, int message, std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4) { + return UIWindow::SendMsg(sender, message, argument1, argument2, argument3, argument4); +} + +// OFFSET: 0x008984E0 +// FUNCTION: fn_11547 +int UIComboBoxV2Wnd::SendMsg(UIWindow* sender, int message, std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4) { + if (message == 6) { + if (argument1 != 273) { + return 0; + } + + int height = this->unknown_0098->geometry.height; + + if (this->geometry.height <= height) { + height += this->list->geometry.height; + } + + this->Resize(this->geometry.width, height); + + if (this->parent) { + this->parent->Invalidate(); + } + + this->Invalidate(); + return 0; + } + + if (message != 39) { + return UIWindow::SendMsg(sender, message, argument1, argument2, argument3, argument4); + } + + if (WindowPolicy(g_windowMgr.policy[0].actions, g_replayAnimationScaling != 0, 3, this->parent->geometry.id) == 0) { + return 0; + } + + this->SendMsg(nullptr, 6, 273, 0, 0, 0); + this->selected = argument1; + + if (this->parent) { + this->parent->SendMsg(this, 39, argument1, 0, 0, 0); + } + + this->Invalidate(); + return 0; +} + +// OFFSET: 0x00898730 + // OFFSET: 0x00897BF0 // FUNCTION: fn_11541 int UIBmpRadioBtn::SendMsg(UIWindow*, int message, std::intptr_t argument1, std::intptr_t, std::intptr_t, std::intptr_t) { diff --git a/Source/UI/Buttons/UITextButton.h b/Source/UI/Buttons/UITextButton.h index ff8bf6ef..aaa21986 100644 --- a/Source/UI/Buttons/UITextButton.h +++ b/Source/UI/Buttons/UITextButton.h @@ -20,6 +20,7 @@ public: void Slot33(int x, int y) override; void Slot35(int value) override; void Configure(const char* text, std::uint32_t color, int family, int height, unsigned char outline, unsigned char underline); + void ResizeToText(); protected: /* 00B4 */ std::uint32_t m_color; diff --git a/Source/UI/Lists/TableBox.h b/Source/UI/Lists/TableBox.h new file mode 100644 index 00000000..3b41aaf0 --- /dev/null +++ b/Source/UI/Lists/TableBox.h @@ -0,0 +1,11 @@ +#ifndef RAGNAROK_SOURCE_UI_LISTS_TABLEBOX_H +#define RAGNAROK_SOURCE_UI_LISTS_TABLEBOX_H + +#include "UI/Window/UIWindow.h" + +class TableBox : public UIWindow { +public: + int SendMsg(UIWindow* sender, int message, std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4) override; +}; + +#endif diff --git a/Source/UI/Lists/UIComboBoxDefWnd.cpp b/Source/UI/Lists/UIComboBoxDefWnd.cpp index ee70fd01..14431172 100644 --- a/Source/UI/Lists/UIComboBoxDefWnd.cpp +++ b/Source/UI/Lists/UIComboBoxDefWnd.cpp @@ -1,6 +1,7 @@ #include "Render/DeviceContext/DeviceContext.h" #include "UI/Buttons/UIBitmapButton.h" #include "UI/Lists/UIComboBoxDefWnd.h" +#include "UI/Lists/UIItemStoreComboBox.h" #include "UI/Lists/UIListBox.h" #include "UI/Text/UIStaticText.h" #include "UI/Window/WindowPolicy.h" @@ -141,6 +142,50 @@ int UIComboBoxDefWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, st } } +// OFFSET: 0x00898940 +// FUNCTION: fn_11551 +int UIItemStoreComboBoxWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std::intptr_t b, std::intptr_t c, std::intptr_t d) { + const int value = static_cast(a); + + switch (message) { + case 6: + if (value == 273) { + this->expanded = this->expanded == 0; + + if (this->expanded) { + this->list->Show(1); + this->Resize(this->geometry.width, this->list->geometry.height + this->geometry.height); + this->Move(214, this->geometry.y - this->list->geometry.height); + this->button->Move(this->geometry.width - this->button->BitmapWidth(), this->geometry.height - this->button->BitmapHeight()); + this->label->Move(2, this->list->geometry.height + 3); + } else { + this->list->Show(0); + this->Resize(this->geometry.width, this->geometry.height - this->list->geometry.height); + this->Move(214, this->list->geometry.height + this->geometry.y); + this->button->Move(this->geometry.width - this->button->BitmapWidth(), 0); + this->label->Move(2, 3); + } + + this->parent->Invalidate(); + this->list->Invalidate(); + this->Invalidate(); + } + + return 0; + case 39: + if (value < 0) { + return 0; + } + + this->label->SetText(this->list->lines[value].text.c_str(), 0); + this->SendMsg(nullptr, 6, 273, 0, 0, 0); + this->parent->SendMsg(this, 39, value, 0, 0, 0); + return 0; + default: + return this->UIWindow::SendMsg(sender, message, a, b, c, d); + } +} + // OFFSET: 0x0086CBA0 // FUNCTION: fn_11034 UIComboBoxDef2Wnd::UIComboBoxDef2Wnd(UIWindowContext& windows, UIComboBoxHeaderContext& controls) diff --git a/Source/UI/Lists/UIComboBoxV2Wnd.h b/Source/UI/Lists/UIComboBoxV2Wnd.h index a5a23c11..be695315 100644 --- a/Source/UI/Lists/UIComboBoxV2Wnd.h +++ b/Source/UI/Lists/UIComboBoxV2Wnd.h @@ -11,6 +11,7 @@ class UIComboBoxV2Wnd : public UIWindow { public: void Slot31(int x, int y) override; void Slot35(int value) override; + int SendMsg(UIWindow* sender, int message, std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4) override; /* 007C */ std::string text; /* 0094 */ int selected; diff --git a/Source/UI/Lists/UIImgMenu.h b/Source/UI/Lists/UIImgMenu.h index 92615c43..8af28896 100644 --- a/Source/UI/Lists/UIImgMenu.h +++ b/Source/UI/Lists/UIImgMenu.h @@ -3,6 +3,8 @@ #include "UI/Window/UIWindow.h" +#include + class UIImgMenu : public UIWindow { public: int ItemAt(int x, int y); @@ -10,11 +12,17 @@ public: void Slot27(int x, int y) override; void Slot28(int x, int y) override; void ResetCursor(int x, int y) override; + int SendMsg(UIWindow* sender, int message, std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4) override; /* 0080 */ int count; /* 0084 */ int itemWidth; /* 0088 */ int itemHeight; /* 008C */ int horizontal; + /* 0090 */ bool* unknown_0090; + /* 0094 */ bool* unknown_0094; + /* 0098 */ std::string bitmapName; + /* 00B0 */ std::string baseName; + /* 00C8 */ int unknown_00C8; /* 007C */ int hovered; }; diff --git a/Source/UI/Lists/UIItemStoreComboBox.h b/Source/UI/Lists/UIItemStoreComboBox.h index 8e34f73d..d4d24800 100644 --- a/Source/UI/Lists/UIItemStoreComboBox.h +++ b/Source/UI/Lists/UIItemStoreComboBox.h @@ -1,6 +1,7 @@ #ifndef RAGNAROK_SOURCE_UI_LISTS_UIITEMSTORECOMBOBOX_H #define RAGNAROK_SOURCE_UI_LISTS_UIITEMSTORECOMBOBOX_H +#include "UI/Lists/UIComboBoxDefWnd.h" #include "UI/Lists/UIComboBoxEx.h" class UIItemStoreComboBox : public UIComboBoxEx { @@ -10,9 +11,10 @@ public: void Slot31(int x, int y) override; }; -class UIItemStoreComboBoxWnd : public UIWindow { +class UIItemStoreComboBoxWnd : public UIComboBoxDefWnd { public: void Paint() override; + int SendMsg(UIWindow* sender, int message, std::intptr_t a, std::intptr_t b, std::intptr_t c, std::intptr_t d) override; }; #endif diff --git a/Source/UI/Lists/UIMemberListBox.h b/Source/UI/Lists/UIMemberListBox.h index 3fbb930b..1456c801 100644 --- a/Source/UI/Lists/UIMemberListBox.h +++ b/Source/UI/Lists/UIMemberListBox.h @@ -13,6 +13,11 @@ public: void Slot33(int x, int y) override; }; +class UIChatHisBox3 : public UIChatHisBox2 { +public: + void Resize(int width, int height) override; +}; + class UIMemberListBox : public UIChatHisBox2 { public: void Slot25(int x, int y) override; diff --git a/Source/UI/Lists/UITabControl.h b/Source/UI/Lists/UITabControl.h index 9cec747b..86263ca6 100644 --- a/Source/UI/Lists/UITabControl.h +++ b/Source/UI/Lists/UITabControl.h @@ -18,6 +18,8 @@ public: void DrawVerticalTab(int index); void DrawHorizontalTab(int index); void DrawTabBorder(int x, int y, int width, int height, std::uint32_t color); + void RecalculateWidths(); + void FitToTabs(); void Slot10(int argument1, int argument2, std::intptr_t argument3) override; void Slot25(int x, int y) override; void Slot27(int x, int y) override; @@ -25,7 +27,10 @@ public: void Slot31(int x, int y) override; /* 0080 */ int layout; - /* 0084 */ unsigned char unknown_0084[0xC]; + /* 0084 */ int tabHeight; + /* 0088 */ int tabPadding; + /* 008C */ unsigned char uniformWidths; + /* 008D */ unsigned char unknown_008D[0x3]; /* 0090 */ std::uint32_t activeFillColor; /* 0094 */ std::uint32_t inactiveFillColor; /* 0098 */ std::uint32_t activeBorderColor;