99#include < Geode/modify/MenuLayer.hpp>
1010
1111using namespace geode ::prelude;
12- using namespace geode ::utils;
13- using namespace matjson ;
1412using namespace horrible ;
1513
1614class $modify(HorribleMenuLayer, MenuLayer) {
@@ -25,9 +23,6 @@ class $modify(HorribleMenuLayer, MenuLayer) {
2523
2624 log::debug (" Store Current FPS: {}" , storedFPS);
2725
28- auto rnd = rand () % 101 ;
29- log::debug (" chance {}" , rnd);
30-
3126 if (auto bottomMenu = getChildByID (" bottom-menu" )) {
3227 auto btnSprite = CircleButtonSprite::createWithSpriteFrameName (
3328 " GJ_moonsIcon_001.png" ,
@@ -49,88 +44,6 @@ class $modify(HorribleMenuLayer, MenuLayer) {
4944 };
5045 };
5146
52- // Show a LazySprite for the first PNG found in the save directory
53- if (horribleMod && horribleMod->getSavedValue <bool >(" mock" , false )) {
54- log::debug (" mock feature enabled in MainMenu layer" );
55-
56- namespace fs = std::filesystem;
57-
58- if (rnd <= static_cast <int >(horribleMod->getSettingValue <int64_t >(" mock-chance" ))) {
59- auto mockConfigPath = fmt::format (" {}\\ mock.json" , horribleMod->getSaveDir ());
60- auto mockConfig = file::readJson (fs::path (mockConfigPath));
61-
62- log::debug (" Reading path {}..." , mockConfigPath);
63-
64- if (mockConfig.isOk ()) {
65- log::debug (" Read mocking config file" );
66-
67- auto mockConfigUnwr = mockConfig.unwrapOr (Value ());
68-
69- auto lvlUnwr = mockConfigUnwr.begin ();
70- std::advance (lvlUnwr, rnd % mockConfigUnwr.size ());
71-
72- auto id = lvlUnwr->getKey ().value_or (" " );
73- auto percent = lvlUnwr->asInt ().unwrapOr (99 );
74-
75- if (!id.empty ()) {
76- log::debug (" ID {} with percentage {} is valid" , id, percent);
77-
78- std::string pngPath = fmt::format (" {}\\ {}.png" , horribleMod->getSaveDir (), id);
79-
80- log::info (" Displaying {}" , pngPath);
81-
82- auto ss = LazySprite::create ({ 192 .f , 108 .f });
83- ss->setID (" mock" _spr);
84- ss->setScale (0.25 );
85- ss->setAnchorPoint ({ 0.5 , 0.5 });
86- ss->setPosition ({ -192 .f , getScaledContentHeight () / 2 .f });
87- ss->setZOrder (1000 );
88-
89- ss->setLoadCallback ([this , ss, percent, rnd](Result<> res) {
90- if (res.isOk ()) {
91- log::info (" Sprite loaded successfully from save dir PNG" );
92-
93- auto percLabelText = fmt::format (" {}%" , percent);
94-
95- auto percLabel = CCLabelBMFont::create (percLabelText.c_str (), " bigFont.fnt" );
96- percLabel->setID (" percentage" );
97- percLabel->setPosition ({ ss->getScaledContentWidth () / 2 .f , ss->getScaledContentHeight () / 2 .f });
98- percLabel->setAlignment (CCTextAlignment::kCCTextAlignmentLeft );
99- percLabel->ignoreAnchorPointForPosition (false );
100- percLabel->setAnchorPoint ({ 0 , 0 });
101- percLabel->setScale (2.5 );
102-
103- ss->addChild (percLabel);
104-
105- float yA = static_cast <float >(rnd) / 100 .f ;
106- float yB = static_cast <float >(rnd) / 100 .f ;
107-
108- ss->setPositionY (getScaledContentHeight () * yA);
109- ss->setRotation (360 .f * (yA * yB));
110-
111- auto move = CCEaseIn::create (CCMoveTo::create (10 .f , { getScaledContentWidth () + 192 .f , getScaledContentHeight () * yB }), 1 .f );
112- auto rotate = CCEaseOut::create (CCRotateBy::create (12 .5f , 45 .f ), 1 .f );
113-
114- auto action = CCSpawn::createWithTwoActions (move, rotate);
115- ss->runAction (action);
116-
117- log::info (" Animated sprite successfully" );
118- } else {
119- log::error (" Sprite failed to load: {}" , res.unwrapErr ());
120- ss->removeMeAndCleanup ();
121- }; });
122-
123- ss->loadFromFile (fs::path (pngPath));
124- addChild (ss);
125- } else {
126- log::error (" ID is invalid" );
127- };
128- } else {
129- log::error (" Mocking data file not found" );
130- };
131- };
132- };
133-
13447 return true ;
13548 };
13649
0 commit comments