99
1010using namespace geode ::prelude;
1111static 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+
1733class $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>
4062class $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