Author: tschmitz
Date: Thu Jul 14 07:38:58 2011
New Revision: 50297
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50297&view=rev
Log:
Made allies' whiteboard plans highlightable.
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=50297&r1=50296&r2=50297&view=diff
==============================================================================
--- trunk/src/whiteboard/highlight_visitor.cpp (original)
+++ trunk/src/whiteboard/highlight_visitor.cpp Thu Jul 14 07:38:58 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() == resources::screen->viewing_side())
+ && it->side() == int(side_actions_->team_index()+1))
{
selection_candidate_ = &(*it);
Modified: trunk/src/whiteboard/manager.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=50297&r1=50296&r2=50297&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Thu Jul 14 07:38:58 2011
@@ -55,7 +55,7 @@
executing_actions_(false),
gamestate_mutated_(false),
mapbuilder_(),
- highlighter_(),
+ highlighters_(),
route_(),
move_arrow_(),
fake_unit_(),
@@ -63,6 +63,9 @@
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";
}
@@ -198,7 +201,7 @@
bool manager::can_reorder_action() const
{
- return can_execute_hotkey() && highlighter_ &&
highlighter_->get_bump_target();
+ return can_execute_hotkey() &&
const_cast<manager*>(this)->get_viewer_highlighter().get_bump_target();
}
bool manager::allow_leader_to_move(unit const& leader) const
@@ -237,7 +240,6 @@
void manager::on_finish_side_turn()
{
wait_for_side_init_ = true;
- highlighter_.reset();
erase_temp_move();
LOG_WB << "on_finish_side_turn()\n";
}
@@ -340,12 +342,11 @@
if (!((selected_hex.valid() && it != resources::units->end())
|| has_temp_move() || wait_for_side_init_ ||
executing_actions_))
{
- if (!highlighter_)
- {
- highlighter_.reset(new
highlight_visitor(*resources::units, viewer_actions()));
- }
- highlighter_->set_mouseover_hex(hex);
- highlighter_->highlight();
+ foreach(highlight_visitor& h, highlighters_)
+ {
+ h.set_mouseover_hex(hex);
+ h.highlight();
+ }
}
}
@@ -643,7 +644,7 @@
viewer_actions()->execute(it);
executing_actions_ = false;
}
- else if (highlighter_ && (action =
highlighter_->get_execute_target()) &&
+ else if ((action =
get_viewer_highlighter().get_execute_target()) &&
(it =
viewer_actions()->get_position_of(action)) != viewer_actions()->end())
{
executing_actions_ = true;
@@ -679,6 +680,7 @@
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());
@@ -689,13 +691,13 @@
viewer_actions()->remove_action(it);
///@todo Shouldn't we probably deselect the unit at
this point?
}
- else if (highlighter_ && (action =
highlighter_->get_delete_target()) &&
+ else if ((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()
{
@@ -709,11 +711,10 @@
void manager::contextual_bump_up_action()
{
- if (!(executing_actions_ || viewer_actions()->empty() ||
resources::controller->is_linger_mode())
- && highlighter_)
+ if (!(executing_actions_ || viewer_actions()->empty() ||
resources::controller->is_linger_mode()))
{
validate_viewer_actions();
- action_ptr action = highlighter_->get_bump_target();
+ action_ptr action = get_viewer_highlighter().get_bump_target();
if (action)
{
viewer_actions()->bump_earlier(viewer_actions()->get_position_of(action));
@@ -723,11 +724,10 @@
void manager::contextual_bump_down_action()
{
- if (!(executing_actions_ || viewer_actions()->empty() ||
resources::controller->is_linger_mode())
- && highlighter_)
+ if (!(executing_actions_ || viewer_actions()->empty() ||
resources::controller->is_linger_mode()))
{
validate_viewer_actions();
- action_ptr action = highlighter_->get_bump_target();
+ action_ptr action = get_viewer_highlighter().get_bump_target();
if (action)
{
viewer_actions()->bump_later(viewer_actions()->get_position_of(action));
@@ -743,6 +743,11 @@
{
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=50297&r1=50296&r2=50297&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.hpp (original)
+++ trunk/src/whiteboard/manager.hpp Thu Jul 14 07:38:58 2011
@@ -28,6 +28,7 @@
#include "network.hpp"
#include <boost/noncopyable.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
class CKey;
@@ -144,8 +145,10 @@
/** Deletes all planned actions for all teams */
void erase_all_actions();
- /// Get the highlight visitor instance in use by the manager
- boost::weak_ptr<highlight_visitor> get_highlighter() { return
highlighter_; }
+ /// 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];}
/** Checks whether the specified unit has at least one planned action */
bool unit_has_actions(unit const* unit) const;
@@ -180,7 +183,7 @@
bool gamestate_mutated_;
boost::scoped_ptr<mapbuilder_visitor> mapbuilder_;
- boost::shared_ptr<highlight_visitor> highlighter_;
+ boost::ptr_vector<highlight_visitor> highlighters_;
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=50297&r1=50296&r2=50297&view=diff
==============================================================================
--- trunk/src/whiteboard/side_actions.cpp (original)
+++ trunk/src/whiteboard/side_actions.cpp Thu Jul 14 07:38:58 2011
@@ -81,8 +81,7 @@
std::vector<int> numbers_to_draw;
int main_number = -1;
std::set<int> secondary_numbers;
- boost::shared_ptr<highlight_visitor> highlighter =
-
resources::whiteboard->get_highlighter().lock();
+ highlight_visitor& highlighter =
resources::whiteboard->get_highlighter(team_index_);
const_iterator it;
for(it = begin(); it != end(); ++it)
@@ -95,18 +94,16 @@
//store number corresponding to iterator's position + 1
size_t number = (it - begin()) + 1;
numbers_to_draw.push_back(number);
- if (highlighter)
- {
- if (highlighter->get_main_highlight().lock() ==
*it) {
- main_number = number;
- }
-
- foreach(weak_action_ptr action,
highlighter->get_secondary_highlights())
+
+ if (highlighter.get_main_highlight().lock() == *it) {
+ main_number = number;
+ }
+
+ foreach(weak_action_ptr action,
highlighter.get_secondary_highlights())
+ {
+ if (action.lock() == *it)
{
- if (action.lock() == *it)
- {
-
secondary_numbers.insert(number);
- }
+ secondary_numbers.insert(number);
}
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits