Peoplemon  0.1.0
Peoplemon 3 game source documentation
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
core::file::GameSave Struct Reference

Represents a game save and provides functionality to load and save. More...

#include <GameSave.hpp>

Classes

struct  ClockPointers
 Stores the date in game. More...
 
struct  InteractDataPointers
 Stores pointers to the actual data to save/load from. More...
 
struct  PlayerDataPointers
 Stores pointers to the actual data to save/load from. More...
 
struct  ScriptDataPointers
 Stores pointers to the actual data to save/load from. More...
 
struct  TrainerPointers
 Stores defeated trainer information. More...
 
struct  WorldDataPointers
 Stores pointers to the actual data to save/load from. More...
 

Public Member Functions

 GameSave ()
 Initializes all pointers to the local members. More...
 
bool load ()
 Loads the save represented by this object and fires an event::GameSaveLoaded event to allow systems to populate their data. More...
 
void editorSave ()
 Saves the data back to the file it was loaded from. More...
 
bool remove () const
 Deletes the game save. More...
 
bool operator< (const GameSave &rhs) const
 For sorting. More...
 
void useLocalData ()
 Instantiates the save data in this object and sets all the pointers to it. Useful for loading a save without populating the game systems. More...
 

Static Public Member Functions

static void listSaves (std::vector< GameSave > &result)
 Lists all saves in the save directory. More...
 
static bool saveGame (const std::string &name)
 Saves the game. Fires an event::GameSaveInitializing event for systems to add their data to the save before it is written. More...
 
static bool loadFromFile (const std::string &sourceFile)
 Loads the game from the given save file. More...
 
static std::string filename (const std::string &saveName)
 Returns the filename for the given save name. More...
 

Public Attributes

unsigned long long saveTime
 Local timestamp that the save was modified on. More...
 
std::string saveName
 Same as the player name but always valid. More...
 
struct core::file::GameSave::InteractDataPointers interaction
 
struct core::file::GameSave::PlayerDataPointers player
 
struct core::file::GameSave::WorldDataPointers world
 
struct core::file::GameSave::ScriptDataPointers scripts
 
struct core::file::GameSave::ClockPointers clock
 
struct core::file::GameSave::TrainerPointers trainers
 

Detailed Description

Represents a game save and provides functionality to load and save.

Definition at line 24 of file GameSave.hpp.

Constructor & Destructor Documentation

◆ GameSave()

core::file::GameSave::GameSave ( )

Initializes all pointers to the local members.

Definition at line 152 of file GameSave.cpp.

Member Function Documentation

◆ editorSave()

void core::file::GameSave::editorSave ( )

Saves the data back to the file it was loaded from.

Definition at line 84 of file GameSave.cpp.

◆ filename()

std::string core::file::GameSave::filename ( const std::string &  saveName)
static

Returns the filename for the given save name.

Parameters
saveNameThe name of the player in the save
Returns
The filename to load or save from

Definition at line 180 of file GameSave.cpp.

◆ listSaves()

void core::file::GameSave::listSaves ( std::vector< GameSave > &  result)
static

Lists all saves in the save directory.

Parameters
resultVector to populate with found saves

Definition at line 40 of file GameSave.cpp.

◆ load()

bool core::file::GameSave::load ( )

Loads the save represented by this object and fires an event::GameSaveLoaded event to allow systems to populate their data.

Returns
True on success, false on error

Definition at line 90 of file GameSave.cpp.

◆ loadFromFile()

bool core::file::GameSave::loadFromFile ( const std::string &  sourceFile)
static

Loads the game from the given save file.

Parameters
sourceFileThe file to load from
Returns
True on success, false on error

Definition at line 78 of file GameSave.cpp.

◆ operator<()

bool core::file::GameSave::operator< ( const GameSave rhs) const

For sorting.

Parameters
rhsThe save to compare to
Returns
True if should come first, false if not

Definition at line 116 of file GameSave.cpp.

◆ remove()

bool core::file::GameSave::remove ( ) const

Deletes the game save.

Returns
True on success, false on error

Definition at line 114 of file GameSave.cpp.

◆ saveGame()

bool core::file::GameSave::saveGame ( const std::string &  name)
static

Saves the game. Fires an event::GameSaveInitializing event for systems to add their data to the save before it is written.

Parameters
nameThe name of the player
Returns
True if the game could be saved, false on error

Definition at line 62 of file GameSave.cpp.

◆ useLocalData()

void core::file::GameSave::useLocalData ( )

Instantiates the save data in this object and sets all the pointers to it. Useful for loading a save without populating the game systems.

Definition at line 121 of file GameSave.cpp.

Member Data Documentation

◆ clock

struct core::file::GameSave::ClockPointers core::file::GameSave::clock

◆ interaction

struct core::file::GameSave::InteractDataPointers core::file::GameSave::interaction

◆ player

struct core::file::GameSave::PlayerDataPointers core::file::GameSave::player

◆ saveName

std::string core::file::GameSave::saveName

Same as the player name but always valid.

Definition at line 29 of file GameSave.hpp.

◆ saveTime

unsigned long long core::file::GameSave::saveTime

Local timestamp that the save was modified on.

Definition at line 26 of file GameSave.hpp.

◆ scripts

struct core::file::GameSave::ScriptDataPointers core::file::GameSave::scripts

◆ trainers

struct core::file::GameSave::TrainerPointers core::file::GameSave::trainers

◆ world

struct core::file::GameSave::WorldDataPointers core::file::GameSave::world

The documentation for this struct was generated from the following files: