From: RĂ©mi Verschelde Date: Tue, 24 Jan 2017 18:47:12 +0000 (+0100) Subject: Output version info to stdout and show in menu X-Git-Url: https://git.jsancho.org/?p=lugaru.git;a=commitdiff_plain;h=1198f8141fe7d5b04a936935c45af3217064b0d7 Output version info to stdout and show in menu Fixes #82. --- diff --git a/Source/Game.hpp b/Source/Game.hpp index 159cbe7..36ad6c8 100644 --- a/Source/Game.hpp +++ b/Source/Game.hpp @@ -206,9 +206,9 @@ SDL_bool sdlEventProc(const SDL_Event &e); -enum optionIndex { UNKNOWN, HELP, FULLSCREEN, NOMOUSEGRAB, SOUND, OPENALINFO, SHOWRESOLUTIONS, DEVTOOLS }; +enum optionIndex { UNKNOWN, VERSION, HELP, FULLSCREEN, NOMOUSEGRAB, SOUND, OPENALINFO, SHOWRESOLUTIONS, DEVTOOLS }; /* Number of options + 1 */ -const int commandLineOptionsNumber = 9; +const int commandLineOptionsNumber = 10; extern const option::Descriptor usage[13]; diff --git a/Source/Menu/Menu.cpp b/Source/Menu/Menu.cpp index 1fbecd2..b8d0031 100644 --- a/Source/Menu/Menu.cpp +++ b/Source/Menu/Menu.cpp @@ -25,6 +25,7 @@ along with Lugaru. If not, see . #include "Level/Campaign.hpp" #include "User/Settings.hpp" #include "Utils/Input.hpp" +#include "Version.hpp" // Should not be needed, Menu should call methods from other classes to launch maps and challenges and so on #include "Level/Awards.hpp" @@ -381,6 +382,7 @@ void Menu::Load() addButtonImage(1, Mainmenuitems[mainmenu == 1 ? 1 : 5], 18, 480 - 152 - 32, 128, 32); addButtonImage(2, Mainmenuitems[2], 18, 480 - 228 - 32, 112, 32); addButtonImage(3, Mainmenuitems[mainmenu == 1 ? 3 : 6], 18, 480 - 306 - 32, mainmenu == 1 ? 68 : 132, 32); + addLabel(-1, VERSION_NUMBER + VERSION_SUFFIX, 640 - 100, 10); break; case 3: addButton(0, "", 10 + 20, 440); diff --git a/Source/main.cpp b/Source/main.cpp index 3e37f64..19bfa6e 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -24,6 +24,7 @@ along with Lugaru. If not, see . #include "Graphic/gamegl.hpp" #include "MacCompatibility.hpp" #include "User/Settings.hpp" +#include "Version.hpp" #include #include @@ -588,6 +589,7 @@ const option::Descriptor usage[] = { { UNKNOWN, 0, "", "", option::Arg::None, "USAGE: lugaru [options]\n\n" "Options:" }, + { VERSION, 0, "v", "version", option::Arg::None, " -v, --version Print version and exit." }, { HELP, 0, "h", "help", option::Arg::None, " -h, --help Print usage and exit." }, { FULLSCREEN, 1, "f", "fullscreen", option::Arg::None, " -f, --fullscreen Start the game in fullscreen mode." }, { FULLSCREEN, 0, "w", "windowed", option::Arg::None, " -w, --windowed Start the game in windowed mode (default)." }, @@ -620,6 +622,23 @@ int main(int argc, char** argv) return 1; } + // Always start by printing the version and info to the stdout + std::cout << "--------------------------------------------------------------------------\n" + << "Lugaru HD: The Rabbit's Foot, by Wolfire Games and the OSS Lugaru project.\n\n" + << "Licensed under the GPL 2.0+ and CC-BY-SA 3.0 and 4.0 licenses.\n" + << "More information, updates and bug reports at http://osslugaru.gitlab.io\n" + << std::endl; + + std::cout << "Version " + VERSION_STRING + " -- " + VERSION_BUILD_TYPE + " build\n" + << "--------------------------------------------------------------------------\n" + << std::endl; + + if (commandLineOptions[VERSION]) { + // That was enough, quit. + delete[] commandLineOptionsBuffer; + return 0; + } + if (commandLineOptions[HELP]) { option::printUsage(std::cout, usage); delete[] commandLineOptionsBuffer;