From ebe074e308c518fb9e951076e0b6ba3a0de3ab47 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 20 Nov 2020 17:58:28 -0800 Subject: [PATCH] Add commit hash and date to title screen The commit hash and date are now shown above the version number in the bottom-right of the title screen. They both automatically go away when compiled in release mode. https://cdn.discordapp.com/attachments/717089363896434719/779525976689213480/vvvvvv_with_interim_commit_and_date.png This is useful to easily figure out which commit someone is on whenever they report an issue, without having to ask them to do `git show` or whatever. --- desktop_version/CMakeLists.txt | 20 ++++++++++++++++++++ desktop_version/src/Render.cpp | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/desktop_version/CMakeLists.txt b/desktop_version/CMakeLists.txt index 3f69743f..54801bd1 100644 --- a/desktop_version/CMakeLists.txt +++ b/desktop_version/CMakeLists.txt @@ -16,6 +16,26 @@ SET(GOG OFF CACHE BOOL "Use the GOG API") IF(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") SET(STEAM ON) SET(GOG ON) +ELSE() + # Get interim commit and date of commit + FIND_PACKAGE(Git) + IF(GIT_FOUND) + EXECUTE_PROCESS( + COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h + OUTPUT_VARIABLE INTERIM_COMMIT + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + ADD_DEFINITIONS(-DINTERIM_COMMIT="${INTERIM_COMMIT}") + + EXECUTE_PROCESS( + COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cs + OUTPUT_VARIABLE COMMIT_DATE + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + ADD_DEFINITIONS(-DCOMMIT_DATE="${COMMIT_DATE}") + ENDIF() ENDIF() # Set standard to C++98/C++03 diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 4a85d4d2..796e52da 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -40,6 +40,12 @@ void menurender() graphics.drawsprite((160 - 96) + 5 * 32, temp, 23, tr, tg, tb); #if defined(MAKEANDPLAY) graphics.Print(-1,temp+35," MAKE AND PLAY EDITION",tr, tg, tb, true); +#endif +#ifdef COMMIT_DATE + graphics.Print( 310 - (10*8), 210, COMMIT_DATE, tr/2, tg/2, tb/2); +#endif +#ifdef INTERIM_COMMIT + graphics.Print( 310 - (8*8), 220, INTERIM_COMMIT, tr/2, tg/2, tb/2); #endif graphics.Print( 310 - (4*8), 230, "v2.3", tr/2, tg/2, tb/2);