aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/saveload-dialog.cpp21
-rw-r--r--gui/saveload-dialog.h1
-rw-r--r--gui/widgets/list.h1
3 files changed, 23 insertions, 0 deletions
diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index 63d8d25fe0..c8f7556e66 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -422,7 +422,28 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) {
}
}
+void SaveLoadChooserSimple::open() {
+ SaveLoadChooserDialog::open();
+
+ // Scroll the list to the last used entry.
+ _list->scrollTo(ConfMan.getInt("gui_saveload_last_pos"));
+}
+
void SaveLoadChooserSimple::close() {
+ // Save the current scroll position/used entry.
+ const int result = getResult();
+ if (result >= 0) {
+ ConfMan.setInt("gui_saveload_last_pos", result);
+ } else {
+ // Use the current scroll position here.
+ // TODO: This means we canceled the dialog (or switch to the grid). Do
+ // we want to save this position here? Does the user want that?
+ // TODO: Do we want to save the current scroll position or the
+ // currently selected item here? The scroll position is what the user
+ // currently sees and seems to make more sense.
+ ConfMan.setInt("gui_saveload_last_pos", _list->getCurrentScrollPos());
+ }
+
_metaEngine = 0;
_target.clear();
_saveList.clear();
diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h
index 9d0350d69d..6f7d95f73f 100644
--- a/gui/saveload-dialog.h
+++ b/gui/saveload-dialog.h
@@ -103,6 +103,7 @@ public:
virtual SaveLoadChooserType getType() const { return kSaveLoadDialogList; }
#endif // !DISABLE_SAVELOADCHOOSER_GRID
+ virtual void open();
virtual void close();
private:
virtual int runIntern();
diff --git a/gui/widgets/list.h b/gui/widgets/list.h
index 41fae37a71..47613b79f3 100644
--- a/gui/widgets/list.h
+++ b/gui/widgets/list.h
@@ -105,6 +105,7 @@ public:
void scrollTo(int item);
void scrollToEnd();
+ int getCurrentScrollPos() const { return _currentPos; }
void enableQuickSelect(bool enable) { _quickSelect = enable; }
String getQuickSelectString() const { return _quickSelectStr; }