diff --git a/Source/Client/Mode/CGameMode.h b/Source/Client/Mode/CGameMode.h index 56fd01ba0..fe12a8257 100644 --- a/Source/Client/Mode/CGameMode.h +++ b/Source/Client/Mode/CGameMode.h @@ -533,6 +533,7 @@ public: void ResendMinimapMarkers(); void ReceiveJobTitle(unsigned char result, int job); void ReceiveQuestStates(int count, const unsigned char* entries); + void ReceiveStoreResult(unsigned char kind, unsigned char result); void ReceiveMessageBox(const unsigned char* packet); void NotifyCaptchaRegistered(); void ReceiveItem1784List(const unsigned char* packet); diff --git a/Source/Client/Mode/GameModeNotices.cpp b/Source/Client/Mode/GameModeNotices.cpp index 557eaf2a1..4509dd174 100644 --- a/Source/Client/Mode/GameModeNotices.cpp +++ b/Source/Client/Mode/GameModeNotices.cpp @@ -7633,3 +7633,78 @@ void CGameMode::sub_D1A520(int unknown_0004, std::string name, std::string text, } } } + +// OFFSET: 0x00D69530 +// FUNCTION: fn_22050 +void CGameMode::ReceiveStoreResult(unsigned char kind, unsigned char result) { + if (kind == 100) { + switch (result) { + case 0: + g_windowMgr.CloseWindow(41); + reinterpret_cast(&g_session)->ClearItems1768(); + break; + case 1: + case 2: + case 3: { + UIWindow* window = g_windowMgr.LookupWindow(41); + if (window) { + static_cast(window)->SetSuspended(0); + } + break; + } + case 4: + case 6: + case 7: + reinterpret_cast(&g_session)->ClearItems1768(); + g_windowMgr.CloseWindow(41); + break; + } + } else if (kind == 101) { + switch (result) { + case 0: + g_windowMgr.CloseWindow(174); + reinterpret_cast(&g_session)->ClearItems1768(); + break; + case 1: + case 2: + case 3: { + UIWindow* window = g_windowMgr.LookupWindow(174); + if (window) { + static_cast(window)->SetSuspended(0); + } + break; + } + case 4: + case 6: + case 7: + case 8: + reinterpret_cast(&g_session)->ClearItems1768(); + g_windowMgr.CloseWindow(174); + g_windowMgr.CloseWindow(175); + break; + } + } + + switch (result) { + case 2: + g_windowMgr.SendNotice(1, reinterpret_cast(LookupMessage(2983)), 0xFF, 0, 0, 0); + break; + case 3: + g_windowMgr.SendNotice(1, reinterpret_cast(LookupMessage(1954)), 0xFF, 0, 0, 0); + break; + case 8: + g_windowMgr.SendNotice(1, reinterpret_cast(LookupMessage(56)), 0xFF, 0, 0, 0); + break; + } + + if (result == 200) { + reinterpret_cast(&g_session)->ClearItems1768(); + g_windowMgr.CloseWindow(41); + g_windowMgr.CloseWindow(174); + g_windowMgr.CloseWindow(8); + g_windowMgr.ShowWaitDBSaveWindow(); + return; + } + + g_windowMgr.CloseWindow(10024); +} diff --git a/Source/UI/Dialogs/UIWaitDBSaveWnd.cpp b/Source/UI/Dialogs/UIWaitDBSaveWnd.cpp index 33bf88f99..2b0e0615a 100644 --- a/Source/UI/Dialogs/UIWaitDBSaveWnd.cpp +++ b/Source/UI/Dialogs/UIWaitDBSaveWnd.cpp @@ -53,7 +53,7 @@ private: // FUNCTION: fn_17446 UIWaitDBSaveWnd::UIWaitDBSaveWnd(UIWindowContext& windowContext, UIWaitDBSaveWndContext& waitContext) : UIWindow(windowContext, 0), m_animation(0), m_frame(0), m_loopLimit(0), m_sprite(nullptr), m_action(nullptr), m_startTime(0), m_loop(1), - m_closeTime(0), m_waitContext(&waitContext) { + m_closeTime(0), m_waitContext(waitContext) { const std::uint8_t actionSource[] = {0x36, 0xCE, 0xE6, 0x4D, 0xCF, 0x8B, 0xAC, 0x76, 0x17, 0xCA, 0xD3, 0x77, 0xE4, 0xBE, 0xB3, 0x78, 0x00, 0xCB, 0xE6, 0x57, 0xEC, 0xE7, 0x9E, 0x74, 0x15, 0xAF}; thread_local EncryptedName actionName(actionSource); @@ -73,7 +73,7 @@ UIWaitDBSaveWnd::UIWaitDBSaveWnd(UIWindowContext& windowContext, UIWaitDBSaveWnd // OFFSET: 0x00AB4CE0 // FUNCTION: fn_17448 void UIWaitDBSaveWnd::Slot15(int width, int height) { - UIButton* button = new UIButton(*this->m_context, this->m_waitContext->buttons); + UIButton* button = new UIButton(*this->m_context, this->m_waitContext.buttons); button->SetSize(width, height); button->Move(0, 0); button->SetId(0); @@ -146,7 +146,7 @@ void UIWaitDBSaveWnd::Slot27(int, int) { void UIWaitDBSaveWnd::Slot19() { if (this->m_closeTime != 0 && timeGetTime() >= this->m_closeTime) { this->m_closeTime = 0; - this->m_waitContext->windows.CloseWindow(10024); + this->m_waitContext.windows.CloseWindow(10024); return; } diff --git a/Source/UI/Dialogs/UIWaitDBSaveWnd.h b/Source/UI/Dialogs/UIWaitDBSaveWnd.h index 0ac45cabc..492a41564 100644 --- a/Source/UI/Dialogs/UIWaitDBSaveWnd.h +++ b/Source/UI/Dialogs/UIWaitDBSaveWnd.h @@ -32,7 +32,7 @@ public: /* 0090 */ std::uint32_t m_startTime; /* 0094 */ unsigned int m_loop; /* 0098 */ std::uint32_t m_closeTime; - UIWaitDBSaveWndContext* m_waitContext; + UIWaitDBSaveWndContext m_waitContext; }; #endif diff --git a/Source/UI/Window/UIWindowMgr.cpp b/Source/UI/Window/UIWindowMgr.cpp index 06ab85315..62ae5713e 100644 --- a/Source/UI/Window/UIWindowMgr.cpp +++ b/Source/UI/Window/UIWindowMgr.cpp @@ -63,6 +63,8 @@ #include "Contents/Messenger/ClientMessenger.h" #include "UI/Text/TextMarkup.h" #include "UI/Dialogs/UIWaitDBSaveWnd.h" +#include "UI/Text/UITextViewer.h" +#include "UI/Window/UIMessageBox.h" #include "Render/Primitives/AlphaRectangle.h" #include "UI/Cooldowns/CooldownOwner.h" #include "UI/Text/UITransBalloonText.h" @@ -3945,12 +3947,14 @@ bool UIWindowMgr::CloseWindow(int id) { // OFFSET: 0x00AA2A00 // FUNCTION: fn_17218 -void UIWindowMgr::ShowWaitDBSaveWindow(UIWindowContext& windows, UIWaitDBSaveWndContext& waitContext) { +void UIWindowMgr::ShowWaitDBSaveWindow() { if (this->window_4F2AC != nullptr) { return; } - this->window_4F2AC = new UIWaitDBSaveWnd(windows, waitContext); + WindowDialogs& dialogs = *reinterpret_cast(this); + UIWaitDBSaveWndContext waitContext{*reinterpret_cast(this), dialogs.dialog.text.buttons}; + this->window_4F2AC = new UIWaitDBSaveWnd(dialogs.windows, waitContext); this->window_4F2AC->SetSize(g_renderer->viewport.width, g_renderer->viewport.height); this->window_4F2AC->Move(0, 0); this->window_4F2AC->SetId(10024); diff --git a/Source/UI/Window/UIWindowMgr.h b/Source/UI/Window/UIWindowMgr.h index 9fdf66ea3..09e79e548 100644 --- a/Source/UI/Window/UIWindowMgr.h +++ b/Source/UI/Window/UIWindowMgr.h @@ -567,7 +567,7 @@ public: bool ProcessHotkeyAction(int action, int pressed); bool sub_AA35F0(int action); bool ProcessKeyDown(int key, int keyData, int pressed); - void ShowWaitDBSaveWindow(UIWindowContext& windows, UIWaitDBSaveWndContext& waitContext); + void ShowWaitDBSaveWindow(); void SendEmotionHotkey(int index); };