Skip to content

Commit

Permalink
Allow additional information appended after version string
Browse files Browse the repository at this point in the history
Related: EasyRPG#87
  • Loading branch information
carstene1ns committed Feb 28, 2016
1 parent 625927d commit 53df1fc
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,4 @@

//#define USE_FIXED_TIMESTEP_FPS

/** Version of player. Should be redefined by build system. */
#ifndef PLAYER_VERSION
# define PLAYER_VERSION "0.4.0"
#endif

#endif
27 changes: 24 additions & 3 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@
#include "scene_battle.h"
#include "scene_logo.h"
#include "utils.h"
#include "version.h"

#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <fstream>

#ifdef GEKKO
Expand Down Expand Up @@ -115,8 +117,19 @@ void Player::Init(int argc, char *argv[]) {

if (init) return;

Output::Debug("EasyRPG Player started");
Output::Debug("======================");
// Display a nice version string
std::stringstream header;
std::string addtl_ver(PLAYER_ADDTL);
header << "EasyRPG Player " << PLAYER_VERSION;
if (!addtl_ver.empty())
header << " " << addtl_ver;
header << " started";
Output::Debug(header.str().c_str());

uint header_width = header.str().length();
header.str("");
header << std::setfill('=') << std::setw(header_width) << "=";
Output::Debug(header.str().c_str());

#ifdef GEKKO
// Init libfat (Mount SD/USB)
Expand Down Expand Up @@ -730,7 +743,15 @@ std::string Player::GetEncoding() {
}

void Player::PrintVersion() {
std::cout << "EasyRPG Player " << PLAYER_VERSION << std::endl;
std::string additional(PLAYER_ADDTL);
std::stringstream version;

version << PLAYER_VERSION;

if (!additional.empty())
version << " " << additional;

std::cout << "EasyRPG Player " << version.str() << std::endl;
}

void Player::PrintUsage() {
Expand Down
35 changes: 35 additions & 0 deletions src/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Player is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _VERSION_H_
#define _VERSION_H_

// Helper Macros
#define STRINGIFY(x) #x
#define TO_STRING(x) STRINGIFY(x)

/**
* Version of Player.
* FIXME: Make this a proper, generated version header redefined by the build system.
*/
#define PLAYER_MAJOR 0
#define PLAYER_MINOR 4
#define PLAYER_PATCH 0
#define PLAYER_ADDTL ""
#define PLAYER_VERSION TO_STRING(PLAYER_MAJOR) "." TO_STRING(PLAYER_MINOR) "." TO_STRING(PLAYER_PATCH)

#endif /* _VERSION_H_ */

0 comments on commit 53df1fc

Please sign in to comment.