diff --git a/Source/UI/Window/UISeekPartyMBWnd.cpp b/Source/UI/Window/UISeekPartyMBWnd.cpp index fc97585f..bd064ccf 100644 --- a/Source/UI/Window/UISeekPartyMBWnd.cpp +++ b/Source/UI/Window/UISeekPartyMBWnd.cpp @@ -1,7 +1,153 @@ #include "UI/Window/UISeekPartyMBWnd.h" #include "Contents/MessageTable.h" +#include "Contents/UserData/NormalItemSlots.h" +#include "Network/Connection/Connection.h" +#include "Network/Packets/PacketId.h" +#include "Network/Packets/PacketLengths.h" #include "UI/Buttons/UICheckBox.h" +#include "UI/Edit/UIEditCtrl.h" #include "UI/Lists/UIComboBoxDefWnd.h" +#include "UI/Window/UISeekPartyWnd.h" +#include "UI/Window/UIWindowMgr.h" +#include "UI/Window/WindowDialogs.h" +#include "UI/Window/WindowManagerWindows.h" +#include "Utility/Text/FormatString.h" + +#include +#include +#include + +namespace { +#pragma pack(push, 1) +struct PACKET_CZ_PARTY_BOOKING_REQ_REGISTER { + /* 0000 */ short packetType; + /* 0002 */ PARTY_BOOKING_DETAIL detail; +}; +#pragma pack(pop) +} + +// OFFSET: 0x00939EE0 +// FUNCTION: fn_12756 +int UISeekPartyMBWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std::intptr_t b, std::intptr_t c, std::intptr_t d) { + WindowDialogs& dialogs = *reinterpret_cast(&g_windowMgr); + + switch (message) { + case 6: + switch (a) { + case 184: { + for (int i = 0; i < 6; ++i) { + this->m_registration.detail.job[i] = -1; + } + + int count = 0; + for (int category = 0; category < 8; ++category) { + std::map& checks = this->m_jobChecks[category]; + for (auto it = checks.begin(); it != checks.end(); ++it) { + if (it->second->geometry.unknown_0030) { + if (count < 6) { + this->m_registration.detail.job[count] = it->first; + } + ++count; + } + } + } + + if (count == 0) { + dialogs.Confirm(LookupMessage(1768), 0, true, false, 0, "Message", 280, 120, 0); + break; + } + + if (count > 6) { + char text[100]; + std::memset(text, 0, sizeof(text)); + std::sprintf(text, LookupMessage(1769), count); + dialogs.Confirm(text, 0, true, false, 0, "Message", 280, 120, 0); + break; + } + + std::string level(this->m_levelEdit->Text()); + for (unsigned int i = 0; i < level.size(); ++i) { + if (level[i] < '/' || level[i] > '9') { + dialogs.Confirm(LookupMessage(1770), 0, true, false, 0, "Message", 280, 120, 0); + return 0; + } + } + + this->m_registration.detail.level = static_cast(std::atoi(this->m_levelEdit->Text())); + g_partyBookingLevelLimit = this->m_registration.detail.level; + const int maximum = g_partyBookingLevelMax; + if (this->m_registration.detail.level >= 1 && this->m_registration.detail.level <= maximum) { + this->m_registration.detail.mapId = static_cast((this->m_type + 1) * 256 | this->m_subType); + if (!this->m_frameContext->windows.CloseWindow(164)) { + PACKET_CZ_PARTY_BOOKING_REQ_REGISTER packet; + packet.packetType = ID_CZ_PARTY_BOOKING_REQ_REGISTER; + packet.detail = this->m_registration.detail; + GetRagConnection().Send(g_packetLengths.FixedLength(packet.packetType), &packet); + } + } else { + char text[260]; + std::memset(text, 0, sizeof(text)); + StringFormat(text, sizeof(text), static_cast(-1), LookupMessage(2601), maximum); + dialogs.Confirm(text, 0, true, false, 0, "Message", 280, 120, 0); + } + break; + } + case 185: + case 201: + this->m_frameContext->windows.CloseWindow(168); + this->m_frameContext->windows.CloseWindow(170); + break; + case 202: + if (this->m_minimized) { + this->Resize(this->geometry.width, this->m_restoreHeight); + } else { + this->m_restoreHeight = this->geometry.height; + this->Resize(this->geometry.width, 17); + } + + this->m_minimized = !this->m_minimized; + this->Invalidate(); + break; + } + break; + case 34: + this->m_saved = reinterpret_cast(a); + if (!this->m_saved->IsValid()) { + this->m_saved->Reset(); + } + + this->Move(this->m_saved->x, this->m_saved->y); + this->SendMsg(nullptr, 14, 3, this->m_saved->width, this->m_saved->height, 0); + this->SendMsg(nullptr, 23, 0, 0, 0, 0); + break; + case 39: + if (sender == this->m_typeCombo) { + const int key = a + 2; + this->m_subTypeCombo->Clear(); + auto found = this->m_subTypes.find(key); + if (found != this->m_subTypes.end()) { + const std::vector> entries = found->second; + for (auto it = entries.begin(); it != entries.end(); ++it) { + const std::pair entry = *it; + this->m_subTypeCombo->AddOption(entry.first.c_str(), entry.second); + } + } + + this->m_type = static_cast(a); + this->m_subTypeCombo->Select(0); + this->m_subType = 0; + } else if (sender == this->m_subTypeCombo) { + this->m_subType = static_cast(a); + } else if (sender == this->m_jobCategoryCombo) { + this->ShowJobCategory(a); + } + break; + default: + return UIFrameWnd::SendMsg(sender, message, a, b, c, d); + } + + return 0; +} // OFFSET: 0x00944370 // FUNCTION: fn_12831 diff --git a/Source/UI/Window/UISeekPartyMBWnd.h b/Source/UI/Window/UISeekPartyMBWnd.h index 9aadecb2..64d09665 100644 --- a/Source/UI/Window/UISeekPartyMBWnd.h +++ b/Source/UI/Window/UISeekPartyMBWnd.h @@ -1,33 +1,53 @@ #ifndef RAGNAROK_SOURCE_UI_WINDOW_UISEEKPARTYMBWND_H #define RAGNAROK_SOURCE_UI_WINDOW_UISEEKPARTYMBWND_H +#include "Contents/Party/PartyBookingInfo.h" #include "UI/Window/UIFrameWnd.h" #include +#include +#include +#include struct UIButtonContext; struct SeekPartyMBWndInfo; class UICheckBox; class UIComboBoxDefWnd; +class UIEditCtrl; + +#pragma pack(push, 1) +struct SeekPartyRegistration { + /* 0000 */ PARTY_BOOKING_DETAIL detail; +}; +#pragma pack(pop) class UISeekPartyMBWnd : public UIFrameWnd { public: void Slot11() override; void Paint() override; + int SendMsg(UIWindow* sender, int message, std::intptr_t a, std::intptr_t b, std::intptr_t c, std::intptr_t d) override; void CreateJobChecks(); void InitJobCategoryCombo(); void ShowJobCategory(int category); protected: - /* 00BC */ unsigned char unknown_00BC[0x14]; + /* 00BC */ unsigned char unknown_00BC[8]; + /* 00C4 */ UIEditCtrl* m_levelEdit; + /* 00C8 */ UIComboBoxDefWnd* m_typeCombo; + /* 00CC */ UIComboBoxDefWnd* m_subTypeCombo; /* 00D0 */ UIComboBoxDefWnd* m_jobCategoryCombo; /* 00D4 */ unsigned char unknown_00D4[0x30]; /* 0104 */ std::map m_jobChecks[8]; - /* 0144 */ unsigned char unknown_0144[0x18]; + /* 0144 */ unsigned char unknown_0144[8]; + /* 014C */ std::map>> m_subTypes; + /* 0154 */ unsigned char unknown_0154[8]; /* 015C */ int m_jobCategory; - /* 0160 */ unsigned char unknown_0160[0x8]; + /* 0160 */ short m_type; + /* 0162 */ short m_subType; + /* 0164 */ int m_restoreHeight; /* 0168 */ unsigned char m_minimized; - /* 0169 */ unsigned char unknown_0169[0x13]; + /* 0169 */ SeekPartyRegistration m_registration; + /* 0179 */ unsigned char unknown_0179[3]; /* 017C */ SeekPartyMBWndInfo* m_saved; UIButtonContext* m_controls; }; diff --git a/Source/UI/Window/UISeekPartyWnd.h b/Source/UI/Window/UISeekPartyWnd.h index e9aa94ed..5bbd67f6 100644 --- a/Source/UI/Window/UISeekPartyWnd.h +++ b/Source/UI/Window/UISeekPartyWnd.h @@ -10,6 +10,9 @@ class UIStaticText; struct UIButtonContext; struct SeekPartyWndInfo; +extern int g_partyBookingLevelLimit; +extern int g_partyBookingLevelMax; + class UISeekPartyWnd : public UIFrameWnd { public: void Slot11() override;