Skip to content

Commit c6cc958

Browse files
authored
Refactor conditional compilation directives
1 parent 90a5143 commit c6cc958

1 file changed

Lines changed: 61 additions & 58 deletions

File tree

src/main.cpp

Lines changed: 61 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ std::string escENC(std::string str) {
2525
}) CCFileUtils::get()->addPriorityPath(path.c_str());
2626
};
2727

28-
#ifndef LEVELS_MODIFICATION
28+
#ifndef EXCLUDE_MLC_LEVELS_MODIFICATION
2929

3030
#include <Geode/modify/LocalLevelManager.hpp>
3131
class $modify(MLE_LocalLevelManager, LocalLevelManager) {
@@ -218,9 +218,7 @@ class $modify(MLE_MusicDownloadManager, MusicDownloadManager) {
218218
}
219219
};
220220

221-
#endif//LEVELS_MODIFICATION
222-
223-
#ifndef LISTING_OVERTAKE
221+
#endif//EXCLUDE_MLC_LEVELS_MODIFICATION
224222

225223
inline std::string createListingIDs(const std::vector<int>& list) {
226224
std::string new_listing;
@@ -261,9 +259,11 @@ inline std::vector<int> parseListingIDs(std::string list) {
261259
return rtn;
262260
}
263261

262+
#ifndef EXCLUDE_MLC_LISTING_OVERTAKE
263+
264264
#include <Geode/modify/BoomScrollLayer.hpp>
265265
class $modify(BoomScrollLayerLevelSelectExt, BoomScrollLayer) {
266-
$override static BoomScrollLayer* create(cocos2d::CCArray * pages, int unk1, bool unk2, cocos2d::CCArray * unk3, DynamicScrollDelegate * delegate) {
266+
static BoomScrollLayer* create(cocos2d::CCArray * pages, int unk1, bool unk2, cocos2d::CCArray * unk3, DynamicScrollDelegate * delegate) {
267267
if (delegate and unk3) {
268268
if (auto layer = exact_cast<LevelSelectLayer*>(delegate)) { //is created for LevelSelectLayer
269269
auto file = "levels/_list.txt";
@@ -356,7 +356,7 @@ class $modify(MLE_LevelPageExt, LevelPage) {
356356
}
357357
}
358358

359-
$override bool init(GJGameLevel * level) {
359+
bool init(GJGameLevel * level) {
360360
if (!LevelPage::init(level)) return false;
361361
return true;
362362
}
@@ -376,13 +376,63 @@ class $modify(MLE_LevelPageExt, LevelPage) {
376376
void onTheTower(CCObject * sender) { saveCurrentPageForForceNextTo(); LevelPage::onTheTower(sender); }
377377
};
378378

379-
#endif//LISTING_OVERTAKE
379+
#endif//EXCLUDE_MLC_LISTING_OVERTAKE
380380

381-
#ifndef RANDOM_SHIT
381+
#ifndef EXCLUDE_MLC_SECRET_COIN_OBJECTS_HACK
382+
383+
#include <Geode/modify/GameObject.hpp>
384+
class $modify(MLE_GameObjectExt, GameObject) {
385+
void customSetup(float) { customSetup(); };
386+
void customSetup() {
387+
if (auto v = this->getUserObject("org-"_spr + std::string("m_objectID"))) this->m_objectID = v->getTag();
388+
if (auto v = this->getUserObject("org-"_spr + std::string("m_objectType"))) this->m_objectType = (GameObjectType)v->getTag();
389+
if (auto v = this->getUserObject("org-"_spr + std::string("m_savedObjectType"))) this->m_savedObjectType = (GameObjectType)v->getTag();
390+
GameObject::customSetup();
391+
};
392+
void PlayLayerCustomSetup(float) {
393+
if (auto play = typeinfo_cast<PlayLayer*>(this)) {
394+
auto lvl = play->m_level;
395+
if (auto v = lvl->getUserObject("org-"_spr + std::string("m_localOrSaved"))) lvl->m_localOrSaved = v->getTag();
396+
if (auto v = lvl->getUserObject("org-"_spr + std::string("m_levelType"))) lvl->m_levelType = (GJLevelType)v->getTag();
397+
}
398+
};
399+
static auto valTagContainerObj(int val) { auto a = new CCObject(); a->autorelease(); a->setTag(val); return a; };
400+
static GameObject* objectFromVector(
401+
gd::vector<gd::string>&p0, gd::vector<void*>&p1, GJBaseGameLayer * p2, bool p3
402+
) {
403+
auto rtn = GameObject::objectFromVector(p0, p1, p2, p3);
404+
if (!rtn) return rtn;
405+
if (auto editor = typeinfo_cast<LevelEditorLayer*>(p2)) {
406+
if (rtn) if (rtn->m_objectID == 142) {
407+
rtn->setUserObject("org-"_spr + std::string("m_objectID"), valTagContainerObj(rtn->m_objectID));
408+
rtn->m_objectID = 1329; //user coin object id
409+
rtn->setUserObject("org-"_spr + std::string("m_objectType"), valTagContainerObj((int)rtn->m_objectType));
410+
rtn->m_objectType = GameObjectType::UserCoin; //user coin object
411+
rtn->setUserObject("org-"_spr + std::string("m_savedObjectType"), valTagContainerObj((int)rtn->m_savedObjectType));
412+
rtn->m_savedObjectType = GameObjectType::UserCoin; //what
413+
rtn->scheduleOnce(schedule_selector(MLE_GameObjectExt::customSetup), 0.f);
414+
}
415+
};
416+
if (auto play = typeinfo_cast<PlayLayer*>(p2)) {
417+
if (rtn) if (rtn->m_objectID == 142) {
418+
auto lvl = play->m_level;
419+
lvl->setUserObject("org-"_spr + std::string("m_localOrSaved"), valTagContainerObj(lvl->m_localOrSaved));
420+
lvl->m_localOrSaved = true;
421+
lvl->setUserObject("org-"_spr + std::string("m_levelType"), valTagContainerObj((int)lvl->m_levelType));
422+
lvl->m_levelType = GJLevelType::Main;
423+
play->scheduleOnce(schedule_selector(MLE_GameObjectExt::PlayLayerCustomSetup), 0.f);
424+
}
425+
}
426+
return rtn;
427+
}
428+
};
429+
#endif//EXCLUDE_MLC_SECRET_COIN_OBJECTS_HACK
430+
431+
#ifndef EXCLUDE_MLC_INGAME_CONFIG_SUPPORT
382432

383433
#include <Geode/modify/EditorPauseLayer.hpp>
384434
class $modify(MLE_EditorPauseLayer, EditorPauseLayer) {
385-
$override void saveLevel() {
435+
void saveLevel() {
386436
EditorPauseLayer::saveLevel();
387437
auto level = m_editorLayer->m_level;
388438
if (level->m_levelType == GJLevelType::Main) {
@@ -408,7 +458,7 @@ class $modify(MLE_EditorUI, EditorUI) {
408458
pop->m_scene = (this);
409459
pop->show();
410460
}
411-
$override bool init(LevelEditorLayer * editorLayer) {
461+
bool init(LevelEditorLayer * editorLayer) {
412462
if (!EditorUI::init(editorLayer)) return false;
413463
if (m_editorLayer->m_level->m_levelType == GJLevelType::Main) scheduleOnce(
414464
schedule_selector(MLE_EditorUI::showInfoPopup), 0.f
@@ -553,53 +603,6 @@ class $modify(MLE_EditorUI, EditorUI) {
553603
}
554604
};
555605

556-
#include <Geode/modify/GameObject.hpp>
557-
class $modify(MLE_GameObjectExt, GameObject) {
558-
void customSetup(float) { customSetup(); };
559-
void customSetup() {
560-
if (auto v = this->getUserObject("org-"_spr + std::string("m_objectID"))) this->m_objectID = v->getTag();
561-
if (auto v = this->getUserObject("org-"_spr + std::string("m_objectType"))) this->m_objectType = (GameObjectType)v->getTag();
562-
if (auto v = this->getUserObject("org-"_spr + std::string("m_savedObjectType"))) this->m_savedObjectType = (GameObjectType)v->getTag();
563-
GameObject::customSetup();
564-
};
565-
void PlayLayerCustomSetup(float) {
566-
if (auto play = typeinfo_cast<PlayLayer*>(this)) {
567-
auto lvl = play->m_level;
568-
if (auto v = lvl->getUserObject("org-"_spr + std::string("m_localOrSaved"))) lvl->m_localOrSaved = v->getTag();
569-
if (auto v = lvl->getUserObject("org-"_spr + std::string("m_levelType"))) lvl->m_levelType = (GJLevelType)v->getTag();
570-
}
571-
};
572-
static auto valTagContainerObj(int val) { auto a = new CCObject(); a->autorelease(); a->setTag(val); return a; };
573-
static GameObject* objectFromVector(
574-
gd::vector<gd::string>&p0, gd::vector<void*>&p1, GJBaseGameLayer * p2, bool p3
575-
) {
576-
auto rtn = GameObject::objectFromVector(p0, p1, p2, p3);
577-
if (!rtn) return rtn;
578-
if (auto editor = typeinfo_cast<LevelEditorLayer*>(p2)) {
579-
if (rtn) if (rtn->m_objectID == 142) {
580-
rtn->setUserObject("org-"_spr + std::string("m_objectID"), valTagContainerObj(rtn->m_objectID));
581-
rtn->m_objectID = 1329; //user coin object id
582-
rtn->setUserObject("org-"_spr + std::string("m_objectType"), valTagContainerObj((int)rtn->m_objectType));
583-
rtn->m_objectType = GameObjectType::UserCoin; //user coin object
584-
rtn->setUserObject("org-"_spr + std::string("m_savedObjectType"), valTagContainerObj((int)rtn->m_savedObjectType));
585-
rtn->m_savedObjectType = GameObjectType::UserCoin; //what
586-
rtn->scheduleOnce(schedule_selector(MLE_GameObjectExt::customSetup), 0.f);
587-
}
588-
};
589-
if (auto play = typeinfo_cast<PlayLayer*>(p2)) {
590-
if (rtn) if (rtn->m_objectID == 142) {
591-
auto lvl = play->m_level;
592-
lvl->setUserObject("org-"_spr + std::string("m_localOrSaved"), valTagContainerObj(lvl->m_localOrSaved));
593-
lvl->m_localOrSaved = true;
594-
lvl->setUserObject("org-"_spr + std::string("m_levelType"), valTagContainerObj((int)lvl->m_levelType));
595-
lvl->m_levelType = GJLevelType::Main;
596-
play->scheduleOnce(schedule_selector(MLE_GameObjectExt::PlayLayerCustomSetup), 0.f);
597-
}
598-
}
599-
return rtn;
600-
}
601-
};
602-
603606
void openListingEditor() {
604607
auto path = CCFileUtils::get()->fullPathForFilename("levels/_list.txt", !"why");
605608
auto read = file::readString(path.c_str()).unwrapOrDefault();
@@ -702,4 +705,4 @@ void openListingEditor() {
702705
).leak();
703706
}
704707

705-
#endif
708+
#endif//EXCLUDE_MLC_INGAME_CONFIG_SUPPORT

0 commit comments

Comments
 (0)