From dd106a2f20afda333aff975a740cc7d4f8fc0b67 Mon Sep 17 00:00:00 2001 From: Dipshet <264011288+Dipshet@users.noreply.github.com> Date: Tue, 14 Jul 2026 20:37:15 +0200 Subject: [PATCH] Added build-stamp watermark Extract the build watermark into its own BuildStampOverlay (rex/ui/overlay/build_stamp_overlay.*), a non-interactive drawer in the lower-left corner - independent of the F3 debug overlay. It stamps the short git commit hash (REXGLUE_GIT_HASH, captured by CMake via git rev-parse --short HEAD -> version.h; re-run cmake to refresh) via REXGLUE_BUILD_HASH_STAMP, instead of the build date. Drawing is gated by the show_build_stamp cvar (category UI, default true) so players can hide it; registered next to the other built-in overlays in rex_app. --- thirdparty/rexglue-sdk/CMakeLists.txt | 11 +++++ thirdparty/rexglue-sdk/include/rex/rex_app.h | 2 + .../rex/ui/overlay/build_stamp_overlay.h | 26 ++++++++++++ .../rexglue-sdk/include/rex/version.h.in | 5 +++ .../rexglue-sdk/src/native/ui/CMakeLists.txt | 1 + .../rexglue-sdk/src/native/ui/rex_app.cpp | 2 + thirdparty/rexglue-sdk/src/ui/CMakeLists.txt | 1 + .../src/ui/overlay/build_stamp_overlay.cpp | 40 +++++++++++++++++++ 8 files changed, 88 insertions(+) create mode 100644 thirdparty/rexglue-sdk/include/rex/ui/overlay/build_stamp_overlay.h create mode 100644 thirdparty/rexglue-sdk/src/ui/overlay/build_stamp_overlay.cpp diff --git a/thirdparty/rexglue-sdk/CMakeLists.txt b/thirdparty/rexglue-sdk/CMakeLists.txt index 9d3196f1..2c5c997f 100644 --- a/thirdparty/rexglue-sdk/CMakeLists.txt +++ b/thirdparty/rexglue-sdk/CMakeLists.txt @@ -136,6 +136,17 @@ add_compile_definitions(REXGLUE_BUILD_CONFIG="$") # Generate version header -- must run after REX_PLATFORM is set # Timestamp is set at configure time -- intentionally not updated on every rebuild string(TIMESTAMP REXGLUE_BUILD_TIMESTAMP "%Y%m%d_%H%M") +# Short git commit hash of the containing project (re-run cmake to refresh it). +execute_process( + COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE REXGLUE_GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) +if(NOT REXGLUE_GIT_HASH) + set(REXGLUE_GIT_HASH "nogit") +endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/include/rex/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/rex/version.h diff --git a/thirdparty/rexglue-sdk/include/rex/rex_app.h b/thirdparty/rexglue-sdk/include/rex/rex_app.h index 6fcda846..4aa041f3 100644 --- a/thirdparty/rexglue-sdk/include/rex/rex_app.h +++ b/thirdparty/rexglue-sdk/include/rex/rex_app.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -139,6 +140,7 @@ class ReXApp : public ui::WindowedApp, public ui::WindowListener, public ui::Win // Built-in overlays std::shared_ptr log_sink_; std::unique_ptr debug_overlay_; + std::unique_ptr build_stamp_overlay_; std::unique_ptr console_overlay_; std::unique_ptr settings_overlay_; }; diff --git a/thirdparty/rexglue-sdk/include/rex/ui/overlay/build_stamp_overlay.h b/thirdparty/rexglue-sdk/include/rex/ui/overlay/build_stamp_overlay.h new file mode 100644 index 00000000..3fad9b77 --- /dev/null +++ b/thirdparty/rexglue-sdk/include/rex/ui/overlay/build_stamp_overlay.h @@ -0,0 +1,26 @@ +/** + * @file rex/ui/overlay/build_stamp_overlay.h + * @brief Always-on build-stamp watermark (short git commit hash) drawn in + * the lower-left corner, independent of the F3 debug overlay. + * + * @copyright Copyright (c) 2026 Project Gracemeria + * @license BSD 3-Clause License + */ +#pragma once +#include + +namespace rex::ui { + +// A non-interactive dialog that draws the build's short git commit hash in the +// lower-left corner every frame. Registers itself with the ImGuiDrawer on +// construction (like any ImGuiDialog). Drawing is gated by the show_build_stamp +// cvar (on by default); set it false to hide the watermark. +class BuildStampOverlay : public ImGuiDialog { + public: + explicit BuildStampOverlay(ImGuiDrawer* imgui_drawer); + + protected: + void OnDraw(ImGuiIO& io) override; +}; + +} // namespace rex::ui diff --git a/thirdparty/rexglue-sdk/include/rex/version.h.in b/thirdparty/rexglue-sdk/include/rex/version.h.in index 8600b5d9..8538b50e 100644 --- a/thirdparty/rexglue-sdk/include/rex/version.h.in +++ b/thirdparty/rexglue-sdk/include/rex/version.h.in @@ -8,6 +8,7 @@ #define REXGLUE_BUILD_PLATFORM "@REX_PLATFORM@" #define REXGLUE_BUILD_TIMESTAMP "@REXGLUE_BUILD_TIMESTAMP@" +#define REXGLUE_GIT_HASH "@REXGLUE_GIT_HASH@" // Requires REXGLUE_BUILD_CONFIG compile definition // Title: "[rexglue-v0.7.1-Release]" @@ -18,3 +19,7 @@ #define REXGLUE_BUILD_STAMP \ "build: rexglue-v" REXGLUE_VERSION_STRING "-" REXGLUE_BUILD_PLATFORM \ "-" REXGLUE_BUILD_CONFIG "@" REXGLUE_BUILD_TIMESTAMP + +// Watermark: "rexglue-v0.7.1-Release @5120188b" (short git commit hash) +#define REXGLUE_BUILD_HASH_STAMP \ + "rexglue-v" REXGLUE_VERSION_STRING "-" REXGLUE_BUILD_CONFIG " @" REXGLUE_GIT_HASH diff --git a/thirdparty/rexglue-sdk/src/native/ui/CMakeLists.txt b/thirdparty/rexglue-sdk/src/native/ui/CMakeLists.txt index 8192ab3e..804bc5a8 100644 --- a/thirdparty/rexglue-sdk/src/native/ui/CMakeLists.txt +++ b/thirdparty/rexglue-sdk/src/native/ui/CMakeLists.txt @@ -17,6 +17,7 @@ set(REXUI_CORE_SOURCES set(REXUI_OVERLAY_SOURCES ${REXGLUE_ROOT}/src/ui/overlay/debug_overlay.cpp + ${REXGLUE_ROOT}/src/ui/overlay/build_stamp_overlay.cpp ${REXGLUE_ROOT}/src/ui/overlay/console_overlay.cpp ${REXGLUE_ROOT}/src/ui/overlay/settings_overlay.cpp ) diff --git a/thirdparty/rexglue-sdk/src/native/ui/rex_app.cpp b/thirdparty/rexglue-sdk/src/native/ui/rex_app.cpp index 46acee0a..cbfe4d5a 100644 --- a/thirdparty/rexglue-sdk/src/native/ui/rex_app.cpp +++ b/thirdparty/rexglue-sdk/src/native/ui/rex_app.cpp @@ -223,6 +223,7 @@ bool ReXApp::OnInitialize() { imgui_drawer_->SetPresenterAndImmediateDrawer(presenter, immediate_drawer_.get()); // Built-in overlays debug_overlay_ = std::make_unique(imgui_drawer_.get()); + build_stamp_overlay_ = std::make_unique(imgui_drawer_.get()); console_overlay_ = std::make_unique(imgui_drawer_.get(), log_sink_); settings_overlay_ = std::make_unique( imgui_drawer_.get(), config_path); @@ -309,6 +310,7 @@ void ReXApp::OnDestroy() { // ImGui cleanup (reverse of setup) settings_overlay_.reset(); console_overlay_.reset(); + build_stamp_overlay_.reset(); debug_overlay_.reset(); if (imgui_drawer_) { imgui_drawer_->SetPresenterAndImmediateDrawer(nullptr, nullptr); diff --git a/thirdparty/rexglue-sdk/src/ui/CMakeLists.txt b/thirdparty/rexglue-sdk/src/ui/CMakeLists.txt index 0ed53f27..105a26f0 100644 --- a/thirdparty/rexglue-sdk/src/ui/CMakeLists.txt +++ b/thirdparty/rexglue-sdk/src/ui/CMakeLists.txt @@ -19,6 +19,7 @@ set(REXUI_CORE_SOURCES # Optional overlay dialogs set(REXUI_OVERLAY_SOURCES overlay/debug_overlay.cpp + overlay/build_stamp_overlay.cpp overlay/console_overlay.cpp overlay/settings_overlay.cpp ) diff --git a/thirdparty/rexglue-sdk/src/ui/overlay/build_stamp_overlay.cpp b/thirdparty/rexglue-sdk/src/ui/overlay/build_stamp_overlay.cpp new file mode 100644 index 00000000..c607ed32 --- /dev/null +++ b/thirdparty/rexglue-sdk/src/ui/overlay/build_stamp_overlay.cpp @@ -0,0 +1,40 @@ +/** + * @file ui/overlay/build_stamp_overlay.cpp + * @brief Always-on build-stamp watermark. See build_stamp_overlay.h. + * + * @copyright Copyright (c) 2026 Project Gracemeria + * @license BSD 3-Clause License + */ +#include +#include +#include +#include + +REXCVAR_DEFINE_BOOL(show_build_stamp, true, "UI", + "Draw the build-stamp watermark (short git commit hash) in the " + "lower-left corner. On by default; set false to hide it."); + +namespace rex::ui { + +BuildStampOverlay::BuildStampOverlay(ImGuiDrawer* imgui_drawer) : ImGuiDialog(imgui_drawer) {} + +void BuildStampOverlay::OnDraw(ImGuiIO& io) { + if (!REXCVAR_GET(show_build_stamp)) + return; + + const float margin = io.DisplaySize.y * 0.02f; + const ImVec2 size = ImGui::CalcTextSize(REXGLUE_BUILD_HASH_STAMP); + ImGui::SetNextWindowPos(ImVec2(margin, io.DisplaySize.y - size.y - margin)); + ImGui::SetNextWindowSize(ImVec2(0, 0)); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f, 0.5f)); + if (ImGui::Begin("##buildstamp", nullptr, + ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBackground | + ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoNav | + ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::TextUnformatted(REXGLUE_BUILD_HASH_STAMP); + } + ImGui::End(); + ImGui::PopStyleColor(); +} + +} // namespace rex::ui