From 8008ff6dac25b8e69e6a6e53f467bc98c158e46e Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 17 Aug 2015 12:46:09 -0400 Subject: [PATCH] Show git revision on Blades of Exile title screen and in scenario editor --- .gitignore | 1 + src/BoE.xcodeproj/project.pbxproj | 20 ++++++++++++++++ src/boe.graphics.cpp | 13 +++++++++-- src/scenedit/scen.actions.cpp | 38 +++++++++++++++++++++++-------- src/scenedit/scen.global.hpp | 2 +- src/tools/gitrev.sh | 7 ++++++ 6 files changed, 68 insertions(+), 13 deletions(-) create mode 100755 src/tools/gitrev.sh diff --git a/.gitignore b/.gitignore index e6a14a6c..f9403563 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ test/junk/*.map # Misc oldstructs.txt +src/tools/gitrev.hpp diff --git a/src/BoE.xcodeproj/project.pbxproj b/src/BoE.xcodeproj/project.pbxproj index f3efb1ba..cb271a4a 100755 --- a/src/BoE.xcodeproj/project.pbxproj +++ b/src/BoE.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 914701A618F62A52008A6DC9 /* Copy Fonts */, 914B2BB718E8BF99007B6799 /* Validate Dialog Definitions */, 914B2B9518E8008A007B6799 /* Copy Dialog Definitions */, + 91C2A6E01B823C7B00346948 /* Generate Git Revision Information */, ); dependencies = ( ); @@ -736,6 +737,8 @@ 91BFA3D91902ADD5001686E4 /* tarball.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = tarball.hpp; sourceTree = ""; }; 91BFA3DE19033E01001686E4 /* gzstream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gzstream.cpp; sourceTree = ""; }; 91BFA3DF19033E01001686E4 /* gzstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gzstream.h; sourceTree = ""; }; + 91C2A6E11B823CCD00346948 /* gitrev.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = gitrev.sh; sourceTree = ""; }; + 91C2A6E21B8244F700346948 /* gitrev.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = gitrev.hpp; sourceTree = ""; }; 91C688E60FD702B9000F6D01 /* cursors.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cursors.hpp; sourceTree = ""; }; 91C688E70FD702B9000F6D01 /* cursors.mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = cursors.mac.mm; sourceTree = ""; }; 91C749B71A2D6432008E0E10 /* strings */ = {isa = PBXFileReference; lastKnownFileType = folder; path = strings; sourceTree = ""; }; @@ -1086,6 +1089,7 @@ children = ( 91C688E60FD702B9000F6D01 /* cursors.hpp */, 91E5C7A50F9F615400C21460 /* fileio.hpp */, + 91C2A6E21B8244F700346948 /* gitrev.hpp */, 91B3F1090F9779C300BF5B67 /* graphtool.hpp */, 915E09071A316D6A008BDF00 /* map_parse.hpp */, 91B3F11D0F97801F00BF5B67 /* mathutil.hpp */, @@ -1272,6 +1276,7 @@ 91B3F0FF0F97797200BF5B67 /* tools */ = { isa = PBXGroup; children = ( + 91C2A6E11B823CCD00346948 /* gitrev.sh */, 91BFA3DC19033E00001686E4 /* gzstream */, 912DFE8718E24B0B00B00D75 /* resmgr */, 910BBA130FB8BE66001E34EA /* dialogxml */, @@ -1677,6 +1682,21 @@ shellPath = /bin/sh; shellScript = ./fix_dylibs.sh; }; + 91C2A6E01B823C7B00346948 /* Generate Git Revision Information */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Generate Git Revision Information"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/bash; + shellScript = ./tools/gitrev.sh; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/src/boe.graphics.cpp b/src/boe.graphics.cpp index 1924f552..dd636222 100644 --- a/src/boe.graphics.cpp +++ b/src/boe.graphics.cpp @@ -28,6 +28,7 @@ #include "restypes.hpp" #include "boe.menus.hpp" #include "winutil.hpp" +#include "gitrev.hpp" extern sf::RenderWindow mainPtr; extern short stat_window; @@ -426,15 +427,23 @@ void draw_startup_stats() { } } + std::ostringstream sout; + sout << "Copyright 1997, All Rights Reserved, v" << oboeVersionString(); +#if defined(GIT_REVISION) && defined(GIT_TAG_REVISION) + if(strcmp(GIT_REVISION, GIT_TAG_REVISION) != 0) { + sout << " [" << GIT_REVISION << "]"; + } +#endif + std::string copyright = sout.str(); style.font = FONT_BOLD; style.pointSize = 10; pc_rect = startup_from[0]; pc_rect.offset(5,5); pc_rect.top = pc_rect.bottom - 25; - pc_rect.left = pc_rect.right - 270; + pc_rect.left = pc_rect.right - string_length(copyright, style) - 45; // TODO: Should replace this with a more appropriate copyright string // Windows replaced it with "That is not dead which can eternally lie..." - I don't think that's quite appropriate though. - win_draw_string(mainPtr,pc_rect,"Copyright 1997, All Rights Reserved, v" + oboeVersionString(),eTextMode::WRAP,style,ul); + win_draw_string(mainPtr, pc_rect, copyright, eTextMode::WRAP, style, ul); } diff --git a/src/scenedit/scen.actions.cpp b/src/scenedit/scen.actions.cpp index 2b6ad1b5..d744b849 100644 --- a/src/scenedit/scen.actions.cpp +++ b/src/scenedit/scen.actions.cpp @@ -21,6 +21,7 @@ #include "cursors.hpp" #include "scrollbar.hpp" #include "dlogutil.hpp" +#include "gitrev.hpp" #include "scen.btnmg.hpp" @@ -2371,6 +2372,21 @@ void town_entry(location spot_hit) { } } +static std::string version() { + static std::string version; + if(version.empty()) { + std::ostringstream sout; + sout << "Version " << oboeVersionString(); +#if defined(GIT_REVISION) && defined(GIT_TAG_REVISION) + if(strcmp(GIT_REVISION, GIT_TAG_REVISION) != 0) { + sout << " [" << GIT_REVISION << "]"; + } +#endif + version = sout.str(); + } + return version; +} + // is slot >= 0, force that slot // if -1, use 1st free slot void set_up_start_screen() { @@ -2383,11 +2399,12 @@ void set_up_start_screen() { set_lb(7,LB_TEXT,LB_NO_ACTION,"To find out how to use the"); set_lb(8,LB_TEXT,LB_NO_ACTION,"editor, select Getting Started "); set_lb(9,LB_TEXT,LB_NO_ACTION,"from the Help menu."); - set_lb(NLS - 5,LB_TEXT,LB_NO_ACTION,"Be sure to read the file Blades"); - set_lb(NLS - 4,LB_TEXT,LB_NO_ACTION,"of Exile License. Using this"); - set_lb(NLS - 3,LB_TEXT,LB_NO_ACTION,"program implies that you agree "); - set_lb(NLS - 2,LB_TEXT,LB_NO_ACTION,"with the terms of the license."); - set_lb(NLS - 1,LB_TEXT,LB_NO_ACTION,"Copyright 1997, All rights reserved."); + set_lb(NLS - 6,LB_TEXT,LB_NO_ACTION,"Be sure to read the file Blades"); + set_lb(NLS - 5,LB_TEXT,LB_NO_ACTION,"of Exile License. Using this"); + set_lb(NLS - 4,LB_TEXT,LB_NO_ACTION,"program implies that you agree "); + set_lb(NLS - 3,LB_TEXT,LB_NO_ACTION,"with the terms of the license."); + set_lb(NLS - 2,LB_TEXT,LB_NO_ACTION,"Copyright 1997, All rights reserved."); + set_lb(NLS - 1,LB_TEXT,LB_NO_ACTION,version()); } void set_up_main_screen() { @@ -2419,7 +2436,8 @@ void set_up_main_screen() { set_lb(-1,LB_TEXT,LB_LOAD_TOWN,"Load Another Town"); set_lb(-1,LB_TEXT,LB_EDIT_TOWN,"Edit Town Terrain"); set_lb(-1,LB_TEXT,LB_EDIT_TALK,"Edit Town Dialogue"); - set_lb(NLS - 1,LB_TEXT,LB_NO_ACTION,"Copyright 1997, All rights reserved."); + set_lb(NLS - 2,LB_TEXT,LB_NO_ACTION,"Copyright 1997, All rights reserved."); + set_lb(NLS - 1,LB_TEXT,LB_NO_ACTION,version()); overall_mode = MODE_MAIN_SCREEN; right_sbar->show(); pal_sbar->hide(); @@ -2438,8 +2456,8 @@ void start_town_edit() { strb << "Editing Town " << cur_town; set_lb(0,LB_TITLE,LB_NO_ACTION,strb.str()); set_lb(NLS - 3,LB_TEXT,LB_NO_ACTION,town->town_name); - set_lb(NLS - 2,LB_TEXT,LB_NO_ACTION,"(Click border to scroll view.)"); - set_lb(NLS - 1,LB_TEXT,LB_RETURN,"Back to Main Menu"); + set_lb(NLS - 2,LB_TEXT,LB_RETURN,"Back to Main Menu"); + set_lb(NLS - 1,LB_TEXT,LB_NO_ACTION,"(Click border to scroll view.)"); overall_mode = MODE_DRAWING; editing_town = true; set_up_terrain_buttons(true); @@ -2468,8 +2486,8 @@ void start_out_edit() { strb << "Editing outdoors (" << cur_out.x << ',' << cur_out.y << ")"; set_lb(0,LB_TITLE,LB_NO_ACTION,strb.str()); set_lb(NLS - 3,LB_TEXT,LB_NO_ACTION,current_terrain->out_name); - set_lb(NLS - 2,LB_TEXT,LB_NO_ACTION,"(Click border to scroll view.)"); - set_lb(NLS - 1,LB_TEXT,LB_RETURN,"Back to Main Menu"); + set_lb(NLS - 2,LB_TEXT,LB_RETURN,"Back to Main Menu"); + set_lb(NLS - 1,LB_TEXT,LB_NO_ACTION,"(Click border to scroll view.)"); overall_mode = MODE_DRAWING; draw_mode = DRAW_TERRAIN; editing_town = false; diff --git a/src/scenedit/scen.global.hpp b/src/scenedit/scen.global.hpp index 99dabc06..f77e8eb7 100644 --- a/src/scenedit/scen.global.hpp +++ b/src/scenedit/scen.global.hpp @@ -12,7 +12,7 @@ #define NUM_DLOG_B 53 -#define NLS 25 +#define NLS 26 // number of left slots for buttons #define NRS right_button_status.size() // number of right slots for scrolling list diff --git a/src/tools/gitrev.sh b/src/tools/gitrev.sh new file mode 100755 index 00000000..c031f798 --- /dev/null +++ b/src/tools/gitrev.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +REVID=`/opt/local/bin/git rev-parse HEAD`; +export FULLTAG=`/opt/local/bin/git tag --sort=v:refname | tail -n1`; +TAGREV=`/opt/local/bin/git rev-parse $FULLTAG`; + +echo -e "\n#define GIT_REVISION \"${REVID:0:7}\"\n#define GIT_TAG \"$FULLTAG\"\n#define GIT_TAG_REVISION \"${TAGREV:0:7}\"\n" > tools/gitrev.hpp