From e170e64f9cfe17a39a5b46f311933af85c2caf12 Mon Sep 17 00:00:00 2001 From: FlightlessMango Date: Sat, 2 May 2020 18:39:39 +0200 Subject: [PATCH] [Params] Version option --- meson.build | 5 +++++ src/overlay.cpp | 6 +++++- src/overlay_params.h | 1 + version.h.in | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 version.h.in diff --git a/meson.build b/meson.build index c5f316c1..34e9710f 100644 --- a/meson.build +++ b/meson.build @@ -10,6 +10,11 @@ cpp = meson.get_compiler('cpp') prog_python = import('python').find_installation('python3') null_dep = dependency('', required : false) +mangohud_version = vcs_tag( + command: ['git', 'describe', '--tags', '--dirty=+'], + input: 'version.h.in', + output: 'version.h') + pre_args = [ '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS', diff --git a/src/overlay.cpp b/src/overlay.cpp index 91d0e1cc..88ba0402 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -58,6 +58,7 @@ #include "memory.h" #include "notify.h" #include "blacklist.h" +#include "version.h" #ifdef HAVE_DBUS #include "dbus_info.h" @@ -1135,9 +1136,12 @@ void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size = ImVec2(params.width, params.height); unsigned width = ImGui::GetIO().DisplaySize.x; unsigned height = ImGui::GetIO().DisplaySize.y; - + if (!params.no_display){ ImGui::Begin("Main", &open, ImGuiWindowFlags_NoDecoration); + if (params.enabled[OVERLAY_PARAM_ENABLED_version]) + ImGui::Text("%s", MANGOHUD_VERSION); + ImGui::Dummy(ImVec2(0, 8.0f)); if (params.enabled[OVERLAY_PARAM_ENABLED_time]){ ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 1.00f), "%s", data.time.c_str()); } diff --git a/src/overlay_params.h b/src/overlay_params.h index 6ad1225c..38dbada3 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -42,6 +42,7 @@ typedef unsigned long KeySym; OVERLAY_PARAM_BOOL(gpu_core_clock) \ OVERLAY_PARAM_BOOL(arch) \ OVERLAY_PARAM_BOOL(media_player) \ + OVERLAY_PARAM_BOOL(version) \ OVERLAY_PARAM_CUSTOM(fps_sampling_period) \ OVERLAY_PARAM_CUSTOM(output_file) \ OVERLAY_PARAM_CUSTOM(font_file) \ diff --git a/version.h.in b/version.h.in new file mode 100644 index 00000000..86032798 --- /dev/null +++ b/version.h.in @@ -0,0 +1,3 @@ +#pragma once + +#define MANGOHUD_VERSION "@VCS_TAG@"