Skip to content

Commit

Permalink
Plugins: Add FBoolProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 17, 2024
1 parent 0c14e9c commit 838668f
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 2 deletions.
15 changes: 14 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 23
#define UEVR_PLUGIN_VERSION_MINOR 24
#define UEVR_PLUGIN_VERSION_PATCH 0

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

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

0 comments on commit 838668f

Please sign in to comment.