Skip to content

Commit 7886c9e

Browse files
committed
lots of tweaks
1 parent 6eac886 commit 7886c9e

8 files changed

Lines changed: 86 additions & 225 deletions

File tree

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ First off, thank you for considering contributing! We simply ask that you follow
44
## Pull Requests
55
You're free to fork our repository and [open a pull request](../../pulls/) if you'd like to submit a new feature or propose a fix for an unknown issue.
66

7-
Before opening or marking your pull request as ready for review, please be sure to test your build and make sure it is stable and not conflicting with the upstream repository. Try not to diverge from our current code styling and practices in your fork.
7+
Before opening or marking your pull request as ready for review, please be sure to test your build and make sure it is stable and not conflicting with the upstream repository. Try not to diverge from our current code styling and practices in your branch.
88

99
### Practices
10-
The things you should always do and not do when opening a new pull request.
11-
- **Be clear!** Explain the important details of your changes, if not already obvious.
10+
The things you should always do and not do when opening a new pull request for this project.
11+
- **Be clear!** Explain the important details of and motives behind your changes, if not already obvious.
1212
- **Don't change versioning metadata.** Our maintainers will do that once it's been decided a new update should release soon.
13-
- **Don't write changelogs.** Maintainers will check back on changes and document everything!
14-
- **Isolate your changes.** Refrain from formatting or changing code outside of what you're actually working on to prevent conflicts.
15-
- **Get ready for feedback!** Sometimes not everything done does not meet the standard or is just questionable.
13+
- **Don't write changelogs.** Maintainers will check back on past changes and document everything!
14+
- **Isolate your changes.** Refrain from formatting or changing code outside of what you're actually working on in order to prevent conflicts.
15+
- **Get ready for feedback!** Sometimes not everything done meets the current standard or is just questionable.
1616

1717
### Guidelines
1818
This section mainly covers contributions for new features to Horrible Menu. For other pull requests, we simply ask that you justify your changes in detail when opening your request.

changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# v1.1.0
2-
- probably a feature update
2+
- Raise minimum Geode version support to `v5.4.0`
3+
- Added Automatic safe mode setting ([#6](https://github.com/CubicCommunity/HorribleMenu/pull/6))
4+
- Added cheat marker to several options ([#6](https://github.com/CubicCommunity/HorribleMenu/pull/6))
5+
- Added information label to Safe Mode section in mod settings
6+
- Fix touch issues with category list and dropdown in options menu
7+
- Silliness filter dropdown in options menu now resets when clearing filters
8+
- Reworked *Horrible Options Menu* button section in mod settings
39

410
# v1.0.3
511
- Added additional info button to *Safe Mode* label in options menu

mod.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "5.0.0",
2+
"geode": "5.4.0",
33
"gd": {
44
"win": "2.2081",
55
"android": "2.2081",
@@ -47,9 +47,13 @@
4747
}
4848
},
4949
"settings": {
50-
"button": {
51-
"type": "custom:menu",
52-
"name": " "
50+
"btn-popup": {
51+
"type": "button",
52+
"name": "Menu Button",
53+
"buttons": {
54+
"menu": "Horrible Options Menu"
55+
},
56+
"description": "Open the <cg>Horrible Options</c> menu."
5357
},
5458
"key-popup": {
5559
"type": "keybind",
@@ -65,6 +69,11 @@
6569
"name": "Safe Mode",
6670
"description": "Settings for Safe Mode."
6771
},
72+
"safe-mode-info": {
73+
"type": "info",
74+
"description": "Safe Mode prevents you from accidentally saving progress in levels while using this mod's features.",
75+
"color": "#00FF00"
76+
},
6877
"safe-mode": {
6978
"type": "bool",
7079
"name": "Enable",

src/main.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <ui/Menu.h>
66
#include <ui/MenuButton.h>
7-
#include <ui/SettingV3.h>
87

98
#include <Geode/modify/PlayLayer.hpp>
109
#include <Geode/modify/PauseLayer.hpp>
@@ -42,8 +41,6 @@ static void toggleSafeModeHooks(bool value) {
4241
};
4342

4443
$on_game(Loaded) {
45-
(void)mod->registerCustomSettingType("menu", &HorribleSettingV3::parse);
46-
4744
if (auto om = OverlayManager::get()) {
4845
if (auto fb = MenuButton::get()) om->addChild(fb);
4946
};
@@ -117,6 +114,12 @@ static void toggleSafeModeHooks(bool value) {
117114
log::trace("Global options listener detected {} being {}, {}, {}", id, data.enabled ? "enabled" : "disabled", data.pin ? "pinned" : "unpinned", data.viewed ? "viewed" : "not viewed yet");
118115
});
119116

117+
ButtonSettingPressedEventV3(mod, "btn-popup")
118+
.listen([](std::string_view buttonKey) {
119+
if (buttonKey == "menu") menu::open();
120+
})
121+
.leak();
122+
120123
OptionCheatingEvent()
121124
.listen([](bool cheating) {
122125
if (mod->getSettingValue<bool>(setting::DynamicSafeMode)) {

src/ui/Menu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace horrible {
2828

2929
void setupSafeModeNode(bool safeMode);
3030
void setupImageBackground(fs::path const& path);
31+
void setupSillyFilterDropdown(cocos2d::CCPoint const& pos);
3132

3233
protected:
3334
Menu();

src/ui/SettingV3.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/ui/src/Menu.cpp

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ class Menu::Impl final {
4343
std::string const theme = mod->getSettingValue<std::string>("theme");
4444

4545
CCNode* safeModeContainer = nullptr;
46+
4647
LazySprite* themeBackground = nullptr;
4748
CCClippingNode* themeBgContainer = nullptr;
4849

50+
cue::DropdownNode* sillyFilterDropdown = nullptr;
51+
4952
std::vector<WeakRef<MenuCategoryFilterCell>> categoryItems;
5053

5154
void filterOptions(std::vector<std::weak_ptr<Option>>&& optList, SillyTier tier = SillyTier::None, ZStringView category = "") {
@@ -200,6 +203,48 @@ void Menu::setupImageBackground(fs::path const& path) {
200203
};
201204
};
202205

206+
void Menu::setupSillyFilterDropdown(CCPoint const& pos) {
207+
cue::resetNode(m_impl->sillyFilterDropdown);
208+
209+
m_impl->sillyFilterDropdown = cue::DropdownNode::create(
210+
to4B(colors::black, 0),
211+
m_impl->categoryList->getScaledContentWidth(),
212+
17.5f,
213+
43.75f);
214+
m_impl->sillyFilterDropdown->setID("silly-filter-dropdown");
215+
m_impl->sillyFilterDropdown->setAnchorPoint({0.5, 1});
216+
m_impl->sillyFilterDropdown->setPosition(pos);
217+
218+
m_impl->sillyFilterDropdown->setCallback([this](auto, CCNode* node) {
219+
if (auto cell = typeinfo_cast<MenuSillyFilterCell*>(node)) {
220+
if (m_impl->selectedTier != cell->getSillyTier()) m_impl->filterOptions(options::getAll(), cell->getSillyTier(), m_impl->selectedCategory);
221+
m_impl->selectedTier = cell->getSillyTier();
222+
};
223+
});
224+
225+
constexpr TierFilterBtnData filterBtns[] = {
226+
{SillyTier::None, "Any", "filter-none-btn", colors::white},
227+
{SillyTier::Low, "Low", "filter-low-btn", colors::green},
228+
{SillyTier::Medium, "Medium", "filter-medium-btn", colors::yellow},
229+
{SillyTier::High, "High", "filter-high-btn", colors::red},
230+
};
231+
232+
for (auto const& fBtn : filterBtns) {
233+
if (auto cell = MenuSillyFilterCell::create(
234+
{m_impl->sillyFilterDropdown->getScaledContentWidth(), 16.5f},
235+
fBtn.tier,
236+
fBtn.id,
237+
fBtn.label,
238+
fBtn.color)) {
239+
m_impl->sillyFilterDropdown->addCell(cell);
240+
} else {
241+
log::error("Failed to create filter button");
242+
};
243+
};
244+
245+
m_mainLayer->addChild(m_impl->sillyFilterDropdown, 9);
246+
};
247+
203248
bool Menu::init() {
204249
auto btns = themes::getCircleBaseColor(m_impl->theme);
205250

@@ -289,8 +334,6 @@ bool Menu::init() {
289334
m_impl->categoryList->m_contentLayer->updateLayout();
290335
m_impl->categoryList->scrollToTop();
291336

292-
m_mainLayer->addChild(m_impl->categoryList, 9);
293-
294337
auto categoryListBg = cue::createBackground(
295338
{m_impl->categoryList->getScaledContentWidth() + 7.5f, m_impl->categoryList->getScaledContentHeight() + 7.5f},
296339
{
@@ -367,45 +410,13 @@ bool Menu::init() {
367410

368411
m_mainLayer->addChild(filterContainerLabel);
369412

370-
auto sillyDropdown = cue::DropdownNode::create(
371-
to4B(colors::black, 0),
372-
m_impl->categoryList->getScaledContentWidth(),
373-
17.5f,
374-
43.75f);
375-
sillyDropdown->setID("silly-filter-dropdown");
376-
sillyDropdown->setAnchorPoint({0.5, 1});
377-
sillyDropdown->setPosition({filterContainerLabel->getPositionX(), 88.75f});
378-
379-
sillyDropdown->setCallback([this](auto, CCNode* node) {
380-
if (auto cell = typeinfo_cast<MenuSillyFilterCell*>(node)) {
381-
if (m_impl->selectedTier != cell->getSillyTier()) m_impl->filterOptions(options::getAll(), cell->getSillyTier(), m_impl->selectedCategory);
382-
m_impl->selectedTier = cell->getSillyTier();
383-
};
384-
});
385-
386-
constexpr TierFilterBtnData filterBtns[] = {
387-
{SillyTier::None, "Any", "filter-none-btn", colors::white},
388-
{SillyTier::Low, "Low", "filter-low-btn", colors::green},
389-
{SillyTier::Medium, "Medium", "filter-medium-btn", colors::yellow},
390-
{SillyTier::High, "High", "filter-high-btn", colors::red},
391-
};
392-
393-
for (auto const& fBtn : filterBtns) {
394-
if (auto cell = MenuSillyFilterCell::create(
395-
{sillyDropdown->getScaledContentWidth(), 16.5f},
396-
fBtn.tier,
397-
fBtn.id,
398-
fBtn.label,
399-
fBtn.color)) {
400-
sillyDropdown->addCell(cell);
401-
} else {
402-
log::error("Failed to create filter button");
403-
};
404-
};
413+
CCPoint const dropdownPos = {filterContainerLabel->getPositionX(), 88.75f};
414+
setupSillyFilterDropdown(dropdownPos);
405415

406-
m_mainLayer->addChild(sillyDropdown, 9);
416+
// adding now to fix touch issue with cue dropdown
417+
m_mainLayer->addChild(m_impl->categoryList, 9);
407418

408-
m_mainLayer->addChild(m_impl->createFilterLabel("Silliness", "silly-filter-label", {m_impl->categoryList->getPositionX(), sillyDropdown->getPositionY() + 8.75f}), 1);
419+
m_mainLayer->addChild(m_impl->createFilterLabel("Silliness", "silly-filter-label", {m_impl->categoryList->getPositionX(), m_impl->sillyFilterDropdown->getPositionY() + 8.75f}), 1);
409420

410421
auto filterHint = SimpleTextArea::create(
411422
"Use different filters to search for certain options faster. Press the pin icon on an option cell to pin it to the top of the list.",
@@ -444,13 +455,13 @@ bool Menu::init() {
444455

445456
auto resetFiltersBtn = Button::createWithNode(
446457
resetFiltersBtnSpr,
447-
[this](auto) {
458+
[this, dropdownPos](auto) {
448459
createQuickPopup(
449460
"Reset Filters",
450461
"Would you like to <cr>reset all search filters</c>?\n<cy>This will not clear your pins.</c>",
451462
"Cancel",
452463
"OK",
453-
[this](auto, bool ok) {
464+
[this, &dropdownPos](auto, bool ok) {
454465
if (ok) {
455466
m_impl->selectedTier = SillyTier::None;
456467
m_impl->selectedCategory = "";
@@ -460,6 +471,7 @@ bool Menu::init() {
460471
};
461472

462473
m_impl->filterOptions(options::getAll(), m_impl->selectedTier, m_impl->selectedCategory);
474+
setupSillyFilterDropdown(dropdownPos);
463475
};
464476
});
465477
});

0 commit comments

Comments
 (0)