Merge branch 'master' of github.com:Allanis/Unuk

This commit is contained in:
Rtch90 2012-01-07 01:48:01 +00:00
commit 936014d8d9
3 changed files with 54 additions and 7 deletions

View File

@ -1,6 +1,7 @@
<?xml version="1.0" ?>
<save> <save>
<name>Allanis</name> <name>Allanis</name>
<x>150</x> <x>572</x>
<y>150</y> <y>364</y>
<map>map</map> <map>map</map>
</save> </save>

View File

@ -153,6 +153,14 @@
RelativePath="..\..\..\src\libUnuk\ApplySurface.h" RelativePath="..\..\..\src\libUnuk\ApplySurface.h"
> >
</File> </File>
<File
RelativePath="..\..\..\src\libUnuk\AStar.cpp"
>
</File>
<File
RelativePath="..\..\..\src\libUnuk\AStar.h"
>
</File>
<File <File
RelativePath="..\..\..\src\libUnuk\Button.cpp" RelativePath="..\..\..\src\libUnuk\Button.cpp"
> >
@ -277,6 +285,10 @@
RelativePath="..\..\..\src\libUnuk\MemManager.h" RelativePath="..\..\..\src\libUnuk\MemManager.h"
> >
</File> </File>
<File
RelativePath="..\..\..\src\libUnuk\Node.h"
>
</File>
<File <File
RelativePath="..\..\..\src\libUnuk\NPC.cpp" RelativePath="..\..\..\src\libUnuk\NPC.cpp"
> >

View File

@ -147,6 +147,7 @@ void Game::HandleInput(void) {
_ingameMenu.SetStatus(false); _ingameMenu.SetStatus(false);
break; break;
case ingameMenuSaveGame: case ingameMenuSaveGame:
SaveSavegame();
break; break;
case ingameMenuLoadGame: case ingameMenuLoadGame:
break; break;
@ -247,8 +248,41 @@ void Game::LoadSavegame(const string savegameIDArg) {
void Game::SaveSavegame(void) { void Game::SaveSavegame(void) {
string saveFilename = "../Save/" + _saveGameID; string saveFilename = "../Save/" + _saveGameID;
ofstream saveFile(saveFilename.c_str()); TiXmlDocument doc;
assert(saveFile.is_open());
// Write stuff. TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "");
TiXmlElement* saveElement = new TiXmlElement("save");
TiXmlElement* nameElement = new TiXmlElement("name");
TiXmlText* nameText = new TiXmlText("Allanis"); //TODO: replace with _player->GetName() when it works. --konom
nameElement->LinkEndChild(nameText);
char xString[16];
itoa(_player->GetX(), xString, 10);
TiXmlElement* xElement = new TiXmlElement("x");
TiXmlText* xText = new TiXmlText(xString);
xElement->LinkEndChild(xText);
char yString[16];
itoa(_player->GetY(), yString, 10);
TiXmlElement* yElement = new TiXmlElement("y");
TiXmlText* yText = new TiXmlText(yString);
yElement->LinkEndChild(yText);
TiXmlElement* mapElement = new TiXmlElement("map");
TiXmlText* mapText = new TiXmlText("map"); //TODO: replace with actual map name.
mapElement->LinkEndChild(mapText);
saveElement->LinkEndChild(nameElement);
saveElement->LinkEndChild(xElement);
saveElement->LinkEndChild(yElement);
saveElement->LinkEndChild(mapElement);
doc.LinkEndChild(decl);
doc.LinkEndChild(saveElement);
doc.SaveFile(saveFilename.c_str());
} }