diff --git a/Source/UI/Buttons/UIBmpTextButton2.h b/Source/UI/Buttons/UIBmpTextButton2.h new file mode 100644 index 0000000..95ec49d --- /dev/null +++ b/Source/UI/Buttons/UIBmpTextButton2.h @@ -0,0 +1,32 @@ +#ifndef RAGNAROK_SOURCE_UI_BUTTONS_UIBMPTEXTBUTTON2_H +#define RAGNAROK_SOURCE_UI_BUTTONS_UIBMPTEXTBUTTON2_H + +#include "UI/Buttons/UIBitmapButton.h" + +#include +#include +#include + +struct BmpTextButtonLabel { + /* 0000 */ std::string text; + /* 0018 */ int unknown_0018; + /* 001C */ int x; + /* 0020 */ int y; + /* 0024 */ int height; + /* 0028 */ unsigned char bold; + /* 002C */ std::uint32_t color; + /* 0030 */ unsigned char shadow; +}; + +class UIBmpTextButton2 : public UIBitmapButton { +public: + void DrawLabels(); + + /* 0120 */ std::vector labels; +}; + +#if defined(_WIN32) && !defined(_WIN64) +static_assert(sizeof(BmpTextButtonLabel) == 52); +#endif + +#endif diff --git a/Source/UI/Edit/UIEditCtrl.cpp b/Source/UI/Edit/UIEditCtrl.cpp index a0f2a26..d0eb129 100644 --- a/Source/UI/Edit/UIEditCtrl.cpp +++ b/Source/UI/Edit/UIEditCtrl.cpp @@ -18,6 +18,7 @@ #include "Resource/ResourceMgr.h" #include "Resource/Sprites/ActionResource.h" #include "Resource/Sprites/SpriteResource.h" +#include "UI/Buttons/UIBmpTextButton2.h" #include "UI/Buttons/UINaviLinkButton.h" #include "UI/Buttons/UISpriteButton.h" #include "UI/Item/UIItemStoreFindWnd.h" @@ -596,6 +597,68 @@ void UIEditCtrl::MoveReadingWindow(int x) { window->Move(left, top); } +// OFFSET: 0x008570D0 +// FUNCTION: fn_10760 +void UIBmpTextButton2::DrawLabels() { + for (unsigned index = 0; index < this->labels.size(); ++index) { + const BmpTextButtonLabel& label = this->labels[index]; + + if (label.text.size() == 0) { + continue; + } + + int x = label.x; + int y = label.y; + int shadowX = 0; + int shadowY = 0; + + if (x == -1000) { + const int width = this->TextWidth(this->m_buttonContext->fonts, this->m_buttonContext->locale, label.text.c_str(), label.text.size(), 0, label.height, label.bold, 0); + x = static_cast((this->geometry.width - width) * 0.5); + } + + if (y == -1000) { + const int height = this->TextHeight(this->m_buttonContext->fonts, this->m_buttonContext->locale, label.text.c_str(), label.text.size(), 0, label.height, label.bold, 0); + y = static_cast((this->geometry.height - height) * 0.5); + } + + std::uint32_t color = label.color; + std::uint32_t shadowColor = 0xE6E6E6; + + switch (this->geometry.unknown_0030) { + case 0: + shadowX = x + 1; + shadowY = y + 1; + shadowColor = 0xD7D7D7; + break; + case 1: + shadowX = x + 1; + shadowY = y + 1; + shadowColor = 0xC7A796; + break; + case 2: + shadowX = x; + shadowY = y; + shadowColor = 0xFFFFFF; + ++x; + ++y; + break; + case 3: + color = 0xADADAD; + shadowX = x + 1; + shadowY = y + 1; + shadowColor = 0xD7D7D7; + break; + } + + if (label.shadow == 1) { + this->DrawTextAt(this->m_buttonContext->fonts, this->m_buttonContext->locale, shadowX, shadowY, label.text.c_str(), 0, 0, label.height, shadowColor, label.bold, 0); + } + + this->DrawTextAt(this->m_buttonContext->fonts, this->m_buttonContext->locale, x, y, label.text.c_str(), 0, 0, label.height, color, label.bold, 0); + } +} + // OFFSET: 0x00858B80 // FUNCTION: fn_10764 std::string UINaviLinkButton::Link() {