commit 2a85555c8f0851de1bccc3f633a8072e1ea15551 Author: Justin Jacobs Date: Mon Dec 9 20:06:56 2013 -0500 Display the default game warning on the title screen Closes #896 diff --git src/GameStateTitle.cpp src/GameStateTitle.cpp index 2cdd797..3ca06e8 100644 --- src/GameStateTitle.cpp +++ src/GameStateTitle.cpp @@ -24,6 +24,8 @@ FLARE. If not, see http://www.gnu.org/licenses/ #include "SharedResources.h" #include "WidgetButton.h" #include "WidgetLabel.h" +#include "WidgetScrollBox.h" +#include "UtilsMath.h" GameStateTitle::GameStateTitle() : GameState() { @@ -71,6 +73,21 @@ GameStateTitle::GameStateTitle() : GameState() { tablist.add(button_cfg); tablist.add(button_credits); tablist.add(button_exit); + + // Warning text box + warning_box = NULL; + if (GAME_FOLDER == "default") { + std::string warning_text = msg->get("Warning: A game wasn't specified, falling back to the 'default' game. Did you forget the --game flag? (e.g. --game=flare-game). See --help for more details."); + Point warning_size = font->calc_size(warning_text, VIEW_W/2); + + int warning_box_h = warning_size.y; + clampCeil(warning_box_h, VIEW_H/2); + warning_box = new WidgetScrollBox(VIEW_W/2, warning_box_h); + warning_box->resize(warning_size.y); + + font->setFont("font_normal"); + font->renderShadowed(warning_text, 0, 0, JUSTIFY_LEFT, warning_box->contents, VIEW_W/2, FONT_WHITE); + } } void GameStateTitle::logic() { @@ -83,6 +100,10 @@ void GameStateTitle::logic() { exitRequested = true; } + if (warning_box) { + warning_box->logic(); + } + tablist.logic(); if (button_play->checkClick()) { @@ -134,6 +155,11 @@ void GameStateTitle::render() { // version number label_version->render(); + + // warning text + if (warning_box) { + warning_box->render(); + } } GameStateTitle::~GameStateTitle() { @@ -142,5 +168,6 @@ GameStateTitle::~GameStateTitle() { delete button_credits; delete button_exit; delete label_version; + delete warning_box; SDL_FreeSurface(logo); } diff --git src/GameStateTitle.h src/GameStateTitle.h index 7494dc5..ed2a093 100644 --- src/GameStateTitle.h +++ src/GameStateTitle.h @@ -24,6 +24,7 @@ FLARE. If not, see http://www.gnu.org/licenses/ class WidgetButton; class WidgetLabel; +class WidgetScrollBox; class GameStateTitle : public GameState { private: @@ -33,6 +34,7 @@ private: WidgetButton *button_cfg; WidgetButton *button_credits; WidgetLabel *label_version; + WidgetScrollBox *warning_box; TabList tablist; commit 2f99397b27a407d8f5a34a023a6e54b378d0e32d Author: Justin Jacobs Date: Sat Dec 7 04:52:17 2013 -0500 Add --help and --version command line flags Closes #899 diff --git src/GameStateTitle.cpp src/GameStateTitle.cpp index 4dcaaca..2cdd797 100644 --- src/GameStateTitle.cpp +++ src/GameStateTitle.cpp @@ -64,7 +64,7 @@ GameStateTitle::GameStateTitle() : GameState() { // set up labels label_version = new WidgetLabel(); - label_version->set(VIEW_W, 0, JUSTIFY_RIGHT, VALIGN_TOP, msg->get("Flare Alpha v0.19"), font->getColor("menu_normal")); + label_version->set(VIEW_W, 0, JUSTIFY_RIGHT, VALIGN_TOP, RELEASE_VERSION, font->getColor("menu_normal")); // Setup tab order tablist.add(button_play); diff --git src/Settings.h src/Settings.h index 3682960..cee4808 100644 --- src/Settings.h +++ src/Settings.h @@ -27,6 +27,8 @@ FLARE. If not, see http://www.gnu.org/licenses/ #include "CommonIncludes.h" +const std::string RELEASE_VERSION = "Flare Alpha v0.19"; + class Element{ public: std::string name; diff --git src/main.cpp src/main.cpp index 43d70d0..beabf3e 100644 --- src/main.cpp +++ src/main.cpp @@ -120,8 +120,10 @@ static void init() { for(int i = 0; i < SDL_NumJoysticks(); i++) { printf(" Joy %d) %s\n", i, SDL_JoystickName(i)); } - if ((ENABLE_JOYSTICK) && (SDL_NumJoysticks() > 0)) joy = SDL_JoystickOpen(JOYSTICK_DEVICE); - printf("Using joystick #%d.\n", JOYSTICK_DEVICE); + if ((ENABLE_JOYSTICK) && (SDL_NumJoysticks() > 0)) { + joy = SDL_JoystickOpen(JOYSTICK_DEVICE); + printf("Using joystick #%d.\n", JOYSTICK_DEVICE); + } // Set sound effects volume from settings file if (AUDIO) @@ -213,6 +215,7 @@ string parseArgValue(const string &arg) { int main(int argc, char *argv[]) { bool debug_event = false; + bool done = false; for (int i = 1 ; i < argc; i++) { string arg = string(argv[i]); @@ -227,12 +230,28 @@ int main(int argc, char *argv[]) { if (!CUSTOM_PATH_DATA.empty() && CUSTOM_PATH_DATA.at(CUSTOM_PATH_DATA.length()-1) != '/') CUSTOM_PATH_DATA += "/"; } + else if (parseArg(arg) == "version") { + printf("%s\n", RELEASE_VERSION.c_str()); + done = true; + } + else if (parseArg(arg) == "help") { + printf("\ +--help Prints this message.\n\n\ +--version Prints the release version.\n\n\ +--game Specifies which 'game' to use when launching. A game\n\ + determines which parent folder to look for mods in, as well\n\ + as where user settings and save data are stored.\n\n\ +--data-path Specifies an exact path to look for mod data.\n\n\ +--debug-event Prints verbose hardware input information.\n"); + done = true; + } } - srand((unsigned int)time(NULL)); - - init(); - mainLoop(debug_event); + if (!done) { + srand((unsigned int)time(NULL)); + init(); + mainLoop(debug_event); + } cleanup(); return 0; commit 23547426abb3e1f55228feda6782607d33348f99 Author: Justin Jacobs Date: Sat Dec 7 05:05:00 2013 -0500 Display a warning when the --game flag is omitted diff --git src/main.cpp src/main.cpp index beabf3e..200bdd0 100644 --- src/main.cpp +++ src/main.cpp @@ -216,6 +216,7 @@ string parseArgValue(const string &arg) { int main(int argc, char *argv[]) { bool debug_event = false; bool done = false; + bool game_warning = true; for (int i = 1 ; i < argc; i++) { string arg = string(argv[i]); @@ -224,6 +225,7 @@ int main(int argc, char *argv[]) { } else if (parseArg(arg) == "game") { GAME_FOLDER = parseArgValue(arg); + game_warning = false; } else if (parseArg(arg) == "data-path") { CUSTOM_PATH_DATA = parseArgValue(arg); @@ -247,6 +249,11 @@ int main(int argc, char *argv[]) { } } + // if a game isn't specified, display a warning + if (game_warning) { + printf("Warning: A game wasn't specified, falling back to the 'default' game.\nDid you forget the --game flag? (e.g. --game=flare-game).\nSee --help for more details.\n\n"); + } + if (!done) { srand((unsigned int)time(NULL)); init();