git repos / blockattack-game

blame: source/code/editor/editor_loader.hpp

normal view · raw

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