Skip to content

Commit

Permalink
Add commit revision to window title
Browse files Browse the repository at this point in the history
  • Loading branch information
Benualdo committed Oct 29, 2024
1 parent 6aea982 commit 13d2e9a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
14 changes: 14 additions & 0 deletions generate_version_header.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@echo off

rem Change to the directory where your header should be generated
cd /d "src"

rem Get the current short Git revision
for /f "delims=" %%i in ('git rev-parse --short HEAD') do set GIT_REVISION=%%i

rem Create the version header file
echo // This file is generated automatically > version.h
echo #define GIT_REVISION "%GIT_REVISION%" >> version.h

rem Optional: print a message
echo Version header generated with GIT revision: %GIT_REVISION%
37 changes: 8 additions & 29 deletions src/application/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,14 @@

#include "resource.h"
#include "application.h"

#define TEST_META_ENUM 0

#if TEST_META_ENUM
#include "core/Types/Enum/Enum_meta.h"
#endif
#include "version.h"

HINSTANCE hInst;
HWND g_hWnd;

using namespace vg;
engine::IEngine * g_engine = nullptr;

#if TEST_META_ENUM

vg_enum(Color, vg::core::u32,
Red = 0x000000FF,
Green = 0x0000FF00,
Blue = 0x00FF0000
);

void TestMetaEnum()
{
VG_DEBUGPRINT("%s\n", ((vg::core::string)Color_meta.string).c_str());

const auto & pairs = meta::enumPairs<Color>();
for (auto i = 0; i < pairs.size(); ++i)
{
const auto & pair = pairs[i];
VG_DEBUGPRINT("[#%u] %s = %u\n", i, pair.second.c_str(), pair.first);
}
}

#endif

//--------------------------------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
Expand Down Expand Up @@ -268,10 +241,16 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
Application * app = new Application(*g_engine);
const auto version = app->GetVersion();

core::string title = "VG Framework " + core::to_string(version.major) + "." + core::to_string(version.minor) + " " + core::Plugin::getPlatform() + "|" + core::Plugin::getConfiguration() + " - " + core::asString(engineParams.renderer.device.api);
core::string title = fmt::sprintf("VGFramework %s|%s - %s", core::Plugin::getPlatform(), core::Plugin::getConfiguration(), core::asString(engineParams.renderer.device.api));
if (engineParams.renderer.device.debugDevice)
title += " (debug device)";

title += fmt::sprintf(" - Version %u.%u", version.major, version.minor);

#ifdef GIT_REVISION
title += fmt::sprintf(" commit %s", GIT_REVISION);
#endif

SetWindowTextA(g_hWnd, title.c_str());

// Start in play mode?
Expand Down
2 changes: 2 additions & 0 deletions src/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// This file is generated automatically
#define GIT_REVISION "70d9c2af"

0 comments on commit 13d2e9a

Please sign in to comment.