Skip to content

Commit 0ae8de0

Browse files
committed
Compatibility check
1 parent a79f8b6 commit 0ae8de0

File tree

4 files changed

+54
-28
lines changed

4 files changed

+54
-28
lines changed

mod.json

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"mac": "2.2074",
66
"android": "2.2074"
77
},
8-
"version": "v0.9.15",
8+
"version": "v0.10.0",
99
"id": "zalphalaneous.minecraft",
1010
"name": "Minecraftify!",
1111
"developer": "Alphalaneous",
@@ -40,32 +40,5 @@
4040
"version": ">=v1.12.0-alpha.2",
4141
"importance": "required"
4242
}
43-
],
44-
"incompatibilities": [
45-
{
46-
"id": "ninxout.redash",
47-
"version": "*",
48-
"importance": "breaking"
49-
},
50-
{
51-
"id": "muhammadgames.bettermenu",
52-
"version": "*",
53-
"importance": "breaking"
54-
},
55-
{
56-
"id": "sanes.daily-transfer",
57-
"version": "*",
58-
"importance": "breaking"
59-
},
60-
{
61-
"id": "undefined0.icon_ninja",
62-
"version": "*",
63-
"importance": "breaking"
64-
},
65-
{
66-
"id": "timestepyt.deltarune_textboxes",
67-
"version": "*",
68-
"importance": "breaking"
69-
}
7043
]
7144
}

src/ui/hooks/LoadingLayer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class $modify(MyLoadingLayer, LoadingLayer){
6868
return false;
6969
}
7070

71+
if (!Utils::checkCompatibility()) return true;
72+
7173
auto searchPath = dirs::getModRuntimeDir() / Mod::get()->getID() / "resources";
7274
CCFileUtils::get()->addSearchPath(searchPath.string().c_str());
7375

src/ui/hooks/MenuLayer.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class $modify(MenuLayer){
1818
if (!MenuLayer::init()) {
1919
return false;
2020
}
21+
22+
if (!Utils::incompatModlist.empty()) return true;
23+
2124
if (CCNode* bottomMenu = this->getChildByIDRecursive("bottom-menu")){
2225
Utils::getNodeSafe(bottomMenu, "achievements-button")->setVisible(false);
2326
Utils::getNodeSafe(bottomMenu, "settings-button")->setVisible(false);
@@ -46,6 +49,8 @@ class $modify(MenuLayer){
4649
}
4750
};
4851

52+
bool shownAlert = false;
53+
4954
class $modify(MyMenuLayer, MenuLayer) {
5055

5156
struct Fields {
@@ -61,6 +66,23 @@ class $modify(MyMenuLayer, MenuLayer) {
6166
return false;
6267
}
6368

69+
if (!Utils::incompatModlist.empty()) {
70+
71+
if (!shownAlert) {
72+
std::string incompatModsString = "Disable the following mods to use <cg>Minecraftify</c>: \n";
73+
for (Mod* mod : Utils::incompatModlist) {
74+
incompatModsString += "<cr>" + mod->getName() + "</c>\n";
75+
}
76+
77+
queueInMainThread([=] {
78+
geode::createQuickPopup("Incompatible Mods!", incompatModsString, "Okay", nullptr, nullptr, true);
79+
});
80+
81+
shownAlert = true;
82+
}
83+
return true;
84+
}
85+
6486
auto winSize = CCDirector::sharedDirector()->getWinSize();
6587

6688
float scale = CCDirector::sharedDirector()->getContentScaleFactor()/4;

src/utils/Utils.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Utils {
3333
public:
3434

3535
inline static std::vector<ImageData> imageCache;
36+
inline static std::vector<Mod*> incompatModlist;
3637

3738
static void clearImageCache() {
3839
for(ImageData i : imageCache){
@@ -42,6 +43,34 @@ class Utils {
4243
imageCache.clear();
4344
}
4445

46+
static bool checkCompatibility() {
47+
48+
static std::vector<std::string> incompatModIDs = {
49+
"ninxout.redash",
50+
"muhammadgames.bettermenu",
51+
"sanes.daily-transfer",
52+
"undefined0.icon_ninja",
53+
"timestepyt.deltarune_textboxes"
54+
};
55+
56+
for (std::string id : incompatModIDs) {
57+
Mod* mod = Loader::get()->getInstalledMod(id);
58+
if (mod) {
59+
incompatModlist.push_back(mod);
60+
}
61+
}
62+
63+
if (!incompatModlist.empty()) {
64+
for (Hook* hook : Mod::get()->getHooks()) {
65+
if (hook->getDisplayName() != "MenuLayer::init") {
66+
(void) hook->disable();
67+
}
68+
}
69+
}
70+
71+
return incompatModlist.empty();
72+
}
73+
4574
static void generateTexture(std::string filePath, GLenum target){
4675

4776
ImageData imgData;

0 commit comments

Comments
 (0)