Skip to content

Commit

Permalink
Plugins/Lua: Add repository information functions
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Dec 3, 2024
1 parent 38afaa2 commit 9095d90
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 11 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 35
#define UEVR_PLUGIN_VERSION_MINOR 36
#define UEVR_PLUGIN_VERSION_PATCH 0

#define UEVR_RENDERER_D3D11 0
Expand Down Expand Up @@ -218,6 +218,15 @@ typedef struct {
int (*register_inline_hook)(void* target, void* dst, void** original);
void (*unregister_inline_hook)(int hook_id);
void (*dispatch_lua_event)(const char* event_name, const char* event_data);

const char* (*get_commit_hash)();
const char* (*get_tag)();
const char* (*get_tag_long)();
const char* (*get_branch)();
const char* (*get_build_date)();
const char* (*get_build_time)();
unsigned int (*get_commits_past_tag)();
unsigned int (*get_total_commits)();
} UEVR_PluginFunctions;

typedef struct {
Expand Down
11 changes: 10 additions & 1 deletion lua-api/lib/src/ScriptContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,16 @@ int ScriptContext::setup_bindings() {
"log_error", &UEVR_PluginFunctions::log_error,
"log_warn", &UEVR_PluginFunctions::log_warn,
"log_info", &UEVR_PluginFunctions::log_info,
"is_drawing_ui", &UEVR_PluginFunctions::is_drawing_ui
"is_drawing_ui", &UEVR_PluginFunctions::is_drawing_ui,

"get_commit_hash", &UEVR_PluginFunctions::get_commit_hash,
"get_tag", &UEVR_PluginFunctions::get_tag,
"get_tag_long", &UEVR_PluginFunctions::get_tag_long,
"get_branch", &UEVR_PluginFunctions::get_branch,
"get_build_date", &UEVR_PluginFunctions::get_build_date,
"get_build_time", &UEVR_PluginFunctions::get_build_time,
"get_commits_past_tag", &UEVR_PluginFunctions::get_commits_past_tag,
"get_total_commits", &UEVR_PluginFunctions::get_total_commits
);

m_lua.new_usertype<UEVR_RendererData>("UEVR_RendererData",
Expand Down
44 changes: 35 additions & 9 deletions src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <openvr.h>

#include "Framework.hpp"
#include "CommitHash.autogenerated"
#include "uevr/API.h"

#include <utility/String.hpp>
Expand Down Expand Up @@ -186,15 +187,40 @@ UEVR_PluginCallbacks g_plugin_callbacks {
};

UEVR_PluginFunctions g_plugin_functions {
uevr::log_error,
uevr::log_warn,
uevr::log_info,
uevr::is_drawing_ui,
uevr::remove_callback,
uevr::get_persistent_dir,
uevr::register_inline_hook,
uevr::unregister_inline_hook,
uevr::dispatch_lua_event
.log_error = uevr::log_error,
.log_warn = uevr::log_warn,
.log_info = uevr::log_info,
.is_drawing_ui = uevr::is_drawing_ui,
.remove_callback = uevr::remove_callback,
.get_persistent_dir = uevr::get_persistent_dir,
.register_inline_hook = uevr::register_inline_hook,
.unregister_inline_hook = uevr::unregister_inline_hook,
.dispatch_lua_event =::dispatch_lua_event,

.get_commit_hash = []() -> const char* {
return UEVR_COMMIT_HASH;
},
.get_tag = []() -> const char* {
return UEVR_TAG;
},
.get_tag_long = []() -> const char* {
return UEVR_TAG_LONG;
},
.get_branch = []() -> const char* {
return UEVR_BRANCH;
},
.get_build_date = []() -> const char* {
return UEVR_BUILD_DATE;
},
.get_build_time = []() -> const char* {
return UEVR_BUILD_TIME;
},
.get_commits_past_tag = []() -> unsigned int {
return UEVR_COMMITS_PAST_TAG;
},
.get_total_commits = []() -> unsigned int {
return UEVR_TOTAL_COMMITS;
}
};

#define GET_ENGINE_WORLD_RETNULL() \
Expand Down

0 comments on commit 9095d90

Please sign in to comment.