The decompiled C++ tree moves to generated-src/ (classes.h, C++20); src/ is for code written by hand. A curated function defines the generated declaration and starts its comment with its address, and source_tree.py stops emitting that body. src/rng.cpp takes over RNG (SetSeed, the constructor, Next, RandomInt, RandomFloat, Shuffle) with the shift table read from the exe as a constexpr array; src/log.h names KAGE_LogMessage's levels (1 INFO, 2 NET, 4 WARN, 8 ERROR, 16 ASSERT, from its prefix jump table). CMakeLists.txt builds src/*.cpp against generated-src/classes.h (clean with -Wall -Wextra). structs.hpp and headers.py are retired: scripts/merge_fields.py writes the merged field list, classes.h checks the layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
346 lines
12 KiB
C++
346 lines
12 KiB
C++
#include "classes.h"
|
|
|
|
// 00423990
|
|
void PopupButtons::Init()
|
|
{
|
|
PopupButtons *in_ECX;
|
|
|
|
load_graphics();
|
|
reset(in_ECX,0);
|
|
return;
|
|
}
|
|
|
|
// 004239b0
|
|
void PopupButtons::reset(byte isZeroHeight)
|
|
{
|
|
this->_buttons[0]._textFrame = 1;
|
|
this->_buttons[1]._textFrame = 0;
|
|
this->_buttons[0]._buttonAction = 0xf;
|
|
this->_buttons[1]._buttonAction = 0xe;
|
|
this->_buttons[0]._isVisible = 1;
|
|
this->_buttons[0]._offset.x = g_vectorZero.x;
|
|
this->_buttons[0]._offset.y = g_vectorZero.y;
|
|
this->_buttons[0]._targetSlideOffset = 96.0;
|
|
this->_buttons[0]._slideOffset = 96.0;
|
|
if (isZeroHeight != 0) {
|
|
this->_buttons[0]._targetSlideOffset = 0.0;
|
|
}
|
|
this->_buttons[1]._isVisible = 1;
|
|
this->_buttons[1]._offset.x = g_vectorZero.x;
|
|
this->_buttons[1]._offset.y = g_vectorZero.y;
|
|
this->_buttons[1]._targetSlideOffset = 96.0;
|
|
this->_buttons[1]._slideOffset = 96.0;
|
|
if (isZeroHeight != 0) {
|
|
this->_buttons[1]._targetSlideOffset = 0.0;
|
|
}
|
|
this->_scale = 1.0;
|
|
this->_callback = (void *)0x0;
|
|
this->_callbackContext = (void *)0x0;
|
|
return;
|
|
}
|
|
|
|
// 00423aa0
|
|
void PopupButtons::load_graphics()
|
|
{
|
|
byte bVar1;
|
|
byte *curAnimChar;
|
|
ANM2 *in_ECX;
|
|
char *pcVar2;
|
|
uint size;
|
|
uint uVar3;
|
|
ANM2 *this;
|
|
bool isLess;
|
|
std_string anm2Path;
|
|
uint stackCookie;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
byte *animData;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00af18ad;
|
|
local_1c = ExceptionList;
|
|
stackCookie = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
ExceptionList = &local_1c;
|
|
uVar3 = 0;
|
|
this = in_ECX;
|
|
do {
|
|
anm2Path._size = 0;
|
|
anm2Path._capacity = 0xf;
|
|
anm2Path._buf[0] = '\0';
|
|
anm2Path._buf[1] = '\0';
|
|
anm2Path._buf[2] = '\0';
|
|
anm2Path._buf[3] = '\0';
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = std::_Allocate(0x20);
|
|
anm2Path._size = 0x1e;
|
|
anm2Path._capacity = 0x1f;
|
|
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0))),"gfx/ui/ButtonPromptWidget.anm2",0x1f);
|
|
local_14 = 0;
|
|
this->ANM2::Load(&anm2Path,1);
|
|
local_14 = 0xffffffff;
|
|
if (0xf < anm2Path._capacity) {
|
|
size = anm2Path._capacity + 1;
|
|
pcVar2 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0)));
|
|
if (0xfff < size) {
|
|
pcVar2 = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + -4));
|
|
size = anm2Path._capacity + 0x24;
|
|
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar2))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(pcVar2,size);
|
|
}
|
|
uVar3 = uVar3 + 1;
|
|
this = GHIDRA_CAST<ANM2 *>((this[1]._animDefaultName._buf + 4));
|
|
} while (uVar3 < 2);
|
|
animData = (in_ECX->_animState)._animData;
|
|
if (animData != GHIDRA_CAST<byte *>(0x0)) {
|
|
curAnimChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimChar = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
pcVar2 = "LeftPrompt";
|
|
do {
|
|
bVar1 = *curAnimChar;
|
|
isLess = bVar1 < (byte)*pcVar2;
|
|
if (bVar1 != *pcVar2) {
|
|
LAB_00423bee:
|
|
uVar3 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_00423bf3;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimChar[1];
|
|
isLess = bVar1 < (byte)pcVar2[1];
|
|
if (bVar1 != pcVar2[1]) goto LAB_00423bee;
|
|
curAnimChar = curAnimChar + 2;
|
|
pcVar2 = pcVar2 + 2;
|
|
} while (bVar1 != 0);
|
|
uVar3 = 0;
|
|
LAB_00423bf3:
|
|
if ((uVar3 == 0) && ((animData[0x34] == 0 || ((in_ECX->_animState)._isPlaying != 0))))
|
|
goto LAB_00423c1f;
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((in_ECX)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("LeftPrompt"),1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&in_ECX->_animState)))->AnimationState::Rewind();
|
|
(in_ECX->_animState)._isPlaying = 1;
|
|
}
|
|
LAB_00423c1f:
|
|
animData = in_ECX[1]._overlayAnimState._animation;
|
|
if (animData != GHIDRA_CAST<byte *>(0x0)) {
|
|
curAnimChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimChar = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
pcVar2 = "RightPrompt";
|
|
do {
|
|
bVar1 = *curAnimChar;
|
|
isLess = bVar1 < (byte)*pcVar2;
|
|
if (bVar1 != *pcVar2) {
|
|
LAB_00423c58:
|
|
uVar3 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_00423c5d;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimChar[1];
|
|
isLess = bVar1 < (byte)pcVar2[1];
|
|
if (bVar1 != pcVar2[1]) goto LAB_00423c58;
|
|
curAnimChar = curAnimChar + 2;
|
|
pcVar2 = pcVar2 + 2;
|
|
} while (bVar1 != 0);
|
|
uVar3 = 0;
|
|
LAB_00423c5d:
|
|
if (uVar3 == 0) {
|
|
if (animData[0x34] == 0) {
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
if (*GHIDRA_CAST<char *>(&in_ECX[1]._overlayAnimState._animFrame) != '\0') {
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((in_ECX[1]._animDefaultName._buf + 4)))))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("RightPrompt"),1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>(&in_ECX[1]._animState._previouslyTriggeredEvents))))->AnimationState::Rewind();
|
|
*GHIDRA_CAST<undefined1 *>(&in_ECX[1]._overlayAnimState._animFrame) = 1;
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 00423cc0
|
|
void PopupButtons::Render()
|
|
{
|
|
Vector scale;
|
|
int *piVar1;
|
|
uint uVar2;
|
|
char cVar3;
|
|
int iVar4;
|
|
LayerState *textLayer;
|
|
Vector *renderPos;
|
|
byte *str;
|
|
int in_ECX;
|
|
AnimationState *this;
|
|
int *piVar5;
|
|
float fVar6;
|
|
float fVar7;
|
|
undefined4 textSettings;
|
|
undefined4 local_9c;
|
|
undefined4 local_98;
|
|
undefined4 local_94;
|
|
undefined4 local_90;
|
|
undefined4 local_8c;
|
|
undefined4 local_88;
|
|
KColor textColor;
|
|
undefined1 textPosBuf [8];
|
|
undefined1 glyphPosBuf [8];
|
|
undefined1 buttonPosBuf [8];
|
|
Vector textScale;
|
|
int *inputMapping;
|
|
int *inputMappingRefCount;
|
|
float local_48;
|
|
float local_44;
|
|
int inputDevice;
|
|
int *inputDeviceRefCount;
|
|
Font *font;
|
|
Vector *textPos;
|
|
uint local_30;
|
|
float buttonScale;
|
|
int popup;
|
|
uint buttonIndex;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
|
|
puStack_20 = buttonPosBuf + 0x5c;
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00af1900;
|
|
local_1c = ExceptionList;
|
|
ExceptionList = &local_1c;
|
|
popup = in_ECX;
|
|
iVar4 = FUN_00424220(__security_cookie ^ GHIDRA_UINT((buttonPosBuf + 0x50)));
|
|
(GHIDRA_CAST<InputManager *>((&PTR_vftable_00c57b18)))->InputManager::get_device(&inputDevice,iVar4);
|
|
local_14 = 0;
|
|
textScale.x = *GHIDRA_CAST<float *>((in_ECX + 0x260));
|
|
textScale.y = textScale.x;
|
|
buttonScale = textScale.x;
|
|
if (inputDevice != 0) {
|
|
g_graphicsManager_blendMode[1] = 1;
|
|
g_graphicsManager_blendMode[0] = 0;
|
|
if (((byte)g_graphicsManager_flags & 4) == 0) {
|
|
g_graphicsManager_blendMode[1] = 6;
|
|
}
|
|
g_graphicsManager_blendMode[2] = 7;
|
|
g_graphicsManager_blendMode[3] = 1;
|
|
piVar5 = GHIDRA_CAST<int *>((in_ECX + 0x11c));
|
|
g_graphicsManager_blendMode[4] = 7;
|
|
buttonIndex = 0;
|
|
do {
|
|
uVar2 = buttonIndex;
|
|
textLayer = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((piVar5 + -0x47)))))->ANM2::GetLayer(&DAT_00b1c208);
|
|
if (textLayer == GHIDRA_CAST<LayerState *>(0x0)) {
|
|
KAGE_LogMessage(4,GHIDRA_CAST<byte *>("[warn] no layer named %s\n"));
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((piVar5 + -0x47)))))->ANM2::SetLayerFrame(*GHIDRA_CAST<int *>(textLayer->_layerData),*piVar5);
|
|
}
|
|
piVar5[-0x20] = GHIDRA_INT(buttonScale);
|
|
piVar5[-0x1f] = GHIDRA_INT(buttonScale);
|
|
renderPos = GHIDRA_CAST<Vector *>(FUN_00424130(buttonPosBuf,uVar2));
|
|
if (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(piVar5) + -0x13)) != '\0') {
|
|
if ((char)piVar5[-0x2b] == '\0') {
|
|
AnimationState::Render
|
|
(GHIDRA_CAST<AnimationState *>((piVar5 + -0x3b)),renderPos,&g_vectorZero,&g_vectorZero);
|
|
this = GHIDRA_CAST<AnimationState *>((piVar5 + -0x33));
|
|
}
|
|
else {
|
|
AnimationState::Render
|
|
(GHIDRA_CAST<AnimationState *>((piVar5 + -0x33)),renderPos,&g_vectorZero,&g_vectorZero);
|
|
this = GHIDRA_CAST<AnimationState *>((piVar5 + -0x3b));
|
|
}
|
|
AnimationState::Render(this,renderPos,&g_vectorZero,&g_vectorZero);
|
|
}
|
|
if ((piVar5[2] != 0x20) && ((char)piVar5[1] != '\0')) {
|
|
(**(code **)(PTR_vftable_00c57b18 + 0x28))(&inputMapping,0);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 1;
|
|
iVar4 = __RTDynamicCast(inputDevice,0,&KAGE::Input::InputDeviceBase::RTTI_Type_Descriptor,
|
|
&KAGE::Input::InputDeviceGamepad::RTTI_Type_Descriptor,0);
|
|
local_30 = *GHIDRA_CAST<uint *>((inputDevice + 0xc));
|
|
if ((local_30 == 0) ||
|
|
((iVar4 != 0 && (((*GHIDRA_CAST<byte *>((iVar4 + 8)) & 0x20) != 0 || (*GHIDRA_CAST<int *>((iVar4 + 900)) == 3))))))
|
|
{
|
|
font = &g_manager->_font1_TeamMeatEx10;
|
|
textSettings = 4;
|
|
local_9c = 0xffff;
|
|
local_98 = 0;
|
|
local_94 = 0x3f800000;
|
|
local_90 = 0xffffffff;
|
|
local_8c = 0;
|
|
local_88 = 0;
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 2;
|
|
(GHIDRA_CAST<KColor *>((&textColor)))->KColor::SetFromARGB(0xff362f2d);
|
|
textPos = GHIDRA_CAST<Vector *>(FUN_004240b0(textPosBuf,buttonIndex));
|
|
piVar1 = inputMapping;
|
|
local_30 = piVar5[2];
|
|
iVar4 = inputMapping[4];
|
|
if (GHIDRA_UINT((inputMapping[5] - iVar4 >> 4)) <= local_30) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("ActionId is out of range\n"));
|
|
iVar4 = piVar1[4];
|
|
}
|
|
iVar4 = *GHIDRA_CAST<int *>((iVar4 + local_30 * 0x10));
|
|
if (iVar4 == -1) {
|
|
str = &DAT_00b6d124;
|
|
}
|
|
else {
|
|
str = GHIDRA_CAST<byte *>((**(code **)(*piVar1 + 0x10))(iVar4));
|
|
}
|
|
(GHIDRA_CAST<Font *>((font)))->Font::DrawString(str,textPos,&textScale,&textColor,&textSettings);
|
|
}
|
|
else {
|
|
fVar6 = buttonScale * 1.5;
|
|
iVar4 = piVar5[2];
|
|
fVar7 = fVar6;
|
|
local_48 = fVar6;
|
|
local_44 = fVar6;
|
|
renderPos = GHIDRA_CAST<Vector *>(FUN_004240b0(glyphPosBuf,buttonIndex));
|
|
scale.y = fVar7;
|
|
scale.x = fVar6;
|
|
Manager::render_controller_action_glyph
|
|
(g_manager,local_30,iVar4,0,1,
|
|
(ColorMod)
|
|
ZEXT1644(CONCAT412(0x3f800000,CONCAT48(0x3f800000,0x3f8000003f800000))),
|
|
*renderPos,scale);
|
|
}
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 3;
|
|
if (inputMappingRefCount != GHIDRA_CAST<int *>(0x0)) {
|
|
cVar3 = (**(code **)(*inputMappingRefCount + 0xc))();
|
|
if ((cVar3 != '\0') && (g_inputDeviceRelease != (void *)0x0)) {
|
|
(*g_inputDeviceRelease)(&inputMapping);
|
|
}
|
|
}
|
|
local_14 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(local_14))) + 0x1))) << 8;
|
|
}
|
|
piVar5 = piVar5 + 0x4c;
|
|
buttonIndex = buttonIndex + 1;
|
|
} while (buttonIndex < 2);
|
|
if (*(code **)(popup + 0x264) != (code *)0x0) {
|
|
(**(code **)(popup + 0x264))(popup,*GHIDRA_CAST<undefined4 *>((popup + 0x268)));
|
|
}
|
|
}
|
|
local_14 = 4;
|
|
if (inputDeviceRefCount != GHIDRA_CAST<int *>(0x0)) {
|
|
cVar3 = (**(code **)(*inputDeviceRefCount + 0xc))();
|
|
if ((cVar3 != '\0') && (g_inputDeviceRelease != (void *)0x0)) {
|
|
(*g_inputDeviceRelease)(&inputDevice);
|
|
}
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|