Author: zaroth
Date: Thu Jun  9 11:52:55 2011
New Revision: 49813

URL: http://svn.gna.org/viewcvs/wesnoth?rev=49813&view=rev
Log:
Added debug-dot-domain, debug-dot-level, server, test options to
commandline_options.

Modified:
    trunk/src/commandline_options.cpp
    trunk/src/commandline_options.hpp
    trunk/src/game_controller.cpp
    trunk/src/tests/test_commandline_options.cpp

Modified: trunk/src/commandline_options.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/commandline_options.cpp?rev=49813&r1=49812&r2=49813&view=diff
==============================================================================
--- trunk/src/commandline_options.cpp (original)
+++ trunk/src/commandline_options.cpp Thu Jun  9 11:52:55 2011
@@ -94,7 +94,7 @@
        screenshot_map_file(),
        screenshot_output_file(),
        smallgui(false),
-       test(false),
+       test(),
        validcache(false),
        version(false),
        windowed(false),
@@ -113,6 +113,10 @@
                ("config-path", "prints the path of the user config directory 
and exits.")
                ("data-dir", po::value<std::string>(), "overrides the data 
directory with the one specified.")
                ("debug,d", "enables additional command mode options in-game.")
+#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
+               ("debug-dot-level", po::value<std::string>(), "sets the level 
of the debug dot files. <arg> should be a comma separated list of levels. These 
files are used for debugging the widgets especially the for the layout engine. 
When enabled the engine will produce dot files which can be converted to images 
with the dot tool. Available levels: size (generate the size info of the 
widget), state (generate the state info of the widget).")
+               ("debug-dot-domain", po::value<std::string>(), "sets the domain 
of the debug dot files. <arg> should be a comma separated list of domains. See 
--debug-dot-level for more info. Available domains: show (generate the data 
when the dialog is about to be shown), layout (generate the data during the 
layout phase - might result in multiple files). The data can also be generated 
when the F12 is pressed in a dialog.")
+#endif
                ("gunzip", po::value<std::string>(), "decompresses a file 
(<arg>.gz) in gzip format and stores it without the .gz suffix. <arg>.gz will 
be removed.")
                ("gzip", po::value<std::string>(), "compresses a file (<arg>) 
in gzip format, stores it as <arg>.gz and removes <arg>.")
                ("help,h", "prints this message and exits.")
@@ -122,6 +126,8 @@
                ("path", "prints the path to the data directory and exits.")
                ("rng-seed", po::value<unsigned int>(), "seeds the random 
number generator with number <arg>. Example: --rng-seed 0")
                ("screenshot", po::value<two_strings>()->multitoken(), "takes 
two arguments: <map> <output>. Saves a screenshot of <map> to <output> without 
initializing a screen. Editor must be compiled in for this to work.")
+               ("server,s", 
po::value<std::string>()->implicit_value(std::string()), "connects to the host 
<arg> if specified or to the first host in your preferences.")
+               ("test,t", 
po::value<std::string>()->implicit_value(std::string()), "runs the game in a 
small test scenario. If specified, scenario <arg> will be used instead.")
                ("validcache", "assumes that the cache is valid. (dangerous)")
                ("version,v", "prints the game's version number and exits.")
                ("with-replay", "replays the file loaded with the --load 
option.")
@@ -185,6 +191,12 @@
                data_dir = vm["data-dir"].as<std::string>();
        if (vm.count("debug"))
                debug = true;
+#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
+       if (vm.count("debug-dot-domain")
+               debug_dot_domain = vm["debug-dot-domain"].as<std::string>();
+       if (vm.count("debug-dot-level")
+               debug_dot_domain = vm["debug-dot-level"].as<std::string>();
+#endif
        if (vm.count("fps"))
                fps = true;
        if (vm.count("fullscreen"))
@@ -245,6 +257,10 @@
                screenshot_map_file = 
vm["screenshot"].as<two_strings>().get<0>();
                screenshot_output_file = 
vm["screenshot"].as<two_strings>().get<1>();
        }
+       if (vm.count("server"))
+               server = vm["server"].as<std::string>();
+       if (vm.count("test"))
+               test = vm["test"].as<std::string>();
        if (vm.count("smallgui"))
                smallgui = true;
        if (vm.count("validcache"))

Modified: trunk/src/commandline_options.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/commandline_options.hpp?rev=49813&r1=49812&r2=49813&view=diff
==============================================================================
--- trunk/src/commandline_options.hpp (original)
+++ trunk/src/commandline_options.hpp Thu Jun  9 11:52:55 2011
@@ -50,10 +50,10 @@
        /// True if --debug was given on the command line. Enables debug mode.
        bool debug;
 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
+       /// Non-empty if --debug-dot-domain was given on the command line.
+       boost::optional<std::string> debug_dot_domain;
        /// Non-empty if --debug-dot-level was given on the command line.
        boost::optional<std::string> debug_dot_level;
-       /// Non-empty if --debug-dot-domain was given on the command line.
-       boost::optional<std::string> debug_dot_domain;
 #endif
        /// Non-empty if --editor was given on the command line. Goes directly 
into editor. If string is longer than 0, it contains path to the file to edit.
        boost::optional<std::string> editor;
@@ -148,8 +148,8 @@
        boost::optional<std::string> screenshot_output_file;
        /// True if --smallgui was given on the command line. Makes Wesnoth use 
small gui layout.
        bool smallgui;
-       /// True if --test was given on the command line. Goes directly into 
test mode.
-       bool test;
+       /// Non-empty if --test was given on the command line. Goes directly 
into test mode, into a scenario, if specified.
+       boost::optional<std::string> test;
        /// True if --validcache was given on the command line. Makes Wesnoth 
assume the cache is valid.
        bool validcache;
        /// True if --version was given on the command line. Prints version and 
exits.

Modified: trunk/src/game_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_controller.cpp?rev=49813&r1=49812&r2=49813&view=diff
==============================================================================
--- trunk/src/game_controller.cpp (original)
+++ trunk/src/game_controller.cpp Thu Jun  9 11:52:55 2011
@@ -127,6 +127,12 @@
                int severity = 3;
                lg::set_log_domain_severity(s, severity);
        }
+#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
+       if (cmdline_opts_.debug_dot_domain)
+               gui2::tdebug_layout_graph::set_domain 
(*cmdline_opts_.debug_dot_domain);
+       if (cmdline_opts_.debug_dot_level)
+               gui2::tdebug_layout_graph::set_level 
(*cmdline_opts_.debug_dot_level);
+#endif
        if (cmdline_opts_.fps)
                preferences::set_show_fps(true);
        if (cmdline_opts_.fullscreen)
@@ -180,8 +186,27 @@
                preferences::disable_preferences_save();
                force_bpp_ = 32;
        }
+       if (cmdline_opts_.server){
+               jump_to_multiplayer_ = true;
+               //Do we have any server specified ?
+               if (!cmdline_opts_.server->empty())
+                       multiplayer_server_ = *cmdline_opts_.server;
+               else //Pick the first server in config
+               {
+                       if (game_config::server_list.size() > 0)
+                               multiplayer_server_ = 
preferences::network_host();
+                       else
+                               multiplayer_server_ = "";
+               }
+       }
        if (cmdline_opts_.smallgui)
                game_config::small_gui = true;
+       if (cmdline_opts_.test)
+       {
+               test_mode_ = true;
+               if (!cmdline_opts_.test->empty())
+                       test_scenario_ = *cmdline_opts_.test;
+       }
        if (cmdline_opts_.validcache)
                cache_.set_force_valid_cache(true);
        if (cmdline_opts_.windowed)
@@ -220,35 +245,6 @@
                                jump_to_campaign_.scenario_id_ = 
std::string(argv_[arg_]);
                                std::cerr<<"selected scenario id: 
["<<jump_to_campaign_.scenario_id_<<"]\n";
                        }
-               } else if(val == "--server" || val == "-s"){
-                       jump_to_multiplayer_ = true;
-                       //Do we have any server specified ?
-                       if(argc_ > arg_+1){
-                               multiplayer_server_ = argv_[arg_+1];
-                               ++arg_;
-                       //Pick the first server in config
-                       }else{
-                               if(game_config::server_list.size() > 0)
-                                       multiplayer_server_ = 
preferences::network_host();
-                               else
-                                       multiplayer_server_ = "";
-                       }
-
-               } else if(val == "--test" || val == "-t") {
-                       test_mode_ = true;
-                       // If we have -t foo it's ambiguous whether it foo is 
the parameter
-                       // for Wesnoth or the start directory so we assume it's 
the starting
-                       // directory.
-                       if(arg_ + 2 < argc_ && argv_[arg_ + 1][0] != '-') {
-                               ++arg_;
-                               test_scenario_ = argv_[arg_];
-                       }
-#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
-                } else if (val.substr(0, 18) == "--debug-dot-level=") {
-                        gui2::tdebug_layout_graph::set_level(val.substr(18));
-                } else if (val.substr(0, 19) == "--debug-dot-domain=") {
-                        gui2::tdebug_layout_graph::set_domain(val.substr(19));
-#endif
                } else if(val == "--no-delay") {
                        game_config::no_delay = true;
                } else if (val.substr(0, 6) == "--log-") {

Modified: trunk/src/tests/test_commandline_options.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/test_commandline_options.cpp?rev=49813&r1=49812&r2=49813&view=diff
==============================================================================
--- trunk/src/tests/test_commandline_options.cpp (original)
+++ trunk/src/tests/test_commandline_options.cpp Thu Jun  9 11:52:55 2011
@@ -36,8 +36,8 @@
        BOOST_CHECK(!co.data_dir);
        BOOST_CHECK(!co.debug);
 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
+       BOOST_CHECK(!co.debug_dot_domain);
        BOOST_CHECK(!co.debug_dot_level);
-       BOOST_CHECK(!co.debug_dot_domain);
 #endif
        BOOST_CHECK(!co.editor);
        BOOST_CHECK(!co.fps);
@@ -99,7 +99,9 @@
        {
                "wesnoth",
                "--logdomains",
-               "--preprocess-output-macros"
+               "--preprocess-output-macros",
+               "--server",
+               "--test"
        };
        const int argc = sizeof(argv)/sizeof(const char *);
        commandline_options co(argc,const_cast<char**>(argv));
@@ -114,8 +116,8 @@
        BOOST_CHECK(!co.data_dir);
        BOOST_CHECK(!co.debug);
 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
+       BOOST_CHECK(!co.debug_dot_domain);
        BOOST_CHECK(!co.debug_dot_level);
-       BOOST_CHECK(!co.debug_dot_domain);
 #endif
        BOOST_CHECK(!co.editor);
        BOOST_CHECK(!co.fps);
@@ -158,12 +160,12 @@
        BOOST_CHECK(!co.proxy_user);
        BOOST_CHECK(!co.resolution);
        BOOST_CHECK(!co.rng_seed);
-       BOOST_CHECK(!co.server);
+       BOOST_CHECK(co.server && co.server->empty());
        BOOST_CHECK(!co.screenshot);
        BOOST_CHECK(!co.screenshot_map_file);
        BOOST_CHECK(!co.screenshot_output_file);
        BOOST_CHECK(!co.smallgui);
-       BOOST_CHECK(!co.test);
+       BOOST_CHECK(co.test && co.test->empty());
        BOOST_CHECK(!co.validcache);
        BOOST_CHECK(!co.version);
        BOOST_CHECK(!co.windowed);
@@ -182,6 +184,10 @@
                "--config-path",
                "--data-dir=datadirfoo",
                "--debug",
+#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
+               "--debug-dot-domain=ddfoo",
+               "--debug-dot-level=dlfoo",
+#endif
                "--fps",
                "--fullscreen",
                "--gunzip=gunzipfoo.gz",
@@ -208,7 +214,9 @@
                "--resolution=800x600",
                "--rng-seed=1234",
                "--screenshot", "mapfoo", "outssfoo",
+               "--server=servfoo",
                "--smallgui",
+               "--test=testfoo",
                "--validcache",
                "--version",
                "--windowed",
@@ -227,8 +235,8 @@
        BOOST_CHECK(co.data_dir && *co.data_dir == "datadirfoo");
        BOOST_CHECK(co.debug);
 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
-       BOOST_CHECK(!co.debug_dot_level);
-       BOOST_CHECK(!co.debug_dot_domain);
+       BOOST_CHECK(co.debug_dot_domain && *co.debug_dot_domain == "ddfoo");
+       BOOST_CHECK(co.debug_dot_level && *co.debug_dot_level == "dlfoo");
 #endif
        BOOST_CHECK(!co.editor);
        BOOST_CHECK(co.fps);
@@ -284,11 +292,11 @@
        BOOST_CHECK(co.resolution);
        BOOST_CHECK(co.resolution->get<0>() == 800 && co.resolution->get<1>() 
== 600);
        BOOST_CHECK(co.rng_seed && *co.rng_seed == 1234);
-       BOOST_CHECK(!co.server);
+       BOOST_CHECK(co.server && *co.server == "servfoo");
        BOOST_CHECK(co.screenshot && co.screenshot_map_file && 
co.screenshot_output_file);
        BOOST_CHECK(*co.screenshot_map_file == "mapfoo" && 
*co.screenshot_output_file == "outssfoo");
        BOOST_CHECK(co.smallgui);
-       BOOST_CHECK(!co.test);
+       BOOST_CHECK(co.test && *co.test == "testfoo");
        BOOST_CHECK(co.validcache);
        BOOST_CHECK(co.version);
        BOOST_CHECK(co.windowed);


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to