diff --git a/Source/UI/Buttons/UITagButton.cpp b/Source/UI/Buttons/UITagButton.cpp new file mode 100644 index 00000000..b90ee6ac --- /dev/null +++ b/Source/UI/Buttons/UITagButton.cpp @@ -0,0 +1,63 @@ +#include "UI/Buttons/UITagButton.h" + +#include "UI/Window/UIWindowMgr.h" + +#include + +// GLOBAL: gl_24936 +std::string g_emptyString; + +// OFFSET: 0x009B54A0 +// FUNCTION: fn_13844 +void UITagButton::Slot31(int x, int y) { + if (this->m_disabled != 0) { + return; + } + + if (HIBYTE(GetAsyncKeyState(VK_SHIFT))) { + if (g_windowMgr.GetHoverWindow() && this->item.identified) { + g_windowMgr.GetHoverWindow()->SendMsg(nullptr, 148, reinterpret_cast(&this->item), 0, 0, 0); + } + + return; + } + + if (g_windowMgr.Capture() != this) { + return; + } + + if (x < 0 || x >= this->geometry.width || y < 0 || y >= this->geometry.height) { + this->geometry.unknown_0030 = 0; + } else { + this->geometry.unknown_0030 = 1; + + if (this->parent) { + this->parent->SendMsg(this, 98, this->geometry.id, this->m_value, 0, 0); + } + } + + this->Invalidate(); + g_windowMgr.ReleaseCapture(); +} + +// OFFSET: 0x009B5580 +// FUNCTION: fn_13845 +void UITagButton::AddString(std::string text) { + this->m_strings.push_back(text); +} + +// OFFSET: 0x009B5600 +// FUNCTION: fn_13846 +std::string UITagButton::GetString(std::size_t index) { + if (index < this->m_strings.size()) { + return this->m_strings[index]; + } + + return std::string(); +} + +// OFFSET: 0x009B56C0 +// FUNCTION: fn_13847 +int UITagButton::GetStringCount() { + return static_cast(this->m_strings.size()); +} diff --git a/Source/UI/Buttons/UITagButton.h b/Source/UI/Buttons/UITagButton.h new file mode 100644 index 00000000..2b50cb4b --- /dev/null +++ b/Source/UI/Buttons/UITagButton.h @@ -0,0 +1,23 @@ +#ifndef RAGNAROK_SOURCE_UI_BUTTONS_UITAGBUTTON_H +#define RAGNAROK_SOURCE_UI_BUTTONS_UITAGBUTTON_H + +#include "Contents/Items/ItemInfo.h" +#include "UI/Buttons/UITextButton.h" + +#include +#include +#include + +class UITagButton : public UITextButton { +public: + /* 00F8 */ ITEM_INFO item; + /* 01F0 */ std::vector m_strings; + + void Slot31(int x, int y) override; + + void AddString(std::string text); + std::string GetString(std::size_t index); + int GetStringCount(); +}; + +#endif diff --git a/Source/UI/Buttons/UITextButton.cpp b/Source/UI/Buttons/UITextButton.cpp index f55dfd84..8fb5d4db 100644 --- a/Source/UI/Buttons/UITextButton.cpp +++ b/Source/UI/Buttons/UITextButton.cpp @@ -1653,3 +1653,13 @@ void UIImgMenu::Move(int x, int y) { int UIString::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: 0x009B4EF0 +// FUNCTION: fn_13834 +const std::string& UITextButton::GetLine(std::size_t index) const { + try { + return this->m_lines.at(index); + } catch (...) { + return g_emptyString; + } +} diff --git a/Source/UI/Buttons/UITextButton.h b/Source/UI/Buttons/UITextButton.h index aaa21986..4a8e8727 100644 --- a/Source/UI/Buttons/UITextButton.h +++ b/Source/UI/Buttons/UITextButton.h @@ -3,6 +3,8 @@ #include "UI/Buttons/UIButton.h" +#include +#include #include class UITextButton : public UIButton { @@ -21,6 +23,7 @@ public: 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(); + const std::string& GetLine(std::size_t index) const; protected: /* 00B4 */ std::uint32_t m_color; @@ -36,6 +39,8 @@ protected: /* 00EC */ std::vector m_lines; }; +extern std::string g_emptyString; + #if defined(_WIN32) && !defined(_WIN64) static_assert(sizeof(UITextButton) == 256); #endif diff --git a/data/compile.json b/data/compile.json index 5bef9cb7..39f73289 100644 --- a/data/compile.json +++ b/data/compile.json @@ -801,6 +801,7 @@ "Source/UI/Buttons/UINaviLinkButton.cpp": 2, "Source/UI/Buttons/UINoneVisibleButton.cpp": 2, "Source/UI/Buttons/UIRadioBtn.cpp": 2, + "Source/UI/Buttons/UITagButton.cpp": 2, "Source/UI/Buttons/UITextButton.cpp": 2, "Source/UI/Buttons/UITextureButton.cpp": 2, "Source/UI/CashShop/UICashShopWnd.cpp": 2,