Skip to content

Commit

Permalink
Plugins: Add FEnumProperty functions
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 28, 2024
1 parent 3d59cc8 commit a16461a
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
11 changes: 10 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 25
#define UEVR_PLUGIN_VERSION_MINOR 26
#define UEVR_PLUGIN_VERSION_PATCH 0

#define UEVR_RENDERER_D3D11 0
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
33 changes: 33 additions & 0 deletions include/uevr/API.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
13 changes: 12 additions & 1 deletion src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <sdk/FArrayProperty.hpp>
#include <sdk/FBoolProperty.hpp>
#include <sdk/FStructProperty.hpp>
#include <sdk/FEnumProperty.hpp>

#include "pluginloader/FFakeStereoRenderingFunctions.hpp"
#include "pluginloader/FRenderTargetPoolHook.hpp"
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit a16461a

Please sign in to comment.