tmxlite 1.0.0
lightweight parse for Tiled maps
ObjectTypes.hpp
1/*********************************************************************
2Raphaƫl Frantz 2021
3
4tmxlite - Zlib license.
5
6This software is provided 'as-is', without any express or
7implied warranty. In no event will the authors be held
8liable for any damages arising from the use of this software.
9
10Permission is granted to anyone to use this software for any purpose,
11including commercial applications, and to alter it and redistribute
12it freely, subject to the following restrictions:
13
141. The origin of this software must not be misrepresented;
15you must not claim that you wrote the original software.
16If you use this software in a product, an acknowledgment
17in the product documentation would be appreciated but
18is not required.
19
202. Altered source versions must be plainly marked as such,
21and must not be misrepresented as being the original software.
22
233. This notice may not be removed or altered from any
24source distribution.
25*********************************************************************/
26
27#pragma once
28
29#include <tmxlite/Property.hpp>
30
31#include <string>
32#include <vector>
33
34namespace tmx
35{
40 class TMXLITE_EXPORT_API ObjectTypes final
41 {
42 public:
47 struct Type
48 {
49 std::string name;
50 Colour colour;
51 std::vector<Property> properties;
52 };
53
60 bool load(const std::string&);
61
69 bool loadFromString(const std::string& data, const std::string& workingDir);
70
74 const std::vector<Type>& getTypes() const { return m_types; }
75
76 private:
77 std::string m_workingDirectory;
78 std::vector<Type> m_types;
79
80 bool parseObjectTypesNode(const pugi::xml_node&);
81
82 //always returns false so we can return this
83 //on load failure
84 bool reset();
85 };
86}
Parser for Tiled object types export format. Link to the specification: https://doc....
Definition ObjectTypes.hpp:41
const std::vector< Type > & getTypes() const
Returns all predefined types and their default values.
Definition ObjectTypes.hpp:74
bool loadFromString(const std::string &data, const std::string &workingDir)
Loads an object types from a document stored in a string.
bool load(const std::string &)
Attempts to parse the object types at the given location.
Contains the red, green, blue and alpha values of a colour in the range 0 - 255.
Definition Types.hpp:111
Types that stores all predefined properties for all objects of this type. To take less spaces,...
Definition ObjectTypes.hpp:48