PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
FileFormats Class Reference

PGE File library class of static functions. Library is buildable in both Qt and STL applications. More...

#include <file_formats.h>

Public Types

enum  ErrorCodes {
  Success =0, ERROR_NotExist, ERROR_AccessDenied, ERROR_InvalidSyntax,
  ERROR_PGEX_SectionNotClosed, ERROR_PGEX_InvalidSyntax, ERROR_PGEX_InvalidDataType
}
 File parse error codes. More...
 
enum  SMBX64_violations {
  SMBX64_FINE = 0x000, SMBX64EXC_SECTIONS = 0x001, SMBX64EXC_BLOCKS = 0x002, SMBX64EXC_BGOS = 0x004,
  SMBX64EXC_NPCS = 0x008, SMBX64EXC_WATERBOXES = 0x010, SMBX64EXC_WARPS = 0x020, SMBX64EXC_LAYERS = 0x040,
  SMBX64EXC_EVENTS = 0x080, SMBX64EXC_TILES = 0x100, SMBX64EXC_SCENERIES = 0x200, SMBX64EXC_PATHS = 0x400,
  SMBX64EXC_LEVELS = 0x800, SMBX64EXC_MUSICBOXES = 0x1000
}
 SMBX64 Standrd specific violation codes. More...
 

Static Public Member Functions

static MetaData ReadNonSMBX64MetaData (PGESTRING RawData)
 Parses non-SMBX64 meta-data from additional *.meta files there are contains data which impossible to save into SMBX64 LVL file therefore it will be saved into additional *.meta file. More...
 
static PGESTRING WriteNonSMBX64MetaData (MetaData metaData)
 Generates raw data of non-SMBX meta-data file from Meta-data structure. More...
 
static LevelData OpenLevelFile (PGESTRING filePath)
 Parses a level file with auto-detection of a file type (SMBX1...64 LVL or PGE-LVLX) More...
 
static LevelData OpenLevelFileHeader (PGESTRING filePath)
 Parses a level file header only with auto-detection of a file type (SMBX1...64 LVL or PGE-LVLX) More...
 
static LevelData ReadSMBX64LvlFileHeader (PGESTRING filePath)
 Parses SMBX1...64 level file header and skips other part of a file. More...
 
static LevelData ReadSMBX64LvlFile (PGESTRING RawData, PGESTRING filePath="")
 Parses SMBX1...64 level file data. More...
 
static PGESTRING WriteSMBX64LvlFile (LevelData FileData, int file_format=64)
 Generates SMBX1...64 Level file data. More...
 
static LevelData ReadExtendedLvlFileHeader (PGESTRING filePath)
 Parses PGE-X Level file header. More...
 
static LevelData ReadExtendedLvlFile (PGESTRING RawData, PGESTRING filePath="")
 Parses PGE-X level file data. More...
 
static PGESTRING WriteExtendedLvlFile (LevelData FileData)
 Generates PGE-X Level file. More...
 
static LevelData CreateLevelData ()
 Generates blank initialized level data structure. More...
 
static LevelNPC CreateLvlNpc ()
 Initializes Level specific NPC entry structure with default properties. More...
 
static LevelDoor CreateLvlWarp ()
 Initializes Level specific Warp entry structure with default properties. More...
 
static LevelBlock CreateLvlBlock ()
 Initializes Level specific Block entry structure with default properties. More...
 
static LevelBGO CreateLvlBgo ()
 Initializes Level specific Background Object entry structure with default properties. More...
 
static LevelPhysEnv CreateLvlPhysEnv ()
 Initializes Level specific Physical Environment Zone entry structure with default properties. More...
 
static LevelLayer CreateLvlLayer ()
 Initializes Level specific Layer entry structure with default properties. More...
 
static LevelSMBX64Event CreateLvlEvent ()
 Initializes Level specific SMBX64 Event entry structure with default properties. More...
 
static PlayerPoint CreateLvlPlayerPoint (int id=0)
 Initializes Level specific Player spawn point entry structure with default properties. More...
 
static LevelSection CreateLvlSection ()
 Initializes Level specific Section Settings entry structure with default properties. More...
 
static void smbx64LevelPrepare (LevelData &lvl)
 Optimizing level data for SMBX64 Standard requirements. More...
 
static void smbx64LevelSortBlocks (LevelData &lvl)
 Sorts blocks array by Y->X positions in the given level data structure. By SMBX64 standard, blocks array must be sorted because it is required for NPC's collision detection algorithm of SMBX Engine. More...
 
static void smbx64LevelSortBGOs (LevelData &lvl)
 Sorts Background objects by special order priority value Modifying of order priority values allowing to force specific non-foreground BGO's to be rendered foreground. More...
 
static WorldData OpenWorldFile (PGESTRING filePath)
 Parses a world map file with auto-detection of a file type (SMBX1...64 LVL or PGE-WLDX) More...
 
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) More...
 
static WorldData ReadSMBX64WldFileHeader (PGESTRING filePath)
 Parsed SMBX1...64 World map file header only. More...
 
static WorldData ReadSMBX64WldFile (PGESTRING RawData, PGESTRING filePath)
 Parses SMBX1...64 World map file from raw data. More...
 
static PGESTRING WriteSMBX64WldFile (WorldData FileData, int file_format=64)
 Generates raw data string in SMBX1...64 World map format. More...
 
static WorldData ReadExtendedWldFileHeader (PGESTRING filePath)
 Parsed PGE-X World map file header only. More...
 
static WorldData ReadExtendedWldFile (PGESTRING RawData, PGESTRING filePath)
 Parses PGE-X World map file from raw data. More...
 
static PGESTRING WriteExtendedWldFile (WorldData FileData)
 Generates raw data string in PGE-X World map format. More...
 
static WorldData CreateWorldData ()
 Generates blank initialized World map data structure. More...
 
static WorldTiles CreateWldTile ()
 Initializes World map specific Tile entry structure with default properties. More...
 
static WorldScenery CreateWldScenery ()
 Initializes World map specific Scenery entry structure with default properties. More...
 
static WorldPaths CreateWldPath ()
 Initializes World map specific Path entry structure with default properties. More...
 
static WorldLevels CreateWldLevel ()
 Initializes World map specific Level Entrance point entry structure with default properties. More...
 
static WorldMusic CreateWldMusicbox ()
 Initializes World map specific Music Box entry structure with default properties. More...
 
static GamesaveData ReadSMBX64SavFile (PGESTRING RawData, PGESTRING filePath)
 Parses SMBX1...64 Game save file from raw data string. More...
 
static GamesaveData ReadExtendedSaveFile (PGESTRING RawData, PGESTRING filePath)
 Parses PGE-X Game save file from raw data string. More...
 
static PGESTRING WriteExtendedSaveFile (GamesaveData &FileData)
 Generate raw data in PGE-X Game save file from GameSave data structure. More...
 
static GamesaveData CreateGameSaveData ()
 Initializes blank game save data structure with default preferences. More...
 
static saveCharState CreateSavCharacterState ()
 Inirializes Game Save specific playable character state entry. More...
 
static SMBX64_ConfigFile ReadSMBX64ConfigFile (PGESTRING RawData)
 Parses SMBX Engine config file raw data string. More...
 
static PGESTRING WriteSMBX64ConfigFile (SMBX64_ConfigFile &FileData, int file_format)
 Generates SMBX Engine specific config file raw data string. More...
 
static NPCConfigFile ReadNpcTXTFile (PGESTRING file, bool IgnoreBad=false)
 Parses SMBX64 NPC.txt file. More...
 
static PGESTRING WriteNPCTxtFile (NPCConfigFile FileData)
 Generates NPC.txt raw data string in SMBX64 NPC.txt format. More...
 
static NPCConfigFile CreateEmpytNpcTXT ()
 Initialize blank NPC Customizing Config data structure. More...
 
static PGESTRING getErrorString (ErrorCodes errCode)
 Get detailed information from returned error code. More...
 
static int smbx64LevelCheckLimits (LevelData &lvl)
 Validates level file data structure to conformation to SMBX64 Standard. More...
 
static int smbx64WorldCheckLimits (WorldData &wld)
 Validates World map file data structure to conformation to SMBX64 Standard. More...
 
static PGESTRING removeQuotes (PGESTRING str)
 Removes edge dobule quoties characters from a string for example '"Meow"' (without signgle-quotes characters) will be converted into 'Meow' (without signgle-quotes characters) More...
 

Static Public Attributes

static PGESTRING errorString =""
 String which contains info about last happened error.
 

Detailed Description

PGE File library class of static functions. Library is buildable in both Qt and STL applications.

Member Enumeration Documentation

File parse error codes.

Enumerator
Success 

file has been successfully parses

ERROR_NotExist 

Requested file is not exist.

ERROR_AccessDenied 

Access to requested file is denied by operation system.

ERROR_InvalidSyntax 

File contains invalid format syntax.

ERROR_PGEX_SectionNotClosed 

PGE-X File contains a not closed data section.

ERROR_PGEX_InvalidSyntax 

PGE-X File contains invalid syntax in the data entried.

ERROR_PGEX_InvalidDataType 

PGE-X File data field has invalid data type.

SMBX64 Standrd specific violation codes.

Enumerator
SMBX64_FINE 

File data is conforms to the SMBX64 Standard.

SMBX64EXC_SECTIONS 

File data structure has exited limit of section entries.

SMBX64EXC_BLOCKS 

File data structure has exited limit of block entries.

SMBX64EXC_BGOS 

File data structure has exited limit of Background Object entries.

SMBX64EXC_NPCS 

File data structure has exited limit of NPC entries.

SMBX64EXC_WATERBOXES 

File data structure has exited limit of Water boxes entries.

SMBX64EXC_WARPS 

File data structure has exited limit of Warp entries.

SMBX64EXC_LAYERS 

File data structure has exited limit of Layer entries.

SMBX64EXC_EVENTS 

File data structure has exited limit of Event entries.

SMBX64EXC_TILES 

File data structure has exited limit of Tile entries.

SMBX64EXC_SCENERIES 

File data structure has exited limit of Scenery entries.

SMBX64EXC_PATHS 

File data structure has exited limit of Path entries.

SMBX64EXC_LEVELS 

File data structure has exited limit of Level Entrance point entries.

SMBX64EXC_MUSICBOXES 

File data structure has exited limit of Music Box entries.

Member Function Documentation

NPCConfigFile FileFormats::CreateEmpytNpcTXT ( )
static

Initialize blank NPC Customizing Config data structure.

Returns
Blank NPC Customizing Config data structure
GamesaveData FileFormats::CreateGameSaveData ( )
static

Initializes blank game save data structure with default preferences.

Returns
Blank Game Save data structure
LevelData FileFormats::CreateLevelData ( )
static

Generates blank initialized level data structure.

Returns
Level data structure
LevelBGO FileFormats::CreateLvlBgo ( )
static

Initializes Level specific Background Object entry structure with default properties.

Returns
Initialized with default properties level specific Background Object entry structure
LevelBlock FileFormats::CreateLvlBlock ( )
static

Initializes Level specific Block entry structure with default properties.

Returns
Initialized with default properties level specific Block entry structure
LevelSMBX64Event FileFormats::CreateLvlEvent ( )
static

Initializes Level specific SMBX64 Event entry structure with default properties.

Returns
Initialized with default properties level specific SMBX64 Event entry structure
LevelLayer FileFormats::CreateLvlLayer ( )
static

Initializes Level specific Layer entry structure with default properties.

Returns
Initialized with default properties level specific Layer entry structure
LevelNPC FileFormats::CreateLvlNpc ( )
static

Initializes Level specific NPC entry structure with default properties.

Returns
Initialized with default properties level specific NPC entry structure
LevelPhysEnv FileFormats::CreateLvlPhysEnv ( )
static

Initializes Level specific Physical Environment Zone entry structure with default properties.

Returns
Initialized with default properties level specific Physical Environment Zone entry structure
PlayerPoint FileFormats::CreateLvlPlayerPoint ( int  id = 0)
static

Initializes Level specific Player spawn point entry structure with default properties.

Returns
Initialized with default properties level specific Player spawn point entry structure
LevelSection FileFormats::CreateLvlSection ( )
static

Initializes Level specific Section Settings entry structure with default properties.

Returns
Initialized with default properties level specific Section Settings entry structure
LevelDoor FileFormats::CreateLvlWarp ( )
static

Initializes Level specific Warp entry structure with default properties.

Returns
Initialized with default properties level specific Warp entry structure
saveCharState FileFormats::CreateSavCharacterState ( )
static

Inirializes Game Save specific playable character state entry.

Returns
Blank game save specific playable character state entry
WorldLevels FileFormats::CreateWldLevel ( )
static

Initializes World map specific Level Entrance point entry structure with default properties.

Returns
Initialized with default properties World map specific Level Entrance point entry structure
WorldMusic FileFormats::CreateWldMusicbox ( )
static

Initializes World map specific Music Box entry structure with default properties.

Returns
Initialized with default properties World map specific Music Box entry structure
WorldPaths FileFormats::CreateWldPath ( )
static

Initializes World map specific Path entry structure with default properties.

Returns
Initialized with default properties World map specific Path entry structure
WorldScenery FileFormats::CreateWldScenery ( )
static

Initializes World map specific Scenery entry structure with default properties.

Returns
Initialized with default properties World map specific Scenery entry structure
WorldTiles FileFormats::CreateWldTile ( )
static

Initializes World map specific Tile entry structure with default properties.

Returns
Initialized with default properties World map specific Tile entry structure
WorldData FileFormats::CreateWorldData ( )
static

Generates blank initialized World map data structure.

Returns
World map data structure
PGESTRING FileFormats::getErrorString ( FileFormats::ErrorCodes  errCode)
static

Get detailed information from returned error code.

Parameters
errCodeReturned error code by file parser
Returns
Understandable error description
LevelData FileFormats::OpenLevelFile ( PGESTRING  filePath)
static

Parses a level file with auto-detection of a file type (SMBX1...64 LVL or PGE-LVLX)

Parameters
filePathFull path to file which must be opened
Returns
Level data structure
LevelData FileFormats::OpenLevelFileHeader ( PGESTRING  filePath)
static

Parses a level file header only with auto-detection of a file type (SMBX1...64 LVL or PGE-LVLX)

Parameters
filePathFull path to file which must be opened
Returns
Level data structure (with initialized header data only)
WorldData FileFormats::OpenWorldFile ( PGESTRING  filePath)
static

Parses a world map file with auto-detection of a file type (SMBX1...64 LVL or PGE-WLDX)

Parameters
filePathFull path to file which must be opened
Returns
World data structure
WorldData FileFormats::OpenWorldFileHeader ( PGESTRING  filePath)
static

Parses a world map file header only with auto-detection of a file type (SMBX1...64 LVL or PGE-WLDX)

Parameters
filePathFull path to file which must be opened
Returns
World data structure (with initialized header data only)
LevelData FileFormats::ReadExtendedLvlFile ( PGESTRING  RawData,
PGESTRING  filePath = "" 
)
static

Parses PGE-X level file data.

Parameters
RawDataRaw data string in the PGE-X level format
filePathFull path to the file (if empty, custom data in the episode and in the custom directories are will be inaccessible)
Returns
Level data structure
LevelData FileFormats::ReadExtendedLvlFileHeader ( PGESTRING  filePath)
static

Parses PGE-X Level file header.

Parameters
filePathFull path to PGE-X Level file
Returns
Level data structure (with initialized header data only)
GamesaveData FileFormats::ReadExtendedSaveFile ( PGESTRING  RawData,
PGESTRING  filePath 
)
static

Parses PGE-X Game save file from raw data string.

Parameters
RawDataraw data string in PGE-X game save format
filePathPath to original file
Returns
Game save data structure
WorldData FileFormats::ReadExtendedWldFile ( PGESTRING  RawData,
PGESTRING  filePath 
)
static

Parses PGE-X World map file from raw data.

Parameters
RawDataRaw data string in PGE-X World map format
filePathFull path to the file (if empty, custom data in the episode and in the custom directories are will be inaccessible)
Returns
World map data structure
WorldData FileFormats::ReadExtendedWldFileHeader ( PGESTRING  filePath)
static

Parsed PGE-X World map file header only.

Parameters
filePathFull path to file which must be opened
Returns
World data structure (with initialized header data only)
MetaData FileFormats::ReadNonSMBX64MetaData ( PGESTRING  RawData)
static

Parses non-SMBX64 meta-data from additional *.meta files there are contains data which impossible to save into SMBX64 LVL file therefore it will be saved into additional *.meta file.

Parameters
Raw-dataFull raw file data contents
Returns
Meta-data structure
NPCConfigFile FileFormats::ReadNpcTXTFile ( PGESTRING  file,
bool  IgnoreBad = false 
)
static

Parses SMBX64 NPC.txt file.

Parameters
fileFull path to NPC.txt
IgnoreBadDon't spawn warning message on errors in the file syntax
Returns
NPC Customizing Config data structure
SMBX64_ConfigFile FileFormats::ReadSMBX64ConfigFile ( PGESTRING  RawData)
static

Parses SMBX Engine config file raw data string.

Parameters
RawDataraw data string in SMBX Engine config file format
Returns
SMBX Engine specific config structure
LevelData FileFormats::ReadSMBX64LvlFile ( PGESTRING  RawData,
PGESTRING  filePath = "" 
)
static

Parses SMBX1...64 level file data.

Parameters
RawDataRaw data string in the SMBX1...64 level format
filePathFull path to the file (if empty, custom data in the episode and in the custom directories are will be inaccessible)
Returns
Level data structure
LevelData FileFormats::ReadSMBX64LvlFileHeader ( PGESTRING  filePath)
static

Parses SMBX1...64 level file header and skips other part of a file.

Parameters
filePathFull path to level file
Returns
Level data structure (with initialized header data only)
GamesaveData FileFormats::ReadSMBX64SavFile ( PGESTRING  RawData,
PGESTRING  filePath 
)
static

Parses SMBX1...64 Game save file from raw data string.

Parameters
RawDataraw data string in SMBX1..64 game save format
filePathPath to original file
Returns
Game save data structure
WorldData FileFormats::ReadSMBX64WldFile ( PGESTRING  RawData,
PGESTRING  filePath 
)
static

Parses SMBX1...64 World map file from raw data.

Parameters
RawDataRaw data string in SMBX1...64 World map format
filePathFull path to the file (if empty, custom data in the episode and in the custom directories are will be inaccessible)
Returns
World data structure
WorldData FileFormats::ReadSMBX64WldFileHeader ( PGESTRING  filePath)
static

Parsed SMBX1...64 World map file header only.

Parameters
filePathFull path to file which must be opened
Returns
World data structure (with initialized header data only)
PGESTRING FileFormats::removeQuotes ( PGESTRING  str)
static

Removes edge dobule quoties characters from a string for example '"Meow"' (without signgle-quotes characters) will be converted into 'Meow' (without signgle-quotes characters)

Parameters
strInput string with quites characters at begin and end of string
Returns
String with removed double quotes at edges. If string has no double quotes at edges, input string will be retured with no changes
int FileFormats::smbx64LevelCheckLimits ( LevelData lvl)
static

Validates level file data structure to conformation to SMBX64 Standard.

Parameters
lvlLevel file data structure
Returns
SMBX64 Standrd specific violation code
void FileFormats::smbx64LevelPrepare ( LevelData lvl)
static

Optimizing level data for SMBX64 Standard requirements.

Parameters
lvlLevel data structure object
void FileFormats::smbx64LevelSortBGOs ( LevelData lvl)
static

Sorts Background objects by special order priority value Modifying of order priority values allowing to force specific non-foreground BGO's to be rendered foreground.

Parameters
lvlLevel data structure object
void FileFormats::smbx64LevelSortBlocks ( LevelData lvl)
static

Sorts blocks array by Y->X positions in the given level data structure. By SMBX64 standard, blocks array must be sorted because it is required for NPC's collision detection algorithm of SMBX Engine.

Parameters
lvlLevel data structure object
int FileFormats::smbx64WorldCheckLimits ( WorldData wld)
static

Validates World map file data structure to conformation to SMBX64 Standard.

Parameters
wldWorld map file data structure
Returns
SMBX64 Standrd specific violation code
PGESTRING FileFormats::WriteExtendedLvlFile ( LevelData  FileData)
static

Generates PGE-X Level file.

Parameters
FileDataLevel data structure
Returns
Raw data string in the PGE-X level formatGenerate PGE-X level raw data
PGESTRING FileFormats::WriteExtendedSaveFile ( GamesaveData FileData)
static

Generate raw data in PGE-X Game save file from GameSave data structure.

Parameters
FileDataGamesave data structure
Returns
raw string in PGE-X Game save format
PGESTRING FileFormats::WriteExtendedWldFile ( WorldData  FileData)
static

Generates raw data string in PGE-X World map format.

Parameters
FileDataWorld map data structure
Returns
Raw data string in PGE-X World map format
PGESTRING FileFormats::WriteNonSMBX64MetaData ( MetaData  metaData)
static

Generates raw data of non-SMBX meta-data file from Meta-data structure.

Parameters
metaDataMeta-data structure
Returns
Full raw-data string
PGESTRING FileFormats::WriteNPCTxtFile ( NPCConfigFile  FileData)
static

Generates NPC.txt raw data string in SMBX64 NPC.txt format.

Parameters
FileDataNPC Customizing Config data structure
Returns
raw data string in SMBX64 NPC.txt format
PGESTRING FileFormats::WriteSMBX64ConfigFile ( SMBX64_ConfigFile FileData,
int  file_format 
)
static

Generates SMBX Engine specific config file raw data string.

Parameters
FileDataSMBX Engine specific config structure
file_formatSMBX file format version number (from 0 to 64)
Returns
raw data string in SMBX Engine config file format
PGESTRING FileFormats::WriteSMBX64LvlFile ( LevelData  FileData,
int  file_format = 64 
)
static

Generates SMBX1...64 Level file data.

Parameters
FileDataLevel data structure
file_formatSMBX file format version number (from 0 to 64) [Example of level in SMBX0 format is intro.dat included with SMBX 1.0]
Returns
Raw data string in the SMBX1...64 level formatGenerate SMBX1-SMBX64 level raw data
PGESTRING FileFormats::WriteSMBX64WldFile ( WorldData  FileData,
int  file_format = 64 
)
static

Generates raw data string in SMBX1...64 World map format.

Parameters
FileDataWorld map data structure
file_formatSMBX file format version number (from 0 to 64)
Returns
Raw data string in SMBX1...64 World map format

The documentation for this class was generated from the following files: