//
// ShareLevelLayer::init from 0x100274f94 to 0x100275a58 (2756 bytes)
//
// 1 xrefs:
// > ShareLevelLayer::create @ 0x100274f48
//
// 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 ShareLevelLayer::init(ShareLevelLayer *a1, GJGameLevel *a2)
{
_BOOL4 v4; // w0
cocos2d::CCDirector *v5; // x0
cocos2d::CCLayer *v6; // x0
cocos2d::extension::CCScale9Sprite *v7; // x22
__n128 v8; // q0
__n128 v9; // q1
GJGameLevel *m_level; // x8
std::string *p_dst; // x0
cocos2d::CCLabelBMFont *v12; // x22
__n128 v13; // q0
__n128 v14; // q1
__n128 v15; // q0
__n128 v16; // q1
cocos2d::CCObject *v17; // x23
float32x2_t *v18; // x22
__n128 v19; // q0
__n128 v20; // q1
double v21; // d0
__n128 v22; // q0
__n128 v23; // q1
double v24; // d0
cocos2d::extension::CCScale9Sprite *v25; // x22
__int64 v26; // x20
size_t v27; // x8
void *v28; // x21
size_t v29; // x9
void **v30; // x0
const void *v31; // x1
size_t v32; // x2
bool v33; // w19
void **v34; // x1
std::string::size_type v35; // x21
std::string::size_type v36; // x8
unsigned __int8 v37; // w10
std::string::size_type v38; // x11
std::string::size_type size; // x28
std::string *v40; // x27
std::string::size_type v41; // x19
unsigned __int64 v42; // x26
std::string::size_type v43; // x20
void **v44; // x22
signed __int64 v45; // x23
signed __int64 v46; // x9
char *v47; // x25
char *v48; // x0
int v49; // w21
char *v50; // x0
char *v51; // x24
std::string::size_type v52; // x2
const std::string::value_type *v53; // x3
std::string::size_type v54; // x4
std::string::size_type v55; // x8
ShareLevelLayer *v56; // x19
float v57; // s9
std::string *v58; // x1
__n128 v59; // q0
__n128 v60; // q1
cocos2d::CCObject *v61; // x21
__n128 v62; // q0
__n128 v63; // q1
double v64; // d0
__n128 v65; // q0
__n128 v66; // q1
cocos2d::CCObject *v67; // x21
__n128 v68; // q0
__n128 v69; // q1
cocos2d::CCArray *v70; // x21
ButtonSprite *v71; // x0
CCMenuItemSpriteExtra *v72; // x0
const char *v73; // x5
ButtonSprite *v74; // x0
CCMenuItemSpriteExtra *v75; // x0
cocos2d::CCNode *m_buttonMenu; // x22
__n128 v77; // q0
__n128 v78; // q1
cocos2d::CCSprite *v79; // x21
CCMenuItemSpriteExtra *v80; // x21
__n128 v81; // q0
cocos2d::CCNode *v82; // x22
__n128 v83; // q1
GameManager *v84; // x0
cocos2d::CCSprite *v85; // x22
cocos2d::CCNode *v86; // x20
const cocos2d::CCPoint *v87; // x0
__n128 v88; // q0
__n128 v89; // q1
double v90; // d0
float v91; // s1
float v92; // s2
float v93; // s3
bool v95; // [xsp+Ch] [xbp-174h]
ShareLevelLayer *v96; // [xsp+10h] [xbp-170h]
std::string::size_type v97; // [xsp+18h] [xbp-168h]
unsigned __int8 v98; // [xsp+20h] [xbp-160h]
float32x2_t v99; // [xsp+28h] [xbp-158h] BYREF
void *v100[2]; // [xsp+30h] [xbp-150h] BYREF
char v101; // [xsp+47h] [xbp-139h]
float32x2_t v102; // [xsp+48h] [xbp-138h] BYREF
float32x2_t v103; // [xsp+50h] [xbp-130h] BYREF
void *__p[2]; // [xsp+58h] [xbp-128h] BYREF
char v105; // [xsp+6Fh] [xbp-111h]
void *v106; // [xsp+70h] [xbp-110h] BYREF
std::string::size_type v107; // [xsp+78h] [xbp-108h]
unsigned __int8 v108; // [xsp+87h] [xbp-F9h]
void *v109; // [xsp+88h] [xbp-F8h] BYREF
signed __int64 v110; // [xsp+90h] [xbp-F0h]
char v111; // [xsp+9Fh] [xbp-E1h]
void *v112[2]; // [xsp+A0h] [xbp-E0h] BYREF
unsigned __int8 v113; // [xsp+B7h] [xbp-C9h]
float v114; // [xsp+B8h] [xbp-C8h] BYREF
float v115[4]; // [xsp+C0h] [xbp-C0h] BYREF
float32x2_t v116; // [xsp+D0h] [xbp-B0h] BYREF
void *v117[2]; // [xsp+D8h] [xbp-A8h] BYREF
char v118; // [xsp+EFh] [xbp-91h]
std::string __dst; // [xsp+F0h] [xbp-90h] BYREF
float v120; // [xsp+110h] [xbp-70h]
float v121; // [xsp+114h] [xbp-6Ch]
cocos2d::CCPoint v122; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v123; // 0:x3.16
cocos2d::SEL_MenuHandler v124; // 0:x3.16
cocos2d::SEL_MenuHandler v125; // 0:x3.16
cocos2d::CCRect v126; // 0:kr20_16.16
cocos2d::CCPoint v127; // 0:s1.4,4:s2.4
cocos2d::CCRect v128; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
LODWORD(__dst.__r_.__value_.__l.__data_) = -1778384896;
v4 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::ccColor4B *)&__dst);
if ( !v4 )
return v4;
v95 = v4;
FLAlertLayer::incrementForcePrio(a1);
a1->m_level = a2;
cocos2d::CCObject::retain(a2);
((void (__fastcall *)(ShareLevelLayer *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(ShareLevelLayer *, __int64))a1->setKeypadEnabled)(a1, 1);
v5 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v5);
v6 = cocos2d::CCLayer::create();
a1->m_mainLayer = v6;
((void (__fastcall *)(ShareLevelLayer *, cocos2d::CCLayer *))a1->addChild)(a1, v6);
sub_100022990((float *)&__dst, 0.0, 0.0, 80.0, 80.0);
v7 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v128);
sub_100022988((float *)&__dst, 420.0, 300.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v7->setContentSize)(v7, &__dst);
v8 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v7,
0xFFFFFFFFLL);
v8.n128_f32[0] = v120 * 0.5;
v9.n128_f32[0] = v121 * 0.5;
sub_100022980(v8, v9, &__dst);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v7->setPosition)(v7, &__dst);
m_level = a1->m_level;
if ( m_level->m_levelName.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(
&__dst,
(void *)m_level->m_levelName.m_data.m_long.capacitym1,
m_level->m_levelName.m_data.m_long.size);
else
__dst = (std::string)m_level->m_levelName;
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_dst = &__dst;
else
p_dst = (std::string *)__dst.__r_.__value_.__r.__words[0];
v12 = cocos2d::CCLabelBMFont::create_1((const char *)p_dst, "goldFont.fnt");
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
v13 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(
a1->m_mainLayer,
v12);
v13.n128_f32[0] = v120 * 0.5;
v14.n128_f32[0] = (float)((float)(v121 * 0.5) + 150.0) + -20.0;
sub_100022980(v13, v14, &__dst);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string *))v12->setPosition)(v12, &__dst);
sub_100009900(v117, "You cannot change the name once it is shared.");
v15.n128_u32[0] = 0.5;
v16.n128_u32[0] = 1.0;
sub_100022980(v15, v16, &__dst);
v17 = TextArea::create((__int64)v117, (__int64)"chatFont.fnt", (__int64 *)&__dst, 0, 1.0, 400.0, 20.0);
if ( v118 < 0 )
operator delete(v117[0]);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCObject *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v17);
v18 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v12->getPosition)(v12);
v19.n128_u32[0] = 0;
v20.n128_u32[0] = -20.0;
sub_100022980(v19, v20, v112);
*(float32x2_t *)&v21 = sub_1000229DC(v18, (float32x2_t *)v112, (float32x2_t *)&__dst);
((void (__fastcall *)(cocos2d::CCObject *, std::string *, double))v17->__vftable[2].isEqual)(v17, &__dst, v21);
v22 = ((__n128 (__fastcall *)(cocos2d::CCObject *, float))v17->__vftable[2].copyWithZone)(v17, 0.8);
v22.n128_f32[0] = v120 * 0.5;
v23.n128_f32[0] = (float)(v121 * 0.5) + 60.0;
sub_100022980(v22, v23, &v116);
sub_100022990(v115, 0.0, 0.0, 80.0, 80.0);
v24 = sub_100022B98(&__dst, (__int64)v115);
v126.origin.x = *(float *)&v24;
v126.origin.y = v91;
v126.size.width = v92;
v126.size.height = v93;
v25 = cocos2d::extension::CCScale9Sprite::create("square02b_001.png", v126);
sub_100022988(&v114, 380.0, 50.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v25->setContentSize)(v25, &v114);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v25,
0xFFFFFFFFLL);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v25->setPosition)(v25, &v116);
__dst.__r_.__value_.__s.__data_[2] = 33;
LOWORD(__dst.__r_.__value_.__l.__data_) = 16514;
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v25->setColor)(v25, &__dst);
sub_100009900(&__dst, "(No description provided)");
GJGameLevel::getUnpackedLevelDescription((__int64)a2, v112);
sub_100009900(&v109, "");
v26 = v111;
v28 = v109;
v27 = v110;
v29 = v113;
if ( (v113 & 0x80u) == 0 )
{
v30 = v112;
}
else
{
v29 = (size_t)v112[1];
v30 = (void **)v112[0];
}
if ( v111 < 0 )
{
v31 = v109;
}
else
{
v27 = v111;
v31 = &v109;
}
if ( v27 >= v29 )
v32 = v29;
else
v32 = v27;
v33 = v27 == v29;
if ( memcmp(v30, v31, v32) )
v33 = 0;
if ( (v26 & 0x8000000000000000LL) == 0 )
{
if ( v33 )
goto LABEL_31;
LABEL_27:
if ( (v113 & 0x80u) == 0 )
v34 = v112;
else
v34 = (void **)v112[0];
std::string::assign(&__dst, (const std::string::value_type *)v34);
goto LABEL_31;
}
operator delete(v28);
if ( !v33 )
goto LABEL_27;
LABEL_31:
sub_100009900(&v109, "\xA0");
v96 = a1;
sub_100009900(&v106, "");
v35 = 0;
v36 = HIBYTE(__dst.__r_.__value_.__r.__words[2]);
v37 = HIBYTE(__dst.__r_.__value_.__r.__words[2]);
size = __dst.__r_.__value_.__l.__size_;
v38 = __dst.__r_.__value_.__r.__words[0];
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v40 = &__dst;
else
v40 = (std::string *)__dst.__r_.__value_.__r.__words[0];
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v36 = __dst.__r_.__value_.__l.__size_;
v41 = v111;
v42 = (unsigned __int64)v111 >> 63;
v43 = v110;
if ( v111 >= 0 )
v44 = &v109;
else
v44 = (void **)v109;
if ( v111 >= 0 )
v45 = v111;
else
v45 = v110;
while ( !v45 )
{
LABEL_52:
if ( v35 != -1 )
{
if ( (v42 & 1) != 0 )
v52 = v43;
else
v52 = v41;
if ( (v108 & 0x80u) == 0 )
v53 = (const std::string::value_type *)&v106;
else
v53 = (const std::string::value_type *)v106;
if ( (v108 & 0x80u) == 0 )
v54 = v108;
else
v54 = v107;
std::string::replace(&__dst, v35, v52, v53, v54);
v55 = v108;
if ( (v108 & 0x80u) != 0 )
v55 = v107;
v35 += v55;
v36 = HIBYTE(__dst.__r_.__value_.__r.__words[2]);
v37 = HIBYTE(__dst.__r_.__value_.__r.__words[2]);
size = __dst.__r_.__value_.__l.__size_;
v38 = __dst.__r_.__value_.__r.__words[0];
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v40 = &__dst;
else
v40 = (std::string *)__dst.__r_.__value_.__r.__words[0];
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v36 = __dst.__r_.__value_.__l.__size_;
v41 = v111;
v42 = (unsigned __int64)v111 >> 63;
v43 = v110;
v44 = v111 >= 0 ? &v109 : (void **)v109;
v45 = v111 >= 0 ? v111 : v110;
if ( v36 >= v35 )
continue;
}
goto LABEL_78;
}
v46 = v36 - v35;
if ( (__int64)(v36 - v35) >= v45 )
{
v97 = v38;
v98 = v37;
v47 = (char *)v40 + v36;
v48 = (char *)v40 + v35;
v49 = *(char *)v44;
do
{
if ( v46 - v45 == -1 )
break;
v50 = (char *)memchr(v48, v49, v46 - v45 + 1);
if ( !v50 )
break;
v51 = v50;
if ( !memcmp(v50, v44, v45) )
{
if ( v51 != v47 )
{
v35 = v51 - (char *)v40;
v38 = v97;
v37 = v98;
goto LABEL_52;
}
break;
}
v48 = v51 + 1;
v46 = v47 - (v51 + 1);
}
while ( v46 >= v45 );
v38 = v97;
v37 = v98;
}
LABEL_78:
if ( (v37 & 0x80) != 0 )
{
v56 = v96;
if ( size > 0xB4 )
{
LODWORD(size) = 180;
LABEL_83:
v57 = (float)((float)((float)(unsigned int)(180 - size) / 180.0) * 0.3) + 0.7;
goto LABEL_84;
}
}
else
{
size = v37;
v56 = v96;
}
v57 = 1.0;
if ( size >= 0x47 )
goto LABEL_83;
LABEL_84:
if ( (v37 & 0x80u) == 0 )
v58 = &__dst;
else
v58 = (std::string *)v38;
sub_100009900(__p, (char *)v58);
v59.n128_u32[0] = 0.5;
v60.n128_u32[0] = 0.5;
sub_100022980(v59, v60, &v103);
v61 = TextArea::create((__int64)__p, (__int64)"chatFont.fnt", (__int64 *)&v103, 1, 1.0, 335.0 / v57, 20.0);
if ( v105 < 0 )
operator delete(__p[0]);
v62 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCObject *))v56->m_mainLayer->addChild)(
v56->m_mainLayer,
v61);
v62.n128_u32[0] = 0;
v63.n128_u32[0] = 1.0;
sub_100022980(v62, v63, &v102);
*(float32x2_t *)&v64 = sub_1000229DC(&v116, &v102, &v103);
((void (__fastcall *)(cocos2d::CCObject *, float32x2_t *, double))v61->__vftable[2].isEqual)(v61, &v103, v64);
((void (__fastcall *)(cocos2d::CCObject *, float))v61->__vftable[2].copyWithZone)(v61, v57);
sub_100009900(
v100,
"By sharing a level you give the rights to use the level\n(in any way) to the creators of Geometry Dash.");
v65.n128_u32[0] = 0.5;
v66.n128_u32[0] = 1.0;
sub_100022980(v65, v66, &v103);
v67 = TextArea::create((__int64)v100, (__int64)"chatFont.fnt", (__int64 *)&v103, 0, 1.0, 380.0, 20.0);
if ( v101 < 0 )
operator delete(v100[0]);
v68 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCObject *))v56->m_mainLayer->addChild)(
v56->m_mainLayer,
v67);
v68.n128_f32[0] = v120 * 0.5;
v69.n128_f32[0] = (float)((float)(v121 * 0.5) + -150.0) + 65.0;
sub_100022980(v68, v69, &v103);
((void (__fastcall *)(cocos2d::CCObject *, float32x2_t *))v67->__vftable[2].isEqual)(v67, &v103);
((void (__fastcall *)(cocos2d::CCObject *, float))v67->__vftable[2].copyWithZone)(v67, 0.65);
v56->m_joystickConnected = -1;
v56->m_buttonMenu = cocos2d::CCMenu::create();
((void (__fastcall *)(cocos2d::CCLayer *))v56->m_mainLayer->addChild_0)(v56->m_mainLayer);
ShareLevelLayer::setupStars(v56);
v70 = (cocos2d::CCArray *)sub_10024A15C();
v71 = sub_10005F294("Cancel");
v123.ptr = (void (__cdecl *)(cocos2d::CCObject *))ShareLevelLayer::onClose;
v123.adj = 0;
v72 = CCMenuItemSpriteExtra::create(v71, nullptr, v56, v123);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v56->m_buttonMenu->addChild)(v56->m_buttonMenu, v72);
sub_10024A2D0((__int64)v70);
if ( v56->m_level->m_isUploaded )
v73 = "GJ_button_04.png";
else
v73 = "GJ_button_01.png";
v74 = sub_10005F3A0("Share Level", 0, 0, 0, "goldFont.fnt", v73, 1.0);
v124.ptr = (void (__cdecl *)(cocos2d::CCObject *))ShareLevelLayer::onShare;
v124.adj = 0;
v75 = CCMenuItemSpriteExtra::create(v74, nullptr, v56, v124);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v56->m_buttonMenu->addChild)(v56->m_buttonMenu, v75);
sub_10024A2D0((__int64)v70);
m_buttonMenu = v56->m_buttonMenu;
v77.n128_f32[0] = v120 * 0.5;
v78.n128_f32[0] = (float)((float)(v121 * 0.5) + -150.0) + 25.0;
sub_100022980(v77, v78, &v102);
LODWORD(v127.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(
m_buttonMenu,
(const cocos2d::CCPoint *)&v102).y);
GameToolbox::alignItemsHorisontally(v70, 15.0, v127, (bool)&v103);
v79 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_optionsBtn02_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v79->setScale)(v79, 0.8);
v125.ptr = (void (__cdecl *)(cocos2d::CCObject *))ShareLevelLayer::onSettings;
v125.adj = 0;
v80 = CCMenuItemSpriteExtra::create(v79, nullptr, v56, v125);
CCMenuItemSpriteExtra::setSizeMult(v80, 2.0);
v81 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v56->m_buttonMenu->addChild)(
v56->m_buttonMenu,
v80);
v82 = v56->m_buttonMenu;
v81.n128_f32[0] = (float)((float)(v120 * 0.5) + 210.0) + -26.0;
v83.n128_f32[0] = (float)((float)(v121 * 0.5) + 150.0) + -26.0;
sub_100022980(v81, v83, &v102);
v122 = cocos2d::CCNode::convertToNodeSpace(v82, (const cocos2d::CCPoint *)&v102);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))v80->setPosition)(
v80,
&v103,
v122.x,
v122.y);
v84 = GameManager::sharedState();
if ( !GameManager::getGameVariable(v84, "0029") )
{
v85 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_optionsTxt_001.png");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *))v56->m_mainLayer->addChild)(v56->m_mainLayer, v85);
v86 = v56->m_buttonMenu;
v87 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))v80->getPosition)(v80);
cocos2d::CCNode::convertToWorldSpace(v86, v87);
v88.n128_u32[0] = -1034158080;
v89.n128_u32[0] = 0;
sub_100022980(v88, v89, &v99);
*(float32x2_t *)&v90 = sub_1000229DC(&v102, &v99, &v103);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *, double))v85->setPosition)(v85, &v103, v90);
}
if ( (char)v108 < 0 )
operator delete(v106);
if ( v111 < 0 )
operator delete(v109);
if ( (char)v113 < 0 )
operator delete(v112[0]);
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
LOBYTE(v4) = v95;
return v4;
}