Wizard Engine
2D cross-platform game engine built around SDL2
 
Loading...
Searching...
No Matches
assets.hpp
Go to the documentation of this file.
1/*
2 Wizard Engine
3 Copyright (C) 2023-2024 Zana Domán
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22#ifndef WIZARD_ENGINE_ASSETS_HPP
23#define WIZARD_ENGINE_ASSETS_HPP
24
27
28namespace wze {
35using image = SDL_Surface;
36
42using texture = SDL_Texture;
43
50using sound = Mix_Chunk;
51
58using font = TTF_Font;
59
65using cursor = SDL_Cursor;
66
72class assets final {
73 private:
79 static constexpr char const* _assets =
80#ifdef __ANDROID__
81 ""
82#else /* __ANDROID__ */
83 "./assets/"
84#endif /* __ANDROID__ */
85 ;
86
92 assets() = default;
93
101 static void combine_hash(size_t& seed, size_t value);
102
103 public:
113 [[nodiscard]] static std::shared_ptr<image>
114 load_image(std::string const& path);
115
127 [[nodiscard]] static std::shared_ptr<image>
128 create_image(std::string const& text, std::shared_ptr<font> const& font,
129 uint32_t wrap_length = 0);
130
138 [[nodiscard]] static size_t hash_image(std::shared_ptr<image> const& image);
139
148 [[nodiscard]] static std::shared_ptr<texture>
149 create_texture(std::shared_ptr<image> const& image);
150
160 [[nodiscard]] static std::shared_ptr<sound>
161 load_sound(std::string const& path);
162
170 [[nodiscard]] static size_t hash_sound(std::shared_ptr<sound> const& sound);
171
184 [[nodiscard]] static std::shared_ptr<font>
185 // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
186 load_font(std::string const& path, uint8_t size = 48,
187 font_style style = FONT_STYLE_NORMAL,
188 font_alignment alignment = FONT_ALIGNMENT_LEFT);
189
198 [[nodiscard]] static std::unique_ptr<cursor, std::function<void(cursor*)>>
199 create_cursor(system_cursor system_cursor);
200
211 [[nodiscard]] static std::unique_ptr<cursor, std::function<void(cursor*)>>
212 create_cursor(std::shared_ptr<image> const& image, uint16_t hot_x = 0,
213 uint16_t hot_y = 0);
214};
215} /* namespace wze */
216
217#endif /* WIZARD_ENGINE_ASSETS_HPP */
Enumerations.
Export header of the Wizard Engine.
Wizard Engine.
font_style
Font styles.
Definition enums.hpp:59
system_cursor
System cursors.
Definition enums.hpp:352
font_alignment
Font alignments.
Definition enums.hpp:48