The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
highlighter.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2016 by Gabriel Morin <gabrielmorin (at) gmail (dot) com>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13  */
14 
15 /**
16  * @file
17  */
18 
19 #ifndef WB_HIGHLIGHTER_HPP_
20 #define WB_HIGHLIGHTER_HPP_
21 
22 #include "visitor.hpp"
23 #include "map/location.hpp"
24 
25 static lg::log_domain log_whiteboard_highlight("whiteboard/highlight");
26 #define ERR_WB_H LOG_STREAM(err, log_whiteboard_highlight)
27 #define WRN_WB_H LOG_STREAM(warn, log_whiteboard_highlight)
28 #define LOG_WB_H LOG_STREAM(info, log_whiteboard_highlight)
29 #define DBG_WB_H LOG_STREAM(debug, log_whiteboard_highlight)
30 
31 namespace wb
32 {
33 
34 /**
35  * Class that handles highlighting planned actions as you hover over them
36  * and determine the right target for contextual execution.
37  */
39 {
40 
41 public:
43  virtual ~highlighter();
44 
45  void set_mouseover_hex(const map_location& hex);
46  const map_location& get_mouseover_hex() const {return mouseover_hex_; }
47 
48  void highlight();
49  void clear();
50 
55 
56  /// @return the action that currently receives the highlight focus
58  typedef std::deque<weak_action_ptr> secondary_highlights_t;
59  /// @return the collection of actions that are highlighted but don't have the focus
60  secondary_highlights_t get_secondary_highlights() { return secondary_highlights_; }
61 
62 private:
64  /** Unhighlight a given action (main or secondary). */
65  class unhighlight_visitor;
66 
67  /** Highlight the given main action. */
68  class highlight_main_visitor;
69 
70  /** Highlight the given secondary action. */
71  class highlight_secondary_visitor;
72 
73  void unhighlight();
74  void find_main_highlight();
76 
77  /** Redraw the given move action when needed. */
79 
81  std::set<map_location> exclusive_display_hexes_;
84 
87  secondary_highlights_t secondary_highlights_;
88 
90 };
91 
93 public:
95  void visit(move_ptr);
96  void visit(attack_ptr);
97  void visit(recruit_ptr);
98  /// @todo: find some suitable effect for mouseover on planned recall.
99  void visit(recall_ptr){}
101 private:
103 };
104 
106 public:
108  void visit(move_ptr);
109  void visit(attack_ptr);
113 private:
115 };
116 
118 public:
120  void visit(move_ptr);
121  void visit(attack_ptr);
123  void visit(recall_ptr);
125 private:
127 };
128 
129 } // end namespace wb
130 
131 #endif /* WB_HIGHLIGHTER_HPP_ */
action_ptr get_delete_target()
side_actions_ptr side_actions_
Definition: highlighter.hpp:89
const map_location & get_mouseover_hex() const
Definition: highlighter.hpp:46
weak_action_ptr main_highlight_
Definition: highlighter.hpp:86
unit_ptr owner_unit_
Definition: highlighter.hpp:82
void find_main_highlight()
weak_action_ptr selected_action_
Definition: highlighter.hpp:85
void find_secondary_highlights()
map_location mouseover_hex_
Definition: highlighter.hpp:80
unit_map & get_unit_map()
boost::weak_ptr< action > weak_action_ptr
Definition: typedefs.hpp:72
secondary_highlights_t get_secondary_highlights()
Definition: highlighter.hpp:60
unit_ptr selection_candidate_
Definition: highlighter.hpp:83
static lg::log_domain log_whiteboard_highlight("whiteboard/highlight")
highlighter(side_actions_ptr side_actions)
Definition: highlighter.cpp:53
secondary_highlights_t secondary_highlights_
Definition: highlighter.hpp:87
virtual ~highlighter()
Definition: highlighter.cpp:65
Class that handles highlighting planned actions as you hover over them and determine the right target...
Definition: highlighter.hpp:38
Encapsulates the map of the game.
Definition: location.hpp:38
std::deque< weak_action_ptr > secondary_highlights_t
Definition: highlighter.hpp:58
void set_mouseover_hex(const map_location &hex)
Definition: highlighter.cpp:74
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:5910
action_ptr get_bump_target()
unit_ptr get_selection_target()
std::set< map_location > exclusive_display_hexes_
Definition: highlighter.hpp:81
Container associating units to locations.
Definition: map.hpp:90
void last_action_redraw(move_ptr)
Redraw the given move action when needed.
visitor is an abstract interface : action.accept(visitor) calls visitor.visit(action) ...
action_ptr get_execute_target()
weak_action_ptr get_main_highlight()
Definition: highlighter.hpp:57
This internal whiteboard class holds the planned action queues for a team, and offers many utility me...
Definition: display.hpp:47
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses...
Definition: visitor.hpp:32