rodecomp/Source/UI/Window/UIBasicInfoWnd.cpp
ragnarok-clanker 01cb3e00bf Decompile fn_13498 (UIBasicInfoWnd::SendMsg)
Batch #8594 by eAthena: 0 byte-identical, 1 confirmed by peer review.

- fn_13498 UIBasicInfoWnd::SendMsg: logic confirmed by peer review

Peer-reviewed-by: gordaoprogramas, Lumen, Tanke, dori
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-10-31 19:35:14 +00:00

332 lines
9.9 KiB
C++

#include "UI/Window/UIBasicInfoWnd.h"
#include "Client/Session.h"
#include "UI/Buttons/UIButton.h"
#include "UI/Text/UIStaticText.h"
#include "UI/Window/UIWindowMgr.h"
#include "Contents/MessageTable.h"
#include "UI/Items/UIEquipWnd.h"
#include "UI/Layout/SnapMgr.h"
#include "UI/Layout/WindowSnapping.h"
#include "UI/Lists/UITabControl.h"
#include "UI/Shortcuts/ShortcutVisibility.h"
#include "UI/Window/WindowDialogs.h"
#include "UI/Window/WindowOrdering.h"
#include <cstdio>
// OFFSET: 0x00997250
// FUNCTION: fn_13484
UIBasicInfoWnd::UIBasicInfoWnd(UIWindowContext& windowContext, UIFrameContext& frameContext) : UIFrameWnd(windowContext, frameContext, 0) {
this->saved = nullptr;
this->mode = 0;
this->layoutOffset = 13;
this->collapsedHeight = 55;
this->expandedHeight = 134;
this->extendedOffset = 28;
this->extendedCollapsedHeight = 71;
this->extendedExpandedHeight = 149;
this->normalOffset = 13;
this->normalCollapsedHeight = 55;
this->normalExpandedHeight = 134;
if (g_session.IsTreeGroupThree(g_session.GetDisplayJob()) == true) {
this->layoutOffset = this->extendedOffset;
this->collapsedHeight = this->extendedCollapsedHeight;
this->expandedHeight = this->extendedExpandedHeight;
}
}
// OFFSET: 0x00998190
// FUNCTION: fn_13489
bool UIBasicInfoWnd::Slot03() {
return true;
}
// OFFSET: 0x009981A0
// FUNCTION: fn_13490
void UIBasicInfoWnd::SetHeight(int height) {
if (height == this->collapsedHeight) {
this->Resize(this->geometry.width, this->collapsedHeight);
this->nameText->Resize(this->geometry.width - 30, 15);
this->nameText->SetTextFitted(g_session.DecodePlayerName());
this->nameText->Move(17, 3);
this->hpBar->Move(-100, -100);
this->spBar->Move(-100, -100);
this->apBar->Move(-100, -100);
this->baseExpBar->Move(-100, -100);
this->jobExpBar->Move(-100, -100);
} else if (height == this->expandedHeight) {
this->Resize(this->geometry.width, this->expandedHeight);
this->hpBar->Move(35, 53);
this->spBar->Move(35, 68);
if (g_session.IsTreeGroupThree(g_session.GetDisplayJob()) == true) {
this->apBar->Move(35, 83);
}
this->nameText->Resize(this->geometry.width - 20, 15);
this->nameText->SetTextFitted(g_session.DecodePlayerName());
this->nameText->Move(9, 22);
if (g_session.GetMaxBaseLevel(g_session.GetDisplayJob()) == g_session.m_level) {
this->baseExpBar->Move(-200, 78);
} else {
this->baseExpBar->Move(85, this->layoutOffset + 76);
}
if (g_session.m_jobLevel < g_session.GetMaxJobLevel(g_session.GetDisplayJob())) {
this->jobExpBar->Move(85, this->layoutOffset + 88);
} else {
this->jobExpBar->Move(-200, 88);
}
}
if (UIWindow* window = g_windowMgr.LookupWindow(307)) {
int screenX = 0;
int screenY = 0;
this->ToScreen(screenX, screenY);
window->Move(screenX, this->geometry.height + screenY);
}
}
// OFFSET: 0x00999490
// FUNCTION: fn_13497
void UIBasicInfoWnd::RefreshLayout() {
const int height = this->geometry.height;
if (g_session.IsTreeGroupThree(g_session.GetDisplayJob())) {
if (height == this->collapsedHeight) {
this->layoutOffset = this->extendedOffset;
this->collapsedHeight = this->extendedCollapsedHeight;
this->expandedHeight = this->extendedExpandedHeight;
this->SetHeight(this->extendedCollapsedHeight);
} else if (height == this->expandedHeight) {
this->layoutOffset = this->extendedOffset;
this->collapsedHeight = this->extendedCollapsedHeight;
this->expandedHeight = this->extendedExpandedHeight;
this->SetHeight(this->extendedExpandedHeight);
}
} else {
if (height == this->collapsedHeight) {
this->layoutOffset = this->normalOffset;
this->collapsedHeight = this->normalCollapsedHeight;
this->expandedHeight = this->normalExpandedHeight;
this->SetHeight(this->normalCollapsedHeight);
} else if (height == this->expandedHeight) {
this->layoutOffset = this->normalOffset;
this->collapsedHeight = this->normalCollapsedHeight;
this->expandedHeight = this->normalExpandedHeight;
this->SetHeight(this->normalExpandedHeight);
}
this->apBar->Move(-100, -100);
}
this->Invalidate();
}
// OFFSET: 0x00999BC0
// FUNCTION: fn_13499
void UIBasicInfoWnd::Slot11() {
if (this->saved) {
this->saved->height = this->geometry.height;
this->saved->width = this->geometry.width;
this->saved->x = this->geometry.x;
this->saved->y = this->geometry.y;
this->saved->unknown_0010 = this->mode;
}
}
// OFFSET: 0x00999360
// FUNCTION: fn_13494
void UIBasicInfoWnd::Slot25(int x, int y) {
if (y < 17) {
UIFrameWnd::Slot25(x, y);
}
}
// OFFSET: 0x00999330
// FUNCTION: fn_13493
void UIBasicInfoWnd::Slot26(int x, int y) {
if (y < 17) {
this->SendMsg(this, 6, 202, 0, 0, 0);
}
}
// OFFSET: 0x00999430
// FUNCTION: fn_13496
void UIBasicInfoWnd::Slot27(int x, int y) {
UIFrameWnd::Slot27(x, y);
if (UIWindow* window = g_windowMgr.LookupWindow(307)) {
int screenX = 0;
int screenY = 0;
this->ToScreen(screenX, screenY);
window->Move(screenX, this->geometry.height + screenY);
}
}
// OFFSET: 0x00999380
// FUNCTION: fn_13495
void UIBasicInfoWnd::Slot28(int x, int y) {
if (this->geometry.height != this->expandedHeight) {
return;
}
int top = this->geometry.height - 20;
if (x < 0 || x >= 100 || y < top || y >= this->geometry.height) {
return;
}
char text[64];
std::sprintf(text, "Weight %d%%", g_session.m_maxWeight ? g_session.m_weight * 100 / g_session.m_maxWeight : 0);
int screenX = 0;
int screenY = top - 19;
this->ToScreen(screenX, screenY);
this->m_controls->services.Tooltip(text, screenX, screenY, -1, false, true);
}
// OFFSET: 0x009995A0
// FUNCTION: fn_13498
int UIBasicInfoWnd::SendMsg(UIWindow* sender, int message, std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4) {
switch (message) {
case 6:
switch (argument1) {
case 192:
if (!g_windowMgr.CloseWindow(11)) {
g_windowMgr.EnsureWindow(11);
}
break;
case 193:
if (!g_windowMgr.CloseWindow(155)) {
g_windowMgr.EnsureWindow(155);
}
break;
case 194:
if (!g_windowMgr.CloseWindow(8)) {
g_windowMgr.EnsureWindow(8);
}
break;
case 195: {
UIEquipWnd* equip = dynamic_cast<UIEquipWnd*>(g_windowMgr.LookupWindow(10));
if (equip) {
if (equip->m_page == 0) {
g_windowMgr.CloseWindow(10);
return 0;
}
} else {
equip = dynamic_cast<UIEquipWnd*>(static_cast<UIFrameWnd*>(g_windowMgr.EnsureWindow(10)));
if (!equip) {
return 0;
}
}
equip->m_tabs->SelectTab(0);
break;
}
case 196:
if (!g_windowMgr.CloseWindow(37)) {
g_windowMgr.EnsureWindow(37);
}
break;
case 199:
if (!g_windowMgr.CloseWindow(69)) {
g_windowMgr.EnsureWindow(69);
}
break;
case 202: {
const int height = this->geometry.height;
this->SetHeight(height == this->collapsedHeight ? this->expandedHeight : this->collapsedHeight);
this->m_frameContext->snapping.Store(this);
reinterpret_cast<WindowOrdering&>(g_windowMgr).Promote(this);
const int delta = this->geometry.height - height;
if (delta != 0) {
g_snapMgr.MoveEdge(this, 0, delta, 3, this->m_frameContext->snapping);
}
break;
}
case 214:
if (!g_windowMgr.CloseWindow(27) && !g_windowMgr.window_027C) {
if (!g_windowMgr.unknown_02FC && !g_windowMgr.unknown_0304) {
g_windowMgr.EnsureWindow(27);
} else {
reinterpret_cast<WindowDialogs*>(&g_windowMgr)->Confirm(LookupMessage(587), 0, true, false, 0, "Message", 280, 120, 0);
}
}
break;
case 219:
if (!g_windowMgr.CloseWindow(140)) {
g_windowMgr.EnsureWindow(140);
}
break;
case 222:
g_windowMgr.CloseWindow(11);
g_windowMgr.CloseWindow(13);
g_windowMgr.CloseWindow(8);
g_windowMgr.CloseWindow(10008);
g_windowMgr.CloseWindow(10);
g_windowMgr.CloseWindow(69);
g_windowMgr.CloseWindow(27);
g_windowMgr.CloseWindow(30);
g_windowMgr.CloseWindow(37);
g_windowMgr.CloseWindow(38);
g_windowMgr.CloseWindow(88);
g_windowMgr.CloseWindow(86);
g_windowMgr.CloseWindow(87);
g_windowMgr.CloseWindow(40);
g_windowMgr.CloseWindow(59);
reinterpret_cast<WindowVisibility&>(g_windowMgr).Show(36, 0);
this->SetHeight(this->collapsedHeight);
this->m_frameContext->snapping.Store(this);
break;
case 247:
if (!g_windowMgr.LookupWindow(227) && !g_windowMgr.CloseWindow(40) && g_session.unknown_5C1C > 0) {
g_windowMgr.EnsureWindow(40);
}
break;
case 361:
if (!g_windowMgr.CloseWindow(10008)) {
g_windowMgr.EnsureWindow(10008);
}
break;
case 373:
if (!g_windowMgr.CloseWindow(59)) {
g_windowMgr.EnsureWindow(59);
}
break;
case 578: {
UIEquipWnd* equip = dynamic_cast<UIEquipWnd*>(g_windowMgr.LookupWindow(10));
if (equip) {
if (equip->m_page == 1) {
g_windowMgr.CloseWindow(10);
return 0;
}
} else {
equip = dynamic_cast<UIEquipWnd*>(static_cast<UIFrameWnd*>(g_windowMgr.EnsureWindow(10)));
if (!equip) {
return 0;
}
}
equip->m_tabs->SelectTab(1);
break;
}
}
break;
case 34:
this->saved = reinterpret_cast<BasicInfoWndInfo*>(argument1);
if (!this->saved->IsValid()) {
this->saved->Reset();
}
this->mode = this->saved->unknown_0010 != 0;
this->SetHeight(this->saved->height);
this->Move(this->saved->x, this->saved->y);
break;
case 60:
if (this->geometry.height != this->expandedHeight) {
this->Invalidate();
}
break;
default:
return UIFrameWnd::SendMsg(sender, message, argument1, argument2, argument3, argument4);
}
return 0;
}