The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
minimap.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by Mark de Wever <[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 #ifndef GUI_WIDGETS_MINIMAP_HPP_INCLUDED
16 #define GUI_WIDGETS_MINIMAP_HPP_INCLUDED
17 
18 #include "gui/widgets/control.hpp"
19 
22 
23 class config;
24 
25 namespace gui2
26 {
27 
28 // ------------ WIDGET -----------{
29 
30 /**
31  * The basic minimap class.
32  *
33  * This minimap can only show a minimap, but it can't be interacted with. For
34  * that the tminimap_interactive class will be created.
35  */
36 class tminimap : public tcontrol
37 {
38 public:
39  tminimap() : tcontrol(1), map_data_(), terrain_(nullptr)
40  {
41  }
42 
43  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
44 
45  /** See @ref tcontrol::set_active. */
46  virtual void set_active(const bool active) override;
47 
48  /** See @ref tcontrol::get_active. */
49  virtual bool get_active() const override;
50 
51  /** See @ref tcontrol::get_state. */
52  virtual unsigned get_state() const override;
53 
54  /** See @ref twidget::disable_click_dismiss. */
55  bool disable_click_dismiss() const override;
56 
57  /***** ***** ***** setters / getters for members ***** ****** *****/
58 
60  {
61  if(map_data != map_data_) {
63  set_is_dirty(true);
64  }
65  }
66 
68  {
69  return map_data_;
70  }
71 
72  const std::string& map_data() const
73  {
74  return map_data_;
75  }
76 
77  void set_config(const ::config* terrain)
78  {
79  terrain_ = terrain;
80  }
81 
82 private:
83  /** The map data to be used to generate the map. */
85 
86  /**
87  * The config object with the terrain data.
88  *
89  * This config must be set before the object can be drawn.
90  */
91  const ::config* terrain_;
92 
93  /**
94  * Gets the image for the minimap.
95  *
96  * @param w The wanted width of the image.
97  * @param h The wanted height of the image.
98  *
99  * @returns The image, nullptr upon error.
100  */
101  const surface get_image(const int w, const int h) const;
102 
103  /** See @ref twidget::impl_draw_background. */
104  virtual void impl_draw_background(surface& frame_buffer,
105  int x_offset,
106  int y_offset) override;
107 
108  /** See @ref tcontrol::get_control_type. */
109  virtual const std::string& get_control_type() const override;
110 };
111 
112 // }---------- DEFINITION ---------{
113 
115 {
116  explicit tminimap_definition(const config& cfg);
117 
119  {
120  explicit tresolution(const config& cfg);
121  };
122 };
123 
124 // }---------- BUILDER -----------{
125 
126 namespace implementation
127 {
128 
130 {
131  explicit tbuilder_minimap(const config& cfg);
132 
134 
135  twidget* build() const;
136 };
137 
138 } // namespace implementation
139 
140 // }------------ END --------------
141 
142 } // namespace gui2
143 
144 #endif
The basic minimap class.
Definition: minimap.hpp:36
bool disable_click_dismiss() const override
See twidget::disable_click_dismiss.
Definition: minimap.cpp:180
virtual unsigned get_state() const override
See tcontrol::get_state.
Definition: minimap.cpp:60
void set_is_dirty(const bool is_dirty)
Definition: widget.cpp:435
Base class of a resolution, contains the common keys for a resolution.
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
virtual twidget * build() const =0
std::string get_map_data() const
Definition: minimap.hpp:67
std::string map_data_
The map data to be used to generate the map.
Definition: minimap.hpp:84
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1858
virtual void impl_draw_background(surface &frame_buffer, int x_offset, int y_offset) override
See twidget::impl_draw_background.
Definition: minimap.cpp:236
virtual void set_active(const bool active) override
See tcontrol::set_active.
Definition: minimap.cpp:50
static const ::config * terrain
The terrain used to create the cache.
Definition: minimap.cpp:135
virtual const std::string & get_control_type() const override
See tcontrol::get_control_type.
Definition: minimap.cpp:260
virtual bool get_active() const override
See tcontrol::get_active.
Definition: minimap.cpp:55
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:5910
const surface get_image(const int w, const int h) const
Gets the image for the minimap.
Definition: minimap.cpp:185
Base class for all visible items.
Definition: control.hpp:34
tminimap_definition(const config &cfg)
Definition: minimap.cpp:268
const ::config * terrain_
The config object with the terrain data.
Definition: minimap.hpp:91
Base class for all widgets.
Definition: widget.hpp:49
void set_config(const ::config *terrain)
Definition: minimap.hpp:77
const std::string & map_data() const
Definition: minimap.hpp:72
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503
Contains the implementation details for lexical_cast and shouldn't be used directly.
void set_map_data(const std::string &map_data)
Definition: minimap.hpp:59