From a16461a183d9eba793c969b23b5ccbbfd9ffe598 Mon Sep 17 00:00:00 2001 From: praydog Date: Fri, 28 Jun 2024 08:07:21 -0700 Subject: [PATCH] Plugins: Add FEnumProperty functions --- include/uevr/API.h | 11 ++++++++++- include/uevr/API.hpp | 33 +++++++++++++++++++++++++++++++++ src/mods/PluginLoader.cpp | 13 ++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/include/uevr/API.h b/include/uevr/API.h index 48fa6e62..41393f84 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 25 +#define UEVR_PLUGIN_VERSION_MINOR 26 #define UEVR_PLUGIN_VERSION_PATCH 0 #define UEVR_RENDERER_D3D11 0 @@ -79,6 +79,9 @@ DECLARE_UEVR_HANDLE(UEVR_UScriptStructHandle); DECLARE_UEVR_HANDLE(UEVR_FArrayPropertyHandle); DECLARE_UEVR_HANDLE(UEVR_FBoolPropertyHandle); DECLARE_UEVR_HANDLE(UEVR_FStructPropertyHandle); +DECLARE_UEVR_HANDLE(UEVR_FEnumPropertyHandle); +DECLARE_UEVR_HANDLE(UEVR_UEnumHandle); +DECLARE_UEVR_HANDLE(UEVR_FNumericPropertyHandle); /* OpenXR stuff */ DECLARE_UEVR_HANDLE(UEVR_XrInstance); @@ -416,6 +419,11 @@ typedef struct { UEVR_UScriptStructHandle (*get_struct)(UEVR_FStructPropertyHandle prop); } UEVR_FStructPropertyFunctions; +typedef struct { + UEVR_FNumericPropertyHandle (*get_underlying_prop)(UEVR_FEnumPropertyHandle prop); + UEVR_UEnumHandle (*get_enum)(UEVR_FEnumPropertyHandle prop); +} UEVR_FEnumPropertyFunctions; + typedef struct { const UEVR_SDKFunctions* functions; const UEVR_SDKCallbacks* callbacks; @@ -438,6 +446,7 @@ typedef struct { const UEVR_FArrayPropertyFunctions* farrayproperty; const UEVR_FBoolPropertyFunctions* fboolproperty; const UEVR_FStructPropertyFunctions* fstructproperty; + const UEVR_FEnumPropertyFunctions* fenumproperty; } UEVR_SDKData; DECLARE_UEVR_HANDLE(UEVR_IVRSystem); diff --git a/include/uevr/API.hpp b/include/uevr/API.hpp index 51f2750d..b9943ad1 100644 --- a/include/uevr/API.hpp +++ b/include/uevr/API.hpp @@ -742,6 +742,39 @@ class API { } }; + struct UEnum : public UObject { + + }; + + struct FNumericProperty : public FProperty { + + }; + + struct FEnumProperty : public FProperty { + inline UEVR_FEnumPropertyHandle to_handle() { return (UEVR_FEnumPropertyHandle)this; } + inline UEVR_FEnumPropertyHandle to_handle() const { return (UEVR_FEnumPropertyHandle)this; } + + FNumericProperty* get_underlying_prop() const { + static const auto fn = initialize()->get_underlying_prop; + return (FNumericProperty*)fn(to_handle()); + } + + UEnum* get_enum() const { + static const auto fn = initialize()->get_enum; + return (UEnum*)fn(to_handle()); + } + + private: + static inline const UEVR_FEnumPropertyFunctions* s_functions{nullptr}; + static inline const UEVR_FEnumPropertyFunctions* initialize() { + if (s_functions == nullptr) { + s_functions = API::get()->sdk()->fenumproperty; + } + + 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 6277eed3..54ee5078 100644 --- a/src/mods/PluginLoader.cpp +++ b/src/mods/PluginLoader.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "pluginloader/FFakeStereoRenderingFunctions.hpp" #include "pluginloader/FRenderTargetPoolHook.hpp" @@ -858,6 +859,15 @@ UEVR_FStructPropertyFunctions g_fstruct_property_functions { } }; +UEVR_FEnumPropertyFunctions g_fenum_property_functions { + .get_underlying_prop = [](UEVR_FEnumPropertyHandle prop) -> UEVR_FNumericPropertyHandle { + return (UEVR_FNumericPropertyHandle)((sdk::FEnumProperty*)prop)->get_underlying_prop(); + }, + .get_enum = [](UEVR_FEnumPropertyHandle prop) -> UEVR_UEnumHandle { + return (UEVR_UEnumHandle)((sdk::FEnumProperty*)prop)->get_enum(); + } +}; + UEVR_SDKData g_sdk_data { &g_sdk_functions, &g_sdk_callbacks, @@ -879,7 +889,8 @@ UEVR_SDKData g_sdk_data { &uevr::uscriptstruct::functions, &g_farray_property_functions, &g_fbool_property_functions, - &g_fstruct_property_functions + &g_fstruct_property_functions, + &g_fenum_property_functions }; namespace uevr {