//
// ShareLevelLayer::init from 0x14048eec0 to 0x14048fb74 (3252 bytes)
//
// 2 xrefs:
// > EditLevelLayer::onShare @ 0x1400d8a8b
// > ??> @ 0x1406dc020
//
// 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
//
// Hidden C++ exception states: #wind=8
bool ShareLevelLayer::init(ShareLevelLayer *a1, GJGameLevel *a2)
{
bool result; // al
__int64 v5; // rcx
__int64 v6; // rax
cocos2d::CCTouchDispatcher *v7; // rax
_BOOL8 v8; // rdx
_BOOL8 v9; // rdx
__int64 v10; // rcx
cocos2d::CCDirector *v11; // rax
cocos2d::CCLayer *v12; // rax
struct cocos2d::CCRect *v13; // rax
struct cocos2d::extension::CCScale9Sprite *v14; // rdi
cocos2d::extension::CCScale9Sprite_vtbl *v15; // rbx
const cocos2d::CCSize *v16; // rax
float v17; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v18; // rbx
const cocos2d::CCPoint *v19; // rax
const char *p_Buf2; // rcx
struct cocos2d::CCLabelBMFont *v21; // rsi
float v22; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v23; // rbx
const cocos2d::CCPoint *v24; // rax
const struct cocos2d::CCPoint *v25; // rax
char *v26; // rdi
float v27; // xmm0_4
__int64 v28; // rax
float v29; // xmm0_4
struct cocos2d::CCRect *v30; // rax
struct cocos2d::extension::CCScale9Sprite *v31; // rbx
void **v32; // rcx
bool v33; // si
void **v34; // rdi
size_t v35; // rbx
size_t v36; // r8
void **v37; // rdx
size_t v38; // r8
size_t v39; // r13
unsigned __int64 i; // rbx
void **v41; // r15
unsigned __int64 v42; // r12
char *v43; // rsi
int v44; // r14d
char *v45; // rbx
float v46; // xmm6_4
unsigned __int64 v47; // rbx
char *v48; // r9
void **v49; // rdx
size_t v50; // r8
const struct cocos2d::CCPoint *v51; // rax
char *v52; // rbx
ShareLevelLayer *v53; // r14
float v54; // xmm0_4
const struct cocos2d::CCPoint *v55; // rax
char *v56; // rdi
float v57; // xmm0_4
__int64 v58; // rbx
__int64 v59; // rax
double v60; // xmm0_8
__int64 v61; // rcx
__int64 v62; // rax
__int64 v63; // rcx
SetupTriggerPopup *v64; // rsi
const char *v65; // rdi
ButtonSprite *v66; // rax
CCMenuItemSpriteExtra *v67; // rbx
ButtonSprite *v68; // r8
cocos2d::CCPoint v69; // r9
ButtonSprite *v70; // rax
CCMenuItemSpriteExtra *v71; // rbx
ButtonSprite *v72; // r8
cocos2d::CCPoint v73; // r9
struct cocos2d::CCPoint v74; // rax
struct cocos2d::CCSprite *v75; // rbx
CCMenuItemSpriteExtra *v76; // rsi
float v77; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v78; // rbx
struct cocos2d::CCPoint v79; // rax
GameManager *v80; // rcx
struct cocos2d::CCSprite *v81; // rdi
float v82; // xmm0_4
struct cocos2d::CCPoint v83; // rax
void *v84; // rcx
void *v85; // rcx
struct cocos2d::CCPoint *v86; // [rsp+50h] [rbp-B8h] BYREF
int v87; // [rsp+58h] [rbp-B0h]
__int64 v88; // [rsp+60h] [rbp-A8h]
ShareLevelLayer *v89; // [rsp+68h] [rbp-A0h] BYREF
struct cocos2d::CCPoint v90[3]; // [rsp+70h] [rbp-98h] BYREF
__int64 v91; // [rsp+88h] [rbp-80h]
__int64 v92; // [rsp+90h] [rbp-78h]
cocos2d::CCRect v93; // [rsp+98h] [rbp-70h] BYREF
cocos2d::CCPoint v94; // [rsp+A8h] [rbp-60h] BYREF
cocos2d::CCSize v95; // [rsp+B0h] [rbp-58h] BYREF
cocos2d::CCRect v96; // [rsp+B8h] [rbp-50h] BYREF
void *v97[2]; // [rsp+C8h] [rbp-40h] BYREF
__int64 v98; // [rsp+D8h] [rbp-30h]
unsigned __int64 v99; // [rsp+E0h] [rbp-28h]
void *Block[2]; // [rsp+E8h] [rbp-20h] BYREF
size_t v101; // [rsp+F8h] [rbp-10h]
unsigned __int64 v102; // [rsp+100h] [rbp-8h]
__int128 Buf2; // [rsp+108h] [rbp+0h] BYREF
__int64 v104; // [rsp+118h] [rbp+10h]
unsigned __int64 v105; // [rsp+120h] [rbp+18h]
void *v106[2]; // [rsp+128h] [rbp+20h] BYREF
__int64 v107; // [rsp+138h] [rbp+30h]
__int64 v108; // [rsp+140h] [rbp+38h]
void *Buf1[2]; // [rsp+148h] [rbp+40h] BYREF
size_t v110; // [rsp+158h] [rbp+50h]
unsigned __int64 v111; // [rsp+160h] [rbp+58h]
v89 = a1;
LODWORD(v86) = -1778384896;
result = cocos2d::CCLayerColor::initWithColor(a1, (const struct cocos2d::_ccColor4B *)&v86);
if ( !result )
return result;
if ( !a1->m_forcePrioRegistered )
{
a1->m_forcePrioRegistered = 1;
v6 = cocos2d::CCDirector::sharedDirector(v5);
v7 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v6 + 144LL))(v6);
cocos2d::CCTouchDispatcher::registerForcePrio(v7, a1, 2);
}
a1->m_level = a2;
cocos2d::CCObject::retain(a2);
LOBYTE(v8) = 1;
a1->setTouchEnabled(a1, v8);
LOBYTE(v9) = 1;
a1->setKeypadEnabled(a1, v9);
v11 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v10);
cocos2d::CCDirector::getWinSize(v11);
v12 = (cocos2d::CCLayer *)cocos2d::CCLayer::create();
a1->m_mainLayer = v12;
a1->addChild_1(a1, v12);
cocos2d::CCRect::CCRect(&v93, 0.0, 0.0, 80.0, 80.0);
v14 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v13);
v15 = v14->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v86, 420.0, 300.0);
v15->setContentSize(v14, v16);
v17 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v14,
0xFFFFFFFFLL);
v18 = v14->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v17, *(float *)&v88 * 0.5);
v18->setPosition_0(v14, v19);
sub_14003BDB0((__int64)&Buf2, (__int64)&a1->m_level->m_levelName);
p_Buf2 = (const char *)&Buf2;
if ( v105 > 0xF )
p_Buf2 = (const char *)Buf2;
v21 = cocos2d::CCLabelBMFont::create(p_Buf2, "goldFont.fnt");
sub_14003A830((__int64)&Buf2);
v22 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild_1)(
a1->m_mainLayer,
v21);
v23 = v21->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v22, *(float *)&v88 * 0.5);
v23->setPosition_0(v21, v24);
v86 = &v90[1];
*(_OWORD *)&v90[1].x = 0;
v91 = 0;
v92 = 15;
v90[1] = (struct cocos2d::CCPoint)sub_14003AA10(0x40u);
v91 = 53;
v92 = 63;
strcpy(*(char **)&v90[1], "You cannot change the name once it is shared.");
cocos2d::CCPoint::CCPoint(1.9429953e-19, 0.5);
v26 = TextArea::create((__int64)&v90[1], "chatFont.fnt", 1.0, 400.0, v25, 1101004800, 0);
v27 = ((float (__fastcall *)(cocos2d::CCLayer *, char *))a1->m_mainLayer->addChild_1)(a1->m_mainLayer, v26);
cocos2d::CCPoint::CCPoint(v27, 0.0);
v28 = (__int64)v21->getPosition_0(v21);
cocos2d::CCPoint::operator+(v28, &v86);
(*(void (__fastcall **)(char *, struct cocos2d::CCPoint **))(*(_QWORD *)v26 + 184LL))(v26, &v86);
v29 = (*(float (__fastcall **)(char *))(*(_QWORD *)v26 + 160LL))(v26);
cocos2d::CCPoint::CCPoint(v29, *(float *)&v88 * 0.5);
cocos2d::CCRect::CCRect(&v96, 0.0, 0.0, 80.0, 80.0);
cocos2d::CCRect::CCRect(&v93, &v96);
v31 = cocos2d::extension::CCScale9Sprite::create("square02b_001.png", v30);
cocos2d::CCSize::CCSize(&v95, 380.0, 50.0);
v31->setContentSize(v31, &v95);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v31, -1);
v31->setPosition_0(v31, &v94);
LOWORD(v86) = 16514;
BYTE2(v86) = 33;
v31->setColor(&v31->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v86);
*(_OWORD *)v97 = 0;
v98 = 0;
v99 = 15;
v97[0] = sub_14003AA10(0x20u);
v98 = 25;
v99 = 31;
strcpy((char *)v97[0], "(No description provided)");
GJGameLevel::getUnpackedLevelDescription((__int64)a2, (__int64)Buf1);
Buf2 = 0;
v104 = 0;
v105 = 15;
LOBYTE(Buf2) = 0;
v32 = Buf1;
v33 = v111 > 0xF;
v34 = (void **)Buf1[0];
if ( v111 > 0xF )
v32 = (void **)Buf1[0];
v35 = v110;
v36 = v110;
if ( v110 )
v36 = 0;
if ( memcmp(v32, &Buf2, v36) || v35 )
{
v37 = Buf1;
if ( v33 )
v37 = v34;
v38 = -1;
do
++v38;
while ( *((_BYTE *)v37 + v38) );
sub_14003CCE0(v97, v37, v38);
}
*(_OWORD *)v106 = 0;
v107 = 1;
v108 = 15;
LOWORD(v106[0]) = 160;
*(_OWORD *)Block = 0;
v39 = 0;
v101 = 0;
v102 = 15;
LOBYTE(Block[0]) = 0;
for ( i = 0; ; i = v101 + v47 )
{
v41 = v97;
LOBYTE(v87) = v99 > 0xF;
if ( v99 > 0xF )
v41 = (void **)v97[0];
v42 = v98;
if ( !v98 )
break;
if ( i > v98 - 1 )
break;
v43 = (char *)v41 + v98 - 1;
v44 = SLOBYTE(v106[0]);
v45 = (char *)memchr((char *)v41 + i, SLOBYTE(v106[0]), v98 - i);
if ( !v45 )
break;
while ( memcmp(v45, v106, 1u) )
{
v45 = (char *)memchr(v45 + 1, v44, v43 - v45);
if ( !v45 )
goto LABEL_25;
}
v47 = v45 - (char *)v41;
if ( v47 == -1 )
break;
v48 = (char *)Block;
if ( v102 > 0xF )
v48 = (char *)Block[0];
sub_140041FF0(v97, v47, 1u, v48, v39);
v39 = v101;
}
LABEL_25:
v46 = 1.0;
if ( v42 >= 0xB4 )
{
LODWORD(v42) = 180;
LABEL_33:
v46 = (float)((float)((float)(180 - (int)v42) / 180.0) * 0.30000001) + 0.69999999;
goto LABEL_34;
}
if ( (int)v42 > 70 )
goto LABEL_33;
LABEL_34:
v93.origin = (cocos2d::CCPoint)&v90[1];
v49 = v97;
if ( (_BYTE)v87 )
v49 = (void **)v97[0];
*(_OWORD *)&v90[1].x = 0;
v91 = 0;
v92 = 0;
v50 = -1;
do
++v50;
while ( *((_BYTE *)v49 + v50) );
sub_14003A930(&v90[1], v49, v50);
cocos2d::CCPoint::CCPoint(0.0, 0.5);
v52 = TextArea::create((__int64)&v90[1], "chatFont.fnt", 1.0, 335.0 / v46, v51, 1101004800, 1);
v53 = v89;
v54 = ((float (__fastcall *)(cocos2d::CCLayer *, char *))v89->m_mainLayer->addChild_1)(v89->m_mainLayer, v52);
cocos2d::CCPoint::CCPoint(v54, 0.0);
cocos2d::CCPoint::operator+(&v94, &v89);
(*(void (__fastcall **)(char *, ShareLevelLayer **))(*(_QWORD *)v52 + 184LL))(v52, &v89);
(*(void (__fastcall **)(char *))(*(_QWORD *)v52 + 160LL))(v52);
v93.origin = (cocos2d::CCPoint)&v90[1];
*(_OWORD *)&v90[1].x = 0;
v91 = 0;
v92 = 15;
v90[1] = (struct cocos2d::CCPoint)sub_14003AA10(0x70u);
v91 = 102;
v92 = 111;
strcpy(
*(char **)&v90[1],
"By sharing a level you give the rights to use the level\n(in any way) to the creators of Geometry Dash.");
cocos2d::CCPoint::CCPoint(5.5373644e-14, 0.5);
v56 = TextArea::create((__int64)&v90[1], "chatFont.fnt", 1.0, 380.0, v55, 1101004800, 0);
v57 = ((float (__fastcall *)(cocos2d::CCLayer *, char *))v53->m_mainLayer->addChild_1)(v53->m_mainLayer, v56);
v58 = *(_QWORD *)v56;
cocos2d::CCPoint::CCPoint(v57, *(float *)&v88 * 0.5);
v60 = (*(double (__fastcall **)(char *, __int64))(v58 + 184))(v56, v59);
(*(void (__fastcall **)(char *))(*(_QWORD *)v56 + 160LL))(v56);
v53->m_joystickConnected = -1;
v62 = cocos2d::CCMenu::create(v61);
v53->m_buttonMenu = (cocos2d::CCMenu *)v62;
v53->m_mainLayer->addChild_0(v53->m_mainLayer, (cocos2d::CCNode *)v62, 10);
ShareLevelLayer::setupStars(v53);
v64 = (SetupTriggerPopup *)cocos2d::CCArray::create(v63);
v65 = "GJ_button_01.png";
v66 = ButtonSprite::create_1("Cancel", 0, 0, 1.0, 0, "goldFont.fnt", "GJ_button_01.png", 0.0);
v67 = CCMenuItemSpriteExtra::create(v66, nullptr, v53, (cocos2d::SEL_MenuHandler *)AudioAssetsBrowser::onClose);
v53->m_buttonMenu->addChild_1(v53->m_buttonMenu, v67);
cocos2d::CCArray::addObject(v64, v67, v68, v69);
if ( v53->m_level->m_isUploaded )
v65 = "GJ_button_04.png";
v70 = ButtonSprite::create_1("Share Level", 0, 0, 1.0, 0, "goldFont.fnt", v65, 0.0);
v71 = CCMenuItemSpriteExtra::create(v70, nullptr, v53, (cocos2d::SEL_MenuHandler *)ShareLevelLayer::onShare);
v53->m_buttonMenu->addChild_1(v53->m_buttonMenu, v71);
cocos2d::CCArray::addObject(v64, v71, v72, v73);
cocos2d::CCPoint::CCPoint(*(float *)&v60, *(float *)&v88 * 0.5);
v74 = cocos2d::CCNode::convertToNodeSpace(v53->m_buttonMenu, v90);
GameToolbox::alignItemsHorisontally((cocos2d::CCArray *)v64, 15.0, v74, 0);
v75 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_optionsBtn02_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v75->setScale_0)(v75);
v76 = CCMenuItemSpriteExtra::create(v75, nullptr, v53, (cocos2d::SEL_MenuHandler *)ShareLevelLayer::onSettings);
HIDWORD(v76->m_pfnSelector.adj) = 0x40000000;
v77 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v53->m_buttonMenu->addChild_1)(
v53->m_buttonMenu,
v76);
v78 = v76->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v77, (float)((float)(*(float *)&v88 * 0.5) + 210.0) - 26.0);
v79 = cocos2d::CCNode::convertToNodeSpace(v53->m_buttonMenu, v90);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v78->setPosition_0)(v76, v79);
v80 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v89 = (ShareLevelLayer *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v89);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v80 = (GameManager *)qword_1406C2ED8;
}
if ( !GameManager::getGameVariable(v80, "0029") )
{
v81 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_optionsTxt_001.png");
v82 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::CCSprite *))v53->m_mainLayer->addChild_1)(
v53->m_mainLayer,
v81);
cocos2d::CCPoint::CCPoint(v82, -55.0);
v76->getPosition_0(v76);
v83 = cocos2d::CCNode::convertToWorldSpace(v53->m_buttonMenu, v90);
((void (__fastcall *)(_QWORD, _QWORD))cocos2d::CCPoint::operator+)(v83, &v89);
v81->setPosition_0(v81, (const cocos2d::CCPoint *)&v89);
}
if ( v102 > 0xF )
{
v84 = Block[0];
if ( v102 + 1 >= 0x1000 )
{
v84 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v84 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v84);
}
sub_14003A830((__int64)Buf1);
if ( v99 > 0xF )
{
v85 = v97[0];
if ( v99 + 1 >= 0x1000 )
{
v85 = *((void **)v97[0] - 1);
if ( (unsigned __int64)((char *)v97[0] - (char *)v85 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v85);
}
return 1;
}