From 854228e91b5edb703d1f88c7f9931585c8b0bbdf Mon Sep 17 00:00:00 2001 From: Daniel Evans Date: Fri, 30 Jan 2015 10:04:25 +0000 Subject: [PATCH] Re-implement -w and -h window size arguments --- rwgame/RWGame.cpp | 14 +++++++++++++- rwgame/RWGame.hpp | 2 +- rwgame/main.cpp | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index decc2ee1..5faf6ad6 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -15,7 +15,7 @@ DebugDraw* debug; -RWGame::RWGame(const std::string& gamepath) +RWGame::RWGame(const std::string& gamepath, int argc, char* argv[]) : engine(nullptr), inFocus(true), accum(0.f), timescale(1.f) { @@ -25,6 +25,18 @@ RWGame::RWGame(const std::string& gamepath) size_t w = GAME_WINDOW_WIDTH, h = GAME_WINDOW_HEIGHT; + for( int i = 1; i < argc; ++i ) + { + if( strcasecmp( "-w", argv[i] ) == 0 && i+1 < argc ) + { + w = std::atoi(argv[i+1]); + } + if( strcasecmp( "-h", argv[i] ) == 0 && i+1 < argc ) + { + h = std::atoi(argv[i+1]); + } + } + sf::ContextSettings cs; cs.depthBits = 32; window.create(sf::VideoMode(w, h), "", sf::Style::Default, cs); diff --git a/rwgame/RWGame.hpp b/rwgame/RWGame.hpp index 5351a99e..76fb71e2 100644 --- a/rwgame/RWGame.hpp +++ b/rwgame/RWGame.hpp @@ -19,7 +19,7 @@ class RWGame sf::Font font; public: - RWGame(const std::string& gamepath); + RWGame(const std::string& gamepath, int argc, char* argv[]); ~RWGame(); int run(); diff --git a/rwgame/main.cpp b/rwgame/main.cpp index bac6b0c4..797a7693 100644 --- a/rwgame/main.cpp +++ b/rwgame/main.cpp @@ -12,7 +12,7 @@ std::string getGamePath() int main(int argc, char *argv[]) { - RWGame game(getGamePath()); + RWGame game( getGamePath(), argc, argv ); return game.run(); }