//
// DialogLayer::init from 0x1003c7300 to 0x1003c77ab (1195 bytes)
//
// 1 xrefs:
// > DialogLayer::createDialogLayer @ 0x1003c72a0
//
// 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
//
bool __fastcall DialogLayer::init(DialogLayer *a1, DialogObject *a2, cocos2d::CCArray *a3, int a4)
{
bool v6; // bl
cocos2d::CCDirector *v7; // rsi
cocos2d::CCDirector *v8; // rax
cocos2d::CCTouchDispatcher *v9; // rax
cocos2d::CCLayer *v10; // rax
cocos2d::CCLayer *m_mainLayer; // r15
double v12; // xmm0_8
cocos2d::CCString *v13; // rax
const char *CString; // r13
size_t v15; // rax
size_t v16; // r12
char *v17; // r15
size_t v18; // rbx
char v19; // bl
const char *v20; // r15
DialogObject *v22; // r13
cocos2d::extension::CCScale9Sprite *v23; // r12
cocos2d::CCLabelBMFont *v24; // rax
cocos2d::CCLabelBMFont *m_characterLabel; // r15
cocos2d::CCLabelBMFont *v26; // r15
cocos2d::extension::CCScale9Sprite *v27; // r12
const char *v28; // r12
cocos2d::CCSprite *v29; // rax
cocos2d::CCSprite *m_navButtonSprite; // r15
cocos2d::CCArray *m_dialogObjects; // rdi
cocos2d::CCSprite *v32; // r14
cocos2d::CCSpriteFrameCache *v33; // rax
cocos2d::CCSpriteFrame *v34; // rax
__m128 v36; // [rsp+0h] [rbp-80h] BYREF
DialogObject *v37; // [rsp+10h] [rbp-70h]
float v38[2]; // [rsp+18h] [rbp-68h] BYREF
unsigned __int64 v39[2]; // [rsp+20h] [rbp-60h] BYREF
_QWORD __dst[2]; // [rsp+30h] [rbp-50h] BYREF
void *__p; // [rsp+40h] [rbp-40h]
float v42[2]; // [rsp+4Ch] [rbp-34h] BYREF
bool v43; // [rsp+57h] [rbp-29h]
double v44; // 0:xmm0_8.8
cocos2d::CCRect v45; // 0:xmm0_8.8,8:xmm1_8.8
cocos2d::CCRect v46; // 0:xmm0_8.8,8:xmm1_8.8
LODWORD(__dst[0]) = -1778384896;
v6 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::ccColor4B *)__dst);
if ( !v6 )
return v6;
v37 = a2;
if ( a3 )
{
a1->m_dialogObjects = a3;
cocos2d::CCObject::retain(a3);
}
v7 = cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v44 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v38);
v8 = cocos2d::CCDirector::sharedDirector();
v9 = (cocos2d::CCTouchDispatcher *)((__int64 (__fastcall *)(cocos2d::CCDirector *, cocos2d::CCDirector *, double))v8->getTouchDispatcher)(
v8,
v7,
v44);
cocos2d::CCTouchDispatcher::registerForcePrio(v9, a1, 2);
((void (__fastcall *)(DialogLayer *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(DialogLayer *, __int64))a1->setKeypadEnabled)(a1, 1);
((void (__fastcall *)(DialogLayer *, __int64))a1->setKeyboardEnabled)(a1, 1);
v10 = cocos2d::CCLayer::create();
a1->m_mainLayer = v10;
((void (__fastcall *)(DialogLayer *, cocos2d::CCLayer *))a1->addChild)(a1, v10);
((void (__fastcall *)(cocos2d::CCLayer *, void *))a1->m_mainLayer->setContentSize)(a1->m_mainLayer, &unk_1009A12D0);
m_mainLayer = a1->m_mainLayer;
*(_QWORD *)&v12 = LODWORD(v38[0]);
*(float *)&v12 = v38[0] * 0.5;
sub_10028CBE0((float *)__dst, v38[0] * 0.5, 0.5 * v38[1]);
((void (__fastcall *)(cocos2d::CCLayer *, _QWORD *))m_mainLayer->setPosition)(m_mainLayer, __dst);
v13 = (cocos2d::CCString *)sub_1007AB580("GJ_square%02d.png", v36.i8[0]);
CString = cocos2d::CCString::getCString(v13);
v15 = strlen(CString);
if ( v15 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v12);
v16 = v15;
v17 = (char *)__dst + 1;
v43 = v6;
if ( v15 >= 0x17 )
{
v18 = 26;
if ( (v15 | 7) != 0x17 )
v18 = (v15 | 7) + 1;
v17 = (char *)operator new(v18);
__p = v17;
__dst[0] = v18 + 1;
__dst[1] = v16;
}
else
{
LOBYTE(__dst[0]) = 2 * v15;
if ( !v15 )
goto LABEL_12;
}
memmove(v17, CString, v16);
LABEL_12:
v17[v16] = 0;
v19 = __dst[0];
v20 = (const char *)__p;
v45.origin = 0;
v45.size = 0;
sub_10028CC00((__int64)v39, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v22 = v37;
if ( (v19 & 1) == 0 )
v20 = (char *)__dst + 1;
v23 = cocos2d::extension::CCScale9Sprite::create_2(v20, v45);
sub_10028CBF0((float *)v39, 380.0, 100.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, unsigned __int64 *))v23->setContentSize)(v23, v39);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v23,
4294967294LL);
v24 = cocos2d::CCLabelBMFont::create_3(" ", "bigFont.fnt");
a1->m_characterLabel = v24;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v24,
2);
m_characterLabel = a1->m_characterLabel;
sub_10028CBE0((float *)v39, 0.0, 1.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int64 *))m_characterLabel->setAnchorPoint)(
m_characterLabel,
v39);
v26 = a1->m_characterLabel;
sub_10028CBE0((float *)v39, -93.0, 36.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int64 *))v26->setPosition)(v26, v39);
cocos2d::CCLabelBMFont::limitLabelWidth(a1->m_characterLabel, 200.0, 0.5, 0.0);
v46.size = 0;
sub_10028CC00((__int64)v39, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
*(double *)&v46.origin = sub_10028D180(&v36, v39);
v6 = v43;
v27 = cocos2d::extension::CCScale9Sprite::create_2("square02b_001.png", v46);
sub_10028CBF0(v36.f32, 280.0, 80.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __m128 *))v27->setContentSize)(v27, &v36);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v27,
0xFFFFFFFFLL);
sub_10028CBE0(v42, 40.0, 0.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v27->setPosition)(v27, v42);
BYTE2(v42[0]) = 0;
LOWORD(v42[0]) = 0;
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v27->setColor)(v27, v42);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v27->setOpacity)(v27, 50);
v28 = "GJ_chatBtn_01_001.png";
v29 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_chatBtn_01_001.png");
a1->m_navButtonSprite = v29;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v29,
3);
m_navButtonSprite = a1->m_navButtonSprite;
sub_10028CBE0(v42, 0.0, -50.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))m_navButtonSprite->setPosition)(m_navButtonSprite, v42);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))a1->m_navButtonSprite->setOpacity)(a1->m_navButtonSprite, 0);
if ( a1->m_dialogObjects )
DialogLayer::displayNextObject(a1);
else
DialogLayer::displayDialogObject(a1, v22);
m_dialogObjects = a1->m_dialogObjects;
if ( m_dialogObjects )
{
if ( !(unsigned int)sub_100720070(m_dialogObjects) )
v28 = "GJ_chatBtn_02_001.png";
}
else
{
v28 = "GJ_chatBtn_02_001.png";
}
v32 = a1->m_navButtonSprite;
v33 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v34 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v33, v28);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSpriteFrame *))v32->setDisplayFrame)(v32, v34);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
return v6;
}