From 838668fa4dfc66b5a5e9c31489bc22d1ee7231f6 Mon Sep 17 00:00:00 2001 From: praydog Date: Sun, 16 Jun 2024 20:18:47 -0700 Subject: [PATCH] Plugins: Add FBoolProperty --- include/uevr/API.h | 15 ++++++++++- include/uevr/API.hpp | 55 +++++++++++++++++++++++++++++++++++++++ src/mods/PluginLoader.cpp | 31 +++++++++++++++++++++- 3 files changed, 99 insertions(+), 2 deletions(-) diff --git a/include/uevr/API.h b/include/uevr/API.h index 5f1eaef4..8d1f918c 100644 --- a/include/uevr/API.h +++ b/include/uevr/API.h @@ -36,7 +36,7 @@ SOFTWARE. #define UEVR_OUT #define UEVR_PLUGIN_VERSION_MAJOR 2 -#define UEVR_PLUGIN_VERSION_MINOR 23 +#define UEVR_PLUGIN_VERSION_MINOR 24 #define UEVR_PLUGIN_VERSION_PATCH 0 #define UEVR_RENDERER_D3D11 0 @@ -77,6 +77,7 @@ DECLARE_UEVR_HANDLE(UEVR_FMallocHandle); DECLARE_UEVR_HANDLE(UEVR_FRHITexture2DHandle); DECLARE_UEVR_HANDLE(UEVR_UScriptStructHandle); DECLARE_UEVR_HANDLE(UEVR_FArrayPropertyHandle); +DECLARE_UEVR_HANDLE(UEVR_FBoolPropertyHandle); /* OpenXR stuff */ DECLARE_UEVR_HANDLE(UEVR_XrInstance); @@ -399,6 +400,17 @@ typedef struct { UEVR_FPropertyHandle (*get_inner)(UEVR_FArrayPropertyHandle prop); } UEVR_FArrayPropertyFunctions; +typedef struct { + unsigned int (*get_field_size)(UEVR_FBoolPropertyHandle prop); + unsigned int (*get_byte_offset)(UEVR_FBoolPropertyHandle prop); + unsigned int (*get_byte_mask)(UEVR_FBoolPropertyHandle prop); + unsigned int (*get_field_mask)(UEVR_FBoolPropertyHandle prop); + bool (*get_value_from_object)(UEVR_FBoolPropertyHandle prop, void* object); + bool (*get_value_from_propbase)(UEVR_FBoolPropertyHandle prop, void* addr); + void (*set_value_in_object)(UEVR_FBoolPropertyHandle prop, void* object, bool value); + void (*set_value_in_propbase)(UEVR_FBoolPropertyHandle prop, void* addr, bool value); +} UEVR_FBoolPropertyFunctions; + typedef struct { const UEVR_SDKFunctions* functions; const UEVR_SDKCallbacks* callbacks; @@ -419,6 +431,7 @@ typedef struct { const UEVR_FRHITexture2DFunctions* frhitexture2d; const UEVR_UScriptStructFunctions* uscriptstruct; const UEVR_FArrayPropertyFunctions* farrayproperty; + const UEVR_FBoolPropertyFunctions* fboolproperty; } UEVR_SDKData; DECLARE_UEVR_HANDLE(UEVR_IVRSystem); diff --git a/include/uevr/API.hpp b/include/uevr/API.hpp index 3ac4ff7d..a774c6fd 100644 --- a/include/uevr/API.hpp +++ b/include/uevr/API.hpp @@ -667,6 +667,61 @@ class API { } }; + struct FBoolProperty : public FProperty { + inline UEVR_FBoolPropertyHandle to_handle() { return (UEVR_FBoolPropertyHandle)this; } + inline UEVR_FBoolPropertyHandle to_handle() const { return (UEVR_FBoolPropertyHandle)this; } + + uint32_t get_field_size() const { + static const auto fn = initialize()->get_field_size; + return fn(to_handle()); + } + + uint32_t get_byte_offset() const { + static const auto fn = initialize()->get_byte_offset; + return fn(to_handle()); + } + + uint32_t get_byte_mask() const { + static const auto fn = initialize()->get_byte_mask; + return fn(to_handle()); + } + + uint32_t get_field_mask() const { + static const auto fn = initialize()->get_field_mask; + return fn(to_handle()); + } + + bool get_value_from_object(void* object) const { + static const auto fn = initialize()->get_value_from_object; + return fn(to_handle(), object); + } + + bool get_value_from_propbase(void* addr) const { + static const auto fn = initialize()->get_value_from_propbase; + return fn(to_handle(), addr); + } + + void set_value_in_object(void* object, bool value) const { + static const auto fn = initialize()->set_value_in_object; + fn(to_handle(), object, value); + } + + void set_value_in_propbase(void* addr, bool value) const { + static const auto fn = initialize()->set_value_in_propbase; + fn(to_handle(), addr, value); + } + + private: + static inline const UEVR_FBoolPropertyFunctions* s_functions{nullptr}; + static inline const UEVR_FBoolPropertyFunctions* initialize() { + if (s_functions == nullptr) { + s_functions = API::get()->sdk()->fboolproperty; + } + + return s_functions; + } + }; + struct FFieldClass { inline UEVR_FFieldClassHandle to_handle() { return (UEVR_FFieldClassHandle)this; } inline UEVR_FFieldClassHandle to_handle() const { return (UEVR_FFieldClassHandle)this; } diff --git a/src/mods/PluginLoader.cpp b/src/mods/PluginLoader.cpp index 55b6310a..354f3d66 100644 --- a/src/mods/PluginLoader.cpp +++ b/src/mods/PluginLoader.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "pluginloader/FFakeStereoRenderingFunctions.hpp" #include "pluginloader/FRenderTargetPoolHook.hpp" @@ -810,6 +811,33 @@ UEVR_FArrayPropertyFunctions g_farray_property_functions { } }; +UEVR_FBoolPropertyFunctions g_fbool_property_functions { + .get_field_size = [](UEVR_FBoolPropertyHandle prop) -> uint32_t { + return ((sdk::FBoolProperty*)prop)->get_field_size(); + }, + .get_byte_offset = [](UEVR_FBoolPropertyHandle prop) -> uint32_t { + return ((sdk::FBoolProperty*)prop)->get_byte_offset(); + }, + .get_byte_mask = [](UEVR_FBoolPropertyHandle prop) -> uint32_t { + return ((sdk::FBoolProperty*)prop)->get_byte_mask(); + }, + .get_field_mask = [](UEVR_FBoolPropertyHandle prop) -> uint32_t { + return ((sdk::FBoolProperty*)prop)->get_field_mask(); + }, + .get_value_from_object = [](UEVR_FBoolPropertyHandle prop, void* obj) -> bool { + return ((sdk::FBoolProperty*)prop)->get_value_from_object((sdk::UObject*)obj); + }, + .get_value_from_propbase = [](UEVR_FBoolPropertyHandle prop, void* propbase) -> bool { + return ((sdk::FBoolProperty*)prop)->get_value_from_propbase(propbase); + }, + .set_value_in_object = [](UEVR_FBoolPropertyHandle prop, void* obj, bool value) { + ((sdk::FBoolProperty*)prop)->set_value_in_object((sdk::UObject*)obj, value); + }, + .set_value_in_propbase = [](UEVR_FBoolPropertyHandle prop, void* propbase, bool value) { + ((sdk::FBoolProperty*)prop)->set_value_in_propbase(propbase, value); + } +}; + UEVR_SDKData g_sdk_data { &g_sdk_functions, &g_sdk_callbacks, @@ -829,7 +857,8 @@ UEVR_SDKData g_sdk_data { &uevr::stereo_hook::functions, &uevr::frhitexture2d::functions, &uevr::uscriptstruct::functions, - &g_farray_property_functions + &g_farray_property_functions, + &g_fbool_property_functions }; namespace uevr {