[Scummvm-git-logs] scummvm master -> a17816f14dc8aece4bd88c411382107467dbb3b4

orgads orgads at gmail.com
Wed Aug 25 02:56:25 UTC 2021


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

Summary:
44e5d3f9bd GUI: Factor out save/load activation to a function
a17816f14d GUI: Warn when saving a "young" game over an "older" one


Commit: 44e5d3f9bdb64e000f97f234e96f85637c3bc1b0
    https://github.com/scummvm/scummvm/commit/44e5d3f9bdb64e000f97f234e96f85637c3bc1b0
Author: Orgad Shaneh (orgads at gmail.com)
Date: 2021-08-25T05:56:22+03:00

Commit Message:
GUI: Factor out save/load activation to a function

Changed paths:
    gui/saveload-dialog.cpp
    gui/saveload-dialog.h


diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index 9e4d05ee65..cf9a1ff8e8 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -330,6 +330,17 @@ void SaveLoadChooserDialog::listSaves() {
 #endif
 }
 
+void SaveLoadChooserDialog::activate(int slot, const Common::U32String &description) {
+	if (!_saveList.empty() && slot < int(_saveList.size())) {
+		const SaveStateDescriptor &desc = _saveList[slot];
+		if (_saveMode) {
+			_resultString = description.empty() ? desc.getDescription() : description;
+		}
+		setResult(desc.getSaveSlot());
+	}
+	close();
+}
+
 #ifndef DISABLE_SAVELOADCHOOSER_GRID
 void SaveLoadChooserDialog::addChooserButtons() {
 	if (_listButton) {
@@ -441,22 +452,14 @@ void SaveLoadChooserSimple::handleCommand(CommandSender *sender, uint32 cmd, uin
 		if (selItem >= 0 && _chooseButton->isEnabled()) {
 			if (_list->isEditable() || !_list->getSelectedString().empty()) {
 				_list->endEditMode();
-				if (!_saveList.empty()) {
-					setResult(_saveList[selItem].getSaveSlot());
-					_resultString = _list->getSelectedString();
-				}
-				close();
+				activate(selItem, _list->getSelectedString());
 			}
 		}
 		break;
 	case kChooseCmd:
 		_list->endEditMode();
 		if (selItem >= 0) {
-			if (!_saveList.empty()) {
-				setResult(_saveList[selItem].getSaveSlot());
-				_resultString = _list->getSelectedString();
-			}
-			close();
+			activate(selItem, _list->getSelectedString());
 		}
 		break;
 	case kListSelectionChangedCmd:
@@ -793,15 +796,9 @@ const Common::U32String &SaveLoadChooserGrid::getResultString() const {
 }
 
 void SaveLoadChooserGrid::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
-	if (cmd <= _entriesPerPage && cmd + _curPage * _entriesPerPage <= _saveList.size()) {
-		const SaveStateDescriptor &desc = _saveList[cmd - 1 + _curPage * _entriesPerPage];
-
-		if (_saveMode) {
-			_resultString = desc.getDescription();
-		}
-
-		setResult(desc.getSaveSlot());
-		close();
+	const int slot = cmd + _curPage * _entriesPerPage - 1;
+	if (cmd <= _entriesPerPage) {
+		activate(slot, Common::U32String());
 	}
 
 	switch (cmd) {
diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h
index fa5b126ba1..f10e7103c3 100644
--- a/gui/saveload-dialog.h
+++ b/gui/saveload-dialog.h
@@ -110,6 +110,8 @@ protected:
 	*/
 	virtual void listSaves();
 
+	void activate(int slot, const Common::U32String &description);
+
 	const bool					_saveMode;
 	const MetaEngine		    *_metaEngine;
 	bool						_delSupport;
@@ -120,6 +122,7 @@ protected:
 	Common::String				_target;
 	bool _dialogWasShown;
 	SaveStateList				_saveList;
+	Common::U32String			_resultString;
 
 #ifndef DISABLE_SAVELOADCHOOSER_GRID
 	ButtonWidget *_listButton;
@@ -166,8 +169,6 @@ private:
 	StaticTextWidget	*_playtime;
 	StaticTextWidget	*_pageTitle;
 
-	U32String			_resultString;
-
 	void addThumbnailContainer();
 	void updateSelection(bool redraw);
 };
@@ -227,7 +228,6 @@ private:
 
 	ContainerWidget *_newSaveContainer;
 	int _nextFreeSaveSlot;
-	Common::U32String _resultString;
 
 	SavenameDialog _savenameDialog;
 	bool selectDescription();


Commit: a17816f14dc8aece4bd88c411382107467dbb3b4
    https://github.com/scummvm/scummvm/commit/a17816f14dc8aece4bd88c411382107467dbb3b4
Author: Orgad Shaneh (orgads at gmail.com)
Date: 2021-08-25T05:56:22+03:00

Commit Message:
GUI: Warn when saving a "young" game over an "older" one

Changed paths:
    gui/saveload-dialog.cpp


diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index cf9a1ff8e8..f221f86236 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -38,6 +38,7 @@
 
 #include "graphics/scaler.h"
 #include "common/savefile.h"
+#include "engines/engine.h"
 
 namespace GUI {
 
@@ -334,6 +335,17 @@ void SaveLoadChooserDialog::activate(int slot, const Common::U32String &descript
 	if (!_saveList.empty() && slot < int(_saveList.size())) {
 		const SaveStateDescriptor &desc = _saveList[slot];
 		if (_saveMode) {
+			if (g_engine) {
+				const int currentPlayTime = g_engine->getTotalPlayTime();
+				const int savedPlayTime = desc.getPlayTimeMSecs();
+				if (currentPlayTime > 0 && savedPlayTime > 0 && currentPlayTime < savedPlayTime) {
+					GUI::MessageDialog warn(
+								_("WARNING: Existing save has longer gameplay duration than the "
+								  "current state. Are you sure you want to overwrite it?"), _("Yes"), _("No"));
+					if (warn.runModal() != GUI::kMessageOK)
+						return;
+				}
+			}
 			_resultString = description.empty() ? desc.getDescription() : description;
 		}
 		setResult(desc.getSaveSlot());
@@ -579,6 +591,8 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) {
 
 	if (selItem >= 0 && _metaInfoSupport) {
 		SaveStateDescriptor desc = (_saveList[selItem].getLocked() ? _saveList[selItem] : _metaEngine->querySaveMetaInfos(_target.c_str(), _saveList[selItem].getSaveSlot()));
+		if (!_saveList[selItem].getLocked())
+			_saveList[selItem] = desc;
 
 		isDeletable = desc.getDeletableFlag() && _delSupport;
 		isWriteProtected = desc.getWriteProtectedFlag() ||
@@ -1096,6 +1110,8 @@ void SaveLoadChooserGrid::updateSaves() {
 		const uint saveSlot = _saveList[i].getSaveSlot();
 
 		SaveStateDescriptor desc =  (_saveList[i].getLocked() ? _saveList[i] : _metaEngine->querySaveMetaInfos(_target.c_str(), saveSlot));
+		if (!_saveList[i].getLocked())
+			_saveList[i] = desc;
 		SlotButton &curButton = _buttons[curNum];
 		curButton.setVisible(true);
 		const Graphics::Surface *thumbnail = desc.getThumbnail();




More information about the Scummvm-git-logs mailing list