1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-06-07 17:11:56 +00:00

Merge branch 'tinyxml2' into experimental. Thanks to James Le Cuirot for this.

Conflicts:
	Aquaria/UserSettings.cpp
	CMakeLists.txt
This commit is contained in:
fgenesis 2014-06-09 22:31:39 +02:00
commit 4bafcb3e18
30 changed files with 4866 additions and 11258 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/Quad.h"
#include "../BBGE/ActionMapper.h"
#include "../ExternalLibs/tinyxml.h"
#include "../BBGE/Slider.h"
#include "../BBGE/DebugFont.h"
#include "../BBGE/TTFFont.h"
#include "../BBGE/RoundedRect.h"
#include "tinyxml2.h"
using namespace tinyxml2;
class AquariaGuiElement
{
public:
@ -76,7 +78,7 @@ public:
void setLabel(const std::string &label);
EventPtr event;
BitmapText *font, *glowFont;
TiXmlElement *ability, *xmlItem;
XMLElement *ability, *xmlItem;
int choice;
Quad *glow, *quad;
void useQuad(const std::string &tex);
@ -111,7 +113,7 @@ public:
bool mbDown;
static std::string getSaveDescription(const TiXmlDocument &doc);
static std::string getSaveDescription(const XMLDocument &doc);
protected:
void onUpdate(float dt);

View file

@ -58,7 +58,7 @@ AquariaSaveSlot::AquariaSaveSlot(int slot) : AquariaGuiQuad()
glowText->position = text1->position = Vector(-175, -25);
TiXmlDocument doc;
XMLDocument doc;
dsq->continuity.loadFileData(slot, 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)
return "";

View file

@ -26,7 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "GridRender.h"
#include "DeflateCompressor.h"
#include "../ExternalLibs/tinyxml.h"
#include "tinyxml2.h"
using namespace tinyxml2;
#define MAX_EATS 8
@ -1251,9 +1252,9 @@ std::string Continuity::getInternalFormName()
void Continuity::loadIntoSongBank(const std::string &file)
{
TiXmlDocument doc;
doc.LoadFile(file);
TiXmlElement *song = doc.FirstChildElement("Song");
XMLDocument doc;
doc.LoadFile(file.c_str());
XMLElement *song = doc.FirstChildElement("Song");
while (song)
{
Song s;
@ -2359,13 +2360,13 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
dsq->user.save();
TiXmlDocument doc;
XMLDocument doc;
TiXmlElement version("Version");
XMLElement *version = doc.NewElement("Version");
{
version.SetAttribute("major", VERSION_MAJOR);
version.SetAttribute("minor", VERSION_MINOR);
version.SetAttribute("revision", VERSION_REVISION);
version->SetAttribute("major", VERSION_MAJOR);
version->SetAttribute("minor", VERSION_MINOR);
version->SetAttribute("revision", VERSION_REVISION);
}
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("TEMP_")!=std::string::npos) continue;
TiXmlElement flag("Flag");
flag.SetAttribute("name", (*i).first);
flag.SetAttribute("value", (*i).second);
XMLElement *flag = doc.NewElement("Flag");
flag->SetAttribute("name", (*i).first.c_str());
flag->SetAttribute("value", (*i).second);
doc.InsertEndChild(flag);
}
TiXmlElement efx("EFX");
XMLElement *efx = doc.NewElement("EFX");
{
std::ostringstream os;
for (EntityFlags::iterator i = entityFlags.begin(); i != entityFlags.end(); i++)
{
os << (*i).first << " " << (*i).second << " ";
}
efx.SetAttribute("a", os.str());
efx->SetAttribute("a", os.str().c_str());
}
doc.InsertEndChild(efx);
TiXmlElement gems("Gems");
XMLElement *gems = doc.NewElement("Gems");
{
std::ostringstream os;
bool hasUserString = false;
@ -2407,7 +2408,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
if (hasUserString)
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,
// 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)
os << spacesToUnderscores((*i).userString) << " ";
}
gems.SetAttribute("d", os.str());
gems->SetAttribute("d", os.str());
*/
}
doc.InsertEndChild(gems);
TiXmlElement worldMap("WorldMap");
XMLElement *worldMap = doc.NewElement("WorldMap");
{
std::ostringstream os;
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 << " ";
}
}
worldMap.SetAttribute("b", os.str());
worldMap->SetAttribute("b", os.str().c_str());
#ifdef AQUARIA_BUILD_MAPVIS
if (dsq->game->worldMapRender)
@ -2461,13 +2462,13 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
tile->dataToString(os);
os << " ";
}
worldMap.SetAttribute("va", os.str());
worldMap->SetAttribute("va", os.str().c_str());
}
#endif
}
doc.InsertEndChild(worldMap);
TiXmlElement vox("VO");
XMLElement *vox = doc.NewElement("VO");
{
std::ostringstream os;
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] << " ";
}
vox.SetAttribute("v", os.str());
vox->SetAttribute("v", os.str().c_str());
}
doc.InsertEndChild(vox);
TiXmlElement eats("eats");
XMLElement *eats = doc.NewElement("eats");
{
std::ostringstream os;
int num = naijaEats.size();
@ -2489,11 +2490,11 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
EatData *eat = &naijaEats[i];
os << eat->name << " " << eat->shot << " " << eat->ammo << " " << eat->ammoUnitSize << " ";
}
eats.SetAttribute("a", os.str());
eats->SetAttribute("a", os.str().c_str());
}
doc.InsertEndChild(eats);
TiXmlElement bcn("bcn");
XMLElement *bcn = doc.NewElement("bcn");
{
std::ostringstream os;
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->pos.x << " " << data->pos.y << " " << data->pos.z << " ";
}
bcn.SetAttribute("a", os.str());
bcn->SetAttribute("a", os.str().c_str());
}
doc.InsertEndChild(bcn);
TiXmlElement s("Story");
XMLElement *s = doc.NewElement("Story");
{
std::ostringstream os;
os << story;
s.SetAttribute("v", os.str());
s->SetAttribute("v", os.str().c_str());
doc.InsertEndChild(s);
}
for (StringFlags::iterator i = stringFlags.begin(); i != stringFlags.end(); i++)
{
if ((*i).first.find("TEMP_")!=std::string::npos) continue;
TiXmlElement stringFlag("StringFlag");
stringFlag.SetAttribute("name", (*i).first);
stringFlag.SetAttribute("value", (*i).second);
XMLElement *stringFlag = doc.NewElement("StringFlag");
stringFlag->SetAttribute("name", (*i).first.c_str());
stringFlag->SetAttribute("value", (*i).second.c_str());
doc.InsertEndChild(stringFlag);
}
TiXmlElement startData("StartData");
startData.SetAttribute("x", int(position.x));
startData.SetAttribute("y", int(position.y));
startData.SetAttribute("scene", dsq->game->sceneName);
startData.SetAttribute("exp", dsq->continuity.exp);
startData.SetAttribute("h", dsq->continuity.maxHealth);
startData.SetAttribute("ch", dsq->continuity.health);
startData.SetAttribute("naijaModel", dsq->continuity.naijaModel);
startData.SetAttribute("costume", dsq->continuity.costume);
startData.SetAttribute("form", dsq->continuity.form);
XMLElement *startData = doc.NewElement("StartData");
startData->SetAttribute("x", int(position.x));
startData->SetAttribute("y", int(position.y));
startData->SetAttribute("scene", dsq->game->sceneName.c_str());
startData->SetAttribute("exp", dsq->continuity.exp);
startData->SetAttribute("h", dsq->continuity.maxHealth);
startData->SetAttribute("ch", dsq->continuity.health);
startData->SetAttribute("naijaModel", dsq->continuity.naijaModel.c_str());
startData->SetAttribute("costume", dsq->continuity.costume.c_str());
startData->SetAttribute("form", dsq->continuity.form);
if (dsq->mod.isActive())
startData.SetAttribute("mod", dsq->mod.getName());
startData->SetAttribute("mod", dsq->mod.getName().c_str());
std::ostringstream secondsOS;
secondsOS << dsq->continuity.seconds;
startData.SetAttribute("seconds", secondsOS.str());
startData->SetAttribute("seconds", secondsOS.str().c_str());
std::ostringstream os2;
for (int i = 0; i < SONG_MAX; i++)
{
@ -2547,7 +2548,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
os2 << i << " ";
}
}
startData.SetAttribute("songs", os2.str());
startData->SetAttribute("songs", os2.str().c_str());
// new format as used by android version
std::ostringstream ingrNames;
@ -2556,7 +2557,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
IngredientData *data = ingredients[i];
ingrNames << data->name << " " << data->amount << " ";
}
startData.SetAttribute("ingrNames", ingrNames.str());
startData->SetAttribute("ingrNames", ingrNames.str().c_str());
// for compatibility with older versions
std::ostringstream ingrOs;
@ -2565,14 +2566,14 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
IngredientData *data = ingredients[i];
ingrOs << data->getIndex() << " " << data->amount << " ";
}
startData.SetAttribute("ingr", ingrOs.str());
startData->SetAttribute("ingr", ingrOs.str().c_str());
std::ostringstream recOs;
for (int i = 0; i < recipes.size(); i++)
{
recOs << recipes[i].isKnown() << " ";
}
startData.SetAttribute("rec", recOs.str());
startData->SetAttribute("rec", recOs.str().c_str());
std::ostringstream os3;
for (int i = 0; i < FORMUPGRADE_MAX; i++)
@ -2582,7 +2583,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
os3 << i << " ";
}
}
startData.SetAttribute("formUpgrades", os3.str());
startData->SetAttribute("formUpgrades", os3.str().c_str());
std::ostringstream fos;
fos << MAX_FLAGS << " ";
@ -2590,7 +2591,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
{
fos << intFlags[i] << " ";
}
startData.SetAttribute("intFlags", fos.str());
startData->SetAttribute("intFlags", fos.str().c_str());
// Additional data for the android version
@ -2598,7 +2599,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
do { if((cond) && (val)) { \
std::ostringstream osf; \
osf << (val); \
startData.SetAttribute(name, osf.str()); \
startData->SetAttribute(name, osf.str().c_str()); \
}} while(0)
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)) { \
std::ostringstream osf; \
osf << (val) << " " << ((timer).getValue()); \
startData.SetAttribute((name), osf.str()); \
startData->SetAttribute((name), osf.str().c_str()); \
}} while(0)
TIMER_AND_VALUE_ATTR("biteMult", biteMultTimer, biteMult);
@ -2631,14 +2632,14 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
{
std::ostringstream osp;
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)
{
std::ostringstream osa;
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.
@ -2655,7 +2656,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
Vector v = w->getPoint(i);
osw << v.x << " " << v.y << " ";
}
startData.SetAttribute("web", osw.str());
startData->SetAttribute("web", osw.str().c_str());
}
// end extra android data
@ -2671,11 +2672,11 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
return;
}
TiXmlPrinter printer;
XMLPrinter printer;
doc.Accept( &printer );
const char* xmlstr = printer.CStr();
ZlibCompressor z;
z.init((void*)xmlstr, printer.Size(), ZlibCompressor::REUSE);
z.init((void*)xmlstr, printer.CStrSize(), ZlibCompressor::REUSE);
z.SetForceCompression(true);
z.Compress(3);
std::ostringstream os;
@ -2696,7 +2697,7 @@ std::string Continuity::getSaveFileName(int slot, const std::string &pfix)
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");
if(!exists(teh_file))
@ -2711,9 +2712,9 @@ void Continuity::loadFileData(int slot, TiXmlDocument &doc)
errorLog("Failed to decompress save file: " + teh_file);
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;
}
}
@ -2721,7 +2722,7 @@ void Continuity::loadFileData(int slot, TiXmlDocument &doc)
teh_file = dsq->continuity.getSaveFileName(slot, "xml");
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);
}
}
@ -2730,10 +2731,10 @@ void Continuity::loadFile(int slot)
{
dsq->user.save();
TiXmlDocument doc;
XMLDocument doc;
loadFileData(slot, doc);
TiXmlElement *startData = doc.FirstChildElement("StartData");
XMLElement *startData = doc.FirstChildElement("StartData");
if (startData)
{
if (startData->Attribute("mod"))
@ -2749,7 +2750,7 @@ void Continuity::loadFile(int slot)
this->reset();
int versionMajor=-1, versionMinor=-1, versionRevision=-1;
TiXmlElement *xmlVersion = doc.FirstChildElement("Version");
XMLElement *xmlVersion = doc.FirstChildElement("Version");
if (xmlVersion)
{
versionMajor = atoi(xmlVersion->Attribute("major"));
@ -2757,7 +2758,7 @@ void Continuity::loadFile(int slot)
versionRevision = atoi(xmlVersion->Attribute("revision"));
}
TiXmlElement *e = doc.FirstChildElement("Flag");
XMLElement *e = doc.FirstChildElement("Flag");
while (e)
{
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->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->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->Attribute("a"))
@ -2834,7 +2835,7 @@ void Continuity::loadFile(int slot)
}
}
TiXmlElement *vox = doc.FirstChildElement("VO");
XMLElement *vox = doc.FirstChildElement("VO");
if (vox)
{
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->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->Attribute("b"))
@ -3023,14 +3024,14 @@ void Continuity::loadFile(int slot)
}
TiXmlElement *s = doc.FirstChildElement("Story");
XMLElement *s = doc.FirstChildElement("Story");
if (s)
{
std::istringstream is(s->Attribute("v"));
is >> story;
}
TiXmlElement *e2 = doc.FirstChildElement("StringFlag");
XMLElement *e2 = doc.FirstChildElement("StringFlag");
while (e2)
{
dsq->continuity.setStringFlag(e2->Attribute("name"), e2->Attribute("value"));

View file

@ -2075,11 +2075,11 @@ void DSQ::loadModsCallback(const std::string &filename, intptr_t param)
m.path = name;
m.id = dsq->modEntries.size();
TiXmlDocument d;
XMLDocument d;
if(!Mod::loadModXML(&d, name))
{
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());
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/ScreenTransition.h"
#include "../BBGE/Precacher.h"
#include "../ExternalLibs/tinyxml.h"
#include "AquariaMenuItem.h"
#include "ScriptInterface.h"
@ -36,6 +35,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "TTFFont.h"
#include "tinyxml2.h"
using namespace tinyxml2;
#define AQUARIA_BUILD_MAPVIS
// Define this to save map visited data in a base64-encoded raw format.
@ -286,8 +288,8 @@ public:
void shutdown();
bool isShuttingDown();
static bool loadModXML(TiXmlDocument *d, std::string modName);
static ModType getTypeFromXML(TiXmlElement *xml);
static bool loadModXML(XMLDocument *d, std::string modName);
static ModType getTypeFromXML(XMLElement *xml);
WorldMapRevealMethod mapRevealMethod;
@ -939,7 +941,7 @@ public:
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 loadFileData(int slot, TiXmlDocument &doc);
void loadFileData(int slot, XMLDocument &doc);
void loadFile(int slot);
void castSong(int num);
@ -1622,7 +1624,6 @@ protected:
std::vector <AquariaSaveSlot*> saveSlots;
BitmapText *expText, *moneyText;
TiXmlDocument *xmlDoc;
void clearMenu(float t = 0.01);
std::vector <RenderObject*> menu;

View file

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

View file

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

View file

@ -2407,14 +2407,14 @@ bool Game::removeEntity(Entity *selected)
{
selected->setState(Entity::STATE_DEAD);
selected->safeKill();
TiXmlElement *e = this->saveFile->FirstChildElement("Enemy");
XMLElement *e = this->saveFile->FirstChildElement("Enemy");
while (e)
{
int x = atoi(e->Attribute("x"));
int y = atoi(e->Attribute("y"));
if (int(selected->startPos.x) == x && int(selected->startPos.y) == y)
{
this->saveFile->RemoveChild(e);
this->saveFile->DeleteChild(e);
//delete e;
return true;
}
@ -4201,8 +4201,8 @@ bool Game::loadSceneXML(std::string scene)
dsq->screenMessage(s);
return false;
}
TiXmlDocument doc;
doc.LoadFile(fn);
XMLDocument doc;
doc.LoadFile(fn.c_str());
if (saveFile)
{
delete saveFile;
@ -4210,14 +4210,14 @@ bool Game::loadSceneXML(std::string scene)
}
if (!saveFile)
{
saveFile = new TiXmlDocument();
saveFile = new XMLDocument();
}
addProgress();
clearObsRows();
warpAreas.clear();
TiXmlElement *lensFlare = doc.FirstChildElement("LensFlare");
XMLElement *lensFlare = doc.FirstChildElement("LensFlare");
while (lensFlare)
{
LensFlare *l = new LensFlare;
@ -4244,33 +4244,33 @@ bool Game::loadSceneXML(std::string scene)
l->position = Vector(atoi(lensFlare->Attribute("x")),atoi(lensFlare->Attribute("y")));
addRenderObject(l, LR_LIGHTING);
TiXmlElement lSF("LensFlare");
lSF.SetAttribute("inc", lensFlare->Attribute("inc"));
lSF.SetAttribute("x", lensFlare->Attribute("x"));
lSF.SetAttribute("y", lensFlare->Attribute("y"));
lSF.SetAttribute("tex", lensFlare->Attribute("tex"));
lSF.SetAttribute("w", lensFlare->Attribute("w"));
lSF.SetAttribute("h", lensFlare->Attribute("h"));
lSF.SetAttribute("maxLen", lensFlare->Attribute("maxLen"));
XMLElement *lSF = doc.NewElement("LensFlare");
lSF->SetAttribute("inc", lensFlare->Attribute("inc"));
lSF->SetAttribute("x", lensFlare->Attribute("x"));
lSF->SetAttribute("y", lensFlare->Attribute("y"));
lSF->SetAttribute("tex", lensFlare->Attribute("tex"));
lSF->SetAttribute("w", lensFlare->Attribute("w"));
lSF->SetAttribute("h", lensFlare->Attribute("h"));
lSF->SetAttribute("maxLen", lensFlare->Attribute("maxLen"));
saveFile->InsertEndChild(lSF);
lensFlare = lensFlare->NextSiblingElement("LensFlare");
}
TiXmlElement *level = doc.FirstChildElement("Level");
XMLElement *level = doc.FirstChildElement("Level");
if (level)
{
TiXmlElement levelSF("Level");
XMLElement *levelSF = doc.NewElement("Level");
if (level->Attribute("tileset"))
{
elementTemplatePack = level->Attribute("tileset");
loadElementTemplates(elementTemplatePack);
levelSF.SetAttribute("tileset", elementTemplatePack);
levelSF->SetAttribute("tileset", elementTemplatePack.c_str());
}
else if (level->Attribute("elementTemplatePack"))
{
elementTemplatePack = level->Attribute("elementTemplatePack");
loadElementTemplates(elementTemplatePack);
levelSF.SetAttribute("tileset", elementTemplatePack);
levelSF->SetAttribute("tileset", elementTemplatePack.c_str());
}
else
return false;
@ -4280,28 +4280,28 @@ bool Game::loadSceneXML(std::string scene)
useWaterLevel = true;
waterLevel = atoi(level->Attribute("waterLevel"));
saveWaterLevel = atoi(level->Attribute("waterLevel"));
levelSF.SetAttribute("waterLevel", waterLevel.x);
levelSF->SetAttribute("waterLevel", waterLevel.x);
}
if (level->Attribute("worldMapIndex"))
{
worldMapIndex = atoi(level->Attribute("worldMapIndex"));
levelSF.SetAttribute("worldMapIndex", worldMapIndex);
levelSF->SetAttribute("worldMapIndex", worldMapIndex);
}
if (level->Attribute("bgSfxLoop"))
{
bgSfxLoop = level->Attribute("bgSfxLoop");
levelSF.SetAttribute("bgSfxLoop", bgSfxLoop);
levelSF->SetAttribute("bgSfxLoop", bgSfxLoop.c_str());
}
if (level->Attribute("airSfxLoop"))
{
airSfxLoop = level->Attribute("airSfxLoop");
levelSF.SetAttribute("airSfxLoop", airSfxLoop);
levelSF->SetAttribute("airSfxLoop", airSfxLoop.c_str());
}
if (level->Attribute("bnat"))
{
bNatural = atoi(level->Attribute("bnat"));
levelSF.SetAttribute("bnat", 1);
levelSF->SetAttribute("bnat", 1);
}
else
{
@ -4313,7 +4313,7 @@ bool Game::loadSceneXML(std::string scene)
{
int v = (atoi(level->Attribute("darkLayer")));
levelSF.SetAttribute("darkLayer", v);
levelSF->SetAttribute("darkLayer", v);
}
*/
dsq->darkLayer.toggle(true);
@ -4322,13 +4322,13 @@ bool Game::loadSceneXML(std::string scene)
{
SimpleIStringStream is(level->Attribute("bgRepeat"));
is >> backgroundImageRepeat;
levelSF.SetAttribute("bgRepeat", level->Attribute("bgRepeat"));
levelSF->SetAttribute("bgRepeat", level->Attribute("bgRepeat"));
}
if (level->Attribute("cameraConstrained"))
{
SimpleIStringStream is(level->Attribute("cameraConstrained"));
is >> cameraConstrained;
levelSF.SetAttribute("cameraConstrained", cameraConstrained);
levelSF->SetAttribute("cameraConstrained", cameraConstrained);
std::ostringstream os;
os << "cameraConstrained: " << cameraConstrained;
debugLog(os.str());
@ -4338,12 +4338,12 @@ bool Game::loadSceneXML(std::string scene)
maxZoom = atof(level->Attribute("maxZoom"));
std::ostringstream os;
os << maxZoom;
levelSF.SetAttribute("maxZoom", os.str());
levelSF->SetAttribute("maxZoom", os.str().c_str());
}
if (level->Attribute("natureForm"))
{
sceneNatureForm = level->Attribute("natureForm");
levelSF.SetAttribute("natureForm", sceneNatureForm);
levelSF->SetAttribute("natureForm", sceneNatureForm.c_str());
}
if (level->Attribute("bg"))
{
@ -4359,7 +4359,7 @@ bool Game::loadSceneXML(std::string scene)
bg->setTexture(tex);
bg->setWidthHeight(900,600);
levelSF.SetAttribute("bg", tex);
levelSF->SetAttribute("bg", tex.c_str());
}
else
{
@ -4378,16 +4378,16 @@ bool Game::loadSceneXML(std::string scene)
{
SimpleIStringStream is(level->Attribute("gradTop"));
is >> gradTop.x >> gradTop.y >> gradTop.z;
levelSF.SetAttribute("gradTop", level->Attribute("gradTop"));
levelSF->SetAttribute("gradTop", level->Attribute("gradTop"));
}
if (level->Attribute("gradBtm"))
{
SimpleIStringStream is(level->Attribute("gradBtm"));
is >> gradBtm.x >> gradBtm.y >> gradBtm.z;
levelSF.SetAttribute("gradBtm", level->Attribute("gradBtm"));
levelSF->SetAttribute("gradBtm", level->Attribute("gradBtm"));
}
createGradient();
levelSF.SetAttribute("gradient", 1);
levelSF->SetAttribute("gradient", 1);
}
if (level->Attribute("parallax"))
@ -4412,7 +4412,7 @@ bool Game::loadSceneXML(std::string scene)
l->followCamera = g;
l = &dsq->renderObjectLayers[LR_ELEMENTS16];
l->followCamera = b;
levelSF.SetAttribute("parallax", level->Attribute("parallax"));
levelSF->SetAttribute("parallax", level->Attribute("parallax"));
}
if (level->Attribute("parallaxLock"))
@ -4435,7 +4435,7 @@ bool Game::loadSceneXML(std::string scene)
l = &dsq->renderObjectLayers[LR_ELEMENTS16];
l->followCameraLock = b;
levelSF.SetAttribute("parallaxLock", level->Attribute("parallaxLock"));
levelSF->SetAttribute("parallaxLock", level->Attribute("parallaxLock"));
}
if (level->Attribute("bg2"))
@ -4452,7 +4452,7 @@ bool Game::loadSceneXML(std::string scene)
*/
bg2->setTexture(tex);
bg2->setWidthHeight(900,600);
levelSF.SetAttribute("bg2", tex);
levelSF->SetAttribute("bg2", tex.c_str());
}
else
@ -4480,16 +4480,16 @@ bool Game::loadSceneXML(std::string scene)
int x = atoi(level->Attribute("bd-x"));
int y = atoi(level->Attribute("bd-y"));
backdropQuad->position = Vector(x,y);
levelSF.SetAttribute("bd-x", x);
levelSF.SetAttribute("bd-y", y);
levelSF->SetAttribute("bd-x", x);
levelSF->SetAttribute("bd-y", y);
}
if (level->Attribute("bd-w") && level->Attribute("bd-h"))
{
int w = atoi(level->Attribute("bd-w"));
int h = atoi(level->Attribute("bd-h"));
backdropQuad->setWidthHeight(w, h);
levelSF.SetAttribute("bd-w", w);
levelSF.SetAttribute("bd-h", h);
levelSF->SetAttribute("bd-w", w);
levelSF->SetAttribute("bd-h", h);
}
backdropQuad->toggleCull(false);
//backdropQuad->followCamera = 1;
@ -4500,7 +4500,7 @@ bool Game::loadSceneXML(std::string scene)
Vector((backdropQuad->getWidth()*backdropQuad->scale.x)/2.0f,
(backdropQuad->getHeight()*backdropQuad->scale.y)/2.0f);
// save
levelSF.SetAttribute("backdrop", backdrop.c_str());
levelSF->SetAttribute("backdrop", backdrop.c_str());
//backdrop="cavebg" bd-w="2400" bd-h="2400"
}
musicToPlay = "";
@ -4508,7 +4508,7 @@ bool Game::loadSceneXML(std::string scene)
{
setMusicToPlay(level->Attribute("music"));
saveMusic = level->Attribute("music");
levelSF.SetAttribute("music", level->Attribute("music"));
levelSF->SetAttribute("music", level->Attribute("music"));
/*
// if using SDL_Mixer
if (!core->sound->isPlayingMusic(musicToPlay))
@ -4521,7 +4521,7 @@ bool Game::loadSceneXML(std::string scene)
{
SimpleIStringStream in(level->Attribute("sceneColor"));
in >> sceneColor.x >> sceneColor.y >> sceneColor.z;
levelSF.SetAttribute("sceneColor", level->Attribute("sceneColor"));
levelSF->SetAttribute("sceneColor", level->Attribute("sceneColor"));
}
saveFile->InsertEndChild(levelSF);
@ -4529,7 +4529,7 @@ bool Game::loadSceneXML(std::string scene)
else
return false;
TiXmlElement *obs = doc.FirstChildElement("Obs");
XMLElement *obs = doc.FirstChildElement("Obs");
if (obs)
{
int tx, ty, len;
@ -4542,7 +4542,7 @@ bool Game::loadSceneXML(std::string scene)
addProgress();
}
TiXmlElement *pathXml = doc.FirstChildElement("Path");
XMLElement *pathXml = doc.FirstChildElement("Path");
while (pathXml)
{
Path *path = new Path;
@ -4554,7 +4554,7 @@ bool Game::loadSceneXML(std::string scene)
path.active = atoi(pathXml->Attribute("active"));
}
*/
TiXmlElement *nodeXml = pathXml->FirstChildElement("Node");
XMLElement *nodeXml = pathXml->FirstChildElement("Node");
while (nodeXml)
{
PathNode node;
@ -4589,27 +4589,27 @@ bool Game::loadSceneXML(std::string scene)
pathXml = pathXml->NextSiblingElement("Path");
}
TiXmlElement *quad = doc.FirstChildElement("Quad");
XMLElement *quad = doc.FirstChildElement("Quad");
while (quad)
{
TiXmlElement qSF("Quad");
XMLElement *qSF = doc.NewElement("Quad");
int x=0, y=0, z=0;
int w=0,h=0;
bool cull=true;
bool solid = false;
std::string justify;
std::string tex;
qSF.SetAttribute("x", x = atoi(quad->Attribute("x")));
qSF.SetAttribute("y", y = atoi(quad->Attribute("y")));
//qSF.SetAttribute("z", z = atoi(quad->Attribute("z")));
qSF.SetAttribute("w", w = atoi(quad->Attribute("w")));
qSF.SetAttribute("h", h = atoi(quad->Attribute("h")));
qSF.SetAttribute("tex", tex = (quad->Attribute("tex")));
qSF.SetAttribute("cull", cull = atoi(quad->Attribute("cull")));
qSF.SetAttribute("justify", justify = (quad->Attribute("justify")));
qSF->SetAttribute("x", x = atoi(quad->Attribute("x")));
qSF->SetAttribute("y", y = atoi(quad->Attribute("y")));
//qSF->SetAttribute("z", z = atoi(quad->Attribute("z")));
qSF->SetAttribute("w", w = atoi(quad->Attribute("w")));
qSF->SetAttribute("h", h = atoi(quad->Attribute("h")));
qSF->SetAttribute("tex", (tex = (quad->Attribute("tex"))).c_str());
qSF->SetAttribute("cull", cull = atoi(quad->Attribute("cull")));
qSF->SetAttribute("justify", (justify = (quad->Attribute("justify"))).c_str());
if (quad->Attribute("solid"))
qSF.SetAttribute("solid", solid = atoi(quad->Attribute("solid")));
qSF->SetAttribute("solid", solid = atoi(quad->Attribute("solid")));
Quad *q = new Quad;
q->position = Vector(x,y,z);
@ -4636,25 +4636,23 @@ bool Game::loadSceneXML(std::string scene)
quad = quad->NextSiblingElement("Quad");
}
TiXmlElement *floater = doc.FirstChildElement("Floater");
XMLElement *floater = doc.FirstChildElement("Floater");
while(floater)
{
TiXmlElement nSF("Floater");
XMLElement *nSF = doc.NewElement("Floater");
if (!floater->Attribute("boxW") || !floater->Attribute("boxH"))
{
errorLog ("no boxW/boxH");
break;
}
int boxW, boxH, x, y, fx, fy;
std::string tex;
nSF.SetAttribute("boxW", boxW = atoi(floater->Attribute("boxW")));
nSF.SetAttribute("boxH", boxH = atoi(floater->Attribute("boxH")));
tex = floater->Attribute("tex");
nSF.SetAttribute("tex", tex);
nSF.SetAttribute("x", x = atoi(floater->Attribute("x")));
nSF.SetAttribute("y", y = atoi(floater->Attribute("y")));
nSF.SetAttribute("fx", fx = atoi(floater->Attribute("fx")));
nSF.SetAttribute("fy", fy = atoi(floater->Attribute("fy")));
nSF->SetAttribute("boxW", boxW = atoi(floater->Attribute("boxW")));
nSF->SetAttribute("boxH", boxH = atoi(floater->Attribute("boxH")));
nSF->SetAttribute("tex", floater->Attribute("tex"));
nSF->SetAttribute("x", x = atoi(floater->Attribute("x")));
nSF->SetAttribute("y", y = atoi(floater->Attribute("y")));
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);
@ -4668,10 +4666,10 @@ bool Game::loadSceneXML(std::string scene)
}
/*
TiXmlElement *breakable = doc.FirstChildElement("Breakable");
XMLElement *breakable = doc.FirstChildElement("Breakable");
while(breakable)
{
TiXmlElement nSF("Breakable");
XMLElement *nSF = doc.NewElement("Breakable");
if (!breakable->Attribute("boxW") || !breakable->Attribute("boxH"))
{
errorLog ("Breakable error.. no boxW/boxH");
@ -4679,19 +4677,19 @@ bool Game::loadSceneXML(std::string scene)
}
int boxW, boxH;
std::string tex;
nSF.SetAttribute("boxW", boxW = atoi(breakable->Attribute("boxW")));
nSF.SetAttribute("boxH", boxH = atoi(breakable->Attribute("boxH")));
nSF->SetAttribute("boxW", boxW = atoi(breakable->Attribute("boxW")));
nSF->SetAttribute("boxH", boxH = atoi(breakable->Attribute("boxH")));
tex = breakable->Attribute("tex");
nSF.SetAttribute("tex", tex);
nSF->SetAttribute("tex", tex);
Breakable *n = new Breakable(boxW, boxH, tex);
{
nSF.SetAttribute("x", n->position.x = atoi(breakable->Attribute("x")));
nSF.SetAttribute("y", n->position.y = atoi(breakable->Attribute("y")));
nSF->SetAttribute("x", n->position.x = atoi(breakable->Attribute("x")));
nSF->SetAttribute("y", n->position.y = atoi(breakable->Attribute("y")));
int w=0, h=0;
if (breakable->Attribute("w"))
nSF.SetAttribute("w", w = atoi(breakable->Attribute("w")));
nSF->SetAttribute("w", w = atoi(breakable->Attribute("w")));
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)
{
n->setWidthHeight(w, h);
@ -4703,31 +4701,31 @@ bool Game::loadSceneXML(std::string scene)
}
*/
TiXmlElement *warpArea = doc.FirstChildElement("WarpArea");
XMLElement *warpArea = doc.FirstChildElement("WarpArea");
while(warpArea)
{
TiXmlElement waSF("WarpArea");
XMLElement *waSF = doc.NewElement("WarpArea");
WarpArea a;
waSF.SetAttribute("x", a.position.x = atoi(warpArea->Attribute("x")));
waSF.SetAttribute("y", a.position.y = atoi(warpArea->Attribute("y")));
waSF->SetAttribute("x", a.position.x = atoi(warpArea->Attribute("x")));
waSF->SetAttribute("y", a.position.y = atoi(warpArea->Attribute("y")));
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;
if (warpArea->Attribute("w"))
{
isRect = true;
waSF.SetAttribute("w", a.w = atoi(warpArea->Attribute("w")));
waSF.SetAttribute("h", a.h = atoi(warpArea->Attribute("h")));
waSF->SetAttribute("w", a.w = atoi(warpArea->Attribute("w")));
waSF->SetAttribute("h", a.h = atoi(warpArea->Attribute("h")));
}
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");
waSF.SetAttribute("scene", sceneString.c_str());
waSF->SetAttribute("scene", sceneString.c_str());
/*
waSF.SetAttribute("ax", a.avatarPosition.x = atoi(warpArea->Attribute("ax")));
waSF.SetAttribute("ay", a.avatarPosition.y = atoi(warpArea->Attribute("ay")));
waSF->SetAttribute("ax", a.avatarPosition.x = atoi(warpArea->Attribute("ax")));
waSF->SetAttribute("ay", a.avatarPosition.y = atoi(warpArea->Attribute("ay")));
*/
SimpleIStringStream is(sceneString);
@ -4757,7 +4755,7 @@ bool Game::loadSceneXML(std::string scene)
warpArea = warpArea->NextSiblingElement("WarpArea");
}
TiXmlElement *schoolFish = doc.FirstChildElement("SchoolFish");
XMLElement *schoolFish = doc.FirstChildElement("SchoolFish");
while(schoolFish)
{
int num = atoi(schoolFish->Attribute("num"));
@ -4854,27 +4852,27 @@ bool Game::loadSceneXML(std::string scene)
schoolFish = schoolFish->NextSiblingElement("SchoolFish");
TiXmlElement newSF("SchoolFish");
newSF.SetAttribute("x", x);
newSF.SetAttribute("y", y);
newSF.SetAttribute("id", id);
newSF.SetAttribute("num", num);
XMLElement *newSF = doc.NewElement("SchoolFish");
newSF->SetAttribute("x", x);
newSF->SetAttribute("y", y);
newSF->SetAttribute("id", id);
newSF->SetAttribute("num", num);
if (range != 0)
newSF.SetAttribute("range", range);
newSF->SetAttribute("range", range);
if (maxSpeed != 0)
newSF.SetAttribute("maxSpeed", maxSpeed);
newSF->SetAttribute("maxSpeed", maxSpeed);
if (layer != 0)
newSF.SetAttribute("layer", layer);
newSF->SetAttribute("layer", layer);
if (!gfx.empty())
newSF.SetAttribute("gfx", gfx.c_str());
newSF->SetAttribute("gfx", gfx.c_str());
if (size != 1)
newSF.SetAttribute("size", size);
newSF->SetAttribute("size", size);
saveFile->InsertEndChild(newSF);
}
/*
TiXmlElement *boxElement = doc.FirstChildElement("BoxElement");
XMLElement *boxElement = doc.FirstChildElement("BoxElement");
while (boxElement)
{
BoxElement *b = new BoxElement(atoi(boxElement->Attribute("w")), atoi(boxElement->Attribute("h")));
@ -4885,7 +4883,7 @@ bool Game::loadSceneXML(std::string scene)
boxElement = boxElement->NextSiblingElement("BoxElement");
}
*/
TiXmlElement *simpleElements = doc.FirstChildElement("SE");
XMLElement *simpleElements = doc.FirstChildElement("SE");
while (simpleElements)
{
int idx, x, y, rot;
@ -5052,7 +5050,7 @@ bool Game::loadSceneXML(std::string scene)
simpleElements = simpleElements->NextSiblingElement("SE");
}
TiXmlElement *element = doc.FirstChildElement("Element");
XMLElement *element = doc.FirstChildElement("Element");
while (element)
{
if (element->Attribute("idx"))
@ -5099,7 +5097,7 @@ bool Game::loadSceneXML(std::string scene)
this->reconstructGrid(true);
/*
TiXmlElement *enemyNode = doc.FirstChildElement("Enemy");
XMLElement *enemyNode = doc.FirstChildElement("Enemy");
while(enemyNode)
{
Vector pos;
@ -5119,7 +5117,7 @@ bool Game::loadSceneXML(std::string scene)
enemyNode = enemyNode->NextSiblingElement("Enemy");
}
*/
TiXmlElement *entitiesNode = doc.FirstChildElement("Entities");
XMLElement *entitiesNode = doc.FirstChildElement("Entities");
while(entitiesNode)
{
if (entitiesNode->Attribute("j"))
@ -5307,15 +5305,19 @@ bool Game::saveScene(std::string scene)
std::string fn = getSceneFilename(scene);
TiXmlDocument saveFile(*this->saveFile);
//this->saveFile->CopyTo(&saveFile);
TiXmlElement *level = saveFile.FirstChildElement("Level");
XMLPrinter printer;
this->saveFile->Print(&printer);
TiXmlElement levelLocal("Level");
XMLDocument saveFile;
saveFile.Parse(printer.CStr(), printer.CStrSize());
XMLElement *level = saveFile.FirstChildElement("Level");
XMLElement *levelLocal = saveFile.NewElement("Level");
bool addIt = false;
if (!level)
{
level = &levelLocal;
level = levelLocal;
addIt = true;
}
@ -5329,17 +5331,17 @@ bool Game::saveScene(std::string scene)
std::ostringstream os;
os << gradTop.x << " " << gradTop.y << " " << gradTop.z;
level->SetAttribute("gradTop", os.str());
level->SetAttribute("gradTop", os.str().c_str());
std::ostringstream os2;
os2 << gradBtm.x << " " << gradBtm.y << " " << gradBtm.z;
level->SetAttribute("gradBtm", os2.str());
level->SetAttribute("gradBtm", os2.str().c_str());
}
if (!saveMusic.empty())
{
level->SetAttribute("music", saveMusic);
level->SetAttribute("music", saveMusic.c_str());
}
}
@ -5349,16 +5351,16 @@ bool Game::saveScene(std::string scene)
}
/*
TiXmlElement level("Level");
level.SetAttribute("elementTemplatePack", elementTemplatePack);
XMLElement *level = doc.NewElement("Level");
level->SetAttribute("elementTemplatePack", elementTemplatePack);
if (bg)
{
int pos = bg->texture->name.find_last_of('/')+1;
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;
os << sceneColor.x << " " << sceneColor.y << " " << sceneColor.z;
level.SetAttribute("sceneColor", os.str());
level->SetAttribute("sceneColor", os.str());
}
saveFile->InsertEndChild(level);
*/
@ -5369,32 +5371,32 @@ bool Game::saveScene(std::string scene)
{
obs << obsRows[i].tx << " " << obsRows[i].ty << " " << obsRows[i].len << " ";
}
TiXmlElement obsXml("Obs");
obsXml.SetAttribute("d", obs.str());
XMLElement *obsXml = saveFile.NewElement("Obs");
obsXml->SetAttribute("d", obs.str().c_str());
saveFile.InsertEndChild(obsXml);
for (i = 0; i < dsq->game->getNumPaths(); i++)
{
TiXmlElement pathXml("Path");
XMLElement *pathXml = saveFile.NewElement("Path");
Path *p = dsq->game->getPath(i);
pathXml.SetAttribute("name", p->name);
//pathXml.SetAttribute("active", p->active);
pathXml->SetAttribute("name", p->name.c_str());
//pathXml->SetAttribute("active", p->active);
for (int n = 0; n < p->nodes.size(); n++)
{
TiXmlElement nodeXml("Node");
XMLElement *nodeXml = saveFile.NewElement("Node");
std::ostringstream os;
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;
os2 << p->rect.getWidth() << " " << p->rect.getHeight();
nodeXml.SetAttribute("rect", os2.str().c_str());
nodeXml.SetAttribute("shape", (int)p->pathShape);
nodeXml->SetAttribute("rect", os2.str().c_str());
nodeXml->SetAttribute("shape", (int)p->pathShape);
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);
}
@ -5402,23 +5404,23 @@ bool Game::saveScene(std::string scene)
for (i = 0; i < dsq->game->warpAreas.size(); i++)
{
WarpArea a = dsq->game->warpAreas[i];
TiXmlElement waSF("WarpArea");
waSF.SetAttribute("x", a.position.x);
waSF.SetAttribute("y", a.position.y);
XMLElement *waSF = saveFile.NewElement("WarpArea");
waSF->SetAttribute("x", a.position.x);
waSF->SetAttribute("y", a.position.y);
if (a.radius > 0)
waSF.SetAttribute("radius", a.radius);
waSF->SetAttribute("radius", a.radius);
else if (a.w > 0 && a.h > 0)
{
waSF.SetAttribute("w", a.w);
waSF.SetAttribute("h", a.h);
waSF->SetAttribute("w", a.w);
waSF->SetAttribute("h", a.h);
}
if (a.generated)
{
waSF.SetAttribute("g", 1);
waSF->SetAttribute("g", 1);
}
std::ostringstream os;
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);
}
@ -5434,7 +5436,7 @@ bool Game::saveScene(std::string scene)
if (dsq->game->entitySaveData.size() > 0)
{
TiXmlElement entitiesNode("Entities");
XMLElement *entitiesNode = saveFile.NewElement("Entities");
std::ostringstream os;
for (int i = 0; i < dsq->game->entitySaveData.size(); i++)
@ -5452,7 +5454,7 @@ bool Game::saveScene(std::string scene)
// group ID no longer used
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);
}
@ -5461,9 +5463,9 @@ bool Game::saveScene(std::string scene)
std::string s = simpleElements[i].str();
if (!s.empty())
{
TiXmlElement simpleElementsXML("SE");
simpleElementsXML.SetAttribute("k", s.c_str());
simpleElementsXML.SetAttribute("l", i);
XMLElement *simpleElementsXML = saveFile.NewElement("SE");
simpleElementsXML->SetAttribute("k", s.c_str());
simpleElementsXML->SetAttribute("l", i);
saveFile.InsertEndChild(simpleElementsXML);
}
}
@ -5475,27 +5477,27 @@ bool Game::saveScene(std::string scene)
LightShaft *l = dynamic_cast<LightShaft*>(*i);
if (l)
{
TiXmlElement lightShaft("LightShaft");
lightShaft.SetAttribute("x", l->position.x);
lightShaft.SetAttribute("y", l->position.y);
XMLElement *lightShaft = saveFile.NewElement("LightShaft");
lightShaft->SetAttribute("x", l->position.x);
lightShaft->SetAttribute("y", l->position.y);
std::ostringstream os;
os << l->getDir().x;
lightShaft.SetAttribute("dirx", os.str());
lightShaft->SetAttribute("dirx", os.str());
std::ostringstream os2;
os2 << l->getDir().y;
lightShaft.SetAttribute("diry", os2.str());
lightShaft->SetAttribute("diry", os2.str());
std::ostringstream os3;
os3 << l->shaftWidth;
lightShaft.SetAttribute("w", os3.str());
lightShaft->SetAttribute("w", os3.str());
//lightShaft.SetAttribute("dirx", int(l->getDir().x*1000));
//lightShaft.SetAttribute("diry", int(l->getDir().y*1000));
//lightShaft->SetAttribute("dirx", int(l->getDir().x*1000));
//lightShaft->SetAttribute("diry", int(l->getDir().y*1000));
saveFile.InsertEndChild(lightShaft);
}
}
*/
bool result = saveFile.SaveFile(fn);
bool result = saveFile.SaveFile(fn.c_str());
if (result)
debugLog("Successfully saved map: " + fn);
else

View file

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

View file

@ -83,9 +83,9 @@ bool Mod::isEditorBlocked()
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
@ -108,46 +108,25 @@ void Mod::load(const std::string &p)
setActive(true);
TiXmlDocument d;
XMLDocument d;
loadModXML(&d, p);
TiXmlElement *mod = d.FirstChildElement("AquariaMod");
XMLElement *mod = d.FirstChildElement("AquariaMod");
if (mod)
{
TiXmlElement *props = mod->FirstChildElement("Properties");
XMLElement *props = mod->FirstChildElement("Properties");
if (props)
{
if (props->Attribute("recache")){
props->Attribute("recache", &doRecache);
}
props->QueryIntAttribute("recache", &doRecache);
props->QueryIntAttribute("debugMenu", &debugMenu);
props->QueryBoolAttribute("hasWorldMap", &hasMap);
props->QueryBoolAttribute("blockEditor", &blockEditor);
if (props->Attribute("runBG")){
int runBG = 0;
props->Attribute("runBG", &runBG);
if (runBG){
core->settings.runInBackground = true;
}
}
if (props->BoolAttribute("runBG"))
core->settings.runInBackground = true;
if (props->Attribute("debugMenu")) {
props->Attribute("debugMenu", &debugMenu);
}
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;
}
if (props->Attribute("worldMapRevealMethod"))
mapRevealMethod = (WorldMapRevealMethod) props->IntAttribute("worldMapRevealMethod");
}
}
@ -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)
{
TiXmlElement *prop = xml->FirstChildElement("Properties");
XMLElement *prop = xml->FirstChildElement("Properties");
if(prop)
{
const char *type = prop->Attribute("type");

View file

@ -6,9 +6,11 @@
#include "ModDownloader.h"
#include "ModSelector.h"
#include "Network.h"
#include "tinyxml.h"
#include "ttvfs.h"
#include "tinyxml2.h"
using namespace tinyxml2;
using Network::NetEvent;
using Network::NE_ABORT;
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)
{
TiXmlDocument xml;
if(!xml.LoadFile(fn))
XMLDocument xml;
if(xml.LoadFile(fn.c_str()) != XML_SUCCESS)
{
debugLog("Failed to parse downloaded XML: " + fn);
return false;
@ -279,7 +281,7 @@ bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
<ModList>
*/
TiXmlElement *modlist = xml.FirstChildElement("ModList");
XMLElement *modlist = xml.FirstChildElement("ModList");
if(!modlist)
{
debugLog("ModList root tag not found");
@ -288,11 +290,10 @@ bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
if(allowChaining)
{
TiXmlElement *servx = modlist->FirstChildElement("Server");
XMLElement *servx = modlist->FirstChildElement("Server");
while(servx)
{
int chain = 0;
servx->Attribute("chain", &chain);
int chain = servx->IntAttribute("chain");
if(const char *url = servx->Attribute("url"))
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)
{
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;
int serverSize = 0;
int serverIconSize = 0;
TiXmlElement *fullname, *desc, *icon, *pkg, *confirm, *props, *web;
XMLElement *fullname, *desc, *icon, *pkg, *confirm, *props, *web;
fullname = modx->FirstChildElement("Fullname");
desc = modx->FirstChildElement("Description");
icon = modx->FirstChildElement("Icon");
@ -327,8 +328,8 @@ bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
{
if(icon->Attribute("url"))
iconurl = icon->Attribute("url");
if(icon->Attribute("size"))
icon->Attribute("size", &serverIconSize);
serverIconSize = icon->IntAttribute("size");
}
if(props && props->Attribute("type"))
@ -352,8 +353,7 @@ bool ModDL::ParseModXML(const std::string& fn, bool allowChaining)
if(pkg->Attribute("saveAs"))
localname = _PathToModName(pkg->Attribute("saveAs"));
if(pkg->Attribute("size"))
pkg->Attribute("size", &serverSize);
serverSize = pkg->IntAttribute("size");
}
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 "AquariaProgressBar.h"
#include "tinyxml.h"
#include "ModSelector.h"
#include <algorithm>
@ -30,6 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ModDownloader.h"
#endif
#include "tinyxml2.h"
using namespace tinyxml2;
#define MOD_ICON_SIZE 150
#define MINI_ICON_SIZE 32
@ -551,16 +553,16 @@ void ModIcon::loadEntry(const ModEntry& entry)
useQuad(texToLoad);
quad->setWidthHeight(MOD_ICON_SIZE, MOD_ICON_SIZE);
TiXmlDocument d;
XMLDocument d;
dsq->mod.loadModXML(&d, entry.path);
std::string ds = dsq->continuity.stringBank.get(2009);
TiXmlElement *top = d.FirstChildElement("AquariaMod");
XMLElement *top = d.FirstChildElement("AquariaMod");
if (top)
{
TiXmlElement *desc = top->FirstChildElement("Description");
XMLElement *desc = top->FirstChildElement("Description");
if (desc)
{
if (desc->Attribute("text"))
@ -568,7 +570,7 @@ void ModIcon::loadEntry(const ModEntry& entry)
ds = desc->Attribute("text");
}
}
TiXmlElement *fullname = top->FirstChildElement("Fullname");
XMLElement *fullname = top->FirstChildElement("Fullname");
if (fullname)
{
if (fullname->Attribute("text"))

View file

@ -1169,7 +1169,7 @@ void SceneEditor::deleteSelected()
void SceneEditor::updateSaveFileEnemyPosition(Entity *ent)
{
TiXmlElement *exml = dsq->game->saveFile->FirstChildElement("Enemy");
XMLElement *exml = dsq->game->saveFile->FirstChildElement("Enemy");
while (exml)
{
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 "Avatar.h"
#else
#include "../ExternalLibs/tinyxml.h"
#include "tinyxml2.h"
using namespace tinyxml2;
#endif
@ -33,274 +34,249 @@ void UserSettings::save()
{
//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);
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);
TiXmlElement xml_unsafe("AllowDangerousScriptFunctions");
XMLElement *xml_unsafe = doc.NewElement("AllowDangerousScriptFunctions");
{
xml_unsafe.SetAttribute("on", system.allowDangerousScriptFunctions);
xml_unsafe->SetAttribute("on", system.allowDangerousScriptFunctions);
}
xml_system.InsertEndChild(xml_unsafe);
xml_system->InsertEndChild(xml_unsafe);
}
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("octave", audio.octave);
xml_microphone->SetAttribute("on", audio.micOn);
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.SetDoubleAttribute("vox", double(audio.voxvol));
xml_volume.SetDoubleAttribute("mus", double(audio.musvol));
xml_volume.SetAttribute("subs", audio.subtitles);
xml_volume->SetAttribute("sfx", double(audio.sfxvol));
xml_volume->SetAttribute("vox", double(audio.voxvol));
xml_volume->SetAttribute("mus", double(audio.musvol));
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);
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;
os << video.parallaxOn0 << " " << video.parallaxOn1 << " " << video.parallaxOn2;
xml_parallax.SetAttribute("on", os.str());
xml_video.InsertEndChild(xml_parallax);
xml_parallax->SetAttribute("on", os.str().c_str());
xml_video->InsertEndChild(xml_parallax);
TiXmlElement xml_numParticles("NumParticles");
xml_numParticles.SetAttribute("v", video.numParticles);
xml_video.InsertEndChild(xml_numParticles);
XMLElement *xml_numParticles = doc.NewElement("NumParticles");
xml_numParticles->SetAttribute("v", video.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("resy", video.resy);
xml_screenMode.SetAttribute("bits", video.bits);
xml_screenMode.SetAttribute("fbuffer", video.fbuffer);
xml_screenMode.SetAttribute("full", video.full);
xml_screenMode.SetAttribute("vsync", video.vsync);
xml_screenMode.SetAttribute("darkfbuffer", video.darkfbuffer);
xml_screenMode.SetAttribute("darkbuffersize", video.darkbuffersize);
xml_screenMode.SetAttribute("displaylists", video.displaylists);
xml_screenMode->SetAttribute("resx", video.resx);
xml_screenMode->SetAttribute("resy", video.resy);
xml_screenMode->SetAttribute("bits", video.bits);
xml_screenMode->SetAttribute("fbuffer", video.fbuffer);
xml_screenMode->SetAttribute("full", video.full);
xml_screenMode->SetAttribute("vsync", video.vsync);
xml_screenMode->SetAttribute("darkfbuffer", video.darkfbuffer);
xml_screenMode->SetAttribute("darkbuffersize", video.darkbuffersize);
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);
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("s1ay", control.s1ay);
xml_joyAxes.SetAttribute("s2ax", control.s2ax);
xml_joyAxes.SetAttribute("s2ay", control.s2ay);
xml_joyAxes.SetDoubleAttribute("s1dead", double(control.s1dead));
xml_joyAxes.SetDoubleAttribute("s2dead", double(control.s2dead));
xml_joyAxes->SetAttribute("s1ax", control.s1ax);
xml_joyAxes->SetAttribute("s1ay", control.s1ay);
xml_joyAxes->SetAttribute("s2ax", control.s2ax);
xml_joyAxes->SetAttribute("s2ay", control.s2ay);
xml_joyAxes->SetAttribute("s1dead", double(control.s1dead));
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++)
{
TiXmlElement xml_action("Action");
XMLElement *xml_action = doc.NewElement("Action");
ActionInput *actionInput = &control.actionSet.inputSet[i];
xml_action.SetAttribute("name", actionInput->name);
xml_action.SetAttribute("input", actionInput->toString());
xml_action->SetAttribute("name", actionInput->name.c_str());
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);
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);
TiXmlElement xml_data("Data");
XMLElement *xml_data = doc.NewElement("Data");
{
xml_data.SetAttribute("savePage", data.savePage);
xml_data.SetAttribute("saveSlot", data.saveSlot);
xml_data->SetAttribute("savePage", data.savePage);
xml_data->SetAttribute("saveSlot", data.saveSlot);
std::ostringstream ss;
for (std::set<std::string>::iterator it = dsq->activePatches.begin(); it != dsq->activePatches.end(); ++it)
ss << *it << " ";
xml_data.SetAttribute("activePatches", ss.str());
xml_data->SetAttribute("activePatches", ss.str().c_str());
}
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);
}
#if defined(BBGE_BUILD_UNIX)
doc.SaveFile(dsq->getPreferencesFolder() + "/" + userSettingsFilename);
doc.SaveFile((dsq->getPreferencesFolder() + "/" + userSettingsFilename).c_str());
#elif defined(BBGE_BUILD_WINDOWS)
doc.SaveFile(userSettingsFilename);
doc.SaveFile(userSettingsFilename.c_str());
#endif
//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)
{
TiXmlElement *xml2 = xml->FirstChildElement(elem);
if (xml2)
{
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);
}
}
XMLElement *xml2 = xml->FirstChildElement(elem);
if (xml2) xml2->QueryIntAttribute(att, toChange);
}
}
@ -325,23 +301,23 @@ void UserSettings::loadDefaults(bool doApply)
void UserSettings::load(bool doApply, const std::string &overrideFile)
{
TiXmlDocument doc;
XMLDocument doc;
#if defined(BBGE_BUILD_UNIX)
doc.LoadFile(dsq->getPreferencesFolder() + "/" + userSettingsFilename);
doc.LoadFile((dsq->getPreferencesFolder() + "/" + userSettingsFilename).c_str());
#elif defined(BBGE_BUILD_WINDOWS)
if (!overrideFile.empty())
doc.LoadFile(overrideFile);
doc.LoadFile(overrideFile.c_str());
else
doc.LoadFile(userSettingsFilename);
doc.LoadFile(userSettingsFilename.c_str());
#endif
version.settingsVersion = 0;
TiXmlElement *xml_version = doc.FirstChildElement("Version");
XMLElement *xml_version = doc.FirstChildElement("Version");
if (xml_version)
{
xml_version->Attribute("settingsVersion", &version.settingsVersion);
version.settingsVersion = xml_version->IntAttribute("settingsVersion");
}
control.actionSet.clearActions();
@ -368,67 +344,66 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
control.actionSet.addActionInput("Look");
control.actionSet.addActionInput("ToggleHelp");
TiXmlElement *xml_system = doc.FirstChildElement("System");
XMLElement *xml_system = doc.FirstChildElement("System");
if (xml_system)
{
TiXmlElement *xml_debugLog = xml_system->FirstChildElement("DebugLog");
XMLElement *xml_debugLog = xml_system->FirstChildElement("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)
{
system.locale = xml_locale->Attribute("name");
}
TiXmlElement *xml_devmode = xml_system->FirstChildElement("DeveloperMode");
XMLElement *xml_devmode = xml_system->FirstChildElement("DeveloperMode");
if (xml_devmode)
{
xml_devmode->Attribute("on", &system.devModeOn);
system.devModeOn = xml_devmode->IntAttribute("on");
}
TiXmlElement *xml_unsafe = xml_system->FirstChildElement("AllowDangerousScriptFunctions");
XMLElement *xml_unsafe = xml_system->FirstChildElement("AllowDangerousScriptFunctions");
if (xml_unsafe)
{
xml_unsafe->Attribute("on", &system.allowDangerousScriptFunctions);
system.allowDangerousScriptFunctions = xml_unsafe->IntAttribute("on");
}
}
TiXmlElement *xml_audio = doc.FirstChildElement("Audio");
XMLElement *xml_audio = doc.FirstChildElement("Audio");
if (xml_audio)
{
TiXmlElement *xml_microphone = xml_audio->FirstChildElement("Mic");
XMLElement *xml_microphone = xml_audio->FirstChildElement("Mic");
if (xml_microphone)
{
xml_microphone->Attribute("on", &audio.micOn);
xml_microphone->Attribute("octave", &audio.octave);
audio.micOn = xml_microphone->IntAttribute("on");
audio.octave = xml_microphone->IntAttribute("octave");
}
TiXmlElement *xml_volume = xml_audio->FirstChildElement("Volume");
XMLElement *xml_volume = xml_audio->FirstChildElement("Volume");
if (xml_volume)
{
double d;
xml_volume->Attribute("sfx", &d), audio.sfxvol = d;
xml_volume->Attribute("vox", &d), audio.voxvol = d;
xml_volume->Attribute("mus", &d), audio.musvol = d;
xml_volume->Attribute("subs", &audio.subtitles);
audio.sfxvol = xml_volume->DoubleAttribute("sfx");
audio.voxvol = xml_volume->DoubleAttribute("vox");
audio.musvol = xml_volume->DoubleAttribute("mus");
audio.subtitles = xml_volume->IntAttribute("subs");
}
TiXmlElement *xml_device = xml_audio->FirstChildElement("Device");
XMLElement *xml_device = xml_audio->FirstChildElement("Device");
if (xml_device)
{
audio.deviceName = xml_device->Attribute("name");
}
TiXmlElement *xml_prebuf = xml_audio->FirstChildElement("Prebuffer");
XMLElement *xml_prebuf = xml_audio->FirstChildElement("Prebuffer");
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)
{
readInt(xml_video, "Blur", "on", &video.blur);
@ -440,7 +415,7 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
/*
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->Attribute("on"))
@ -452,18 +427,18 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
readInt(xml_video, "NumParticles", "v", &video.numParticles);
TiXmlElement *xml_screenMode = xml_video->FirstChildElement("ScreenMode");
XMLElement *xml_screenMode = xml_video->FirstChildElement("ScreenMode");
if (xml_screenMode)
{
readIntAtt(xml_screenMode, "resx", &video.resx);
readIntAtt(xml_screenMode, "resy", &video.resy);
readIntAtt(xml_screenMode, "bits", &video.bits);
readIntAtt(xml_screenMode, "fbuffer", &video.fbuffer);
readIntAtt(xml_screenMode, "full", &video.full);
readIntAtt(xml_screenMode, "vsync", &video.vsync);
readIntAtt(xml_screenMode, "darkfbuffer", &video.darkfbuffer);
readIntAtt(xml_screenMode, "darkbuffersize", &video.darkbuffersize);
readIntAtt(xml_screenMode, "displaylists", &video.displaylists);
xml_screenMode->QueryIntAttribute("resx", &video.resx);
xml_screenMode->QueryIntAttribute("resy", &video.resy);
xml_screenMode->QueryIntAttribute("bits", &video.bits);
xml_screenMode->QueryIntAttribute("fbuffer", &video.fbuffer);
xml_screenMode->QueryIntAttribute("full", &video.full);
xml_screenMode->QueryIntAttribute("vsync", &video.vsync);
xml_screenMode->QueryIntAttribute("darkfbuffer", &video.darkfbuffer);
xml_screenMode->QueryIntAttribute("darkbuffersize", &video.darkbuffersize);
xml_screenMode->QueryIntAttribute("displaylists", &video.displaylists);
}
readInt(xml_video, "SaveSlotScreens", "on", &video.saveSlotScreens);
@ -471,7 +446,7 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
readInt(xml_video, "WorldMap", "revealMethod", &video.worldMapRevealMethod);
}
TiXmlElement *xml_control = doc.FirstChildElement("Control");
XMLElement *xml_control = doc.FirstChildElement("Control");
if (xml_control)
{
readInt(xml_control, "JoystickEnabled", "on", &control.joystickEnabled);
@ -480,30 +455,25 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
readInt(xml_control, "Targeting", "on", &control.targeting);
TiXmlElement *xml_joyCursorSpeed = xml_control->FirstChildElement("JoyCursorSpeed");
XMLElement *xml_joyCursorSpeed = xml_control->FirstChildElement("JoyCursorSpeed");
if (xml_joyCursorSpeed)
{
double d;
if (xml_joyCursorSpeed->Attribute("v"))
xml_joyCursorSpeed->Attribute("v", &d), control.joyCursorSpeed = d;
}
xml_joyCursorSpeed->QueryFloatAttribute("v", &control.joyCursorSpeed);
TiXmlElement *xml_joyAxes = xml_control->FirstChildElement("JoyAxes");
XMLElement *xml_joyAxes = xml_control->FirstChildElement("JoyAxes");
if (xml_joyAxes)
{
xml_joyAxes->Attribute("s1ax", &control.s1ax);
xml_joyAxes->Attribute("s1ay", &control.s1ay);
xml_joyAxes->Attribute("s2ax", &control.s2ax);
xml_joyAxes->Attribute("s2ay", &control.s2ay);
double d;
xml_joyAxes->Attribute("s1dead", &d), control.s1dead = d;
xml_joyAxes->Attribute("s2dead", &d), control.s2dead = d;
control.s1ax = xml_joyAxes->IntAttribute("s1ax");
control.s1ay = xml_joyAxes->IntAttribute("s1ay");
control.s2ax = xml_joyAxes->IntAttribute("s2ax");
control.s2ay = xml_joyAxes->IntAttribute("s2ay");
control.s1dead = xml_joyAxes->DoubleAttribute("s1dead");
control.s2dead = xml_joyAxes->DoubleAttribute("s2dead");
}
TiXmlElement *xml_actionSet = xml_control->FirstChildElement("ActionSet");
XMLElement *xml_actionSet = xml_control->FirstChildElement("ActionSet");
if (xml_actionSet)
{
TiXmlElement *xml_action = 0;
XMLElement *xml_action = 0;
xml_action = xml_actionSet->FirstChildElement();
while (xml_action)
{
@ -522,7 +492,7 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
readInt(xml_control, "ToolTipsOn", "on", &control.toolTipsOn);
}
TiXmlElement *xml_demo = doc.FirstChildElement("Demo");
XMLElement *xml_demo = doc.FirstChildElement("Demo");
if (xml_demo)
{
readInt(xml_demo, "WarpKeys", "on", &demo.warpKeys);
@ -530,11 +500,11 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
readInt(xml_demo, "ShortLogos", "on", &demo.shortLogos);
}
TiXmlElement *xml_data = doc.FirstChildElement("Data");
XMLElement *xml_data = doc.FirstChildElement("Data");
if (xml_data)
{
readIntAtt(xml_data, "savePage", &data.savePage);
readIntAtt(xml_data, "saveSlot", &data.saveSlot);
xml_data->QueryIntAttribute("savePage", &data.savePage);
xml_data->QueryIntAttribute("saveSlot", &data.saveSlot);
if(const char *patchlist = xml_data->Attribute("activePatches"))
{
@ -549,7 +519,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)
{
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());
TiXmlElement *e = doc.FirstChildElement("time");
XMLElement *e = doc.FirstChildElement("time");
while (e)
{
CutsceneMarker m;
@ -94,7 +94,7 @@ void Cutscene::playMarker(CutsceneMarker *m)
{
if (m)
{
TiXmlElement *r=0;
XMLElement *r=0;
if (r = m->e->FirstChildElement("quad"))
{
id = r->Attribute("id");

View file

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct CutsceneMarker
{
float t;
TiXmlElement *e;
XMLElement *e;
};
class Cutscene
@ -40,7 +40,7 @@ public:
void update(float dt);
TiXmlDocument file;
XMLDocument file;
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.
*/
#include "SkeletalSprite.h"
#include "../ExternalLibs/tinyxml.h"
#include "Core.h"
#include "Particles.h"
#include "MathFunctions.h"
#include "SimpleIStringStream.h"
#include "tinyxml2.h"
using namespace tinyxml2;
std::string SkeletalSprite::animationPath = "data/animations/";
std::string SkeletalSprite::skinPath = "skins/";
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];
if (!doc.RootElement())
doc.LoadFile(name);
XMLDocument *doc = skelCache[name];
if (!doc) {
doc = new XMLDocument();
doc->LoadFile(name.c_str());
skelCache[name] = doc;
}
return doc;
}
void SkeletalSprite::clearCache()
{
for (std::map<std::string, XMLDocument*>::iterator i = skelCache.begin(); i != skelCache.end(); i++)
delete i->second;
skelCache.clear();
}
@ -862,13 +870,13 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
}
int i = 0;
TiXmlDocument& xml = _retrieveSkeletalXML(file);
xml.Clear();
XMLDocument *xml = _retrieveSkeletalXML(file);
xml->Clear();
TiXmlElement animationLayers("AnimationLayers");
XMLElement *animationLayers = xml->NewElement("AnimationLayers");
for (i = 0; i < animLayers.size(); i++)
{
TiXmlElement animationLayer("AnimationLayer");
XMLElement *animationLayer = xml->NewElement("AnimationLayer");
if (animLayers[i].ignoreBones.size() > 0)
{
std::ostringstream os;
@ -876,7 +884,7 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
{
os << animLayers[i].ignoreBones[j] << " ";
}
animationLayer.SetAttribute("ignore", os.str());
animationLayer->SetAttribute("ignore", os.str().c_str());
}
if (animLayers[i].includeBones.size() > 0)
{
@ -885,33 +893,33 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
{
os << animLayers[i].includeBones[j] << " ";
}
animationLayer.SetAttribute("include", os.str());
animationLayer->SetAttribute("include", os.str().c_str());
}
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++)
{
TiXmlElement bone("Bone");
bone.SetAttribute("idx", this->bones[i]->boneIdx);
bone.SetAttribute("gfx", this->bones[i]->gfx);
bone.SetAttribute("pidx", this->bones[i]->pidx);
bone.SetAttribute("name", this->bones[i]->name);
bone.SetAttribute("fh", this->bones[i]->isfh());
bone.SetAttribute("fv", this->bones[i]->isfv());
bone.SetAttribute("gc", this->bones[i]->generateCollisionMask);
bone.SetAttribute("cr", this->bones[i]->collideRadius);
XMLElement *bone = xml->NewElement("Bone");
bone->SetAttribute("idx", this->bones[i]->boneIdx);
bone->SetAttribute("gfx", this->bones[i]->gfx.c_str());
bone->SetAttribute("pidx", this->bones[i]->pidx);
bone->SetAttribute("name", this->bones[i]->name.c_str());
bone->SetAttribute("fh", this->bones[i]->isfh());
bone->SetAttribute("fv", this->bones[i]->isfv());
bone->SetAttribute("gc", this->bones[i]->generateCollisionMask);
bone->SetAttribute("cr", this->bones[i]->collideRadius);
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())
{
@ -924,49 +932,49 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
r->getCWH(&x, &y, &w, &h);
os << x << " " << y << " " << w << " " << h << " ";
}
bone.SetAttribute("crects", os.str());
bone->SetAttribute("crects", os.str().c_str());
}
std::ostringstream os;
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)
bone.SetAttribute("rbp", this->bones[i]->rbp);
bone->SetAttribute("rbp", this->bones[i]->rbp);
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)
bone.SetAttribute("offx", this->bones[i]->offset.x);
bone->SetAttribute("offx", this->bones[i]->offset.x);
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())
bone.SetAttribute("prt", this->bones[i]->prt);
bone->SetAttribute("prt", this->bones[i]->prt.c_str());
if (!this->bones[i]->changeStrip.empty())
{
std::ostringstream os;
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())
{
std::ostringstream os;
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())
{
bone.SetAttribute("rt", 1);
bone->SetAttribute("rt", 1);
}
if (this->bones[i]->originalScale.x != 1 || this->bones[i]->originalScale.y != 1)
{
std::ostringstream os;
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)
{
std::ostringstream os;
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);
if (q && !b && !p)
{
TiXmlElement frame("Frame");
frame.SetAttribute("gfx", q->texture->name);
XMLElement *frame = xml->NewElement("Frame");
frame->SetAttribute("gfx", q->texture->name.c_str());
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++)
{
Animation *a = &this->animations[i];
TiXmlElement animation("Animation");
animation.SetAttribute("name", a->name);
XMLElement *animation = xml->NewElement("Animation");
animation->SetAttribute("name", a->name.c_str());
for (int j = 0; j < a->keyframes.size(); j++)
{
TiXmlElement key("Key");
XMLElement *key = xml->NewElement("Key");
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())
{
key.SetAttribute("cmd", a->keyframes[j].cmd);
key->SetAttribute("cmd", a->keyframes[j].cmd.c_str());
}
if (a->keyframes[j].lerpType != 0)
{
key.SetAttribute("lerp", a->keyframes[j].lerpType);
key->SetAttribute("lerp", a->keyframes[j].lerpType);
}
std::ostringstream os;
os << a->keyframes[j].t << " ";
@ -1028,16 +1036,16 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
}
std::string szoss = szos.str();
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);
return xml.SaveFile(file);
xml->InsertEndChild(animations);
return xml->SaveFile(file.c_str());
}
int SkeletalSprite::getBoneIdx(Bone *b)
@ -1181,12 +1189,12 @@ void SkeletalSprite::loadSkin(const std::string &fn)
errorLog("Could not load skin[" + file + "]");
return;
}
TiXmlDocument& d = _retrieveSkeletalXML(file);
XMLDocument *d = _retrieveSkeletalXML(file);
TiXmlElement *bonesXml = d.FirstChildElement("Bones");
XMLElement *bonesXml = d->FirstChildElement("Bones");
if (bonesXml)
{
TiXmlElement *boneXml = bonesXml->FirstChildElement("Bone");
XMLElement *boneXml = bonesXml->FirstChildElement("Bone");
while (boneXml)
{
int idx = atoi(boneXml->Attribute("idx"));
@ -1316,10 +1324,10 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
loaded = true;
TiXmlDocument& xml = _retrieveSkeletalXML(file);
xml.LoadFile(file.c_str());
XMLDocument *xml = _retrieveSkeletalXML(file);
xml->LoadFile(file.c_str());
TiXmlElement *bones = xml.FirstChildElement("Bones");
XMLElement *bones = xml->FirstChildElement("Bones");
if (bones)
{
if (bones->Attribute("scale"))
@ -1328,7 +1336,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
is >> scale.x >> scale.y;
}
TiXmlElement *bone = bones->FirstChildElement("Bone");
XMLElement *bone = bones->FirstChildElement("Bone");
while(bone)
{
int idx = atoi(bone->Attribute("idx"));
@ -1400,7 +1408,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
//e->start();
}
}
TiXmlElement *fr=0;
XMLElement *fr=0;
fr = bone->FirstChildElement("Frame");
int frc=0;
while(fr)
@ -1528,10 +1536,10 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
}
animLayers.clear();
TiXmlElement *animationLayers = xml.FirstChildElement("AnimationLayers");
XMLElement *animationLayers = xml->FirstChildElement("AnimationLayers");
if (animationLayers)
{
TiXmlElement *animationLayer = animationLayers->FirstChildElement("AnimationLayer");
XMLElement *animationLayer = animationLayers->FirstChildElement("AnimationLayer");
while (animationLayer)
{
AnimationLayer newAnimationLayer;
@ -1564,17 +1572,17 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
}
animations.clear();
TiXmlElement *animations = xml.FirstChildElement("Animations");
XMLElement *animations = xml->FirstChildElement("Animations");
if (animations)
{
TiXmlElement *animation = animations->FirstChildElement("Animation");
XMLElement *animation = animations->FirstChildElement("Animation");
while(animation)
{
Animation newAnimation;
newAnimation.name = animation->Attribute("name");
stringToLower(newAnimation.name);
TiXmlElement *key = animation->FirstChildElement("Key");
XMLElement *key = animation->FirstChildElement("Key");
while (key)
{
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,18 @@ if (NOT OPENAL_FOUND)
endif(WIN32)
endif (NOT OPENAL_FOUND)
### TinyXML2
OPTION(AQUARIA_INTERNAL_TINYXML2 "Always use included TinyXML2 library" ${WIN32_TRUE})
if(NOT AQUARIA_INTERNAL_TINYXML2)
find_package(TinyXML2)
endif(NOT AQUARIA_INTERNAL_TINYXML2)
if (AQUARIA_INTERNAL_TINYXML2 OR NOT TINYXML2_FOUND)
message(STATUS "Using internal copy of TinyXML2")
set(TINYXML2_INCLUDE_DIR "${EXTLIBDIR}")
set(TINYXML2_SRCS "${EXTLIBDIR}/tinyxml2.cpp")
endif (AQUARIA_INTERNAL_TINYXML2 OR NOT TINYXML2_FOUND)
################ End of external libraries
INCLUDE_DIRECTORIES(${BBGEDIR})
@ -235,6 +247,7 @@ INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${TINYXML2_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${EXTLIBDIR})
@ -334,6 +347,9 @@ IF(CMAKE_COMPILER_IS_GNUCC)
ADD_DEFINITIONS(-fno-stack-protector)
ENDIF(AQUARIA_GCC_HAS_STACKPROT)
# We knowingly apply offsetof to non-POD types.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
# -O3 breaks on some GCC/MinGW versions, make sure CMake does not set this as default.
# Exceptions are not used, excluding support for release builds adds less bulk as well.
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "Flags used for release builds" FORCE)
@ -486,9 +502,6 @@ SET(BBGE_SRCS
${EXTLIBDIR}/DeflateCompressor.cpp
${EXTLIBDIR}/glfont2/glfont2.cpp
${EXTLIBDIR}/glpng/glpng.c
${EXTLIBDIR}/tinyxml.cpp
${EXTLIBDIR}/tinyxmlerror.cpp
${EXTLIBDIR}/tinyxmlparser.cpp
${EXTLIBDIR}/minihttp.cpp
${EXTLIBDIR}/JPS.h
)
@ -741,6 +754,12 @@ ELSE(OGGVORBIS_FOUND)
SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${OGGVORBIS_SRCS})
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}
${AQUARIA_SRCS}
${BBGE_SRCS}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

2186
ExternalLibs/tinyxml2.cpp Normal file

File diff suppressed because it is too large Load diff

2076
ExternalLibs/tinyxml2.h Normal file

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)

View file

@ -189,22 +189,6 @@
RelativePath="..\..\ExternalLibs\minihttp.h"
>
</File>
<File
RelativePath="..\..\ExternalLibs\tinyxml.cpp"
>
</File>
<File
RelativePath="..\..\ExternalLibs\tinyxml.h"
>
</File>
<File
RelativePath="..\..\ExternalLibs\tinyxmlerror.cpp"
>
</File>
<File
RelativePath="..\..\ExternalLibs\tinyxmlparser.cpp"
>
</File>
<Filter
Name="glpng"
>
@ -1566,6 +1550,18 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="tinyxml2"
>
<File
RelativePath="..\..\ExternalLibs\tinyxml2.cpp"
>
</File>
<File
RelativePath="..\..\ExternalLibs\tinyxml2.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>