geode/loader/include/Geode/modify/Modify.hpp

47 lines
1.7 KiB
C++
Raw Normal View History

2022-07-30 12:24:03 -04:00
#pragma once
#include "Wrapper.hpp"
#include "Types.hpp"
#include "Addresses.hpp"
#include "../meta/meta.hpp"
2022-10-08 09:55:40 -04:00
#include <Geode/loader/Loader.hpp>
#include <Geode/loader/Mod.hpp>
2022-07-30 12:24:03 -04:00
#include <iostream>
2022-10-06 17:08:44 -04:00
#define GEODE_APPLY_MODIFY_FOR_FUNCTION(index, convention, className, functionName) \
using base##index = wrap::functionName<Base, types::pure##index>; \
using derived##index = wrap::functionName<Derived, types::pure##index>; \
if constexpr (derived##index::uuid != nullptr && (void*)base##index::uuid != (void*)derived##index::uuid) { \
Mod::get()->addHook<derived##index::value, convention>( \
2022-10-06 17:08:44 -04:00
#className "::" #functionName, \
(void*)addresses::address##index() \
); \
} \
2022-07-30 12:24:03 -04:00
namespace geode::modifier {
template <class Derived, class Base>
class Modify;
template <class Derived>
class ModifyBase {
public:
// unordered_map<handles> idea
ModifyBase() {
Loader::get()->scheduleOnModLoad(getMod(), [](){
Derived::apply();
});
2022-07-30 12:24:03 -04:00
}
template <class, class>
friend class Modify;
// explicit Modify(Property property) idea
};
template <class Derived, class Base>
class Modify {
public:
Modify() {
static_assert(core::meta::always_false<Derived>, "Custom Modify not implemented.");
}
};
}