-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgame_resources.cpp
267 lines (224 loc) · 6.42 KB
/
game_resources.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#include "game_resources.h"
#ifndef LOGIC_ONLY
#include <QFile>
#include <cassert>
#include <optional>
std::optional<fonts> game_resources::m_fonts;
std::optional<lobby_menu_textures> game_resources::m_lobby_menu_textures = {};
std::optional<options_menu_textures> game_resources::m_options_menu_textures = {};
std::optional<loading_screen_fonts> game_resources::m_loading_screen_fonts = {};
loading_screen_songs * game_resources::m_loading_screen_songs{nullptr};
std::optional<loading_screen_textures> game_resources::m_loading_screen_textures = {};
std::optional<map_textures> game_resources::m_map_textures = {};
std::optional<piece_action_textures> game_resources::m_piece_action_textures = {};
std::optional<piece_textures> game_resources::m_piece_textures = {};
std::optional<piece_portrait_textures> game_resources::m_piece_portrait_textures = {};
songs * game_resources::m_songs{nullptr};
sound_effects * game_resources::m_sound_effects{nullptr};
std::optional<textures> game_resources::m_textures = {};
game_resources::game_resources()
{
}
sf::Texture& get_action_icon(
game_resources& gr,
piece_action_type t
) noexcept
{
return gr.get_piece_action_textures().get_texture(t);
}
sf::Font& get_arial_font(game_resources& r) noexcept
{
return r.get_fonts().get_arial_font();
}
sf::Font& get_code_squared_font(game_resources& r) noexcept
{
return r.get_fonts().get_code_squared_font();
}
fonts& game_resources::get_fonts() noexcept
{
if (!m_fonts) m_fonts = fonts();
assert(m_fonts);
return m_fonts.value();
}
sf::Texture& get_game_option_icon(
game_resources& gr,
const options_view_item item
) noexcept
{
return gr.get_options_menu_textures().get_texture(item);
}
lobby_menu_textures& game_resources::get_lobby_menu_textures() noexcept
{
if (!m_lobby_menu_textures) m_lobby_menu_textures = lobby_menu_textures();
assert(m_lobby_menu_textures);
return m_lobby_menu_textures.value();
}
options_menu_textures& game_resources::get_options_menu_textures() noexcept
{
if (!m_options_menu_textures) m_options_menu_textures = options_menu_textures();
assert(m_options_menu_textures);
return m_options_menu_textures.value();
}
int game_resources::get_n_fonts() noexcept
{
return get_fonts().get_n_fonts();
}
loading_screen_fonts& game_resources::get_loading_screen_fonts() noexcept
{
if (!m_loading_screen_fonts) m_loading_screen_fonts = loading_screen_fonts();
assert(m_loading_screen_fonts);
return m_loading_screen_fonts.value();
}
loading_screen_songs& game_resources::get_loading_screen_songs() noexcept
{
if (!m_loading_screen_songs)
{
m_loading_screen_songs = new loading_screen_songs();
}
assert(m_loading_screen_songs);
return *m_loading_screen_songs;
}
loading_screen_textures& game_resources::get_loading_screen_textures() noexcept
{
if (!m_loading_screen_textures) m_loading_screen_textures = loading_screen_textures();
assert(m_loading_screen_textures);
return m_loading_screen_textures.value();
}
sf::Texture& get_map(
game_resources& gr,
const race r
) noexcept
{
return gr.get_map_textures().get_map(r);
}
map_textures& game_resources::get_map_textures() noexcept
{
if (!m_map_textures) m_map_textures = map_textures();
assert(m_map_textures);
return m_map_textures.value();
}
int game_resources::get_n_lobby_menu_textures() noexcept
{
return get_lobby_menu_textures().get_n_textures();
}
int game_resources::get_n_options_menu_textures() noexcept
{
return get_options_menu_textures().get_n_textures();
}
int game_resources::get_n_loading_screen_fonts() noexcept
{
return get_loading_screen_fonts().get_n_fonts();
}
int game_resources::get_n_loading_screen_songs() noexcept
{
return get_loading_screen_songs().get_n_songs();
}
int game_resources::get_n_loading_screen_textures() noexcept
{
return get_loading_screen_textures().get_n_textures();
}
int game_resources::get_n_map_textures() noexcept
{
return get_map_textures().get_n_textures();
}
int game_resources::get_n_piece_action_textures() noexcept
{
return get_piece_action_textures().get_n_textures();
}
int game_resources::get_n_piece_portrait_textures() noexcept
{
return get_piece_portrait_textures().get_n_textures();
}
int game_resources::get_n_piece_textures() noexcept
{
return get_piece_textures().get_n_textures();
}
int game_resources::get_n_songs() noexcept
{
return get_songs().get_n_songs();
}
int game_resources::get_n_sound_effects() noexcept
{
return get_sound_effects().get_n_sound_effects();
}
int game_resources::get_n_textures() noexcept
{
return get_textures().get_n_textures();
}
sf::Texture& get_piece(
game_resources& gr,
const race r,
const chess_color color,
const piece_type type
)
{
return gr.get_piece_textures().get_piece(r, color, type);
}
sf::Texture& get_piece_portrait(
game_resources& gr,
const race r,
const chess_color color,
const piece_type type
)
{
return gr.get_piece_portrait_textures().get_portrait(r, color, type);
}
piece_action_textures& game_resources::get_piece_action_textures() noexcept
{
if (!m_piece_action_textures) m_piece_action_textures = piece_action_textures();
assert(m_piece_action_textures);
return m_piece_action_textures.value();
}
piece_portrait_textures& game_resources::get_piece_portrait_textures() noexcept
{
if (!m_piece_portrait_textures) m_piece_portrait_textures = piece_portrait_textures();
assert(m_piece_portrait_textures);
return m_piece_portrait_textures.value();
}
piece_textures& game_resources::get_piece_textures() noexcept
{
if (!m_piece_textures) m_piece_textures = piece_textures();
assert(m_piece_textures);
return m_piece_textures.value();
}
songs& game_resources::get_songs() noexcept
{
if (!m_songs)
{
m_songs = new songs();
}
assert(m_songs);
return *m_songs;
}
sound_effects& game_resources::get_sound_effects() noexcept
{
if (!m_sound_effects) m_sound_effects = new sound_effects();
assert(m_sound_effects);
return *m_sound_effects;
}
textures& game_resources::get_textures() noexcept
{
if (!m_textures) m_textures = textures();
assert(m_textures);
return m_textures.value();
}
sf::Texture& get_strip(game_resources& r, const chess_color c) noexcept
{
return r.get_textures().get_strip(c);
}
sf::Texture& get_subtitle(game_resources& r) noexcept
{
return r.get_textures().get_subtitle();
}
sf::Texture& get_title(game_resources& r) noexcept
{
return r.get_textures().get_title();
}
void play(
game_resources& r,
const message& effect
)
{
r.get_sound_effects().play(effect);
}
#endif // LOGIC_ONLY