V-Gears 0
Free Final Fantasy VII engine.
VGearsBackground2DFileXMLSerializer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include "common/TypeDefine.h"
21
22namespace VGears{
23
28
29 public:
30
35
40
47 virtual void ImportBackground2DFile(
48 Ogre::DataStreamPtr &stream, Background2DFile *dest
49 );
50
51 protected:
52
58 virtual void ReadHeader(TiXmlNode *node);
59
71 virtual bool ReadAttribute(
72 TiXmlNode &node, const String &attribute, Blending &dest, const Blending &def
73 );
74
76
83 virtual void readObject(TiXmlNode &node, Tile &dest);
84
91 virtual void readObject(TiXmlNode &node, Animation &dest);
92
99 virtual void readObject(TiXmlNode &node, KeyFrame &dest);
100
104 static const String BLENDING_ALPHA;
105
109 static const String BLENDING_ADD;
110
115
123 template<typename ValueType> void ReadVector(
124 TiXmlNode &node, const String &tag, std::vector<ValueType> &dest
125 ){
126 dest.clear();
127 TiXmlNode* child(node.FirstChild());
128 while (child != NULL){
129 if (
130 child->Type() == TiXmlNode::TINYXML_ELEMENT
131 && child->ValueStr() == tag
132 ){
133 ValueType in_tmp;
134 readObject(*child, in_tmp);
135 dest.push_back(in_tmp);
136 }
137 child = child->NextSibling();
138 }
139 }
140
149 template<typename KeyType, typename ValueType> void ReadMap(
150 TiXmlNode& node, const String& tag, const String& key_attribute,
151 std::map<KeyType, ValueType> &dest
152 ){
153 dest.clear();
154 TiXmlNode* child(node.FirstChild());
155 while (child != NULL){
156 if (
157 child->Type() == TiXmlNode::TINYXML_ELEMENT
158 && child->ValueStr() == tag
159 ){
160 KeyType key;
161 if (ReadAttribute(*child, key_attribute, key)){
162 ValueType in_tmp;
163 readObject(*child, in_tmp);
164 dest[key] = in_tmp;
165 }
166 }
167 child = child->NextSibling();
168 }
169 }
170
171 };
172}
Handles the serialization of 2D background XML files.
Definition: VGearsBackground2DFileXMLSerializer.h:27
static const String BLENDING_SUBTRACT
Substract-type blending key.
Definition: VGearsBackground2DFileXMLSerializer.h:114
virtual ~Background2DFileXMLSerializer()
Destructor.
Definition: VGearsBackground2DFileXMLSerializer.cpp:32
static const String BLENDING_ALPHA
Alpha-type blending key.
Definition: VGearsBackground2DFileXMLSerializer.h:104
Background2DFileXMLSerializer()
Constructor.
Definition: VGearsBackground2DFileXMLSerializer.cpp:28
virtual void ReadHeader(TiXmlNode *node)
Reads a file header and sets the instance data.
Definition: VGearsBackground2DFileXMLSerializer.cpp:34
void ReadMap(TiXmlNode &node, const String &tag, const String &key_attribute, std::map< KeyType, ValueType > &dest)
Reads a XML node as a map.
Definition: VGearsBackground2DFileXMLSerializer.h:149
virtual void ImportBackground2DFile(Ogre::DataStreamPtr &stream, Background2DFile *dest)
Imports a 2D background XML file.
Definition: VGearsBackground2DFileXMLSerializer.cpp:69
virtual bool ReadAttribute(TiXmlNode &node, const String &attribute, Blending &dest, const Blending &def)
Reads an XMl node attribute as tile blending information.
Definition: VGearsBackground2DFileXMLSerializer.cpp:44
virtual void readObject(TiXmlNode &node, Tile &dest)
Reads an XML node as a tile.
Definition: VGearsBackground2DFileXMLSerializer.cpp:108
void ReadVector(TiXmlNode &node, const String &tag, std::vector< ValueType > &dest)
Reads a XML node as a vector.
Definition: VGearsBackground2DFileXMLSerializer.h:123
static const String BLENDING_ADD
Add-type blending key.
Definition: VGearsBackground2DFileXMLSerializer.h:109
Handles 2D background files.
Definition: VGearsBackground2DFile.h:30
Handles the serialization of XML files.
Definition: VGearsXMLSerializer.h:44
virtual const String * ReadAttribute(TiXmlNode &node, const String &attribute)
Reads an XMl node attribute as a string.
Definition: VGearsXMLSerializer.cpp:30
Definition: FF7NameLookup.h:24
Ogre::String String
Definition: TypeDefine.h:37
Blending
Definition: VGearsTile.h:23
A tile animation.
Definition: VGearsTile.h:62
A tile key frame.
Definition: VGearsTile.h:44
A tile.
Definition: VGearsTile.h:82