1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-07-03 22:44:32 +00:00

Migrate from TinyXML v1 to v2. Not bundled (yet).

This commit is contained in:
James Le Cuirot 2014-06-08 21:11:23 +01:00
parent 18034bcc18
commit 43d41feeb8
27 changed files with 583 additions and 11237 deletions

View file

@ -24,12 +24,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/BitmapFont.h" #include "../BBGE/BitmapFont.h"
#include "../BBGE/Quad.h" #include "../BBGE/Quad.h"
#include "../BBGE/ActionMapper.h" #include "../BBGE/ActionMapper.h"
#include "../ExternalLibs/tinyxml.h"
#include "../BBGE/Slider.h" #include "../BBGE/Slider.h"
#include "../BBGE/DebugFont.h" #include "../BBGE/DebugFont.h"
#include "../BBGE/TTFFont.h" #include "../BBGE/TTFFont.h"
#include "../BBGE/RoundedRect.h" #include "../BBGE/RoundedRect.h"
#include "tinyxml2.h"
using namespace tinyxml2;
class AquariaGuiElement class AquariaGuiElement
{ {
public: public:
@ -76,7 +78,7 @@ public:
void setLabel(const std::string &label); void setLabel(const std::string &label);
EventPtr event; EventPtr event;
BitmapText *font, *glowFont; BitmapText *font, *glowFont;
TiXmlElement *ability, *xmlItem; XMLElement *ability, *xmlItem;
int choice; int choice;
Quad *glow, *quad; Quad *glow, *quad;
void useQuad(const std::string &tex); void useQuad(const std::string &tex);
@ -111,7 +113,7 @@ public:
bool mbDown; bool mbDown;
static std::string getSaveDescription(const TiXmlDocument &doc); static std::string getSaveDescription(const XMLDocument &doc);
protected: protected:
void onUpdate(float dt); void onUpdate(float dt);

View file

@ -58,7 +58,7 @@ AquariaSaveSlot::AquariaSaveSlot(int slot) : AquariaGuiQuad()
glowText->position = text1->position = Vector(-175, -25); glowText->position = text1->position = Vector(-175, -25);
TiXmlDocument doc; XMLDocument doc;
dsq->continuity.loadFileData(slot, doc); dsq->continuity.loadFileData(slot, doc);
std::string description = getSaveDescription(doc); std::string description = getSaveDescription(doc);
@ -283,9 +283,9 @@ void AquariaSaveSlot::onUpdate(float dt)
} }
std::string AquariaSaveSlot::getSaveDescription(const TiXmlDocument &doc) std::string AquariaSaveSlot::getSaveDescription(const XMLDocument &doc)
{ {
const TiXmlElement *startData = doc.FirstChildElement("StartData"); const XMLElement *startData = doc.FirstChildElement("StartData");
if (!startData) if (!startData)
return ""; return "";

View file

@ -26,7 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "GridRender.h" #include "GridRender.h"
#include "DeflateCompressor.h" #include "DeflateCompressor.h"
#include "../ExternalLibs/tinyxml.h" #include "tinyxml2.h"
using namespace tinyxml2;
#define MAX_EATS 8 #define MAX_EATS 8
@ -1251,9 +1252,9 @@ std::string Continuity::getInternalFormName()
void Continuity::loadIntoSongBank(const std::string &file) void Continuity::loadIntoSongBank(const std::string &file)
{ {
TiXmlDocument doc; XMLDocument doc;
doc.LoadFile(file); doc.LoadFile(file.c_str());
TiXmlElement *song = doc.FirstChildElement("Song"); XMLElement *song = doc.FirstChildElement("Song");
while (song) while (song)
{ {
Song s; Song s;
@ -2359,13 +2360,13 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
dsq->user.save(); dsq->user.save();
TiXmlDocument doc; XMLDocument doc;
TiXmlElement version("Version"); XMLElement *version = doc.NewElement("Version");
{ {
version.SetAttribute("major", VERSION_MAJOR); version->SetAttribute("major", VERSION_MAJOR);
version.SetAttribute("minor", VERSION_MINOR); version->SetAttribute("minor", VERSION_MINOR);
version.SetAttribute("revision", VERSION_REVISION); version->SetAttribute("revision", VERSION_REVISION);
} }
doc.InsertEndChild(version); doc.InsertEndChild(version);
@ -2373,24 +2374,24 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
{ {
if ((*i).first.find("CHOICE_")!=std::string::npos) continue; if ((*i).first.find("CHOICE_")!=std::string::npos) continue;
if ((*i).first.find("TEMP_")!=std::string::npos) continue; if ((*i).first.find("TEMP_")!=std::string::npos) continue;
TiXmlElement flag("Flag"); XMLElement *flag = doc.NewElement("Flag");
flag.SetAttribute("name", (*i).first); flag->SetAttribute("name", (*i).first.c_str());
flag.SetAttribute("value", (*i).second); flag->SetAttribute("value", (*i).second);
doc.InsertEndChild(flag); doc.InsertEndChild(flag);
} }
TiXmlElement efx("EFX"); XMLElement *efx = doc.NewElement("EFX");
{ {
std::ostringstream os; std::ostringstream os;
for (EntityFlags::iterator i = entityFlags.begin(); i != entityFlags.end(); i++) for (EntityFlags::iterator i = entityFlags.begin(); i != entityFlags.end(); i++)
{ {
os << (*i).first << " " << (*i).second << " "; os << (*i).first << " " << (*i).second << " ";
} }
efx.SetAttribute("a", os.str()); efx->SetAttribute("a", os.str().c_str());
} }
doc.InsertEndChild(efx); doc.InsertEndChild(efx);
TiXmlElement gems("Gems"); XMLElement *gems = doc.NewElement("Gems");
{ {
std::ostringstream os; std::ostringstream os;
bool hasUserString = false; bool hasUserString = false;
@ -2407,7 +2408,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
if (hasUserString) if (hasUserString)
os << spacesToUnderscores((*i).userString) << " "; os << spacesToUnderscores((*i).userString) << " ";
} }
gems.SetAttribute("c", os.str()); gems->SetAttribute("c", os.str().c_str());
// This is the format used in the android version. Keeping this commented out for now, // This is the format used in the android version. Keeping this commented out for now,
// but it should be used instead of the code above in some time -- FG // but it should be used instead of the code above in some time -- FG
@ -2431,13 +2432,13 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
if (hasUserString) if (hasUserString)
os << spacesToUnderscores((*i).userString) << " "; os << spacesToUnderscores((*i).userString) << " ";
} }
gems.SetAttribute("d", os.str()); gems->SetAttribute("d", os.str());
*/ */
} }
doc.InsertEndChild(gems); doc.InsertEndChild(gems);
TiXmlElement worldMap("WorldMap"); XMLElement *worldMap = doc.NewElement("WorldMap");
{ {
std::ostringstream os; std::ostringstream os;
for (int i = 0; i < dsq->continuity.worldMap.getNumWorldMapTiles(); i++) for (int i = 0; i < dsq->continuity.worldMap.getNumWorldMapTiles(); i++)
@ -2448,7 +2449,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
os << tile->index << " "; os << tile->index << " ";
} }
} }
worldMap.SetAttribute("b", os.str()); worldMap->SetAttribute("b", os.str().c_str());
#ifdef AQUARIA_BUILD_MAPVIS #ifdef AQUARIA_BUILD_MAPVIS
if (dsq->game->worldMapRender) if (dsq->game->worldMapRender)
@ -2461,13 +2462,13 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
tile->dataToString(os); tile->dataToString(os);
os << " "; os << " ";
} }
worldMap.SetAttribute("va", os.str()); worldMap->SetAttribute("va", os.str().c_str());
} }
#endif #endif
} }
doc.InsertEndChild(worldMap); doc.InsertEndChild(worldMap);
TiXmlElement vox("VO"); XMLElement *vox = doc.NewElement("VO");
{ {
std::ostringstream os; std::ostringstream os;
for (int i = 0; i < dsq->continuity.voiceOversPlayed.size(); i++) for (int i = 0; i < dsq->continuity.voiceOversPlayed.size(); i++)
@ -2475,11 +2476,11 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
os << dsq->continuity.voiceOversPlayed[i] << " "; os << dsq->continuity.voiceOversPlayed[i] << " ";
} }
vox.SetAttribute("v", os.str()); vox->SetAttribute("v", os.str().c_str());
} }
doc.InsertEndChild(vox); doc.InsertEndChild(vox);
TiXmlElement eats("eats"); XMLElement *eats = doc.NewElement("eats");
{ {
std::ostringstream os; std::ostringstream os;
int num = naijaEats.size(); int num = naijaEats.size();
@ -2489,11 +2490,11 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
EatData *eat = &naijaEats[i]; EatData *eat = &naijaEats[i];
os << eat->name << " " << eat->shot << " " << eat->ammo << " " << eat->ammoUnitSize << " "; os << eat->name << " " << eat->shot << " " << eat->ammo << " " << eat->ammoUnitSize << " ";
} }
eats.SetAttribute("a", os.str()); eats->SetAttribute("a", os.str().c_str());
} }
doc.InsertEndChild(eats); doc.InsertEndChild(eats);
TiXmlElement bcn("bcn"); XMLElement *bcn = doc.NewElement("bcn");
{ {
std::ostringstream os; std::ostringstream os;
for (Beacons::iterator i = beacons.begin(); i != beacons.end(); i++) for (Beacons::iterator i = beacons.begin(); i != beacons.end(); i++)
@ -2503,42 +2504,42 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
os << data->color.x << " " << data->color.y << " " << data->color.z << " "; os << data->color.x << " " << data->color.y << " " << data->color.z << " ";
os << data->pos.x << " " << data->pos.y << " " << data->pos.z << " "; os << data->pos.x << " " << data->pos.y << " " << data->pos.z << " ";
} }
bcn.SetAttribute("a", os.str()); bcn->SetAttribute("a", os.str().c_str());
} }
doc.InsertEndChild(bcn); doc.InsertEndChild(bcn);
TiXmlElement s("Story"); XMLElement *s = doc.NewElement("Story");
{ {
std::ostringstream os; std::ostringstream os;
os << story; os << story;
s.SetAttribute("v", os.str()); s->SetAttribute("v", os.str().c_str());
doc.InsertEndChild(s); doc.InsertEndChild(s);
} }
for (StringFlags::iterator i = stringFlags.begin(); i != stringFlags.end(); i++) for (StringFlags::iterator i = stringFlags.begin(); i != stringFlags.end(); i++)
{ {
if ((*i).first.find("TEMP_")!=std::string::npos) continue; if ((*i).first.find("TEMP_")!=std::string::npos) continue;
TiXmlElement stringFlag("StringFlag"); XMLElement *stringFlag = doc.NewElement("StringFlag");
stringFlag.SetAttribute("name", (*i).first); stringFlag->SetAttribute("name", (*i).first.c_str());
stringFlag.SetAttribute("value", (*i).second); stringFlag->SetAttribute("value", (*i).second.c_str());
doc.InsertEndChild(stringFlag); doc.InsertEndChild(stringFlag);
} }
TiXmlElement startData("StartData"); XMLElement *startData = doc.NewElement("StartData");
startData.SetAttribute("x", int(position.x)); startData->SetAttribute("x", int(position.x));
startData.SetAttribute("y", int(position.y)); startData->SetAttribute("y", int(position.y));
startData.SetAttribute("scene", dsq->game->sceneName); startData->SetAttribute("scene", dsq->game->sceneName.c_str());
startData.SetAttribute("exp", dsq->continuity.exp); startData->SetAttribute("exp", dsq->continuity.exp);
startData.SetAttribute("h", dsq->continuity.maxHealth); startData->SetAttribute("h", dsq->continuity.maxHealth);
startData.SetAttribute("ch", dsq->continuity.health); startData->SetAttribute("ch", dsq->continuity.health);
startData.SetAttribute("naijaModel", dsq->continuity.naijaModel); startData->SetAttribute("naijaModel", dsq->continuity.naijaModel.c_str());
startData.SetAttribute("costume", dsq->continuity.costume); startData->SetAttribute("costume", dsq->continuity.costume.c_str());
startData.SetAttribute("form", dsq->continuity.form); startData->SetAttribute("form", dsq->continuity.form);
if (dsq->mod.isActive()) if (dsq->mod.isActive())
startData.SetAttribute("mod", dsq->mod.getName()); startData->SetAttribute("mod", dsq->mod.getName().c_str());
std::ostringstream secondsOS; std::ostringstream secondsOS;
secondsOS << dsq->continuity.seconds; secondsOS << dsq->continuity.seconds;
startData.SetAttribute("seconds", secondsOS.str()); startData->SetAttribute("seconds", secondsOS.str().c_str());
std::ostringstream os2; std::ostringstream os2;
for (int i = 0; i < SONG_MAX; i++) for (int i = 0; i < SONG_MAX; i++)
{ {
@ -2547,7 +2548,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
os2 << i << " "; os2 << i << " ";
} }
} }
startData.SetAttribute("songs", os2.str()); startData->SetAttribute("songs", os2.str().c_str());
// new format as used by android version // new format as used by android version
std::ostringstream ingrNames; std::ostringstream ingrNames;
@ -2556,7 +2557,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
IngredientData *data = ingredients[i]; IngredientData *data = ingredients[i];
ingrNames << data->name << " " << data->amount << " "; ingrNames << data->name << " " << data->amount << " ";
} }
startData.SetAttribute("ingrNames", ingrNames.str()); startData->SetAttribute("ingrNames", ingrNames.str().c_str());
// for compatibility with older versions // for compatibility with older versions
std::ostringstream ingrOs; std::ostringstream ingrOs;
@ -2565,14 +2566,14 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
IngredientData *data = ingredients[i]; IngredientData *data = ingredients[i];
ingrOs << data->getIndex() << " " << data->amount << " "; ingrOs << data->getIndex() << " " << data->amount << " ";
} }
startData.SetAttribute("ingr", ingrOs.str()); startData->SetAttribute("ingr", ingrOs.str().c_str());
std::ostringstream recOs; std::ostringstream recOs;
for (int i = 0; i < recipes.size(); i++) for (int i = 0; i < recipes.size(); i++)
{ {
recOs << recipes[i].isKnown() << " "; recOs << recipes[i].isKnown() << " ";
} }
startData.SetAttribute("rec", recOs.str()); startData->SetAttribute("rec", recOs.str().c_str());
std::ostringstream os3; std::ostringstream os3;
for (int i = 0; i < FORMUPGRADE_MAX; i++) for (int i = 0; i < FORMUPGRADE_MAX; i++)
@ -2582,7 +2583,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
os3 << i << " "; os3 << i << " ";
} }
} }
startData.SetAttribute("formUpgrades", os3.str()); startData->SetAttribute("formUpgrades", os3.str().c_str());
std::ostringstream fos; std::ostringstream fos;
fos << MAX_FLAGS << " "; fos << MAX_FLAGS << " ";
@ -2590,7 +2591,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
{ {
fos << intFlags[i] << " "; fos << intFlags[i] << " ";
} }
startData.SetAttribute("intFlags", fos.str()); startData->SetAttribute("intFlags", fos.str().c_str());
// Additional data for the android version // Additional data for the android version
@ -2598,7 +2599,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
do { if((cond) && (val)) { \ do { if((cond) && (val)) { \
std::ostringstream osf; \ std::ostringstream osf; \
osf << (val); \ osf << (val); \
startData.SetAttribute(name, osf.str()); \ startData->SetAttribute(name, osf.str().c_str()); \
}} while(0) }} while(0)
SINGLE_FLOAT_ATTR("blind", dsq->game->avatar->state.blind, dsq->game->avatar->state.blindTimer.getValue()); SINGLE_FLOAT_ATTR("blind", dsq->game->avatar->state.blind, dsq->game->avatar->state.blindTimer.getValue());
@ -2614,7 +2615,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
do { if(((timer).isActive()) && (val)) { \ do { if(((timer).isActive()) && (val)) { \
std::ostringstream osf; \ std::ostringstream osf; \
osf << (val) << " " << ((timer).getValue()); \ osf << (val) << " " << ((timer).getValue()); \
startData.SetAttribute((name), osf.str()); \ startData->SetAttribute((name), osf.str().c_str()); \
}} while(0) }} while(0)
TIMER_AND_VALUE_ATTR("biteMult", biteMultTimer, biteMult); TIMER_AND_VALUE_ATTR("biteMult", biteMultTimer, biteMult);
@ -2631,14 +2632,14 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
{ {
std::ostringstream osp; std::ostringstream osp;
osp << poison << " " << poisonTimer.getValue() << " " << poisonBitTimer.getValue(); osp << poison << " " << poisonTimer.getValue() << " " << poisonBitTimer.getValue();
startData.SetAttribute("poison", osp.str()); startData->SetAttribute("poison", osp.str().c_str());
} }
if(dsq->game->avatar->activeAura != AURA_NONE) if(dsq->game->avatar->activeAura != AURA_NONE)
{ {
std::ostringstream osa; std::ostringstream osa;
osa << dsq->game->avatar->activeAura << " " << dsq->game->avatar->auraTimer; osa << dsq->game->avatar->activeAura << " " << dsq->game->avatar->auraTimer;
startData.SetAttribute("aura", osa.str()); startData->SetAttribute("aura", osa.str().c_str());
} }
// FIXME: Web is a bit weird. There are 2 webBitTimer variables in use, one in Continuity, one in Avatar. // FIXME: Web is a bit weird. There are 2 webBitTimer variables in use, one in Continuity, one in Avatar.
@ -2655,7 +2656,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
Vector v = w->getPoint(i); Vector v = w->getPoint(i);
osw << v.x << " " << v.y << " "; osw << v.x << " " << v.y << " ";
} }
startData.SetAttribute("web", osw.str()); startData->SetAttribute("web", osw.str().c_str());
} }
// end extra android data // end extra android data
@ -2671,11 +2672,11 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
return; return;
} }
TiXmlPrinter printer; XMLPrinter printer;
doc.Accept( &printer ); doc.Accept( &printer );
const char* xmlstr = printer.CStr(); const char* xmlstr = printer.CStr();
ZlibCompressor z; ZlibCompressor z;
z.init((void*)xmlstr, printer.Size(), ZlibCompressor::REUSE); z.init((void*)xmlstr, printer.CStrSize(), ZlibCompressor::REUSE);
z.SetForceCompression(true); z.SetForceCompression(true);
z.Compress(3); z.Compress(3);
std::ostringstream os; std::ostringstream os;
@ -2696,7 +2697,7 @@ std::string Continuity::getSaveFileName(int slot, const std::string &pfix)
return os.str(); return os.str();
} }
void Continuity::loadFileData(int slot, TiXmlDocument &doc) void Continuity::loadFileData(int slot, XMLDocument &doc)
{ {
std::string teh_file = dsq->continuity.getSaveFileName(slot, "aqs"); std::string teh_file = dsq->continuity.getSaveFileName(slot, "aqs");
if(!exists(teh_file)) if(!exists(teh_file))
@ -2711,9 +2712,9 @@ void Continuity::loadFileData(int slot, TiXmlDocument &doc)
errorLog("Failed to decompress save file: " + teh_file); errorLog("Failed to decompress save file: " + teh_file);
return; return;
} }
if (!doc.LoadMem(buf, size)) if (doc.Parse(buf, size) != XML_SUCCESS)
{ {
errorLog("Failed to load save data: " + teh_file + " -- Error: " + doc.ErrorDesc()); errorLog("Failed to load save data: " + teh_file + " -- Error: " + doc.GetErrorStr1());
return; return;
} }
} }
@ -2721,7 +2722,7 @@ void Continuity::loadFileData(int slot, TiXmlDocument &doc)
teh_file = dsq->continuity.getSaveFileName(slot, "xml"); teh_file = dsq->continuity.getSaveFileName(slot, "xml");
if (exists(teh_file)) if (exists(teh_file))
{ {
if (!doc.LoadFile(teh_file)) if (doc.LoadFile(teh_file.c_str()) != XML_SUCCESS)
errorLog("Failed to load save data: " + teh_file); errorLog("Failed to load save data: " + teh_file);
} }
} }
@ -2730,10 +2731,10 @@ void Continuity::loadFile(int slot)
{ {
dsq->user.save(); dsq->user.save();
TiXmlDocument doc; XMLDocument doc;
loadFileData(slot, doc); loadFileData(slot, doc);
TiXmlElement *startData = doc.FirstChildElement("StartData"); XMLElement *startData = doc.FirstChildElement("StartData");
if (startData) if (startData)
{ {
if (startData->Attribute("mod")) if (startData->Attribute("mod"))
@ -2749,7 +2750,7 @@ void Continuity::loadFile(int slot)
this->reset(); this->reset();
int versionMajor=-1, versionMinor=-1, versionRevision=-1; int versionMajor=-1, versionMinor=-1, versionRevision=-1;
TiXmlElement *xmlVersion = doc.FirstChildElement("Version"); XMLElement *xmlVersion = doc.FirstChildElement("Version");
if (xmlVersion) if (xmlVersion)
{ {
versionMajor = atoi(xmlVersion->Attribute("major")); versionMajor = atoi(xmlVersion->Attribute("major"));
@ -2757,7 +2758,7 @@ void Continuity::loadFile(int slot)
versionRevision = atoi(xmlVersion->Attribute("revision")); versionRevision = atoi(xmlVersion->Attribute("revision"));
} }
TiXmlElement *e = doc.FirstChildElement("Flag"); XMLElement *e = doc.FirstChildElement("Flag");
while (e) while (e)
{ {
dsq->continuity.setFlag(e->Attribute("name"), atoi(e->Attribute("value"))); dsq->continuity.setFlag(e->Attribute("name"), atoi(e->Attribute("value")));
@ -2779,7 +2780,7 @@ void Continuity::loadFile(int slot)
} }
*/ */
TiXmlElement *efx = doc.FirstChildElement("EFX"); XMLElement *efx = doc.FirstChildElement("EFX");
if (efx) if (efx)
{ {
if (efx->Attribute("a")) if (efx->Attribute("a"))
@ -2793,7 +2794,7 @@ void Continuity::loadFile(int slot)
} }
} }
TiXmlElement *eats = doc.FirstChildElement("eats"); XMLElement *eats = doc.FirstChildElement("eats");
if (eats) if (eats)
{ {
if (eats->Attribute("a")) if (eats->Attribute("a"))
@ -2811,7 +2812,7 @@ void Continuity::loadFile(int slot)
} }
} }
TiXmlElement *bcn = doc.FirstChildElement("bcn"); XMLElement *bcn = doc.FirstChildElement("bcn");
if (bcn) if (bcn)
{ {
if (bcn->Attribute("a")) if (bcn->Attribute("a"))
@ -2834,7 +2835,7 @@ void Continuity::loadFile(int slot)
} }
} }
TiXmlElement *vox = doc.FirstChildElement("VO"); XMLElement *vox = doc.FirstChildElement("VO");
if (vox) if (vox)
{ {
std::string s = vox->Attribute("v"); std::string s = vox->Attribute("v");
@ -2846,7 +2847,7 @@ void Continuity::loadFile(int slot)
} }
} }
TiXmlElement *gems = doc.FirstChildElement("Gems"); XMLElement *gems = doc.FirstChildElement("Gems");
if (gems) if (gems)
{ {
if (gems->Attribute("a")) if (gems->Attribute("a"))
@ -2978,7 +2979,7 @@ void Continuity::loadFile(int slot)
} }
} }
TiXmlElement *worldMap = doc.FirstChildElement("WorldMap"); XMLElement *worldMap = doc.FirstChildElement("WorldMap");
if (worldMap) if (worldMap)
{ {
if (worldMap->Attribute("b")) if (worldMap->Attribute("b"))
@ -3023,14 +3024,14 @@ void Continuity::loadFile(int slot)
} }
TiXmlElement *s = doc.FirstChildElement("Story"); XMLElement *s = doc.FirstChildElement("Story");
if (s) if (s)
{ {
std::istringstream is(s->Attribute("v")); std::istringstream is(s->Attribute("v"));
is >> story; is >> story;
} }
TiXmlElement *e2 = doc.FirstChildElement("StringFlag"); XMLElement *e2 = doc.FirstChildElement("StringFlag");
while (e2) while (e2)
{ {
dsq->continuity.setStringFlag(e2->Attribute("name"), e2->Attribute("value")); dsq->continuity.setStringFlag(e2->Attribute("name"), e2->Attribute("value"));

View file

@ -2069,11 +2069,11 @@ void DSQ::loadModsCallback(const std::string &filename, intptr_t param)
m.path = name; m.path = name;
m.id = dsq->modEntries.size(); m.id = dsq->modEntries.size();
TiXmlDocument d; XMLDocument d;
if(!Mod::loadModXML(&d, name)) if(!Mod::loadModXML(&d, name))
{ {
std::ostringstream os; std::ostringstream os;
os << "Failed to load mod xml: " << filename << " -- Error: " << d.ErrorDesc(); os << "Failed to load mod xml: " << filename << " -- Error: " << d.GetErrorStr1();
dsq->debugLog(os.str()); dsq->debugLog(os.str());
return; return;
} }

View file

@ -28,7 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/BitmapFont.h" #include "../BBGE/BitmapFont.h"
#include "../BBGE/ScreenTransition.h" #include "../BBGE/ScreenTransition.h"
#include "../BBGE/Precacher.h" #include "../BBGE/Precacher.h"
#include "../ExternalLibs/tinyxml.h"
#include "AquariaMenuItem.h" #include "AquariaMenuItem.h"
#include "ScriptInterface.h" #include "ScriptInterface.h"
@ -36,6 +35,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "TTFFont.h" #include "TTFFont.h"
#include "tinyxml2.h"
using namespace tinyxml2;
#define AQUARIA_BUILD_MAPVIS #define AQUARIA_BUILD_MAPVIS
// Define this to save map visited data in a base64-encoded raw format. // Define this to save map visited data in a base64-encoded raw format.
@ -286,8 +288,8 @@ public:
void shutdown(); void shutdown();
bool isShuttingDown(); bool isShuttingDown();
static bool loadModXML(TiXmlDocument *d, std::string modName); static bool loadModXML(XMLDocument *d, std::string modName);
static ModType getTypeFromXML(TiXmlElement *xml); static ModType getTypeFromXML(XMLElement *xml);
WorldMapRevealMethod mapRevealMethod; WorldMapRevealMethod mapRevealMethod;
@ -939,7 +941,7 @@ public:
void setStringFlag(std::string flag, std::string v); void setStringFlag(std::string flag, std::string v);
void saveFile(int slot, Vector position=Vector(0,0,0), unsigned char *scrShotData=0, int scrShotWidth=0, int scrShotHeight=0); void saveFile(int slot, Vector position=Vector(0,0,0), unsigned char *scrShotData=0, int scrShotWidth=0, int scrShotHeight=0);
void loadFileData(int slot, TiXmlDocument &doc); void loadFileData(int slot, XMLDocument &doc);
void loadFile(int slot); void loadFile(int slot);
void castSong(int num); void castSong(int num);
@ -1622,7 +1624,7 @@ protected:
std::vector <AquariaSaveSlot*> saveSlots; std::vector <AquariaSaveSlot*> saveSlots;
BitmapText *expText, *moneyText; BitmapText *expText, *moneyText;
TiXmlDocument *xmlDoc; XMLDocument *xmlDoc;
void clearMenu(float t = 0.01); void clearMenu(float t = 0.01);
std::vector <RenderObject*> menu; std::vector <RenderObject*> menu;

View file

@ -77,20 +77,20 @@ void Demo::save(const std::string &name)
std::string filename = "" + name + ".demo"; std::string filename = "" + name + ".demo";
TiXmlDocument doc; XMLDocument doc;
// UNFINISHED // UNFINISHED
for (int i = 0; i < frames.size(); i++) for (int i = 0; i < frames.size(); i++)
{ {
//DemoFrame *frame = &frames[i]; //DemoFrame *frame = &frames[i];
TiXmlElement xmlDemoFrame("DemoFrame"); XMLElement *xmlDemoFrame = doc.NewElement("DemoFrame");
std::ostringstream os; std::ostringstream os;
//os << frame->avatarPos.x << " " << frame->avatarPos.y << " " << frame->mouse; //os << frame->avatarPos.x << " " << frame->avatarPos.y << " " << frame->mouse;
//xmlDemoFrame.SetAttribute("a", os.str()); //xmlDemoFrame->SetAttribute("a", os.str().c_str());
doc.InsertEndChild(xmlDemoFrame); doc.InsertEndChild(xmlDemoFrame);
} }
doc.SaveFile(filename); doc.SaveFile(filename.c_str());
} }
void Demo::load(const std::string &name) void Demo::load(const std::string &name)
@ -101,8 +101,8 @@ void Demo::load(const std::string &name)
// UNFINISHED // UNFINISHED
std::string filename = "" + name + ".demo"; std::string filename = "" + name + ".demo";
TiXmlDocument doc; XMLDocument doc;
doc.LoadFile(filename); doc.LoadFile(filename.c_str());
//doc.FirstChildElement(""); //doc.FirstChildElement("");
} }

View file

@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define ENTITY_H #define ENTITY_H
#include "../BBGE/StateMachine.h" #include "../BBGE/StateMachine.h"
#include "../ExternalLibs/tinyxml.h"
#include "../BBGE/SkeletalSprite.h" #include "../BBGE/SkeletalSprite.h"
#include "../BBGE/ScriptObject.h" #include "../BBGE/ScriptObject.h"
@ -30,6 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Path.h" #include "Path.h"
#include "Hair.h" #include "Hair.h"
#include "tinyxml2.h"
using namespace tinyxml2;
class ManaBall; class ManaBall;
class Path; class Path;
@ -267,8 +269,8 @@ public:
Entity *followEntity; Entity *followEntity;
Entity *ridingOnEntity; Entity *ridingOnEntity;
bool canBeTargetedByAvatar; bool canBeTargetedByAvatar;
virtual void saveExtraData(TiXmlElement *xml){} virtual void saveExtraData(XMLElement *xml){}
virtual void loadExtraData(TiXmlElement *xml){} virtual void loadExtraData(XMLElement *xml){}
Vector startPos; Vector startPos;
void getEXP(unsigned int exp); void getEXP(unsigned int exp);
void rotateToVec(Vector addVec, float time, float offsetAngle=0); void rotateToVec(Vector addVec, float time, float offsetAngle=0);

View file

@ -2347,14 +2347,14 @@ bool Game::removeEntity(Entity *selected)
{ {
selected->setState(Entity::STATE_DEAD); selected->setState(Entity::STATE_DEAD);
selected->safeKill(); selected->safeKill();
TiXmlElement *e = this->saveFile->FirstChildElement("Enemy"); XMLElement *e = this->saveFile->FirstChildElement("Enemy");
while (e) while (e)
{ {
int x = atoi(e->Attribute("x")); int x = atoi(e->Attribute("x"));
int y = atoi(e->Attribute("y")); int y = atoi(e->Attribute("y"));
if (int(selected->startPos.x) == x && int(selected->startPos.y) == y) if (int(selected->startPos.x) == x && int(selected->startPos.y) == y)
{ {
this->saveFile->RemoveChild(e); this->saveFile->DeleteChild(e);
//delete e; //delete e;
return true; return true;
} }
@ -4141,8 +4141,8 @@ bool Game::loadSceneXML(std::string scene)
dsq->screenMessage(s); dsq->screenMessage(s);
return false; return false;
} }
TiXmlDocument doc; XMLDocument doc;
doc.LoadFile(fn); doc.LoadFile(fn.c_str());
if (saveFile) if (saveFile)
{ {
delete saveFile; delete saveFile;
@ -4150,14 +4150,14 @@ bool Game::loadSceneXML(std::string scene)
} }
if (!saveFile) if (!saveFile)
{ {
saveFile = new TiXmlDocument(); saveFile = new XMLDocument();
} }
addProgress(); addProgress();
clearObsRows(); clearObsRows();
warpAreas.clear(); warpAreas.clear();
TiXmlElement *lensFlare = doc.FirstChildElement("LensFlare"); XMLElement *lensFlare = doc.FirstChildElement("LensFlare");
while (lensFlare) while (lensFlare)
{ {
LensFlare *l = new LensFlare; LensFlare *l = new LensFlare;
@ -4184,33 +4184,33 @@ bool Game::loadSceneXML(std::string scene)
l->position = Vector(atoi(lensFlare->Attribute("x")),atoi(lensFlare->Attribute("y"))); l->position = Vector(atoi(lensFlare->Attribute("x")),atoi(lensFlare->Attribute("y")));
addRenderObject(l, LR_LIGHTING); addRenderObject(l, LR_LIGHTING);
TiXmlElement lSF("LensFlare"); XMLElement *lSF = doc.NewElement("LensFlare");
lSF.SetAttribute("inc", lensFlare->Attribute("inc")); lSF->SetAttribute("inc", lensFlare->Attribute("inc"));
lSF.SetAttribute("x", lensFlare->Attribute("x")); lSF->SetAttribute("x", lensFlare->Attribute("x"));
lSF.SetAttribute("y", lensFlare->Attribute("y")); lSF->SetAttribute("y", lensFlare->Attribute("y"));
lSF.SetAttribute("tex", lensFlare->Attribute("tex")); lSF->SetAttribute("tex", lensFlare->Attribute("tex"));
lSF.SetAttribute("w", lensFlare->Attribute("w")); lSF->SetAttribute("w", lensFlare->Attribute("w"));
lSF.SetAttribute("h", lensFlare->Attribute("h")); lSF->SetAttribute("h", lensFlare->Attribute("h"));
lSF.SetAttribute("maxLen", lensFlare->Attribute("maxLen")); lSF->SetAttribute("maxLen", lensFlare->Attribute("maxLen"));
saveFile->InsertEndChild(lSF); saveFile->InsertEndChild(lSF);
lensFlare = lensFlare->NextSiblingElement("LensFlare"); lensFlare = lensFlare->NextSiblingElement("LensFlare");
} }
TiXmlElement *level = doc.FirstChildElement("Level"); XMLElement *level = doc.FirstChildElement("Level");
if (level) if (level)
{ {
TiXmlElement levelSF("Level"); XMLElement *levelSF = doc.NewElement("Level");
if (level->Attribute("tileset")) if (level->Attribute("tileset"))
{ {
elementTemplatePack = level->Attribute("tileset"); elementTemplatePack = level->Attribute("tileset");
loadElementTemplates(elementTemplatePack); loadElementTemplates(elementTemplatePack);
levelSF.SetAttribute("tileset", elementTemplatePack); levelSF->SetAttribute("tileset", elementTemplatePack.c_str());
} }
else if (level->Attribute("elementTemplatePack")) else if (level->Attribute("elementTemplatePack"))
{ {
elementTemplatePack = level->Attribute("elementTemplatePack"); elementTemplatePack = level->Attribute("elementTemplatePack");
loadElementTemplates(elementTemplatePack); loadElementTemplates(elementTemplatePack);
levelSF.SetAttribute("tileset", elementTemplatePack); levelSF->SetAttribute("tileset", elementTemplatePack.c_str());
} }
else else
return false; return false;
@ -4220,28 +4220,28 @@ bool Game::loadSceneXML(std::string scene)
useWaterLevel = true; useWaterLevel = true;
waterLevel = atoi(level->Attribute("waterLevel")); waterLevel = atoi(level->Attribute("waterLevel"));
saveWaterLevel = atoi(level->Attribute("waterLevel")); saveWaterLevel = atoi(level->Attribute("waterLevel"));
levelSF.SetAttribute("waterLevel", waterLevel.x); levelSF->SetAttribute("waterLevel", waterLevel.x);
} }
if (level->Attribute("worldMapIndex")) if (level->Attribute("worldMapIndex"))
{ {
worldMapIndex = atoi(level->Attribute("worldMapIndex")); worldMapIndex = atoi(level->Attribute("worldMapIndex"));
levelSF.SetAttribute("worldMapIndex", worldMapIndex); levelSF->SetAttribute("worldMapIndex", worldMapIndex);
} }
if (level->Attribute("bgSfxLoop")) if (level->Attribute("bgSfxLoop"))
{ {
bgSfxLoop = level->Attribute("bgSfxLoop"); bgSfxLoop = level->Attribute("bgSfxLoop");
levelSF.SetAttribute("bgSfxLoop", bgSfxLoop); levelSF->SetAttribute("bgSfxLoop", bgSfxLoop.c_str());
} }
if (level->Attribute("airSfxLoop")) if (level->Attribute("airSfxLoop"))
{ {
airSfxLoop = level->Attribute("airSfxLoop"); airSfxLoop = level->Attribute("airSfxLoop");
levelSF.SetAttribute("airSfxLoop", airSfxLoop); levelSF->SetAttribute("airSfxLoop", airSfxLoop.c_str());
} }
if (level->Attribute("bnat")) if (level->Attribute("bnat"))
{ {
bNatural = atoi(level->Attribute("bnat")); bNatural = atoi(level->Attribute("bnat"));
levelSF.SetAttribute("bnat", 1); levelSF->SetAttribute("bnat", 1);
} }
else else
{ {
@ -4253,7 +4253,7 @@ bool Game::loadSceneXML(std::string scene)
{ {
int v = (atoi(level->Attribute("darkLayer"))); int v = (atoi(level->Attribute("darkLayer")));
levelSF.SetAttribute("darkLayer", v); levelSF->SetAttribute("darkLayer", v);
} }
*/ */
dsq->darkLayer.toggle(true); dsq->darkLayer.toggle(true);
@ -4262,13 +4262,13 @@ bool Game::loadSceneXML(std::string scene)
{ {
SimpleIStringStream is(level->Attribute("bgRepeat")); SimpleIStringStream is(level->Attribute("bgRepeat"));
is >> backgroundImageRepeat; is >> backgroundImageRepeat;
levelSF.SetAttribute("bgRepeat", level->Attribute("bgRepeat")); levelSF->SetAttribute("bgRepeat", level->Attribute("bgRepeat"));
} }
if (level->Attribute("cameraConstrained")) if (level->Attribute("cameraConstrained"))
{ {
SimpleIStringStream is(level->Attribute("cameraConstrained")); SimpleIStringStream is(level->Attribute("cameraConstrained"));
is >> cameraConstrained; is >> cameraConstrained;
levelSF.SetAttribute("cameraConstrained", cameraConstrained); levelSF->SetAttribute("cameraConstrained", cameraConstrained);
std::ostringstream os; std::ostringstream os;
os << "cameraConstrained: " << cameraConstrained; os << "cameraConstrained: " << cameraConstrained;
debugLog(os.str()); debugLog(os.str());
@ -4278,12 +4278,12 @@ bool Game::loadSceneXML(std::string scene)
maxZoom = atof(level->Attribute("maxZoom")); maxZoom = atof(level->Attribute("maxZoom"));
std::ostringstream os; std::ostringstream os;
os << maxZoom; os << maxZoom;
levelSF.SetAttribute("maxZoom", os.str()); levelSF->SetAttribute("maxZoom", os.str().c_str());
} }
if (level->Attribute("natureForm")) if (level->Attribute("natureForm"))
{ {
sceneNatureForm = level->Attribute("natureForm"); sceneNatureForm = level->Attribute("natureForm");
levelSF.SetAttribute("natureForm", sceneNatureForm); levelSF->SetAttribute("natureForm", sceneNatureForm.c_str());
} }
if (level->Attribute("bg")) if (level->Attribute("bg"))
{ {
@ -4299,7 +4299,7 @@ bool Game::loadSceneXML(std::string scene)
bg->setTexture(tex); bg->setTexture(tex);
bg->setWidthHeight(900,600); bg->setWidthHeight(900,600);
levelSF.SetAttribute("bg", tex); levelSF->SetAttribute("bg", tex.c_str());
} }
else else
{ {
@ -4318,16 +4318,16 @@ bool Game::loadSceneXML(std::string scene)
{ {
SimpleIStringStream is(level->Attribute("gradTop")); SimpleIStringStream is(level->Attribute("gradTop"));
is >> gradTop.x >> gradTop.y >> gradTop.z; is >> gradTop.x >> gradTop.y >> gradTop.z;
levelSF.SetAttribute("gradTop", level->Attribute("gradTop")); levelSF->SetAttribute("gradTop", level->Attribute("gradTop"));
} }
if (level->Attribute("gradBtm")) if (level->Attribute("gradBtm"))
{ {
SimpleIStringStream is(level->Attribute("gradBtm")); SimpleIStringStream is(level->Attribute("gradBtm"));
is >> gradBtm.x >> gradBtm.y >> gradBtm.z; is >> gradBtm.x >> gradBtm.y >> gradBtm.z;
levelSF.SetAttribute("gradBtm", level->Attribute("gradBtm")); levelSF->SetAttribute("gradBtm", level->Attribute("gradBtm"));
} }
createGradient(); createGradient();
levelSF.SetAttribute("gradient", 1); levelSF->SetAttribute("gradient", 1);
} }
if (level->Attribute("parallax")) if (level->Attribute("parallax"))
@ -4352,7 +4352,7 @@ bool Game::loadSceneXML(std::string scene)
l->followCamera = g; l->followCamera = g;
l = &dsq->renderObjectLayers[LR_ELEMENTS16]; l = &dsq->renderObjectLayers[LR_ELEMENTS16];
l->followCamera = b; l->followCamera = b;
levelSF.SetAttribute("parallax", level->Attribute("parallax")); levelSF->SetAttribute("parallax", level->Attribute("parallax"));
} }
if (level->Attribute("parallaxLock")) if (level->Attribute("parallaxLock"))
@ -4375,7 +4375,7 @@ bool Game::loadSceneXML(std::string scene)
l = &dsq->renderObjectLayers[LR_ELEMENTS16]; l = &dsq->renderObjectLayers[LR_ELEMENTS16];
l->followCameraLock = b; l->followCameraLock = b;
levelSF.SetAttribute("parallaxLock", level->Attribute("parallaxLock")); levelSF->SetAttribute("parallaxLock", level->Attribute("parallaxLock"));
} }
if (level->Attribute("bg2")) if (level->Attribute("bg2"))
@ -4392,7 +4392,7 @@ bool Game::loadSceneXML(std::string scene)
*/ */
bg2->setTexture(tex); bg2->setTexture(tex);
bg2->setWidthHeight(900,600); bg2->setWidthHeight(900,600);
levelSF.SetAttribute("bg2", tex); levelSF->SetAttribute("bg2", tex.c_str());
} }
else else
@ -4420,16 +4420,16 @@ bool Game::loadSceneXML(std::string scene)
int x = atoi(level->Attribute("bd-x")); int x = atoi(level->Attribute("bd-x"));
int y = atoi(level->Attribute("bd-y")); int y = atoi(level->Attribute("bd-y"));
backdropQuad->position = Vector(x,y); backdropQuad->position = Vector(x,y);
levelSF.SetAttribute("bd-x", x); levelSF->SetAttribute("bd-x", x);
levelSF.SetAttribute("bd-y", y); levelSF->SetAttribute("bd-y", y);
} }
if (level->Attribute("bd-w") && level->Attribute("bd-h")) if (level->Attribute("bd-w") && level->Attribute("bd-h"))
{ {
int w = atoi(level->Attribute("bd-w")); int w = atoi(level->Attribute("bd-w"));
int h = atoi(level->Attribute("bd-h")); int h = atoi(level->Attribute("bd-h"));
backdropQuad->setWidthHeight(w, h); backdropQuad->setWidthHeight(w, h);
levelSF.SetAttribute("bd-w", w); levelSF->SetAttribute("bd-w", w);
levelSF.SetAttribute("bd-h", h); levelSF->SetAttribute("bd-h", h);
} }
backdropQuad->toggleCull(false); backdropQuad->toggleCull(false);
//backdropQuad->followCamera = 1; //backdropQuad->followCamera = 1;
@ -4440,7 +4440,7 @@ bool Game::loadSceneXML(std::string scene)
Vector((backdropQuad->getWidth()*backdropQuad->scale.x)/2.0f, Vector((backdropQuad->getWidth()*backdropQuad->scale.x)/2.0f,
(backdropQuad->getHeight()*backdropQuad->scale.y)/2.0f); (backdropQuad->getHeight()*backdropQuad->scale.y)/2.0f);
// save // save
levelSF.SetAttribute("backdrop", backdrop.c_str()); levelSF->SetAttribute("backdrop", backdrop.c_str());
//backdrop="cavebg" bd-w="2400" bd-h="2400" //backdrop="cavebg" bd-w="2400" bd-h="2400"
} }
musicToPlay = ""; musicToPlay = "";
@ -4448,7 +4448,7 @@ bool Game::loadSceneXML(std::string scene)
{ {
setMusicToPlay(level->Attribute("music")); setMusicToPlay(level->Attribute("music"));
saveMusic = level->Attribute("music"); saveMusic = level->Attribute("music");
levelSF.SetAttribute("music", level->Attribute("music")); levelSF->SetAttribute("music", level->Attribute("music"));
/* /*
// if using SDL_Mixer // if using SDL_Mixer
if (!core->sound->isPlayingMusic(musicToPlay)) if (!core->sound->isPlayingMusic(musicToPlay))
@ -4461,7 +4461,7 @@ bool Game::loadSceneXML(std::string scene)
{ {
SimpleIStringStream in(level->Attribute("sceneColor")); SimpleIStringStream in(level->Attribute("sceneColor"));
in >> sceneColor.x >> sceneColor.y >> sceneColor.z; in >> sceneColor.x >> sceneColor.y >> sceneColor.z;
levelSF.SetAttribute("sceneColor", level->Attribute("sceneColor")); levelSF->SetAttribute("sceneColor", level->Attribute("sceneColor"));
} }
saveFile->InsertEndChild(levelSF); saveFile->InsertEndChild(levelSF);
@ -4469,7 +4469,7 @@ bool Game::loadSceneXML(std::string scene)
else else
return false; return false;
TiXmlElement *obs = doc.FirstChildElement("Obs"); XMLElement *obs = doc.FirstChildElement("Obs");
if (obs) if (obs)
{ {
int tx, ty, len; int tx, ty, len;
@ -4482,7 +4482,7 @@ bool Game::loadSceneXML(std::string scene)
addProgress(); addProgress();
} }
TiXmlElement *pathXml = doc.FirstChildElement("Path"); XMLElement *pathXml = doc.FirstChildElement("Path");
while (pathXml) while (pathXml)
{ {
Path *path = new Path; Path *path = new Path;
@ -4494,7 +4494,7 @@ bool Game::loadSceneXML(std::string scene)
path.active = atoi(pathXml->Attribute("active")); path.active = atoi(pathXml->Attribute("active"));
} }
*/ */
TiXmlElement *nodeXml = pathXml->FirstChildElement("Node"); XMLElement *nodeXml = pathXml->FirstChildElement("Node");
while (nodeXml) while (nodeXml)
{ {
PathNode node; PathNode node;
@ -4529,27 +4529,27 @@ bool Game::loadSceneXML(std::string scene)
pathXml = pathXml->NextSiblingElement("Path"); pathXml = pathXml->NextSiblingElement("Path");
} }
TiXmlElement *quad = doc.FirstChildElement("Quad"); XMLElement *quad = doc.FirstChildElement("Quad");
while (quad) while (quad)
{ {
TiXmlElement qSF("Quad"); XMLElement *qSF = doc.NewElement("Quad");
int x=0, y=0, z=0; int x=0, y=0, z=0;
int w=0,h=0; int w=0,h=0;
bool cull=true; bool cull=true;
bool solid = false; bool solid = false;
std::string justify; std::string justify;
std::string tex; std::string tex;
qSF.SetAttribute("x", x = atoi(quad->Attribute("x"))); qSF->SetAttribute("x", x = atoi(quad->Attribute("x")));
qSF.SetAttribute("y", y = atoi(quad->Attribute("y"))); qSF->SetAttribute("y", y = atoi(quad->Attribute("y")));
//qSF.SetAttribute("z", z = atoi(quad->Attribute("z"))); //qSF->SetAttribute("z", z = atoi(quad->Attribute("z")));
qSF.SetAttribute("w", w = atoi(quad->Attribute("w"))); qSF->SetAttribute("w", w = atoi(quad->Attribute("w")));
qSF.SetAttribute("h", h = atoi(quad->Attribute("h"))); qSF->SetAttribute("h", h = atoi(quad->Attribute("h")));
qSF.SetAttribute("tex", tex = (quad->Attribute("tex"))); qSF->SetAttribute("tex", (tex = (quad->Attribute("tex"))).c_str());
qSF.SetAttribute("cull", cull = atoi(quad->Attribute("cull"))); qSF->SetAttribute("cull", cull = atoi(quad->Attribute("cull")));
qSF.SetAttribute("justify", justify = (quad->Attribute("justify"))); qSF->SetAttribute("justify", (justify = (quad->Attribute("justify"))).c_str());
if (quad->Attribute("solid")) if (quad->Attribute("solid"))
qSF.SetAttribute("solid", solid = atoi(quad->Attribute("solid"))); qSF->SetAttribute("solid", solid = atoi(quad->Attribute("solid")));
Quad *q = new Quad; Quad *q = new Quad;
q->position = Vector(x,y,z); q->position = Vector(x,y,z);
@ -4576,25 +4576,23 @@ bool Game::loadSceneXML(std::string scene)
quad = quad->NextSiblingElement("Quad"); quad = quad->NextSiblingElement("Quad");
} }
TiXmlElement *floater = doc.FirstChildElement("Floater"); XMLElement *floater = doc.FirstChildElement("Floater");
while(floater) while(floater)
{ {
TiXmlElement nSF("Floater"); XMLElement *nSF = doc.NewElement("Floater");
if (!floater->Attribute("boxW") || !floater->Attribute("boxH")) if (!floater->Attribute("boxW") || !floater->Attribute("boxH"))
{ {
errorLog ("no boxW/boxH"); errorLog ("no boxW/boxH");
break; break;
} }
int boxW, boxH, x, y, fx, fy; int boxW, boxH, x, y, fx, fy;
std::string tex; nSF->SetAttribute("boxW", boxW = atoi(floater->Attribute("boxW")));
nSF.SetAttribute("boxW", boxW = atoi(floater->Attribute("boxW"))); nSF->SetAttribute("boxH", boxH = atoi(floater->Attribute("boxH")));
nSF.SetAttribute("boxH", boxH = atoi(floater->Attribute("boxH"))); nSF->SetAttribute("tex", floater->Attribute("tex"));
tex = floater->Attribute("tex"); nSF->SetAttribute("x", x = atoi(floater->Attribute("x")));
nSF.SetAttribute("tex", tex); nSF->SetAttribute("y", y = atoi(floater->Attribute("y")));
nSF.SetAttribute("x", x = atoi(floater->Attribute("x"))); nSF->SetAttribute("fx", fx = atoi(floater->Attribute("fx")));
nSF.SetAttribute("y", y = atoi(floater->Attribute("y"))); nSF->SetAttribute("fy", fy = atoi(floater->Attribute("fy")));
nSF.SetAttribute("fx", fx = atoi(floater->Attribute("fx")));
nSF.SetAttribute("fy", fy = atoi(floater->Attribute("fy")));
/* /*
Floater *f = new Floater(Vector(x,y), Vector(fx, fy), boxW, boxH, tex); Floater *f = new Floater(Vector(x,y), Vector(fx, fy), boxW, boxH, tex);
@ -4608,10 +4606,10 @@ bool Game::loadSceneXML(std::string scene)
} }
/* /*
TiXmlElement *breakable = doc.FirstChildElement("Breakable"); XMLElement *breakable = doc.FirstChildElement("Breakable");
while(breakable) while(breakable)
{ {
TiXmlElement nSF("Breakable"); XMLElement *nSF = doc.NewElement("Breakable");
if (!breakable->Attribute("boxW") || !breakable->Attribute("boxH")) if (!breakable->Attribute("boxW") || !breakable->Attribute("boxH"))
{ {
errorLog ("Breakable error.. no boxW/boxH"); errorLog ("Breakable error.. no boxW/boxH");
@ -4619,19 +4617,19 @@ bool Game::loadSceneXML(std::string scene)
} }
int boxW, boxH; int boxW, boxH;
std::string tex; std::string tex;
nSF.SetAttribute("boxW", boxW = atoi(breakable->Attribute("boxW"))); nSF->SetAttribute("boxW", boxW = atoi(breakable->Attribute("boxW")));
nSF.SetAttribute("boxH", boxH = atoi(breakable->Attribute("boxH"))); nSF->SetAttribute("boxH", boxH = atoi(breakable->Attribute("boxH")));
tex = breakable->Attribute("tex"); tex = breakable->Attribute("tex");
nSF.SetAttribute("tex", tex); nSF->SetAttribute("tex", tex);
Breakable *n = new Breakable(boxW, boxH, tex); Breakable *n = new Breakable(boxW, boxH, tex);
{ {
nSF.SetAttribute("x", n->position.x = atoi(breakable->Attribute("x"))); nSF->SetAttribute("x", n->position.x = atoi(breakable->Attribute("x")));
nSF.SetAttribute("y", n->position.y = atoi(breakable->Attribute("y"))); nSF->SetAttribute("y", n->position.y = atoi(breakable->Attribute("y")));
int w=0, h=0; int w=0, h=0;
if (breakable->Attribute("w")) if (breakable->Attribute("w"))
nSF.SetAttribute("w", w = atoi(breakable->Attribute("w"))); nSF->SetAttribute("w", w = atoi(breakable->Attribute("w")));
if (breakable->Attribute("h")) if (breakable->Attribute("h"))
nSF.SetAttribute("h", h= atoi(breakable->Attribute("h"))); nSF->SetAttribute("h", h= atoi(breakable->Attribute("h")));
if (w != 0 && h != 0) if (w != 0 && h != 0)
{ {
n->setWidthHeight(w, h); n->setWidthHeight(w, h);
@ -4643,31 +4641,31 @@ bool Game::loadSceneXML(std::string scene)
} }
*/ */
TiXmlElement *warpArea = doc.FirstChildElement("WarpArea"); XMLElement *warpArea = doc.FirstChildElement("WarpArea");
while(warpArea) while(warpArea)
{ {
TiXmlElement waSF("WarpArea"); XMLElement *waSF = doc.NewElement("WarpArea");
WarpArea a; WarpArea a;
waSF.SetAttribute("x", a.position.x = atoi(warpArea->Attribute("x"))); waSF->SetAttribute("x", a.position.x = atoi(warpArea->Attribute("x")));
waSF.SetAttribute("y", a.position.y = atoi(warpArea->Attribute("y"))); waSF->SetAttribute("y", a.position.y = atoi(warpArea->Attribute("y")));
if (warpArea->Attribute("radius")) if (warpArea->Attribute("radius"))
waSF.SetAttribute("radius", a.radius = atoi(warpArea->Attribute("radius"))); waSF->SetAttribute("radius", a.radius = atoi(warpArea->Attribute("radius")));
bool isRect = false; bool isRect = false;
if (warpArea->Attribute("w")) if (warpArea->Attribute("w"))
{ {
isRect = true; isRect = true;
waSF.SetAttribute("w", a.w = atoi(warpArea->Attribute("w"))); waSF->SetAttribute("w", a.w = atoi(warpArea->Attribute("w")));
waSF.SetAttribute("h", a.h = atoi(warpArea->Attribute("h"))); waSF->SetAttribute("h", a.h = atoi(warpArea->Attribute("h")));
} }
if (warpArea->Attribute("g")) if (warpArea->Attribute("g"))
{ {
waSF.SetAttribute("g", a.generated = atoi(warpArea->Attribute("g"))); waSF->SetAttribute("g", a.generated = atoi(warpArea->Attribute("g")));
} }
std::string sceneString = warpArea->Attribute("scene"); std::string sceneString = warpArea->Attribute("scene");
waSF.SetAttribute("scene", sceneString.c_str()); waSF->SetAttribute("scene", sceneString.c_str());
/* /*
waSF.SetAttribute("ax", a.avatarPosition.x = atoi(warpArea->Attribute("ax"))); waSF->SetAttribute("ax", a.avatarPosition.x = atoi(warpArea->Attribute("ax")));
waSF.SetAttribute("ay", a.avatarPosition.y = atoi(warpArea->Attribute("ay"))); waSF->SetAttribute("ay", a.avatarPosition.y = atoi(warpArea->Attribute("ay")));
*/ */
SimpleIStringStream is(sceneString); SimpleIStringStream is(sceneString);
@ -4697,7 +4695,7 @@ bool Game::loadSceneXML(std::string scene)
warpArea = warpArea->NextSiblingElement("WarpArea"); warpArea = warpArea->NextSiblingElement("WarpArea");
} }
TiXmlElement *schoolFish = doc.FirstChildElement("SchoolFish"); XMLElement *schoolFish = doc.FirstChildElement("SchoolFish");
while(schoolFish) while(schoolFish)
{ {
int num = atoi(schoolFish->Attribute("num")); int num = atoi(schoolFish->Attribute("num"));
@ -4794,27 +4792,27 @@ bool Game::loadSceneXML(std::string scene)
schoolFish = schoolFish->NextSiblingElement("SchoolFish"); schoolFish = schoolFish->NextSiblingElement("SchoolFish");
TiXmlElement newSF("SchoolFish"); XMLElement *newSF = doc.NewElement("SchoolFish");
newSF.SetAttribute("x", x); newSF->SetAttribute("x", x);
newSF.SetAttribute("y", y); newSF->SetAttribute("y", y);
newSF.SetAttribute("id", id); newSF->SetAttribute("id", id);
newSF.SetAttribute("num", num); newSF->SetAttribute("num", num);
if (range != 0) if (range != 0)
newSF.SetAttribute("range", range); newSF->SetAttribute("range", range);
if (maxSpeed != 0) if (maxSpeed != 0)
newSF.SetAttribute("maxSpeed", maxSpeed); newSF->SetAttribute("maxSpeed", maxSpeed);
if (layer != 0) if (layer != 0)
newSF.SetAttribute("layer", layer); newSF->SetAttribute("layer", layer);
if (!gfx.empty()) if (!gfx.empty())
newSF.SetAttribute("gfx", gfx.c_str()); newSF->SetAttribute("gfx", gfx.c_str());
if (size != 1) if (size != 1)
newSF.SetAttribute("size", size); newSF->SetAttribute("size", size);
saveFile->InsertEndChild(newSF); saveFile->InsertEndChild(newSF);
} }
/* /*
TiXmlElement *boxElement = doc.FirstChildElement("BoxElement"); XMLElement *boxElement = doc.FirstChildElement("BoxElement");
while (boxElement) while (boxElement)
{ {
BoxElement *b = new BoxElement(atoi(boxElement->Attribute("w")), atoi(boxElement->Attribute("h"))); BoxElement *b = new BoxElement(atoi(boxElement->Attribute("w")), atoi(boxElement->Attribute("h")));
@ -4825,7 +4823,7 @@ bool Game::loadSceneXML(std::string scene)
boxElement = boxElement->NextSiblingElement("BoxElement"); boxElement = boxElement->NextSiblingElement("BoxElement");
} }
*/ */
TiXmlElement *simpleElements = doc.FirstChildElement("SE"); XMLElement *simpleElements = doc.FirstChildElement("SE");
while (simpleElements) while (simpleElements)
{ {
int idx, x, y, rot; int idx, x, y, rot;
@ -4992,7 +4990,7 @@ bool Game::loadSceneXML(std::string scene)
simpleElements = simpleElements->NextSiblingElement("SE"); simpleElements = simpleElements->NextSiblingElement("SE");
} }
TiXmlElement *element = doc.FirstChildElement("Element"); XMLElement *element = doc.FirstChildElement("Element");
while (element) while (element)
{ {
if (element->Attribute("idx")) if (element->Attribute("idx"))
@ -5039,7 +5037,7 @@ bool Game::loadSceneXML(std::string scene)
this->reconstructGrid(true); this->reconstructGrid(true);
/* /*
TiXmlElement *enemyNode = doc.FirstChildElement("Enemy"); XMLElement *enemyNode = doc.FirstChildElement("Enemy");
while(enemyNode) while(enemyNode)
{ {
Vector pos; Vector pos;
@ -5059,7 +5057,7 @@ bool Game::loadSceneXML(std::string scene)
enemyNode = enemyNode->NextSiblingElement("Enemy"); enemyNode = enemyNode->NextSiblingElement("Enemy");
} }
*/ */
TiXmlElement *entitiesNode = doc.FirstChildElement("Entities"); XMLElement *entitiesNode = doc.FirstChildElement("Entities");
while(entitiesNode) while(entitiesNode)
{ {
if (entitiesNode->Attribute("j")) if (entitiesNode->Attribute("j"))
@ -5247,15 +5245,19 @@ bool Game::saveScene(std::string scene)
std::string fn = getSceneFilename(scene); std::string fn = getSceneFilename(scene);
TiXmlDocument saveFile(*this->saveFile); XMLPrinter printer;
//this->saveFile->CopyTo(&saveFile); this->saveFile->Print(&printer);
TiXmlElement *level = saveFile.FirstChildElement("Level");
TiXmlElement levelLocal("Level"); XMLDocument saveFile;
saveFile.Parse(printer.CStr(), printer.CStrSize());
XMLElement *level = saveFile.FirstChildElement("Level");
XMLElement *levelLocal = saveFile.NewElement("Level");
bool addIt = false; bool addIt = false;
if (!level) if (!level)
{ {
level = &levelLocal; level = levelLocal;
addIt = true; addIt = true;
} }
@ -5269,17 +5271,17 @@ bool Game::saveScene(std::string scene)
std::ostringstream os; std::ostringstream os;
os << gradTop.x << " " << gradTop.y << " " << gradTop.z; os << gradTop.x << " " << gradTop.y << " " << gradTop.z;
level->SetAttribute("gradTop", os.str()); level->SetAttribute("gradTop", os.str().c_str());
std::ostringstream os2; std::ostringstream os2;
os2 << gradBtm.x << " " << gradBtm.y << " " << gradBtm.z; os2 << gradBtm.x << " " << gradBtm.y << " " << gradBtm.z;
level->SetAttribute("gradBtm", os2.str()); level->SetAttribute("gradBtm", os2.str().c_str());
} }
if (!saveMusic.empty()) if (!saveMusic.empty())
{ {
level->SetAttribute("music", saveMusic); level->SetAttribute("music", saveMusic.c_str());
} }
} }
@ -5289,16 +5291,16 @@ bool Game::saveScene(std::string scene)
} }
/* /*
TiXmlElement level("Level"); XMLElement *level = doc.NewElement("Level");
level.SetAttribute("elementTemplatePack", elementTemplatePack); level->SetAttribute("elementTemplatePack", elementTemplatePack);
if (bg) if (bg)
{ {
int pos = bg->texture->name.find_last_of('/')+1; int pos = bg->texture->name.find_last_of('/')+1;
int pos2 = bg->texture->name.find_last_of('.'); int pos2 = bg->texture->name.find_last_of('.');
level.SetAttribute("bg", bg->texture->name.substr(pos, pos2-pos)); level->SetAttribute("bg", bg->texture->name.substr(pos, pos2-pos));
std::ostringstream os; std::ostringstream os;
os << sceneColor.x << " " << sceneColor.y << " " << sceneColor.z; os << sceneColor.x << " " << sceneColor.y << " " << sceneColor.z;
level.SetAttribute("sceneColor", os.str()); level->SetAttribute("sceneColor", os.str());
} }
saveFile->InsertEndChild(level); saveFile->InsertEndChild(level);
*/ */
@ -5309,32 +5311,32 @@ bool Game::saveScene(std::string scene)
{ {
obs << obsRows[i].tx << " " << obsRows[i].ty << " " << obsRows[i].len << " "; obs << obsRows[i].tx << " " << obsRows[i].ty << " " << obsRows[i].len << " ";
} }
TiXmlElement obsXml("Obs"); XMLElement *obsXml = saveFile.NewElement("Obs");
obsXml.SetAttribute("d", obs.str()); obsXml->SetAttribute("d", obs.str().c_str());
saveFile.InsertEndChild(obsXml); saveFile.InsertEndChild(obsXml);
for (i = 0; i < dsq->game->getNumPaths(); i++) for (i = 0; i < dsq->game->getNumPaths(); i++)
{ {
TiXmlElement pathXml("Path"); XMLElement *pathXml = saveFile.NewElement("Path");
Path *p = dsq->game->getPath(i); Path *p = dsq->game->getPath(i);
pathXml.SetAttribute("name", p->name); pathXml->SetAttribute("name", p->name.c_str());
//pathXml.SetAttribute("active", p->active); //pathXml->SetAttribute("active", p->active);
for (int n = 0; n < p->nodes.size(); n++) for (int n = 0; n < p->nodes.size(); n++)
{ {
TiXmlElement nodeXml("Node"); XMLElement *nodeXml = saveFile.NewElement("Node");
std::ostringstream os; std::ostringstream os;
os << int(p->nodes[n].position.x) << " " << int(p->nodes[n].position.y); os << int(p->nodes[n].position.x) << " " << int(p->nodes[n].position.y);
nodeXml.SetAttribute("pos", os.str().c_str()); nodeXml->SetAttribute("pos", os.str().c_str());
std::ostringstream os2; std::ostringstream os2;
os2 << p->rect.getWidth() << " " << p->rect.getHeight(); os2 << p->rect.getWidth() << " " << p->rect.getHeight();
nodeXml.SetAttribute("rect", os2.str().c_str()); nodeXml->SetAttribute("rect", os2.str().c_str());
nodeXml.SetAttribute("shape", (int)p->pathShape); nodeXml->SetAttribute("shape", (int)p->pathShape);
if (p->nodes[n].maxSpeed != -1) if (p->nodes[n].maxSpeed != -1)
{ {
nodeXml.SetAttribute("ms", p->nodes[n].maxSpeed); nodeXml->SetAttribute("ms", p->nodes[n].maxSpeed);
} }
pathXml.InsertEndChild(nodeXml); pathXml->InsertEndChild(nodeXml);
} }
saveFile.InsertEndChild(pathXml); saveFile.InsertEndChild(pathXml);
} }
@ -5342,23 +5344,23 @@ bool Game::saveScene(std::string scene)
for (i = 0; i < dsq->game->warpAreas.size(); i++) for (i = 0; i < dsq->game->warpAreas.size(); i++)
{ {
WarpArea a = dsq->game->warpAreas[i]; WarpArea a = dsq->game->warpAreas[i];
TiXmlElement waSF("WarpArea"); XMLElement *waSF = saveFile.NewElement("WarpArea");
waSF.SetAttribute("x", a.position.x); waSF->SetAttribute("x", a.position.x);
waSF.SetAttribute("y", a.position.y); waSF->SetAttribute("y", a.position.y);
if (a.radius > 0) if (a.radius > 0)
waSF.SetAttribute("radius", a.radius); waSF->SetAttribute("radius", a.radius);
else if (a.w > 0 && a.h > 0) else if (a.w > 0 && a.h > 0)
{ {
waSF.SetAttribute("w", a.w); waSF->SetAttribute("w", a.w);
waSF.SetAttribute("h", a.h); waSF->SetAttribute("h", a.h);
} }
if (a.generated) if (a.generated)
{ {
waSF.SetAttribute("g", 1); waSF->SetAttribute("g", 1);
} }
std::ostringstream os; std::ostringstream os;
os << a.sceneName << " " << a.warpAreaType << " " << a.spawnOffset.x << " " << a.spawnOffset.y; os << a.sceneName << " " << a.warpAreaType << " " << a.spawnOffset.x << " " << a.spawnOffset.y;
waSF.SetAttribute("scene", os.str().c_str()); waSF->SetAttribute("scene", os.str().c_str());
saveFile.InsertEndChild(waSF); saveFile.InsertEndChild(waSF);
} }
@ -5374,7 +5376,7 @@ bool Game::saveScene(std::string scene)
if (dsq->game->entitySaveData.size() > 0) if (dsq->game->entitySaveData.size() > 0)
{ {
TiXmlElement entitiesNode("Entities"); XMLElement *entitiesNode = saveFile.NewElement("Entities");
std::ostringstream os; std::ostringstream os;
for (int i = 0; i < dsq->game->entitySaveData.size(); i++) for (int i = 0; i < dsq->game->entitySaveData.size(); i++)
@ -5392,7 +5394,7 @@ bool Game::saveScene(std::string scene)
// group ID no longer used // group ID no longer used
os << e->x << " " << e->y << " " << e->rot << " " << 0 << " " << e->id << " "; os << e->x << " " << e->y << " " << e->rot << " " << 0 << " " << e->id << " ";
} }
entitiesNode.SetAttribute("j", os.str()); entitiesNode->SetAttribute("j", os.str().c_str());
saveFile.InsertEndChild(entitiesNode); saveFile.InsertEndChild(entitiesNode);
} }
@ -5401,9 +5403,9 @@ bool Game::saveScene(std::string scene)
std::string s = simpleElements[i].str(); std::string s = simpleElements[i].str();
if (!s.empty()) if (!s.empty())
{ {
TiXmlElement simpleElementsXML("SE"); XMLElement *simpleElementsXML = saveFile.NewElement("SE");
simpleElementsXML.SetAttribute("k", s.c_str()); simpleElementsXML->SetAttribute("k", s.c_str());
simpleElementsXML.SetAttribute("l", i); simpleElementsXML->SetAttribute("l", i);
saveFile.InsertEndChild(simpleElementsXML); saveFile.InsertEndChild(simpleElementsXML);
} }
} }
@ -5415,27 +5417,27 @@ bool Game::saveScene(std::string scene)
LightShaft *l = dynamic_cast<LightShaft*>(*i); LightShaft *l = dynamic_cast<LightShaft*>(*i);
if (l) if (l)
{ {
TiXmlElement lightShaft("LightShaft"); XMLElement *lightShaft = saveFile.NewElement("LightShaft");
lightShaft.SetAttribute("x", l->position.x); lightShaft->SetAttribute("x", l->position.x);
lightShaft.SetAttribute("y", l->position.y); lightShaft->SetAttribute("y", l->position.y);
std::ostringstream os; std::ostringstream os;
os << l->getDir().x; os << l->getDir().x;
lightShaft.SetAttribute("dirx", os.str()); lightShaft->SetAttribute("dirx", os.str());
std::ostringstream os2; std::ostringstream os2;
os2 << l->getDir().y; os2 << l->getDir().y;
lightShaft.SetAttribute("diry", os2.str()); lightShaft->SetAttribute("diry", os2.str());
std::ostringstream os3; std::ostringstream os3;
os3 << l->shaftWidth; os3 << l->shaftWidth;
lightShaft.SetAttribute("w", os3.str()); lightShaft->SetAttribute("w", os3.str());
//lightShaft.SetAttribute("dirx", int(l->getDir().x*1000)); //lightShaft->SetAttribute("dirx", int(l->getDir().x*1000));
//lightShaft.SetAttribute("diry", int(l->getDir().y*1000)); //lightShaft->SetAttribute("diry", int(l->getDir().y*1000));
saveFile.InsertEndChild(lightShaft); saveFile.InsertEndChild(lightShaft);
} }
} }
*/ */
bool result = saveFile.SaveFile(fn); bool result = saveFile.SaveFile(fn.c_str());
if (result) if (result)
debugLog("Successfully saved map: " + fn); debugLog("Successfully saved map: " + fn);
else else

View file

@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef GAME_H #ifndef GAME_H
#define GAME_H #define GAME_H
#include "../ExternalLibs/tinyxml.h"
#include "../BBGE/DebugFont.h" #include "../BBGE/DebugFont.h"
#include "../ExternalLibs/glpng.h" #include "../ExternalLibs/glpng.h"
@ -32,6 +31,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Shot.h" #include "Shot.h"
#include "AquariaProgressBar.h" #include "AquariaProgressBar.h"
#include "tinyxml2.h"
using namespace tinyxml2;
class RecipeMenuEntry : public RenderObject class RecipeMenuEntry : public RenderObject
{ {
@ -712,7 +714,7 @@ public:
void setParallaxTextureCoordinates(Quad *q, float speed); void setParallaxTextureCoordinates(Quad *q, float speed);
TiXmlDocument *saveFile; XMLDocument *saveFile;
Vector positionToAvatar; Vector positionToAvatar;
float getCoverage(Vector pos, int sampleArea = 5); float getCoverage(Vector pos, int sampleArea = 5);

View file

@ -83,9 +83,9 @@ bool Mod::isEditorBlocked()
return blockEditor; return blockEditor;
} }
bool Mod::loadModXML(TiXmlDocument *d, std::string modName) bool Mod::loadModXML(XMLDocument *d, std::string modName)
{ {
return d->LoadFile(baseModPath + modName + ".xml"); return d->LoadFile((baseModPath + modName + ".xml").c_str()) == XML_SUCCESS;
} }
const std::string& Mod::getBaseModPath() const const std::string& Mod::getBaseModPath() const
@ -108,46 +108,25 @@ void Mod::load(const std::string &p)
setActive(true); setActive(true);
TiXmlDocument d; XMLDocument d;
loadModXML(&d, p); loadModXML(&d, p);
TiXmlElement *mod = d.FirstChildElement("AquariaMod"); XMLElement *mod = d.FirstChildElement("AquariaMod");
if (mod) if (mod)
{ {
TiXmlElement *props = mod->FirstChildElement("Properties"); XMLElement *props = mod->FirstChildElement("Properties");
if (props) if (props)
{ {
if (props->Attribute("recache")){ props->QueryIntAttribute("recache", &doRecache);
props->Attribute("recache", &doRecache); props->QueryIntAttribute("debugMenu", &debugMenu);
} props->QueryBoolAttribute("hasWorldMap", &hasMap);
props->QueryBoolAttribute("blockEditor", &blockEditor);
if (props->Attribute("runBG")){ if (props->BoolAttribute("runBG"))
int runBG = 0;
props->Attribute("runBG", &runBG);
if (runBG){
core->settings.runInBackground = true; core->settings.runInBackground = true;
}
}
if (props->Attribute("debugMenu")) { if (props->Attribute("worldMapRevealMethod"))
props->Attribute("debugMenu", &debugMenu); mapRevealMethod = (WorldMapRevealMethod) props->IntAttribute("worldMapRevealMethod");
}
if (props->Attribute("hasWorldMap")) {
int t;
props->Attribute("hasWorldMap", &t);
hasMap = t;
}
if (props->Attribute("blockEditor")) {
int t;
props->Attribute("blockEditor", &t);
blockEditor = t;
}
if (props->Attribute("worldMapRevealMethod")) {
int t;
props->Attribute("worldMapRevealMethod", &t);
mapRevealMethod = (WorldMapRevealMethod)t;
}
} }
} }
@ -321,11 +300,11 @@ void Mod::update(float dt)
} }
} }
ModType Mod::getTypeFromXML(TiXmlElement *xml) // should be <AquariaMod>...</AquariaMod> - element ModType Mod::getTypeFromXML(XMLElement *xml) // should be <AquariaMod>...</AquariaMod> - element
{ {
if(xml) if(xml)
{ {
TiXmlElement *prop = xml->FirstChildElement("Properties"); XMLElement *prop = xml->FirstChildElement("Properties");
if(prop) if(prop)
{ {
const char *type = prop->Attribute("type"); const char *type = prop->Attribute("type");

View file

@ -6,9 +6,11 @@
#include "ModDownloader.h" #include "ModDownloader.h"
#include "ModSelector.h" #include "ModSelector.h"
#include "Network.h" #include "Network.h"
#include "tinyxml.h"
#include "ttvfs.h" #include "ttvfs.h"
#include "tinyxml2.h"
using namespace tinyxml2;
using Network::NetEvent; using Network::NetEvent;
using Network::NE_ABORT; using Network::NE_ABORT;
using Network::NE_FINISH; using Network::NE_FINISH;
@ -247,8 +249,8 @@ void ModDL::NotifyModlist(ModlistRequest *rq, NetEvent ev, size_t recvd, size_t
bool ModDL::ParseModXML(const std::string& fn, bool allowChaining) bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
{ {
TiXmlDocument xml; XMLDocument xml;
if(!xml.LoadFile(fn)) if(xml.LoadFile(fn.c_str()) != XML_SUCCESS)
{ {
debugLog("Failed to parse downloaded XML: " + fn); debugLog("Failed to parse downloaded XML: " + fn);
return false; return false;
@ -279,7 +281,7 @@ bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
<ModList> <ModList>
*/ */
TiXmlElement *modlist = xml.FirstChildElement("ModList"); XMLElement *modlist = xml.FirstChildElement("ModList");
if(!modlist) if(!modlist)
{ {
debugLog("ModList root tag not found"); debugLog("ModList root tag not found");
@ -288,11 +290,10 @@ bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
if(allowChaining) if(allowChaining)
{ {
TiXmlElement *servx = modlist->FirstChildElement("Server"); XMLElement *servx = modlist->FirstChildElement("Server");
while(servx) while(servx)
{ {
int chain = 0; int chain = servx->IntAttribute("chain");
servx->Attribute("chain", &chain);
if(const char *url = servx->Attribute("url")) if(const char *url = servx->Attribute("url"))
GetModlist(url, chain, false); GetModlist(url, chain, false);
@ -300,7 +301,7 @@ bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
} }
} }
TiXmlElement *modx = modlist->FirstChildElement("AquariaMod"); XMLElement *modx = modlist->FirstChildElement("AquariaMod");
while(modx) while(modx)
{ {
std::string namestr, descstr, iconurl, pkgurl, confirmStr, localname; std::string namestr, descstr, iconurl, pkgurl, confirmStr, localname;
@ -308,7 +309,7 @@ bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
ModPackageType pkgtype = MPT_MOD; ModPackageType pkgtype = MPT_MOD;
int serverSize = 0; int serverSize = 0;
int serverIconSize = 0; int serverIconSize = 0;
TiXmlElement *fullname, *desc, *icon, *pkg, *confirm, *props, *web; XMLElement *fullname, *desc, *icon, *pkg, *confirm, *props, *web;
fullname = modx->FirstChildElement("Fullname"); fullname = modx->FirstChildElement("Fullname");
desc = modx->FirstChildElement("Description"); desc = modx->FirstChildElement("Description");
icon = modx->FirstChildElement("Icon"); icon = modx->FirstChildElement("Icon");
@ -327,8 +328,8 @@ bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
{ {
if(icon->Attribute("url")) if(icon->Attribute("url"))
iconurl = icon->Attribute("url"); iconurl = icon->Attribute("url");
if(icon->Attribute("size"))
icon->Attribute("size", &serverIconSize); serverIconSize = icon->IntAttribute("size");
} }
if(props && props->Attribute("type")) if(props && props->Attribute("type"))
@ -352,8 +353,7 @@ bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
if(pkg->Attribute("saveAs")) if(pkg->Attribute("saveAs"))
localname = _PathToModName(pkg->Attribute("saveAs")); localname = _PathToModName(pkg->Attribute("saveAs"));
if(pkg->Attribute("size")) serverSize = pkg->IntAttribute("size");
pkg->Attribute("size", &serverSize);
} }
if(confirm && confirm->Attribute("text")) if(confirm && confirm->Attribute("text"))

View file

@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "DSQ.h" #include "DSQ.h"
#include "AquariaProgressBar.h" #include "AquariaProgressBar.h"
#include "tinyxml.h"
#include "ModSelector.h" #include "ModSelector.h"
#include <algorithm> #include <algorithm>
@ -30,6 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ModDownloader.h" #include "ModDownloader.h"
#endif #endif
#include "tinyxml2.h"
using namespace tinyxml2;
#define MOD_ICON_SIZE 150 #define MOD_ICON_SIZE 150
#define MINI_ICON_SIZE 32 #define MINI_ICON_SIZE 32
@ -551,16 +553,16 @@ void ModIcon::loadEntry(const ModEntry& entry)
useQuad(texToLoad); useQuad(texToLoad);
quad->setWidthHeight(MOD_ICON_SIZE, MOD_ICON_SIZE); quad->setWidthHeight(MOD_ICON_SIZE, MOD_ICON_SIZE);
TiXmlDocument d; XMLDocument d;
dsq->mod.loadModXML(&d, entry.path); dsq->mod.loadModXML(&d, entry.path);
std::string ds = dsq->continuity.stringBank.get(2009); std::string ds = dsq->continuity.stringBank.get(2009);
TiXmlElement *top = d.FirstChildElement("AquariaMod"); XMLElement *top = d.FirstChildElement("AquariaMod");
if (top) if (top)
{ {
TiXmlElement *desc = top->FirstChildElement("Description"); XMLElement *desc = top->FirstChildElement("Description");
if (desc) if (desc)
{ {
if (desc->Attribute("text")) if (desc->Attribute("text"))
@ -568,7 +570,7 @@ void ModIcon::loadEntry(const ModEntry& entry)
ds = desc->Attribute("text"); ds = desc->Attribute("text");
} }
} }
TiXmlElement *fullname = top->FirstChildElement("Fullname"); XMLElement *fullname = top->FirstChildElement("Fullname");
if (fullname) if (fullname)
{ {
if (fullname->Attribute("text")) if (fullname->Attribute("text"))

View file

@ -1169,7 +1169,7 @@ void SceneEditor::deleteSelected()
void SceneEditor::updateSaveFileEnemyPosition(Entity *ent) void SceneEditor::updateSaveFileEnemyPosition(Entity *ent)
{ {
TiXmlElement *exml = dsq->game->saveFile->FirstChildElement("Enemy"); XMLElement *exml = dsq->game->saveFile->FirstChildElement("Enemy");
while (exml) while (exml)
{ {
int x = atoi(exml->Attribute("x")); int x = atoi(exml->Attribute("x"));

View file

@ -25,7 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Game.h" #include "Game.h"
#include "Avatar.h" #include "Avatar.h"
#else #else
#include "../ExternalLibs/tinyxml.h" #include "tinyxml2.h"
using namespace tinyxml2;
#endif #endif
@ -33,268 +34,243 @@ void UserSettings::save()
{ {
//initInputCodeMap(); //initInputCodeMap();
TiXmlDocument doc; XMLDocument doc;
{ {
TiXmlElement xml_version("Version"); XMLElement *xml_version = doc.NewElement("Version");
{ {
xml_version.SetAttribute("settingsVersion", VERSION_USERSETTINGS); xml_version->SetAttribute("settingsVersion", VERSION_USERSETTINGS);
} }
doc.InsertEndChild(xml_version); doc.InsertEndChild(xml_version);
TiXmlElement xml_system("System"); XMLElement *xml_system = doc.NewElement("System");
{ {
TiXmlElement xml_debugLog("DebugLog"); XMLElement *xml_debugLog = doc.NewElement("DebugLog");
{ {
xml_debugLog.SetAttribute("on", system.debugLogOn); xml_debugLog->SetAttribute("on", system.debugLogOn);
} }
xml_system.InsertEndChild(xml_debugLog); xml_system->InsertEndChild(xml_debugLog);
TiXmlElement xml_locale("Locale"); XMLElement *xml_locale = doc.NewElement("Locale");
{ {
xml_locale.SetAttribute("name", system.locale); xml_locale->SetAttribute("name", system.locale.c_str());
} }
xml_system.InsertEndChild(xml_locale); xml_system->InsertEndChild(xml_locale);
TiXmlElement xml_devmode("DeveloperMode"); XMLElement *xml_devmode = doc.NewElement("DeveloperMode");
{ {
xml_devmode.SetAttribute("on", system.devModeOn); xml_devmode->SetAttribute("on", system.devModeOn);
} }
xml_system.InsertEndChild(xml_devmode); xml_system->InsertEndChild(xml_devmode);
} }
doc.InsertEndChild(xml_system); doc.InsertEndChild(xml_system);
TiXmlElement xml_audio("Audio"); XMLElement *xml_audio = doc.NewElement("Audio");
{ {
TiXmlElement xml_microphone("Mic"); XMLElement *xml_microphone = doc.NewElement("Mic");
{ {
xml_microphone.SetAttribute("on", audio.micOn); xml_microphone->SetAttribute("on", audio.micOn);
xml_microphone.SetAttribute("octave", audio.octave); xml_microphone->SetAttribute("octave", audio.octave);
} }
xml_audio.InsertEndChild(xml_microphone); xml_audio->InsertEndChild(xml_microphone);
TiXmlElement xml_volume("Volume"); XMLElement *xml_volume = doc.NewElement("Volume");
{ {
xml_volume.SetDoubleAttribute("sfx", double(audio.sfxvol)); xml_volume->SetAttribute("sfx", double(audio.sfxvol));
xml_volume.SetDoubleAttribute("vox", double(audio.voxvol)); xml_volume->SetAttribute("vox", double(audio.voxvol));
xml_volume.SetDoubleAttribute("mus", double(audio.musvol)); xml_volume->SetAttribute("mus", double(audio.musvol));
xml_volume.SetAttribute("subs", audio.subtitles); xml_volume->SetAttribute("subs", audio.subtitles);
} }
xml_audio.InsertEndChild(xml_volume); xml_audio->InsertEndChild(xml_volume);
TiXmlElement xml_device("Device"); XMLElement *xml_device = doc.NewElement("Device");
{ {
xml_device.SetAttribute("name", audio.deviceName); xml_device->SetAttribute("name", audio.deviceName.c_str());
} }
xml_audio.InsertEndChild(xml_device); xml_audio->InsertEndChild(xml_device);
TiXmlElement xml_prebuf("Prebuffer"); XMLElement *xml_prebuf = doc.NewElement("Prebuffer");
{ {
xml_prebuf.SetAttribute("on", audio.prebuffer); xml_prebuf->SetAttribute("on", audio.prebuffer);
} }
xml_audio.InsertEndChild(xml_prebuf); xml_audio->InsertEndChild(xml_prebuf);
} }
doc.InsertEndChild(xml_audio); doc.InsertEndChild(xml_audio);
TiXmlElement xml_video("Video"); XMLElement *xml_video = doc.NewElement("Video");
{ {
TiXmlElement xml_blur("Blur"); XMLElement *xml_blur = doc.NewElement("Blur");
{ {
xml_blur.SetAttribute("on", video.blur); xml_blur->SetAttribute("on", video.blur);
} }
xml_video.InsertEndChild(xml_blur); xml_video->InsertEndChild(xml_blur);
TiXmlElement xml_noteEffects("NoteEffects"); XMLElement *xml_noteEffects = doc.NewElement("NoteEffects");
{ {
xml_noteEffects.SetAttribute("on", video.noteEffects); xml_noteEffects->SetAttribute("on", video.noteEffects);
} }
xml_video.InsertEndChild(xml_noteEffects); xml_video->InsertEndChild(xml_noteEffects);
TiXmlElement xml_fpsSmoothing("FpsSmoothing"); XMLElement *xml_fpsSmoothing = doc.NewElement("FpsSmoothing");
{ {
xml_fpsSmoothing.SetAttribute("v", video.fpsSmoothing); xml_fpsSmoothing->SetAttribute("v", video.fpsSmoothing);
} }
xml_video.InsertEndChild(xml_fpsSmoothing); xml_video->InsertEndChild(xml_fpsSmoothing);
TiXmlElement xml_parallax("Parallax"); XMLElement *xml_parallax = doc.NewElement("Parallax");
std::ostringstream os; std::ostringstream os;
os << video.parallaxOn0 << " " << video.parallaxOn1 << " " << video.parallaxOn2; os << video.parallaxOn0 << " " << video.parallaxOn1 << " " << video.parallaxOn2;
xml_parallax.SetAttribute("on", os.str()); xml_parallax->SetAttribute("on", os.str().c_str());
xml_video.InsertEndChild(xml_parallax); xml_video->InsertEndChild(xml_parallax);
TiXmlElement xml_numParticles("NumParticles"); XMLElement *xml_numParticles = doc.NewElement("NumParticles");
xml_numParticles.SetAttribute("v", video.numParticles); xml_numParticles->SetAttribute("v", video.numParticles);
xml_video.InsertEndChild(xml_numParticles); xml_video->InsertEndChild(xml_numParticles);
TiXmlElement xml_screenMode("ScreenMode"); XMLElement *xml_screenMode = doc.NewElement("ScreenMode");
{ {
xml_screenMode.SetAttribute("resx", video.resx); xml_screenMode->SetAttribute("resx", video.resx);
xml_screenMode.SetAttribute("resy", video.resy); xml_screenMode->SetAttribute("resy", video.resy);
xml_screenMode.SetAttribute("bits", video.bits); xml_screenMode->SetAttribute("bits", video.bits);
xml_screenMode.SetAttribute("fbuffer", video.fbuffer); xml_screenMode->SetAttribute("fbuffer", video.fbuffer);
xml_screenMode.SetAttribute("full", video.full); xml_screenMode->SetAttribute("full", video.full);
xml_screenMode.SetAttribute("vsync", video.vsync); xml_screenMode->SetAttribute("vsync", video.vsync);
xml_screenMode.SetAttribute("darkfbuffer", video.darkfbuffer); xml_screenMode->SetAttribute("darkfbuffer", video.darkfbuffer);
xml_screenMode.SetAttribute("darkbuffersize", video.darkbuffersize); xml_screenMode->SetAttribute("darkbuffersize", video.darkbuffersize);
xml_screenMode.SetAttribute("displaylists", video.displaylists); xml_screenMode->SetAttribute("displaylists", video.displaylists);
} }
xml_video.InsertEndChild(xml_screenMode); xml_video->InsertEndChild(xml_screenMode);
TiXmlElement xml_saveSlotScreens("SaveSlotScreens"); XMLElement *xml_saveSlotScreens = doc.NewElement("SaveSlotScreens");
{ {
xml_saveSlotScreens.SetAttribute("on", video.saveSlotScreens); xml_saveSlotScreens->SetAttribute("on", video.saveSlotScreens);
} }
xml_video.InsertEndChild(xml_saveSlotScreens); xml_video->InsertEndChild(xml_saveSlotScreens);
TiXmlElement xml_worldMap("WorldMap"); XMLElement *xml_worldMap = doc.NewElement("WorldMap");
{ {
xml_worldMap.SetAttribute("revealMethod", video.worldMapRevealMethod); xml_worldMap->SetAttribute("revealMethod", video.worldMapRevealMethod);
} }
xml_video.InsertEndChild(xml_worldMap); xml_video->InsertEndChild(xml_worldMap);
} }
doc.InsertEndChild(xml_video); doc.InsertEndChild(xml_video);
TiXmlElement xml_control("Control"); XMLElement *xml_control = doc.NewElement("Control");
{ {
TiXmlElement xml_toolTipsOn("ToolTipsOn"); XMLElement *xml_toolTipsOn = doc.NewElement("ToolTipsOn");
{ {
xml_toolTipsOn.SetAttribute("on", control.toolTipsOn); xml_toolTipsOn->SetAttribute("on", control.toolTipsOn);
} }
xml_control.InsertEndChild(xml_toolTipsOn); xml_control->InsertEndChild(xml_toolTipsOn);
TiXmlElement xml_joystickEnabled("JoystickEnabled"); XMLElement *xml_joystickEnabled = doc.NewElement("JoystickEnabled");
{ {
xml_joystickEnabled.SetAttribute("on", control.joystickEnabled); xml_joystickEnabled->SetAttribute("on", control.joystickEnabled);
} }
xml_control.InsertEndChild(xml_joystickEnabled); xml_control->InsertEndChild(xml_joystickEnabled);
TiXmlElement xml_autoAim("AutoAim"); XMLElement *xml_autoAim = doc.NewElement("AutoAim");
{ {
xml_autoAim.SetAttribute("on", control.autoAim); xml_autoAim->SetAttribute("on", control.autoAim);
} }
xml_control.InsertEndChild(xml_autoAim); xml_control->InsertEndChild(xml_autoAim);
TiXmlElement xml_targeting("Targeting"); XMLElement *xml_targeting = doc.NewElement("Targeting");
{ {
xml_targeting.SetAttribute("on", control.targeting); xml_targeting->SetAttribute("on", control.targeting);
} }
xml_control.InsertEndChild(xml_targeting); xml_control->InsertEndChild(xml_targeting);
TiXmlElement xml_joyCursorSpeed("JoyCursorSpeed"); XMLElement *xml_joyCursorSpeed = doc.NewElement("JoyCursorSpeed");
{ {
xml_joyCursorSpeed.SetDoubleAttribute("v", double(control.joyCursorSpeed)); xml_joyCursorSpeed->SetAttribute("v", double(control.joyCursorSpeed));
} }
xml_control.InsertEndChild(xml_joyCursorSpeed); xml_control->InsertEndChild(xml_joyCursorSpeed);
TiXmlElement xml_joyAxes("JoyAxes"); XMLElement *xml_joyAxes = doc.NewElement("JoyAxes");
{ {
xml_joyAxes.SetAttribute("s1ax", control.s1ax); xml_joyAxes->SetAttribute("s1ax", control.s1ax);
xml_joyAxes.SetAttribute("s1ay", control.s1ay); xml_joyAxes->SetAttribute("s1ay", control.s1ay);
xml_joyAxes.SetAttribute("s2ax", control.s2ax); xml_joyAxes->SetAttribute("s2ax", control.s2ax);
xml_joyAxes.SetAttribute("s2ay", control.s2ay); xml_joyAxes->SetAttribute("s2ay", control.s2ay);
xml_joyAxes.SetDoubleAttribute("s1dead", double(control.s1dead)); xml_joyAxes->SetAttribute("s1dead", double(control.s1dead));
xml_joyAxes.SetDoubleAttribute("s2dead", double(control.s2dead)); xml_joyAxes->SetAttribute("s2dead", double(control.s2dead));
} }
xml_control.InsertEndChild(xml_joyAxes); xml_control->InsertEndChild(xml_joyAxes);
TiXmlElement xml_actionSet("ActionSet"); XMLElement *xml_actionSet = doc.NewElement("ActionSet");
{ {
for (int i = 0; i < control.actionSet.inputSet.size(); i++) for (int i = 0; i < control.actionSet.inputSet.size(); i++)
{ {
TiXmlElement xml_action("Action"); XMLElement *xml_action = doc.NewElement("Action");
ActionInput *actionInput = &control.actionSet.inputSet[i]; ActionInput *actionInput = &control.actionSet.inputSet[i];
xml_action.SetAttribute("name", actionInput->name); xml_action->SetAttribute("name", actionInput->name.c_str());
xml_action.SetAttribute("input", actionInput->toString()); xml_action->SetAttribute("input", actionInput->toString().c_str());
xml_actionSet.InsertEndChild(xml_action); xml_actionSet->InsertEndChild(xml_action);
} }
} }
xml_control.InsertEndChild(xml_actionSet); xml_control->InsertEndChild(xml_actionSet);
} }
doc.InsertEndChild(xml_control); doc.InsertEndChild(xml_control);
TiXmlElement xml_demo("Demo"); XMLElement *xml_demo = doc.NewElement("Demo");
{ {
TiXmlElement xml_warpKeys("WarpKeys"); XMLElement *xml_warpKeys = doc.NewElement("WarpKeys");
{ {
xml_warpKeys.SetAttribute("on", demo.warpKeys); xml_warpKeys->SetAttribute("on", demo.warpKeys);
} }
xml_demo.InsertEndChild(xml_warpKeys); xml_demo->InsertEndChild(xml_warpKeys);
TiXmlElement xml_intro("Intro2"); XMLElement *xml_intro = doc.NewElement("Intro2");
{ {
xml_intro.SetAttribute("on", demo.intro); xml_intro->SetAttribute("on", demo.intro);
} }
xml_demo.InsertEndChild(xml_intro); xml_demo->InsertEndChild(xml_intro);
TiXmlElement xml_shortLogos("ShortLogos"); XMLElement *xml_shortLogos = doc.NewElement("ShortLogos");
{ {
xml_shortLogos.SetAttribute("on", demo.shortLogos); xml_shortLogos->SetAttribute("on", demo.shortLogos);
} }
xml_demo.InsertEndChild(xml_shortLogos); xml_demo->InsertEndChild(xml_shortLogos);
} }
doc.InsertEndChild(xml_demo); doc.InsertEndChild(xml_demo);
TiXmlElement xml_data("Data"); XMLElement *xml_data = doc.NewElement("Data");
{ {
xml_data.SetAttribute("savePage", data.savePage); xml_data->SetAttribute("savePage", data.savePage);
xml_data.SetAttribute("saveSlot", data.saveSlot); xml_data->SetAttribute("saveSlot", data.saveSlot);
std::ostringstream ss; std::ostringstream ss;
for (std::set<std::string>::iterator it = dsq->activePatches.begin(); it != dsq->activePatches.end(); ++it) for (std::set<std::string>::iterator it = dsq->activePatches.begin(); it != dsq->activePatches.end(); ++it)
ss << *it << " "; ss << *it << " ";
xml_data.SetAttribute("activePatches", ss.str()); xml_data->SetAttribute("activePatches", ss.str().c_str());
} }
doc.InsertEndChild(xml_data); doc.InsertEndChild(xml_data);
TiXmlElement xml_net("Network"); XMLElement *xml_net = doc.NewElement("Network");
{ {
xml_net.SetAttribute("masterServer", network.masterServer); xml_net->SetAttribute("masterServer", network.masterServer.c_str());
} }
doc.InsertEndChild(xml_net); doc.InsertEndChild(xml_net);
} }
#if defined(BBGE_BUILD_UNIX) #if defined(BBGE_BUILD_UNIX)
doc.SaveFile(dsq->getPreferencesFolder() + "/" + userSettingsFilename); doc.SaveFile((dsq->getPreferencesFolder() + "/" + userSettingsFilename).c_str());
#elif defined(BBGE_BUILD_WINDOWS) #elif defined(BBGE_BUILD_WINDOWS)
doc.SaveFile(userSettingsFilename); doc.SaveFile(userSettingsFilename.c_str());
#endif #endif
//clearInputCodeMap(); //clearInputCodeMap();
} }
void readInt(TiXmlElement *xml, const std::string &elem, std::string att, int *toChange) static void readInt(XMLElement *xml, const char *elem, const char *att, int *toChange)
{ {
if (xml) if (xml)
{ {
TiXmlElement *xml2 = xml->FirstChildElement(elem); XMLElement *xml2 = xml->FirstChildElement(elem);
if (xml2) if (xml2) xml2->QueryIntAttribute(att, toChange);
{
const std::string *s = xml2->Attribute(att);
if (s) {
const char *c = s->c_str();
if (c)
{
*toChange = atoi(c);
}
}
}
}
}
void readIntAtt(TiXmlElement *xml, std::string att, int *toChange)
{
if (xml)
{
const std::string *s = xml->Attribute(att);
if (s) {
const char *c = s->c_str();
if (c)
{
*toChange = atoi(c);
}
}
} }
} }
@ -319,23 +295,23 @@ void UserSettings::loadDefaults(bool doApply)
void UserSettings::load(bool doApply, const std::string &overrideFile) void UserSettings::load(bool doApply, const std::string &overrideFile)
{ {
TiXmlDocument doc; XMLDocument doc;
#if defined(BBGE_BUILD_UNIX) #if defined(BBGE_BUILD_UNIX)
doc.LoadFile(dsq->getPreferencesFolder() + "/" + userSettingsFilename); doc.LoadFile((dsq->getPreferencesFolder() + "/" + userSettingsFilename).c_str());
#elif defined(BBGE_BUILD_WINDOWS) #elif defined(BBGE_BUILD_WINDOWS)
if (!overrideFile.empty()) if (!overrideFile.empty())
doc.LoadFile(overrideFile); doc.LoadFile(overrideFile.c_str());
else else
doc.LoadFile(userSettingsFilename); doc.LoadFile(userSettingsFilename.c_str());
#endif #endif
version.settingsVersion = 0; version.settingsVersion = 0;
TiXmlElement *xml_version = doc.FirstChildElement("Version"); XMLElement *xml_version = doc.FirstChildElement("Version");
if (xml_version) if (xml_version)
{ {
xml_version->Attribute("settingsVersion", &version.settingsVersion); version.settingsVersion = xml_version->IntAttribute("settingsVersion");
} }
control.actionSet.clearActions(); control.actionSet.clearActions();
@ -362,61 +338,60 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
control.actionSet.addActionInput("Look"); control.actionSet.addActionInput("Look");
control.actionSet.addActionInput("ToggleHelp"); control.actionSet.addActionInput("ToggleHelp");
TiXmlElement *xml_system = doc.FirstChildElement("System"); XMLElement *xml_system = doc.FirstChildElement("System");
if (xml_system) if (xml_system)
{ {
TiXmlElement *xml_debugLog = xml_system->FirstChildElement("DebugLog"); XMLElement *xml_debugLog = xml_system->FirstChildElement("DebugLog");
if (xml_debugLog) if (xml_debugLog)
{ {
xml_debugLog->Attribute("on", &system.debugLogOn); system.debugLogOn = xml_debugLog->IntAttribute("on");
} }
TiXmlElement *xml_locale = xml_system->FirstChildElement("Locale"); XMLElement *xml_locale = xml_system->FirstChildElement("Locale");
if (xml_locale) if (xml_locale)
{ {
system.locale = xml_locale->Attribute("name"); system.locale = xml_locale->Attribute("name");
} }
TiXmlElement *xml_devmode = xml_system->FirstChildElement("DeveloperMode"); XMLElement *xml_devmode = xml_system->FirstChildElement("DeveloperMode");
if (xml_devmode) if (xml_devmode)
{ {
xml_devmode->Attribute("on", &system.devModeOn); system.devModeOn = xml_devmode->IntAttribute("on");
} }
} }
TiXmlElement *xml_audio = doc.FirstChildElement("Audio"); XMLElement *xml_audio = doc.FirstChildElement("Audio");
if (xml_audio) if (xml_audio)
{ {
TiXmlElement *xml_microphone = xml_audio->FirstChildElement("Mic"); XMLElement *xml_microphone = xml_audio->FirstChildElement("Mic");
if (xml_microphone) if (xml_microphone)
{ {
xml_microphone->Attribute("on", &audio.micOn); audio.micOn = xml_microphone->IntAttribute("on");
xml_microphone->Attribute("octave", &audio.octave); audio.octave = xml_microphone->IntAttribute("octave");
} }
TiXmlElement *xml_volume = xml_audio->FirstChildElement("Volume"); XMLElement *xml_volume = xml_audio->FirstChildElement("Volume");
if (xml_volume) if (xml_volume)
{ {
double d; audio.sfxvol = xml_volume->DoubleAttribute("sfx");
xml_volume->Attribute("sfx", &d), audio.sfxvol = d; audio.voxvol = xml_volume->DoubleAttribute("vox");
xml_volume->Attribute("vox", &d), audio.voxvol = d; audio.musvol = xml_volume->DoubleAttribute("mus");
xml_volume->Attribute("mus", &d), audio.musvol = d; audio.subtitles = xml_volume->IntAttribute("subs");
xml_volume->Attribute("subs", &audio.subtitles);
} }
TiXmlElement *xml_device = xml_audio->FirstChildElement("Device"); XMLElement *xml_device = xml_audio->FirstChildElement("Device");
if (xml_device) if (xml_device)
{ {
audio.deviceName = xml_device->Attribute("name"); audio.deviceName = xml_device->Attribute("name");
} }
TiXmlElement *xml_prebuf = xml_audio->FirstChildElement("Prebuffer"); XMLElement *xml_prebuf = xml_audio->FirstChildElement("Prebuffer");
if (xml_prebuf) if (xml_prebuf)
{ {
xml_prebuf->Attribute("on", &audio.prebuffer); audio.prebuffer = xml_prebuf->IntAttribute("on");
} }
} }
TiXmlElement *xml_video = doc.FirstChildElement("Video"); XMLElement *xml_video = doc.FirstChildElement("Video");
if (xml_video) if (xml_video)
{ {
readInt(xml_video, "Blur", "on", &video.blur); readInt(xml_video, "Blur", "on", &video.blur);
@ -428,7 +403,7 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
/* /*
readInt(xml_video, "Parallax", "on", &video.parallaxOn); readInt(xml_video, "Parallax", "on", &video.parallaxOn);
*/ */
TiXmlElement *xml_parallax = xml_video->FirstChildElement("Parallax"); XMLElement *xml_parallax = xml_video->FirstChildElement("Parallax");
if (xml_parallax) if (xml_parallax)
{ {
if (xml_parallax->Attribute("on")) if (xml_parallax->Attribute("on"))
@ -440,18 +415,18 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
readInt(xml_video, "NumParticles", "v", &video.numParticles); readInt(xml_video, "NumParticles", "v", &video.numParticles);
TiXmlElement *xml_screenMode = xml_video->FirstChildElement("ScreenMode"); XMLElement *xml_screenMode = xml_video->FirstChildElement("ScreenMode");
if (xml_screenMode) if (xml_screenMode)
{ {
readIntAtt(xml_screenMode, "resx", &video.resx); xml_screenMode->QueryIntAttribute("resx", &video.resx);
readIntAtt(xml_screenMode, "resy", &video.resy); xml_screenMode->QueryIntAttribute("resy", &video.resy);
readIntAtt(xml_screenMode, "bits", &video.bits); xml_screenMode->QueryIntAttribute("bits", &video.bits);
readIntAtt(xml_screenMode, "fbuffer", &video.fbuffer); xml_screenMode->QueryIntAttribute("fbuffer", &video.fbuffer);
readIntAtt(xml_screenMode, "full", &video.full); xml_screenMode->QueryIntAttribute("full", &video.full);
readIntAtt(xml_screenMode, "vsync", &video.vsync); xml_screenMode->QueryIntAttribute("vsync", &video.vsync);
readIntAtt(xml_screenMode, "darkfbuffer", &video.darkfbuffer); xml_screenMode->QueryIntAttribute("darkfbuffer", &video.darkfbuffer);
readIntAtt(xml_screenMode, "darkbuffersize", &video.darkbuffersize); xml_screenMode->QueryIntAttribute("darkbuffersize", &video.darkbuffersize);
readIntAtt(xml_screenMode, "displaylists", &video.displaylists); xml_screenMode->QueryIntAttribute("displaylists", &video.displaylists);
} }
readInt(xml_video, "SaveSlotScreens", "on", &video.saveSlotScreens); readInt(xml_video, "SaveSlotScreens", "on", &video.saveSlotScreens);
@ -459,7 +434,7 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
readInt(xml_video, "WorldMap", "revealMethod", &video.worldMapRevealMethod); readInt(xml_video, "WorldMap", "revealMethod", &video.worldMapRevealMethod);
} }
TiXmlElement *xml_control = doc.FirstChildElement("Control"); XMLElement *xml_control = doc.FirstChildElement("Control");
if (xml_control) if (xml_control)
{ {
readInt(xml_control, "JoystickEnabled", "on", &control.joystickEnabled); readInt(xml_control, "JoystickEnabled", "on", &control.joystickEnabled);
@ -468,30 +443,25 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
readInt(xml_control, "Targeting", "on", &control.targeting); readInt(xml_control, "Targeting", "on", &control.targeting);
TiXmlElement *xml_joyCursorSpeed = xml_control->FirstChildElement("JoyCursorSpeed"); XMLElement *xml_joyCursorSpeed = xml_control->FirstChildElement("JoyCursorSpeed");
if (xml_joyCursorSpeed) if (xml_joyCursorSpeed)
{ xml_joyCursorSpeed->QueryFloatAttribute("v", &control.joyCursorSpeed);
double d;
if (xml_joyCursorSpeed->Attribute("v"))
xml_joyCursorSpeed->Attribute("v", &d), control.joyCursorSpeed = d;
}
TiXmlElement *xml_joyAxes = xml_control->FirstChildElement("JoyAxes"); XMLElement *xml_joyAxes = xml_control->FirstChildElement("JoyAxes");
if (xml_joyAxes) if (xml_joyAxes)
{ {
xml_joyAxes->Attribute("s1ax", &control.s1ax); control.s1ax = xml_joyAxes->IntAttribute("s1ax");
xml_joyAxes->Attribute("s1ay", &control.s1ay); control.s1ay = xml_joyAxes->IntAttribute("s1ay");
xml_joyAxes->Attribute("s2ax", &control.s2ax); control.s2ax = xml_joyAxes->IntAttribute("s2ax");
xml_joyAxes->Attribute("s2ay", &control.s2ay); control.s2ay = xml_joyAxes->IntAttribute("s2ay");
double d; control.s1dead = xml_joyAxes->DoubleAttribute("s1dead");
xml_joyAxes->Attribute("s1dead", &d), control.s1dead = d; control.s2dead = xml_joyAxes->DoubleAttribute("s2dead");
xml_joyAxes->Attribute("s2dead", &d), control.s2dead = d;
} }
TiXmlElement *xml_actionSet = xml_control->FirstChildElement("ActionSet"); XMLElement *xml_actionSet = xml_control->FirstChildElement("ActionSet");
if (xml_actionSet) if (xml_actionSet)
{ {
TiXmlElement *xml_action = 0; XMLElement *xml_action = 0;
xml_action = xml_actionSet->FirstChildElement(); xml_action = xml_actionSet->FirstChildElement();
while (xml_action) while (xml_action)
{ {
@ -510,7 +480,7 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
readInt(xml_control, "ToolTipsOn", "on", &control.toolTipsOn); readInt(xml_control, "ToolTipsOn", "on", &control.toolTipsOn);
} }
TiXmlElement *xml_demo = doc.FirstChildElement("Demo"); XMLElement *xml_demo = doc.FirstChildElement("Demo");
if (xml_demo) if (xml_demo)
{ {
readInt(xml_demo, "WarpKeys", "on", &demo.warpKeys); readInt(xml_demo, "WarpKeys", "on", &demo.warpKeys);
@ -518,11 +488,11 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
readInt(xml_demo, "ShortLogos", "on", &demo.shortLogos); readInt(xml_demo, "ShortLogos", "on", &demo.shortLogos);
} }
TiXmlElement *xml_data = doc.FirstChildElement("Data"); XMLElement *xml_data = doc.FirstChildElement("Data");
if (xml_data) if (xml_data)
{ {
readIntAtt(xml_data, "savePage", &data.savePage); xml_data->QueryIntAttribute("savePage", &data.savePage);
readIntAtt(xml_data, "saveSlot", &data.saveSlot); xml_data->QueryIntAttribute("saveSlot", &data.saveSlot);
if(const char *patchlist = xml_data->Attribute("activePatches")) if(const char *patchlist = xml_data->Attribute("activePatches"))
{ {
@ -537,7 +507,7 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
} }
} }
TiXmlElement *xml_net = doc.FirstChildElement("Network"); XMLElement *xml_net = doc.FirstChildElement("Network");
if (xml_net) if (xml_net)
{ {
const char *serv = xml_net->Attribute("masterServer"); const char *serv = xml_net->Attribute("masterServer");

View file

@ -48,7 +48,7 @@ void Cutscene::load(const std::string &f)
doc.LoadFile(f.c_str()); doc.LoadFile(f.c_str());
TiXmlElement *e = doc.FirstChildElement("time"); XMLElement *e = doc.FirstChildElement("time");
while (e) while (e)
{ {
CutsceneMarker m; CutsceneMarker m;
@ -94,7 +94,7 @@ void Cutscene::playMarker(CutsceneMarker *m)
{ {
if (m) if (m)
{ {
TiXmlElement *r=0; XMLElement *r=0;
if (r = m->e->FirstChildElement("quad")) if (r = m->e->FirstChildElement("quad"))
{ {
id = r->Attribute("id"); id = r->Attribute("id");

View file

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct CutsceneMarker struct CutsceneMarker
{ {
float t; float t;
TiXmlElement *e; XMLElement *e;
}; };
class Cutscene class Cutscene
@ -40,7 +40,7 @@ public:
void update(float dt); void update(float dt);
TiXmlDocument file; XMLDocument file;
std::vector <CutsceneMarker> markers; std::vector <CutsceneMarker> markers;

View file

@ -19,29 +19,37 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "SkeletalSprite.h" #include "SkeletalSprite.h"
#include "../ExternalLibs/tinyxml.h"
#include "Core.h" #include "Core.h"
#include "Particles.h" #include "Particles.h"
#include "MathFunctions.h" #include "MathFunctions.h"
#include "SimpleIStringStream.h" #include "SimpleIStringStream.h"
#include "tinyxml2.h"
using namespace tinyxml2;
std::string SkeletalSprite::animationPath = "data/animations/"; std::string SkeletalSprite::animationPath = "data/animations/";
std::string SkeletalSprite::skinPath = "skins/"; std::string SkeletalSprite::skinPath = "skins/";
std::string SkeletalSprite::secondaryAnimationPath = ""; std::string SkeletalSprite::secondaryAnimationPath = "";
static std::map<std::string, TiXmlDocument> skelCache; static std::map<std::string, XMLDocument*> skelCache;
static TiXmlDocument& _retrieveSkeletalXML(const std::string& name) static XMLDocument *_retrieveSkeletalXML(const std::string& name)
{ {
TiXmlDocument& doc = skelCache[name]; XMLDocument *doc = skelCache[name];
if (!doc.RootElement()) if (!doc) {
doc.LoadFile(name); doc = new XMLDocument();
doc->LoadFile(name.c_str());
skelCache[name] = doc;
}
return doc; return doc;
} }
void SkeletalSprite::clearCache() void SkeletalSprite::clearCache()
{ {
for (std::map<std::string, XMLDocument*>::iterator i = skelCache.begin(); i != skelCache.end(); i++)
delete i->second;
skelCache.clear(); skelCache.clear();
} }
@ -862,13 +870,13 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
} }
int i = 0; int i = 0;
TiXmlDocument& xml = _retrieveSkeletalXML(file); XMLDocument *xml = _retrieveSkeletalXML(file);
xml.Clear(); xml->Clear();
TiXmlElement animationLayers("AnimationLayers"); XMLElement *animationLayers = xml->NewElement("AnimationLayers");
for (i = 0; i < animLayers.size(); i++) for (i = 0; i < animLayers.size(); i++)
{ {
TiXmlElement animationLayer("AnimationLayer"); XMLElement *animationLayer = xml->NewElement("AnimationLayer");
if (animLayers[i].ignoreBones.size() > 0) if (animLayers[i].ignoreBones.size() > 0)
{ {
std::ostringstream os; std::ostringstream os;
@ -876,7 +884,7 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
{ {
os << animLayers[i].ignoreBones[j] << " "; os << animLayers[i].ignoreBones[j] << " ";
} }
animationLayer.SetAttribute("ignore", os.str()); animationLayer->SetAttribute("ignore", os.str().c_str());
} }
if (animLayers[i].includeBones.size() > 0) if (animLayers[i].includeBones.size() > 0)
{ {
@ -885,33 +893,33 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
{ {
os << animLayers[i].includeBones[j] << " "; os << animLayers[i].includeBones[j] << " ";
} }
animationLayer.SetAttribute("include", os.str()); animationLayer->SetAttribute("include", os.str().c_str());
} }
if (!animLayers[i].name.empty()) if (!animLayers[i].name.empty())
{ {
animationLayer.SetAttribute("name", animLayers[i].name); animationLayer->SetAttribute("name", animLayers[i].name.c_str());
} }
animationLayers.InsertEndChild(animationLayer); animationLayers->InsertEndChild(animationLayer);
} }
xml.InsertEndChild(animationLayers); xml->InsertEndChild(animationLayers);
TiXmlElement bones("Bones"); XMLElement *bones = xml->NewElement("Bones");
for (i = 0; i < this->bones.size(); i++) for (i = 0; i < this->bones.size(); i++)
{ {
TiXmlElement bone("Bone"); XMLElement *bone = xml->NewElement("Bone");
bone.SetAttribute("idx", this->bones[i]->boneIdx); bone->SetAttribute("idx", this->bones[i]->boneIdx);
bone.SetAttribute("gfx", this->bones[i]->gfx); bone->SetAttribute("gfx", this->bones[i]->gfx.c_str());
bone.SetAttribute("pidx", this->bones[i]->pidx); bone->SetAttribute("pidx", this->bones[i]->pidx);
bone.SetAttribute("name", this->bones[i]->name); bone->SetAttribute("name", this->bones[i]->name.c_str());
bone.SetAttribute("fh", this->bones[i]->isfh()); bone->SetAttribute("fh", this->bones[i]->isfh());
bone.SetAttribute("fv", this->bones[i]->isfv()); bone->SetAttribute("fv", this->bones[i]->isfv());
bone.SetAttribute("gc", this->bones[i]->generateCollisionMask); bone->SetAttribute("gc", this->bones[i]->generateCollisionMask);
bone.SetAttribute("cr", this->bones[i]->collideRadius); bone->SetAttribute("cr", this->bones[i]->collideRadius);
if (!this->bones[i]->renderQuad) if (!this->bones[i]->renderQuad)
{ {
bone.SetAttribute("rq", this->bones[i]->fileRenderQuad); bone->SetAttribute("rq", this->bones[i]->fileRenderQuad);
} }
if (!this->bones[i]->collisionRects.empty()) if (!this->bones[i]->collisionRects.empty())
{ {
@ -924,49 +932,49 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
r->getCWH(&x, &y, &w, &h); r->getCWH(&x, &y, &w, &h);
os << x << " " << y << " " << w << " " << h << " "; os << x << " " << y << " " << w << " " << h << " ";
} }
bone.SetAttribute("crects", os.str()); bone->SetAttribute("crects", os.str().c_str());
} }
std::ostringstream os; std::ostringstream os;
os << this->bones[i]->collidePosition.x << " " << this->bones[i]->collidePosition.y; os << this->bones[i]->collidePosition.x << " " << this->bones[i]->collidePosition.y;
bone.SetAttribute("cp", os.str()); bone->SetAttribute("cp", os.str().c_str());
if (this->bones[i]->rbp) if (this->bones[i]->rbp)
bone.SetAttribute("rbp", this->bones[i]->rbp); bone->SetAttribute("rbp", this->bones[i]->rbp);
if (this->bones[i]->getRenderPass()) if (this->bones[i]->getRenderPass())
bone.SetAttribute("pass", this->bones[i]->getRenderPass()); bone->SetAttribute("pass", this->bones[i]->getRenderPass());
if (this->bones[i]->offset.x) if (this->bones[i]->offset.x)
bone.SetAttribute("offx", this->bones[i]->offset.x); bone->SetAttribute("offx", this->bones[i]->offset.x);
if (this->bones[i]->offset.y) if (this->bones[i]->offset.y)
bone.SetAttribute("offy", this->bones[i]->offset.y); bone->SetAttribute("offy", this->bones[i]->offset.y);
if (!this->bones[i]->prt.empty()) if (!this->bones[i]->prt.empty())
bone.SetAttribute("prt", this->bones[i]->prt); bone->SetAttribute("prt", this->bones[i]->prt.c_str());
if (!this->bones[i]->changeStrip.empty()) if (!this->bones[i]->changeStrip.empty())
{ {
std::ostringstream os; std::ostringstream os;
os << this->bones[i]->stripVert << " " << this->bones[i]->changeStrip.size(); os << this->bones[i]->stripVert << " " << this->bones[i]->changeStrip.size();
bone.SetAttribute("strip", os.str()); bone->SetAttribute("strip", os.str().c_str());
} }
if (!this->bones[i]->internalOffset.isZero()) if (!this->bones[i]->internalOffset.isZero())
{ {
std::ostringstream os; std::ostringstream os;
os << this->bones[i]->internalOffset.x << " " << this->bones[i]->internalOffset.y; os << this->bones[i]->internalOffset.x << " " << this->bones[i]->internalOffset.y;
bone.SetAttribute("io", os.str()); bone->SetAttribute("io", os.str().c_str());
} }
if (this->bones[i]->isRepeatingTextureToFill()) if (this->bones[i]->isRepeatingTextureToFill())
{ {
bone.SetAttribute("rt", 1); bone->SetAttribute("rt", 1);
} }
if (this->bones[i]->originalScale.x != 1 || this->bones[i]->originalScale.y != 1) if (this->bones[i]->originalScale.x != 1 || this->bones[i]->originalScale.y != 1)
{ {
std::ostringstream os; std::ostringstream os;
os << this->bones[i]->originalScale.x << " " << this->bones[i]->originalScale.y; os << this->bones[i]->originalScale.x << " " << this->bones[i]->originalScale.y;
bone.SetAttribute("sz", os.str()); bone->SetAttribute("sz", os.str().c_str());
} }
/* /*
if (this->bones[i]->color.x != 1 || this->bones[i]->color.y != 1 || this->bones[i]->color.z != 1) if (this->bones[i]->color.x != 1 || this->bones[i]->color.y != 1 || this->bones[i]->color.z != 1)
{ {
std::ostringstream os; std::ostringstream os;
os << this->bones[i]->color.x << " " << this->bones[i]->color.y << " " << this->bones[i]->color.z; os << this->bones[i]->color.x << " " << this->bones[i]->color.y << " " << this->bones[i]->color.z;
bone.SetAttribute("color", os.str()); bone->SetAttribute("color", os.str().c_str());
} }
*/ */
@ -977,37 +985,37 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
Particle *p = dynamic_cast<Particle*>(*j); Particle *p = dynamic_cast<Particle*>(*j);
if (q && !b && !p) if (q && !b && !p)
{ {
TiXmlElement frame("Frame"); XMLElement *frame = xml->NewElement("Frame");
frame.SetAttribute("gfx", q->texture->name); frame->SetAttribute("gfx", q->texture->name.c_str());
if (q->getRenderPass() != 0) if (q->getRenderPass() != 0)
{ {
frame.SetAttribute("pass", q->getRenderPass()); frame->SetAttribute("pass", q->getRenderPass());
} }
bone.InsertEndChild(frame); bone->InsertEndChild(frame);
} }
} }
bones.InsertEndChild(bone); bones->InsertEndChild(bone);
} }
xml.InsertEndChild(bones); xml->InsertEndChild(bones);
TiXmlElement animations("Animations"); XMLElement *animations = xml->NewElement("Animations");
for (i = 0; i < this->animations.size(); i++) for (i = 0; i < this->animations.size(); i++)
{ {
Animation *a = &this->animations[i]; Animation *a = &this->animations[i];
TiXmlElement animation("Animation"); XMLElement *animation = xml->NewElement("Animation");
animation.SetAttribute("name", a->name); animation->SetAttribute("name", a->name.c_str());
for (int j = 0; j < a->keyframes.size(); j++) for (int j = 0; j < a->keyframes.size(); j++)
{ {
TiXmlElement key("Key"); XMLElement *key = xml->NewElement("Key");
if (!a->keyframes[j].sound.empty()) if (!a->keyframes[j].sound.empty())
key.SetAttribute("sound", a->keyframes[j].sound); key->SetAttribute("sound", a->keyframes[j].sound.c_str());
if (!a->keyframes[j].cmd.empty()) if (!a->keyframes[j].cmd.empty())
{ {
key.SetAttribute("cmd", a->keyframes[j].cmd); key->SetAttribute("cmd", a->keyframes[j].cmd.c_str());
} }
if (a->keyframes[j].lerpType != 0) if (a->keyframes[j].lerpType != 0)
{ {
key.SetAttribute("lerp", a->keyframes[j].lerpType); key->SetAttribute("lerp", a->keyframes[j].lerpType);
} }
std::ostringstream os; std::ostringstream os;
os << a->keyframes[j].t << " "; os << a->keyframes[j].t << " ";
@ -1028,16 +1036,16 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
} }
std::string szoss = szos.str(); std::string szoss = szos.str();
if (!szoss.empty()) if (!szoss.empty())
key.SetAttribute("sz", szoss.c_str()); key->SetAttribute("sz", szoss.c_str());
key.SetAttribute("e", os.str()); key->SetAttribute("e", os.str().c_str());
animation.InsertEndChild(key); animation->InsertEndChild(key);
} }
animations.InsertEndChild(animation); animations->InsertEndChild(animation);
} }
xml.InsertEndChild(animations); xml->InsertEndChild(animations);
return xml.SaveFile(file); return xml->SaveFile(file.c_str());
} }
int SkeletalSprite::getBoneIdx(Bone *b) int SkeletalSprite::getBoneIdx(Bone *b)
@ -1181,12 +1189,12 @@ void SkeletalSprite::loadSkin(const std::string &fn)
errorLog("Could not load skin[" + file + "]"); errorLog("Could not load skin[" + file + "]");
return; return;
} }
TiXmlDocument& d = _retrieveSkeletalXML(file); XMLDocument *d = _retrieveSkeletalXML(file);
TiXmlElement *bonesXml = d.FirstChildElement("Bones"); XMLElement *bonesXml = d->FirstChildElement("Bones");
if (bonesXml) if (bonesXml)
{ {
TiXmlElement *boneXml = bonesXml->FirstChildElement("Bone"); XMLElement *boneXml = bonesXml->FirstChildElement("Bone");
while (boneXml) while (boneXml)
{ {
int idx = atoi(boneXml->Attribute("idx")); int idx = atoi(boneXml->Attribute("idx"));
@ -1316,10 +1324,10 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
loaded = true; loaded = true;
TiXmlDocument& xml = _retrieveSkeletalXML(file); XMLDocument *xml = _retrieveSkeletalXML(file);
xml.LoadFile(file.c_str()); xml->LoadFile(file.c_str());
TiXmlElement *bones = xml.FirstChildElement("Bones"); XMLElement *bones = xml->FirstChildElement("Bones");
if (bones) if (bones)
{ {
if (bones->Attribute("scale")) if (bones->Attribute("scale"))
@ -1328,7 +1336,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
is >> scale.x >> scale.y; is >> scale.x >> scale.y;
} }
TiXmlElement *bone = bones->FirstChildElement("Bone"); XMLElement *bone = bones->FirstChildElement("Bone");
while(bone) while(bone)
{ {
int idx = atoi(bone->Attribute("idx")); int idx = atoi(bone->Attribute("idx"));
@ -1400,7 +1408,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
//e->start(); //e->start();
} }
} }
TiXmlElement *fr=0; XMLElement *fr=0;
fr = bone->FirstChildElement("Frame"); fr = bone->FirstChildElement("Frame");
int frc=0; int frc=0;
while(fr) while(fr)
@ -1528,10 +1536,10 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
} }
animLayers.clear(); animLayers.clear();
TiXmlElement *animationLayers = xml.FirstChildElement("AnimationLayers"); XMLElement *animationLayers = xml->FirstChildElement("AnimationLayers");
if (animationLayers) if (animationLayers)
{ {
TiXmlElement *animationLayer = animationLayers->FirstChildElement("AnimationLayer"); XMLElement *animationLayer = animationLayers->FirstChildElement("AnimationLayer");
while (animationLayer) while (animationLayer)
{ {
AnimationLayer newAnimationLayer; AnimationLayer newAnimationLayer;
@ -1564,17 +1572,17 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
} }
animations.clear(); animations.clear();
TiXmlElement *animations = xml.FirstChildElement("Animations"); XMLElement *animations = xml->FirstChildElement("Animations");
if (animations) if (animations)
{ {
TiXmlElement *animation = animations->FirstChildElement("Animation"); XMLElement *animation = animations->FirstChildElement("Animation");
while(animation) while(animation)
{ {
Animation newAnimation; Animation newAnimation;
newAnimation.name = animation->Attribute("name"); newAnimation.name = animation->Attribute("name");
stringToLower(newAnimation.name); stringToLower(newAnimation.name);
TiXmlElement *key = animation->FirstChildElement("Key"); XMLElement *key = animation->FirstChildElement("Key");
while (key) while (key)
{ {
SkeletalKeyframe newSkeletalKeyframe; SkeletalKeyframe newSkeletalKeyframe;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,52 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxml.h"
// The goal of the seperate error file is to make the first
// step towards localization. tinyxml (currently) only supports
// english error messages, but the could now be translated.
//
// It also cleans up the code a bit.
//
const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
{
"No error",
"Error",
"Failed to open file",
"Error parsing Element.",
"Failed to read Element name",
"Error reading Element value.",
"Error reading Attributes.",
"Error: empty tag.",
"Error reading end tag.",
"Error parsing Unknown.",
"Error parsing Comment.",
"Error parsing Declaration.",
"Error document empty.",
"Error null (0) or unexpected EOF found in input stream.",
"Error parsing CDATA.",
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
};

File diff suppressed because it is too large Load diff

View file

@ -222,6 +222,16 @@ if (NOT OPENAL_FOUND)
endif(WIN32) endif(WIN32)
endif (NOT OPENAL_FOUND) endif (NOT OPENAL_FOUND)
### TinyXML2
OPTION(AQUARIA_INTERNAL_TINYXML2 "Always use included TinyXML2 library" FALSE)
if(NOT AQUARIA_INTERNAL_TINYXML2)
find_package(TinyXML2)
endif(NOT AQUARIA_INTERNAL_TINYXML2)
if (NOT TINYXML2_FOUND)
message(SEND_ERROR "TinyXML2 not found and it hasn't been bundled yet.")
endif (NOT TINYXML2_FOUND)
################ End of external libraries ################ End of external libraries
INCLUDE_DIRECTORIES(${BBGEDIR}) INCLUDE_DIRECTORIES(${BBGEDIR})
@ -235,6 +245,7 @@ INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${TINYXML2_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${EXTLIBDIR}) INCLUDE_DIRECTORIES(${EXTLIBDIR})
@ -486,9 +497,6 @@ SET(BBGE_SRCS
${EXTLIBDIR}/DeflateCompressor.cpp ${EXTLIBDIR}/DeflateCompressor.cpp
${EXTLIBDIR}/glfont2/glfont2.cpp ${EXTLIBDIR}/glfont2/glfont2.cpp
${EXTLIBDIR}/glpng/glpng.c ${EXTLIBDIR}/glpng/glpng.c
${EXTLIBDIR}/tinyxml.cpp
${EXTLIBDIR}/tinyxmlerror.cpp
${EXTLIBDIR}/tinyxmlparser.cpp
${EXTLIBDIR}/minihttp.cpp ${EXTLIBDIR}/minihttp.cpp
${EXTLIBDIR}/JPS.h ${EXTLIBDIR}/JPS.h
) )
@ -737,6 +745,12 @@ ELSE(OGGVORBIS_FOUND)
SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${OGGVORBIS_SRCS}) SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${OGGVORBIS_SRCS})
ENDIF(OGGVORBIS_FOUND) ENDIF(OGGVORBIS_FOUND)
IF(TINYXML2_FOUND)
SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${TINYXML2_LIBRARIES})
ELSE(TINYXML2_FOUND)
# SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${TINYXML2_SRCS})
ENDIF(TINYXML2_FOUND)
ADD_EXECUTABLE(aquaria ${EXETYPE} ADD_EXECUTABLE(aquaria ${EXETYPE}
${AQUARIA_SRCS} ${AQUARIA_SRCS}
${BBGE_SRCS} ${BBGE_SRCS}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,52 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxml.h"
// The goal of the seperate error file is to make the first
// step towards localization. tinyxml (currently) only supports
// english error messages, but the could now be translated.
//
// It also cleans up the code a bit.
//
const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
{
"No error",
"Error",
"Failed to open file",
"Error parsing Element.",
"Failed to read Element name",
"Error reading Element value.",
"Error reading Attributes.",
"Error: empty tag.",
"Error reading end tag.",
"Error parsing Unknown.",
"Error parsing Comment.",
"Error parsing Declaration.",
"Error document empty.",
"Error null (0) or unexpected EOF found in input stream.",
"Error parsing CDATA.",
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
};

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,24 @@
# - Try to find TinyXML2
# Once done this will define
# TINYXML2_FOUND - System has TinyXML2
# TINYXML2_INCLUDE_DIRS - The TinyXML2 include directories
# TINYXML2_LIBRARIES - The libraries needed to use TinyXML2
# TINYXML2_DEFINITIONS - Compiler switches required for using TinyXML2
find_package(PkgConfig)
pkg_check_modules(PC_TINYXML2 QUIET tinyxml2)
set(TINYXML2_DEFINITIONS ${PC_TINYXML2_CFLAGS_OTHER})
find_path(TINYXML2_INCLUDE_DIR tinyxml2.h
HINTS ${PC_TINYXML2_INCLUDEDIR} ${PC_TINYXML2_INCLUDE_DIRS})
find_library(TINYXML2_LIBRARY NAMES tinyxml2
HINTS ${PC_TINYXML2_LIBDIR} ${PC_TINYXML2_LIBRARY_DIRS})
set(TINYXML2_LIBRARIES ${TINYXML2_LIBRARY})
set(TINYXML2_INCLUDE_DIRS ${TINYXML2_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TINYXML2_LIBRARY TINYXML2_INCLUDE_DIR)
mark_as_advanced(TINYXML2_INCLUDE_DIR TINYXML2_LIBRARY)