diff --git a/Source/UI/Buttons/UIBmpRadioBtn.h b/Source/UI/Buttons/UIBmpRadioBtn.h index d4c2279c..417d5d78 100644 --- a/Source/UI/Buttons/UIBmpRadioBtn.h +++ b/Source/UI/Buttons/UIBmpRadioBtn.h @@ -4,23 +4,40 @@ #include "Resource/Bitmap/BitmapResource.h" #include "UI/Window/UIWindow.h" +#include #include +#include struct UIButtonContext; +struct UIBmpRadioBtnText { + /* 0000 */ int id; + /* 0004 */ int x; + /* 0008 */ int y; + /* 000C */ int height; + /* 0010 */ bool bold; + /* 0014 */ std::uint32_t color; + /* 0018 */ bool unknown_0018; +}; + class UIBmpRadioBtn : public UIWindow { public: void Slot25(int x, int y) override; void Slot28(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; + bool SetBitmap(const char* name, int state); + void AddText(int id, int height, std::uint32_t color, bool bold, bool unknown, int x, int y); + protected: - /* 007C */ unsigned char unknown_007C[0x60]; + /* 007C */ std::string m_names[4]; /* 00DC */ bool m_hovered; /* 00DD */ unsigned char unknown_00DD[3]; /* 00E0 */ std::string m_tooltip; UIButtonContext* m_controls; /* 00FC */ int m_value; + /* 0100 */ std::vector m_texts; + /* 010C */ std::string m_label; }; class UIBmpRadioBtn2 : public UIBmpRadioBtn { diff --git a/Source/UI/Buttons/UITVTextButton.h b/Source/UI/Buttons/UITVTextButton.h index 0be3d2ef..fab4e30f 100644 --- a/Source/UI/Buttons/UITVTextButton.h +++ b/Source/UI/Buttons/UITVTextButton.h @@ -17,6 +17,7 @@ public: void Slot32(int x, int y) override; void Slot33(int x, int y) override; void ResizeToText(); + void SetLabel(std::string text); protected: /* 00B4 */ unsigned char unknown_00B4; diff --git a/Source/UI/Buttons/UITextButton.cpp b/Source/UI/Buttons/UITextButton.cpp index a4924b01..447c8897 100644 --- a/Source/UI/Buttons/UITextButton.cpp +++ b/Source/UI/Buttons/UITextButton.cpp @@ -261,6 +261,95 @@ void UIBmpRadioBtn::Slot28(int, int) { } } +// OFFSET: 0x0089B640 +// FUNCTION: fn_11570 +bool UIBmpRadioBtn::SetBitmap(const char* name, int state) { + const auto* bitmap = static_cast(ResourceMgr::Instance().Load(Resolve(name))); + if (!bitmap) { + return false; + } + + if (bitmap->image.width > this->geometry.width) { + this->geometry.width = bitmap->image.width; + } + + if (bitmap->image.height > this->geometry.height) { + this->geometry.height = bitmap->image.height; + } + + this->Resize(this->geometry.width, this->geometry.height); + + switch (state) { + case 0: + this->m_names[0] = name; + break; + case 1: + this->m_names[1] = name; + break; + case 2: + this->m_names[2] = name; + break; + case 3: + this->m_names[3] = name; + break; + } + + return true; +} + +// OFFSET: 0x0089BA00 +// FUNCTION: fn_11573 +void UITextButton::CenterIn(int width, int height) { + UIWindow::Move( + static_cast((width - this->geometry.width) * 0.5 + this->geometry.x), static_cast((height - this->geometry.height) * 0.5 + this->geometry.y) + ); +} + +// OFFSET: 0x0089CA70 +// FUNCTION: fn_11590 +void UITVTextButton::SetLabel(std::string text) { + this->label = text; + this->ResizeToText(); +} + +// OFFSET: 0x0089CC30 +// FUNCTION: fn_11592 +void UIBmpRadioBtn::AddText(int id, int height, std::uint32_t color, bool bold, bool unknown, int x, int y) { + UIBmpRadioBtnText text; + text.id = id; + text.x = x; + text.y = y; + text.height = height; + text.bold = bold; + text.color = color; + text.unknown_0018 = unknown; + + if (x == -1000) { + const int textWidth = + this->TextWidth(this->m_controls->fonts, this->m_controls->locale, this->m_label.c_str(), static_cast(this->m_label.size()), 0, height, bold, 0); + text.x = static_cast((this->geometry.width - textWidth) * 0.5); + } + + if (y == -1000) { + const int textHeight = + this->TextHeight(this->m_controls->fonts, this->m_controls->locale, this->m_label.c_str(), static_cast(this->m_label.size()), 0, height, bold, 0); + text.y = static_cast((this->geometry.height - textHeight) * 0.5); + } + + auto it = this->m_texts.begin(); + for (; it != this->m_texts.end(); ++it) { + if (it->id == id) { + break; + } + } + + if (it != this->m_texts.end()) { + *it = text; + } + + this->m_texts.push_back(text); +} + // OFFSET: 0x007C7CA0 // FUNCTION: fn_09408 void UIBmpRadioBtn2::Slot47() { diff --git a/Source/UI/Buttons/UITextButton.h b/Source/UI/Buttons/UITextButton.h index 4a8e8727..850f0b67 100644 --- a/Source/UI/Buttons/UITextButton.h +++ b/Source/UI/Buttons/UITextButton.h @@ -23,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(); + void CenterIn(int width, int height); const std::string& GetLine(std::size_t index) const; protected: diff --git a/Source/UI/Edit/ItemTagRetirement.cpp b/Source/UI/Edit/ItemTagRetirement.cpp index aa621e90..e0805105 100644 --- a/Source/UI/Edit/ItemTagRetirement.cpp +++ b/Source/UI/Edit/ItemTagRetirement.cpp @@ -40,3 +40,13 @@ std::string UIItemTagCtrl::AppendTag(const std::string& name) { this->taggedText += tag; return this->taggedText; } + +// OFFSET: 0x0089CF10 +// FUNCTION: fn_11595 +void UIItemTagOnMail::SetLines(const std::vector& lines) { + this->m_lines.clear(); + + for (std::size_t index = 0; index < lines.size(); ++index) { + this->m_lines.push_back(lines[index]); + } +} diff --git a/Source/UI/Edit/UIItemTagCtrl.h b/Source/UI/Edit/UIItemTagCtrl.h index a421f1c6..43c83f6c 100644 --- a/Source/UI/Edit/UIItemTagCtrl.h +++ b/Source/UI/Edit/UIItemTagCtrl.h @@ -6,6 +6,7 @@ #include #include +#include class UIItemTagCtrl : public UIEditCtrl { public: @@ -20,4 +21,11 @@ public: /* 0158 */ int tagWidth; }; +class UIItemTagOnMail : public UIItemTagCtrl { +public: + void SetLines(const std::vector& lines); + + /* 015C */ std::vector m_lines; +}; + #endif diff --git a/Source/UI/Gauges/UIPcGage.h b/Source/UI/Gauges/UIPcGage.h index c55bf00e..c3442f4d 100644 --- a/Source/UI/Gauges/UIPcGage.h +++ b/Source/UI/Gauges/UIPcGage.h @@ -5,6 +5,7 @@ #include #include +#include class UIGage : public UIWindow { public: @@ -27,6 +28,37 @@ public: /* 00AC */ int unknown_00AC; }; +class UIRechargeGage : public UIGage { +public: + void SetValues(int current, int maximum); + + /* 009C */ int current; + /* 00A0 */ int maximum; +}; + +class UIPlayerGage : public UIGage { +public: + void SetFirstValues(std::function current, std::function maximum); + void SetSecondValues(std::function current, std::function maximum); + void SetThirdValues(std::function current, std::function maximum); + void SetFourthValues(std::function current, std::function maximum); + + /* 009C */ int unknown_009C; + /* 00A0 */ std::function m_firstCurrent; + /* 00C8 */ std::function m_firstMaximum; + /* 00F0 */ std::function m_secondCurrent; + /* 0118 */ std::function m_secondMaximum; + /* 0140 */ std::function m_thirdCurrent; + /* 0168 */ std::function m_thirdMaximum; + /* 0190 */ std::function m_fourthCurrent; + /* 01B8 */ std::function m_fourthMaximum; +}; + +class UIMonsterGage : public UIPcGage { +public: + void SetMode(int mode); +}; + #if defined(_WIN32) && !defined(_WIN64) static_assert(offsetof(UIGage, colors) == 0x80); static_assert(offsetof(UIPcGage, current) == 0xA0); diff --git a/Source/UI/Gauges/UIPlayerGage.cpp b/Source/UI/Gauges/UIPlayerGage.cpp new file mode 100644 index 00000000..290a505d --- /dev/null +++ b/Source/UI/Gauges/UIPlayerGage.cpp @@ -0,0 +1,43 @@ +#include "UI/Gauges/UIPcGage.h" + +// OFFSET: 0x0089B560 +// FUNCTION: fn_11568 +void UIRechargeGage::SetValues(int current, int maximum) { + this->current = current; + this->maximum = maximum; + this->Invalidate(); +} + +// OFFSET: 0x0089B590 +// FUNCTION: fn_11569 +void UIPlayerGage::SetFourthValues(std::function current, std::function maximum) { + this->m_fourthCurrent = current; + this->m_fourthMaximum = maximum; +} + +// OFFSET: 0x0089BCF0 +// FUNCTION: fn_11578 +void UIPlayerGage::SetFirstValues(std::function current, std::function maximum) { + this->m_firstCurrent = current; + this->m_firstMaximum = maximum; +} + +// OFFSET: 0x0089BDA0 +// FUNCTION: fn_11579 +void UIPlayerGage::SetThirdValues(std::function current, std::function maximum) { + this->m_thirdCurrent = current; + this->m_thirdMaximum = maximum; +} + +// OFFSET: 0x0089C070 +// FUNCTION: fn_11580 +void UIMonsterGage::SetMode(int mode) { + this->unknown_009C = mode; +} + +// OFFSET: 0x0089C390 +// FUNCTION: fn_11587 +void UIPlayerGage::SetSecondValues(std::function current, std::function maximum) { + this->m_secondCurrent = current; + this->m_secondMaximum = maximum; +} diff --git a/Source/UI/Lists/UIScrollBar.cpp b/Source/UI/Lists/UIScrollBar.cpp index b4e61961..ae1699fc 100644 --- a/Source/UI/Lists/UIScrollBar.cpp +++ b/Source/UI/Lists/UIScrollBar.cpp @@ -425,6 +425,8 @@ void UITabControl::ClearTabs() { this->FitToTabs(); } +// OFFSET: 0x0089C1B0 + // OFFSET: 0x00880B20 // FUNCTION: fn_11283 int UITabControl::TabCount() { diff --git a/Source/UI/Lists/UITabControl.h b/Source/UI/Lists/UITabControl.h index bd5026d2..3cd612b6 100644 --- a/Source/UI/Lists/UITabControl.h +++ b/Source/UI/Lists/UITabControl.h @@ -23,6 +23,7 @@ public: void SelectTab(int index); void RemoveTab(int index); void ClearTabs(); + void SetFlag(int index, bool value); 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; diff --git a/Source/UI/UIBarGraph.cpp b/Source/UI/UIBarGraph.cpp index db2c7e03..121d8816 100644 --- a/Source/UI/UIBarGraph.cpp +++ b/Source/UI/UIBarGraph.cpp @@ -17,3 +17,17 @@ UIBarGraph3::~UIBarGraph3() = default; // OFFSET: 0x008700F0 // FUNCTION: fn_11098 UIBarGraphPlayer::~UIBarGraphPlayer() = default; + +// OFFSET: 0x0089CDB0 +// FUNCTION: fn_11593 +void UIBarGraphHomun::SetValues(std::function current, std::function maximum) { + this->m_current = current; + this->m_maximum = maximum; +} + +// OFFSET: 0x0089CE60 +// FUNCTION: fn_11594 +void UIBarGraphPlayer::SetValues(std::function current, std::function maximum) { + this->m_current = current; + this->m_maximum = maximum; +} diff --git a/Source/UI/UIBarGraph.h b/Source/UI/UIBarGraph.h index 900a6d21..ee5b9fea 100644 --- a/Source/UI/UIBarGraph.h +++ b/Source/UI/UIBarGraph.h @@ -58,6 +58,8 @@ class UIBarGraphHomun : public UIWindow { public: explicit UIBarGraphHomun(UIWindowContext& context); + void SetValues(std::function current, std::function maximum); + protected: /* 0080 */ std::function m_current; /* 00A8 */ std::function m_maximum; @@ -68,6 +70,8 @@ public: explicit UIBarGraphPlayer(UIWindowContext& context); ~UIBarGraphPlayer() override; + void SetValues(std::function current, std::function maximum); + protected: /* 0080 */ std::function m_current; /* 00A8 */ std::function m_maximum; diff --git a/data/compile.json b/data/compile.json index b38e6f92..8b354e9e 100644 --- a/data/compile.json +++ b/data/compile.json @@ -835,6 +835,7 @@ "Source/UI/FrameSkin.cpp": 2, "Source/UI/GameSettings/GameSettingsUI.cpp": 2, "Source/UI/Gauges/UIPetInfoBarGraph.cpp": 2, + "Source/UI/Gauges/UIPlayerGage.cpp": 2, "Source/UI/Guild/UIAgitWnd.cpp": 2, "Source/UI/Guild/UIGuildHelperWnd.cpp": 2, "Source/UI/Guild/UIGuildWnd.cpp": 2,