1313
1414#include < Geode/binding/FMODAudioEngine.hpp>
1515
16- struct RandomSeeder
17- {
16+ struct RandomSeeder {
1817 RandomSeeder () { srand (time (0 )); }
1918};
2019static RandomSeeder _randomSeeder;
@@ -27,15 +26,12 @@ auto horribleMod = getMod();
2726
2827bool isFlipped = false ;
2928
30- class $modify(HorribleCCScene, CCScene)
31- {
32- bool init () override
33- {
29+ class $modify(HorribleCCScene, CCScene) {
30+ bool init () override {
3431 if (!CCScene::init ())
3532 return false ;
3633
37- if (typeinfo_cast<CCTransitionFade *>(this ))
38- {
34+ if (typeinfo_cast<CCTransitionFade*>(this )) {
3935 log::debug (" scene is a CCTransitionFade" );
4036 return true ;
4137 }
@@ -47,17 +43,13 @@ class $modify(HorribleCCScene, CCScene)
4743};
4844
4945// modify CCMenuItem so it plays the sound whenever a button is clicked regardless of the layer
50- class $modify(HorribleCCMenuItem, CCMenuItem)
51- {
52- void activate () override
53- {
46+ class $modify(HorribleCCMenuItem, CCMenuItem) {
47+ void activate () override {
5448 auto rnd = rand () % 101 ;
5549 log::debug (" button menu chance {}" , rnd);
5650
57- if (horribleMod && horribleMod->getSavedValue <bool >(" achieve" , true ))
58- {
59- if (auto fmod = FMODAudioEngine::sharedEngine ())
60- {
51+ if (horribleMod && horribleMod->getSavedValue <bool >(" achieve" , true )) {
52+ if (auto fmod = FMODAudioEngine::sharedEngine ()) {
6153
6254 if (rnd <= 75 )
6355 // @geode-ignore(unknown-resource)
@@ -69,10 +61,8 @@ class $modify(HorribleCCMenuItem, CCMenuItem)
6961 };
7062};
7163
72- class $modify(HorribleMenuLayer, MenuLayer)
73- {
74- bool init ()
75- {
64+ class $modify(HorribleMenuLayer, MenuLayer) {
65+ bool init () {
7666 if (!MenuLayer::init ())
7767 return false ;
7868
@@ -86,8 +76,7 @@ class $modify(HorribleMenuLayer, MenuLayer)
8676 auto rnd = rand () % 101 ;
8777 log::debug (" chance {}" , rnd);
8878
89- if (auto bottomMenu = this ->getChildByID (" bottom-menu" ))
90- {
79+ if (auto bottomMenu = getChildByID (" bottom-menu" )) {
9180 auto btnSprite = CircleButtonSprite::createWithSpriteFrameName (
9281 " GJ_moonsIcon_001.png" ,
9382 0 .875f ,
@@ -100,29 +89,25 @@ class $modify(HorribleMenuLayer, MenuLayer)
10089 menu_selector (HorribleMenuLayer::onHorribleButton));
10190 btn->setID (" horribleBtn" );
10291
103- if (auto menu = typeinfo_cast<CCMenu *>(bottomMenu))
104- {
92+ if (auto menu = typeinfo_cast<CCMenu*>(bottomMenu)) {
10593 menu->addChild (btn);
10694 menu->updateLayout (true );
10795 };
10896 };
10997
11098 // Show a LazySprite for the first PNG found in the save directory
111- if (horribleMod && horribleMod->getSavedValue <bool >(" mock" , false ))
112- {
99+ if (horribleMod && horribleMod->getSavedValue <bool >(" mock" , false )) {
113100 log::debug (" mock feature enabled in MainMenu layer" );
114101
115102 namespace fs = std::filesystem;
116103
117- if (rnd <= 75 )
118- {
104+ if (rnd <= 75 ) {
119105 auto mockConfigPath = fmt::format (" {}\\ mock.json" , horribleMod->getSaveDir ());
120106 auto mockConfig = file::readJson (fs::path (mockConfigPath));
121107
122108 log::debug (" Reading path {}..." , mockConfigPath);
123109
124- if (mockConfig.isOk ())
125- {
110+ if (mockConfig.isOk ()) {
126111 log::debug (" Read mocking config file" );
127112
128113 auto mockConfigUnwr = mockConfig.unwrapOr (Value ());
@@ -133,24 +118,22 @@ class $modify(HorribleMenuLayer, MenuLayer)
133118 auto id = lvlUnwr->getKey ().value_or (" " );
134119 auto percent = lvlUnwr->asInt ().unwrapOr (99 );
135120
136- if (!id.empty ())
137- {
121+ if (!id.empty ()) {
138122 log::debug (" ID {} with percentage {} is valid" , id, percent);
139123
140124 std::string pngPath = fmt::format (" {}\\ {}.png" , horribleMod->getSaveDir (), id);
141125 ;
142126
143127 log::info (" Displaying {}" , pngPath);
144128
145- auto ss = LazySprite::create ({192 .f , 108 .f });
129+ auto ss = LazySprite::create ({ 192 .f , 108 .f });
146130 ss->setID (" mock" _spr);
147131 ss->setScale (0.25 );
148- ss->setAnchorPoint ({0.5 , 0.5 });
132+ ss->setAnchorPoint ({ 0.5 , 0.5 });
149133 ss->setZOrder (1000 );
150- ss->setPosition ({-192 .f , -108 .f });
134+ ss->setPosition ({ -192 .f , -108 .f });
151135
152- ss->setLoadCallback ([this , ss, percent, rnd](Result<> res)
153- {
136+ ss->setLoadCallback ([this , ss, percent, rnd](Result<> res) {
154137 if (res.isOk ()) {
155138 log::info (" Sprite loaded successfully from save dir PNG" );
156139
@@ -184,16 +167,12 @@ class $modify(HorribleMenuLayer, MenuLayer)
184167 ss->removeMeAndCleanup ();
185168 }; });
186169
187- ss->loadFromFile (fs::path (pngPath));
188- addChild (ss);
189- }
190- else
191- {
170+ ss->loadFromFile (fs::path (pngPath));
171+ addChild (ss);
172+ } else {
192173 log::error (" ID is invalid" );
193174 };
194- }
195- else
196- {
175+ } else {
197176 log::error (" Mocking data file not found" );
198177 };
199178 };
@@ -202,9 +181,7 @@ class $modify(HorribleMenuLayer, MenuLayer)
202181 return true ;
203182 };
204183
205- void onHorribleButton (CCObject *)
206- {
207- if (auto popup = HorribleMenuPopup::create ())
208- popup->show ();
184+ void onHorribleButton (CCObject*) {
185+ if (auto popup = HorribleMenuPopup::create ()) popup->show ();
209186 };
210187};
0 commit comments