//
// GJBaseGameLayer::positionUIObjects from 0x482444 to 0x48276a (806 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::updateSpecialGroupData @ 0x4952f2
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void GJBaseGameLayer::positionUIObjects(GJBaseGameLayer *a1)
{
cocos2d::CCDirector *v2; // r0
cocos2d::CCArray *v3; // r0
float width; // s18
float height; // s19
cocos2d::CCArray *v6; // r0
cocos2d::CCArray *m_objects; // r3
cocos2d::CCArray *v8; // r10
cocos2d::ccArray *data; // r2
float v10; // s18
cocos2d::CCObject **arr; // r11
float v12; // s19
float v13; // s21
float v14; // s20
int v15; // r4
int v16; // t1
GameObject *MainObject; // r7
cocos2d::CCArray *v18; // r5
cocos2d::ccArray *v19; // r2
GameObject *v20; // r9
unsigned int v21; // r2
int v22; // r3
float v23; // s15
float v24; // s15
float v25; // s15
float v26; // s15
float v27; // s15
float v28; // s15
void (__fastcall *setStartPos)(GameObject *__hidden, cocos2d::CCPoint); // r7
cocos2d::ccArray *v30; // r3
cocos2d::CCObject **v31; // r7
cocos2d::CCObject **v32; // r12
GameObject *v33; // r5
GameObject *v34; // t1
GameObject **v35; // [sp+0h] [bp-74h]
cocos2d::CCArray *Group; // [sp+4h] [bp-70h]
GameObject *GroupParent; // [sp+8h] [bp-6Ch]
cocos2d::CCObject **v38; // [sp+14h] [bp-60h]
GameObject **v39; // [sp+18h] [bp-5Ch]
void (__fastcall *v40)(GameObject *__hidden, cocos2d::CCPoint); // [sp+20h] [bp-54h]
cocos2d::CCObject **v41; // [sp+24h] [bp-50h]
cocos2d::CCSize v42; // [sp+2Ch] [bp-48h] BYREF
cocos2d::CCPoint v43; // [sp+34h] [bp-40h] BYREF
float v44; // [sp+3Ch] [bp-38h] BYREF
float v45; // [sp+40h] [bp-34h]
cocos2d::CCPoint v46; // [sp+44h] [bp-30h] BYREF
cocos2d::CCPoint v47; // [sp+4Ch] [bp-28h] BYREF
_BYTE v48[8]; // [sp+54h] [bp-20h] BYREF
cocos2d::CCPoint v49; // [sp+5Ch] [bp-18h] BYREF
cocos2d::CCPoint v50; // [sp+64h] [bp-10h] BYREF
v2 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v42, v2);
v3 = (cocos2d::CCArray *)cocos2d::CCPoint::CCPoint(&v43, v42.width * 0.5, v42.height * 0.5);
width = v42.width;
height = v42.height;
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v3);
m_objects = a1->m_objects;
v8 = v6;
if ( m_objects )
{
data = m_objects->data;
if ( data->num )
{
v10 = width * 0.5;
arr = data->arr;
v38 = &arr[data->num] + 0x3FFFFFFF;
v12 = height * 0.5;
v13 = v12 / 160.0;
v14 = v10 / 240.0;
while ( 1 )
{
LABEL_4:
if ( arr <= v38 )
{
v16 = (int)*arr++;
v15 = v16;
if ( v16 )
continue;
}
return;
if ( *(_DWORD *)(v15 + 884) == 3613 )
{
Group = GJBaseGameLayer::getGroup(a1, *(_DWORD *)(v15 + 1276));
GroupParent = GJBaseGameLayer::getGroupParent(a1, *(_DWORD *)(v15 + 1276));
MainObject = GJBaseGameLayer::tryGetMainObject(a1, *(_DWORD *)(v15 + 1280));
if ( GroupParent )
{
v18 = v8;
cocos2d::CCArray::removeAllObjects(v8);
cocos2d::CCArray::addObject(v8, GroupParent);
}
else
{
v18 = Group;
}
if ( MainObject )
{
if ( v18 )
{
MainObject->getStartPos((cocos2d::CCPoint *)&v44, MainObject);
v19 = v18->data;
if ( v19->num )
break;
}
}
}
}
v35 = (GameObject **)v19->arr;
v39 = &v35[v19->num] + 0x3FFFFFFF;
while ( 1 )
{
do
{
if ( v35 <= v39 )
{
v20 = *v35++;
if ( v20 )
continue;
}
goto LABEL_4;
}
while ( v20->m_isUIObject );
GJBaseGameLayer::addUIObject(a1, v20);
v20->getStartPos(&v46, v20);
cocos2d::CCPoint::CCPoint(&v47, &v46);
v21 = *(_DWORD *)(v15 + 1636);
v22 = *(_DWORD *)(v15 + 1640);
if ( v21 <= 1 )
{
if ( v46.x >= v44 )
v21 = 4;
else
v21 = 3;
}
if ( v22 == 5 || !v22 )
{
if ( v46.y >= v45 )
v22 = 8;
else
v22 = 7;
}
switch ( v21 )
{
case 2u:
v23 = v46.x - v44;
if ( *(_BYTE *)(v15 + 1644) )
v23 = v23 * v14;
v24 = v23 + v10;
break;
case 3u:
v24 = v46.x - (float)(v44 - 240.0);
if ( *(_BYTE *)(v15 + 1644) )
v24 = v24 * v14;
break;
case 4u:
v25 = v46.x - (float)(v44 + 240.0);
if ( *(_BYTE *)(v15 + 1644) )
v25 = v25 * v14;
v24 = v42.width + v25;
break;
default:
goto LABEL_38;
}
v47.x = v24;
LABEL_38:
switch ( v22 )
{
case 6:
v26 = v46.y - v45;
if ( *(_BYTE *)(v15 + 1645) )
v26 = v26 * v13;
v27 = v26 + v12;
break;
case 7:
v27 = v46.y - (float)(v45 - 160.0);
if ( *(_BYTE *)(v15 + 1645) )
v27 = v27 * v13;
break;
case 8:
v28 = v46.y - (float)(v45 + 160.0);
if ( *(_BYTE *)(v15 + 1645) )
v28 = v28 * v13;
v27 = v42.height + v28;
break;
default:
goto LABEL_50;
}
v47.y = v27;
LABEL_50:
setStartPos = v20->setStartPos;
cocos2d::CCPoint::CCPoint(&v50, &v47);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))setStartPos)(v20, &v50);
if ( v20 == GroupParent )
{
if ( Group )
{
cocos2d::CCPoint::operator-(v48, &v47, &v46);
v30 = Group->data;
if ( v30->num )
{
v31 = v30->arr;
v32 = &v31[v30->num] + 0x3FFFFFFF;
while ( v31 <= v32 )
{
v34 = (GameObject *)*v31++;
v33 = v34;
if ( !v34 )
break;
if ( !v33->m_isUIObject )
{
v41 = v32;
GJBaseGameLayer::addUIObject(a1, v33);
v40 = v33->setStartPos;
v33->getStartPos(&v49, v33);
cocos2d::CCPoint::operator+(&v50, &v49, v48);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))v40)(v33, &v50);
v32 = v41;
}
}
}
}
}
}
}
}
}