From a7dd2ac056326bc9743e8fc0f37dc97df313d8f0 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 15:09:41 +0000 Subject: [PATCH] Decompile fn_17225 (UIWindowMgr::CycleWindowVisibility) Batch #8202 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_17225 UIWindowMgr::CycleWindowVisibility: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, Yommy, gordaoprogramas Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Client/Mode/CGameMode.h | 4 +- Source/UI/Window/UIWindowMgr.cpp | 101 +++++++++++++++++++++++++++++++ Source/UI/Window/UIWindowMgr.h | 1 + 3 files changed, 105 insertions(+), 1 deletion(-) diff --git a/Source/Client/Mode/CGameMode.h b/Source/Client/Mode/CGameMode.h index 8cf9e624..642ebdec 100644 --- a/Source/Client/Mode/CGameMode.h +++ b/Source/Client/Mode/CGameMode.h @@ -135,7 +135,9 @@ public: /* 05D0 */ UIWindow* unknown_05D0; /* 05D4 */ unsigned char unknown_05D4[0x14]; /* 05E8 */ std::uint32_t replayPauseTick; - /* 05EC */ unsigned char unknown_05EC[0x18]; + /* 05EC */ unsigned char unknown_05EC[0x10]; + /* 05FC */ UIWindow* unknown_05FC; + /* 0600 */ unsigned char unknown_0600[0x4]; /* 0604 */ std::list unknown_0604; /* 060C */ unsigned char unknown_060C[0x10]; /* 061C */ UIBroadcastBalloon* broadcastBalloon; diff --git a/Source/UI/Window/UIWindowMgr.cpp b/Source/UI/Window/UIWindowMgr.cpp index e3d1a4a3..dd05504f 100644 --- a/Source/UI/Window/UIWindowMgr.cpp +++ b/Source/UI/Window/UIWindowMgr.cpp @@ -31,6 +31,9 @@ #include "UI/Window/UIWindow.h" #include "UI/Window/UIWindowMgr.h" #include "Client/Mode/CMode.h" +#include "Client/Mode/CGameMode.h" +#include "Contents/Actors/Pc.h" +#include "Contents/World/World.h" #include "Contents/RouletteMgr.h" #include "UI/Item/UIItemStoreWnd.h" #include "UI/Item/UIItemWnd.h" @@ -1158,6 +1161,104 @@ int UIWindowMgr::LoadReplayReserved(const std::vector& data) { return static_cast(offset); } +// OFFSET: 0x00AA5B00 +// FUNCTION: fn_17225 +void UIWindowMgr::CycleWindowVisibility(int) { + for (std::list::iterator it = this->hiddenWindows.begin(); it != this->hiddenWindows.end();) { + std::list::iterator next = it; + ++next; + if (std::find(this->rendered.begin(), this->rendered.end(), *it) == this->rendered.end()) { + this->hiddenWindows.erase(it); + } + it = next; + } + + const int state = this->unknown_0508; + if (state == 0) { + if (this->unknown_01DC) { + this->unknown_01DC->SendMsg(nullptr, 6, 222, 0, 0, 0); + } + if (this->hiddenWindows.size() == 0) { + for (std::list::iterator it = this->rendered.begin(); it != this->rendered.end(); ++it) { + if ((*it)->geometry.visible) { + this->hiddenWindows.push_back(*it); + } + } + } + this->unknown_0508 = 1; + } else if (state == 1) { + bool closed = false; + for (std::list::iterator it = this->rendered.begin(); it != this->rendered.end(); ++it) { + UIWindow* window = *it; + if (window->geometry.visible) { + const int id = window->geometry.id; + if (!this->IsOrderFixed(id)) { + this->CloseWindow(id); + closed = true; + } else if (std::find(this->hiddenWindows.begin(), this->hiddenWindows.end(), window) == this->hiddenWindows.end()) { + this->hiddenWindows.push_back(*it); + } + } + } + if (closed) { + if (this->unknown_01DC) { + this->unknown_01DC->SendMsg(nullptr, 6, 222, 0, 0, 0); + } + return; + } + + for (std::list::iterator it = this->rendered.begin(); it != this->rendered.end(); ++it) { + UIWindow* window = *it; + if (window != reinterpret_cast(static_cast(g_modeMgr.GetGameMode())->EnsureBroadcastBalloon())) { + window->Show(0); + } + } + this->CloseWindow(14); + CPlayer* player = static_cast(g_modeMgr.GetGameMode())->scene->player; + if (player) { + player->SendMsg(nullptr, 109, 0, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + player->unknown_0544 = 0; + } + this->unknown_0508 = 2; + } else if (state == 2) { + bool closed = false; + for (std::list::iterator it = this->rendered.begin(); it != this->rendered.end(); ++it) { + if (*it != reinterpret_cast(static_cast(g_modeMgr.GetGameMode())->EnsureBroadcastBalloon()) && + *it != static_cast(g_modeMgr.GetGameMode())->unknown_05FC && (*it)->geometry.visible) { + UIWindow* window = *it; + if (std::find(this->hiddenWindows.begin(), this->hiddenWindows.end(), window) != this->hiddenWindows.end()) { + window->Show(0); + } else { + this->CloseWindow(window->geometry.id); + } + closed = true; + } + } + if (closed) { + this->ShowWindows189(0); + if (this->unknown_01DC) { + this->unknown_01DC->SendMsg(nullptr, 6, 222, 0, 0, 0); + } + return; + } + + for (std::list::iterator it = this->hiddenWindows.begin(); it != this->hiddenWindows.end(); ++it) { + (*it)->Show(1); + } + for (std::list::iterator it = this->rendered.begin(); it != this->rendered.end(); ++it) { + if ((*it)->geometry.id == 189) { + (*it)->Show(g_serviceOptions.Get(250) ? 1 : 0); + } + } + CGameMode* mode = static_cast(g_modeMgr.GetGameMode()); + if (mode && mode->unknown_0254 == 1) { + this->EnsureWindow(14); + } + static_cast(g_modeMgr.GetGameMode())->scene->player->RefreshEffect164(); + this->unknown_0508 = 1; + } +} + // OFFSET: 0x00AA8D10 // FUNCTION: fn_17249 int UIWindowMgr::LoadReplayWindows(const std::vector& data) { diff --git a/Source/UI/Window/UIWindowMgr.h b/Source/UI/Window/UIWindowMgr.h index 7e9d9ec3..bbc71db9 100644 --- a/Source/UI/Window/UIWindowMgr.h +++ b/Source/UI/Window/UIWindowMgr.h @@ -546,6 +546,7 @@ public: int LoadReplaySettings(const std::vector& data); int LoadReplayReserved(const std::vector& data); int LoadReplayWindows(const std::vector& data); + void CycleWindowVisibility(int unused); void BroadcastMessage21(); bool HasModalWindow(); int TranslateHotkey(int key, int keyData);