Skip to content

Commit c01a566

Browse files
committed
better!
1 parent 6f412c9 commit c01a566

File tree

4 files changed

+70
-21
lines changed

4 files changed

+70
-21
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ else()
99
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
1010
endif()
1111

12-
project(NoStupidButtons VERSION 1.1.5)
12+
project(NoStupidButtons VERSION 1.2.1)
1313

1414
add_library(${PROJECT_NAME} SHARED
1515
src/main.cpp

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog for NoStupidButtons
22

3+
## v1.2.1
4+
- Hiding now works by <cg>only setting the buttons invisible and telling the layout to ignore invisible children</c>, instead of <cr>brutally murdering them</c> (and possibly causing problems with other mods)!
5+
- iOS now doesn't remove the more games button if DevTools is enabled too!
6+
37
## v1.2.0
48
- Grayed out buttons in CreatorLayer are now able to be hidden!
59

mod.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"id": "timestepyt.nostupidbuttons",
1313
"name": "NoStupidButtons",
14-
"version": "v1.2.0",
14+
"version": "v1.2.1",
1515
"developer": "TimeStepYT",
1616
"description": "This mod hides the buttons nobody uses!",
1717

@@ -39,6 +39,12 @@
3939
"type": "bool",
4040
"default": true
4141
},
42+
"reposition-robtop-logo": {
43+
"name": "Reposition RobTop logo",
44+
"description": "Repositions the RobTop logo in a way that I (the mod developer) find nicer to look at when hiding the social media buttons.",
45+
"type": "bool",
46+
"default": true
47+
},
4248
"hide-robtop-logo": {
4349
"name": "Hide RobTop Logo",
4450
"description": "Toggles if the RobTop logo should be hidden in the Main Menu",

src/main.cpp

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,84 @@ bool isSettingEnabled(std::string setting) {
99
return Mod::get()->getSettingValue<bool>(setting);
1010
}
1111

12+
void kys(CCNode* victim) {
13+
victim->setVisible(false);
14+
}
15+
16+
void ignoreInvisible(CCNode* menu) {
17+
if (!menu) return;
18+
19+
auto layout = menu->getLayout();
20+
if (!layout) return;
21+
22+
layout->ignoreInvisibleChildren(true);
23+
}
24+
1225
class $modify(MyMenuLayer, MenuLayer) {
13-
bool init() override {
26+
bool init() {
1427
if (!MenuLayer::init()) {
1528
return false;
1629
}
1730

18-
auto const bottomMenu = this->getChildByID("bottom-menu");
19-
auto const socialMediaMenu = this->getChildByID("social-media-menu");
20-
auto const moreGamesMenu = this->getChildByID("more-games-menu");
31+
auto bottomMenu = this->getChildByID("bottom-menu");
32+
auto socialMediaMenu = this->getChildByID("social-media-menu");
33+
auto moreGamesMenu = this->getChildByID("more-games-menu");
34+
35+
ignoreInvisible(bottomMenu);
2136

2237
if (isSettingEnabled("hide-newgrounds-button")) {
23-
bottomMenu->removeChildByID("newgrounds-button");
38+
auto ngBtn = bottomMenu->getChildByID("newgrounds-button");
39+
40+
kys(ngBtn);
41+
2442
bottomMenu->updateLayout();
2543
}
2644

27-
if (isSettingEnabled("hide-social-media-buttons")) {
28-
socialMediaMenu->removeChildByID("facebook-button");
29-
socialMediaMenu->removeChildByID("twitter-button");
30-
socialMediaMenu->removeChildByID("youtube-button");
31-
socialMediaMenu->removeChildByID("twitch-button");
32-
socialMediaMenu->removeChildByID("discord-button");
45+
if (isSettingEnabled("hide-social-media-buttons") && socialMediaMenu) {
46+
auto fbBtn = socialMediaMenu->getChildByID("facebook-button");
47+
auto twitterBtn = socialMediaMenu->getChildByID("twitter-button");
48+
auto ytBtn = socialMediaMenu->getChildByID("youtube-button");
49+
auto twitchBtn = socialMediaMenu->getChildByID("twitch-button");
50+
auto discordBtn = socialMediaMenu->getChildByID("discord-button");
51+
52+
ignoreInvisible(socialMediaMenu);
53+
54+
kys(fbBtn);
55+
kys(twitterBtn);
56+
kys(ytBtn);
57+
kys(twitchBtn);
58+
kys(discordBtn);
59+
3360
socialMediaMenu->updateLayout();
3461
}
35-
62+
3663
if (isSettingEnabled("hide-robtop-logo")) {
37-
socialMediaMenu->removeChildByID("robtop-logo-button");
64+
auto robtopBtn = socialMediaMenu->getChildByID("robtop-logo-button");
65+
66+
ignoreInvisible(socialMediaMenu);
67+
68+
kys(robtopBtn);
69+
3870
socialMediaMenu->updateLayout();
3971
}
40-
else if (isSettingEnabled("hide-social-media-buttons")) {
72+
else if (isSettingEnabled("hide-social-media-buttons") && isSettingEnabled("reposition-robtop-logo")) {
4173
CCNode* const robtopButtonNode = socialMediaMenu->getChildByID("robtop-logo-button");
4274
CCNode* const bottomMenuButton = bottomMenu->getChildByID("settings-button");
4375
robtopButtonNode->setPositionY(bottomMenuButton->getPositionY());
44-
socialMediaMenu->updateLayout();
4576
}
4677

47-
#ifdef GEODE_IS_ANDROID
78+
#ifdef GEODE_IS_MOBILE
4879
if (Loader::get()->isModLoaded("geode.devtools"))
4980
return true;
5081
#endif
82+
5183
if (isSettingEnabled("hide-more-games-button")) {
52-
moreGamesMenu->removeChildByID("more-games-button");
84+
auto moreGamesButton = moreGamesMenu->getChildByID("more-games-button");
85+
86+
ignoreInvisible(moreGamesMenu);
87+
88+
kys(moreGamesButton);
89+
5390
moreGamesMenu->updateLayout();
5491
}
5592

@@ -66,13 +103,15 @@ class $modify(MyCreatorLayer, CreatorLayer) {
66103

67104
if (!creatorButtonsMenu) return true;
68105

106+
ignoreInvisible(creatorButtonsMenu);
107+
69108
auto versusButton = creatorButtonsMenu->getChildByID("versus-button");
70109
auto mapButton = creatorButtonsMenu->getChildByID("map-button");
71110

72111
if (isSettingEnabled("hide-versus-button"))
73-
versusButton->removeMeAndCleanup();
112+
kys(versusButton);
74113
if (isSettingEnabled("hide-map-button"))
75-
mapButton->removeMeAndCleanup();
114+
kys(mapButton);
76115
creatorButtonsMenu->updateLayout();
77116
return true;
78117
}

0 commit comments

Comments
 (0)