diff --git a/.travis.yml b/.travis.yml index 94faa1e..ec264fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ cache: before_install: - sudo apt-add-repository --yes ppa:zoogie/sdl2-snapshots - sudo apt-get update -qq - - sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev docbook-to-man + - sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev docbook-to-man libboost-program-options-dev install: - export CXX="g++-4.9" diff --git a/CMakeLists.txt b/CMakeLists.txt index 34e6895..adf5f6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,8 @@ pkg_search_module(SDL2MIXER REQUIRED SDL2_mixer) pkg_search_module(SDL2IMAGE REQUIRED SDL2_image) pkg_search_module(SDL2TTF REQUIRED SDL2_ttf) +find_package(Boost COMPONENTS program_options REQUIRED) + #Find all sources but one file(GLOB SOURCES "source/code/*.cpp" "source/code/*/*.cpp" "source/code/Libs/*.c") #I am still trying to get BlockGame to compile as a source file @@ -60,6 +62,7 @@ add_executable(blockattack ${GUI_TYPE} ${SOURCES} ${RES_FILES}) target_link_libraries( blockattack ${SDL2_LIBRARY}) target_link_libraries( blockattack physfs jsoncpp) target_link_libraries( blockattack ${SDL2MIXER_LIBRARIES} ${SDL2IMAGE_LIBRARIES} ${SDL2TTF_LIBRARIES}) +target_link_libraries( blockattack ${Boost_LIBRARIES} ) set_target_properties( blockattack PROPERTIES RUNTIME_OUTPUT_DIRECTORY Game) #Installing diff --git a/README.md b/README.md index f8faaf7..fc0f767 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # blockattack-game [![Build Status](https://travis-ci.org/blockattack/blockattack-game.svg?branch=master)](https://travis-ci.org/blockattack/blockattack-game) Block Attack - Rise of the Blocks - the game -A Tetris Attack Clone under the GPL. +A Tetris Attack Clone under the GPL. www.blockattack.net @@ -15,6 +15,7 @@ www.blockattack.net * libSDL2_ttf * libphysfs * libboost (only needed for compiling) + * libboost-program-options-dev * libutfcpp (only needed for compiling) * jsoncpp @@ -44,5 +45,5 @@ and libutfcpp copied from "source/misc/travis_help/utf8_v2_3_4/source/" to "/pat Compiled with: ``` -i686-w64-mingw32.static-cmake --debug-output . && make +i686-w64-mingw32.static-cmake . && make ``` diff --git a/source/code/main.cpp b/source/code/main.cpp index 8d74004..ed1ece3 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -82,6 +82,7 @@ http://blockattack.net //#include "uploadReplay.h" //Takes care of everything libcurl related #include "common.h" +#include /******************************************************************************* * All variables and constant has been moved to mainVars.hpp for the overview. * @@ -1792,52 +1793,29 @@ int main(int argc, char* argv[]) { setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - if (argc > 1) { - int argumentNr = 1; - while (argc>argumentNr) { - const char helpString[] = "--help"; - const char priorityString[] = "-priority"; - const char singlePuzzleString[] = "-SP"; - const char noSoundAtAll[] = "-nosound"; - const char verbose[] = "-v"; - if (strequals(argv[argumentNr],helpString)) { - cout << "Block Attack Help" << endl << helpString << " " << _("Displays this message") << - endl << "-priority " << _("Starts game in high priority") << endl << - "-nosound " << _("No sound will be played at all, and sound hardware will not be loaded (use this if game crashes because of sound)") << endl; -#ifdef WIN32 - system("Pause"); -#endif - return 0; - } - if (strequals(argv[argumentNr],priorityString)) { - if (verboseLevel) { - cout << "Priority mode" << endl; - } - highPriority = true; - } - if (strequals(argv[argumentNr],singlePuzzleString)) { - singlePuzzle = true; //We will just have one puzzle - if (argv[argumentNr+1][1]!=0) { - singlePuzzleNr = (argv[argumentNr+1][1]-'0')+(argv[argumentNr+1][0]-'0')*10; - } - else { - singlePuzzleNr = (argv[argumentNr+1][0]-'0'); - } - singlePuzzleFile = argv[argumentNr+2]; - argumentNr+=2; - if (verboseLevel) { - cout << "SinglePuzzleMode, File: " << singlePuzzleFile << " and Level: " << singlePuzzleNr << endl; - } - } - if (strequals(argv[argumentNr],noSoundAtAll)) { - NoSound = true; - } - if (strequals(argv[argumentNr],verbose)) { - verboseLevel++; - } - argumentNr++; - } //while - } //if + boost::program_options::options_description desc("Allowed options"); + desc.add_options() + ("help,h", _("Displays this message")) + ("nosound", _("Disables the sound. Can be used if sound gives you programs starting")) + ("priority", _("Causes the game to not sleep between frames.")) + ("verbose-basic", _("Enables basic verbose messages")) + ; + boost::program_options::variables_map vm; + boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); + boost::program_options::notify(vm); + if (vm.count("help")) { + cout << desc << endl; + return 1; + } + if (vm.count("nosound")) { + NoSound = true; + } + if (vm.count("priority")) { + highPriority = true; + } + if (vm.count("verbose-basic")) { + verboseLevel++; + } SoundEnabled = true; MusicEnabled = true;