The Battle for Wesnoth  1.17.21+dev
minimap.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2023
3  by Mark de Wever <koraq@xs4all.nl>
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 #pragma once
17 
19 
22 
23 class config;
24 class gamemap;
25 
26 namespace gui2
27 {
28 namespace implementation
29 {
30 struct builder_minimap;
31 }
32 
33 // ------------ WIDGET -----------{
34 
35 /**
36  * @ingroup GUIWidgetWML
37  *
38  * The basic minimap class.
39  * This minimap can only show a minimap, but it can't be interacted with.
40  *
41  * The following states exist:
42  * * state_enabled - the minimap is enabled.
43  * A minimap has no extra fields.
44  */
45 class minimap : public styled_widget
46 {
47 public:
48  explicit minimap(const implementation::builder_minimap& builder);
49 
50  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
51 
52  /** See @ref styled_widget::set_active. */
53  virtual void set_active(const bool active) override;
54 
55  /** See @ref styled_widget::get_active. */
56  virtual bool get_active() const override;
57 
58  /** See @ref styled_widget::get_state. */
59  virtual unsigned get_state() const override;
60 
61  /** See @ref widget::disable_click_dismiss. */
62  bool disable_click_dismiss() const override;
63 
64  /***** ***** ***** setters / getters for members ***** ****** *****/
65 
66  void set_map_data(const std::string& map_data);
67 
68  std::string get_map_data() const
69  {
70  return map_data_;
71  }
72 
73  const std::string& map_data() const
74  {
75  return map_data_;
76  }
77 
78 private:
79  /** The map data to be used to generate the map. */
80  std::string map_data_;
81 
82  /** Game map generated from the provided data. */
83  std::unique_ptr<gamemap> map_;
84 
85  /** See @ref widget::impl_draw_background. */
86  virtual void impl_draw_background() override;
87 
88 public:
89  /** Static type getter that does not rely on the widget being constructed. */
90  static const std::string& type();
91 
92 private:
93  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
94  virtual const std::string& get_control_type() const override;
95 };
96 
97 // }---------- DEFINITION ---------{
98 
100 {
101  explicit minimap_definition(const config& cfg);
102 
104  {
105  explicit resolution(const config& cfg);
106  };
107 };
108 
109 // }---------- BUILDER -----------{
110 
111 namespace implementation
112 {
113 
115 {
116  explicit builder_minimap(const config& cfg);
117 
119 
120  virtual std::unique_ptr<widget> build() const override;
121 };
122 
123 } // namespace implementation
124 
125 // }------------ END --------------
126 
127 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:161
Encapsulates the map of the game.
Definition: map.hpp:172
The basic minimap class.
Definition: minimap.hpp:46
const std::string & map_data() const
Definition: minimap.hpp:73
void set_map_data(const std::string &map_data)
Definition: minimap.cpp:79
std::string map_data_
The map data to be used to generate the map.
Definition: minimap.hpp:80
std::unique_ptr< gamemap > map_
Game map generated from the provided data.
Definition: minimap.hpp:83
virtual bool get_active() const override
See styled_widget::get_active.
Definition: minimap.cpp:64
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
std::string get_map_data() const
Definition: minimap.hpp:68
virtual unsigned get_state() const override
See styled_widget::get_state.
Definition: minimap.cpp:69
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
Definition: minimap.cpp:74
virtual void set_active(const bool active) override
See styled_widget::set_active.
Definition: minimap.cpp:59
virtual void impl_draw_background() override
See widget::impl_draw_background.
Definition: minimap.cpp:96
minimap(const implementation::builder_minimap &builder)
Definition: minimap.cpp:53
Base class for all visible items.
Generic file dialog.
Contains the implementation details for lexical_cast and shouldn't be used directly.
virtual std::unique_ptr< widget > build() const override
Definition: minimap.cpp:129
builder_minimap(const config &cfg)
Definition: minimap.cpp:125
virtual std::unique_ptr< widget > build() const=0
minimap_definition(const config &cfg)
Definition: minimap.cpp:105
Base class of a resolution, contains the common keys for a resolution.