mail[Wesnoth-commits] r13756 - in /trunk/src: play_controller.cpp play_controller.hpp playmp_controller.cpp playsingle_controller.cpp


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

Header


Content

Posted by edb on September 30, 2006 - 19:44:
Author: edb
Date: Sat Sep 30 19:44:27 2006
New Revision: 13756

URL: http://svn.gna.org/viewcvs/wesnoth?rev=13756&view=rev
Log:
update gui after control transfert to match an human side

Modified:
    trunk/src/play_controller.cpp
    trunk/src/play_controller.hpp
    trunk/src/playmp_controller.cpp
    trunk/src/playsingle_controller.cpp

Modified: trunk/src/play_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=13756&r1=13755&r2=13756&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Sat Sep 30 19:44:27 2006
@@ -516,6 +516,29 @@
        menu_handler_.get_textbox().close(*gui_);
 }
 
+int play_controller::find_human_team_before(const size_t team_num) const
+{
+       if (team_num > teams_.size())
+               return -2;
+
+       int human_side = -2;
+       for (int i = team_num-2; i > -1; --i) {
+               if (teams_[i].is_human()) {
+                       human_side = i;
+                       break;
+               }
+       }
+       if (human_side == -2) {
+               for (size_t i = teams_.size()-1; i > team_num-1; --i) {
+                       if (teams_[i].is_human()) {
+                               human_side = i;
+                               break;
+                       }
+               }
+       }
+       return human_side+1;
+}
+
 void play_controller::handle_event(const SDL_Event& event)
 {
        if(gui::in_dialog()) {

Modified: trunk/src/play_controller.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.hpp?rev=13756&r1=13755&r2=13756&view=diff
==============================================================================
--- trunk/src/play_controller.hpp (original)
+++ trunk/src/play_controller.hpp Sat Sep 30 19:44:27 2006
@@ -98,6 +98,8 @@
        team& current_team() { return teams_[player_number_-1]; }
        const team& current_team() const { return teams_[player_number_-1]; }
 
+       int find_human_team_before(const size_t team) const;
+
        //managers
        const verification_manager verify_manager_;
        teams_manager team_manager_;

Modified: trunk/src/playmp_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playmp_controller.cpp?rev=13756&r1=13755&r2=13756&view=diff
==============================================================================
--- trunk/src/playmp_controller.cpp (original)
+++ trunk/src/playmp_controller.cpp Sat Sep 30 19:44:27 2006
@@ -68,8 +68,21 @@
                        play_human_turn();
                        after_human_turn();
                } catch(end_turn_exception& end_turn) {
-                       if (end_turn.redo == team_index)
+                       if (end_turn.redo == team_index) {
                                player_type_changed_ = true;
+                               // if new controller is not human,
+                               // reset gui to prev human one
+                               if (!teams_[team_index-1].is_human()) {
+                                       int t = 
find_human_team_before(team_index);
+                                       if (t) {
+                                               gui_->set_team(t-1);
+                                               gui_->recalculate_minimap();
+                                               gui_->invalidate_all();
+                                               gui_->draw();
+                                               gui_->update_display();
+                                       }
+                               }
+                       }
                }
                LOG_NG << "human finished turn...\n";
        } else if(current_team().is_ai()) {

Modified: trunk/src/playsingle_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=13756&r1=13755&r2=13756&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Sat Sep 30 19:44:27 2006
@@ -417,8 +417,21 @@
                        play_human_turn();
                        after_human_turn();
                } catch(end_turn_exception& end_turn) {
-                       if (end_turn.redo == team_index)
+                       if (end_turn.redo == team_index) {
                                player_type_changed_ = true;
+                               // if new controller is not human,
+                               // reset gui to prev human one
+                               if (!teams_[team_index-1].is_human()) {
+                                       int t = 
find_human_team_before(team_index);
+                                       if (t) {
+                                               gui_->set_team(t-1);
+                                               gui_->recalculate_minimap();
+                                               gui_->invalidate_all();
+                                               gui_->draw();
+                                               gui_->update_display();
+                                       }
+                               }
+                       }
                }
 
                if(game_config::debug)




Related Messages


Powered by MHonArc, Updated Sat Sep 30 20:00:37 2006