2015-05-03 06:22:03 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef _SAVEGAME_HPP_
|
|
|
|
#define _SAVEGAME_HPP_
|
|
|
|
|
|
|
|
#include <engine/RWTypes.hpp>
|
|
|
|
|
|
|
|
#include <string>
|
2015-06-14 19:08:55 +02:00
|
|
|
#include <vector>
|
2015-05-03 06:22:03 +02:00
|
|
|
|
|
|
|
struct GameState;
|
|
|
|
class GameWorld;
|
|
|
|
class ScriptMachine;
|
|
|
|
|
2015-06-14 19:08:55 +02:00
|
|
|
struct SaveGameInfo
|
|
|
|
{
|
|
|
|
std::string saveName;
|
|
|
|
std::string savePath;
|
|
|
|
};
|
|
|
|
|
2015-05-03 06:22:03 +02:00
|
|
|
/**
|
|
|
|
* Reads and Writes GameStates to disk, restoring the required state information
|
|
|
|
*/
|
|
|
|
class SaveGame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2015-06-14 03:44:51 +02:00
|
|
|
/**
|
|
|
|
* Writes the entire game state to a file format that closely approximates
|
|
|
|
* the format used in GTA III
|
|
|
|
*/
|
|
|
|
static void writeGame(GameState& state, const std::string& file);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads an entire Game State from a file, using a format similar to the
|
|
|
|
* format used by GTA III.
|
|
|
|
*
|
|
|
|
* It assumes that the state already has a world and script that have been
|
|
|
|
* initalized to the same state as the game being loaded.
|
|
|
|
* @return status, false if failure occured.
|
|
|
|
*/
|
|
|
|
static bool loadGame(GameState& state, const std::string& file);
|
|
|
|
|
2015-06-14 19:08:55 +02:00
|
|
|
static SaveGameInfo getSaveInfo(const std::string& file);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns save game information for all found saves
|
|
|
|
*/
|
|
|
|
static std::vector<SaveGameInfo> getAllSaveGameInfo();
|
|
|
|
|
2015-06-14 03:44:51 +02:00
|
|
|
/**
|
|
|
|
* Writes the current game state out into a file suitable for loading later.
|
|
|
|
*/
|
2015-05-03 06:22:03 +02:00
|
|
|
static void writeState(GameState& state, const std::string& file);
|
|
|
|
|
|
|
|
static bool loadState(GameState& state, const std::string& file);
|
|
|
|
|
|
|
|
static void writeScript(ScriptMachine& sm, const std::string& file);
|
|
|
|
|
|
|
|
static bool loadScript(ScriptMachine&, const std::string& file);
|
|
|
|
|
|
|
|
static void writeObjects(GameWorld& world, const std::string& file);
|
|
|
|
|
|
|
|
static bool loadObjects(GameWorld& world, const std::string& file);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|