Skip to content

Commit 76fe059

Browse files
added safe mode
1 parent 4ca6b0d commit 76fe059

4 files changed

Lines changed: 181 additions & 125 deletions

File tree

mod.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
"version": "v1.0.0",
1212
"developer": "ArcticWoof",
1313
"description": "Horrible Geode Mod Ideas",
14+
"settings": {
15+
"safe_mode": {
16+
"type": "bool",
17+
"name": "Safe Mode",
18+
"description": "Prevent any progression made in the level. <cr>Highly recommended that this is kept enabled!</cr>",
19+
"default": true
20+
}
21+
},
1422
"tags": [
1523
"joke",
1624
"offline",

src/modified/GJGameLevel.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <Geode/Geode.hpp>
2+
3+
#include <Geode/utils/terminate.hpp>
4+
5+
#include <Geode/modify/GJGameLevel.hpp>
6+
7+
using namespace geode::prelude;
8+
9+
class $modify(HorribleGJGameLevel, GJGameLevel)
10+
{
11+
void savePercentage(int percent, bool isPracticeMode, int clicks, int attempts, bool isChkValid)
12+
{
13+
14+
auto safeMode = Mod::get()->getSettingValue<bool>("safe_mode");
15+
16+
if (!safeMode)
17+
{
18+
GJGameLevel::savePercentage(percent, isPracticeMode, clicks, attempts, isChkValid);
19+
return;
20+
}
21+
else
22+
{
23+
log::info("Safe mode is enabled. dont save");
24+
}
25+
}
26+
};

src/popups/HorribleMenuPopup.cpp

Lines changed: 146 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -4,139 +4,110 @@
44
#include "toggle/ModOption.hpp"
55

66
#include <Geode/Geode.hpp>
7+
#include <Geode/ui/GeodeUI.hpp>
78

89
using namespace geode::prelude;
910

1011
// add yo mods here :D
11-
std::vector<std::tuple<std::string, std::string, std::string, SillyTier, bool>> HorribleMenuPopup::getAllOptions() {
12+
std::vector<std::tuple<std::string, std::string, std::string, SillyTier, bool>> HorribleMenuPopup::getAllOptions()
13+
{
1214
// for simple minded: [modID, modName, modDescription, sillyTier, restartRequired]
1315
return {
14-
{
15-
"oxygen",
16-
"Oxygen Level",
17-
"Add an oxygen level. You gain oxygen whenever you are a flying gamemode.\n<cy>Credit: ArcticWoof</c>",
18-
SillyTier::High,
19-
false
20-
},
21-
{
22-
"grief",
23-
"Get Back on Grief",
24-
"A 10% chance of forcing you to play Grief.\n<cy>Credit: Sweep</c>",
25-
SillyTier::High,
26-
false
27-
},
28-
{
29-
"congregation",
30-
"Congregation Jumpscare",
31-
"A 10% chance of forcing you to play the Congregation Jumpscare.\n<cy>Credit: StaticGD</c>",
32-
SillyTier::High,
33-
false
34-
},
35-
{
36-
"mock",
37-
"Mock your 90%+ Fail",
38-
"Shows a screenshot of your 90%-99% fail everywhere.\n<cy>Credit: Wuffin</c>\n<cr>Note: This will not work on macOS and iOS</c>",
39-
SillyTier::Medium,
40-
false
41-
},
42-
{
43-
"freeze",
44-
"Random 90%+ FPS Drop",
45-
"Your game FPS starts dropping between 90-99% while playing.\n<cy>Credit: Hexfire</c>",
46-
SillyTier::Medium,
47-
false
48-
},
49-
{
50-
"achieve",
51-
"Random Achievements",
52-
"Play the achievement sound when doing random things.\n<cy>Credit: Cheeseworks</c>",
53-
SillyTier::Low,
54-
false
55-
},
56-
{
57-
"crash-death",
58-
"Crash Chance on Death",
59-
"When your character dies in a level, there's a small chance your game will die too.\n<cy>Credit: DragonixGD</c>",
60-
SillyTier::High,
61-
false
62-
},
63-
{
64-
"math-quiz",
65-
"Richard's Math Quiz!",
66-
"When dying in a level, there's a chance Richard will pop out and give you a quick math quiz.\n<cy>Credit: CyanBoi</c>",
67-
SillyTier::High,
68-
false
69-
},
70-
{
71-
"no-jump",
72-
"Randomly Don't Jump",
73-
"When making an input in a level, there will be a chance your character does not jump.\n<cy>Credit: GilanyKing12</c>\n<cr>Note: This will not work in platformer mode</c>",
74-
SillyTier::Low,
75-
false
76-
},
77-
{
78-
"gravity",
79-
"Randomize Gravity",
80-
"Every time you jump in the level, the gravity will change to a random value.\n<cy>Credit: NJAgain</c>\n<cr>Note: This will not work in platformer mode</c>",
81-
SillyTier::Low,
82-
false
83-
},
84-
{
85-
"death",
86-
"Fake Death",
87-
"The player's death effect will play but will not die.\n<cy>Credit: DragonixGD</c>",
88-
SillyTier::Medium,
89-
false
90-
},
91-
{
92-
"upside-down",
93-
"Upside-Down Chance",
94-
"When playing a level, there's a 50/50 chance it'll be upside-down and probably break everything.\n<cy>Credit: Cheeseworks</c>",
95-
SillyTier::Medium,
96-
false
97-
},
98-
{
99-
"ads",
100-
"Level Ads",
101-
"While playing a level, an ad for a random will pop up on the screen from time to time.\n<cy>Credit: staticGD</c>",
102-
SillyTier::Medium,
103-
false
104-
},
105-
{
106-
"black-screen",
107-
"Black Screen Blink",
108-
"The screen can suddenly turn black for a moment while playing a level.\n<cy>Credit: elite_smiler_ispro</c>",
109-
SillyTier::Low,
110-
false
111-
},
112-
{
113-
"parry",
114-
"Parry Obstacles",
115-
"Whenever your hitbox is inside of an obstacle hitbox, if you time your click right, you don't die.\n<cy>Credit: Wuffin</c>",
116-
SillyTier::Low,
117-
false
118-
},
119-
{
120-
"health",
121-
"Player Health",
122-
"Add a health bar and decreases everytime you taken damage. When your health reaches zero, you die.\n<cy>Credit: Cheeseworks</c>",
123-
SillyTier::Low,
124-
false
125-
},
16+
{"oxygen",
17+
"Oxygen Level",
18+
"Add an oxygen level. You gain oxygen whenever you are a flying gamemode.\n<cy>Credit: ArcticWoof</c>",
19+
SillyTier::High,
20+
false},
21+
{"grief",
22+
"Get Back on Grief",
23+
"A 10% chance of forcing you to play Grief.\n<cy>Credit: Sweep</c>",
24+
SillyTier::High,
25+
false},
26+
{"congregation",
27+
"Congregation Jumpscare",
28+
"A 10% chance of forcing you to play the Congregation Jumpscare.\n<cy>Credit: StaticGD</c>",
29+
SillyTier::High,
30+
false},
31+
{"mock",
32+
"Mock your 90%+ Fail",
33+
"Shows a screenshot of your 90%-99% fail everywhere.\n<cy>Credit: Wuffin</c>\n<cr>Note: This will not work on macOS and iOS</c>",
34+
SillyTier::Medium,
35+
false},
36+
{"freeze",
37+
"Random 90%+ FPS Drop",
38+
"Your game FPS starts dropping between 90-99% while playing.\n<cy>Credit: Hexfire</c>",
39+
SillyTier::Medium,
40+
false},
41+
{"achieve",
42+
"Random Achievements",
43+
"Play the achievement sound when doing random things.\n<cy>Credit: Cheeseworks</c>",
44+
SillyTier::Low,
45+
false},
46+
{"crash-death",
47+
"Crash Chance on Death",
48+
"When you die in the level, there's a small chance your game will die too. Don't worry your progress is saved when crashed :)\n<cy>Credit: DragonixGD</c>",
49+
SillyTier::High,
50+
false},
51+
{"math-quiz",
52+
"Richard's Math Quiz!",
53+
"When dying in a level, there's a chance Richard will pop out and give you a quick math quiz.\n<cy>Credit: CyanBoi</c>",
54+
SillyTier::High,
55+
false},
56+
{"no-jump",
57+
"Randomly Don't Jump",
58+
"When making an input in a level, there will be a chance your character does not jump.\n<cy>Credit: GilanyKing12</c>\n<cr>Note: This will not work in platformer mode</c>",
59+
SillyTier::Low,
60+
false},
61+
{"gravity",
62+
"Randomize Gravity",
63+
"Every time you jump in the level, the gravity will change to a random value.\n<cy>Credit: NJAgain</c>\n<cr>Note: This will not work in platformer mode</c>",
64+
SillyTier::Low,
65+
false},
66+
{"death",
67+
"Fake Death",
68+
"The player's death effect will play but will not die.\n<cy>Credit: DragonixGD</c>",
69+
SillyTier::Medium,
70+
false},
71+
{"upside-down",
72+
"Upside-Down Chance",
73+
"When playing a level, there's a 50/50 chance it'll be upside-down and probably break everything.\n<cy>Credit: Cheeseworks</c>",
74+
SillyTier::Medium,
75+
false},
76+
{"ads",
77+
"Level Ads",
78+
"While playing a level, an ad for a random will pop up on the screen from time to time.\n<cy>Credit: staticGD</c>",
79+
SillyTier::Medium,
80+
false},
81+
{"black-screen",
82+
"Black Screen Blink",
83+
"The screen can suddenly turn black for a moment while playing a level.\n<cy>Credit: elite_smiler_ispro</c>",
84+
SillyTier::Low,
85+
false},
86+
{"parry",
87+
"Parry Obstacles",
88+
"Whenever your hitbox is inside of an obstacle hitbox, if you time your click right, you don't die.\n<cy>Credit: Wuffin</c>",
89+
SillyTier::Low,
90+
false},
91+
{"health",
92+
"Player Health",
93+
"Add a health bar and decreases everytime you taken damage. When your health reaches zero, you die.\n<cy>Credit: Cheeseworks</c>",
94+
SillyTier::Low,
95+
false},
12696
};
12797
};
12898

129-
bool HorribleMenuPopup::setup() {
99+
bool HorribleMenuPopup::setup()
100+
{
130101
setID("options"_spr);
131102
setTitle("Horrible Options");
132103

133104
auto mainLayerSize = m_mainLayer->getContentSize();
134105

135106
// Add a background sprite to the popup
136107
auto optionScrollBg = CCScale9Sprite::create("square02_001.png");
137-
optionScrollBg->setAnchorPoint({ 0.5, 0.5 });
138-
optionScrollBg->setPosition({ mainLayerSize.width / 2.f, mainLayerSize.height / 2.f - 10.f });
139-
optionScrollBg->setContentSize({ mainLayerSize.width - 25.f, mainLayerSize.height - 45.f });
108+
optionScrollBg->setAnchorPoint({0.5, 0.5});
109+
optionScrollBg->setPosition({mainLayerSize.width / 2.f, mainLayerSize.height / 2.f - 10.f});
110+
optionScrollBg->setContentSize({mainLayerSize.width - 25.f, mainLayerSize.height - 45.f});
140111
optionScrollBg->setOpacity(50);
141112

142113
m_mainLayer->addChild(optionScrollBg);
@@ -148,9 +119,9 @@ bool HorribleMenuPopup::setup() {
148119
columnLayout->setAutoGrowAxis(0.f);
149120

150121
// scroll layer
151-
auto optionsScrollLayer = ScrollLayer::create({ optionScrollBg->getContentSize().width - 10.f, optionScrollBg->getContentSize().height - 10.f });
122+
auto optionsScrollLayer = ScrollLayer::create({optionScrollBg->getContentSize().width - 10.f, optionScrollBg->getContentSize().height - 10.f});
152123
optionsScrollLayer->setID("scrollLayer");
153-
optionsScrollLayer->setAnchorPoint({ 0.5, 0.5 });
124+
optionsScrollLayer->setAnchorPoint({0.5, 0.5});
154125
optionsScrollLayer->ignoreAnchorPointForPosition(false);
155126
optionsScrollLayer->setPosition(optionScrollBg->getPosition());
156127

@@ -160,12 +131,14 @@ bool HorribleMenuPopup::setup() {
160131
auto modOptions = getAllOptions();
161132

162133
// Sort mod options alphabetically by name
163-
std::sort(modOptions.begin(), modOptions.end(), [](const auto& a, const auto& b) { return std::get<4>(a) < std::get<4>(b); });
134+
std::sort(modOptions.begin(), modOptions.end(), [](const auto &a, const auto &b)
135+
{ return std::get<4>(a) < std::get<4>(b); });
164136

165-
for (const auto& option : modOptions) {
166-
const auto& [id, name, desc, silly, restart] = option;
137+
for (const auto &option : modOptions)
138+
{
139+
const auto &[id, name, desc, silly, restart] = option;
167140

168-
if (auto modOption = ModOption::create({ optionsScrollLayer->m_contentLayer->getScaledContentWidth(), 32.f }, id, name, desc, silly, restart))
141+
if (auto modOption = ModOption::create({optionsScrollLayer->m_contentLayer->getScaledContentWidth(), 32.f}, id, name, desc, silly, restart))
169142
optionsScrollLayer->m_contentLayer->addChild(modOption);
170143
};
171144

@@ -174,13 +147,61 @@ bool HorribleMenuPopup::setup() {
174147

175148
m_mainLayer->addChild(optionsScrollLayer);
176149

150+
// add a mod settings at the bottom left
151+
auto modSettingsBtnSprite = CircleButtonSprite::createWithSpriteFrameName(
152+
// @geode-ignore(unknown-resource)
153+
"geode.loader/settings.png",
154+
1.f,
155+
CircleBaseColor::Green,
156+
CircleBaseSize::Medium);
157+
modSettingsBtnSprite->setScale(0.75f);
158+
159+
auto modSettingsBtn = CCMenuItemSpriteExtra::create(
160+
modSettingsBtnSprite,
161+
this,
162+
menu_selector(HorribleMenuPopup::openModSettings));
163+
164+
auto modSettingsMenu = CCMenu::create();
165+
modSettingsMenu->addChild(modSettingsBtn);
166+
modSettingsMenu->setPosition({0.f, 0.f});
167+
m_mainLayer->addChild(modSettingsMenu);
168+
169+
// Add 'Save Mode Active' label to bottom middle
170+
auto safeMode = Mod::get()->getSettingValue<bool>("safe_mode");
171+
if (safeMode)
172+
{
173+
auto saveModeLabel = CCLabelBMFont::create("!! Safe Mode ACTIVE !!", "chatFont.fnt");
174+
saveModeLabel->setColor({ 255, 255, 0 });
175+
saveModeLabel->setAnchorPoint({0.5f, 0.0f});
176+
saveModeLabel->setPosition({m_mainLayer->getContentSize().width / 2.f, 5.f});
177+
saveModeLabel->setScale(0.5f);
178+
m_mainLayer->addChild(saveModeLabel, 100);
179+
}
180+
181+
if (!safeMode)
182+
{
183+
auto saveModeLabel = CCLabelBMFont::create("!! Safe Mode INACTIVE !!", "chatFont.fnt");
184+
saveModeLabel->setColor({ 255, 0, 0 });
185+
saveModeLabel->setAnchorPoint({0.5f, 0.0f});
186+
saveModeLabel->setPosition({m_mainLayer->getContentSize().width / 2.f, 5.f});
187+
saveModeLabel->setScale(0.5f);
188+
m_mainLayer->addChild(saveModeLabel, 100);
189+
}
190+
177191
return true;
178192
};
179193

180-
HorribleMenuPopup* HorribleMenuPopup::create() {
194+
void HorribleMenuPopup::openModSettings(CCObject *sender)
195+
{
196+
openSettingsPopup(geode::getMod());
197+
}
198+
199+
HorribleMenuPopup *HorribleMenuPopup::create()
200+
{
181201
auto ret = new HorribleMenuPopup();
182202

183-
if (ret && ret->initAnchored(300.f, 280.f)) {
203+
if (ret && ret->initAnchored(300.f, 280.f))
204+
{
184205
ret->autorelease();
185206
return ret;
186207
};

src/popups/HorribleMenuPopup.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class HorribleMenuPopup : public Popup<>
1010
{
1111
protected:
1212
bool setup() override;
13+
void openModSettings(CCObject *sender);
1314

1415
public:
1516
static HorribleMenuPopup *create();

0 commit comments

Comments
 (0)