Skip to content

Commit

Permalink
Plugins: Add FStructProperty functions
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 26, 2024
1 parent 735ca89 commit 4cedaa7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
8 changes: 7 additions & 1 deletion include/uevr/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SOFTWARE.
#define UEVR_OUT

#define UEVR_PLUGIN_VERSION_MAJOR 2
#define UEVR_PLUGIN_VERSION_MINOR 24
#define UEVR_PLUGIN_VERSION_MINOR 25
#define UEVR_PLUGIN_VERSION_PATCH 0

#define UEVR_RENDERER_D3D11 0
Expand Down Expand Up @@ -78,6 +78,7 @@ DECLARE_UEVR_HANDLE(UEVR_FRHITexture2DHandle);
DECLARE_UEVR_HANDLE(UEVR_UScriptStructHandle);
DECLARE_UEVR_HANDLE(UEVR_FArrayPropertyHandle);
DECLARE_UEVR_HANDLE(UEVR_FBoolPropertyHandle);
DECLARE_UEVR_HANDLE(UEVR_FStructPropertyHandle);

/* OpenXR stuff */
DECLARE_UEVR_HANDLE(UEVR_XrInstance);
Expand Down Expand Up @@ -411,6 +412,10 @@ typedef struct {
void (*set_value_in_propbase)(UEVR_FBoolPropertyHandle prop, void* addr, bool value);
} UEVR_FBoolPropertyFunctions;

typedef struct {
UEVR_UScriptStructHandle (*get_struct)(UEVR_FStructPropertyHandle prop);
} UEVR_FStructPropertyFunctions;

typedef struct {
const UEVR_SDKFunctions* functions;
const UEVR_SDKCallbacks* callbacks;
Expand All @@ -432,6 +437,7 @@ typedef struct {
const UEVR_UScriptStructFunctions* uscriptstruct;
const UEVR_FArrayPropertyFunctions* farrayproperty;
const UEVR_FBoolPropertyFunctions* fboolproperty;
const UEVR_FStructPropertyFunctions* fstructproperty;
} UEVR_SDKData;

DECLARE_UEVR_HANDLE(UEVR_IVRSystem);
Expand Down
20 changes: 20 additions & 0 deletions include/uevr/API.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,26 @@ class API {
}
};

struct FStructProperty : public FProperty {
inline UEVR_FStructPropertyHandle to_handle() { return (UEVR_FStructPropertyHandle)this; }
inline UEVR_FStructPropertyHandle to_handle() const { return (UEVR_FStructPropertyHandle)this; }

UScriptStruct* get_struct() const {
static const auto fn = initialize()->get_struct;
return (UScriptStruct*)fn(to_handle());
}

private:
static inline const UEVR_FStructPropertyFunctions* s_functions{nullptr};
static inline const UEVR_FStructPropertyFunctions* initialize() {
if (s_functions == nullptr) {
s_functions = API::get()->sdk()->fstructproperty;
}

return s_functions;
}
};

struct FFieldClass {
inline UEVR_FFieldClassHandle to_handle() { return (UEVR_FFieldClassHandle)this; }
inline UEVR_FFieldClassHandle to_handle() const { return (UEVR_FFieldClassHandle)this; }
Expand Down
10 changes: 9 additions & 1 deletion src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <sdk/USceneComponent.hpp>
#include <sdk/FArrayProperty.hpp>
#include <sdk/FBoolProperty.hpp>
#include <sdk/FStructProperty.hpp>

#include "pluginloader/FFakeStereoRenderingFunctions.hpp"
#include "pluginloader/FRenderTargetPoolHook.hpp"
Expand Down Expand Up @@ -842,6 +843,12 @@ UEVR_FBoolPropertyFunctions g_fbool_property_functions {
}
};

UEVR_FStructPropertyFunctions g_fstruct_property_functions {
.get_struct = [](UEVR_FStructPropertyHandle prop) -> UEVR_UScriptStructHandle {
return (UEVR_UScriptStructHandle)((sdk::FStructProperty*)prop)->get_struct();
}
};

UEVR_SDKData g_sdk_data {
&g_sdk_functions,
&g_sdk_callbacks,
Expand All @@ -862,7 +869,8 @@ UEVR_SDKData g_sdk_data {
&uevr::frhitexture2d::functions,
&uevr::uscriptstruct::functions,
&g_farray_property_functions,
&g_fbool_property_functions
&g_fbool_property_functions,
&g_fstruct_property_functions
};

namespace uevr {
Expand Down

0 comments on commit 4cedaa7

Please sign in to comment.