aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJohannes Schickel2012-06-10 05:04:59 +0200
committerJohannes Schickel2012-06-10 05:04:59 +0200
commit49fafb48a7f089c97ed3baa9aefe65ec56dce682 (patch)
tree1e9ce4431017539cc4ecf519869f29cd394bd3f9 /gui
parent7c5cf1b400808865a5f601f70d624ad6704a0c8c (diff)
downloadscummvm-rg350-49fafb48a7f089c97ed3baa9aefe65ec56dce682.tar.gz
scummvm-rg350-49fafb48a7f089c97ed3baa9aefe65ec56dce682.tar.bz2
scummvm-rg350-49fafb48a7f089c97ed3baa9aefe65ec56dce682.zip
GUI: Refactor default savegame description creation.
Formerly the GMM, AGI and SCI duplicated the logic for USE_SAVEGAME_TIMESTAMP. Now I added a method to SaveLoadChooser instead, which takes care of this. This might not be the best placement of such a functionality, thus I added a TODO which talks about moving it to a better place.
Diffstat (limited to 'gui')
-rw-r--r--gui/saveload.cpp13
-rw-r--r--gui/saveload.h15
2 files changed, 28 insertions, 0 deletions
diff --git a/gui/saveload.cpp b/gui/saveload.cpp
index 366efa7a90..67d871e133 100644
--- a/gui/saveload.cpp
+++ b/gui/saveload.cpp
@@ -21,6 +21,7 @@
#include "common/config-manager.h"
#include "common/translation.h"
+#include "common/system.h"
#include "gui/widgets/list.h"
#include "gui/message.h"
@@ -126,6 +127,18 @@ const Common::String &SaveLoadChooser::getResultString() const {
return (selItem >= 0) ? _list->getSelectedString() : _resultString;
}
+Common::String SaveLoadChooser::createDefaultSaveDescription(const int slot) const {
+#if defined(USE_SAVEGAME_TIMESTAMP)
+ TimeDate curTime;
+ g_system->getTimeAndDate(curTime);
+ curTime.tm_year += 1900; // fixup year
+ curTime.tm_mon++; // fixup month
+ return Common::String::format("%04d.%02d.%02d / %02d:%02d:%02d", curTime.tm_year, curTime.tm_mon, curTime.tm_mday, curTime.tm_hour, curTime.tm_min, curTime.tm_sec);
+#else
+ return Common::String::format("Save %d", slot + 1);
+#endif
+}
+
void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
int selItem = _list->getSelected();
diff --git a/gui/saveload.h b/gui/saveload.h
index dc0f0429c7..e81b10d214 100644
--- a/gui/saveload.h
+++ b/gui/saveload.h
@@ -79,6 +79,21 @@ public:
const Common::String &getResultString() const;
+ /**
+ * Creates a default save description for the specified slot. Depending
+ * on the ScummVM configuration this might be a simple "Slot #" description
+ * or the current date and time.
+ *
+ * TODO: This might not be the best place to put this, since engines not
+ * using this class might want to mimic the same behavior. Check whether
+ * moving this to a better place makes sense and find what this place would
+ * be.
+ *
+ * @param slot The slot number (must be >= 0).
+ * @return The slot description.
+ */
+ Common::String createDefaultSaveDescription(const int slot) const;
+
virtual void reflowLayout();
virtual void close();