[Scummvm-cvs-logs] scummvm master -> 9942b5ab600f6b71b5d10921d11bf761f5eef298

lordhoto lordhoto at gmail.com
Wed Sep 26 16:18:15 CEST 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9942b5ab60 GUI: Support for page restoring for non-continuous save lists in the grid chooser.


Commit: 9942b5ab600f6b71b5d10921d11bf761f5eef298
    https://github.com/scummvm/scummvm/commit/9942b5ab600f6b71b5d10921d11bf761f5eef298
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-09-26T07:14:18-07:00

Commit Message:
GUI: Support for page restoring for non-continuous save lists in the grid chooser.

Changed paths:
    gui/saveload-dialog.cpp



diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index be6cefd..df8dda7 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -618,14 +618,22 @@ void SaveLoadChooserGrid::open() {
 	assert(_entriesPerPage != 0);
 	const uint lastPos = ConfMan.getInt("gui_saveload_last_pos");
 	const uint listSize = _saveList.size();
-	if (lastPos < listSize) {
-		_curPage = lastPos / _entriesPerPage;
-	} else if (listSize) {
-		_curPage = (_saveList.size() - 1) / _entriesPerPage;
-	} else {
-		_curPage = 0;
+	uint bestMatch = 0;
+	uint diff = 0xFFFFFFFF;
+
+	// We look for the nearest available slot, since a slot might be missing
+	// due to the user deleting it via the list based chooser, by deleting
+	// it by hand, etc.
+	for (uint i = 0; i < listSize; ++i) {
+		uint curDiff = ABS(_saveList[i].getSaveSlot() - (int)lastPos);
+		if (curDiff < diff) {
+			diff = curDiff;
+			bestMatch = i;
+		}
 	}
 
+	_curPage = bestMatch / _entriesPerPage;
+
 	// Determine the next free save slot for save mode
 	if (_saveMode) {
 		int lastSlot = -1;
@@ -765,7 +773,7 @@ void SaveLoadChooserGrid::close() {
 		// Similar things happen on resolution changes.
 		// TODO: Should we ignore this here? Is the user likely to be
 		// interested in having this page restored when he canceled?
-		ConfMan.setInt("gui_saveload_last_pos", _curPage * _entriesPerPage);
+		ConfMan.setInt("gui_saveload_last_pos", !_saveList.empty() ? _saveList[_curPage * _entriesPerPage].getSaveSlot() : 0);
 	}
 
 	SaveLoadChooserDialog::close();






More information about the Scummvm-git-logs mailing list