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