Skip to content

Commit

Permalink
UI: Add commit hash and build date to window title
Browse files Browse the repository at this point in the history
time
  • Loading branch information
praydog committed Jan 31, 2024
1 parent d921a7f commit 60d3c7c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ list(APPEND uevr_SOURCES
"src/uevr-imgui/imgui_impl_dx12.cpp"
"src/uevr-imgui/imgui_impl_win32.cpp"
"src/utility/ImGui.cpp"
"src/CommitHash.hpp"
"src/ExceptionHandler.hpp"
"src/Framework.hpp"
"src/LicenseStrings.hpp"
Expand Down Expand Up @@ -795,6 +796,11 @@ set_target_properties(uevr PROPERTIES
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET uevr PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)
add_custom_command(
TARGET uevr POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:openvr> $<TARGET_FILE_DIR:uevr>)
Expand Down
17 changes: 17 additions & 0 deletions MakeCommitHash.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@echo off
FOR /F "tokens=*" %%g IN ('git rev-parse HEAD') DO (SET UEVR_COMMIT_HASH=%%g)

FOR /F "tokens=2 delims==" %%a IN ('wmic OS get localdatetime /value') DO (
SET datetime=%%a
)

SET year=%datetime:~0,4%
SET month=%datetime:~4,2%
SET day=%datetime:~6,2%
SET hour=%datetime:~8,2%
SET minute=%datetime:~10,2%

echo #pragma once > src/CommitHash.hpp
echo #define UEVR_COMMIT_HASH "%UEVR_COMMIT_HASH%" >> src/CommitHash.hpp
echo #define UEVR_BUILD_DATE "%day%.%month%.%year%" >> src/CommitHash.hpp
echo #define UEVR_BUILD_TIME "%hour%:%minute%" >> src/CommitHash.hpp
6 changes: 6 additions & 0 deletions cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,13 @@ link-libraries = [
"uesdk"
]
cmake-after="""
add_custom_command(
TARGET uevr PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)
add_custom_command(
TARGET uevr POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:openvr> $<TARGET_FILE_DIR:uevr>)
"""
4 changes: 4 additions & 0 deletions src/CommitHash.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once
#define UEVR_COMMIT_HASH "d921a7f616a228e549a0f6826266dcd88a5066f9"
#define UEVR_BUILD_DATE "31.01.2024"
#define UEVR_BUILD_TIME "00:00"
5 changes: 4 additions & 1 deletion src/Framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "mods/VR.hpp"
#include "mods/ImGuiThemeHelpers.hpp"

#include "CommitHash.hpp"
#include "ExceptionHandler.hpp"
#include "LicenseStrings.hpp"
#include "mods/FrameworkConfig.hpp"
Expand Down Expand Up @@ -1157,9 +1158,11 @@ void Framework::draw_ui() {
if (!m_last_draw_ui || m_cursor_state_changed) {
m_cursor_state_changed = false;
}

static const auto UEVR_NAME = std::format("UEVR [rev. {:.8}][{} {}]", UEVR_COMMIT_HASH, UEVR_BUILD_DATE, UEVR_BUILD_TIME);

ImGui::SetNextWindowSize(ImVec2(window_w, window_h), ImGuiCond_::ImGuiCond_Once);
ImGui::Begin("UEVR", &m_draw_ui);
ImGui::Begin(UEVR_NAME.c_str(), &m_draw_ui);

ImGui::BeginGroup();
ImGui::Columns(2);
Expand Down

0 comments on commit 60d3c7c

Please sign in to comment.