diff --git a/mod.json b/mod.json index 096aa96..a701acc 100644 --- a/mod.json +++ b/mod.json @@ -5,7 +5,7 @@ "mac": "2.2074", "android": "2.2074" }, - "version": "v0.9.15", + "version": "v0.10.0", "id": "zalphalaneous.minecraft", "name": "Minecraftify!", "developer": "Alphalaneous", @@ -40,32 +40,5 @@ "version": ">=v1.12.0-alpha.2", "importance": "required" } - ], - "incompatibilities": [ - { - "id": "ninxout.redash", - "version": "*", - "importance": "breaking" - }, - { - "id": "muhammadgames.bettermenu", - "version": "*", - "importance": "breaking" - }, - { - "id": "sanes.daily-transfer", - "version": "*", - "importance": "breaking" - }, - { - "id": "undefined0.icon_ninja", - "version": "*", - "importance": "breaking" - }, - { - "id": "timestepyt.deltarune_textboxes", - "version": "*", - "importance": "breaking" - } ] } \ No newline at end of file diff --git a/src/ui/hooks/LoadingLayer.h b/src/ui/hooks/LoadingLayer.h index e198635..9375c03 100644 --- a/src/ui/hooks/LoadingLayer.h +++ b/src/ui/hooks/LoadingLayer.h @@ -68,6 +68,8 @@ class $modify(MyLoadingLayer, LoadingLayer){ return false; } + if (!Utils::checkCompatibility()) return true; + auto searchPath = dirs::getModRuntimeDir() / Mod::get()->getID() / "resources"; CCFileUtils::get()->addSearchPath(searchPath.string().c_str()); diff --git a/src/ui/hooks/MenuLayer.h b/src/ui/hooks/MenuLayer.h index 801a7ab..1591647 100644 --- a/src/ui/hooks/MenuLayer.h +++ b/src/ui/hooks/MenuLayer.h @@ -18,6 +18,9 @@ class $modify(MenuLayer){ if (!MenuLayer::init()) { return false; } + + if (!Utils::incompatModlist.empty()) return true; + if (CCNode* bottomMenu = this->getChildByIDRecursive("bottom-menu")){ Utils::getNodeSafe(bottomMenu, "achievements-button")->setVisible(false); Utils::getNodeSafe(bottomMenu, "settings-button")->setVisible(false); @@ -46,6 +49,8 @@ class $modify(MenuLayer){ } }; +bool shownAlert = false; + class $modify(MyMenuLayer, MenuLayer) { struct Fields { @@ -61,6 +66,23 @@ class $modify(MyMenuLayer, MenuLayer) { return false; } + if (!Utils::incompatModlist.empty()) { + + if (!shownAlert) { + std::string incompatModsString = "Disable the following mods to use Minecraftify: \n"; + for (Mod* mod : Utils::incompatModlist) { + incompatModsString += "" + mod->getName() + "\n"; + } + + queueInMainThread([=] { + geode::createQuickPopup("Incompatible Mods!", incompatModsString, "Okay", nullptr, nullptr, true); + }); + + shownAlert = true; + } + return true; + } + auto winSize = CCDirector::sharedDirector()->getWinSize(); float scale = CCDirector::sharedDirector()->getContentScaleFactor()/4; diff --git a/src/utils/Utils.h b/src/utils/Utils.h index 8d22114..2700248 100644 --- a/src/utils/Utils.h +++ b/src/utils/Utils.h @@ -33,6 +33,7 @@ class Utils { public: inline static std::vector imageCache; + inline static std::vector incompatModlist; static void clearImageCache() { for(ImageData i : imageCache){ @@ -42,6 +43,34 @@ class Utils { imageCache.clear(); } + static bool checkCompatibility() { + + static std::vector incompatModIDs = { + "ninxout.redash", + "muhammadgames.bettermenu", + "sanes.daily-transfer", + "undefined0.icon_ninja", + "timestepyt.deltarune_textboxes" + }; + + for (std::string id : incompatModIDs) { + Mod* mod = Loader::get()->getInstalledMod(id); + if (mod) { + incompatModlist.push_back(mod); + } + } + + if (!incompatModlist.empty()) { + for (Hook* hook : Mod::get()->getHooks()) { + if (hook->getDisplayName() != "MenuLayer::init") { + (void) hook->disable(); + } + } + } + + return incompatModlist.empty(); + } + static void generateTexture(std::string filePath, GLenum target){ ImageData imgData;