diff options
-rw-r--r-- | base/game.cpp | 18 | ||||
-rw-r--r-- | base/game.h | 15 | ||||
-rw-r--r-- | engines/metaengine.h | 22 | ||||
-rw-r--r-- | engines/scumm/detection.cpp | 25 | ||||
-rw-r--r-- | engines/scumm/saveload.cpp | 9 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 7 | ||||
-rw-r--r-- | gui/launcher.cpp | 75 |
7 files changed, 159 insertions, 12 deletions
diff --git a/base/game.cpp b/base/game.cpp index 30fd5fc850..7dff13e5f2 100644 --- a/base/game.cpp +++ b/base/game.cpp @@ -96,3 +96,21 @@ void SaveStateDescriptor::setDeletableFlag(bool state) { setVal("is_deletable", state ? "true" : "false"); } +void SaveStateDescriptor::setSaveDate(int year, int month, int day) { + char buffer[32]; + snprintf(buffer, 32, "%.2d.%.2d.%.4d", day, month, year); + setVal("save_date", buffer); +} + +void SaveStateDescriptor::setSaveTime(int hour, int min) { + char buffer[32]; + snprintf(buffer, 32, "%.2d:%.2d", hour, min); + setVal("save_time", buffer); +} + +void SaveStateDescriptor::setPlayTime(int hours, int minutes) { + char buffer[32]; + snprintf(buffer, 32, "%.2d:%.2d", hours, minutes); + setVal("play_time", buffer); +} + diff --git a/base/game.h b/base/game.h index 6f9030c56f..8fd1b47422 100644 --- a/base/game.h +++ b/base/game.h @@ -187,6 +187,21 @@ public: const Graphics::Surface *getThumbnail() const { return _thumbnail.get(); } void setThumbnail(Graphics::Surface *t); + + /** + * Sets the 'save_date' key properly, based on the given values + */ + void setSaveDate(int year, int month, int day); + + /** + * Sets the 'save_time' key properly, based on the given values + */ + void setSaveTime(int hour, int min); + + /** + * Sets the 'play_time' key properly, based on the given values + */ + void setPlayTime(int hours, int minutes); }; /** List of savestates. */ diff --git a/engines/metaengine.h b/engines/metaengine.h index 525afe5fa3..e57419a84c 100644 --- a/engines/metaengine.h +++ b/engines/metaengine.h @@ -151,10 +151,26 @@ public: /** * Features a thumbnail in savegames (i.e. includes a thumbnail - * in savestates returned via querySaveMetaInfo). This flag may - * only be set when 'kSupportsMetaInfos' is set. + * in savestates returned via querySaveMetaInfo). + * This flag may only be set when 'kSupportsMetaInfos' is set. */ - kSupportsThumbnails = 5 + kSupportsThumbnails = 5, + + /** + * Features 'save_date' and 'save_time' entries in the + * savestate returned by querySaveMetaInfo. Those values + * indicate the date/time the savegame was created. + * This flag may only be set when 'kSupportsMetaInfos' is set. + */ + kSupportsSaveDate = 6, + + /** + * Features 'play_time' entry in the savestate returned by + * querySaveMetaInfo. It indicates how long the user played + * the game till the save. + * This flag may only be set when 'kSupportsMetaInfos' is set. + */ + kSupportsSavePlayTime = 7 }; /** diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index 34775ab575..d3397fe208 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -693,7 +693,9 @@ bool ScummMetaEngine::hasFeature(MetaEngineFeature f) const { (f == kSupportsDirectLoad) || (f == kSupportsDeleteSave) || (f == kSupportsMetaInfos) || - (f == kSupportsThumbnails); + (f == kSupportsThumbnails) || + (f == kSupportsSaveDate) || + (f == kSupportsSavePlayTime); } GameList ScummMetaEngine::getSupportedGames() const { @@ -1002,6 +1004,27 @@ SaveStateDescriptor ScummMetaEngine::querySaveMetaInfos(const char *target, int desc.setDeletableFlag(true); desc.setThumbnail(thumbnail); + InfoStuff infos; + memset(&infos, 0, sizeof(infos)); + if (ScummEngine::loadInfosFromSlot(target, slot, &infos)) { + int day = (infos.date >> 24) & 0xFF; + int month = (infos.date >> 16) & 0xFF; + int year = infos.date & 0xFFFF; + + desc.setSaveDate(year, month, day); + + int hour = (infos.time >> 8) & 0xFF; + int minutes = infos.time & 0xFF; + + desc.setSaveTime(hour, minutes); + + minutes = infos.playtime / 60; + hour = minutes / 60; + minutes %= 60; + + desc.setPlayTime(hour, minutes); + } + return desc; } diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index d16da2c42e..267e06dafd 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -518,15 +518,15 @@ Graphics::Surface *ScummEngine::loadThumbnailFromSlot(const char *target, int sl return thumb; } -bool ScummEngine::loadInfosFromSlot(int slot, InfoStuff *stuff) { +bool ScummEngine::loadInfosFromSlot(const char *target, int slot, InfoStuff *stuff) { Common::SeekableReadStream *in; SaveGameHeader hdr; if (slot < 0) return 0; - Common::String filename = makeSavegameName(slot, false); - if (!(in = _saveFileMan->openForLoading(filename.c_str()))) { + Common::String filename = makeSavegameName(target, slot, false); + if (!(in = g_system->getSavefileManager()->openForLoading(filename.c_str()))) { return false; } @@ -598,9 +598,8 @@ bool ScummEngine::loadInfos(Common::SeekableReadStream *file, InfoStuff *stuff) stuff->playtime = section.playtime; // Skip over the remaining (unsupported) data - if (section.size > SaveInfoSectionSize) { + if (section.size > SaveInfoSectionSize) file->skip(section.size - SaveInfoSectionSize); - } return true; } diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 2560dfe502..96cc5bb31c 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -637,11 +637,14 @@ public: } static Graphics::Surface *loadThumbnailFromSlot(const char *target, int slot); - bool loadInfosFromSlot(int slot, InfoStuff *stuff); + bool loadInfosFromSlot(int slot, InfoStuff *stuff) { + return loadInfosFromSlot(_targetName.c_str(), slot, stuff); + } + static bool loadInfosFromSlot(const char *target, int slot, InfoStuff *stuff); protected: void saveInfos(Common::WriteStream* file); - bool loadInfos(Common::SeekableReadStream *file, InfoStuff *stuff); + static bool loadInfos(Common::SeekableReadStream *file, InfoStuff *stuff); int32 _engineStartTime; int32 _pauseStartTime; diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 1d50f21998..8f3bfd2c33 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -482,11 +482,16 @@ protected: GUI::ButtonWidget *_deleteButton; GUI::GraphicsWidget *_gfxWidget; GUI::ContainerWidget *_container; + GUI::StaticTextWidget *_date; + GUI::StaticTextWidget *_time; + GUI::StaticTextWidget *_playtime; const EnginePlugin *_plugin; bool _delSupport; bool _metaInfoSupport; bool _thumbnailSupport; + bool _saveDateSupport; + bool _playTimeSupport; String _target; SaveStateList _saveList; @@ -523,6 +528,10 @@ SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel) _gfxWidget = new GUI::GraphicsWidget(this, 0, 0, 10, 10); + _date = new StaticTextWidget(this, 0, 0, 10, 10, "No date saved", kTextAlignCenter); + _time = new StaticTextWidget(this, 0, 0, 10, 10, "No time saved", kTextAlignCenter); + _playtime = new StaticTextWidget(this, 0, 0, 10, 10, "No playtime saved", kTextAlignCenter); + // Buttons new GUI::ButtonWidget(this, "scummsaveload_cancel", "Cancel", kCloseCmd, 0); _chooseButton = new GUI::ButtonWidget(this, "scummsaveload_choose", buttonLabel, kChooseCmd, 0); @@ -546,6 +555,8 @@ int SaveLoadChooser::runModal(const EnginePlugin *plugin, const String &target) _delSupport = (*_plugin)->hasFeature(MetaEngine::kSupportsDeleteSave); _metaInfoSupport = (*_plugin)->hasFeature(MetaEngine::kSupportsMetaInfos); _thumbnailSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSupportsThumbnails); + _saveDateSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSupportsSaveDate); + _playTimeSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSupportsSavePlayTime); reflowLayout(); updateSaveList(); @@ -604,14 +615,43 @@ void SaveLoadChooser::reflowLayout() { int vPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.vPad"); int thumbH = ((g_system->getHeight() % 200 && g_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1); - _container->resize(thumbX - hPad, thumbY - vPad, kThumbnailWidth + hPad * 2, thumbH + vPad * 2/* + kLineHeight * 4*/); + int textLines = 0; + if (_saveDateSupport) + textLines += 2; + if (_playTimeSupport) + textLines += 1; + + if (textLines) + ++textLines; + + _container->resize(thumbX - hPad, thumbY - vPad, kThumbnailWidth + hPad * 2, thumbH + vPad * 2 + kLineHeight * textLines); // Add the thumbnail display _gfxWidget->resize(thumbX, thumbY, kThumbnailWidth, thumbH); + int height = thumbY + thumbH + kLineHeight; + + if (_saveDateSupport) { + _date->resize(thumbX, height, kThumbnailWidth, kLineHeight); + height += kLineHeight; + _time->resize(thumbX, height, kThumbnailWidth, kLineHeight); + height += kLineHeight; + } + + if (_playTimeSupport) + _playtime->resize(thumbX, height, kThumbnailWidth, kLineHeight); + _container->clearFlags(GUI::WIDGET_INVISIBLE); _gfxWidget->clearFlags(GUI::WIDGET_INVISIBLE); + if (_saveDateSupport) { + _date->clearFlags(GUI::WIDGET_INVISIBLE); + _time->clearFlags(GUI::WIDGET_INVISIBLE); + } + + if (_playTimeSupport) + _playtime->clearFlags(GUI::WIDGET_INVISIBLE); + _fillR = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillR"); _fillG = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillG"); _fillB = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillB"); @@ -619,6 +659,9 @@ void SaveLoadChooser::reflowLayout() { } else { _container->setFlags(GUI::WIDGET_INVISIBLE); _gfxWidget->setFlags(GUI::WIDGET_INVISIBLE); + _date->setFlags(GUI::WIDGET_INVISIBLE); + _time->setFlags(GUI::WIDGET_INVISIBLE); + _playtime->setFlags(GUI::WIDGET_INVISIBLE); } Dialog::reflowLayout(); @@ -643,6 +686,33 @@ void SaveLoadChooser::updateSelection(bool redraw) { _gfxWidget->setGfx(-1, -1, _fillR, _fillG, _fillB); } } + + if (_saveDateSupport) { + Common::String date = "Date: "; + if (desc.contains("save_date")) + date += desc.getVal("save_date"); + else + date = "No date saved"; + + Common::String time = "Time: "; + if (desc.contains("save_time")) + time += desc.getVal("save_time"); + else + time = "No time saved"; + + _date->setLabel(date); + _time->setLabel(time); + } + + if (_playTimeSupport) { + Common::String time = "Playtime:"; + if (desc.contains("play_time")) + time += desc.getVal("play_time"); + else + time = "No playtime saved"; + + _playtime->setLabel(time); + } } @@ -654,6 +724,9 @@ void SaveLoadChooser::updateSelection(bool redraw) { if (redraw) { _gfxWidget->draw(); + _date->draw(); + _time->draw(); + _playtime->draw(); _chooseButton->draw(); _deleteButton->draw(); } |