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

62 lines
3 KiB
C++
Raw Normal View History

2022-07-30 12:24:03 -04:00
#pragma once
#include "../meta/meta.hpp"
2022-10-30 14:59:20 -04:00
#include "Addresses.hpp"
2022-11-09 12:11:50 -05:00
#include "Field.hpp"
2022-10-30 14:59:20 -04:00
#include "Types.hpp"
#include "Wrapper.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-17 05:25:56 -04:00
#include "IDManager.hpp"
2022-07-30 12:24:03 -04:00
2022-10-30 14:59:20 -04:00
#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() \
); \
}
2022-07-30 12:24:03 -04:00
namespace geode::modifier {
2022-10-30 14:59:20 -04:00
template <class Derived, class Base>
2022-11-09 12:11:50 -05:00
class ModifyDerive;
2022-07-30 12:24:03 -04:00
2022-10-30 14:59:20 -04:00
template <class Derived>
class ModifyBase {
public:
// unordered_map<handles> idea
ModifyBase() {
Derived::apply();
2022-10-30 14:59:20 -04:00
}
template <class, class>
2022-11-09 12:11:50 -05:00
friend class ModifyDerive;
2022-10-30 14:59:20 -04:00
// explicit Modify(Property property) idea
};
2022-07-30 12:24:03 -04:00
2022-10-30 14:59:20 -04:00
template <class Derived, class Base>
2022-11-09 12:11:50 -05:00
class ModifyDerive {
2022-10-30 14:59:20 -04:00
public:
2022-11-09 12:11:50 -05:00
ModifyDerive() {
2022-10-30 14:59:20 -04:00
static_assert(core::meta::always_false<Derived>, "Custom Modify not implemented.");
}
};
2022-07-30 12:24:03 -04:00
}
2022-11-09 12:11:50 -05:00
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:
modifier::FieldIntermediate<Derived, Base> m_fields;
};
}