V-Gears 0
Free Final Fantasy VII engine.
VGearsBackgroundFileSerializer.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 void ImportBackgroundFile(Ogre::DataStreamPtr &stream, BackgroundFile *dest);
48
49 enum {
50
54 BIT_MASK_RED = 0xF800,
55
60
64 BIT_MASK_BLUE = 0x001F,
65
69 BIT_SIZE = 0x001F,
70
75
79 SPRITE_DST_MAX = 1024
80 };
81
85 struct Header{
86
91
96 };
97
99
101
103
105
107
108 protected:
109
115 virtual void ReadFileHeader(Ogre::DataStreamPtr &stream);
116
123 virtual void ReadSectionHeader(Ogre::DataStreamPtr &stream, const String &section_name);
124
131 virtual void ReadPallete(Ogre::DataStreamPtr &stream, BackgroundFile *dest);
132
139 virtual void ReadBackground(Ogre::DataStreamPtr &stream, BackgroundFile *dest);
140
147 virtual void ReadTexture(Ogre::DataStreamPtr &stream, BackgroundFile *dest);
148
154 virtual void ReadEnd(Ogre::DataStreamPtr &stream);
155
163 virtual void ReadLayer(Ogre::DataStreamPtr &stream, Layer *dest, size_t layer_index);
164
171 virtual void readObject(Ogre::DataStreamPtr &stream, SpriteData &dest);
172
179 virtual void readObject(Ogre::DataStreamPtr &stream, Color &dest);
180
187 virtual void readObject(Ogre::DataStreamPtr &stream, Page &dest);
188
190
198 template<typename ValueType> void ReadVector(
199 Ogre::DataStreamPtr &stream, std::vector<ValueType> &dest, size_t count
200 ){
201 dest.clear();
202 dest.reserve(count);
203 for (size_t i(count); i --;){
204 ValueType in_tmp;
205 readObject(stream, in_tmp);
206 dest.push_back(in_tmp);
207 }
208 }
209
214
219
224
228 static const String TAG_FILE_END;
229
233 static const Ogre::Real SRC_BIG_SCALE;
234
235 private:
236
243 void RemoveBuggySprites(SpriteList &sprites);
244
249
254 };
255}
Handles the serialization of background files.
Definition: VGearsBackgroundFileSerializer.h:27
void RemoveBuggySprites(SpriteList &sprites)
Removes malformed sprites from the map.
Definition: VGearsBackgroundFileSerializer.cpp:121
void ImportBackgroundFile(Ogre::DataStreamPtr &stream, BackgroundFile *dest)
Imports a background file.
Definition: VGearsBackgroundFileSerializer.cpp:40
@ BIT_MASK_RGB
Bitmask for RGB colour.
Definition: VGearsBackgroundFileSerializer.h:74
@ BIT_MASK_GREEN
Bitmask for green colour.
Definition: VGearsBackgroundFileSerializer.h:59
@ BIT_MASK_BLUE
Bitmask for blue colour.
Definition: VGearsBackgroundFileSerializer.h:64
@ BIT_MASK_RED
Bitmask for red colour.
Definition: VGearsBackgroundFileSerializer.h:54
@ SPRITE_DST_MAX
Definition: VGearsBackgroundFileSerializer.h:79
@ BIT_SIZE
Definition: VGearsBackgroundFileSerializer.h:69
static const Ogre::Real SRC_BIG_SCALE
Definition: VGearsBackgroundFileSerializer.h:233
BackgroundFile::SpriteData SpriteData
Definition: VGearsBackgroundFileSerializer.h:100
static const String TAG_FILE_END
End-of-file tag.
Definition: VGearsBackgroundFileSerializer.h:228
BackgroundFileSerializer()
Constructor.
Definition: VGearsBackgroundFileSerializer.cpp:34
virtual void readObject(Ogre::DataStreamPtr &stream, SpriteData &dest)
Reads an object as a sprite.
Definition: VGearsBackgroundFileSerializer.cpp:136
virtual void ReadFileHeader(Ogre::DataStreamPtr &stream)
Reads a background file header.
Definition: VGearsBackgroundFileSerializer.cpp:52
size_t layer_index_
Definition: VGearsBackgroundFileSerializer.h:253
virtual void ReadLayer(Ogre::DataStreamPtr &stream, Layer *dest, size_t layer_index)
Reads a layer from a background file.
Definition: VGearsBackgroundFileSerializer.cpp:97
BackgroundFile::Layer Layer
Definition: VGearsBackgroundFileSerializer.h:98
virtual ~BackgroundFileSerializer()
Destructor.
Definition: VGearsBackgroundFileSerializer.cpp:38
void ReadVector(Ogre::DataStreamPtr &stream, std::vector< ValueType > &dest, size_t count)
Reads a stream as a vector.
Definition: VGearsBackgroundFileSerializer.h:198
virtual void ReadEnd(Ogre::DataStreamPtr &stream)
Definition: VGearsBackgroundFileSerializer.cpp:74
BackgroundFile::Page Page
Definition: VGearsBackgroundFileSerializer.h:104
BackgroundFile::SpriteList SpriteList
Definition: VGearsBackgroundFileSerializer.h:102
virtual void ReadTexture(Ogre::DataStreamPtr &stream, BackgroundFile *dest)
Reads texture data from a background file.
Definition: VGearsBackgroundFileSerializer.cpp:195
Header header_
The file header.
Definition: VGearsBackgroundFileSerializer.h:248
BackgroundFile::Color Color
Definition: VGearsBackgroundFileSerializer.h:106
virtual void ReadSectionHeader(Ogre::DataStreamPtr &stream, const String &section_name)
Reads a section of a background file header.
Definition: VGearsBackgroundFileSerializer.cpp:60
virtual void ReadBackground(Ogre::DataStreamPtr &stream, BackgroundFile *dest)
Reads background data from a background file.
Definition: VGearsBackgroundFileSerializer.cpp:86
static const String SECTION_NAME_PALETTE
Name of the palette section in the file.
Definition: VGearsBackgroundFileSerializer.h:213
virtual void ReadPallete(Ogre::DataStreamPtr &stream, BackgroundFile *dest)
Reads pallete data from a background file.
Definition: VGearsBackgroundFileSerializer.cpp:78
static const String SECTION_NAME_BACK
Name of the back section in the file.
Definition: VGearsBackgroundFileSerializer.h:218
static const String SECTION_NAME_TEXTURE
Name of the texture section in the file.
Definition: VGearsBackgroundFileSerializer.h:223
A background file representation.
Definition: VGearsBackgroundFile.h:32
PaletteFile::Color Color
Definition: VGearsBackgroundFile.h:285
std::vector< SpriteData > SpriteList
Definition: VGearsBackgroundFile.h:229
Handles file serialization.
Definition: VGearsSerializer.h:30
void readObject(Ogre::DataStreamPtr &stream, Ogre::Vector2 &dest)
Reads an object as a 2 dimensional vector.
Definition: VGearsSerializer.cpp:32
Definition: FF7NameLookup.h:24
Ogre::uint16 uint16
Definition: TypeDefine.h:32
Ogre::String String
Definition: TypeDefine.h:37
A background file header.
Definition: VGearsBackgroundFileSerializer.h:85
uint16 unused
Unused data.
Definition: VGearsBackgroundFileSerializer.h:90
uint16 sort_sprites_by_palette
Definition: VGearsBackgroundFileSerializer.h:95
A layer of a background.
Definition: VGearsBackgroundFile.h:241
A background page/.
Definition: VGearsBackgroundFile.h:294
Data for sprites.
Definition: VGearsBackgroundFile.h:135