mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-30 19:26:59 -05:00
72 lines
3.4 KiB
C++
72 lines
3.4 KiB
C++
#pragma once
|
|
#include "../meta/meta.hpp"
|
|
#include "Addresses.hpp"
|
|
#include "Field.hpp"
|
|
#include "Types.hpp"
|
|
#include "Wrapper.hpp"
|
|
|
|
#include <Geode/loader/Loader.hpp>
|
|
#include <Geode/loader/Mod.hpp>
|
|
#include <iostream>
|
|
#include "IDManager.hpp"
|
|
|
|
#define GEODE_APPLY_MODIFY_FOR_FUNCTION( \
|
|
addr_index, pure_index, convention, className, functionName \
|
|
) \
|
|
if constexpr (wrap::functionName<Derived, types::pure##pure_index>::uuid != nullptr && (void*)wrap::functionName<Base, types::pure##pure_index>::uuid != (void*)wrap::functionName<Derived, types::pure##pure_index>::uuid) { \
|
|
(void)Mod::get() \
|
|
->addHook<wrap::functionName<Derived, types::pure##pure_index>::value, convention>( \
|
|
#className "::" #functionName, (void*)addresses::address##addr_index() \
|
|
); \
|
|
}
|
|
|
|
namespace geode::modifier {
|
|
|
|
template <class Derived, class Base>
|
|
class ModifyDerive;
|
|
|
|
template <class Derived>
|
|
class ModifyBase {
|
|
public:
|
|
// unordered_map<handles> idea
|
|
ModifyBase() {
|
|
Derived::apply();
|
|
}
|
|
template <class, class>
|
|
friend class ModifyDerive;
|
|
// explicit Modify(Property property) idea
|
|
};
|
|
|
|
template <class Derived, class Base>
|
|
class ModifyDerive {
|
|
public:
|
|
ModifyDerive() {
|
|
static_assert(core::meta::always_false<Derived>, "Custom Modify not implemented.");
|
|
}
|
|
};
|
|
}
|
|
|
|
namespace geode {
|
|
|
|
template <class Derived, class Base>
|
|
class Modify : public Base {
|
|
private:
|
|
static inline modifier::ModifyDerive<Derived, Base> s_apply;
|
|
// because for some reason we need it
|
|
static inline auto s_applyRef = &Modify::s_apply;
|
|
|
|
public:
|
|
// abusing the internal stuff
|
|
// basically we dont want modify to invoke base ctors and dtors
|
|
// we already have utilities for these, which are ccdestructor
|
|
// and the monostate constructor
|
|
Modify() : Base(std::monostate(), sizeof(Base)) {}
|
|
~Modify() {
|
|
cocos2d::CCDestructor::lock(this) = true;
|
|
}
|
|
Modify(Modify const&) = delete;
|
|
Modify(Modify&&) = delete;
|
|
|
|
modifier::FieldIntermediate<Derived, Base> m_fields;
|
|
};
|
|
}
|