The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
drawer.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Chris Beck <[email protected]>
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  *
17  * This wrapper class should be held by the display object when it needs to draw a unit.
18  * The purpose of this is to improve encapsulation -- other parts of the engine like AI
19  * don't need to be exposed to the unit drawing code, and encapsulation like this will
20  * help us to reduce unnecessary includes.
21  *
22  **/
23 
24 #ifndef DRAWABLE_UNIT_H_INCLUDED
25 #define DRAWABLE_UNIT_H_INCLUDED
26 
27 #include "map/location.hpp"
28 #include <map>
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 struct SDL_Color;
39 struct SDL_Rect;
40 struct surface;
41 
42 # include <SDL_types.h>
43 typedef Sint32 fixed_t;
44 
46 {
47 public:
48  unit_drawer(display & thedisp, std::map<surface,SDL_Rect> & bar_rects);
49 
50 private:
53  const gamemap & map;
54  const std::vector<team> & teams;
56  std::map<surface,SDL_Rect> & energy_bar_rects_;
57  size_t viewing_team;
58  size_t playing_team;
65  double zoom_factor;
66 
67  int hex_size;
69 
70 public:
71  /** draw a unit. */
72  void redraw_unit(const unit & u) const;
73 
74 private:
75  /** draw a health/xp bar of a unit */
76  void draw_bar(const std::string& image, int xpos, int ypos,
77  const map_location& loc, size_t height, double filled,
78  const SDL_Color& col, fixed_t alpha) const;
79 
80  /**
81  * Finds the start and end rows on the energy bar image.
82  *
83  * White pixels are substituted for the color of the energy.
84  */
85  const SDL_Rect& calculate_energy_bar(surface surf) const;
86 };
87 #endif
bool is_blindfolded
Definition: drawer.hpp:61
Definition: unit.hpp:95
Sint32 fixed_t
Definition: drawer.hpp:40
int hex_size
Definition: drawer.hpp:67
unit_drawer(display &thedisp, std::map< surface, SDL_Rect > &bar_rects)
Definition: drawer.cpp:30
halo::manager & halo_man
Definition: drawer.hpp:55
size_t viewing_team
Definition: drawer.hpp:57
const team & playing_team_ref
Definition: drawer.hpp:60
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
size_t playing_team
Definition: drawer.hpp:58
int hex_size_by_2
Definition: drawer.hpp:68
Encapsulates the map of the game.
Definition: map.hpp:37
const gamemap & map
Definition: drawer.hpp:53
const SDL_Rect & calculate_energy_bar(surface surf) const
Finds the start and end rows on the energy bar image.
Definition: drawer.cpp:458
GLclampf GLclampf GLclampf alpha
Definition: glew.h:1488
const std::vector< team > & teams
Definition: drawer.hpp:54
display & disp
Definition: drawer.hpp:51
surf
Definition: filter.cpp:143
Encapsulates the map of the game.
Definition: location.hpp:38
const team & viewing_team_ref
Definition: drawer.hpp:59
const display_context & dc
Definition: drawer.hpp:52
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
Definition: glew.h:1220
Definition: display.hpp:43
void draw_bar(const std::string &image, int xpos, int ypos, const map_location &loc, size_t height, double filled, const SDL_Color &col, fixed_t alpha) const
draw a health/xp bar of a unit
Definition: drawer.cpp:372
this module manages the cache of images.
Definition: image.cpp:75
std::map< surface, SDL_Rect > & energy_bar_rects_
Definition: drawer.hpp:56
double zoom_factor
Definition: drawer.hpp:65
bool show_everything
Definition: drawer.hpp:62
void redraw_unit(const unit &u) const
draw a unit.
Definition: drawer.cpp:50
GLsizei const GLcharARB ** string
Definition: glew.h:4503
map_location mouse_hex
Definition: drawer.hpp:64
map_location sel_hex
Definition: drawer.hpp:63