The Battle for Wesnoth  1.17.10+dev
editor_display.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2022
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  {
56  mouseover_hex_overlay_ = image;
57  }
58 
60  {
62  }
63 
64 protected:
65  void draw_hex(const map_location& loc) override;
66 
67  /** Inherited from display. */
68  virtual overlay_map& get_overlays() override;
69 
70  rect get_clip_rect() const override;
71 
72  std::set<map_location> brush_locations_;
73 
74  /* The controller that owns this display. */
76 
78 };
79 
80 } //end namespace editor
const editor_map & map() const
editor_controller & controller_
virtual overlay_map & get_overlays() override
Inherited from display.
void set_brush_locs(const std::set< map_location > &hexes)
bool in_editor() const override
The editor_controller class contains the mouse and keyboard event handling routines for the editor...
Wrapper class to encapsulate creation and management of an SDL_Texture.
Definition: texture.hpp:32
Unit and team statistics.
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:56
editor_display(editor_controller &controller, reports &reports_object)
void remove_brush_loc(const map_location &hex)
std::map< map_location, std::vector< overlay > > overlay_map
Definition: display.hpp:946
virtual const time_of_day & get_time_of_day(const map_location &loc=map_location::null_location()) const override
Inherited from display.
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:30
Encapsulates the map of the game.
Definition: location.hpp:38
This class adds extra editor-specific functionality to a normal gamemap.
Definition: editor_map.hpp:70
virtual void layout() override
TLD layout() override.
void rebuild_terrain(const map_location &loc)
rect get_clip_rect() const override
Get the clipping rectangle for drawing.
An abstract description of a rectangle with integer coordinates.
Definition: rect.hpp:46
std::set< map_location > brush_locations_
void reset()
Releases ownership of the managed texture and resets the ptr to null.
Definition: texture.cpp:208
const gamemap & get_map() const
Definition: display.hpp:102
editor_controller & get_controller()
void add_brush_loc(const map_location &hex)
Functions to load and save images from/to disk.
static const map_location & null_location()
Definition: location.hpp:81
void draw_hex(const map_location &loc) override
Redraws a single gamemap location.
void set_mouseover_hex_overlay(const texture &image)
Sets texture to be drawn in hex under the mouse&#39;s location.