The Battle for Wesnoth  1.19.0-dev
drawer.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2024
3  by Chris Beck <render787@gmail.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  *
18  * This wrapper class should be held by the display object when it needs to draw a unit.
19  * The purpose of this is to improve encapsulation -- other parts of the engine like AI
20  * don't need to be exposed to the unit drawing code, and encapsulation like this will
21  * help us to reduce unnecessary includes.
22  *
23  **/
24 
25 #pragma once
26 
27 #include "map/location.hpp"
28 
29 #include <vector>
30 
31 class display;
32 class display_context;
33 class gamemap;
34 namespace halo { class manager; }
35 class team;
36 class unit;
37 
38 
40 {
41 public:
42  explicit unit_drawer(display & thedisp);
43 
44 private:
47  const gamemap & map;
48  const std::vector<team> & teams;
50  std::size_t viewing_team;
51  std::size_t playing_team;
58  double zoom_factor;
59  std::set<map_location> units_that_can_reach_goal;
60 
61  int hex_size;
63 
64 public:
65  /** draw a unit. */
66  void redraw_unit(const unit & u) const;
67 };
Abstract class for exposing game data that doesn't depend on the GUI, however which for historical re...
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition: display.hpp:88
Encapsulates the map of the game.
Definition: map.hpp:172
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:74
const team & viewing_team_ref
Definition: drawer.hpp:52
const gamemap & map
Definition: drawer.hpp:47
double zoom_factor
Definition: drawer.hpp:58
void redraw_unit(const unit &u) const
draw a unit.
Definition: drawer.cpp:166
const std::vector< team > & teams
Definition: drawer.hpp:48
const display_context & dc
Definition: drawer.hpp:46
bool show_everything
Definition: drawer.hpp:55
const team & playing_team_ref
Definition: drawer.hpp:53
halo::manager & halo_man
Definition: drawer.hpp:49
std::size_t viewing_team
Definition: drawer.hpp:50
display & disp
Definition: drawer.hpp:45
std::set< map_location > units_that_can_reach_goal
Definition: drawer.hpp:59
int hex_size
Definition: drawer.hpp:61
map_location sel_hex
Definition: drawer.hpp:56
int hex_size_by_2
Definition: drawer.hpp:62
unit_drawer(display &thedisp)
Definition: drawer.cpp:138
std::size_t playing_team
Definition: drawer.hpp:51
map_location mouse_hex
Definition: drawer.hpp:57
bool is_blindfolded
Definition: drawer.hpp:54
This class represents a single unit of a specific type.
Definition: unit.hpp:133
Definition: halo.cpp:39
Encapsulates the map of the game.
Definition: location.hpp:38