rodecomp/Source/UI/Items/UIMakeTargetListWnd.cpp
ragnarok-clanker 858265cc69 Maintenance: Second pass: name remaining numeric switch case labels (identifier-only; no code change). ~3,500 more labels across 150
Batch #14936 by ragnarok-clanker: no function's compiled code changes; checked with 158 compiled unit(s), including every includer of Source/Client/Mode/GameModeEnums.h, Source/Client/Mode/ModeMessage.h, Source/Contents/Actors/ActorEnums.h, Source/Contents/Actors/PetEnums.h, Source/Contents/Combat/CombatTypes.h, Source/Contents/Configuration/ServiceEnums.h, Source/Contents/Effects/EffectPrimId.h, Source/Contents/Hotkeys/InterfaceHotkey.h, Source/Contents/Items/ItemId.h, Source/Contents/Items/ItemType.h, Source/Network/Packets/ModeResultEnums.h, Source/Network/Packets/NoticeEnums.h, Source/Network/Packets/PacketId.h, Source/UI/Window/UIEnums.h, Source/UI/Window/WindowId.h.
2026-11-08 12:37:46 +00:00

161 lines
4.4 KiB
C++

#include "UI/Items/UIMakeTargetListWnd.h"
#include "UI/Window/UIEnums.h"
#include "Client/Input/InputCharset.h"
#include "Client/Mode/ModeMgr.h"
#include "Client/Replay.h"
#include "Client/Session.h"
#include "Contents/Configuration/ServiceConfiguration.h"
#include "Contents/Jobs/JobId.h"
#include "Contents/Items/ItemDescription.h"
#include "Contents/Items/ItemInfo.h"
#include "Contents/Items/ItemNaming.h"
#include "Contents/MessageTable.h"
#include "Contents/PlayerNameDictionary.h"
#include "UI/Buttons/UIButton.h"
#include "UI/Lists/UIListBox.h"
#include "UI/Window/WindowManagerWindows.h"
#include <cstdint>
#include <cstring>
#include <vector>
// OFFSET: 0x009A0490
// FUNCTION: fn_13600
std::vector<unsigned char> UIMakeTargetListWnd::GetReplayData() {
std::vector<unsigned char> records;
{
const auto record = BuildReplayTaggedRecord(22050, nullptr, 0);
records.insert(records.end(), record.begin(), record.end());
}
for (auto it = this->itemIds.begin(); it != this->itemIds.end(); ++it) {
const auto record = BuildReplayTaggedRecord(22052, &*it, sizeof(*it));
records.insert(records.end(), record.begin(), record.end());
}
{
const auto record = BuildReplayTaggedRecord(22051, nullptr, 0);
records.insert(records.end(), record.begin(), record.end());
}
return records;
}
// OFFSET: 0x009A38A0
// FUNCTION: fn_13610
void UIMakeTargetListWnd::Paint() {
const int titleHeight = this->DrawTitleBar(true, LookupMessage(425), 0);
this->DrawPanelBackground(titleHeight, 0, "");
this->DrawButtonBar(2, 0, 1);
}
// OFFSET: 0x009A42E0
// FUNCTION: fn_13616
int UIMakeTargetListWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std::intptr_t b, std::intptr_t c, std::intptr_t d) {
ITEM_INFO item;
switch (message) {
case UM_ADDITEM: {
const int itemId = static_cast<int>(a);
this->itemIds.push_back(itemId);
item.SetItemId(itemId);
item.unknown_0060 = 0;
item.identified = 1;
this->m_list->AddLine(item.DisplayName(0).c_str());
return 0;
}
case UM_UPPUSH:
this->m_list->SendMsg(nullptr, 18, 0, 0, 0, 0);
return 0;
case UM_DOWNPUSH:
this->m_list->SendMsg(nullptr, 19, 0, 0, 0, 0);
return 0;
case UM_COMMAND: {
const int response = static_cast<int>(a);
this->RecordResponse(response, b, c, this->m_list->selected);
switch (response) {
case ID_OK: {
if (g_replayAnimationScaling) {
this->m_list->selected = static_cast<int>(d);
this->m_list->Invalidate();
}
UIListBox* list = this->m_list;
if (list->LineCount() == 0) {
g_windowMgr.CloseWindow(79);
g_windowMgr.CloseWindow(79);
return 0;
}
if (list->selected >= 0) {
switch (g_session.m_job) {
case JT_RUNE_KNIGHT:
case JT_RUNE_KNIGHT_H:
case JT_RUNE_KNIGHT_B:
case JT_DRAGON_KNIGHT: {
ITEM_INFO materials[3];
g_modeMgr.GetGameMode()->SendMsg(130, this->itemIds[this->m_list->selected], reinterpret_cast<int>(materials), 0, 0);
g_windowMgr.CloseWindow(79);
return 0;
}
default: {
UIWindow* window = g_windowMgr.EnsureWindow(80);
window->SendMsg(this, 40, this->itemIds[this->m_list->selected], 0, 0, 0);
window->Move(this->geometry.x, this->geometry.y);
g_windowMgr.CloseWindow(79);
return 0;
}
}
}
break;
}
case ID_CANCEL: {
ITEM_INFO materials[3];
g_modeMgr.GetGameMode()->SendMsg(130, 0, reinterpret_cast<int>(materials), 0, 0);
g_windowMgr.CloseWindow(79);
return 0;
}
}
return 0;
}
case 123: {
const auto* bytes = reinterpret_cast<const unsigned char*>(a);
std::uint16_t marker;
std::memcpy(&marker, bytes, sizeof(marker));
unsigned offset = 6;
if (marker == 22050) {
while (static_cast<unsigned>(b) > offset) {
std::int16_t kind;
std::uint32_t size;
std::memcpy(&kind, bytes + offset, sizeof(kind));
std::memcpy(&size, bytes + offset + 2, sizeof(size));
offset += 6;
if (kind == 22051) {
break;
}
if (kind == 22052) {
int itemId = 0;
std::memcpy(&itemId, bytes + offset, size);
offset += size;
this->SendMsg(nullptr, 31, itemId, 0, 0, 0);
} else {
offset += size;
}
}
}
return 0;
}
}
return this->UIFrameWnd::SendMsg(sender, message, a, b, c, d);
}