From a298e357cb61a81860c85c27b8cac8e7e7fa57c5 Mon Sep 17 00:00:00 2001 From: Erymanthus | RayDeeUx <51521765+RayDeeUx@users.noreply.github.com> Date: Sun, 17 Mar 2024 19:34:56 -0400 Subject: [PATCH] iron out last few unforseen incompats --- mod.json | 8 +++++++- src/main.cpp | 50 +++++++++++++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/mod.json b/mod.json index b41395e..d3c7a30 100644 --- a/mod.json +++ b/mod.json @@ -59,12 +59,18 @@ "type": "bool", "default": false }, - "hideHideEndscreen": { + "hideMegahackHideEndscreen": { "name": "Hide MH \"Hide Endscreen\" Button", "description": "Hides MegaHack's \"Hide Endscreen\" button from EndLevelLayer.\n(Still clickable, just invisible.)", "type": "bool", "default": false }, + "hideQOLModHideEndscreen": { + "name": "Hide QOLMod \"Hide Endscreen\" Button", + "description": "Hides QOLMod's \"Hide Endscreen\" button from EndLevelLayer.\n(Still clickable, just invisible.)", + "type": "bool", + "default": false + }, "noTransition": { "name": "No Transition", "description": "Disables the bouncing transition when showing EndLevelLayer.", diff --git a/src/main.cpp b/src/main.cpp index d0332a4..c5b8a3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -100,6 +100,12 @@ class $modify(MyEndLevelLayer, EndLevelLayer) { bool isCompactEndscreen = Loader::get()->isModLoaded("suntle.compactendscreen"); bool isGDMO = Loader::get()->isModLoaded("maxnu.gd_mega_overlay"); float compactEndscreenFallbackPosition = CCDirector::get()->getWinSize().width * 0.6f; + static void onModify(auto & self) + { + // i wanted to have compat with relative's endscreen text but better safe than sorry :) + self.setHookPriority("EndLevelLayer::showLayer", INT64_MAX - 1); + self.setHookPriority("EndLevelLayer::customSetup", INT64_MAX - 1); + } void showLayer(bool p0) { if (!Mod::get()->getSettingValue("enabled")) { EndLevelLayer::showLayer(p0); @@ -112,9 +118,13 @@ class $modify(MyEndLevelLayer, EndLevelLayer) { getChildByIDRecursive("chain-right")->setVisible(false); } if (Mod::get()->getSettingValue("hideBackground")) { getChildByIDRecursive("background")->setVisible(false); } - if (Mod::get()->getSettingValue("hideHideEndscreen") && Loader::get()->isModLoaded("absolllute.megahack") && getChildByIDRecursive("absolllute.megahack/hide-endscreen")) { + if (Mod::get()->getSettingValue("hideMegahackHideEndscreen") && Loader::get()->isModLoaded("absolllute.megahack") && getChildByIDRecursive("absolllute.megahack/hide-endscreen")) { typeinfo_cast(getChildByIDRecursive("absolllute.megahack/hide-endscreen")->getChildren()->objectAtIndex(0))->setVisible(false); // hide the sprite, not the whole button. otherwise unclickable } + if (Mod::get()->getSettingValue("hideQOLModHideEndscreen") && (Loader::get()->isModLoaded("TheSillyDoggo.Cheats") || Loader::get()->isModLoaded("thesillydoggo.cheats")) && getChildByIDRecursive("hideButton")) { + typeinfo_cast(getChildByIDRecursive("hideButton")->getChildren()->objectAtIndex(0))->setVisible(false); // hide the sprite, not the whole button. otherwise unclickable + typeinfo_cast(getChildByIDRecursive("showButton")->getChildren()->objectAtIndex(0))->setVisible(false); // hide the sprite, not the whole button. otherwise unclickable + } if (Mod::get()->getSettingValue("spaceUK")) { auto levelCompleteText = getChildByIDRecursive("level-complete-text"); if (levelCompleteText == nullptr) levelCompleteText = getChildByIDRecursive("practice-complete-text"); // grab practice mode complete text as fallback node @@ -147,27 +157,29 @@ class $modify(MyEndLevelLayer, EndLevelLayer) { mainLayer->updateLayout(); } if (m_fields->isGDMO && theLevel->m_coins == 0 && Loader::get()->getLoadedMod("maxnu.gd_mega_overlay")->getSavedValue("level/endlevellayerinfo/enabled")) { + /* + gdmo does this silly thing where they add children without giving them node IDs and i need to release this mod ASAP so please forgive me for using getobjectatindex but getchildoftype doesnt work for this use case because everything in endscreen layer is a child of some other cclayer smh auto mainLayer = getChildByID("main-layer"); if (mainLayer == nullptr) return; - // gdmo does this silly thing where they add children without giving them node IDs and i need to release this mod ASAP so please forgive me for using getobjectatindex but getchildoftype doesnt work for this use case because everything in endscreen layer is a child of some other cclayer smh - // auto mainLayerChildren = mainLayer->getChildren(); + auto mainLayerChildren = mainLayer->getChildren(); auto attemptsLabel = getChildByIDRecursive("attempts-label"); - // auto jumpsLabel = getChildByIDRecursive("jumps-label"); - // if (attemptsLabel == nullptr || jumpsLabel == nullptr) { - // log::info("uhoh! couldnt find labels"); - // attemptsLabel = getChildByIDRecursive("attempts-label"_spr); - // jumpsLabel = getChildByIDRecursive("jumps-label"_spr); - // } - // auto iHopeThisIsGDMONoclipAccuracyLabel = typeinfo_cast(mainLayerChildren->objectAtIndex(3)); - // auto iHopeThisIsGDMONoclipDeathLabel = typeinfo_cast(mainLayerChildren->objectAtIndex(4)); - // if (iHopeThisIsGDMONoclipAccuracyLabel == nullptr || iHopeThisIsGDMONoclipDeathLabel == nullptr) { - // return; - // } - // if (strcmp(iHopeThisIsGDMONoclipAccuracyLabel->getID().c_str(), "") != 0 || strcmp(iHopeThisIsGDMONoclipDeathLabel->getID().c_str(), "") != 0) { - // return; - // } - // iHopeThisIsGDMONoclipAccuracyLabel->setPositionY(attemptsLabel->getPositionY()); - // iHopeThisIsGDMONoclipDeathLabel->setPositionY(jumpsLabel->getPositionY()); + auto jumpsLabel = getChildByIDRecursive("jumps-label"); + if (attemptsLabel == nullptr || jumpsLabel == nullptr) { + log::info("uhoh! couldnt find labels"); + attemptsLabel = getChildByIDRecursive("attempts-label"_spr); + jumpsLabel = getChildByIDRecursive("jumps-label"_spr); + } + auto iHopeThisIsGDMONoclipAccuracyLabel = typeinfo_cast(mainLayerChildren->objectAtIndex(3)); + auto iHopeThisIsGDMONoclipDeathLabel = typeinfo_cast(mainLayerChildren->objectAtIndex(4)); + if (iHopeThisIsGDMONoclipAccuracyLabel == nullptr || iHopeThisIsGDMONoclipDeathLabel == nullptr) { + return; + } + if (strcmp(iHopeThisIsGDMONoclipAccuracyLabel->getID().c_str(), "") != 0 || strcmp(iHopeThisIsGDMONoclipDeathLabel->getID().c_str(), "") != 0) { + return; + } + iHopeThisIsGDMONoclipAccuracyLabel->setPositionY(attemptsLabel->getPositionY()); + iHopeThisIsGDMONoclipDeathLabel->setPositionY(jumpsLabel->getPositionY()); + */ // backup plan starts below float windowWidth = getChildByIDRecursive("background")->getContentSize().width; float windowHeight = CCDirector::get()->getWinSize().height;