Author: tschmitz
Date: Fri Jul 15 23:41:41 2011
New Revision: 50333
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50333&view=rev
Log:
Revert "Made allies' whiteboard plans highlightable."
This reverts commit 7d709f8d7306d7d0e036324f4aefaac898a6f408.
Modified:
trunk/src/whiteboard/highlight_visitor.cpp
trunk/src/whiteboard/manager.cpp
trunk/src/whiteboard/manager.hpp
trunk/src/whiteboard/side_actions.cpp
Modified: trunk/src/whiteboard/highlight_visitor.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/highlight_visitor.cpp?rev=50333&r1=50332&r2=50333&view=diff
==============================================================================
--- trunk/src/whiteboard/highlight_visitor.cpp (original)
+++ trunk/src/whiteboard/highlight_visitor.cpp Fri Jul 15 23:41:41 2011
@@ -67,7 +67,7 @@
//if we're right over a unit, just highlight all of this unit's actions
unit_map::const_iterator it = unit_map_.find(hex);
if (it != unit_map_.end()
- && it->side() == int(side_actions_->team_index()+1))
+ && it->side() == resources::screen->viewing_side())
{
selection_candidate_ = &(*it);
Modified: trunk/src/whiteboard/manager.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=50333&r1=50332&r2=50333&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Fri Jul 15 23:41:41 2011
@@ -55,7 +55,7 @@
executing_actions_(false),
gamestate_mutated_(false),
mapbuilder_(),
- highlighters_(),
+ highlighter_(),
route_(),
move_arrow_(),
fake_unit_(),
@@ -63,9 +63,6 @@
hidden_unit_hex_(),
net_buffer_()
{
- foreach(team& t, *resources::teams)
- highlighters_.push_back(new
highlight_visitor(*resources::units,t.get_side_actions()));
-
LOG_WB << "Manager initialized.\n";
}
@@ -201,7 +198,7 @@
bool manager::can_reorder_action() const
{
- return can_execute_hotkey() &&
const_cast<manager*>(this)->get_viewer_highlighter().get_bump_target();
+ return can_execute_hotkey() && highlighter_ &&
highlighter_->get_bump_target();
}
bool manager::allow_leader_to_move(unit const& leader) const
@@ -240,6 +237,7 @@
void manager::on_finish_side_turn()
{
wait_for_side_init_ = true;
+ highlighter_.reset();
erase_temp_move();
LOG_WB << "on_finish_side_turn()\n";
}
@@ -342,11 +340,12 @@
if (!((selected_hex.valid() && it != resources::units->end())
|| has_temp_move() || wait_for_side_init_ ||
executing_actions_))
{
- foreach(highlight_visitor& h, highlighters_)
- {
- h.set_mouseover_hex(hex);
- h.highlight();
- }
+ if (!highlighter_)
+ {
+ highlighter_.reset(new
highlight_visitor(*resources::units, viewer_actions()));
+ }
+ highlighter_->set_mouseover_hex(hex);
+ highlighter_->highlight();
}
}
@@ -640,7 +639,7 @@
viewer_actions()->execute(it);
executing_actions_ = false;
}
- else if ((action =
get_viewer_highlighter().get_execute_target()) &&
+ else if (highlighter_ && (action =
highlighter_->get_execute_target()) &&
(it =
viewer_actions()->get_position_of(action)) != viewer_actions()->end())
{
executing_actions_ = true;
@@ -676,7 +675,6 @@
erase_temp_move();
validate_viewer_actions();
- highlight_visitor& highlighter = get_viewer_highlighter();
action_ptr action;
side_actions::iterator it;
unit const* selected_unit =
future_visible_unit(resources::screen->selected_hex(), viewer_side());
@@ -687,13 +685,13 @@
viewer_actions()->remove_action(it);
///@todo Shouldn't we probably deselect the unit at
this point?
}
- else if ((action = highlighter.get_delete_target()) &&
+ else if (highlighter_ && (action =
highlighter_->get_delete_target()) &&
(it =
viewer_actions()->get_position_of(action)) != viewer_actions()->end())
{
viewer_actions()->remove_action(it);
viewer_actions()->remove_invalid_of(action->get_unit());
-
highlighter.set_mouseover_hex(highlighter.get_mouseover_hex());
- highlighter.highlight();
+
highlighter_->set_mouseover_hex(highlighter_->get_mouseover_hex());
+ highlighter_->highlight();
}
else //we already check above for viewer_actions()->empty()
{
@@ -707,10 +705,11 @@
void manager::contextual_bump_up_action()
{
- if (!(executing_actions_ || viewer_actions()->empty() ||
resources::controller->is_linger_mode()))
+ if (!(executing_actions_ || viewer_actions()->empty() ||
resources::controller->is_linger_mode())
+ && highlighter_)
{
validate_viewer_actions();
- action_ptr action = get_viewer_highlighter().get_bump_target();
+ action_ptr action = highlighter_->get_bump_target();
if (action)
{
viewer_actions()->bump_earlier(viewer_actions()->get_position_of(action));
@@ -720,10 +719,11 @@
void manager::contextual_bump_down_action()
{
- if (!(executing_actions_ || viewer_actions()->empty() ||
resources::controller->is_linger_mode()))
+ if (!(executing_actions_ || viewer_actions()->empty() ||
resources::controller->is_linger_mode())
+ && highlighter_)
{
validate_viewer_actions();
- action_ptr action = get_viewer_highlighter().get_bump_target();
+ action_ptr action = highlighter_->get_bump_target();
if (action)
{
viewer_actions()->bump_later(viewer_actions()->get_position_of(action));
@@ -739,11 +739,6 @@
{
team.get_side_actions()->clear();
}
-}
-
-highlight_visitor& manager::get_viewer_highlighter()
-{
- return highlighters_[resources::screen->viewing_team()];
}
bool manager::unit_has_actions(unit const* unit) const
Modified: trunk/src/whiteboard/manager.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.hpp?rev=50333&r1=50332&r2=50333&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.hpp (original)
+++ trunk/src/whiteboard/manager.hpp Fri Jul 15 23:41:41 2011
@@ -28,7 +28,6 @@
#include "network.hpp"
#include <boost/noncopyable.hpp>
-#include <boost/ptr_container/ptr_vector.hpp>
class CKey;
@@ -145,10 +144,8 @@
/** Deletes all planned actions for all teams */
void erase_all_actions();
- /// Get the highlight visitor associated with viewer_team()
- highlight_visitor& get_viewer_highlighter();
- /// Get the highlight visitor associated with the given team
- highlight_visitor& get_highlighter(size_t team_num) {return
highlighters_[team_num];}
+ /// Get the highlight visitor instance in use by the manager
+ boost::weak_ptr<highlight_visitor> get_highlighter() { return
highlighter_; }
/** Checks whether the specified unit has at least one planned action */
bool unit_has_actions(unit const* unit) const;
@@ -183,7 +180,7 @@
bool gamestate_mutated_;
boost::scoped_ptr<mapbuilder_visitor> mapbuilder_;
- boost::ptr_vector<highlight_visitor> highlighters_;
+ boost::shared_ptr<highlight_visitor> highlighter_;
boost::scoped_ptr<pathfind::marked_route> route_;
Modified: trunk/src/whiteboard/side_actions.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/side_actions.cpp?rev=50333&r1=50332&r2=50333&view=diff
==============================================================================
--- trunk/src/whiteboard/side_actions.cpp (original)
+++ trunk/src/whiteboard/side_actions.cpp Fri Jul 15 23:41:41 2011
@@ -81,7 +81,8 @@
std::vector<int> numbers_to_draw;
int main_number = -1;
std::set<int> secondary_numbers;
- highlight_visitor& highlighter =
resources::whiteboard->get_highlighter(team_index_);
+ boost::shared_ptr<highlight_visitor> highlighter =
+
resources::whiteboard->get_highlighter().lock();
const_iterator it;
for(it = begin(); it != end(); ++it)
@@ -94,16 +95,18 @@
//store number corresponding to iterator's position + 1
size_t number = (it - begin()) + 1;
numbers_to_draw.push_back(number);
-
- if (highlighter.get_main_highlight().lock() == *it) {
- main_number = number;
- }
-
- foreach(weak_action_ptr action,
highlighter.get_secondary_highlights())
- {
- if (action.lock() == *it)
+ if (highlighter)
+ {
+ if (highlighter->get_main_highlight().lock() ==
*it) {
+ main_number = number;
+ }
+
+ foreach(weak_action_ptr action,
highlighter->get_secondary_highlights())
{
- secondary_numbers.insert(number);
+ if (action.lock() == *it)
+ {
+
secondary_numbers.insert(number);
+ }
}
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits