Author: alink
Date: Sun Jul 13 02:24:26 2008
New Revision: 27965

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27965&view=rev
Log:
Add a new debug command ":choose_level" or ":cn" to open a simple menu with all
scenario's id. Works better with nice and clear id (using number).
Next scenario is pre-selected.

Modified:
    trunk/changelog
    trunk/src/menu_events.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=27965&r1=27964&r2=27965&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Jul 13 02:24:26 2008
@@ -54,8 +54,9 @@
    * In multiplayer lobby, all unit's images are now team colored.
    * In help, with debug mode, broken hyperlinks are now visible in red and
      when clicked open a error message showing the bad topic reference.
+   * new debug command ":choose_level" or ":cn" to directly go to a scenario.
    * new debug command feature, ":next_level Some_Id" to directly go to
-     scenario having id=Some_Id. Also allow to go backwards in campaign. 
+     scenario having id=Some_Id.
  * multiplayer:
    * Added support for multiple sides per client in MP start
    * Added support for reserving slots when reloading game

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=27965&r1=27964&r2=27965&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Sun Jul 13 02:24:26 2008
@@ -2164,6 +2164,7 @@
                        void do_ignore_replay_errors();
                        void do_nosaves();
                        void do_next_level();
+                       void do_choose_level();
                        void do_debug();
                        void do_nodebug();
                        void do_custom();
@@ -2236,6 +2237,9 @@
                                register_command("next_level", 
&console_handler::do_next_level,
                                        _("Advance to the next scenario, or 
scenario identified by 'id'"), "<id>", "D");
                                register_alias("next_level", "n");
+                               register_command("choose_level", 
&console_handler::do_choose_level,
+                                       _("Choose next scenario"), "", "D");
+                               register_alias("choose_level", "cn");
                                register_command("debug", 
&console_handler::do_debug,
                                        _("Turn debug mode on."));
                                register_command("nodebug", 
&console_handler::do_nodebug,
@@ -2658,6 +2662,31 @@
                        menu_handler_.gamestate_.next_scenario = get_data();
                throw end_level_exception(LEVEL_CONTINUE_NO_SAVE);
        }
+       void console_handler::do_choose_level() {
+               std::vector<std::string> options;
+               int next = 0;
+               const config::child_list& scenarios =
+                       menu_handler_.game_config_.get_children("scenario");
+               for (config::child_list::const_iterator i = scenarios.begin(),
+                       i_end = scenarios.end(); i != i_end; ++i) {
+                   const std::string id = (**i)["id"];
+                   options.push_back(id);
+                       if (id == menu_handler_.gamestate_.next_scenario)
+                       next = i - scenarios.begin();
+               }
+               int choice = 0;
+               {
+                       gui::dialog menu(*menu_handler_.gui_, _("Choose 
Scenario (Debug!)"), "", gui::OK_CANCEL);
+                       menu.set_menu(options);
+                       menu.get_menu().move_selection(next);
+                       choice = menu.show();
+               }
+
+               if (size_t(choice) < options.size()) {
+                       menu_handler_.gamestate_.next_scenario = 
options[choice];
+                       throw end_level_exception(LEVEL_CONTINUE_NO_SAVE);
+               }
+       }
        void console_handler::do_debug() {
                if (network::nconnections() == 0) {
                        print(get_cmd(), _("Debug mode activated!"));


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

Reply via email to