The Battle for Wesnoth  1.19.0+dev
editor_display.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by Tomasz Sniatowski <kailoran@gmail.com>
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 
18 #include "map/editor_map.hpp"
19 #include "display.hpp"
20 
21 namespace editor {
22 
23 class editor_display : public display
24 {
25 public:
27 
28  bool in_editor() const override { return true; }
29 
30  void add_brush_loc(const map_location& hex);
31  void set_brush_locs(const std::set<map_location>& hexes);
32  void clear_brush_locs();
33  void remove_brush_loc(const map_location& hex);
34  const editor_map& map() const { return static_cast<const editor_map&>(get_map()); }
35  void rebuild_terrain(const map_location &loc);
36 
37  /** Inherited from display. */
38  virtual const time_of_day& get_time_of_day(const map_location& loc = map_location::null_location()) const override;
39 
41  {
42  return controller_;
43  }
44 
45  /**
46  * TLD layout() override. Replaces old refresh_reports(). Be sure to
47  * call the base class method as well.
48  *
49  * This updates some reports that may need to be refreshed every frame.
50  */
51  virtual void layout() override;
52 
53  /** Sets texture to be drawn in hex under the mouse's location. */
55  {
57  }
58 
60  {
62  }
63 
64  /**
65  * Sets and shows the tooltip-like text at the top or bottom of the map area.
66  *
67  * @param str The text to display.
68  */
69  void set_help_string(const std::string& str);
70 
71  /** Removes the help string. */
72  void clear_help_string();
73 
74 protected:
75  void draw_hex(const map_location& loc) override;
76 
77  /** Inherited from display. */
78  virtual overlay_map& get_overlays() override;
79 
80  rect get_clip_rect() const override;
81 
82  std::set<map_location> brush_locations_;
83 
84  /* The controller that owns this display. */
86 
88 
89 private:
90  /** ID of the floating label that's controlled by set_help_string() / clear_help_string(). */
91  int help_handle_ = 0;
92 
93  /**
94  * Ignored when help_handle_ == 0. Othewise, true if the help label obscures the
95  * northern hexes in the map area, false if it's over the southern hexes instead.
96  */
97  bool help_string_at_top_ = false;
98 };
99 
100 } //end namespace editor
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition: display.hpp:88
std::map< map_location, std::vector< overlay > > overlay_map
Definition: display.hpp:962
const gamemap & get_map() const
Definition: display.hpp:106
The editor_controller class contains the mouse and keyboard event handling routines for the editor.
void set_mouseover_hex_overlay(const texture &image)
Sets texture to be drawn in hex under the mouse's location.
virtual overlay_map & get_overlays() override
Inherited from display.
virtual void layout() override
TLD layout() override.
virtual const time_of_day & get_time_of_day(const map_location &loc=map_location::null_location()) const override
Inherited from display.
void set_help_string(const std::string &str)
Sets and shows the tooltip-like text at the top or bottom of the map area.
void rebuild_terrain(const map_location &loc)
int help_handle_
ID of the floating label that's controlled by set_help_string() / clear_help_string().
const editor_map & map() const
rect get_clip_rect() const override
Get the clipping rectangle for drawing.
std::set< map_location > brush_locations_
bool help_string_at_top_
Ignored when help_handle_ == 0.
void remove_brush_loc(const map_location &hex)
editor_controller & controller_
editor_controller & get_controller()
bool in_editor() const override
editor_display(editor_controller &controller, reports &reports_object)
void add_brush_loc(const map_location &hex)
void draw_hex(const map_location &loc) override
Redraws a single gamemap location.
void set_brush_locs(const std::set< map_location > &hexes)
void clear_help_string()
Removes the help string.
This class adds extra editor-specific functionality to a normal gamemap.
Definition: editor_map.hpp:70
Wrapper class to encapsulate creation and management of an SDL_Texture.
Definition: texture.hpp:33
void reset()
Releases ownership of the managed texture and resets the ptr to null.
Definition: texture.cpp:208
map_display and display: classes which take care of displaying the map and game-data on the screen.
Manage the empty-palette in the editor.
Definition: action.cpp:31
Functions to load and save images from/to disk.
Unit and team statistics.
Encapsulates the map of the game.
Definition: location.hpp:38
static const map_location & null_location()
Definition: location.hpp:81
An abstract description of a rectangle with integer coordinates.
Definition: rect.hpp:47
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:57