mirror of
https://github.com/geode-sdk/geode.git
synced 2025-02-17 00:30:26 -05:00
add id priorities
This commit is contained in:
parent
b00ab40ae2
commit
b6a6e4da12
13 changed files with 77 additions and 22 deletions
|
@ -71,6 +71,15 @@ namespace geode::modifier {
|
|||
return Ok(m_hooks[name]);
|
||||
}
|
||||
|
||||
Result<> setHookPriority(std::string const& name, int32_t priority) {
|
||||
auto res = this->getHook(name);
|
||||
if (!res) {
|
||||
return Err(res.unwrapErr());
|
||||
}
|
||||
res.unwrap()->setPriority(priority);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
// unordered_map<handles> idea
|
||||
ModifyBase() {
|
||||
// i really dont want to recompile codegen
|
||||
|
|
|
@ -43,6 +43,12 @@ $execute {
|
|||
};
|
||||
|
||||
struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("MenuLayer::init", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set MenuLayer::init hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
CCSprite* m_geodeButton;
|
||||
|
||||
bool init() {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
USE_GEODE_NAMESPACE();
|
||||
|
||||
static constexpr int32_t GEODE_ID_PRIORITY = 0x100000;
|
||||
|
||||
template<class T = CCNode>
|
||||
requires std::is_base_of_v<CCNode, T>
|
||||
T* setIDSafe(CCNode* node, int index, const char* id) {
|
||||
|
|
|
@ -52,6 +52,12 @@ $register_ids(CreatorLayer) {
|
|||
}
|
||||
|
||||
struct CreatorLayerIDs : Modify<CreatorLayerIDs, CreatorLayer> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("CreatorLayer::init", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set CreatorLayer::init hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
bool init() {
|
||||
if (!CreatorLayer::init()) return false;
|
||||
|
||||
|
|
|
@ -55,6 +55,12 @@ $register_ids(EditLevelLayer) {
|
|||
}
|
||||
|
||||
struct EditLevelLayerIDs : Modify<EditLevelLayerIDs, EditLevelLayer> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("EditLevelLayer::init", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set EditLevelLayer::init hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
bool init(GJGameLevel* l) {
|
||||
if (!EditLevelLayer::init(l)) return false;
|
||||
|
||||
|
|
|
@ -213,6 +213,12 @@ $register_ids(EditorUI) {
|
|||
}
|
||||
|
||||
struct EditorUIIDs : Modify<EditorUIIDs, EditorUI> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("EditorUI::init", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set EditorUI::init hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
bool init(LevelEditorLayer* lel) {
|
||||
if (!EditorUI::init(lel)) return false;
|
||||
|
||||
|
|
|
@ -59,6 +59,12 @@ $register_ids(GJGarageLayer) {
|
|||
}
|
||||
|
||||
struct GJGarageLayerIDs : Modify<GJGarageLayerIDs, GJGarageLayer> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("GJGarageLayer::init", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set GJGarageLayer::init hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
bool init() {
|
||||
if (!GJGarageLayer::init()) return false;
|
||||
|
||||
|
|
|
@ -32,6 +32,12 @@ $register_ids(LevelBrowserLayer) {
|
|||
}
|
||||
|
||||
struct LevelBrowserLayerIDs : Modify<LevelBrowserLayerIDs, LevelBrowserLayer> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("LevelBrowserLayer::init", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set LevelBrowserLayer::init hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
bool init(GJSearchObject* obj) {
|
||||
if (!LevelBrowserLayer::init(obj)) return false;
|
||||
|
||||
|
|
|
@ -81,6 +81,12 @@ $register_ids(LevelInfoLayer) {
|
|||
}
|
||||
|
||||
struct LevelInfoLayerIDs : Modify<LevelInfoLayerIDs, LevelInfoLayer> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("LevelInfoLayer::init", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set LevelInfoLayer::init hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
bool init(GJGameLevel* level) {
|
||||
if (!LevelInfoLayer::init(level)) return false;
|
||||
|
||||
|
|
|
@ -66,6 +66,12 @@ $register_ids(LevelSearchLayer) {
|
|||
}
|
||||
|
||||
struct LevelSearchLayerIDs : Modify<LevelSearchLayerIDs, LevelSearchLayer> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("LevelSearchLayer::init", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set LevelSearchLayer::init hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
bool init() {
|
||||
if (!LevelSearchLayer::init()) return false;
|
||||
|
||||
|
|
|
@ -197,6 +197,12 @@ $register_ids(LevelSettingsLayer) {
|
|||
}
|
||||
|
||||
struct LevelSettingsLayerIDs : Modify<LevelSettingsLayerIDs, LevelSettingsLayer> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("LevelSettingsLayer::init", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set LevelSettingsLayer::init hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
bool init(LevelSettingsObject* levelSettings, LevelEditorLayer* editor) {
|
||||
if (!LevelSettingsLayer::init(levelSettings, editor)) return false;
|
||||
|
||||
|
@ -205,25 +211,3 @@ struct LevelSettingsLayerIDs : Modify<LevelSettingsLayerIDs, LevelSettingsLayer>
|
|||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class... Params>
|
||||
struct Resolve2 {
|
||||
template <class Return>
|
||||
static constexpr auto func(Return(*ptr)(float)) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template <class Return, class Class>
|
||||
static constexpr auto func(Return(Class::*ptr)(float)) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template <class Return, class Class>
|
||||
static constexpr auto func(Return(Class::*ptr)(float) const) {
|
||||
return ptr;
|
||||
}
|
||||
};
|
||||
|
||||
#include <Geode/modify/PlayerObject.hpp>
|
||||
constexpr auto b = Resolve2<float>::func(&PlayerObject::runBallRotation);
|
|
@ -59,6 +59,12 @@ $register_ids(PauseLayer) {
|
|||
}
|
||||
|
||||
struct PauseLayerIDs : Modify<PauseLayerIDs, PauseLayer> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("PauseLayer::customSetup", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set PauseLayer::customSetup hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
void customSetup() {
|
||||
PauseLayer::customSetup();
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ $register_ids(UILayer) {
|
|||
}
|
||||
|
||||
struct UILayerIDs : Modify<UILayerIDs, UILayer> {
|
||||
static void onModify(auto& self) {
|
||||
if (!self.setHookPriority("UILayer::init", GEODE_ID_PRIORITY)) {
|
||||
log::warn("Failed to set UILayer::init hook priority, node IDs may not work properly");
|
||||
}
|
||||
}
|
||||
|
||||
bool init() {
|
||||
if (!UILayer::init()) return false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue