diff --git a/Source/UI/Quest/UIQuestDisplay.cpp b/Source/UI/Quest/UIQuestDisplay.cpp index 6af26b49..e2d23a9c 100644 --- a/Source/UI/Quest/UIQuestDisplay.cpp +++ b/Source/UI/Quest/UIQuestDisplay.cpp @@ -19,6 +19,12 @@ struct PACKET_CZ_ACTIVE_QUEST { }; #pragma pack(pop) +// OFFSET: 0x00948D10 +// FUNCTION: fn_12881 +void UIQuestDisplay::Create(int width, int height) { + this->SetSize(width, height); +} + // OFFSET: 0x0094F1D0 // FUNCTION: fn_12934 void UIQuestDisplay::Slot33(int x, int y) { diff --git a/Source/UI/Quest/UIQuestDisplay.h b/Source/UI/Quest/UIQuestDisplay.h index 53dc296b..1c8daeea 100644 --- a/Source/UI/Quest/UIQuestDisplay.h +++ b/Source/UI/Quest/UIQuestDisplay.h @@ -17,6 +17,7 @@ public: void Slot11() override; void Slot33(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; + void Create(int width, int height); protected: /* 0080 */ int m_selectedIndex; diff --git a/Source/UI/Window/UINormalMB.cpp b/Source/UI/Window/UINormalMB.cpp index f8673b58..3b982c10 100644 --- a/Source/UI/Window/UINormalMB.cpp +++ b/Source/UI/Window/UINormalMB.cpp @@ -1,7 +1,15 @@ #include "UI/Window/UINormalMB.h" +#include "Contents/MessageTable.h" +#include "Render/Renderer.h" +#include "Resource/ResourceMgr.h" +#include "Resource/SkinPalette.h" +#include "UI/Buttons/UIBitmapButton.h" #include "UI/Text/UITextViewer.h" +#include "UI/UIStaticBitmap.h" #include "UI/Window/UIWindowMgr.h" +#include + // OFFSET: 0x00946C00 // FUNCTION: fn_12851 UINormalMB::UINormalMB(UIWindowContext& windows, UIFrameContext& frames) : UIFrameWnd(windows, frames, 0), m_owner(nullptr), m_viewer(nullptr) { @@ -42,3 +50,70 @@ int UINormalMB::SendMsg(UIWindow* sender, int message, std::intptr_t a, std::int return this->UIFrameWnd::SendMsg(sender, message, a, b, c, d); } } + +// INLINED +__forceinline void UINormalMB::AddButton(const char* normal, const char* hover, const char* pressed, int x, int y, int id) { + auto* button = new UIBitmapButton(*this->m_context, this->m_textContext->buttons); + button->SetBitmap(normal, 0, 0); + button->SetBitmap(hover, 1, 0); + button->SetBitmap(pressed, 2, 0); + button->SetSize(button->BitmapWidth(), button->BitmapHeight()); + button->Move(x, y); + button->SetId(id); + this->AddChild(button); +} + +// OFFSET: 0x009487B0 +// FUNCTION: fn_12880 +void UINormalMB::Create(UIWindow* owner, const char* text, int type, bool defaultAccept, const char* title, int width, int height, const char* icon) { + this->m_owner = owner; + this->m_message = text; + this->m_title = title ? title : LookupMessage(3700); + + this->SetSize(width, height); + this->Slot15(width, height); + this->Slot22(width, height); + this->Move(static_cast((g_renderer->viewport.width - width) * 0.5), static_cast((g_renderer->viewport.height - height) * 0.5)); + + int inset = 0; + + if (icon) { + auto* image = new UIStaticBitmap(*this->m_context, this->m_textContext->buttons); + image->SetBitmap(icon); + image->SetSize(image->geometry.width, image->geometry.height); + image->Move(10, 22); + this->AddChild(image); + inset = image->geometry.width + image->geometry.x; + } + + this->m_viewer = new UITextViewer(*this->m_context, *this->m_textContext); + this->m_viewer->Configure(inset + 10, 22, width - inset - 20, height - 55, 0); + unsigned red, green, blue; + SkinPaletteChannels(ResourceMgr::Instance(), 2, 2, red, green, blue); + this->m_viewer->backgroundColor = RGB(red, green, blue) | 0xFF000000u; + this->m_viewer->Invalidate(); + this->AddChild(this->m_viewer); + this->m_viewer->SendMsg(nullptr, 29, reinterpret_cast(this->m_message.c_str()), static_cast(width / 7.5), 0, 0); + + switch (type) { + case 0: + this->AddButton("유저인터페이스\\btn_ok.bmp", "유저인터페이스\\btn_ok_a.bmp", "유저인터페이스\\btn_ok_b.bmp", width - 46, height - 24, 184); + this->m_message0 = 184; + break; + + case 2: + this->AddButton("유저인터페이스\\btn_ok.bmp", "유저인터페이스\\btn_ok_a.bmp", "유저인터페이스\\btn_ok_b.bmp", width - 91, height - 24, 187); + this->AddButton("유저인터페이스\\btn_cancel.bmp", "유저인터페이스\\btn_cancel_a.bmp", "유저인터페이스\\btn_cancel_b.bmp", width - 46, height - 24, 188); + this->m_message1 = 188; + this->m_message0 = defaultAccept ? 187 : 188; + break; + + case 4: + this->AddButton("유저인터페이스\\btn_cancel.bmp", "유저인터페이스\\btn_cancel_a.bmp", "유저인터페이스\\btn_cancel_b.bmp", width - 46, height - 24, 185); + this->m_message0 = 185; + break; + + default: + break; + } +} diff --git a/Source/UI/Window/UINormalMB.h b/Source/UI/Window/UINormalMB.h index c10c2453..36365e78 100644 --- a/Source/UI/Window/UINormalMB.h +++ b/Source/UI/Window/UINormalMB.h @@ -7,19 +7,25 @@ #include class UITextViewer; +struct UITextViewerContext; class UINormalMB : public UIFrameWnd { public: UINormalMB(UIWindowContext& windows, UIFrameContext& frames); int SendMsg(UIWindow* sender, int message, std::intptr_t a, std::intptr_t b, std::intptr_t c, std::intptr_t d) override; + void Create(UIWindow* owner, const char* text, int type, bool defaultAccept, const char* title, int width, int height, const char* icon); protected: /* 00B4 */ UIWindow* m_owner; /* 00B8 */ UITextViewer* m_viewer; - /* 00BC */ std::string unknown_00BC; - /* 00D4 */ std::string unknown_00D4; + /* 00BC */ std::string m_message; + /* 00D4 */ std::string m_title; /* 00EC */ unsigned char m_keepOpen; /* 00F0 */ std::map m_actions; + +private: + UITextViewerContext* m_textContext; + void AddButton(const char* normal, const char* hover, const char* pressed, int x, int y, int id); }; #endif