Skip to content
Merged

V5 #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:

- name: Publish Nightly release
uses: andelf/nightly-release@main
if: ${{ github.ref_name == github.event.repository.default_branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.21)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "iOS" OR IOS)
set(CMAKE_OSX_ARCHITECTURES "arm64")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This silly lil' mod adds a mod menu filled to the brim with **over 35 crazy trol
When pressing `\` or by pressing the floating *Horrible Options* button on your screen, a menu will pop up with a list of joke mod options you can toggle anytime on your game to do some interesting things to your gaming experience. You can view more information within the menu itself.

> [!NOTE]
> *You can customize any keybinds in this mod via the *[Custom Keybinds](https://www.geode-sdk.org/mods/geode.custom-keybinds)* mod.*
> *You can customize any keybinds in this mod through its settings.*

#### Player Life
Give the player a limited health-like meter that must always stay above 0 to prevent the player from dying.
Expand Down
2 changes: 1 addition & 1 deletion about.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This silly lil' mod adds a mod menu filled to the brim with **over 35 crazy trol
### Options
When <cf>pressing `\` on your keyboard</c> or by <cl>pressing the floating *Horrible Options* button on your screen</c>, a <cg>menu</c> will pop up with <cg>a list of horrible mod options</c> you can <cy>toggle anytime</c> on your game to do some interesting things to your gaming experience. You can view more information within the menu itself.

> ![ℹ️](frame:GJ_infoIcon_001.png?scale=0.5) <cj>*You can customize any keybinds in this mod via the *[Custom Keybinds](mod:geode.custom-keybinds)* mod.*</c>
> ![ℹ️](frame:GJ_infoIcon_001.png?scale=0.5) <cj>*You can customize any keybinds in this mod through its settings.*</c>

#### Player Life
Give the player a limited health-like meter that must always stay above 0 to prevent the player from dying.
Expand Down
39 changes: 2 additions & 37 deletions include/Events.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,12 @@

#include "Horrible.hpp"

#include <cocos2d.h>

#include <Geode/loader/Event.hpp>

// Container for Horrible Ideas API
namespace horrible {
// Event for option toggles
class OptionEvent : public geode::Event {
private:
std::string m_id; // Unique ID of the option
bool m_toggled; // Toggle boolean of the option

public:
OptionEvent(std::string id, bool toggled); // Constructor

AWCW_HORRIBLE_API_DLL std::string_view getId() const noexcept; // Get the unique ID of the option
AWCW_HORRIBLE_API_DLL bool getToggled() const noexcept; // Get the toggle boolean of the option
};

// Filter for option toggle event
class AWCW_HORRIBLE_API_DLL OptionEventFilter : public geode::EventFilter<OptionEvent> {
private:
std::vector<std::string> m_ids; // Unique ID of the options to listen to

public:
using Callback = geode::ListenerResult(OptionEvent*);

/**
* Event handler
*
* @param fn Callback function containing a pointer to the event that fired
* @param event Pointer to the event that fired
*/
geode::ListenerResult handle(std::function<Callback> fn, OptionEvent* event);

OptionEventFilter() = default; // Constructor

OptionEventFilter(std::string id); // Constructor (listens to one option's toggle)
OptionEventFilter(std::vector<std::string> ids); // Constructor (listens to any specified options' toggles)

OptionEventFilter(cocos2d::CCNode*, std::string id); // Constructor with target (listens to one option's toggle)
OptionEventFilter(cocos2d::CCNode*, std::vector<std::string> ids); // Constructor with target (listens to any specified options' toggles)
struct OptionEvent final : geode::GlobalEvent<OptionEvent, bool(std::string, bool), std::string> {
using GlobalEvent::GlobalEvent;
};
};
30 changes: 15 additions & 15 deletions include/Horrible.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@
// Container for Horrible Ideas API functions
namespace horrible {
// Mod option manager for Horrible Ideas
class AWCW_HORRIBLE_API_DLL OptionManager : public cocos2d::CCObject {
class AWCW_HORRIBLE_API_DLL OptionManager final : public cocos2d::CCObject {
private:
class Impl; // PImpl class
std::unique_ptr<Impl> m_impl; // PImpl pointer
std::vector<Option> m_options; // Array of registered options
std::vector<std::string> m_categories; // Array of auto-registered categories

protected:
OptionManager(); // Constructor
virtual ~OptionManager(); // Destructor

/**
* Register a category if not already registered
*
* @param category Name of the category
*/
void registerCategory(std::string_view category);
void registerCategory(std::string category);

/**
* Check if an option already exists
Expand All @@ -47,8 +44,6 @@ namespace horrible {
*/
bool doesOptionExist(std::string_view id) const noexcept;

friend class OptionEventFilter;

public:
// Get option manager singleton
static OptionManager* get() noexcept;
Expand All @@ -58,14 +53,14 @@ namespace horrible {
*
* @param option Constructed option object
*/
void registerOption(Option const& option);
void registerOption(Option option);

/**
* Returns a reference to the array of all registered options
*
* @returns An array of every registered option, main and external
*/
std::span<const Option> getOptions() const noexcept;
[[nodiscard]] std::span<const Option> getOptions() const noexcept;

/**
* Returns the toggle state of an option
Expand All @@ -74,7 +69,7 @@ namespace horrible {
*
* @returns Boolean of the current value
*/
bool getOption(std::string_view id) const noexcept;
[[nodiscard]] bool getOption(std::string_view id) const noexcept;

/**
* Set the toggle state of an option
Expand All @@ -84,13 +79,18 @@ namespace horrible {
*
* @returns Boolean of the old value
*/
bool setOption(std::string_view id, bool enable) const noexcept;
bool setOption(geode::ZStringView id, bool enable) const;

/**
* Returns a reference to the array of all registered categories
*
* @returns An array of every category name
*/
std::span<const std::string> getCategories() const noexcept;
[[nodiscard]] std::span<const std::string> getCategories() const noexcept;
};
};
};

// Statically register an option
#define REGISTER_HORRIBLE_OPTION(opt) $execute {\
if (auto om = horrible::OptionManager::get()) om->registerOption(opt); \
}
2 changes: 1 addition & 1 deletion include/Option.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace horrible {
};

// A horrible option
struct Option {
struct Option final {
std::string id; // Unique ID of the option
std::string name; // Name of the option
std::string description; // Description of the option
Expand Down
40 changes: 5 additions & 35 deletions include/OptionalAPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,19 @@
#define MY_MOD_ID "arcticwoof.horrible_ideas"

namespace horrible {
class OptionEventV2 : public geode::Event {
private:
std::string m_id;
bool m_toggled;

public:
OptionEventV2(std::string id, bool toggled) : m_id(std::move(id)), m_toggled(toggled) {};

std::string_view getId() const noexcept { return m_id; };
bool getToggled() const noexcept { return m_toggled; };
};

class OptionEventFilterV2 : public geode::EventFilter<OptionEventV2> {
private:
std::vector<std::string> m_ids;

public:
using Callback = geode::ListenerResult(OptionEventV2*);

geode::ListenerResult handle(std::function<Callback> fn, OptionEventV2* event) {
if (m_ids.empty()) {
return fn(event);
} else {
for (auto const& id : m_ids) if (event->getId() == id) return fn(event);
};

return geode::ListenerResult::Propagate;
};

OptionEventFilterV2() = default;
OptionEventFilterV2(std::string id) : m_ids({ std::move(id) }) {};
OptionEventFilterV2(std::vector<std::string> ids) : m_ids(std::move(ids)) {};
struct OptionEventV2 final : geode::Event<OptionEventV2, bool(std::string, bool)> {
using Event::Event;
};

class OptionManagerV2 {
class OptionManagerV2 final {
public:
static geode::Result<> registerOption(Option const& option)
GEODE_EVENT_EXPORT(&OptionManagerV2::registerOption, (option));

static geode::Result<bool> getOption(std::string_view id)
[[nodiscard]] static geode::Result<bool> getOption(std::string_view id)
GEODE_EVENT_EXPORT(&OptionManagerV2::getOption, (id));

static geode::Result<bool> setOption(std::string_view id, bool enable)
static geode::Result<bool> setOption(geode::ZStringView id, bool enable)
GEODE_EVENT_EXPORT(&OptionManagerV2::setOption, (id, enable));
};
};
35 changes: 16 additions & 19 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"geode": "4.11.0",
"geode": "5.0.0-beta.3",
"gd": {
"win": "2.2074",
"android": "2.2074",
"mac": "2.2074",
"ios": "2.2074"
"win": "2.2081",
"android": "2.2081",
"mac": "2.2081",
"ios": "2.2081"
},
"id": "arcticwoof.horrible_ideas",
"name": "Horrible Ideas",
Expand Down Expand Up @@ -33,19 +33,7 @@
]
},
"dependencies": {
"geode.node-ids": {
"importance": "required",
"version": ">=1.21.0"
},
"geode.custom-keybinds": {
"importance": "required",
"version": ">=1.10.0",
"platforms": [
"win",
"mac",
"android"
]
}
"geode.node-ids": ">=1.22.0"
},
"api": {
"include": [
Expand All @@ -61,7 +49,16 @@
},
"button": {
"type": "custom:menu",
"name": ""
"name": " "
},
"key-popup": {
"type": "keybind",
"name": "Options Menu",
"description": "Key to open the Horrible Options menu.",
"default": [
"\\"
],
"category": "universal"
},
"ui": {
"type": "title",
Expand Down
33 changes: 0 additions & 33 deletions src/Keybinds.cpp

This file was deleted.

41 changes: 0 additions & 41 deletions src/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,47 +43,6 @@ namespace horrible {

namespace str = geode::utils::string; // Shortcut for geode::utils::string

// Default option IDs
namespace key {
inline constexpr auto oxygen = "oxygen";
inline constexpr auto health = "health";
inline constexpr auto grief = "grief";
inline constexpr auto congregation = "congregation";
inline constexpr auto math_quiz = "math_quiz";
inline constexpr auto mock = "mock";
inline constexpr auto freeze = "freeze";
inline constexpr auto spam = "spam";
inline constexpr auto achieve = "achieve";
inline constexpr auto crash_death = "crash_death";
inline constexpr auto confetti = "confetti";
inline constexpr auto no_jump = "no_jump";
inline constexpr auto gravity = "gravity";
inline constexpr auto death = "death";
inline constexpr auto upside_down = "upside_down";
inline constexpr auto ads = "ads";
inline constexpr auto black_screen = "black_screen";
inline constexpr auto parry = "parry";
inline constexpr auto double_jump = "double_jump";
inline constexpr auto sleepy = "sleepy";
inline constexpr auto pauses = "pauses";
inline constexpr auto ice_level = "ice_level";
inline constexpr auto random_mirror = "random_mirror";
inline constexpr auto random_speed = "random_speed";
inline constexpr auto random_icon = "random_icon";
inline constexpr auto blinking_icon = "blinking_icon";
inline constexpr auto dementia = "dementia";
inline constexpr auto earthquake = "earthquake";
inline constexpr auto fake_crash = "fake_crash";
inline constexpr auto gambler = "gambler";
inline constexpr auto placebo = "placebo";
inline constexpr auto click_speed = "click_speed";
inline constexpr auto motivation = "motivation";
inline constexpr auto flipped = "flipped";
inline constexpr auto friends = "friends";
inline constexpr auto size_changer = "size_changer";
inline constexpr auto timewarp_jump = "timewarp_jump";
};

// Default option categories
namespace category {
inline constexpr auto playerlife = "Player Life";
Expand Down
6 changes: 4 additions & 2 deletions src/classes/Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <Utils.hpp>

#include <Geode/Geode.hpp>

namespace horrible {
namespace util {
// Horrible options utilities
Expand Down Expand Up @@ -39,7 +41,7 @@ namespace horrible {
*
* @returns Boolean of the old value
*/
bool set(std::string_view id, bool enable);
bool set(geode::ZStringView id, bool enable);

/**
* Returns the array of all registered option categories
Expand All @@ -53,7 +55,7 @@ namespace horrible {
*
* @param category The exact name of the category to check
*/
bool doesCategoryExist(std::string_view category) noexcept;
bool doesCategoryExist(geode::ZStringView category) noexcept;
};
};
};
Loading