mail[Wesnoth-commits] r44194 - in /trunk/src: play_controller.cpp whiteboard/manager.cpp whiteboard/manager.hpp


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

Header


Content

Posted by gabrielmorin on July 15, 2010 - 22:48:
Author: gabba
Date: Thu Jul 15 22:48:44 2010
New Revision: 44194

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44194&view=rev
Log:
Activate and deactivate the whiteboard at the proper time.

Modified:
    trunk/src/play_controller.cpp
    trunk/src/whiteboard/manager.cpp
    trunk/src/whiteboard/manager.hpp

Modified: trunk/src/play_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=44194&r1=44193&r2=44194&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Thu Jul 15 22:48:44 2010
@@ -517,6 +517,8 @@
        gamestate_.get_variable("side_number") = player_number_;
        gamestate_.last_selected = map_location::null_location;
 
+       resources::whiteboard->init_side();
+
        /**
         * We do this only for local side when we are not replaying.
         * For all other sides it is recorded in replay and replay handler 
has to handle calling do_init_side()
@@ -649,6 +651,9 @@
 }
 
 void play_controller::finish_side_turn(){
+
+       resources::whiteboard->finish_side_turn();
+
        for(unit_map::iterator uit = units_.begin(); uit != units_.end(); 
++uit) {
                if (uit->side() == player_number_)
                        uit->end_turn();

Modified: trunk/src/whiteboard/manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=44194&r1=44193&r2=44194&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Thu Jul 15 22:48:44 2010
@@ -50,6 +50,7 @@
 
 manager::manager():
                active_(false),
+               wait_for_side_init_(true),
                mapbuilder_(),
                highlighter_(),
                route_(),
@@ -75,9 +76,29 @@
                current_actions()->validate_actions();
 }
 
+void manager::init_side()
+{
+       if (active_)
+       {
+                       current_actions()->validate_actions();
+                       highlighter_.reset(new 
highlight_visitor(*resources::units, current_actions()));
+       }
+
+       wait_for_side_init_ = false;
+}
+
+void manager::finish_side_turn()
+{
+       wait_for_side_init_ = true;
+
+       highlighter_.reset();
+       erase_temp_move();
+
+}
+
 void manager::set_planned_unit_map()
 {
-       if (active_ && !modifying_actions_)
+       if (active_ && !modifying_actions_ && !wait_for_side_init_)
        {
                modifying_actions_ = true;
                //TODO: enable back this assert, after modifying the mouse 
code that triggers it constantly
@@ -99,7 +120,7 @@
 
 void manager::set_real_unit_map()
 {
-       if (active_ && !modifying_actions_)
+       if (active_ && !modifying_actions_ && !wait_for_side_init_)
        {
                modifying_actions_ = true;
                if (planned_unit_map_active_)
@@ -118,17 +139,15 @@
 
 void manager::draw_hex(const map_location& hex)
 {
-       current_actions()->draw_hex(hex);
+       if (active_ && !wait_for_side_init_)
+               current_actions()->draw_hex(hex);
 }
 
 void manager::on_mouseover_change(const map_location& hex)
 {
-       if (!active_)
-               return;
-
        //FIXME: Detect if a WML event is executing, and if so, avoid 
modifying the unit map during that time.
        // Acting otherwise causes a crash.
-       if (active_ && !selected_unit_)
+       if (active_ && !selected_unit_ && highlighter_)
        {
                highlighter_->set_mouseover_hex(hex);
                highlighter_->highlight();

Modified: trunk/src/whiteboard/manager.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.hpp?rev=44194&r1=44193&r2=44194&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.hpp (original)
+++ trunk/src/whiteboard/manager.hpp Thu Jul 15 22:48:44 2010
@@ -52,6 +52,9 @@
         */
        bool is_active() const { return active_; }
        void set_active(bool active);
+
+       void init_side();
+       void finish_side_turn();
 
        /**
         * Temporarily apply the effects of the current team's
@@ -112,6 +115,7 @@
         * Tracks whether the whiteboard is active.
         */
        bool active_;
+       bool wait_for_side_init_;
 
        boost::scoped_ptr<mapbuilder_visitor> mapbuilder_;
        boost::scoped_ptr<highlight_visitor> highlighter_;




Related Messages


Powered by MHonArc, Updated Thu Jul 15 23:00:11 2010