//
// SetItemIDLayer::init from 0x140597fb0 to 0x140598766 (1974 bytes)
//
// 2 xrefs:
// > EditorUI::editObjectSpecial @ 0x1401bd801
// > ??> @ 0x14092d1f4
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:34:34 +0000
//
// Hidden C++ exception states: #wind=4
char __fastcall SetItemIDLayer::init(_BYTE *a1, int a2, int a3, int a4)
{
char result; // al
_BYTE *v6; // r9
_BYTE *v7; // rcx
const char *v8; // rdx
__int64 v9; // r8
int v10; // ebx
__int64 v11; // rcx
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rdx
void *v15; // rcx
__int64 v16; // rax
__int64 v17; // rax
int v18; // ebx
__int64 v19; // rax
int v20; // r8d
int v21; // r9d
__int64 v22; // rax
int v23; // r8d
int v24; // r9d
int v25; // ebx
__int64 v26; // rax
int v27; // r8d
int v28; // r9d
__int64 v29; // rax
int v30; // r8d
int v31; // r9d
__int64 v32; // rax
int v33; // r8d
int v34; // r9d
void **v35; // [rsp+68h] [rbp-59h] BYREF
_BYTE v36[8]; // [rsp+70h] [rbp-51h] BYREF
void **v37; // [rsp+78h] [rbp-49h] BYREF
void **v38; // [rsp+80h] [rbp-41h] BYREF
__int128 v39; // [rsp+88h] [rbp-39h] BYREF
__int64 v40; // [rsp+98h] [rbp-29h]
__int64 v41; // [rsp+A0h] [rbp-21h]
float v42[2]; // [rsp+A8h] [rbp-19h] BYREF
void *Block[2]; // [rsp+B0h] [rbp-11h] BYREF
__m128i si128; // [rsp+C0h] [rbp-1h]
result = SetupTriggerPopup::init((_DWORD)a1, a2, a3, a4, 1132593152, 1, 0);
if ( result )
{
a1[744] = 1;
(*(void (__fastcall **)(_BYTE *))(*(_QWORD *)a1 + 1096LL))(a1);
si128.m128i_i64[0] = 13;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Counter Label");
HIWORD(Block[1]) = 0;
SetupTriggerPopup::addTitle(a1, Block);
*(_OWORD *)Block = 0;
si128.m128i_i64[0] = 2;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "OK");
SetupTriggerPopup::addCloseButton(a1, Block);
v35 = Block;
*(_OWORD *)Block = 0;
si128 = 0u;
v6 = sub_14003D460(0x170u);
Block[0] = v6;
si128.m128i_i64[0] = 365;
si128.m128i_i64[1] = 367;
v7 = v6;
v8 = "Displays a set counter value depending on the setting. By default it displays Item ID.\n"
"Use Time Counter to make it function as a timer.\n"
"MainTime shows the exact game time.\n"
"Use Points to show linked collectables.\n"
"Attempts displays the current attempt.\n"
"Left and Right Align changes the alignment of the display.";
v9 = 2;
do
{
*(_OWORD *)v7 = *(_OWORD *)v8;
*((_OWORD *)v7 + 1) = *((_OWORD *)v8 + 1);
*((_OWORD *)v7 + 2) = *((_OWORD *)v8 + 2);
*((_OWORD *)v7 + 3) = *((_OWORD *)v8 + 3);
*((_OWORD *)v7 + 4) = *((_OWORD *)v8 + 4);
*((_OWORD *)v7 + 5) = *((_OWORD *)v8 + 5);
*((_OWORD *)v7 + 6) = *((_OWORD *)v8 + 6);
v7 += 128;
*((_OWORD *)v7 - 1) = *((_OWORD *)v8 + 7);
v8 += 128;
--v9;
}
while ( v9 );
*(_OWORD *)v7 = *(_OWORD *)v8;
*((_OWORD *)v7 + 1) = *((_OWORD *)v8 + 1);
*((_OWORD *)v7 + 2) = *((_OWORD *)v8 + 2);
*((_OWORD *)v7 + 3) = *((_OWORD *)v8 + 3);
*((_OWORD *)v7 + 4) = *((_OWORD *)v8 + 4);
*((_OWORD *)v7 + 5) = *((_OWORD *)v8 + 5);
*((_QWORD *)v7 + 12) = *((_QWORD *)v8 + 12);
*((_DWORD *)v7 + 26) = *((_DWORD *)v8 + 26);
v7[108] = v8[108];
v6[365] = 0;
v39 = 0;
v10 = 4;
v40 = 4;
v41 = 15;
strcpy((char *)&v39, "Help");
SetupTriggerPopup::addHelpButton(a1, &v39, Block);
v12 = cocos2d::CCDirector::sharedDirector(v11);
cocos2d::CCDirector::getWinSize(v12, v42);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v36, v42[0] * 0.5, v42[1] * 0.5);
if ( (*(float (__fastcall **)(_BYTE *, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 466) == 0.0 )
v10 = 2;
*(_OWORD *)Block = 0;
si128 = _mm_load_si128((const __m128i *)&xmmword_140836570);
strcpy((char *)Block, "ItemID");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v37, -60.0, 50.0);
cocos2d::CCPoint::operator+(v36, &v35, v13);
v14 = (__int64)(a1 + 544);
if ( !a1 )
v14 = 0;
IDNameInput::create(
(__int64)a1,
v14,
v10,
80,
(__int64)Block,
(const struct cocos2d::CCPoint *)&v35,
1061997773,
6,
0,
0,
0);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v15 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v15 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v15 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v15);
}
v37 = Block;
si128.m128i_i64[0] = 12;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Time\nCounter");
BYTE5(Block[1]) = 0;
HIWORD(Block[1]) = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v38, -60.0, 0.0);
cocos2d::CCPoint::operator+(v36, &v35, v16);
SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
466,
(unsigned int)Block,
(unsigned int)&v35,
0,
0,
0,
1065353216);
v38 = Block;
si128.m128i_i64[0] = 12;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Seconds\nOnly");
BYTE5(Block[1]) = 0;
HIWORD(Block[1]) = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v37, 60.0, 0.0);
cocos2d::CCPoint::operator+(v36, &v35, v17);
SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
389,
(unsigned int)Block,
(unsigned int)&v35,
0,
0,
0,
1065353216);
v18 = (int)(*(float (__fastcall **)(_BYTE *, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 391);
v38 = Block;
Block[1] = (void *)28263;
si128.m128i_i64[0] = 10;
si128.m128i_i64[1] = 15;
Block[0] = (void *)0x696C410A7466654CLL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v37, 60.0, 80.0);
cocos2d::CCPoint::operator+(v36, &v35, v19);
LOBYTE(v20) = v18 == 1;
SetupTriggerPopup::createCustomToggleValueControl((_DWORD)a1, 1, v20, v21, (__int64)Block, (__int64)&v35, 0, 0, 0);
v38 = Block;
si128.m128i_i64[0] = 11;
si128.m128i_i64[1] = 15;
Block[0] = (void *)0x6C410A7468676952LL;
Block[1] = (void *)7235433;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v37, 60.0, 40.0);
cocos2d::CCPoint::operator+(v36, &v35, v22);
LOBYTE(v23) = v18 == 2;
SetupTriggerPopup::createCustomToggleValueControl((_DWORD)a1, 2, v23, v24, (__int64)Block, (__int64)&v35, 0, 0, 0);
v25 = (int)(*(float (__fastcall **)(_BYTE *, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 390);
v38 = (void **)&v39;
v40 = 8;
v41 = 15;
v39 = 0x656D69546E69614DuLL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v37, -90.0, -60.0);
cocos2d::CCPoint::operator+(v36, &v35, v26);
LOBYTE(v27) = v25 == -1;
SetupTriggerPopup::createCustomToggleValueControl((_DWORD)a1, -1, v27, v28, (__int64)&v39, (__int64)&v35, 1, 0, 0);
v38 = Block;
*(_OWORD *)Block = 0;
si128.m128i_i64[0] = 6;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Points");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v37, -15.0, -60.0);
cocos2d::CCPoint::operator+(v36, &v35, v29);
LOBYTE(v30) = v25 == -2;
SetupTriggerPopup::createCustomToggleValueControl((_DWORD)a1, -2, v30, v31, (__int64)Block, (__int64)&v35, 1, 0, 0);
v38 = (void **)&v39;
v40 = 8;
v41 = 15;
v39 = 0x7374706D65747441uLL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v37, 60.0, -60.0);
cocos2d::CCPoint::operator+(v36, &v35, v32);
LOBYTE(v33) = v25 == -3;
SetupTriggerPopup::createCustomToggleValueControl((_DWORD)a1, -3, v33, v34, (__int64)&v39, (__int64)&v35, 1, 0, 0);
(*(void (__fastcall **)(_BYTE *))(*(_QWORD *)a1 + 1136LL))(a1);
a1[744] = 0;
return 1;
}
return result;
}