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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "engines/savestate.h"
|
|
|
|
#include "graphics/surface.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/textconsole.h"
|
2020-02-11 02:55:31 +00:00
|
|
|
#include "common/translation.h"
|
2010-03-18 15:09:48 +00:00
|
|
|
|
2011-07-02 18:25:32 +00:00
|
|
|
SaveStateDescriptor::SaveStateDescriptor()
|
|
|
|
// FIXME: default to 0 (first slot) or to -1 (invalid slot) ?
|
|
|
|
: _slot(-1), _description(), _isDeletable(true), _isWriteProtected(false),
|
2020-02-11 02:55:31 +00:00
|
|
|
_isLocked(false), _saveDate(), _saveTime(), _playTime(), _playTimeMSecs(0),
|
|
|
|
_thumbnail(), _saveType(kSaveTypeUndetermined) {
|
2010-03-18 15:09:48 +00:00
|
|
|
}
|
|
|
|
|
2011-07-02 18:25:32 +00:00
|
|
|
SaveStateDescriptor::SaveStateDescriptor(int s, const Common::String &d)
|
|
|
|
: _slot(s), _description(d), _isDeletable(true), _isWriteProtected(false),
|
2020-02-11 02:55:31 +00:00
|
|
|
_isLocked(false), _saveDate(), _saveTime(), _playTime(), _playTimeMSecs(0),
|
|
|
|
_thumbnail(), _saveType(kSaveTypeUndetermined) {
|
2010-03-18 15:09:48 +00:00
|
|
|
}
|
|
|
|
|
2011-07-02 18:25:32 +00:00
|
|
|
void SaveStateDescriptor::setThumbnail(Graphics::Surface *t) {
|
|
|
|
if (_thumbnail.get() == t)
|
|
|
|
return;
|
2010-03-18 15:09:48 +00:00
|
|
|
|
2017-11-18 05:28:15 +00:00
|
|
|
_thumbnail = Common::SharedPtr<Graphics::Surface>(t, Graphics::SurfaceDeleter());
|
2010-03-18 15:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SaveStateDescriptor::setSaveDate(int year, int month, int day) {
|
2017-06-01 03:32:32 +00:00
|
|
|
_saveDate = Common::String::format("%.4d-%.2d-%.2d", year, month, day);
|
2010-03-18 15:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SaveStateDescriptor::setSaveTime(int hour, int min) {
|
2011-07-02 18:25:32 +00:00
|
|
|
_saveTime = Common::String::format("%.2d:%.2d", hour, min);
|
2010-03-18 15:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SaveStateDescriptor::setPlayTime(int hours, int minutes) {
|
2018-07-13 02:13:22 +00:00
|
|
|
_playTimeMSecs = ((hours * 60 + minutes) * 60) * 1000;
|
2011-07-02 18:25:32 +00:00
|
|
|
_playTime = Common::String::format("%.2d:%.2d", hours, minutes);
|
2010-03-18 15:09:48 +00:00
|
|
|
}
|
2010-10-29 16:41:30 +00:00
|
|
|
|
|
|
|
void SaveStateDescriptor::setPlayTime(uint32 msecs) {
|
2018-07-13 02:13:22 +00:00
|
|
|
_playTimeMSecs = msecs;
|
2010-10-29 16:41:30 +00:00
|
|
|
uint minutes = msecs / 60000;
|
|
|
|
setPlayTime(minutes / 60, minutes % 60);
|
|
|
|
}
|
2020-02-11 02:55:31 +00:00
|
|
|
|
|
|
|
void SaveStateDescriptor::setAutosave(bool autosave) {
|
|
|
|
_saveType = autosave ? kSaveTypeAutosave : kSaveTypeRegular;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SaveStateDescriptor::isAutosave() const {
|
|
|
|
if (_saveType != kSaveTypeUndetermined) {
|
|
|
|
return _saveType == kSaveTypeAutosave;
|
|
|
|
} else {
|
|
|
|
return _description == _("Autosave");
|
|
|
|
}
|
|
|
|
}
|