From 7c5bf24c9158fa4e2355d5263d3ed84570a9ff8e Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 15:12:59 +0000 Subject: [PATCH] Decompile 2 functions in Source/UI/MiniPartyManager.cpp, Source/UI/Window/UIWindowFactory.cpp, ... Batch #8210 by eAthena: 0 byte-identical, 2 confirmed by peer review. - fn_17183 UIWindowMgr::RebuildMiniPartyWindows: logic confirmed by peer review - fn_17208 UIWindowMgr::CreateLayoutWindow: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, System4z, pedrao Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/MiniPartyManager.cpp | 81 +++++++++++++++++++++++++++- Source/UI/Window/UIWindowFactory.cpp | 79 +++++++++++++++++++++++++++ Source/UI/Window/UIWindowFactory.h | 21 -------- Source/UI/Window/UIWindowMgr.h | 2 + 4 files changed, 160 insertions(+), 23 deletions(-) diff --git a/Source/UI/MiniPartyManager.cpp b/Source/UI/MiniPartyManager.cpp index 58ed1357..ce59e3c7 100644 --- a/Source/UI/MiniPartyManager.cpp +++ b/Source/UI/MiniPartyManager.cpp @@ -1,5 +1,3 @@ -#include "UI/MiniPartyManager.h" - #include "Client/Session.h" #include "Contents/ClientItemLists.h" #include "Contents/Messenger/ClientMessenger.h" @@ -10,6 +8,7 @@ #include "UI/Window/MiniPartyWndAreaMgr.h" #include "UI/Window/UIWindowMgr.h" #include "UI/Window/UIWindow.h" +#include "UI/Window/WindowDialogs.h" #include "UI/Window/WindowManagerWindows.h" #include "UI/Window/WindowOrdering.h" #include @@ -84,3 +83,81 @@ void UIWindowMgr::AddMiniPartyWindow(UIWindow* window) { } // OFFSET: 0x00A96090 +// FUNCTION: fn_17183 +void UIWindowMgr::RebuildMiniPartyWindows() { + for (auto entry = this->snapExcluded.begin(); entry != this->snapExcluded.end();) { + UIWindow* window = *entry; + if (window == this->window_03D4) { + this->window_03D4 = nullptr; + } + + if (window == this->window_03D8) { + this->window_03D8 = nullptr; + } + + if (window == this->window_03DC) { + this->window_03DC = nullptr; + } + + if (window == this->window_01B8) { + this->window_01B8 = nullptr; + } + + if (window == this->window_4F2AC) { + this->window_4F2AC = nullptr; + } + + this->retired.push_back(window); + entry = this->snapExcluded.erase(entry); + } + this->snapExcluded.clear(); + + const int count = ClientMessenger{g_session.m_partyMembers, g_session.m_friends}.PartyCount(); + std::list records; + for (int index = 0; index < count; ++index) { + MessengerMember member = ClientMessenger{g_session.m_partyMembers, g_session.m_friends}.PartyAt(index); + if (member.valid == 0) { + continue; + } + + const SessionRecord0734 record = g_session.FindRecord0734(member.accountId); + if (record.unknown_0000 == 0) { + continue; + } + + records.push_back(record); + } + + reinterpret_cast(g_session).ClearRecords0734(); + + WindowDialogs& dialogs = *reinterpret_cast(this); + for (const SessionRecord0734& record : records) { + MessengerMember member = ClientMessenger{g_session.m_partyMembers, g_session.m_friends}.PartyByAccount(record.id); + if (member.valid == 0) { + continue; + } + + UIMiniPartyWnd* window = new UIMiniPartyWnd(dialogs.windows, dialogs.frames); + window->SetSize(174, 52); + window->m_cell = record.unknown_0008; + this->AddMiniPartyWindow(window); + window->SendMsg(nullptr, 23, reinterpret_cast(&member), 0, 0, 0); + g_session.AddRecord0734(record.id, record.unknown_0008); + + UIWindow* drag = this->unknown_0210; + if (drag != nullptr && *reinterpret_cast(reinterpret_cast(drag) + 0xB4) == 301 && + *reinterpret_cast(reinterpret_cast(drag) + 0xCC) == record.unknown_0008) { + const int x = drag->geometry.x; + const int y = drag->geometry.y; + window->SendMsg(nullptr, 49, 0, 0, 0, 0); + this->unknown_0210->Move(x, y); + } + } + + WindowOrdering ordering{this->rendered, reinterpret_cast(*this), reinterpret_cast(this->modal), this->window_4F174}; + if (this->Window4F250Ready()) { + ordering.Promote(this->window_4F250); + } + + ordering.Promote(this->unknown_0210); +} diff --git a/Source/UI/Window/UIWindowFactory.cpp b/Source/UI/Window/UIWindowFactory.cpp index 8932bc00..d98c83fd 100644 --- a/Source/UI/Window/UIWindowFactory.cpp +++ b/Source/UI/Window/UIWindowFactory.cpp @@ -1,5 +1,6 @@ #include "UI/Window/UIWindowFactory.h" +#include "Client/Session.h" #include "Contents/Configuration/ScriptOptions.h" #include "Render/Renderer.h" #include "Script/LuaScript.h" @@ -12,7 +13,85 @@ #include +struct LayoutWindowContexts { + UIWindowContext& windows; + UIFrameContext& frames; + UIEntryQueueContext& entryQueue; + UIListBoxContext& listBox; + QuickSlotPainting& quickSlots; +}; + // GLOBAL: gl_25184 bool g_searchStoreInfoCreated; // OFFSET: 0x00AA1350 +// FUNCTION: fn_17208 +UIWindow* UIWindowMgr::CreateLayoutWindow(int id) { + int width = 0; + int height = 0; + int x = 0; + int y = 0; + if (!g_luaScript->Call("GetWindowInfo", "d>dddd", id, &width, &height, &x, &y)) { + return nullptr; + } + + x = g_renderer->viewport.width * x / 1024; + y = g_renderer->viewport.height * y / 768; + + UIWindow* window = this->LookupWindow(id); + std::string yKey; + std::string xKey; + if (window == nullptr) { + LayoutWindowContexts& contexts = *reinterpret_cast(this); + switch (id) { + case 0x9C: + window = new UIHotKeyWnd(contexts.windows, contexts.frames); + this->unknown_0404 = window; + break; + case 0x9D: + window = new UIEntryQueueWnd(contexts.windows, contexts.frames, contexts.entryQueue, contexts.listBox); + break; + case 0x9F: + window = new UIQuickSlotWnd(contexts.windows, contexts.frames, contexts.quickSlots); + break; + case 0xB5: + window = new UISerachStoreInfoWnd(); + g_searchStoreInfoCreated = true; + break; + case 0xD1: + window = new UIEntryQueueStandByWnd(contexts.windows, contexts.frames, contexts.entryQueue); + break; + } + + int savedX; + int savedY; + auto saved = this->savedRectangles.find(id); + if (saved != this->savedRectangles.end() && saved->second != nullptr) { + savedX = saved->second->x; + savedY = saved->second->y; + } else { + savedX = reinterpret_cast(g_session).Integer(xKey.c_str(), x); + savedY = reinterpret_cast(g_session).Integer(yKey.c_str(), y); + } + + window->SetId(id); + window->SetSize(width, height); + if (savedX >= 0 && savedX <= g_renderer->viewport.width - window->geometry.width && savedY >= 0 && + savedY <= g_renderer->viewport.height - window->geometry.height) { + x = savedX; + y = savedY; + } + + window->Move(x, y); + this->rendered.push_back(window); + if (id == 0x9F) { + window->SendMsg(nullptr, 0x22, reinterpret_cast(this->unknown_0934), 0, 0, 0); + } else if (id == 0x9D) { + window->SendMsg(nullptr, 0x22, reinterpret_cast(this->unknown_0944), 0, 0, 0); + } else if (id == 0xD4) { + window->SendMsg(nullptr, 0x22, reinterpret_cast(this->unknown_09D4), 0, 0, 0); + } + } + + return window; +} diff --git a/Source/UI/Window/UIWindowFactory.h b/Source/UI/Window/UIWindowFactory.h index 519da17e..1a856486 100644 --- a/Source/UI/Window/UIWindowFactory.h +++ b/Source/UI/Window/UIWindowFactory.h @@ -1,27 +1,6 @@ #ifndef RAGNAROK_SOURCE_UI_WINDOW_UIWINDOWFACTORY_H #define RAGNAROK_SOURCE_UI_WINDOW_UIWINDOWFACTORY_H -class UIWindow; -class UIWindowMgr; -struct UIWindowContext; -struct UIFrameContext; -struct UIEntryQueueContext; -struct UIListBoxContext; -struct QuickSlotPainting; -struct ScriptOptions; - -struct UIWindowFactory { - UIWindowMgr& windows; - UIWindowContext& windowContext; - UIFrameContext& frames; - UIEntryQueueContext& entryQueue; - UIListBoxContext& listBox; - QuickSlotPainting& quickSlots; - ScriptOptions& options; - - UIWindow* CreateFromLayout(int id); -}; - extern bool g_searchStoreInfoCreated; #endif diff --git a/Source/UI/Window/UIWindowMgr.h b/Source/UI/Window/UIWindowMgr.h index bbc71db9..9b9d9444 100644 --- a/Source/UI/Window/UIWindowMgr.h +++ b/Source/UI/Window/UIWindowMgr.h @@ -443,6 +443,7 @@ public: void ArrangeMiniPartyWindows(); void AddMiniPartyWindow(UIWindow* window); void RearrangeMiniPartyWindows(); + void RebuildMiniPartyWindows(); static int ScaleToViewportWidth(int value); static int CenterOnViewportX(int x); static int CenterOnViewportY(int y); @@ -459,6 +460,7 @@ public: void sub_AAB090(); void sub_AAB0B0(); UIWindow* EnsureWindow(int id); + UIWindow* CreateLayoutWindow(int id); void GetMiniPartyUsableArea(RECT* area); UIWindow* FindSnapExcludedWindow(int cell); void Schedule(UIWindow* window);