mail[Wesnoth-commits] r43704 - in /trunk/src: mouse_events.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 June 24, 2010 - 23:47:
Author: gabba
Date: Thu Jun 24 23:47:52 2010
New Revision: 43704

URL: http://svn.gna.org/viewcvs/wesnoth?rev=43704&view=rev
Log:
Whiteboard: renamed methods in the manager

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

Modified: trunk/src/mouse_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.cpp?rev=43704&r1=43703&r2=43704&view=diff
==============================================================================
--- trunk/src/mouse_events.cpp (original)
+++ trunk/src/mouse_events.cpp Thu Jun 24 23:47:52 2010
@@ -95,7 +95,7 @@
 void mouse_handler::mouse_motion(int x, int y, const bool browse, bool 
update)
 {
        if (attackmove_) return;
-       if (resources::whiteboard->ignore_mouse_motion()) return;
+       if (resources::whiteboard->ignore_mouse()) return;
 
        // we ignore the position coming from event handler
        // because it's always a little obsolete and we don't need
@@ -128,9 +128,9 @@
                if (reachmap_invalid_) {
                        reachmap_invalid_ = false;
                        if (!current_paths_.destinations.empty() && 
!show_partial_move_) {
-                               resources::whiteboard->push_temp_modifiers();
+                               resources::whiteboard->set_planned_unit_map();
                                unit_map::iterator u = 
find_unit(selected_hex_);
-                               resources::whiteboard->pop_temp_modifiers();
+                               resources::whiteboard->set_real_unit_map();
                                if(selected_hex_.valid() && u != units_.end() 
) {
                                        // reselect the unit without firing 
events (updates current_paths_)
                                        select_hex(selected_hex_, true);
@@ -159,13 +159,13 @@
                gui().highlight_hex(new_hex);
                resources::whiteboard->mouseover_hex(new_hex);
 
-               resources::whiteboard->push_temp_modifiers();
+               resources::whiteboard->set_planned_unit_map();
                const unit_map::iterator selected_unit = 
find_unit(selected_hex_);
                const unit_map::iterator mouseover_unit = find_unit(new_hex);
 
                // we search if there is an attack possibility and where
                map_location attack_from = current_unit_attacks_from(new_hex);
-               resources::whiteboard->pop_temp_modifiers();
+               resources::whiteboard->set_real_unit_map();
 
                //see if we should show the normal cursor, the movement 
cursor, or
                //the attack cursor
@@ -200,7 +200,7 @@
                        gui().clear_attack_indicator();
                }
 
-               resources::whiteboard->push_temp_modifiers();
+               resources::whiteboard->set_planned_unit_map();
                // the destination is the pointed hex or the adjacent hex
                // used to attack it
                map_location dest;
@@ -263,7 +263,7 @@
                                over_route_ = true;
                        }
                }
-               resources::whiteboard->pop_temp_modifiers();
+               resources::whiteboard->set_real_unit_map();
        }
 }
 
@@ -411,7 +411,7 @@
        // the second open the context menu
        unit_map::iterator unit;
        {
-               wb::scoped_modifiers wb_modifiers;
+               wb::scoped_planned_unit_map wb_modifiers;
                unit = find_unit(selected_hex_);
        }
        if (selected_hex_.valid() && unit != units_.end()) {
@@ -426,7 +426,7 @@
 {
        undo_ = false;
        if (mouse_handler_base::left_click(x, y, browse)) return false;
-       if (resources::whiteboard->ignore_mouse_motion()) return false;
+       if (resources::whiteboard->ignore_mouse()) return false;
 
        bool check_shroud = current_team().auto_shroud_updates();
 
@@ -434,11 +434,11 @@
        //since it's what update our global state
        map_location hex = last_hex_;
 
-       resources::whiteboard->push_temp_modifiers();
+       resources::whiteboard->set_planned_unit_map();
 
        unit_map::iterator u = find_unit(selected_hex_);
 
-       resources::whiteboard->pop_temp_modifiers();
+       resources::whiteboard->set_real_unit_map();
 
        //if the unit is selected and then itself clicked on,
        //any goto command and waypoints are cancelled
@@ -449,11 +449,11 @@
        }
 
 
-       resources::whiteboard->push_temp_modifiers();
+       resources::whiteboard->set_planned_unit_map();
 
        unit_map::iterator clicked_u = find_unit(hex);
 
-       resources::whiteboard->pop_temp_modifiers();
+       resources::whiteboard->set_real_unit_map();
 
 
        const map_location src = selected_hex_;
@@ -565,16 +565,16 @@
        waypoints_.clear();
        show_partial_move_ = false;
 
-       resources::whiteboard->push_temp_modifiers();
+       resources::whiteboard->set_planned_unit_map();
 
        unit_map::iterator u = find_unit(hex);
 
-       resources::whiteboard->pop_temp_modifiers();
+       resources::whiteboard->set_real_unit_map();
 
 
        if (hex.valid() && u != units_.end() && !u->get_hidden()) {
 
-               resources::whiteboard->push_temp_modifiers();
+               resources::whiteboard->set_planned_unit_map();
 
                next_unit_ = u->get_location();
 
@@ -594,7 +594,7 @@
                enemy_paths_ = false;
                gui().set_route(NULL);
 
-               resources::whiteboard->pop_temp_modifiers();
+               resources::whiteboard->set_real_unit_map();
 
                // selection have impact only if we are not observing and 
it's our unit
                if (!browse && !commands_disabled && u->side() == 
gui().viewing_side()) {

Modified: trunk/src/whiteboard/manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=43704&r1=43703&r2=43704&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Thu Jun 24 23:47:52 2010
@@ -43,7 +43,7 @@
                fake_unit_(),
                selected_unit_(NULL),
                ignore_mouse_motion_(false),
-               stacked_modifiers_calls_(0)
+               planned_unit_map_(false)
 {
 }
 
@@ -63,49 +63,37 @@
        return side_actions;
 }
 
-void manager::push_temp_modifiers()
+void manager::set_planned_unit_map()
 {
        if (active_)
        {
-               if (stacked_modifiers_calls_ == 0)
+               assert (!planned_unit_map_);
+               if (!planned_unit_map_)
                {
                        mapbuilder_.reset(new 
mapbuilder_visitor(*resources::units));
                        const action_set& actions = 
get_current_side_actions()->actions();
+                       DBG_WB << "Building planned unit map.\n";
                        foreach (const action_ptr &action, actions)
                        {
                                assert(action);
                                action->accept(*mapbuilder_);
                        }
-               }
-               DBG_WB << "Increasing stacked modifiers calls count to " << 
stacked_modifiers_calls_ << "\n";
-               ++stacked_modifiers_calls_;
-       }
-}
-
-void manager::pop_temp_modifiers()
+                       planned_unit_map_ = true;
+               }
+       }
+}
+
+void manager::set_real_unit_map()
 {
        if (active_)
        {
-               if (stacked_modifiers_calls_ > 0)
-               {
-                       DBG_WB << "Decreasing stacked modifiers calls count 
to " << stacked_modifiers_calls_ << "\n";
-                       --stacked_modifiers_calls_;
-                       if (stacked_modifiers_calls_ == 0)
-                       {
-                               DBG_WB << "Removing temporary modifiers.\n";
-                               mapbuilder_.reset();
-                       }
-               }
-       }
-}
-
-void manager::clear_temp_modifiers()
-{
-       if (active_)
-       {
-               DBG_WB << "Removing temporary modifiers and erasing stack 
marker.\n";
-               stacked_modifiers_calls_ = 0;
-               mapbuilder_.reset();
+               assert (planned_unit_map_);
+               if (planned_unit_map_)
+               {
+                       DBG_WB << "Restoring regular unit map.\n";
+                       mapbuilder_.reset();
+                       planned_unit_map_ = false;
+               }
        }
 }
 
@@ -120,7 +108,7 @@
 
 void manager::highlight_hex(const map_location& hex)
 {
-       scoped_modifiers wb_modifiers;
+       scoped_planned_unit_map wb_modifiers;
 
        unit_map::iterator highlighted_unit = resources::units->find(hex);
 
@@ -242,10 +230,11 @@
                        << " to " << route_.back() << "\n";
        ignore_mouse_motion_ = true;
 
-       assert(!temp_modifiers_applied());
+       assert(!has_planned_unit_map());
        // Ghost either the real unit, or the fake unit of the last move of 
this unit if the move exists.
        bool action_found = false;
        const action_set& actions = get_current_side_actions()->actions();
+       //FIXME: could use a reverse iterator here
        action_set::const_iterator action;
        for (action = actions.end() - 1; ((action != actions.begin() - 1) && 
!action_found ); --action)
        {
@@ -264,7 +253,7 @@
                selected_unit_->set_ghosted(false);
        }
 
-       scoped_modifiers wb_modifiers;
+       scoped_planned_unit_map wb_modifiers;
 
        unit_display::move_unit(route_, *fake_unit_, *resources::teams, true);
        fake_unit_->set_standing(true);
@@ -289,6 +278,7 @@
 void manager::delete_last()
 {
        
get_current_side_actions()->remove_action(get_current_side_actions()->end() - 
1);
+       //TODO: restore "standing" animation on last remaining move of this 
unit
 }
 
 action_ptr manager::has_action(const unit& unit) const
@@ -298,24 +288,24 @@
        return action;
 }
 
-scoped_modifiers::scoped_modifiers()
-{
-       resources::whiteboard->push_temp_modifiers();
-}
-
-scoped_modifiers::~scoped_modifiers()
-{
-       resources::whiteboard->pop_temp_modifiers();
-}
-
-scoped_modifiers_remover::scoped_modifiers_remover()
-{
-       resources::whiteboard->pop_temp_modifiers();
-}
-
-scoped_modifiers_remover::~scoped_modifiers_remover()
-{
-       resources::whiteboard->push_temp_modifiers();
+scoped_planned_unit_map::scoped_planned_unit_map()
+{
+       resources::whiteboard->set_planned_unit_map();
+}
+
+scoped_planned_unit_map::~scoped_planned_unit_map()
+{
+       resources::whiteboard->set_real_unit_map();
+}
+
+scoped_real_unit_map::scoped_real_unit_map()
+{
+       resources::whiteboard->set_real_unit_map();
+}
+
+scoped_real_unit_map::~scoped_real_unit_map()
+{
+       resources::whiteboard->set_planned_unit_map();
 }
 
 } // end namespace wb

Modified: trunk/src/whiteboard/manager.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.hpp?rev=43704&r1=43703&r2=43704&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.hpp (original)
+++ trunk/src/whiteboard/manager.hpp Thu Jun 24 23:47:52 2010
@@ -55,12 +55,11 @@
         * Temporarily apply the effects of the current team's
         * planned moves to the unit map.
         */
-       void push_temp_modifiers();
-       void pop_temp_modifiers();
-       void clear_temp_modifiers();
-       bool temp_modifiers_applied() { return stacked_modifiers_calls_ > 0; }
+       void set_planned_unit_map();
+       void set_real_unit_map();
+       bool has_planned_unit_map() { return planned_unit_map_; }
 
-       bool ignore_mouse_motion() {return ignore_mouse_motion_; }
+       bool ignore_mouse() {return ignore_mouse_motion_; }
 
        /**
         * Highlights the action for this unit,
@@ -117,19 +116,19 @@
 
        bool ignore_mouse_motion_;
 
-       unsigned int stacked_modifiers_calls_;
+       bool planned_unit_map_;
 };
 
-struct scoped_modifiers
+struct scoped_planned_unit_map
 {
-       scoped_modifiers();
-       ~scoped_modifiers();
+       scoped_planned_unit_map();
+       ~scoped_planned_unit_map();
 };
 
-struct scoped_modifiers_remover
+struct scoped_real_unit_map
 {
-       scoped_modifiers_remover();
-       ~scoped_modifiers_remover();
+       scoped_real_unit_map();
+       ~scoped_real_unit_map();
 };
 
 } // end namespace wb




Related Messages


Powered by MHonArc, Updated Fri Jun 25 00:00:19 2010