Skip to content

Commit 0868c96

Browse files
v0.0.4
1 parent 97e49e4 commit 0868c96

3 files changed

Lines changed: 66 additions & 21 deletions

File tree

about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Some info about this mod
2-
This mod will lock you out of most levels if you die in any level :3 (Torture mod lol)
2+
This mod will kick you out of the current level if you die in said level 5 times.

mod.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,28 @@
88
},
99
"id": "jamiexists.levellockout",
1010
"name": "LevelLockout",
11-
"version": "v0.0.3",
11+
"version": "v0.0.4",
1212
"developer": "JamiExists",
13-
"description": "When you die, it locks you out of custom levels... until you restart the game! (for now)",
13+
"description": "When you die 5 times, it kicks you out of the level.",
1414
"dependencies": {
1515
"geode.node-ids": ">=v1.22.0"
1616
},
17-
"tags": ["joke", "gameplay"]
17+
"tags": ["joke", "gameplay"],
18+
"settings": {
19+
"thetitle" : {
20+
"type": "title",
21+
"name": "LevelLockout Settings"
22+
},
23+
"shouldlockout": {
24+
"name": "Lockout?",
25+
"type": "bool",
26+
"default": false
27+
},
28+
"reset": {
29+
"name": "Reset Lockout status",
30+
"type": "bool",
31+
"default": false,
32+
"enable-if": "shouldlockout"
33+
}
34+
}
1835
}

src/main.cpp

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,33 @@
99

1010
using namespace geode::prelude;
1111
static bool g_levelLocked = false;
12-
int g_attemptcount = 0;
12+
int g_attemptcount = 1;
13+
#include <Geode/loader/SettingV3.hpp>
14+
#include <Geode/loader/Mod.hpp>
1315
#include <Geode/modify/PlayerObject.hpp>
1416
#include <Geode/modify/PlayLayer.hpp>
1517
#include <Geode/binding/LevelTools.hpp>
1618
#include <Geode/binding/GameManager.hpp>
19+
#include <Geode/modify/MenuLayer.hpp>
20+
#include <Geode/binding/FLAlertLayer.hpp>
21+
$execute {
22+
listenForSettingChanges<bool>("shouldlockout", [](bool value) {
23+
g_levelLocked = false;
24+
});
25+
listenForSettingChanges<bool>("reset", [](bool value) {
26+
if (value == true) {
27+
g_levelLocked = false;
28+
Mod::get()->setSettingValue("reset", false);
29+
}
30+
});
31+
}
32+
1733
class $modify(MyPlayerObject, PlayerObject) {
1834
void playerDestroyed(bool p0) {
1935
auto gm = GameManager::get();
2036
auto playLayer = PlayLayer::get();
21-
if (g_attemptcount<=9) {
22-
log::debug("test");
37+
if (g_attemptcount<=4) {
38+
log::debug("{}", g_attemptcount);
2339
g_attemptcount++;
2440
} else {
2541
PlayerObject::playerDestroyed(p0);
@@ -32,28 +48,40 @@ class $modify(MyPlayerObject, PlayerObject) {
3248
PlatformToolbox::showCursor();
3349
PlatformToolbox::toggleLockCursor(false);
3450
g_attemptcount = 0;
51+
auto alert = FLAlertLayer::create(
52+
"Well...", // title
53+
"You failed that level, try better next time.", // content
54+
"Alright" // button
55+
);
56+
alert->m_scene = this;
57+
alert->show();
3558
}
3659
}
3760
}
3861
};
39-
#include <Geode/modify/MenuLayer.hpp>
4062
class $modify(MyMenuLayer, MenuLayer) {
41-
4263
bool init() {
4364
if (!MenuLayer::init())
4465
return false;
45-
46-
if (g_levelLocked) {
47-
auto menu = this->getChildByID("main-menu");
48-
auto createmenu = this->getChildByID("main-menu");
49-
if (menu) {
50-
auto createBtn = menu->getChildByID("editor-button");
51-
if (createBtn) {
52-
createBtn->setVisible(false);
53-
menu->updateLayout(true);
54-
}
55-
}
56-
}
66+
auto lockoutchoice = Mod::get()->getSettingValue<bool>("shouldlockout");
67+
if (lockoutchoice == true) {
68+
if (g_levelLocked) {
69+
auto menu = this->getChildByID("main-menu");
70+
auto createmenu = this->getChildByID("main-menu");
71+
if (menu) {
72+
auto playBtn = menu->getChildByID("play-button");
73+
auto createBtn = menu->getChildByID("editor-button");
74+
if (playBtn) {
75+
playBtn->setVisible(false);
76+
menu->updateLayout(true);
77+
}
78+
if (createBtn) {
79+
createBtn->setVisible(false);
80+
menu->updateLayout(true);
81+
}
82+
}
83+
}
84+
}
5785

5886
return true;
5987
}

0 commit comments

Comments
 (0)