mail[Wesnoth-commits] r25276 - in /trunk: data/core/ src/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by soliton . de on March 29, 2008 - 12:18:
Author: soliton
Date: Sat Mar 29 12:18:09 2008
New Revision: 25276

URL: http://svn.gna.org/viewcvs/wesnoth?rev=25276&view=rev
Log:
* committed patch #1024: "Optionally cancel unit orders (goto location) on 
load game" by ilor

Modified:
    trunk/data/core/about.cfg
    trunk/src/dialogs.cpp
    trunk/src/dialogs.hpp
    trunk/src/game.cpp
    trunk/src/game_errors.hpp
    trunk/src/menu_events.cpp
    trunk/src/multiplayer_connect.cpp
    trunk/src/play_controller.cpp

Modified: trunk/data/core/about.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/core/about.cfg?rev=25276&r1=25275&r2=25276&view=diff
==============================================================================
--- trunk/data/core/about.cfg (original)
+++ trunk/data/core/about.cfg Sat Mar 29 12:18:09 2008
@@ -653,6 +653,10 @@
         wikiuser = "ShikadiLord"
     [/entry]
     [entry]
+        name = "ilor"
+        comment = "option to cancel goto orders on load"
+    [/entry]
+    [entry]
         name = "J.R. Blain (Cowboy)"
     [/entry]
     [entry]

Modified: trunk/src/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/dialogs.cpp?rev=25276&r1=25275&r2=25276&view=diff
==============================================================================
--- trunk/src/dialogs.cpp (original)
+++ trunk/src/dialogs.cpp Sat Mar 29 12:18:09 2008
@@ -628,7 +628,7 @@
 
 } // end anon namespace
 
-std::string load_game_dialog(display& disp, const config& game_config, const 
game_data& data, bool* show_replay)
+std::string load_game_dialog(display& disp, const config& game_config, const 
game_data& data, bool* show_replay, bool* cancel_orders)
 {
        std::vector<save_info> games;
        {
@@ -689,6 +689,13 @@
                        lmenu.add_option(_("Show replay"), false);
                #endif
        }
+       if(cancel_orders != NULL) {
+               #ifdef USE_SMALL_GUI
+                       lmenu.add_option(_("Cancel orders"), false, 
gui::dialog::BUTTON_STANDARD);
+               #else
+                       lmenu.add_option(_("Cancel orders"), false);
+               #endif
+       }
        lmenu.add_button(new 
gui::standard_dialog_button(disp.video(),_("OK"),0,false), 
gui::dialog::BUTTON_STANDARD);
        lmenu.add_button(new 
gui::standard_dialog_button(disp.video(),_("Cancel"),1,true), 
gui::dialog::BUTTON_STANDARD);
 
@@ -711,12 +718,15 @@
        res = filter->get_save_index(res);
 
        if(show_replay != NULL) {
-         *show_replay = lmenu.option_checked();
+         *show_replay = lmenu.option_checked(0);
 
                const config& summary = *summaries[res];
                if(utils::string_bool(summary["replay"], false) && 
!utils::string_bool(summary["snapshot"], true)) {
                        *show_replay = true;
                }
+       }
+       if (cancel_orders != NULL) {
+               *cancel_orders = lmenu.option_checked(1);
        }
 
        return games[res].name;

Modified: trunk/src/dialogs.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/dialogs.hpp?rev=25276&r1=25275&r2=25276&view=diff
==============================================================================
--- trunk/src/dialogs.hpp (original)
+++ trunk/src/dialogs.hpp Sat Mar 29 12:18:09 2008
@@ -64,7 +64,7 @@
 //of the save they want to load. Stores whether the user wants to show
 //a replay of the game in show_replay. If show_replay is NULL, then
 //the user will not be asked if they want to show a replay.
-std::string load_game_dialog(display& disp, const config& terrain_config, 
const game_data& data, bool* show_replay);
+std::string load_game_dialog(display& disp, const config& terrain_config, 
const game_data& data, bool* show_replay, bool* cancel_orders);
 
 class unit_preview_pane : public gui::preview_pane
 {

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=25276&r1=25275&r2=25276&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Sat Mar 29 12:18:09 2008
@@ -179,6 +179,7 @@
 
        std::string loaded_game_;
        bool loaded_game_show_replay_;
+       bool loaded_game_cancel_orders_;
 
        preproc_map defines_map_, old_defines_map_;
 };
@@ -187,7 +188,8 @@
    : argc_(argc), arg_(1), argv_(argv), thread_manager(),
      test_scenario_("test"), test_mode_(false), multiplayer_mode_(false),
      no_gui_(false), use_caching_(true), force_valid_cache_(false),
-     force_bpp_(-1), disp_(NULL), loaded_game_show_replay_(false)
+     force_bpp_(-1), disp_(NULL), loaded_game_show_replay_(false),
+     loaded_game_cancel_orders_(false)
 {
        bool no_sound = false;
        for(arg_ = 1; arg_ != argc_; ++arg_) {
@@ -502,6 +504,7 @@
        } catch(game::load_game_exception& e) {
                loaded_game_ = e.game;
                loaded_game_show_replay_ = e.show_replay;
+               loaded_game_cancel_orders_ = e.cancel_orders;
                test_mode_ = false;
                return true;
        }
@@ -701,6 +704,7 @@
                //the user's trying to load a game, so go into the normal 
title screen loop and load one
                loaded_game_ = e.game;
                loaded_game_show_replay_ = e.show_replay;
+               loaded_game_cancel_orders_ = e.cancel_orders;
                return true;
        } catch(twml_exception& e) {
                e.show(disp());
@@ -722,8 +726,9 @@
        state_ = game_state();
 
        bool show_replay = loaded_game_show_replay_;
-
-       const std::string game = loaded_game_.empty() ? 
dialogs::load_game_dialog(disp(),game_config_,units_data_,&show_replay) : 
loaded_game_;
+       bool cancel_orders = loaded_game_cancel_orders_;
+
+       const std::string game = loaded_game_.empty() ? 
dialogs::load_game_dialog(disp(),game_config_,units_data_,&show_replay,&cancel_orders)
 : loaded_game_;
 
        loaded_game_ = "";
 
@@ -858,6 +863,19 @@
                    sides.first != sides.second; ++sides.first) {
                        if((**sides.first)["controller"] == "network")
                                (**sides.first)["controller"] = "human";
+               }
+       }
+       
+       if (cancel_orders) {
+               for(config::child_itors sides = 
state_.snapshot.child_range("side");
+                           sides.first != sides.second; ++sides.first) {
+                               if((**sides.first)["controller"] == "human") {
+                                       for (config::child_itors units = 
(**sides.first).child_range("unit");
+                                                       units.first != 
units.second; ++units.first) {
+                                               (**units.first)["goto_x"] = 
"-999";
+                                               (**units.first)["goto_y"] = 
"-999";
+                                       }
+                               }
                }
        }
 
@@ -1571,6 +1589,7 @@
                //this will make it so next time through the title screen 
loop, this game is loaded
                loaded_game_ = e.game;
                loaded_game_show_replay_ = e.show_replay;
+               loaded_game_cancel_orders_ = e.cancel_orders;
        } catch(twml_exception& e) {
                e.show(disp());
        }
@@ -1935,6 +1954,7 @@
                //this will make it so next time through the title screen 
loop, this game is loaded
                loaded_game_ = e.game;
                loaded_game_show_replay_ = e.show_replay;
+               loaded_game_cancel_orders_ = e.cancel_orders;
 
        } catch(twml_exception& e) {
                e.show(disp());
@@ -1955,6 +1975,7 @@
                //this will make it so next time through the title screen 
loop, this game is loaded
                loaded_game_ = e.game;
                loaded_game_show_replay_ = e.show_replay;
+               loaded_game_cancel_orders_ = e.cancel_orders;
 
        } catch(twml_exception& e) {
                e.show(disp());

Modified: trunk/src/game_errors.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_errors.hpp?rev=25276&r1=25275&r2=25276&view=diff
==============================================================================
--- trunk/src/game_errors.hpp (original)
+++ trunk/src/game_errors.hpp Sat Mar 29 12:18:09 2008
@@ -49,9 +49,11 @@
 //an exception object used to signal that the user has decided to abort
 //a game, and load another game instead
 struct load_game_exception {
-       load_game_exception(const std::string& game, bool show_replay) : 
game(game), show_replay(show_replay) {}
+       load_game_exception(const std::string& game, bool show_replay, bool 
cancel_orders) 
+       : game(game), show_replay(show_replay), cancel_orders(cancel_orders) 
{}
        std::string game;
        bool show_replay;
+       bool cancel_orders;
 };
 }
 

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=25276&r1=25275&r2=25276&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Sat Mar 29 12:18:09 2008
@@ -889,9 +889,10 @@
 
        void menu_handler::load_game(){
                bool show_replay = false;
-               const std::string game = dialogs::load_game_dialog(*gui_, 
game_config_, gameinfo_, &show_replay);
+               bool cancel_orders = false;
+               const std::string game = dialogs::load_game_dialog(*gui_, 
game_config_, gameinfo_, &show_replay, &cancel_orders);
                if(game != "") {
-                       throw game::load_game_exception(game,show_replay);
+                       throw 
game::load_game_exception(game,show_replay,cancel_orders);
                }
        }
 

Modified: trunk/src/multiplayer_connect.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_connect.cpp?rev=25276&r1=25275&r2=25276&view=diff
==============================================================================
--- trunk/src/multiplayer_connect.cpp (original)
+++ trunk/src/multiplayer_connect.cpp Sat Mar 29 12:18:09 2008
@@ -1409,8 +1409,11 @@
 {
        if(params_.saved_game) {
                bool show_replay = false;
+               //bool cancel_orders = false;
                const std::string game = dialogs::load_game_dialog(disp(), 
-                                                                
game_config(), game_data_, &show_replay);
+                                                                
game_config(), game_data_, &show_replay, 
+                                                                NULL);
+                                                                
                if(game.empty()) {
                        set_result(CREATE);
                        return;

Modified: trunk/src/play_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=25276&r1=25275&r2=25276&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Sat Mar 29 12:18:09 2008
@@ -472,7 +472,7 @@
                unsigned i = static_cast<unsigned>(index);
                if(i < savenames_.size() && !savenames_[i].empty()) {
                        // Load the game by throwing load_game_exception
-                       throw game::load_game_exception(savenames_[i],false);
+                       throw 
game::load_game_exception(savenames_[i],false,false);
 
                } else if (i < wml_commands_.size() && wml_commands_[i] != 
NULL) {
                        if(gamestate_.last_selected.valid() && 
wml_commands_[i]->needs_select) {




Related Messages


Powered by MHonArc, Updated Sat Mar 29 12:41:18 2008