diff --git a/Source/UI/Chat/UISubChatHisWnd.h b/Source/UI/Chat/UISubChatHisWnd.h index 76d65fe8..a3bd009e 100644 --- a/Source/UI/Chat/UISubChatHisWnd.h +++ b/Source/UI/Chat/UISubChatHisWnd.h @@ -7,6 +7,7 @@ class UIChatHisBox; class UIEditCtrl; +class UIWindowMgr; struct SubChatHisWndInfo; struct SubChatHistoryState { @@ -20,7 +21,10 @@ struct SubChatHistoryState { }; class UISubChatHisWnd : public UIFrameWnd { + friend class UIWindowMgr; + public: + UISubChatHisWnd(); void Move(int x, int y) override; void Slot11() override; void Paint() override; diff --git a/Source/UI/Window/UIRegisterMgr.cpp b/Source/UI/Window/UIRegisterMgr.cpp new file mode 100644 index 00000000..b84d3766 --- /dev/null +++ b/Source/UI/Window/UIRegisterMgr.cpp @@ -0,0 +1,7 @@ +#include "UI/Window/UIRegisterMgr.h" + +// OFFSET: 0x00A970A0 +// FUNCTION: fn_17199 +bool CUIRegisterMgr::sub_A970A0(int key) { + return this->entries.find(key) != this->entries.end(); +} diff --git a/Source/UI/Window/UIRegisterMgr.h b/Source/UI/Window/UIRegisterMgr.h new file mode 100644 index 00000000..5c66ac1a --- /dev/null +++ b/Source/UI/Window/UIRegisterMgr.h @@ -0,0 +1,25 @@ +#ifndef RAGNAROK_SOURCE_UI_WINDOW_UIREGISTERMGR_H +#define RAGNAROK_SOURCE_UI_WINDOW_UIREGISTERMGR_H + +#include +#include +#include + +class CUIRegisterMgr { +public: + bool sub_A970A0(int key); + + /* 0000 */ void* vtable; + /* 0004 */ std::map entries; + /* 000C */ std::map unknown_000C; + /* 0014 */ std::map unknown_0014; + /* 001C */ CRITICAL_SECTION lock; +}; + +#if defined(_WIN32) && !defined(_WIN64) +static_assert(sizeof(CUIRegisterMgr) == 0x34); +static_assert(offsetof(CUIRegisterMgr, entries) == 0x4); +static_assert(offsetof(CUIRegisterMgr, lock) == 0x1C); +#endif + +#endif diff --git a/Source/UI/Window/UIWindowMgr.cpp b/Source/UI/Window/UIWindowMgr.cpp index 8103d0a6..e911328c 100644 --- a/Source/UI/Window/UIWindowMgr.cpp +++ b/Source/UI/Window/UIWindowMgr.cpp @@ -1,6 +1,10 @@ +#include "Render/Renderer.h" +#include "UI/Chat/UISubChatHisWnd.h" #include "Client/Browser/WebBrowser.h" #include "Client/Mode/ModeMgr.h" #include "Client/Replay.h" +#include "Client/ReplayPacketRecorder.h" +#include "Client/Session.h" #include "Contents/Configuration/ServiceConfiguration.h" #include "Contents/Configuration/ServiceOptions.h" #include "Network/Connection/Connection.h" @@ -8,7 +12,9 @@ #include "Network/Packets/PacketLengths.h" #include "UI/Layout/SnapMgr.h" #include "UI/Lists/UIDropDownBox.h" +#include "UI/Chat/ChatSuggestions.h" #include "UI/Window/MiniPartyWndAreaMgr.h" +#include "UI/Window/WindowDialogs.h" #include "UI/Window/UIWindow.h" #include "UI/Window/UIWindowMgr.h" #include "Render/DeviceContext/DCSurface.h" @@ -37,6 +43,9 @@ CMiniPartyWndAreaMgr* g_miniPartyWndAreaMgr = nullptr; // GLOBAL: gl_24366 UIWindowMgr g_windowMgr; +// GLOBAL: gl_25090 +unsigned char g_windowCloseByte; + // OFFSET: 0x00A94FD0 // FUNCTION: fn_17179 void UIWindowMgr::InitializeWindowPolicy() { @@ -1002,3 +1011,165 @@ std::vector UIWindowMgr::SaveReplayWindows() { } return data; } + +void __fastcall sub_DFF150(CSession* session); + +// OFFSET: 0x00A8C4B0 +// FUNCTION: fn_17132 +void UIWindowMgr::sub_A8C4B0(int id) { + g_session.EraseRecord0734(id); + this->unknown_4F248.push_back(id); + sub_DFF150(&g_session); +} + +__forceinline void RecordEditTextsNoArg(UIWindow* window) { + union { + int (UIWindow::*method)(WindowReplayRecorder&); + void (__thiscall* call)(UIWindow*); + } convert; + convert.method = &UIWindow::RecordEditTexts; + convert.call(window); +} + +// OFFSET: 0x00A8CA20 +// FUNCTION: fn_17139 +bool UIWindowMgr::sub_A8CA20() { + if (g_replayAnimationScaling != 0) { + return false; + } + + bool handled = true; + if (!this->modalWindows.empty() && this->modalWindows.back() != nullptr) { + reinterpret_cast(this)->Top()->SendMsg(nullptr, 0, 0, 0, 0, 0); + return true; + } + + UIWindow* window = reinterpret_cast(static_cast(this->unknown_0234)); + if (window == nullptr) { + window = reinterpret_cast(static_cast(this->unknown_0314)); + if (window != nullptr) { + if (Replay::Instance().state == 2) { + RecordEditTextsNoArg(window); + } + window->SendMsg(nullptr, 0, 0, 0, 0, 0); + return true; + } + window = reinterpret_cast(static_cast(this->unknown_0318)); + if (window != nullptr) { + if (Replay::Instance().state == 2) { + RecordEditTextsNoArg(window); + } + window->SendMsg(nullptr, 0, 0, 0, 0, 0); + return true; + } + window = this->unknown_01F8; + if (window == nullptr) { + window = this->unknown_01F0; + } + if (window == nullptr) { + window = this->unknown_01F4; + } + if (window == nullptr) { + window = this->unknown_0214; + } + if (window == nullptr) { + window = this->unknown_021C; + if (window != nullptr) { + window->SendMsg(nullptr, 0x13, 0, 0, 0, 0); + return true; + } + window = this->unknown_020C; + if (window == nullptr) { + window = this->unknown_0374; + } + if (window == nullptr) { + window = reinterpret_cast(static_cast(this->unknown_0378)); + } + if (window == nullptr) { + window = reinterpret_cast(static_cast(this->unknown_030C)); + } + if (window == nullptr) { + if (this->hoverWindow != nullptr) { + if (this->window_01C8 != nullptr && this->hoverWindow->parent == this->window_01C8) { + if (reinterpret_cast(this->window_01C8)->Visible()) { + UIWindow* child = *reinterpret_cast(reinterpret_cast(this->window_01C8) + 0x13C); + if (child != nullptr) { + child->SendMsg(nullptr, 0xB0, 0xD, 0, 0, 0); + return true; + } + } + handled = false; + } + if (Replay::Instance().state == 2 && handled) { + RecordEditTextsNoArg(this->hoverWindow->Root()); + } + if (g_windowCloseByte == 0) { + handled = true; + } else if (!handled) { + return false; + } + this->hoverWindow->SendMsg(nullptr, 0, 0, 0, 0, 0); + return handled; + } + window = this->window_03D4; + if (window == nullptr) { + if (this->window_01C8 != nullptr && reinterpret_cast(&g_windowCloseByte)[-2] == 1) { + handled = false; + RecordEditTextsNoArg(this->window_01C8); + window = this->window_01C8; + } else { + for (UIWindow* item : this->rendered) { + if (!item->Slot02()) { + continue; + } + if (g_replayAnimationScaling == 0) { + RecordEditTextsNoArg(item->Root()); + } + item->SendMsg(nullptr, 0, 0, 0, 0, 0); + } + return false; + } + } + } + } + } + + window->SendMsg(nullptr, 0, 0, 0, 0, 0); + return handled; +} + +// OFFSET: 0x00A97580 +// FUNCTION: fn_17205 +UIWindow* UIWindowMgr::sub_A97580(int id, int x, int y, int width, int height) { + if (x == -1 && y == -1) { + x = (id + 10) * 10; + y = (id + 5) * 20; + } + if (width == 0 || width > g_renderer->viewport.width) { + width = 300; + } + if (height == 0 || height > g_renderer->viewport.height) { + height = 0x5F; + } + int posX = g_renderer->viewport.width - width; + if (x <= g_renderer->viewport.width) { + posX = x; + } + int posY = y; + if (y > g_renderer->viewport.height) { + posY = 100; + } + + UIWindow* window = this->retainedWindows[id]; + if (window == nullptr) { + UISubChatHisWnd* created = new UISubChatHisWnd(); + created->m_index = id; + created->SetSize(width, height); + created->Move(posX, posY); + this->rendered.push_back(created); + this->retainedWindows[id] = created; + window = created; + } + window->Show(1); + return window; +} diff --git a/Source/UI/Window/UIWindowMgr.h b/Source/UI/Window/UIWindowMgr.h index 8495b588..f0dd16a5 100644 --- a/Source/UI/Window/UIWindowMgr.h +++ b/Source/UI/Window/UIWindowMgr.h @@ -500,6 +500,9 @@ public: bool IsOrderFixed(int id); void RemoveOrder(int id); void BringToFront(int id); + void sub_A8C4B0(int id); + bool sub_A8CA20(); + UIWindow* sub_A97580(int id, int x, int y, int width, int height); void SetCapture(UIWindow* window); void ReleaseCapture(); UIWindow* Capture() const; diff --git a/data/compile.json b/data/compile.json index 69d52dae..df5cd286 100644 --- a/data/compile.json +++ b/data/compile.json @@ -1017,6 +1017,7 @@ "Source/UI/Window/UIPetEvolutionWnd.cpp": 2, "Source/UI/Window/UIRPImageWnd2.cpp": 2, "Source/UI/Window/UIRebirthWnd.cpp": 2, + "Source/UI/Window/UIRegisterMgr.cpp": 2, "Source/UI/Window/UIResizer.cpp": 2, "Source/UI/Window/UIRoMapWnd.cpp": 2, "Source/UI/Window/UIRodexContentsWnd.cpp": 2,