The Battle for Wesnoth  1.17.12+dev
minimap.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2022
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
Base class of a resolution, contains the common keys for a resolution.
std::unique_ptr< gamemap > map_
Game map generated from the provided data.
Definition: minimap.hpp:83
std::string get_map_data() const
Definition: minimap.hpp:68
std::string map_data_
The map data to be used to generate the map.
Definition: minimap.hpp:80
const std::string & map_data() const
Definition: minimap.hpp:73
Generic file dialog.
Encapsulates the map of the game.
Definition: map.hpp:171
virtual std::unique_ptr< widget > build() const =0
Base class for all visible items.
The basic minimap class.
Definition: minimap.hpp:45
point resolution()
Definition: general.cpp:392
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:60
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.