Fixed the filesytem for the converter.

This commit is contained in:
Steffen Fündgens 2014-12-05 16:18:48 +01:00
parent e79128a1a5
commit da197f063f
4 changed files with 129 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

View File

@ -0,0 +1,116 @@
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<xPos>3.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>3.500000</zPos>
<idGreen>1</idGreen>
<idBlue>9</idBlue>
<typeID>99</typeID>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<xPos>3.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>-0.500000</zPos>
<idGreen>1</idGreen>
<idBlue>8</idBlue>
<typeID>99</typeID>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<xPos>2.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>-2.500000</zPos>
<idGreen>1</idGreen>
<idBlue>7</idBlue>
<typeID>99</typeID>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<xPos>1.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>0.500000</zPos>
<idGreen>1</idGreen>
<idBlue>6</idBlue>
<typeID>99</typeID>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<xPos>-0.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>1.500000</zPos>
<idGreen>1</idGreen>
<idBlue>5</idBlue>
<typeID>99</typeID>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<xPos>-0.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>-1.500000</zPos>
<idGreen>1</idGreen>
<idBlue>4</idBlue>
<typeID>99</typeID>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<xPos>-2.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>-1.500000</zPos>
<idGreen>1</idGreen>
<idBlue>3</idBlue>
<typeID>99</typeID>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<xPos>-3.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>-3.500000</zPos>
<idGreen>1</idGreen>
<idBlue>2</idBlue>
<typeID>99</typeID>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<xPos>-4.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>-4.500000</zPos>
<idGreen>1</idGreen>
<idBlue>1</idBlue>
<typeID>99</typeID>
</composition>

View File

Before

Width:  |  Height:  |  Size: 721 KiB

After

Width:  |  Height:  |  Size: 721 KiB

View File

@ -1,6 +1,7 @@
#include "converter.hh"
#include <fstream>
#include <string>
#include <sys/stat.h>
using namespace tinyxml2;
@ -14,10 +15,20 @@ Converter::Converter(std::string level){
printf("Could not open Compositions!!!\n");
}
//Create a backup of the current Level png file, if no backup exists
std::string pngFile = "../Levels/ObjectSetups/Level" + level + ".png";
std::string backupPNG = "../Levels/ObjectSetups/BackupLevel" + level + ".png";
struct stat buf;
if(stat(backupPNG.c_str(), &buf) != 0){
std::ifstream src(pngFile, std::ios::binary);
std::ofstream dst(backupPNG, std::ios::binary);
dst << src.rdbuf();
}
//Create a backup of the current Level xml file
std::string backup = "../Levels/ObjectSetups/BackupLevel" + level + ".xml";
std::string backupXML = "../Levels/ObjectSetups/BackupLevel" + level + ".xml";
std::ifstream src(xmlFile, std::ios::binary);
std::ofstream dst(backup, std::ios::binary);
std::ofstream dst(backupXML, std::ios::binary);
dst << src.rdbuf();
//Load the Level xml file