Skip to content

Commit a468ea8

Browse files
committed
refactor ui
1 parent 6ab5cd1 commit a468ea8

16 files changed

Lines changed: 281 additions & 254 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ project(HorribleMenu VERSION 1.0.0)
1313
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.cpp)
1414
add_library(${PROJECT_NAME} SHARED ${SOURCES})
1515

16-
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/include)
16+
target_include_directories(${PROJECT_NAME} PRIVATE include src)
1717

1818
if(PROJECT_IS_TOP_LEVEL)
1919
target_compile_definitions(${PROJECT_NAME} PRIVATE BRKD_HORRIBLE_API_EXPORTING)

src/Utils.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
#include <util/ui/WhackButton.hpp>
1818

1919
#include <cue/Util.hpp>
20+
#include <cue/DropdownNode.hpp>
2021
#include <cue/PlayerIcon.hpp>
2122

23+
#include <asp/fs.hpp>
24+
2225
#include <cocos2d.h>
2326

2427
#include <Geode/ui/Button.hpp>
@@ -60,7 +63,8 @@ namespace horrible {
6063
};
6164
};
6265

63-
namespace str = geode::utils::string; // Shortcut for geode::utils::string
66+
namespace fs = asp::fs; // Shortcut for `asp::fs`
67+
namespace str = geode::utils::string; // Shortcut for `geode::utils::string`
6468

6569
// For convenience
6670
namespace setting {

src/hooks/Mock.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ static auto const o = Option::create(THIS_ID)
1919
->autoRegister();
2020

2121
#if !defined(GEODE_IS_MACOS) && !defined(GEODE_IS_IOS) // not compat with these platforms
22-
// Shortcut for `std::filesystem`
23-
namespace fs = std::filesystem;
24-
2522
class $modify(MockMenuLayer, MenuLayer) {
2623
HORRIBLE_DELEGATE_HOOKS(THIS_ID);
2724

src/hooks/jumpscares/ForceLevels.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class $modify(GriefPlayLayer, PlayLayer) {
4141
HORRIBLE_DELEGATE_HOOKS(THIS_ID_GRIEF);
4242

4343
struct Fields {
44-
int chance = options::getChance(oGrief->getID());
44+
unsigned int chance = options::getChance(oGrief->getID());
4545

4646
bool dontCreateObjects = false;
4747
};
@@ -62,7 +62,7 @@ class $modify(CongregationPlayLayer, PlayLayer) {
6262
HORRIBLE_DELEGATE_HOOKS(THIS_ID_CONGREG);
6363

6464
struct Fields {
65-
int chance = options::getChance(oCongreg->getID());
65+
unsigned int chance = options::getChance(oCongreg->getID());
6666

6767
bool dontCreateObjects = false;
6868
};

src/hooks/obstructive/TOS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class $modify(TOSGJBaseGameLayer, GJBaseGameLayer) {
2020
HORRIBLE_DELEGATE_HOOKS(THIS_ID);
2121

2222
struct Fields {
23-
int chance = options::getChance(THIS_ID);
23+
unsigned int chance = options::getChance(THIS_ID);
2424

2525
Ref<TermsAndConditions> currentTos = nullptr;
2626
};

src/hooks/randoms/FakeCrash.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class $modify(FakeCrashGJBaseGameLayer, GJBaseGameLayer) {
3939
void scheduler(float) {
4040
auto f = m_fields.self();
4141

42-
// log::debug("FakeCrash update tick");
4342
if (!f->inFakeCrash && randng::fast() % f->chance == 0) {
4443
log::debug("Faking crash");
4544
f->lastTimeWarp = LevelTools::getLastTimewarp();

src/ui/Menu.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,12 @@
55
#include <Geode/Geode.hpp>
66

77
namespace horrible {
8-
class MenuNothingNode final : public cocos2d::CCNode {
9-
protected:
10-
bool init(cocos2d::CCSize const& size, cocos2d::CCPoint const& pos);
11-
12-
public:
13-
static MenuNothingNode* create(cocos2d::CCSize const& size, cocos2d::CCPoint const& pos);
14-
};
15-
168
class Menu final : public geode::Popup {
179
struct TierFilterBtnData final {
1810
SillyTier tier;
1911
const char* label;
2012
const char* id;
21-
ccColor3B color;
13+
cocos2d::ccColor3B const& color;
2214
};
2315

2416
struct SocialBtnData final {
@@ -35,7 +27,7 @@ namespace horrible {
3527
static Menu* s_inst;
3628

3729
void setupSafeModeNode(bool safeMode);
38-
void setupImageBackground(std::filesystem::path path);
30+
void setupImageBackground(fs::path const& path);
3931

4032
protected:
4133
Menu();

src/ui/MenuFilterCells.hpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#pragma once
2+
3+
#include <Utils.h>
4+
5+
#include <Geode/Geode.hpp>
6+
7+
namespace horrible {
8+
class MenuCategoryFilterCell final : public cocos2d::CCMenu {
9+
using Callback = geode::Function<void(std::string_view, bool)>;
10+
11+
private:
12+
std::string m_category = ""; // The category name
13+
CCMenuItemToggler* m_toggler = nullptr; // The toggler for the option
14+
Callback m_toggleCallback = nullptr; // Callback for when the category is toggled
15+
16+
protected:
17+
void onToggle(CCObject* sender);
18+
19+
bool init(cocos2d::CCSize const& size, std::string category);
20+
21+
public:
22+
static MenuCategoryFilterCell* create(cocos2d::CCSize const& size, std::string category);
23+
24+
void setToggleCallback(Callback&& callback);
25+
void setToggled(bool on);
26+
27+
geode::ZStringView getCategory() const noexcept;
28+
};
29+
30+
class MenuSillyFilterCell final : public cocos2d::CCNode {
31+
private:
32+
SillyTier m_silly = SillyTier::None;
33+
34+
protected:
35+
bool init(cocos2d::CCSize const& size, SillyTier silly, std::string id, geode::ZStringView label, cocos2d::ccColor3B const& color);
36+
37+
public:
38+
static MenuSillyFilterCell* create(cocos2d::CCSize const& size, SillyTier silly, std::string id, geode::ZStringView label, cocos2d::ccColor3B const& color);
39+
40+
SillyTier getSillyTier() const noexcept;
41+
};
42+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
#include <Geode/Geode.hpp>
66

77
namespace horrible {
8+
class MenuNothingNode final : public cocos2d::CCNode {
9+
protected:
10+
bool init(cocos2d::CCSize const& size, cocos2d::CCPoint const& pos);
11+
12+
public:
13+
static MenuNothingNode* create(cocos2d::CCSize const& size, cocos2d::CCPoint const& pos);
14+
};
15+
816
class MenuOption final : public cocos2d::CCMenu {
917
using Callback = Function<void()>;
1018

src/ui/MenuOptionCategory.h

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

0 commit comments

Comments
 (0)