2010-03-18 15:09:48 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2010-03-18 15:09:48 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2010-03-18 15:09:48 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ENGINES_SAVESTATE_H
|
|
|
|
#define ENGINES_SAVESTATE_H
|
|
|
|
|
|
|
|
#include "common/array.h"
|
2011-07-02 18:25:32 +00:00
|
|
|
#include "common/str.h"
|
2020-06-13 16:42:25 +00:00
|
|
|
#include "common/ustr.h"
|
2010-03-18 15:09:48 +00:00
|
|
|
#include "common/ptr.h"
|
|
|
|
|
|
|
|
namespace Graphics {
|
2011-04-25 19:29:26 +00:00
|
|
|
struct Surface;
|
2010-03-18 15:09:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-21 01:20:41 +00:00
|
|
|
/**
|
|
|
|
* @defgroup engines_savestate Save states
|
|
|
|
* @ingroup engines
|
|
|
|
*
|
|
|
|
* @brief API for managing save states.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2010-03-18 15:09:48 +00:00
|
|
|
/**
|
2011-07-02 18:25:32 +00:00
|
|
|
* Object describing a save state.
|
|
|
|
*
|
|
|
|
* This at least includes the save slot number and a human readable
|
|
|
|
* description of the save state.
|
|
|
|
*
|
|
|
|
* Further possibilites are a thumbnail, play time, creation date,
|
|
|
|
* creation time, delete protected, write protection.
|
2012-07-03 16:40:40 +00:00
|
|
|
*
|
|
|
|
* Saves are writable and deletable by default.
|
2010-03-18 15:09:48 +00:00
|
|
|
*/
|
2011-07-02 18:25:32 +00:00
|
|
|
class SaveStateDescriptor {
|
2020-02-11 02:55:31 +00:00
|
|
|
private:
|
|
|
|
enum SaveType {
|
|
|
|
kSaveTypeUndetermined,
|
|
|
|
kSaveTypeRegular,
|
|
|
|
kSaveTypeAutosave
|
|
|
|
};
|
2021-08-10 20:34:51 +00:00
|
|
|
|
|
|
|
void initSaveType();
|
2010-03-18 15:09:48 +00:00
|
|
|
public:
|
2011-07-02 18:25:32 +00:00
|
|
|
SaveStateDescriptor();
|
2021-08-10 20:34:51 +00:00
|
|
|
SaveStateDescriptor(int slot, const Common::U32String &d);
|
|
|
|
SaveStateDescriptor(int slot, const Common::String &d);
|
2010-03-18 15:09:48 +00:00
|
|
|
|
2011-07-02 18:25:32 +00:00
|
|
|
/**
|
|
|
|
* @param slot The saveslot id, as it would be passed to the "-x" command line switch.
|
|
|
|
*/
|
|
|
|
void setSaveSlot(int slot) { _slot = slot; }
|
2010-03-18 15:09:48 +00:00
|
|
|
|
2011-07-02 18:25:32 +00:00
|
|
|
/**
|
|
|
|
* @return The saveslot id, as it would be passed to the "-x" command line switch.
|
|
|
|
*/
|
|
|
|
int getSaveSlot() const { return _slot; }
|
2010-03-18 15:09:48 +00:00
|
|
|
|
2011-07-02 18:25:32 +00:00
|
|
|
/**
|
|
|
|
* @param desc A human readable description of the save state.
|
|
|
|
*/
|
2020-08-29 13:38:39 +00:00
|
|
|
void setDescription(const Common::String &desc) { _description = desc.decode(); }
|
2020-06-13 16:42:25 +00:00
|
|
|
void setDescription(const Common::U32String &desc) { _description = desc; }
|
2010-03-18 15:09:48 +00:00
|
|
|
|
2011-07-02 18:25:32 +00:00
|
|
|
/**
|
|
|
|
* @return A human readable description of the save state.
|
|
|
|
*/
|
2020-06-13 16:42:25 +00:00
|
|
|
const Common::U32String &getDescription() const { return _description; }
|
2010-03-18 15:09:48 +00:00
|
|
|
|
|
|
|
/** Optional entries only included when querying via MetaEngine::querySaveMetaInfo */
|
|
|
|
|
|
|
|
/**
|
2011-07-02 18:25:32 +00:00
|
|
|
* Defines whether the save state is allowed to be deleted.
|
2010-03-18 15:09:48 +00:00
|
|
|
*/
|
2011-07-02 18:25:32 +00:00
|
|
|
void setDeletableFlag(bool state) { _isDeletable = state; }
|
2010-03-18 15:09:48 +00:00
|
|
|
|
|
|
|
/**
|
2011-07-02 18:25:32 +00:00
|
|
|
* Queries whether the save state is allowed to be deleted.
|
2010-03-18 15:09:48 +00:00
|
|
|
*/
|
2011-07-02 18:25:32 +00:00
|
|
|
bool getDeletableFlag() const { return _isDeletable; }
|
2010-03-18 15:09:48 +00:00
|
|
|
|
|
|
|
/**
|
2011-07-02 18:25:32 +00:00
|
|
|
* Defines whether the save state is write protected.
|
2010-03-18 15:09:48 +00:00
|
|
|
*/
|
2011-07-02 18:25:32 +00:00
|
|
|
void setWriteProtectedFlag(bool state) { _isWriteProtected = state; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Queries whether the save state is write protected.
|
|
|
|
*/
|
|
|
|
bool getWriteProtectedFlag() const { return _isWriteProtected; }
|
2010-03-18 15:09:48 +00:00
|
|
|
|
2016-06-06 06:22:22 +00:00
|
|
|
/**
|
|
|
|
* Defines whether the save state is "locked" because is being synced.
|
|
|
|
*/
|
|
|
|
void setLocked(bool state) {
|
|
|
|
_isLocked = state;
|
|
|
|
|
|
|
|
//just in case:
|
|
|
|
if (state) {
|
|
|
|
setDeletableFlag(false);
|
|
|
|
setWriteProtectedFlag(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Queries whether the save state is "locked" because is being synced.
|
|
|
|
*/
|
|
|
|
bool getLocked() const { return _isLocked; }
|
|
|
|
|
2010-03-18 15:09:48 +00:00
|
|
|
/**
|
|
|
|
* Return a thumbnail graphics surface representing the savestate visually.
|
|
|
|
* This is usually a scaled down version of the game graphics. The size
|
|
|
|
* should be either 160x100 or 160x120 pixels, depending on the aspect
|
|
|
|
* ratio of the game. If another ratio is required, contact the core team.
|
|
|
|
*/
|
|
|
|
const Graphics::Surface *getThumbnail() const { return _thumbnail.get(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a thumbnail graphics surface representing the savestate visually.
|
|
|
|
* Ownership of the surface is transferred to the SaveStateDescriptor.
|
|
|
|
* Hence the caller must not delete the surface.
|
|
|
|
*/
|
|
|
|
void setThumbnail(Graphics::Surface *t);
|
2017-11-14 18:52:22 +00:00
|
|
|
void setThumbnail(Common::SharedPtr<Graphics::Surface> t) { _thumbnail = t; }
|
2010-03-18 15:09:48 +00:00
|
|
|
|
|
|
|
/**
|
2011-07-02 18:25:32 +00:00
|
|
|
* Sets the date the save state was created.
|
|
|
|
*
|
|
|
|
* @param year Year of creation.
|
|
|
|
* @param month Month of creation.
|
|
|
|
* @param day Day of creation.
|
2010-03-18 15:09:48 +00:00
|
|
|
*/
|
|
|
|
void setSaveDate(int year, int month, int day);
|
|
|
|
|
|
|
|
/**
|
2011-07-02 18:25:32 +00:00
|
|
|
* Queries a human readable description of the date the save state was created.
|
|
|
|
*
|
|
|
|
* This will return an empty string in case the value is not set.
|
|
|
|
*/
|
|
|
|
const Common::String &getSaveDate() const { return _saveDate; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the time the save state was created.
|
|
|
|
*
|
|
|
|
* @param hour Hour of creation.
|
|
|
|
* @param min Minute of creation.
|
2010-03-18 15:09:48 +00:00
|
|
|
*/
|
|
|
|
void setSaveTime(int hour, int min);
|
|
|
|
|
|
|
|
/**
|
2011-07-02 18:25:32 +00:00
|
|
|
* Queries a human readable description of the time the save state was created.
|
|
|
|
*
|
|
|
|
* This will return an empty string in case the value is not set.
|
|
|
|
*/
|
|
|
|
const Common::String &getSaveTime() const { return _saveTime; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the time the game was played before the save state was created.
|
|
|
|
*
|
|
|
|
* @param hours How many hours the user played the game so far.
|
2014-08-29 01:28:43 +00:00
|
|
|
* @param minutes How many minutes the user played the game so far.
|
2010-03-18 15:09:48 +00:00
|
|
|
*/
|
|
|
|
void setPlayTime(int hours, int minutes);
|
2010-10-29 16:41:30 +00:00
|
|
|
|
|
|
|
/**
|
2011-07-02 18:25:32 +00:00
|
|
|
* Sets the time the game was played before the save state was created.
|
|
|
|
*
|
|
|
|
* @param msecs How many milliseconds the user played the game so far.
|
2010-10-29 16:41:30 +00:00
|
|
|
*/
|
|
|
|
void setPlayTime(uint32 msecs);
|
2011-07-02 18:25:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Queries a human readable description of the time the game was played
|
|
|
|
* before the save state was created.
|
|
|
|
*
|
|
|
|
* This will return an empty string in case the value is not set.
|
|
|
|
*/
|
2020-08-29 13:38:39 +00:00
|
|
|
const Common::String &getPlayTime() const { return _playTime; }
|
2011-07-02 18:25:32 +00:00
|
|
|
|
2018-07-13 02:13:22 +00:00
|
|
|
/**
|
|
|
|
* Returns the time the game was played before the save state was created
|
|
|
|
* in milliseconds.
|
|
|
|
*
|
|
|
|
* It defaults to 0.
|
|
|
|
*/
|
|
|
|
uint32 getPlayTimeMSecs() const { return _playTimeMSecs; }
|
|
|
|
|
2020-02-11 02:55:31 +00:00
|
|
|
/**
|
|
|
|
* Sets whether the save is an autosave
|
|
|
|
*/
|
|
|
|
void setAutosave(bool autosave);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true whether the save is an autosave
|
|
|
|
*/
|
|
|
|
bool isAutosave() const;
|
2021-08-16 20:38:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the save has an autosave name
|
|
|
|
*/
|
|
|
|
bool hasAutosaveName() const;
|
2011-07-02 18:25:32 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* The saveslot id, as it would be passed to the "-x" command line switch.
|
|
|
|
*/
|
|
|
|
int _slot;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A human readable description of the save state.
|
|
|
|
*/
|
2020-06-13 16:42:25 +00:00
|
|
|
Common::U32String _description;
|
2011-07-02 18:25:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the save state can be deleted.
|
|
|
|
*/
|
|
|
|
bool _isDeletable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the save state is write protected.
|
|
|
|
*/
|
|
|
|
bool _isWriteProtected;
|
|
|
|
|
2016-06-06 06:22:22 +00:00
|
|
|
/**
|
|
|
|
* Whether the save state is "locked" because is being synced.
|
|
|
|
*/
|
|
|
|
bool _isLocked;
|
|
|
|
|
2011-07-02 18:25:32 +00:00
|
|
|
/**
|
|
|
|
* Human readable description of the date the save state was created.
|
|
|
|
*/
|
|
|
|
Common::String _saveDate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Human readable description of the time the save state was created.
|
|
|
|
*/
|
|
|
|
Common::String _saveTime;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Human readable description of the time the game was played till the
|
|
|
|
* save state was created.
|
|
|
|
*/
|
2020-08-29 13:38:39 +00:00
|
|
|
Common::String _playTime;
|
2011-07-02 18:25:32 +00:00
|
|
|
|
2018-07-13 02:13:22 +00:00
|
|
|
/**
|
|
|
|
* The time the game was played before the save state was created
|
|
|
|
* in milliseconds.
|
|
|
|
*/
|
|
|
|
uint32 _playTimeMSecs;
|
|
|
|
|
2011-07-02 18:25:32 +00:00
|
|
|
/**
|
|
|
|
* The thumbnail of the save state.
|
|
|
|
*/
|
|
|
|
Common::SharedPtr<Graphics::Surface> _thumbnail;
|
2020-02-11 02:55:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Save file type
|
|
|
|
*/
|
|
|
|
SaveType _saveType;
|
2010-03-18 15:09:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** List of savestates. */
|
|
|
|
typedef Common::Array<SaveStateDescriptor> SaveStateList;
|
|
|
|
|
2016-02-25 18:13:10 +00:00
|
|
|
/**
|
|
|
|
* Comparator object to compare SaveStateDescriptor's based on slot.
|
|
|
|
*/
|
|
|
|
struct SaveStateDescriptorSlotComparator {
|
|
|
|
bool operator()(const SaveStateDescriptor &x, const SaveStateDescriptor &y) const {
|
|
|
|
return x.getSaveSlot() < y.getSaveSlot();
|
|
|
|
}
|
|
|
|
};
|
2020-11-21 01:20:41 +00:00
|
|
|
/** @} */
|
2010-03-18 15:09:48 +00:00
|
|
|
#endif
|