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.
This commit is contained in:
Dipshet
2026-07-14 20:37:15 +02:00
parent 97906a6d4e
commit dd106a2f20
8 changed files with 88 additions and 0 deletions
+11
View File
@@ -136,6 +136,17 @@ add_compile_definitions(REXGLUE_BUILD_CONFIG="$<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
+2
View File
@@ -23,6 +23,7 @@
#include <rex/ui/imgui_dialog.h>
#include <rex/ui/imgui_drawer.h>
#include <rex/ui/immediate_drawer.h>
#include <rex/ui/overlay/build_stamp_overlay.h>
#include <rex/ui/overlay/debug_overlay.h>
#include <rex/ui/window.h>
#include <rex/ui/window_listener.h>
@@ -139,6 +140,7 @@ class ReXApp : public ui::WindowedApp, public ui::WindowListener, public ui::Win
// Built-in overlays
std::shared_ptr<LogCaptureSink> log_sink_;
std::unique_ptr<ui::DebugOverlayDialog> debug_overlay_;
std::unique_ptr<ui::BuildStampOverlay> build_stamp_overlay_;
std::unique_ptr<ui::ConsoleDialog> console_overlay_;
std::unique_ptr<ui::SettingsDialog> settings_overlay_;
};
@@ -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 <rex/ui/imgui_dialog.h>
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
+5
View File
@@ -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
+1
View File
@@ -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
)
+2
View File
@@ -223,6 +223,7 @@ bool ReXApp::OnInitialize() {
imgui_drawer_->SetPresenterAndImmediateDrawer(presenter, immediate_drawer_.get());
// Built-in overlays
debug_overlay_ = std::make_unique<ui::DebugOverlayDialog>(imgui_drawer_.get());
build_stamp_overlay_ = std::make_unique<ui::BuildStampOverlay>(imgui_drawer_.get());
console_overlay_ = std::make_unique<ui::ConsoleDialog>(imgui_drawer_.get(), log_sink_);
settings_overlay_ = std::make_unique<ui::SettingsDialog>(
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);
+1
View File
@@ -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
)
@@ -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 <rex/ui/overlay/build_stamp_overlay.h>
#include <rex/cvar.h>
#include <rex/version.h>
#include <imgui.h>
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