CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
th_map_overlays.h
Go to the documentation of this file.
1/*
2Copyright (c) 2010 Peter "Corsix" Cawley
3
4Permission is hereby granted, free of charge, to any person obtaining a copy of
5this software and associated documentation files (the "Software"), to deal in
6the Software without restriction, including without limitation the rights to
7use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8of the Software, and to permit persons to whom the Software is furnished to do
9so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
21*/
22
23#ifndef CORSIX_TH_TH_MAP_OVERLAYS_H_
24#define CORSIX_TH_TH_MAP_OVERLAYS_H_
25
26#include <cstddef>
27#include <string>
28#include <string_view>
29
30class font;
31class level_map;
32class render_target;
33class sprite_sheet;
34
36 public:
37 virtual ~map_overlay() = default;
38
40 const level_map* pMap, int iNodeX, int iNodeY) = 0;
41};
42
44 public:
45 map_overlay_pair() = default;
46 ~map_overlay_pair() override;
47
50
52 const level_map* pMap, int iNodeX, int iNodeY) override;
53
54 private:
55 map_overlay *first{nullptr}, *second{nullptr};
56 bool owns_first{false}, owns_second{false};
57};
58
60 public:
62 ~map_typical_overlay() override;
63
66
67 protected:
68 void draw_text(render_target* pCanvas, int iX, int iY, std::string_view str);
69
71 ::font* font{nullptr};
72
73 private:
74 bool owns_sprites{false};
75 bool owns_font{false};
76};
77
79 public:
80 map_text_overlay() = default;
81 ~map_text_overlay() override = default;
82
84 const level_map* pMap, int iNodeX, int iNodeY) override;
85
86 void set_background_sprite(size_t iSprite);
87 virtual const std::string get_text(const level_map* pMap, int iNodeX,
88 int iNodeY) = 0;
89
90 private:
91 size_t background_sprite{};
92};
93
95 public:
96 const std::string get_text(const level_map* pMap, int iNodeX,
97 int iNodeY) override;
98};
99
101 public:
103 const level_map* pMap, int iNodeX, int iNodeY) override;
104};
105
107 public:
109 const level_map* pMap, int iNodeX, int iNodeY) override;
110};
111
112#endif
Definition th_gfx_font.h:81
Definition th_map.h:252
Definition th_map_overlays.h:100
void draw_cell(render_target *pCanvas, int iCanvasX, int iCanvasY, const level_map *pMap, int iNodeX, int iNodeY) override
Definition th_map_overlays.cpp:94
Definition th_map_overlays.h:43
map_overlay_pair()=default
void set_second(map_overlay *pOverlay, bool bTakeOwnership)
Definition th_map_overlays.cpp:48
void set_first(map_overlay *pOverlay, bool bTakeOwnership)
Definition th_map_overlays.cpp:40
~map_overlay_pair() override
Definition th_map_overlays.cpp:35
void draw_cell(render_target *pCanvas, int iCanvasX, int iCanvasY, const level_map *pMap, int iNodeX, int iNodeY) override
Definition th_map_overlays.cpp:56
Definition th_map_overlays.h:35
virtual void draw_cell(render_target *pCanvas, int iCanvasX, int iCanvasY, const level_map *pMap, int iNodeX, int iNodeY)=0
virtual ~map_overlay()=default
Definition th_map_overlays.h:106
void draw_cell(render_target *pCanvas, int iCanvasX, int iCanvasY, const level_map *pMap, int iNodeX, int iNodeY) override
Definition th_map_overlays.cpp:158
Definition th_map_overlays.h:94
const std::string get_text(const level_map *pMap, int iNodeX, int iNodeY) override
Definition th_map_overlays.cpp:82
Definition th_map_overlays.h:78
map_text_overlay()=default
virtual const std::string get_text(const level_map *pMap, int iNodeX, int iNodeY)=0
~map_text_overlay() override=default
void draw_cell(render_target *pCanvas, int iCanvasX, int iCanvasY, const level_map *pMap, int iNodeX, int iNodeY) override
Definition th_map_overlays.cpp:71
void set_background_sprite(size_t iSprite)
Definition th_map_overlays.cpp:67
Definition th_map_overlays.h:59
void draw_text(render_target *pCanvas, int iX, int iY, std::string_view str)
Definition th_map_overlays.cpp:179
sprite_sheet * sprites
Definition th_map_overlays.h:70
void set_sprites(sprite_sheet *pSheet, bool bTakeOwnership)
Definition th_map_overlays.cpp:186
~map_typical_overlay() override
Definition th_map_overlays.cpp:89
void set_font(::font *font, bool take_ownership)
Definition th_map_overlays.cpp:195
map_typical_overlay()=default
Definition th_gfx_sdl.h:247
Sheet of sprites.
Definition th_gfx_sdl.h:504