From 9095d9025e1d4a0c732007c9f1244e00de16d3ad Mon Sep 17 00:00:00 2001 From: praydog Date: Mon, 2 Dec 2024 20:06:24 -0800 Subject: [PATCH] Plugins/Lua: Add repository information functions --- include/uevr/API.h | 11 +++++++- lua-api/lib/src/ScriptContext.cpp | 11 +++++++- src/mods/PluginLoader.cpp | 44 ++++++++++++++++++++++++------- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/include/uevr/API.h b/include/uevr/API.h index 2979947a..d7668012 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 35 +#define UEVR_PLUGIN_VERSION_MINOR 36 #define UEVR_PLUGIN_VERSION_PATCH 0 #define UEVR_RENDERER_D3D11 0 @@ -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 { diff --git a/lua-api/lib/src/ScriptContext.cpp b/lua-api/lib/src/ScriptContext.cpp index a3420b44..20c12def 100644 --- a/lua-api/lib/src/ScriptContext.cpp +++ b/lua-api/lib/src/ScriptContext.cpp @@ -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", diff --git a/src/mods/PluginLoader.cpp b/src/mods/PluginLoader.cpp index b187e786..69d9b0c8 100644 --- a/src/mods/PluginLoader.cpp +++ b/src/mods/PluginLoader.cpp @@ -6,6 +6,7 @@ #include #include "Framework.hpp" +#include "CommitHash.autogenerated" #include "uevr/API.h" #include @@ -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() \