Skip to content

Commit

Permalink
Compatibility check
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphalaneous committed Dec 28, 2024
1 parent a79f8b6 commit 0ae8de0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 28 deletions.
29 changes: 1 addition & 28 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
]
}
2 changes: 2 additions & 0 deletions src/ui/hooks/LoadingLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
22 changes: 22 additions & 0 deletions src/ui/hooks/MenuLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -46,6 +49,8 @@ class $modify(MenuLayer){
}
};

bool shownAlert = false;

class $modify(MyMenuLayer, MenuLayer) {

struct Fields {
Expand All @@ -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 <cg>Minecraftify</c>: \n";
for (Mod* mod : Utils::incompatModlist) {
incompatModsString += "<cr>" + mod->getName() + "</c>\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;
Expand Down
29 changes: 29 additions & 0 deletions src/utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Utils {
public:

inline static std::vector<ImageData> imageCache;
inline static std::vector<Mod*> incompatModlist;

static void clearImageCache() {
for(ImageData i : imageCache){
Expand All @@ -42,6 +43,34 @@ class Utils {
imageCache.clear();
}

static bool checkCompatibility() {

static std::vector<std::string> 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;
Expand Down

0 comments on commit 0ae8de0

Please sign in to comment.