Debian Codegraph @

source/code/editor/editor_loader.hpp

raw
1 /*
2 ===========================================================================
3 * Sago Multi Scrambler Puzzle
4 Copyright (C) 2022-2024 Poul Sander
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
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see http://www.gnu.org/licenses/
18
19 Source information and contacts persons can be found at
20 https://github.com/sago007/saland
21 ===========================================================================
22 */
23
24 #include <string>
25 #include "nlohmann/json.hpp"
26 #include <vector>
27 #include <map>
28
29 struct SagoSprite {
30 std::string texture;
31 int topx = 0;
32 int topy = 0;
33 int height = 1;
34 int width = 1;
35 int number_of_frames = 1;
36 int frame_time = 1;
37 int originx = 0;
38 int originy = 0;
39
40 std::string meta_name = "";
41 std::string meta_from_file = "<memory>";
42 std::string meta_modified = "false";
43 };
44
45 struct SagoSpriteFile {
46 std::map<std::string, SagoSprite> sprites;
47 };
48
49 void to_json(nlohmann::json& j, const SagoSprite& p);
50
51 void from_json(const nlohmann::json& j, SagoSprite& p);
52
53 void from_json(const nlohmann::json& j, SagoSpriteFile& p);
54
55 void AppendFromJson(const std::string& json_content, const std::string& filename, std::map<std::string, SagoSprite>& sprites);
56
57 std::map<std::string, SagoSprite> LoadSprites();