Skip to content

Commit ef011ee

Browse files
committed
add random gamemodes
1 parent dfe49ce commit ef011ee

4 files changed

Lines changed: 111 additions & 31 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#include <Utils.h>
2+
3+
#include <Geode/Geode.hpp>
4+
5+
#include <Geode/modify/PlayerObject.hpp>
6+
7+
using namespace geode::prelude;
8+
using namespace horrible::prelude;
9+
10+
static constexpr auto id = "random_gamemode";
11+
12+
static auto const o = Option::create(id)
13+
.setName("Game Mode Randomizer")
14+
.setDescription("Switch to a different game mode every time you enter a portal.\n<co>Might cause funny behavior to happen elsewhere.</c>\n<cl>Credit: Cheeseworks</c>")
15+
.setCategory(category::randoms)
16+
.setSillyTier(SillyTier::Medium);
17+
HORRIBLE_REGISTER_OPTION(o);
18+
19+
static constexpr auto s_modes = std::to_array<GameObjectType>({
20+
GameObjectType::CubePortal,
21+
GameObjectType::ShipPortal,
22+
GameObjectType::BallPortal,
23+
GameObjectType::UfoPortal,
24+
GameObjectType::WavePortal,
25+
GameObjectType::RobotPortal,
26+
GameObjectType::SpiderPortal,
27+
GameObjectType::SwingPortal,
28+
});
29+
30+
#define HORRIBLE_RANDOMGAMEMODE() \
31+
auto type = s_modes[randng::get(s_modes.size() - 1)]; \
32+
\
33+
switch (type) { \
34+
default: [[fallthrough]]; \
35+
\
36+
case GameObjectType::CubePortal: return PlayerObject::toggleRollMode(enable, noEffects); \
37+
case GameObjectType::ShipPortal: return PlayerObject::toggleFlyMode(enable, noEffects); \
38+
case GameObjectType::BallPortal: return PlayerObject::toggleRollMode(enable, noEffects); \
39+
case GameObjectType::UfoPortal: return PlayerObject::toggleBirdMode(enable, noEffects); \
40+
case GameObjectType::WavePortal: return PlayerObject::toggleDartMode(enable, noEffects); \
41+
case GameObjectType::RobotPortal: return PlayerObject::toggleRobotMode(enable, noEffects); \
42+
case GameObjectType::SpiderPortal: return PlayerObject::toggleSpiderMode(enable, noEffects); \
43+
case GameObjectType::SwingPortal: return PlayerObject::toggleSwingMode(enable, noEffects); \
44+
}
45+
46+
class $modify(RandomGamemodePlayerObject, PlayerObject) {
47+
HORRIBLE_DELEGATE_HOOKS(id);
48+
49+
void toggleRollMode(bool enable, bool noEffects) {
50+
HORRIBLE_RANDOMGAMEMODE();
51+
};
52+
53+
void toggleFlyMode(bool enable, bool noEffects) {
54+
HORRIBLE_RANDOMGAMEMODE();
55+
};
56+
57+
void toggleBirdMode(bool enable, bool noEffects) {
58+
HORRIBLE_RANDOMGAMEMODE();
59+
};
60+
61+
void toggleDartMode(bool enable, bool noEffects) {
62+
HORRIBLE_RANDOMGAMEMODE();
63+
};
64+
65+
void toggleRobotMode(bool enable, bool noEffects) {
66+
HORRIBLE_RANDOMGAMEMODE();
67+
};
68+
69+
void toggleSpiderMode(bool enable, bool noEffects) {
70+
HORRIBLE_RANDOMGAMEMODE();
71+
};
72+
73+
void toggleSwingMode(bool enable, bool noEffects) {
74+
HORRIBLE_RANDOMGAMEMODE();
75+
};
76+
};

src/include/Horrible.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ void horrible::delegateHooks(ZStringView id, utils::StringMap<std::shared_ptr<Ho
192192
for (auto const& hook : hooks | std::views::values) {
193193
hook->setAutoEnable(value);
194194
log::trace("Set default state of '{}' hook for option {} to {}", hook->getDisplayName(), id, value ? "ON" : "OFF");
195+
hook->setPriority(geode::Priority::FirstPre);
195196
allHooks.push_back(hook);
196197
};
197198

src/menu/src/OptionItem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ bool OptionItem::init(CCSize const& size, Option option, bool devMode) {
166166
[this](Button*) {
167167
m_impl->notifyIncompat();
168168

169-
auto formatDesc = fmt::format("{}\n\n{}", m_impl->option.getDescription(), m_impl->getTierDescString(m_impl->option.getSillyTier(), m_impl->compatible));
169+
auto formatDesc = fmt::format("{}\n\n{}", (m_impl->option.getDescription().size() > 0) ? m_impl->option.getDescription() : "<cc>No description provided.</c>", m_impl->getTierDescString(m_impl->option.getSillyTier(), m_impl->compatible));
170170

171171
if (auto popup = FLAlertLayer::create(
172172
this,

src/menu/src/OptionMenu.cpp

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ class OptionMenu::Impl final {
8484
};
8585
};
8686

87+
log::trace("Finished sorting {} options", list.size());
88+
8789
optionList->m_contentLayer->updateLayout();
8890
optionList->scrollToTop();
8991
} else {
@@ -278,6 +280,7 @@ bool OptionMenu::init() {
278280

279281
// get all the options data
280282
m_impl->filterOptions(options::getAll());
283+
log::debug("Processed {} options", options::getAll().size());
281284

282285
auto settingsBtn = Button::createWithNode(
283286
CircleButtonSprite::createWithSpriteFrameName(
@@ -293,7 +296,6 @@ bool OptionMenu::init() {
293296
m_mainLayer->addChild(settingsBtn);
294297

295298
auto resetFiltersBtnSpr = CircleButtonSprite::createWithSpriteFrameName(
296-
// @geode-ignore(unknown-resource)
297299
"geode.loader/reload.png",
298300
1.f,
299301
btns,
@@ -334,35 +336,36 @@ bool OptionMenu::init() {
334336
socialContainer->setContentWidth(0.f);
335337
socialContainer->setLayout(socialContainerLayout);
336338

337-
auto socialBtns = std::to_array<SocialBtnData>({{"gj_ytIcon_001.png",
338-
"horrible-mods-series-btn",
339-
[](auto) {
340-
createQuickPopup(
341-
"Horrible Mods",
342-
"Watch the series '<cr>Horrible Mods</c>' on <cl>Avalanche</c>'s YouTube channel?",
343-
"Cancel",
344-
"OK",
345-
[](bool, bool ok) {
346-
if (ok) web::openLinkInBrowser("https://www.youtube.com/watch?v=Ssl49pNmW_0&list=PL0dsSu2pR5cERnq7gojZTKVRvUwWo2Ohu");
347-
});
348-
}},
349-
{"gj_discordIcon_001.png",
350-
"discord-btn",
351-
[](auto) {
352-
createQuickPopup(
353-
"Discord",
354-
"Join the <cj>Cubic Studios</c> official community Discord server?",
355-
"Cancel",
356-
"OK",
357-
[](bool, bool ok) {
358-
if (ok) web::openLinkInBrowser("https://www.dsc.gg/cubic");
359-
});
360-
}},
361-
{"geode.loader/gift.png",
362-
"support-btn",
363-
[](auto) {
364-
openSupportPopup(thisMod);
365-
}}});
339+
auto socialBtns = std::to_array<SocialBtnData>(
340+
{{"gj_ytIcon_001.png",
341+
"horrible-mods-series-btn",
342+
[](auto) {
343+
createQuickPopup(
344+
"Horrible Mods",
345+
"Watch the series '<cr>Horrible Mods</c>' on <cl>Avalanche</c>'s YouTube channel?",
346+
"Cancel",
347+
"OK",
348+
[](bool, bool ok) {
349+
if (ok) web::openLinkInBrowser("https://www.youtube.com/watch?v=Ssl49pNmW_0&list=PL0dsSu2pR5cERnq7gojZTKVRvUwWo2Ohu");
350+
});
351+
}},
352+
{"gj_discordIcon_001.png",
353+
"discord-btn",
354+
[](auto) {
355+
createQuickPopup(
356+
"Discord",
357+
"Join the <cj>Cubic Studios</c> official community Discord server?",
358+
"Cancel",
359+
"OK",
360+
[](bool, bool ok) {
361+
if (ok) web::openLinkInBrowser("https://www.dsc.gg/cubic");
362+
});
363+
}},
364+
{"geode.loader/gift.png",
365+
"support-btn",
366+
[](auto) {
367+
openSupportPopup(thisMod);
368+
}}});
366369

367370
for (auto& socialBtn : socialBtns) {
368371
if (auto btn = Button::createWithSpriteFrameName(

0 commit comments

Comments
 (0)