Commit 272eee97 authored by Gerhard Stein's avatar Gerhard Stein

More Code for galaxy savegame controller

parent 55a300cc
......@@ -91,4 +91,14 @@ void CInventory::drawStatus()
mp_StatusScreen->draw();
}
void CInventory::operator>>(CSaveGameController &savedGame)
{
savedGame.encodeData(Item);
}
void CInventory::operator<<(CSaveGameController &savedGame)
{
savedGame.decodeData(Item);
}
......@@ -15,6 +15,7 @@
#include "common/CHUD.h"
#include "ItemsGalaxy.h"
#include "CStatusScreenGalaxy.h"
#include "fileio/CSaveGameController.h"
#include "SmartPointer.h"
#include <string>
#include <SDL.h>
......@@ -38,6 +39,12 @@ public:
// make the status get opened or closed
void toggleStatusScreen();
// Saves the inventory using the Savegamecontroller.
void operator>>(CSaveGameController &savedGame);
// This is for loading the game
void operator<<(CSaveGameController &savedGame);
stItemGalaxy Item;
CHUD m_HUD;
......
......@@ -14,7 +14,8 @@
namespace galaxy {
class CLevelPlay : public CMapPlayGalaxy {
class CLevelPlay : public CMapPlayGalaxy
{
public:
CLevelPlay(CExeFile &ExeFile, CInventory &Inventory, stCheat &Cheatmode);
......
......@@ -155,6 +155,17 @@ void CMapPlayGalaxy::process(const bool msgboxactive)
}
// Saves the inventory using the Savegamecontroller.
void CMapPlayGalaxy::operator>>(CSaveGameController &savedGame)
{
}
// This is for loading the game
void CMapPlayGalaxy::operator<<(CSaveGameController &savedGame)
{
}
......
......@@ -41,6 +41,13 @@ public:
void process(const bool msgboxactive);
// Push data to Savegame-Controller
void operator>>(CSaveGameController &savedGame);
// This is for loading the game
void operator<<(CSaveGameController &savedGame);
protected:
std::vector<CSpriteObject*> m_ObjectPtr;
bool m_active;
......
......@@ -33,10 +33,80 @@ m_SavedGame(SavedGame)
}
bool CPlayGameGalaxy::loadGameState()
{ return false; }
{
return false;
}
bool CPlayGameGalaxy::saveGameState()
{ return false; }
{
//size_t i;
//size_t size;
CSaveGameController &savedGame = *(gpSaveGameController);
/// Save the Game in the CSavedGame object
// store the episode, level and difficulty
savedGame.encodeData(m_Episode);
savedGame.encodeData(m_Level);
savedGame.encodeData(g_pBehaviorEngine->mDifficulty);
// Save number of Players
savedGame.encodeData(m_NumPlayers);
m_Inventory >> savedGame;
m_WorldMap >> savedGame;
m_LevelPlay >> savedGame;
/*// Now save the inventory of every player
for( i=0 ; i<m_NumPlayers ; i++ )
{
savedGame.encodeData(m_Player[i].getXPosition());
savedGame.encodeData(m_Player[i].getYPosition());
savedGame.encodeData(m_Player[i].blockedd);
savedGame.encodeData(m_Player[i].blockedu);
savedGame.encodeData(m_Player[i].blockedl);
savedGame.encodeData(m_Player[i].blockedr);
savedGame.encodeData(m_Player[i].inventory);
}
size = m_Object.size();
// save the number of objects on screen
savedGame.encodeData(size);
for( i=0 ; i<size ; i++)
{
// save all the objects states
savedGame.encodeData(m_Object[i]->m_type);
savedGame.encodeData(m_Object[i]->getXPosition());
savedGame.encodeData(m_Object[i]->getYPosition());
savedGame.encodeData(m_Object[i]->dead);
savedGame.encodeData(m_Object[i]->onscreen);
savedGame.encodeData(m_Object[i]->hasbeenonscreen);
savedGame.encodeData(m_Object[i]->exists);
savedGame.encodeData(m_Object[i]->blockedd);
savedGame.encodeData(m_Object[i]->blockedu);
savedGame.encodeData(m_Object[i]->blockedl);
savedGame.encodeData(m_Object[i]->blockedr);
savedGame.encodeData(m_Object[i]->mHealthPoints);
savedGame.encodeData(m_Object[i]->canbezapped);
savedGame.encodeData(m_Object[i]->cansupportplayer);
savedGame.encodeData(m_Object[i]->inhibitfall);
savedGame.encodeData(m_Object[i]->honorPriority);
savedGame.encodeData(m_Object[i]->sprite);
}
// Save the map_data as it is left
savedGame.encodeData(mMap->m_width);
savedGame.encodeData(mMap->m_height);
savedGame.addData( reinterpret_cast<byte*>(mMap->getForegroundData()),
2*mMap->m_width*mMap->m_height );
// store completed levels
savedGame.addData( (byte*)(mp_level_completed), MAX_LEVELS_VORTICON );*/
return savedGame.save();
}
// Setup for the ingame
......
......@@ -41,4 +41,5 @@ void CWorldMap::loadAndPlayMusic()
g_pMusicPlayer->play();
}
}
......@@ -14,7 +14,8 @@
namespace galaxy {
class CWorldMap : public CMapPlayGalaxy {
class CWorldMap : public CMapPlayGalaxy
{
public:
CWorldMap(CExeFile &ExeFile, CInventory &Inventory, stCheat &Cheatmode);
......
......@@ -21,7 +21,8 @@
const int WM_MAP_NUM = 80;
class CPlayGame{
class CPlayGame
{
public:
CPlayGame(CExeFile &ExeFile, char level,
char numplayers);
......
......@@ -212,7 +212,8 @@ bool CPlayGameVorticon::saveGameState()
size = m_Object.size();
// save the number of objects on screen
savedGame.encodeData(size);
for( i=0 ; i<size ; i++) {
for( i=0 ; i<size ; i++)
{
// save all the objects states
savedGame.encodeData(m_Object[i]->m_type);
savedGame.encodeData(m_Object[i]->getXPosition());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment