The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
highlighter.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2010 - 2025
3 by Gabriel Morin <gabrielmorin (at) gmail (dot) com>
4 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY.
12
13 See the COPYING file for more details.
14*/
15
16/**
17 * @file
18 */
19
20#pragma once
21
22#include "visitor.hpp"
23#include "map/location.hpp"
24
25static 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
31namespace 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
41public:
43 virtual ~highlighter();
44
45 void set_mouseover_hex(const map_location& 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 */
61
62 void set_selection_candidate(unit_ptr candidate) { selection_candidate_ = candidate; }
63
64private:
66 /** Unhighlight a given action (main or secondary). */
67 class unhighlight_visitor;
68
69 /** Highlight the given main action. */
70 class highlight_main_visitor;
71
72 /** Highlight the given secondary action. */
73 class highlight_secondary_visitor;
74
75 void unhighlight();
78
79 /** Redraw the given move action when needed. */
80 void last_action_redraw(const move_ptr&);
81
83 std::set<map_location> exclusive_display_hexes_;
86
90
92};
93
95public:
97 void visit(move_ptr);
98 void visit(attack_ptr);
99 void visit(recruit_ptr);
100 /** @todo: find some suitable effect for mouseover on planned recall. */
103private:
105};
106
118
120public:
122 void visit(move_ptr);
123 void visit(attack_ptr);
125 void visit(recall_ptr);
127private:
129};
130
131} // end namespace wb
Container associating units to locations.
Definition map.hpp:98
Class that handles highlighting planned actions as you hover over them and determine the right target...
virtual ~highlighter()
side_actions_ptr side_actions_
std::deque< weak_action_ptr > secondary_highlights_t
void find_main_highlight()
std::set< map_location > exclusive_display_hexes_
action_ptr get_bump_target()
const map_location & get_mouseover_hex() const
secondary_highlights_t secondary_highlights_
weak_action_ptr get_main_highlight()
unit_ptr selection_candidate_
action_ptr get_execute_target()
void set_selection_candidate(unit_ptr candidate)
void set_mouseover_hex(const map_location &hex)
map_location mouseover_hex_
void last_action_redraw(const move_ptr &)
Redraw the given move action when needed.
secondary_highlights_t get_secondary_highlights()
unit_ptr owner_unit_
unit_map & get_unit_map()
action_ptr get_delete_target()
weak_action_ptr selected_action_
unit_ptr get_selection_target()
void find_secondary_highlights()
weak_action_ptr main_highlight_
This internal whiteboard class holds the planned action queues for a team, and offers many utility me...
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses.
Definition visitor.hpp:33
static lg::log_domain log_whiteboard_highlight("whiteboard/highlight")
Definition display.hpp:45
std::shared_ptr< recruit > recruit_ptr
Definition typedefs.hpp:72
std::weak_ptr< action > weak_action_ptr
Definition typedefs.hpp:64
std::shared_ptr< suppose_dead > suppose_dead_ptr
Definition typedefs.hpp:76
std::shared_ptr< move > move_ptr
Definition typedefs.hpp:68
std::shared_ptr< action > action_ptr
Definition typedefs.hpp:62
std::shared_ptr< attack > attack_ptr
Definition typedefs.hpp:70
std::shared_ptr< side_actions > side_actions_ptr
Definition typedefs.hpp:66
std::shared_ptr< recall > recall_ptr
Definition typedefs.hpp:74
std::shared_ptr< unit > unit_ptr
Definition ptr.hpp:26
Encapsulates the map of the game.
Definition location.hpp:46
visitor is an abstract interface : action.accept(visitor) calls visitor.visit(action)
#define h