Skip to content

Commit ffe19c2

Browse files
committed
more docs
1 parent 67063a3 commit ffe19c2

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

include/HorribleIdeas.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ namespace horribleideas {
6767
platforms(std::move(platforms)) {};
6868
};
6969

70+
// Event for option toggles
7071
class HorribleOptionEvent : public Event {
7172
protected:
7273
std::string id;
@@ -79,10 +80,17 @@ namespace horribleideas {
7980
AWCW_HORRIBLE_API_DLL bool getIsToggled() const; // Get the toggle boolean of the option
8081
};
8182

83+
// Filter for option toggle event
8284
class AWCW_HORRIBLE_API_DLL HorribleOptionEventFilter : public EventFilter<HorribleOptionEvent> {
8385
public:
8486
using Callback = ListenerResult(HorribleOptionEvent*);
8587

88+
/**
89+
* Event handler
90+
*
91+
* @param fn Callback function containing a pointer to the event that fired
92+
* @param event Pointer to the event that fired
93+
*/
8694
ListenerResult handle(std::function<Callback> fn, HorribleOptionEvent* event) {
8795
return fn(event);
8896
};

include/README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ An event that fires any time any option is changed.
3232
- `std::string` **`getId()`**: Get the unique ID of the option
3333
- `bool` **`getIsToggled()`**: Get the toggle boolean of the option
3434

35+
#### class `horribleideas::HorribleOptionEventFilter`
36+
- `ListenerResult` **`handle(std::function<Callback> fn, HorribleOptionEvent* event)`**: Event handler
37+
- `std::function<Callback>` **`fn`**: Callback function containing a pointer to the event that fired
38+
- `HorribleOptionEvent*` **`event`**: Pointer to the event that fired
39+
40+
#### Summary
41+
| Type | Name | Description |
42+
| ------------ | --------------------------- | ------------------------------------ |
43+
| `enum class` | `SillyTier` | Defines how silly an option is |
44+
| `struct` | `Option` | Represents a toggleable option |
45+
| `class` | `HorribleOptionEvent` | Fired when an option is toggled |
46+
| `class` | `HorribleOptionEventFilter` | Filters through option toggle events |
47+
3548
### Options
3649
You can register and check any and as many options as you desire through this API.
3750

@@ -53,7 +66,13 @@ $execute{
5366
"Stuff!",
5467
SillyTier::Medium
5568
));
69+
};
70+
```
5671

72+
You can include optional fields `restart` and `platforms` as well! The array for `platforms` uses Geode's dynamic `PlatformID` class to identify the exact platform the player is running Geometry Dash on. By default, Horrible Ideas set every option to be compatible for `PlatformID::Desktop` and `PlatformID::Mobile`, essentially covering all platforms. However, you can get very specific about the exact platform you can run your own options on if absolutely necessary, though it's unlikely to be.
73+
74+
```cpp
75+
$execute{
5776
auto coolOption = Option(
5877
"cool-things"_spr,
5978
"Cool Things",
@@ -63,12 +82,12 @@ $execute{
6382
false,
6483
{
6584
PlatformID::Android32,
66-
PlatformID::iOS
85+
PlatformID::X64
6786
}
6887
);
6988

7089
registerOption(coolOption);
71-
}
90+
};
7291
```
7392

7493
This will automatically include your option in Horrible Ideas's pre-existing list of options, and will appear in the menu for the player whenever they open it.
@@ -135,4 +154,12 @@ class $modify(SomethingInterestingMenuLayer, MenuLayer) {
135154
};
136155
```
137156

138-
Happy modding!
157+
### Watch Out!
158+
Some common pitfalls include the following.
159+
- Forgetting to use `_spr` when defining unique option ID
160+
- Not returning `ListenerResult::Propagate` in event callbacks
161+
- Registering options outside the `$execute` block
162+
163+
Always double-check your code to make sure it follows safe practices.
164+
165+
*Happy modding!*

0 commit comments

Comments
 (0)