Silly API
a bunch of utils for my mods to make my life easier
if ur not a dev this is useless to u
theres a documentation for pretty much everything in headers, otherwise heres a feature list and half finished docs !
the setting stuff is out of date and alot of it is deprecated, but if u js wanna use setting cache, remove settingsmanager->load call, change "Setting" to "SettingCache", and include nwo5/cache instead of nwo5/setting
Features
- geode setting/saved value cache (by making them inline variables so also ide autocomplete)
- plethora of editor utils (like 100+ functions or smth)
- tooltips using user objects
- uibuilder ripoff
- compile time info about every trigger in the game
- bad drawnode rewrite
- named constants for game textures
- array/color utils
- a bunch more stuff (mainly for sillyedit lol)
Editor
make fw the editor hopefully easier :3
u can include with
#include
editor utils are split into a couple different namespaces
- editor
- object
- selection
- constants
- triggers
Editor
uncategorized/general utils related to the editor
one of the most important functions from here is nwo5::editor::update()
most/all editor functions in the api dont actually update stuff like editor buttons or info label
so you need to do that with this function :3
(assuming you included nwo5::editor::prelude) u can use editor::ui() and editor::layer() to get editorlayer/ui ptr (or pass a template argument to reinterpret cast the ptr)
also theres an overcomplicated system (thats kinda shittly implemented) for adding new edit tab buttons so no more createmovemenu hooks !
Selection
a bunch of utils for working with the editor selection
Object
everything related to getting data from/manipulating objs
for example to scale an object
#include
#include
using namespace geode::prelude;
class $modify(EditorUI) {
void customScaleObjects(CCArray* objects, float scale) {
// scale objects to scale (biggest obj scale will be scale, everything else gets scaled accordingly) with undo enabled
nwo5::editor::object::scale(objects, scale, true);
nwo5::editor::update();
}
};
Triggers
i spent almost 10 hours on this im too lazy to write docs
basically an easy way to change trigger groups/duration and query some info abt a trigger (like if it has a center group or smth) read more in editor/trigger.hpp but mayb collapse line 186
UI
very opinionated ui builder alternative + some other ui functions
Settings Cache
part of this mod is a way to cache/easily access geode settings thru inline variables
u can use generate-settings.py to port over ur mod.json settings :3c (i js wanted an excuse to learn python)
Basics
u set up a setting like this
#include
namespace Settings {
// define a bool setting that corresponds to mod setting "silly-setting"
inline nwo5::settings::Setting sillySetting{"silly-setting"};
}
and u can use it like so
#include
#include "settings.hpp"
using namespace geode::prelude;
class $modify(MenuLayer) {
bool init() {
if (!MenuLayer::init()) {
return false;
}
// settings also have a conversion operator which works fine for most cases
// but id recommend just using .get(); its more explicit anyway so :3
if (Settings::sillySetting.get()) {
log::info("haiiii :3");
}
return true;
};
};
somewhere in ur mod u have to load settings
#include
$on_mod(Loaded) {
nwo5::settings::SettingsManager::get()->load();
}
Categories
settings can be categorized, u can define ur categories before loading settings
#include
$on_mod(Loaded) {
nwo5::settings::SettingsManager::get()->registerCategories(
// simply define a category
{"Silly Category"},
// define a category with a description and set its priority
// u can use an enum as priority itll be automatically casted
{"Sillier Category", "is a sillier category than silly category", 10},
// define a category with no description but with a logo
{"Silliest Category", std::nullopt, "silliest-category-logo.png"_spr}
// SettingsManager::get()::getCategories returns a vector of category* sorted by priority
// category priority is by default 0
);
nwo5::settings::SettingsManager::get()->load();
}
u can add a setting to a category like so
#include
namespace Settings {
inline nwo5::settings::Setting sillyCategorizedSetting{"silly-categorized-setting", "Silly Category"};
}
Data
if u wanna add some extra data to ur settings you can either inherit setting to add constructors or use an alias
struct SillyData {
bool isSilly = true;
};
template
class SillySetting : public nwo5::settings::Setting {
public:
SillySetting(std::string_view key, SillyData data)
: nwo5::settings::Setting(key)
{
this->data() = data;
}
};
// alternatively just make an alias and set data whenever
template
using MySillySetting = Setting
Saved Settings
there are also saved settings that use geode saved values if u want to implement settings in ur mod completely from scratch (like silly edit)
#include
namespace Settings {
// key is automatically generated with category + name
inline nwo5::settings::SavedSetting sillySavedSetting{"Silly Saved Setting", "Silly Category", true, "a silly saved setting"};
}
Utils
the rest of the utils in this mod are prolly useless to u but i use them in my mods usually :3
utils has setupnode function which is bad and dumb and stupid, dont use it, use the ui stuffs at the very least (or js actually use the real ui builder) its js there so i dont have to update the entire sillyedit codebase for the time being, it will be removed soon™