//
// EndLevelLayer::customSetup from 0x7d59a4 to 0x7d7550 (7084 bytes)
//
// 2 xrefs:
// > ??> @ 0x84588
// > ??> @ 0x117f758
//
// 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 EndLevelLayer::customSetup(EndLevelLayer *a1)
{
cocos2d::CCPoint v2; // x0
cocos2d::CCDirector *v3; // x0
PlayLayer *m_playLayer; // x1
GJGameLevel *m_level; // x26
_BOOL4 m_isPlatformer; // w20
int m_stars; // w0
int m_moons; // w4
int m_orbs; // w3
int v10; // w0
bool m_secretKey; // w2
int m_diamonds; // w1
float v13; // s8
float v14; // s1
float v15; // s0
float v16; // s1
float v17; // s0
float v18; // s1
float v19; // s0
float v20; // s1
float v21; // s0
float v22; // s1
const char *v23; // x0
cocos2d::CCSprite *v24; // x21
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x22
GameManager *v26; // x0
float v27; // s0
float v28; // s1
__int64 v29; // x21
int PlayTimerMilli; // w0
double m_unkDouble3; // d0
unsigned __int64 v32; // x1
_BOOL4 v33; // w7
__int64 v34; // x2
unsigned int v35; // w22
__int64 v36; // x3
cocos2d::CCString *v37; // x0
size_t v38; // x0
cocos2d::CCString *v39; // x0
size_t v40; // x0
cocos2d::CCString *v41; // x0
cocos2d::CCLabelBMFont *v42; // x22
GameToolbox *m_points; // x0
cocos2d::CCMenu *v44; // x0
cocos2d::CCLayer *m_mainLayer; // x3
cocos2d::CCMenu *m_sideMenu; // x22
cocos2d::CCLayer *v47; // x21
float v48; // s8
cocos2d::CCSprite *v49; // x0
void (__fastcall *v50)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
cocos2d::CCSprite *v51; // x0
cocos2d::CCSprite *v52; // x23
void (__fastcall *v53)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
GJLevelType m_levelType; // w0
cocos2d::CCSprite *v55; // x0
CCMenuItemSpriteExtra *v56; // x20
void (__fastcall *v57)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
cocos2d::CCMenu *v58; // x23
cocos2d::CCLayer *v59; // x22
cocos2d::CCSprite *v60; // x20
CCMenuItemSpriteExtra *v61; // x0
cocos2d::CCMenu *v62; // x21
void (__fastcall *setPosition_0)(cocos2d::CCNode *__hidden, float, float); // x22
cocos2d::CCDirector *v64; // x0
float v65; // s0
float v66; // s8
cocos2d::CCDirector *v67; // x0
float v68; // s0
cocos2d::CCFadeTo *v69; // x0
GJLevelType v70; // w1
int random; // w0
int seed; // w3
int m_coins; // w24
_BOOL8 m_isPracticeMode; // x0
cocos2d::CCArray *v75; // x0
float v76; // s0
float v77; // s1
cocos2d::CCArray *v78; // x0
float v79; // s8
cocos2d::CCArray *v80; // x25
int i; // w21
const char *v82; // x0
cocos2d::CCSprite *v83; // x20
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
int j; // w20
__int64 v86; // x22
GameStatsManager *v87; // x21
const char *CoinKey; // x0
bool hasUserCoin; // w0
unsigned int v90; // w23
_BOOL4 hasItem; // w21
const char *v92; // x0
cocos2d::CCSprite *v93; // x23
__int64 v94; // x0
const char *v95; // x0
cocos2d::CCSprite *v96; // x21
__int64 v97; // x0
__int64 (__fastcall *v98)(__int64); // x1
void (__fastcall *v99)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x22
__int64 v100; // x0
_BOOL4 m_notLocal; // w0
void (__fastcall *v102)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
void *v103; // x0
char *v104; // x21
char *v105; // x22
cocos2d::CCString *v106; // x0
cocos2d::CCLabelBMFont *v107; // x23
const char *m_jumps; // x1
cocos2d::CCString *v109; // x0
cocos2d::CCLabelBMFont *v110; // x23
int v111; // w5
cocos2d::CCString *v112; // x0
size_t v113; // x0
void (__fastcall *v114)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
GameStatsManager *v115; // x21
const char *v116; // x0
GameStatsManager *v117; // x21
const char *v118; // x0
cocos2d::CCSprite *v119; // x20
cocos2d::CCLayer *v120; // x23
cocos2d::CCNode *v121; // x22
const cocos2d::CCPoint *v122; // x0
void (__fastcall *v123)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x22
cocos2d::CCSprite *v124; // x20
cocos2d::CCLayer *v125; // x19
cocos2d::CCNode *v126; // x22
const cocos2d::CCPoint *v127; // x0
void (__fastcall *v128)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x19
unsigned int *v129; // x21
int v130; // w0
cocos2d::CCSprite *v131; // x0
CCMenuItemSpriteExtra *v132; // x22
cocos2d::CCMenu *v133; // x23
__int64 v134; // x22
void *v135; // x0
void (__fastcall *v136)(__int64, cocos2d::CCPoint *); // x23
char *v137; // x1
char *v138; // x0
unsigned int *v139; // x1
int v140; // w2
__int64 *v141; // x0
__int64 v142; // x22
void *v143; // x0
cocos2d::CCLabelBMFont *v144; // x23
void *v145; // x0
unsigned int *v146; // x22
int v147; // w1
unsigned int *v148; // x1
int v149; // w2
cocos2d::CCLabelBMFont *v150; // x21
void (__fastcall *v151)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
__int64 v152; // x22
void *v153; // x0
void (__fastcall *v154)(__int64, cocos2d::CCPoint *); // x23
char *v155; // x2
unsigned int *v156; // x3
int v157; // w1
cocos2d::CCSprite *v158; // x21
void (__fastcall *setScale)(cocos2d::CCSprite *__hidden, float); // x22
float width; // s10
float *v161; // x0
CCMenuItemSpriteExtra *v162; // x22
cocos2d::CCMenu *v163; // x23
unsigned int *v164; // x3
unsigned int *v165; // x1
void (__fastcall *v166)(__int64, cocos2d::CCPoint *); // x23
unsigned int *v167; // x3
unsigned int *v168; // x1
int v169; // w2
unsigned int *v170; // x1
int v171; // w2
unsigned int *v172; // x3
int v173; // w2
char *v174; // x0
CCMenuItemSpriteExtra *v175; // [xsp+80h] [xbp+80h]
CCMenuItemSpriteExtra *v176; // [xsp+88h] [xbp+88h]
const char *v177; // [xsp+A8h] [xbp+A8h]
const char *v178; // [xsp+A8h] [xbp+A8h]
void (__fastcall *v179)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+A8h] [xbp+A8h]
const char *CString; // [xsp+A8h] [xbp+A8h]
float v181; // [xsp+B8h] [xbp+B8h]
float v182; // [xsp+BCh] [xbp+BCh]
cocos2d::CCPoint v183; // [xsp+C0h] [xbp+C0h] BYREF
cocos2d::CCPoint v184; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCPoint v185; // [xsp+D0h] [xbp+D0h] BYREF
char *v186; // [xsp+D8h] [xbp+D8h] BYREF
__int64 v187; // [xsp+E0h] [xbp+E0h] BYREF
__int64 v188; // [xsp+E8h] [xbp+E8h] BYREF
char *v189; // [xsp+F0h] [xbp+F0h] BYREF
char *v190; // [xsp+F8h] [xbp+F8h] BYREF
char *v191; // [xsp+100h] [xbp+100h] BYREF
char *v192; // [xsp+108h] [xbp+108h] BYREF
char *v193; // [xsp+110h] [xbp+110h] BYREF
char *v194; // [xsp+118h] [xbp+118h] BYREF
char *v195; // [xsp+120h] [xbp+120h] BYREF
char v196[8]; // [xsp+128h] [xbp+128h] BYREF
cocos2d::CCPoint v197; // [xsp+130h] [xbp+130h] BYREF
char *v198; // [xsp+138h] [xbp+138h] BYREF
cocos2d::CCPoint v199[2]; // [xsp+140h] [xbp+140h] BYREF
cocos2d::CCPoint v200; // 0:kr20_8.8
cocos2d::CCPoint v201; // 0:kr40_8.8
cocos2d::CCPoint v202; // 0:kr50_8.8
cocos2d::CCPoint v203; // 0:kr60_8.8
cocos2d::SEL_MenuHandler v204; // 0:x2.16
cocos2d::SEL_MenuHandler v205; // 0:x2.16
cocos2d::SEL_MenuHandler v206; // 0:x2.16
cocos2d::SEL_MenuHandler v207; // 0:x2.16
cocos2d::SEL_MenuHandler v208; // 0:x2.16
cocos2d::SEL_MenuHandler v209; // 0:x2.16
cocos2d::CCPoint v210; // 0:s1.4,4:s2.4
v2 = (cocos2d::CCPoint)_stack_chk_guard;
a1->m_coinsToAnimate = nullptr;
v199[1] = v2;
v3 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v3);
m_playLayer = a1->m_playLayer;
m_level = m_playLayer->m_level;
m_isPlatformer = m_playLayer->m_isPlatformer;
if ( m_playLayer->m_endLayerStars )
{
if ( m_level->m_levelLength == 5 )
{
m_stars = a1->m_stars;
m_moons = m_level->m_stars.random - m_level->m_stars.seed;
a1->m_moons = m_moons;
}
else
{
m_moons = a1->m_moons;
m_stars = m_level->m_stars.random - m_level->m_stars.seed;
a1->m_stars = m_stars;
}
}
else
{
m_stars = a1->m_stars;
m_moons = a1->m_moons;
}
m_orbs = m_playLayer->m_orbs;
a1->m_orbs = m_orbs;
v10 = m_stars > 0;
m_secretKey = m_playLayer->m_secretKey;
m_diamonds = m_playLayer->m_diamonds;
if ( m_moons > 0 )
++v10;
a1->m_diamonds = m_diamonds;
if ( m_orbs > 0 )
++v10;
if ( m_diamonds > 0 )
++v10;
a1->m_secretKey = m_secretKey;
if ( v10 > 2 )
{
v13 = -34.0;
v14 = 16.0;
}
else
{
v13 = -38.0;
if ( v10 == 2 )
v14 = 5.0;
else
v14 = 0.0;
}
cocos2d::CCPoint::CCPoint(&v183, (float)(v181 * 0.5) + 120.0, (float)((float)(v182 * 0.5) + 18.0) + v14);
if ( a1->m_stars > 0 || a1->m_moons > 0 )
{
cocos2d::CCPoint::operator=(&a1->m_starsPosition, v15, v16);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, 0.0, v13);
cocos2d::CCPoint::operator+(v199, &v183, &v198);
cocos2d::CCPoint::operator=(&v183, v17, v18);
}
if ( a1->m_orbs > 0 )
{
cocos2d::CCPoint::operator=(&a1->m_orbsPosition, v15, v16);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, 0.0, v13);
cocos2d::CCPoint::operator+(v199, &v183, &v198);
cocos2d::CCPoint::operator=(&v183, v19, v20);
}
if ( a1->m_diamonds > 0 )
{
cocos2d::CCPoint::operator=(&a1->m_diamondsPosition, v15, v16);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, 0.0, v13);
cocos2d::CCPoint::operator+(v199, &v183, &v198);
cocos2d::CCPoint::operator=(&v183, v21, v22);
}
if ( a1->m_playLayer->m_isPracticeMode )
v23 = "GJ_practiceComplete_001.png";
else
v23 = "GJ_levelComplete_001.png";
v24 = cocos2d::CCSprite::createWithSpriteFrameName(v23);
v24->setScale(v24, 0.8);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v24, 15);
setPosition = v24->setPosition;
cocos2d::CCPoint::CCPoint(v199, v181 * 0.5, (float)(v182 * 0.5) + 75.0);
setPosition(v24, v199);
v26 = GameManager::sharedState();
if ( GameManager::getGameVariable(v26, "0095") )
cocos2d::CCSprite::setFlipX(v24, 1);
a1->m_buttonMenu->setVisible(a1->m_buttonMenu, 0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, 0.0, 5.0);
cocos2d::CCPoint::operator+(v199, &a1->m_endPosition, &v198);
cocos2d::CCPoint::operator=(&a1->m_endPosition, v27, v28);
v29 = (__int64)v24->getPosition(v24);
cocos2d::CCPoint::CCPoint(v199, 0.0, -40.0);
cocos2d::CCPoint::operator+(&v184, v29, v199);
if ( !m_isPlatformer )
{
cocos2d::CCPoint::CCPoint(&v185, &v184);
v35 = 0;
v106 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Attempts: %i",
(const char *)(unsigned int)a1->m_playLayer->m_attempts);
cocos2d::CCString::getCString(v106);
v107 = cocos2d::CCLabelBMFont::create();
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v107, 3);
v107->setPosition(v107, &v185);
v107->setScale(v107, 0.8);
m_jumps = (const char *)(unsigned int)a1->m_playLayer->m_jumps;
v185.y = v185.y - 24.0;
v109 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"Jumps: %i", m_jumps);
cocos2d::CCString::getCString(v109);
v110 = cocos2d::CCLabelBMFont::create();
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v110, 3);
v110->setPosition(v110, &v185);
v110->setScale(v110, 0.8);
m_unkDouble3 = a1->m_playLayer->m_gameState.m_unkDouble3;
v111 = (int)m_unkDouble3;
v186 = &byte_124B6C8;
*(float *)&m_unkDouble3 = v185.y - 24.0;
v32 = (unsigned int)(v111 / 3600);
v36 = (unsigned int)(v111 % 60);
v34 = (unsigned int)(v111 / 60 % 60);
v33 = v111 / 3600 == 0;
v185.y = v185.y - 24.0;
LABEL_76:
if ( v33 )
{
v112 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%02d:%02d",
(const char *)(unsigned int)v34,
(unsigned int)v36,
m_unkDouble3);
goto LABEL_78;
}
LABEL_81:
v112 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%02d:%02d:%02d",
(const char *)v32,
v34,
v36);
LABEL_78:
CString = cocos2d::CCString::getCString(v112);
v113 = strlen(CString);
sub_D1798C(&v186, CString, v113);
if ( !m_isPlatformer )
goto LABEL_30;
goto LABEL_29;
}
v184.y = v184.y - 12.0;
cocos2d::CCPoint::CCPoint(&v185, &v184);
PlayTimerMilli = GJBaseGameLayer::getPlayTimerMilli(a1->m_playLayer);
v186 = &byte_124B6C8;
v32 = (unsigned int)(PlayTimerMilli / 1000 / 3600);
v33 = PlayTimerMilli / 1000 / 3600 == 0;
v34 = (unsigned int)(PlayTimerMilli / 1000 / 60 % 60);
v35 = PlayTimerMilli % 1000;
v36 = (unsigned int)(PlayTimerMilli / 1000 % 60);
if ( (_DWORD)v34 )
goto LABEL_76;
if ( PlayTimerMilli / 1000 / 3600 )
goto LABEL_81;
v37 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)v36,
v34);
v177 = cocos2d::CCString::getCString(v37);
v38 = strlen(v177);
sub_D1798C(&v186, v177, v38);
LABEL_29:
v39 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s.%03d", v186, v35);
v178 = cocos2d::CCString::getCString(v39);
v40 = strlen(v178);
sub_D1798C(&v186, v178, v40);
LABEL_30:
v41 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"Time: %s", v186);
cocos2d::CCString::getCString(v41);
v42 = cocos2d::CCLabelBMFont::create();
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v42, 3);
v42->setPosition(v42, &v185);
cocos2d::CCLabelBMFont::limitLabelWidth(v42, 150.0, 0.8, 0.0);
v185.y = v185.y - 24.0;
if ( m_isPlatformer )
{
m_points = (GameToolbox *)(unsigned int)a1->m_playLayer->m_gameState.m_points;
if ( (_DWORD)m_points )
{
GameToolbox::pointsToString(m_points, &v187);
v141 = (__int64 *)sub_D17B90(&v187, 0, "Points: ", 8);
v142 = *v141;
*v141 = (__int64)&byte_124B6C8;
v143 = (void *)(v187 - 24);
if ( (__int64 *)(v187 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v170 = (unsigned int *)(v187 - 8);
do
v171 = __ldaxr(v170);
while ( __stlxr(v171 - 1, v170) );
}
else
{
v171 = *(_DWORD *)(v187 - 8);
*(_DWORD *)(v187 - 8) = v171 - 1;
}
if ( v171 <= 0 )
operator delete(v143);
}
v144 = cocos2d::CCLabelBMFont::create();
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v144, 3);
v144->setPosition(v144, &v185);
cocos2d::CCLabelBMFont::limitLabelWidth(v144, 150.0, 0.8, 0.0);
v145 = (void *)(v142 - 24);
v185.y = v185.y - 24.0;
if ( (__int64 *)(v142 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v146 = (unsigned int *)(v142 - 8);
do
v147 = __ldaxr(v146);
while ( __stlxr(v147 - 1, v146) );
}
else
{
v147 = *(_DWORD *)(v142 - 8);
*(_DWORD *)(v142 - 8) = v147 - 1;
}
if ( v147 <= 0 )
operator delete(v145);
}
}
}
if ( m_level->m_levelType == Editor )
{
sub_D153B8((int)&v188, " ");
cocos2d::CCPoint::CCPoint(v199, 0.5, 1.0);
v152 = TextArea::create((__int64)&v188, "bigFont.fnt", v199, 0, 1.0, 620.0, 20.0);
v153 = (void *)(v188 - 24);
if ( (__int64 *)(v188 - 24) != &qword_124B6B0 )
{
v172 = (unsigned int *)(v188 - 8);
if ( &pthread_create )
{
do
v173 = __ldaxr(v172);
while ( __stlxr(v173 - 1, v172) );
}
else
{
v173 = *(_DWORD *)(v188 - 8);
*(_DWORD *)(v188 - 8) = v173 - 1;
}
if ( v173 <= 0 )
operator delete(v153);
}
a1->m_mainLayer->addChild(a1->m_mainLayer, (cocos2d::CCNode *)v152);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v152 + 160LL))(v152, 0.55);
v154 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v152 + 184LL);
*(_DWORD *)(v152 + 624) = 1107820544;
cocos2d::CCPoint::CCPoint(v199, v181 * 0.5, (float)(v182 * 0.5) + -51.0);
v154(v152, v199);
if ( m_isPlatformer )
{
v166 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v152 + 184LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, 0.0, -12.0);
cocos2d::CCPoint::operator+(v199, &v185, &v198);
v166(v152, v199);
}
if ( a1->m_playLayer->m_isIgnoreDamageEnabled )
{
sub_D153B8((int)&v189, "You cannot verify a level after using Ignore Damage.");
TextArea::setString(v152, (const void **)&v189);
v137 = v189;
v138 = v189 - 24;
if ( v189 - 24 == (char *)&qword_124B6B0 )
goto LABEL_36;
if ( &pthread_create )
{
v165 = (unsigned int *)(v189 - 8);
do
v140 = __ldaxr(v165);
while ( __stlxr(v140 - 1, v165) );
LABEL_106:
if ( v140 > 0 )
goto LABEL_36;
LABEL_134:
operator delete(v138);
goto LABEL_36;
}
LABEL_169:
v140 = *((_DWORD *)v137 - 2);
*((_DWORD *)v137 - 2) = v140 - 1;
goto LABEL_106;
}
if ( a1->m_playLayer->m_isTestMode )
{
sub_D153B8((int)&v190, "You cannot verify a level if it has a start pos.");
TextArea::setString(v152, (const void **)&v190);
v155 = v190;
v138 = v190 - 24;
if ( v190 - 24 == (char *)&qword_124B6B0 )
goto LABEL_36;
v167 = (unsigned int *)(v190 - 8);
if ( &pthread_create )
{
do
v157 = __ldaxr(v167);
while ( __stlxr(v157 - 1, v167) );
LABEL_133:
if ( v157 > 0 )
goto LABEL_36;
goto LABEL_134;
}
}
else
{
if ( !a1->m_playLayer->m_isPracticeMode || m_level->m_isVerified.random - m_level->m_isVerified.seed == 1 )
{
if ( GJGameLevel::areCoinsVerified(m_level) )
{
if ( m_level->m_coins > 0 )
{
sub_D153B8((int)&v192, "Level and Coins Verified!");
TextArea::setString(v152, (const void **)&v192);
v155 = v192;
v138 = v192 - 24;
if ( v192 - 24 == (char *)&qword_124B6B0 )
goto LABEL_36;
v156 = (unsigned int *)(v192 - 8);
if ( &pthread_create )
{
do
v157 = __ldaxr(v156);
while ( __stlxr(v157 - 1, v156) );
goto LABEL_133;
}
goto LABEL_176;
}
sub_D153B8((int)&v193, "Level Verified!");
TextArea::setString(v152, (const void **)&v193);
v174 = v193 - 24;
if ( v193 - 24 == (char *)&qword_124B6B0 )
goto LABEL_36;
}
else
{
EndLevelLayer::getCoinString(a1, (__int64)&v194);
sub_D153B8((int)&v195, v194);
TextArea::setString(v152, (const void **)&v195);
if ( v195 - 24 != (char *)&qword_124B6B0 )
sub_4DBDD0(v195 - 24);
v174 = v194 - 24;
if ( v194 - 24 == (char *)&qword_124B6B0 )
goto LABEL_36;
}
sub_4DBDD0(v174);
goto LABEL_36;
}
sub_D153B8((int)&v191, "Complete the level in normal mode to verify it!");
TextArea::setString(v152, (const void **)&v191);
v155 = v191;
v138 = v191 - 24;
if ( v191 - 24 == (char *)&qword_124B6B0 )
goto LABEL_36;
v164 = (unsigned int *)(v191 - 8);
if ( &pthread_create )
{
do
v157 = __ldaxr(v164);
while ( __stlxr(v157 - 1, v164) );
goto LABEL_133;
}
}
LABEL_176:
v157 = *((_DWORD *)v155 - 2);
*((_DWORD *)v155 - 2) = v157 - 1;
goto LABEL_133;
}
if ( !a1->m_playLayer->m_isPracticeMode )
{
if ( m_level->m_coins <= 0 )
{
EndLevelLayer::getEndText(a1);
v150 = cocos2d::CCLabelBMFont::create();
cocos2d::CCLabelBMFont::limitLabelWidth(v150, 260.0, 0.9, 0.0);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v150, 3);
v151 = v150->setPosition;
cocos2d::CCPoint::CCPoint(v199, v181 * 0.5, (float)(v182 * 0.5) + -65.0);
v151(v150, v199);
}
goto LABEL_36;
}
sub_D153B8((int)&v197, " ");
cocos2d::CCPoint::CCPoint(v199, 0.5, 1.0);
v134 = TextArea::create((__int64)&v197, "bigFont.fnt", v199, 0, 1.0, 620.0, 20.0);
v135 = (void *)(*(_QWORD *)&v197 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v197 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v168 = (unsigned int *)(*(_QWORD *)&v197 - 8LL);
do
v169 = __ldaxr(v168);
while ( __stlxr(v169 - 1, v168) );
}
else
{
v169 = *(_DWORD *)(*(_QWORD *)&v197 - 8LL);
*(_DWORD *)(*(_QWORD *)&v197 - 8LL) = v169 - 1;
}
if ( v169 <= 0 )
operator delete(v135);
}
a1->m_mainLayer->addChild(a1->m_mainLayer, (cocos2d::CCNode *)v134);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v134 + 160LL))(v134, 0.55);
v136 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v134 + 184LL);
*(_DWORD *)(v134 + 624) = 1107820544;
cocos2d::CCPoint::CCPoint(v199, v181 * 0.5, (float)(v182 * 0.5) + -51.0);
v136(v134, v199);
sub_D153B8((int)&v198, "Well done... Now try to complete it without any checkpoints!");
TextArea::setString(v134, (const void **)&v198);
v137 = v198;
v138 = v198 - 24;
if ( v198 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v139 = (unsigned int *)(v198 - 8);
do
v140 = __ldaxr(v139);
while ( __stlxr(v140 - 1, v139) );
goto LABEL_106;
}
goto LABEL_169;
}
LABEL_36:
v44 = cocos2d::CCMenu::create();
m_mainLayer = a1->m_mainLayer;
a1->m_sideMenu = v44;
m_mainLayer->addChild_0(m_mainLayer, v44, 1);
m_sideMenu = a1->m_sideMenu;
v47 = a1->m_mainLayer;
v48 = (float)((float)(v182 * 0.5) + -115.0) - 10.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, v181 * 0.5, v48);
cocos2d::CCNode::convertToWorldSpace(v47, (const cocos2d::CCPoint *)&v198);
cocos2d::CCNode::convertToNodeSpace(m_sideMenu, v199);
v49 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_replayBtn_001.png");
v204.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v204.adj = (size_t)EndLevelLayer::onReplay;
v176 = CCMenuItemSpriteExtra::create(v49, nullptr, v204);
a1->m_sideMenu->addChild(a1->m_sideMenu, v176);
v50 = v176->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, -100.0, 0.0);
cocos2d::CCPoint::operator+(v199, v196, &v198);
v50(v176, v199);
v51 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_menuBtn_001.png");
v205.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v52 = v51;
v205.adj = (size_t)EndLevelLayer::onMenu;
v175 = CCMenuItemSpriteExtra::create(v51, nullptr, v205);
a1->m_sideMenu->addChild(a1->m_sideMenu, v175);
v53 = v175->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, 100.0, 0.0);
cocos2d::CCPoint::operator+(v199, v196, &v198);
v53(v175, v199);
if ( m_level->m_levelType == Editor )
{
v158 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_editBtn_001.png");
setScale = v158->setScale;
width = v52->getContentSize(v52)->width;
v161 = (float *)v158->getContentSize(v158);
setScale(v158, width / *v161);
v209.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v209.adj = (size_t)EndLevelLayer::onEdit;
v162 = CCMenuItemSpriteExtra::create(v158, nullptr, v209);
a1->m_sideMenu->addChild(a1->m_sideMenu, v162);
cocos2d::CCPoint::CCPoint(&v197, v181 * 0.5, v48);
v163 = a1->m_sideMenu;
cocos2d::CCNode::convertToWorldSpace(a1->m_mainLayer, &v197);
v203 = cocos2d::CCNode::convertToNodeSpace(v163, (const cocos2d::CCPoint *)&v198);
cocos2d::CCPoint::operator=(&v197, v203.x, v203.y);
v162->setPosition(v162, &v197);
}
if ( a1->m_playLayer->m_isPracticeMode )
{
v131 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_restartCheckBtn_001.png");
v208.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v208.adj = (size_t)EndLevelLayer::onRestartCheckpoint;
v132 = CCMenuItemSpriteExtra::create(v131, nullptr, v208);
a1->m_sideMenu->addChild(a1->m_sideMenu, v132);
cocos2d::CCPoint::CCPoint(&v197, (float)(v181 * 0.5) + -180.0, v48);
v133 = a1->m_sideMenu;
cocos2d::CCNode::convertToWorldSpace(a1->m_mainLayer, &v197);
v202 = cocos2d::CCNode::convertToNodeSpace(v133, (const cocos2d::CCPoint *)&v198);
cocos2d::CCPoint::operator=(&v197, v202.x, v202.y);
v132->setPosition(v132, &v197);
}
m_levelType = m_level->m_levelType;
if ( (m_isPlatformer || m_levelType != Editor) && m_levelType != Main )
{
v55 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_levelLeaderboardBtn_001.png");
v206.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v206.adj = (size_t)EndLevelLayer::onLevelLeaderboard;
v56 = CCMenuItemSpriteExtra::create(v55, nullptr, v206);
a1->m_sideMenu->addChild(a1->m_sideMenu, v56);
v57 = v56->setPosition;
v58 = a1->m_sideMenu;
v59 = a1->m_mainLayer;
cocos2d::CCPoint::CCPoint(&v197, (float)(v181 * 0.5) + 178.0, (float)(v182 * 0.5) + 115.0);
cocos2d::CCNode::convertToWorldSpace(v59, &v197);
v200 = cocos2d::CCNode::convertToNodeSpace(v58, (const cocos2d::CCPoint *)&v198);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))v57)(v56, v199, v200.x, v200.y);
}
v60 = cocos2d::CCSprite::createWithSpriteFrameName("hideBtn_001.png");
v60->setOpacity(v60, 0);
v207.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v207.adj = (size_t)EndLevelLayer::onHideLayer;
v61 = CCMenuItemSpriteExtra::create(v60, nullptr, v207);
v62 = cocos2d::CCMenu::createWithItem(v61);
a1->addChild_0(a1, v62, 100);
setPosition_0 = v62->setPosition_0;
v64 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenRight(v64);
v66 = v65 - 17.0;
v67 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenTop(v67);
setPosition_0(v62, v66, v68 - 15.0);
v69 = cocos2d::CCFadeTo::create(1.0, (unsigned __int8)&dword_7C + 1);
cocos2d::CCNode::runAction(v60, v69);
v70 = m_level->m_levelType;
random = m_level->m_coinsVerified.random;
seed = m_level->m_coinsVerified.seed;
m_coins = m_level->m_coins;
a1->m_notLocal = v70 != Main;
a1->m_coinsVerified = random - seed == 1;
if ( m_coins > 0 )
{
m_isPracticeMode = a1->m_playLayer->m_isPracticeMode;
if ( (unsigned int)m_isPracticeMode < (v70 != Editor) )
{
v75 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)m_isPracticeMode);
a1->m_coinsToAnimate = v75;
cocos2d::CCObject::retain(v75);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, v181 * 0.5, (float)(v182 * 0.5) + 126.0);
cocos2d::CCPoint::CCPoint(v199, v181 * 0.5, (float)(v182 * 0.5) + -64.0);
v78 = (cocos2d::CCArray *)cocos2d::CCPoint::operator=(&v198, v76, v77);
if ( m_coins <= 4 )
{
if ( m_coins == 4 )
v79 = 15.0;
else
v79 = 20.0;
}
else
{
v79 = 13.0;
}
v80 = (cocos2d::CCArray *)cocos2d::CCArray::create(v78);
for ( i = 1; i <= m_coins; ++i )
{
while ( 1 )
{
v82 = a1->m_notLocal ? "secretCoin_2_b_01_001.png" : "secretCoin_b_01_001.png";
v83 = cocos2d::CCSprite::createWithSpriteFrameName(v82);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v83, 8);
cocos2d::CCArray::addObject(v80, v83);
if ( a1->m_notLocal && !a1->m_coinsVerified )
break;
if ( m_coins < ++i )
goto LABEL_56;
}
setColor = v83->setColor;
LOWORD(v199[0].x) = -20481;
BYTE2(v199[0].x) = 75;
setColor(v83, (const cocos2d::ccColor3B *)v199);
}
LABEL_56:
cocos2d::CCPoint::CCPoint(v199, (const cocos2d::CCPoint *)&v198);
GameToolbox::alignItemsHorisontally(v80, v79, v210, (bool)v199);
for ( j = 1; m_coins >= j; ++j )
{
v86 = cocos2d::CCArray::objectAtIndex(v80, j - 1);
if ( a1->m_notLocal )
{
if ( a1->m_coinsVerified )
{
v87 = GameStatsManager::sharedState();
CoinKey = GJGameLevel::getCoinKey(m_level, j);
hasUserCoin = GameStatsManager::hasUserCoin(v87, CoinKey);
}
else
{
v115 = GameStatsManager::sharedState();
v116 = GJGameLevel::getCoinKey(m_level, j);
hasUserCoin = GameStatsManager::hasPendingUserCoin(v115, v116);
}
}
else
{
v117 = GameStatsManager::sharedState();
v118 = GJGameLevel::getCoinKey(m_level, j);
hasUserCoin = GameStatsManager::hasSecretCoin(v117, v118);
}
v90 = hasUserCoin;
hasItem = GJBaseGameLayer::hasItem(a1->m_playLayer, j);
if ( v90 <= hasItem )
goto LABEL_86;
v92 = "secretCoinUI2_001.png";
if ( !a1->m_notLocal )
v92 = "secretCoinUI_001.png";
v93 = cocos2d::CCSprite::createWithSpriteFrameName(v92);
v179 = v93->setPosition;
v94 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v86 + 192LL))(v86);
v179(v93, (const cocos2d::CCPoint *)v94);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v93, 9);
if ( a1->m_notLocal )
{
if ( !a1->m_coinsVerified )
{
v114 = v93->setColor;
LOWORD(v199[0].x) = -20481;
BYTE2(v199[0].x) = 75;
v114(v93, (const cocos2d::ccColor3B *)v199);
LABEL_86:
if ( hasItem )
{
v95 = "secretCoinUI_001.png";
if ( a1->m_notLocal )
v95 = "secretCoinUI2_001.png";
goto LABEL_67;
}
continue;
}
if ( hasItem )
{
v95 = "secretCoinUI2_001.png";
LABEL_67:
v96 = cocos2d::CCSprite::createWithSpriteFrameName(v95);
v97 = v86;
v98 = *(__int64 (__fastcall **)(__int64))(*(_QWORD *)v86 + 192LL);
v99 = v96->setPosition;
v100 = v98(v97);
v99(v96, (const cocos2d::CCPoint *)v100);
cocos2d::CCArray::addObject(a1->m_coinsToAnimate, v96);
m_notLocal = a1->m_notLocal;
a1->m_animateCoins = 1;
if ( m_notLocal && !a1->m_coinsVerified )
{
v102 = v96->setColor;
LOWORD(v199[0].x) = -20481;
BYTE2(v199[0].x) = 75;
v102(v96, (const cocos2d::ccColor3B *)v199);
}
}
}
else if ( hasItem )
{
v95 = "secretCoinUI_001.png";
goto LABEL_67;
}
}
}
}
sub_D153B8((int)v199, "Geometry Dash");
PlatformToolbox::tryShowRateDialog(v199);
v103 = (void *)(*(_QWORD *)v199 - 24LL);
if ( (__int64 *)(*(_QWORD *)v199 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v148 = (unsigned int *)(*(_QWORD *)v199 - 8LL);
do
v149 = __ldaxr(v148);
while ( __stlxr(v149 - 1, v148) );
}
else
{
v149 = *(_DWORD *)(*(_QWORD *)v199 - 8LL);
*(_DWORD *)(*(_QWORD *)v199 - 8LL) = v149 - 1;
}
if ( v149 <= 0 )
operator delete(v103);
}
if ( PlatformToolbox::isControllerConnected() )
{
v119 = cocos2d::CCSprite::createWithSpriteFrameName("controllerBtn_Start_001.png");
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v119, 10);
v120 = a1->m_mainLayer;
v121 = v176->getParent(v176);
v122 = v176->getPosition(v176);
cocos2d::CCNode::convertToWorldSpace(v121, v122);
cocos2d::CCNode::convertToNodeSpace(v120, v199);
v123 = v119->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, 0.0, -25.0);
cocos2d::CCPoint::operator+(v199, &v197, &v198);
v123(v119, v199);
v124 = cocos2d::CCSprite::createWithSpriteFrameName("controllerBtn_B_001.png");
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v124, 10);
v125 = a1->m_mainLayer;
v126 = v175->getParent(v175);
v127 = v175->getPosition(v175);
cocos2d::CCNode::convertToWorldSpace(v126, v127);
v201 = cocos2d::CCNode::convertToNodeSpace(v125, (const cocos2d::CCPoint *)&v198);
cocos2d::CCPoint::operator=(&v197, v201.x, v201.y);
v128 = v124->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v198, 0.0, -25.0);
cocos2d::CCPoint::operator+(v199, &v197, &v198);
v128(v124, v199);
v124->setScale(v124, 0.8);
v104 = v186;
v105 = v186 - 24;
if ( v186 - 24 == (char *)&qword_124B6B0 )
return;
}
else
{
v104 = v186;
v105 = v186 - 24;
if ( v186 - 24 == (char *)&qword_124B6B0 )
return;
}
if ( &pthread_create )
{
v129 = (unsigned int *)(v104 - 8);
do
v130 = __ldaxr(v129);
while ( __stlxr(v130 - 1, v129) );
}
else
{
v130 = *((_DWORD *)v104 - 2);
*((_DWORD *)v104 - 2) = v130 - 1;
}
if ( v130 <= 0 )
operator delete(v105);
}