PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
file_formats.h
Go to the documentation of this file.
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2014-2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program 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  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
26 #ifndef FILE_FORMATS_H
27 #define FILE_FORMATS_H
28 
29 #include "pge_file_lib_globs.h"
30 #include "lvl_filedata.h"
31 #include "npc_filedata.h"
32 #include "wld_filedata.h"
33 #include "save_filedata.h"
34 #include "smbx64_cnf_filedata.h"
35 
40 #ifdef PGE_FILES_QT
41 class FileFormats: PGE_FILES_INHERED
42 {
43  Q_OBJECT
44 #else
46 {
47 #endif
48 
49 public:
50 
51 //File format read/write functions
60 
66  static PGESTRING WriteNonSMBX64MetaData(MetaData metaData);
67 
68 /******************************Level files***********************************/
74  static LevelData OpenLevelFile(PGESTRING filePath);
80  static LevelData OpenLevelFileHeader(PGESTRING filePath);
81 
82 // SMBX64 LVL File
95  static LevelData ReadSMBX64LvlFile(PGESTRING RawData, PGESTRING filePath="");
102  static PGESTRING WriteSMBX64LvlFile(LevelData FileData, int file_format=64);
103 
104 
105 
106 // PGE Extended Level File
113 
120  static LevelData ReadExtendedLvlFile(PGESTRING RawData, PGESTRING filePath="");
121 
127  static PGESTRING WriteExtendedLvlFile(LevelData FileData);
128 
129 // Lvl Data
134  static LevelData CreateLevelData();
139  static LevelNPC CreateLvlNpc();
144  static LevelDoor CreateLvlWarp();
149  static LevelBlock CreateLvlBlock();
154  static LevelBGO CreateLvlBgo();
164  static LevelLayer CreateLvlLayer();
174  static PlayerPoint CreateLvlPlayerPoint(int id=0);
180 
185  static void smbx64LevelPrepare(LevelData &lvl);
186 
193  static void smbx64LevelSortBlocks(LevelData &lvl);
194 
201  static void smbx64LevelSortBGOs(LevelData &lvl);
202 
203 
204 /******************************World file***********************************/
210  static WorldData OpenWorldFile(PGESTRING filePath);
216  static WorldData OpenWorldFileHeader(PGESTRING filePath);
217 
218 // SMBX64 WLD File
231  static WorldData ReadSMBX64WldFile(PGESTRING RawData, PGESTRING filePath);
238  static PGESTRING WriteSMBX64WldFile(WorldData FileData, int file_format=64);
239 
240 // PGE Extended World map File
253  static WorldData ReadExtendedWldFile(PGESTRING RawData, PGESTRING filePath);
259  static PGESTRING WriteExtendedWldFile(WorldData FileData);
260 
261 //Wld Data
266  static WorldData CreateWorldData();
271  static WorldTiles CreateWldTile();
281  static WorldPaths CreateWldPath();
286  static WorldLevels CreateWldLevel();
291  static WorldMusic CreateWldMusicbox();
292 
293 
294 /****************************Save of game file********************************/
301  static GamesaveData ReadSMBX64SavFile(PGESTRING RawData, PGESTRING filePath);
302 
309  static GamesaveData ReadExtendedSaveFile(PGESTRING RawData, PGESTRING filePath);
315  static PGESTRING WriteExtendedSaveFile(GamesaveData &FileData);
316 
317 //Save Data
328 
329 /****************************SMBX64 Config file********************************/
342  static PGESTRING WriteSMBX64ConfigFile(SMBX64_ConfigFile &FileData, int file_format);
343 
344 /******************************NPC.txt file***********************************/
345 // SMBX64 NPC.TXT File
352  static NPCConfigFile ReadNpcTXTFile(PGESTRING file, bool IgnoreBad=false);
358  static PGESTRING WriteNPCTxtFile(NPCConfigFile FileData);
359 
365 
366 /******************************common stuff***********************************/
385  };
391  static PGESTRING getErrorString(ErrorCodes errCode);
392 
398  SMBX64_FINE = 0x000,
404  SMBX64EXC_BGOS = 0x004,
406  SMBX64EXC_NPCS = 0x008,
425  };
426 
427 //Check SMBX64 limits
433  static int smbx64LevelCheckLimits(LevelData &lvl);
439  static int smbx64WorldCheckLimits(WorldData &wld);
440 
441 /******************************Internal stuff***********************************/
450  static PGESTRING removeQuotes(PGESTRING str);
453 };
454 
455 #endif // FILE_FORMATS_H
456 
File data structure has exited limit of Warp entries.
Definition: file_formats.h:410
static LevelData OpenLevelFileHeader(PGESTRING filePath)
Parses a level file header only with auto-detection of a file type (SMBX1...64 LVL or PGE-LVLX) ...
Definition: file_rwopen.cpp:61
static WorldData OpenWorldFile(PGESTRING filePath)
Parses a world map file with auto-detection of a file type (SMBX1...64 LVL or PGE-WLDX) ...
Definition: file_rwopen.cpp:86
static PGESTRING getErrorString(ErrorCodes errCode)
Get detailed information from returned error code.
Definition: file_formats.cpp:53
static SMBX64_ConfigFile ReadSMBX64ConfigFile(PGESTRING RawData)
Parses SMBX Engine config file raw data string.
Definition: file_rw_smbx64_cnf.cpp:31
Definition: wld_filedata.h:26
static saveCharState CreateSavCharacterState()
Inirializes Game Save specific playable character state entry.
Definition: save_filedata.cpp:25
static WorldLevels CreateWldLevel()
Initializes World map specific Level Entrance point entry structure with default properties.
Definition: wld_filedata.cpp:78
File data structure has exited limit of Path entries.
Definition: file_formats.h:420
static WorldData ReadSMBX64WldFile(PGESTRING RawData, PGESTRING filePath)
Parses SMBX1...64 World map file from raw data.
Definition: file_rw_wld.cpp:125
File data structure has exited limit of Music Box entries.
Definition: file_formats.h:424
static WorldData ReadSMBX64WldFileHeader(PGESTRING filePath)
Parsed SMBX1...64 World map file header only.
Definition: file_rw_wld.cpp:30
File data structure has exited limit of Tile entries.
Definition: file_formats.h:416
#define PGESTRING
A macro which equal to std::string if PGE File Library built in the STL mode and equal to QString if ...
Definition: pge_file_lib_globs.h:97
static WorldScenery CreateWldScenery()
Initializes World map specific Scenery entry structure with default properties.
Definition: wld_filedata.cpp:54
Definition: save_filedata.h:27
Definition: wld_filedata.h:95
static WorldData CreateWorldData()
Generates blank initialized World map data structure.
Definition: wld_filedata.cpp:124
static LevelData ReadSMBX64LvlFile(PGESTRING RawData, PGESTRING filePath="")
Parses SMBX1...64 level file data.
Definition: file_rw_lvl.cpp:92
static LevelNPC CreateLvlNpc()
Initializes Level specific NPC entry structure with default properties.
Definition: lvl_filedata.cpp:212
static GamesaveData ReadExtendedSaveFile(PGESTRING RawData, PGESTRING filePath)
Parses PGE-X Game save file from raw data string.
Definition: file_rw_savx.cpp:32
PGE-X File contains a not closed data section.
Definition: file_formats.h:380
static LevelData CreateLevelData()
Generates blank initialized level data structure.
Definition: lvl_filedata.cpp:442
Level specific Section entry structure. Defines prererences of one section.
Definition: lvl_filedata.h:33
static WorldTiles CreateWldTile()
Initializes World map specific Tile entry structure with default properties.
Definition: wld_filedata.cpp:42
File data structure has exited limit of section entries.
Definition: file_formats.h:400
static LevelLayer CreateLvlLayer()
Initializes Level specific Layer entry structure with default properties.
Definition: lvl_filedata.cpp:409
static PGESTRING WriteExtendedSaveFile(GamesaveData &FileData)
Generate raw data in PGE-X Game save file from GameSave data structure.
Definition: file_rw_savx.cpp:223
static NPCConfigFile ReadNpcTXTFile(PGESTRING file, bool IgnoreBad=false)
Parses SMBX64 NPC.txt file.
Definition: file_rw_npc_txt.cpp:39
Definition: npc_filedata.h:24
static LevelData ReadExtendedLvlFile(PGESTRING RawData, PGESTRING filePath="")
Parses PGE-X level file data.
Definition: file_rw_lvlx.cpp:136
Level specific Layer entry structure.
Definition: lvl_filedata.h:291
static PGESTRING WriteSMBX64ConfigFile(SMBX64_ConfigFile &FileData, int file_format)
Generates SMBX Engine specific config file raw data string.
Definition: file_rw_smbx64_cnf.cpp:90
Level specific NPC entry structure. Defines preferences of each NPC.
Definition: lvl_filedata.h:195
Level specific Warp entry structure. Defines preferences of each Warp entry.
Definition: lvl_filedata.h:231
static PGESTRING WriteSMBX64LvlFile(LevelData FileData, int file_format=64)
Generates SMBX1...64 Level file data.
Definition: file_rw_lvl.cpp:680
File data structure has exited limit of Level Entrance point entries.
Definition: file_formats.h:422
Access to requested file is denied by operation system.
Definition: file_formats.h:376
static WorldData ReadExtendedWldFile(PGESTRING RawData, PGESTRING filePath)
Parses PGE-X World map file from raw data.
Definition: file_rw_wldx.cpp:163
static PGESTRING WriteExtendedLvlFile(LevelData FileData)
Generates PGE-X Level file.
Definition: file_rw_lvlx.cpp:821
PGE-X File contains invalid syntax in the data entried.
Definition: file_formats.h:382
static WorldMusic CreateWldMusicbox()
Initializes World map specific Music Box entry structure with default properties. ...
Definition: wld_filedata.cpp:111
static PGESTRING WriteSMBX64WldFile(WorldData FileData, int file_format=64)
Generates raw data string in SMBX1...64 World map format.
Definition: file_rw_wld.cpp:344
static LevelData ReadSMBX64LvlFileHeader(PGESTRING filePath)
Parses SMBX1...64 level file header and skips other part of a file.
Definition: file_rw_lvl.cpp:35
static GamesaveData CreateGameSaveData()
Initializes blank game save data structure with default preferences.
Definition: save_filedata.cpp:40
File data structure has exited limit of Layer entries.
Definition: file_formats.h:412
static PGESTRING errorString
String which contains info about last happened error.
Definition: file_formats.h:452
static LevelData OpenLevelFile(PGESTRING filePath)
Parses a level file with auto-detection of a file type (SMBX1...64 LVL or PGE-LVLX) ...
Definition: file_rwopen.cpp:31
static void smbx64LevelSortBGOs(LevelData &lvl)
Sorts Background objects by special order priority value Modifying of order priority values allowing ...
Definition: lvl_filedata.cpp:125
PGE File library class of static functions. Library is buildable in both Qt and STL applications...
Definition: file_formats.h:45
static WorldPaths CreateWldPath()
Initializes World map specific Path entry structure with default properties.
Definition: wld_filedata.cpp:66
Contains data structure definitions for a level file data.
static LevelSMBX64Event CreateLvlEvent()
Initializes Level specific SMBX64 Event entry structure with default properties.
Definition: lvl_filedata.cpp:334
static NPCConfigFile CreateEmpytNpcTXT()
Initialize blank NPC Customizing Config data structure.
Definition: npc_filedata.cpp:26
Level specific Background object entry structure. Defines preferences of each Background object...
Definition: lvl_filedata.h:138
Definition: smbx64_cnf_filedata.h:47
File data structure has exited limit of Scenery entries.
Definition: file_formats.h:418
Definition: wld_filedata.h:59
static WorldData ReadExtendedWldFileHeader(PGESTRING filePath)
Parsed PGE-X World map file header only.
Definition: file_rw_wldx.cpp:43
static LevelPhysEnv CreateLvlPhysEnv()
Initializes Level specific Physical Environment Zone entry structure with default properties...
Definition: lvl_filedata.cpp:318
Level data structure. Contains all available settings and element lists on the level.
Definition: lvl_filedata.h:396
static void smbx64LevelPrepare(LevelData &lvl)
Optimizing level data for SMBX64 Standard requirements.
Definition: lvl_filedata.cpp:39
file has been successfully parses
Definition: file_formats.h:372
File data structure has exited limit of NPC entries.
Definition: file_formats.h:406
Contains additional helpful meda-data used by PGE Applications.
Definition: meta_filedata.h:81
static LevelData ReadExtendedLvlFileHeader(PGESTRING filePath)
Parses PGE-X Level file header.
Definition: file_rw_lvlx.cpp:56
Level specific Block entry structure. Defines preferences of each block.
Definition: lvl_filedata.h:95
static void smbx64LevelSortBlocks(LevelData &lvl)
Sorts blocks array by Y->X positions in the given level data structure. By SMBX64 standard...
Definition: lvl_filedata.cpp:71
static LevelBGO CreateLvlBgo()
Initializes Level specific Background Object entry structure with default properties.
Definition: lvl_filedata.cpp:296
static WorldData OpenWorldFileHeader(PGESTRING filePath)
Parses a world map file header only with auto-detection of a file type (SMBX1...64 LVL or PGE-WLDX) ...
Definition: file_rwopen.cpp:118
SMBX64_violations
SMBX64 Standrd specific violation codes.
Definition: file_formats.h:396
Definition: wld_filedata.h:48
static LevelBlock CreateLvlBlock()
Initializes Level specific Block entry structure with default properties.
Definition: lvl_filedata.cpp:275
File data structure has exited limit of Background Object entries.
Definition: file_formats.h:404
File data structure has exited limit of block entries.
Definition: file_formats.h:402
File data structure has exited limit of Water boxes entries.
Definition: file_formats.h:408
static LevelDoor CreateLvlWarp()
Initializes Level specific Warp entry structure with default properties.
Definition: lvl_filedata.cpp:242
Level specific Physical Environment entry structure. Defines preferences of each Physical Environment...
Definition: lvl_filedata.h:269
static PGESTRING WriteNPCTxtFile(NPCConfigFile FileData)
Generates NPC.txt raw data string in SMBX64 NPC.txt format.
Definition: file_rw_npc_txt.cpp:657
static int smbx64WorldCheckLimits(WorldData &wld)
Validates World map file data structure to conformation to SMBX64 Standard.
Definition: wld_filedata.cpp:23
Definition: wld_filedata.h:83
static LevelSection CreateLvlSection()
Initializes Level specific Section Settings entry structure with default properties.
Definition: lvl_filedata.cpp:386
File data structure has exited limit of Event entries.
Definition: file_formats.h:414
static PGESTRING WriteExtendedWldFile(WorldData FileData)
Generates raw data string in PGE-X World map format.
Definition: file_rw_wldx.cpp:440
Requested file is not exist.
Definition: file_formats.h:374
Level specific Classic Event Entry structure.
Definition: lvl_filedata.h:321
Definition: wld_filedata.h:37
static MetaData ReadNonSMBX64MetaData(PGESTRING RawData)
Parses non-SMBX64 meta-data from additional *.meta files there are contains data which impossible to ...
Definition: file_rw_meta.cpp:30
Level specific Player spawn point entry definition structure.
Definition: lvl_filedata.h:76
static int smbx64LevelCheckLimits(LevelData &lvl)
Validates level file data structure to conformation to SMBX64 Standard.
Definition: lvl_filedata.cpp:181
PGE-X File data field has invalid data type.
Definition: file_formats.h:384
static PGESTRING WriteNonSMBX64MetaData(MetaData metaData)
Generates raw data of non-SMBX meta-data file from Meta-data structure.
Definition: file_rw_meta.cpp:311
static PlayerPoint CreateLvlPlayerPoint(int id=0)
Initializes Level specific Player spawn point entry structure with default properties.
Definition: lvl_filedata.cpp:419
File data is conforms to the SMBX64 Standard.
Definition: file_formats.h:398
static PGESTRING removeQuotes(PGESTRING str)
Removes edge dobule quoties characters from a string for example '"Meow"' (without signgle-quotes cha...
Definition: file_formats.cpp:32
ErrorCodes
File parse error codes.
Definition: file_formats.h:370
static GamesaveData ReadSMBX64SavFile(PGESTRING RawData, PGESTRING filePath)
Parses SMBX1...64 Game save file from raw data string.
Definition: file_rw_sav.cpp:36
Contains internal settings and references for PGE File Library.
Definition: save_filedata.h:42
File contains invalid format syntax.
Definition: file_formats.h:378