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

digitall noreply at scummvm.org
Tue Jan 18 12:33:19 UTC 2022


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

Summary:
51cdcb8766 SKY: Fix saving names for non selected save slots
85064d6553 SKY: Prevent saving empty string as name
bd39fd3ec9 SKY: Prevent GMM save or load if control panel is open


Commit: 51cdcb8766b149d03a77e7b256ac0224a97be059
    https://github.com/scummvm/scummvm/commit/51cdcb8766b149d03a77e7b256ac0224a97be059
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2022-01-18T12:33:16Z

Commit Message:
SKY: Fix saving names for non selected save slots

We use a dirty string buffer to temporary store the edited text for the selected slot

Changed paths:
    engines/sky/control.cpp
    engines/sky/control.h


diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp
index 6fb89b14d90..6cd8124a2b2 100644
--- a/engines/sky/control.cpp
+++ b/engines/sky/control.cpp
@@ -897,8 +897,10 @@ uint16 Control::saveRestorePanel(bool allowSave) {
 		textSprites[cnt] = NULL;
 	_firstText = 0;
 
+	Common::String dirtyBufStr;
 	loadDescriptions(saveGameTexts);
 	_selectedGame = 0;
+	dirtyBufStr = saveGameTexts[_selectedGame];
 
 	bool quitPanel = false;
 	bool refreshNames = true;
@@ -918,7 +920,7 @@ uint16 Control::saveRestorePanel(bool allowSave) {
 			for (cnt = 0; cnt < MAX_ON_SCREEN; cnt++)
 				if (textSprites[cnt])
 					free(textSprites[cnt]);
-			setUpGameSprites(saveGameTexts, textSprites, _firstText, _selectedGame);
+			setUpGameSprites(saveGameTexts, textSprites, _firstText, _selectedGame, dirtyBufStr);
 			showSprites(textSprites, allowSave);
 			refreshNames = false;
 		}
@@ -937,15 +939,17 @@ uint16 Control::saveRestorePanel(bool allowSave) {
 			clickRes = handleClick(lookList[0]);
 			if (!_controlPanel) //game state was destroyed
 				return clickRes;
-			if (clickRes == GAME_SAVED)
+			if (clickRes == GAME_SAVED) {
+				saveGameTexts[_selectedGame] = dirtyBufStr;
 				saveDescriptions(saveGameTexts);
+			}
 			else if (clickRes == NO_DISK_SPACE)
 				displayMessage(0, "Could not save the game. (%s)", _saveFileMan->popErrorDesc().c_str());
 			quitPanel = true;
 			_mouseClicked = false;
 			_action = kSkyActionNone;
 		} if (allowSave && _keyPressed.keycode) {
-			handleKeyPress(_keyPressed, saveGameTexts[_selectedGame]);
+			handleKeyPress(_keyPressed, dirtyBufStr);
 			refreshNames = true;
 			_keyPressed.reset();
 		}
@@ -958,6 +962,7 @@ uint16 Control::saveRestorePanel(bool allowSave) {
 			_mouseWheel = 0;
 			if (clickRes == SHIFTED) {
 				_selectedGame = _firstText;
+				dirtyBufStr = saveGameTexts[_selectedGame];
 				refreshNames = true;
 			}
 		}
@@ -978,6 +983,7 @@ uint16 Control::saveRestorePanel(bool allowSave) {
 
 					if (clickRes == SHIFTED) {
 						_selectedGame = _firstText;
+						dirtyBufStr = saveGameTexts[_selectedGame];
 						refreshNames = true;
 					}
 					if (clickRes == NO_DISK_SPACE) {
@@ -988,6 +994,7 @@ uint16 Control::saveRestorePanel(bool allowSave) {
 						quitPanel = true;
 
 					if (clickRes == GAME_SAVED) {
+						saveGameTexts[_selectedGame] = dirtyBufStr;
 						saveDescriptions(saveGameTexts);
 						quitPanel = true;
 					}
@@ -1000,8 +1007,12 @@ uint16 Control::saveRestorePanel(bool allowSave) {
 			if ((mouse.x >= GAME_NAME_X) && (mouse.x <= GAME_NAME_X + PAN_LINE_WIDTH) &&
 				(mouse.y >= GAME_NAME_Y) && (mouse.y <= GAME_NAME_Y + PAN_CHAR_HEIGHT * MAX_ON_SCREEN)) {
 
-					_selectedGame = (mouse.y - GAME_NAME_Y) / PAN_CHAR_HEIGHT + _firstText;
-					refreshNames = true;
+				uint16 newSelectedGame = (mouse.y - GAME_NAME_Y) / PAN_CHAR_HEIGHT + _firstText;
+				if (_selectedGame != newSelectedGame) {
+					_selectedGame = newSelectedGame;
+					dirtyBufStr = saveGameTexts[_selectedGame];
+				}
+				refreshNames = true;
 			}
 		}
 		if (!haveButton)
@@ -1044,7 +1055,7 @@ void Control::handleKeyPress(Common::KeyState kbd, Common::String &textBuf) {
 	}
 }
 
-void Control::setUpGameSprites(const Common::StringArray &saveGameNames, DataFileHeader **nameSprites, uint16 firstNum, uint16 selectedGame) {
+void Control::setUpGameSprites(const Common::StringArray &saveGameNames, DataFileHeader **nameSprites, uint16 firstNum, uint16 selectedGame, const Common::String &dirtyString) {
 	char cursorChar[2] = "-";
 	DisplayedText textSpr;
 	if (!nameSprites[MAX_ON_SCREEN]) {
@@ -1053,12 +1064,14 @@ void Control::setUpGameSprites(const Common::StringArray &saveGameNames, DataFil
 	}
 	for (uint16 cnt = 0; cnt < MAX_ON_SCREEN; cnt++) {
 		char nameBuf[MAX_TEXT_LEN + 10];
-		sprintf(nameBuf, "%3d: %s", firstNum + cnt + 1, saveGameNames[firstNum + cnt].c_str());
 
-		if (firstNum + cnt == selectedGame)
+		if (firstNum + cnt == selectedGame) {
+			sprintf(nameBuf, "%3d: %s", firstNum + cnt + 1, dirtyString.c_str());
 			textSpr = _skyText->displayText(nameBuf, NULL, false, PAN_LINE_WIDTH, 0);
-		else
+		} else {
+			sprintf(nameBuf, "%3d: %s", firstNum + cnt + 1, saveGameNames[firstNum + cnt].c_str());
 			textSpr = _skyText->displayText(nameBuf, NULL, false, PAN_LINE_WIDTH, 37);
+		}
 		nameSprites[cnt] = (DataFileHeader *)textSpr.textData;
 		if (firstNum + cnt == selectedGame) {
 			nameSprites[cnt]->flag = 1;
diff --git a/engines/sky/control.h b/engines/sky/control.h
index 9525ba86b3b..806cc746d9d 100644
--- a/engines/sky/control.h
+++ b/engines/sky/control.h
@@ -226,7 +226,7 @@ private:
 	void drawCross(uint16 x, uint16 y);
 
 	uint16 saveRestorePanel(bool allowSave);
-	void setUpGameSprites(const Common::StringArray &saveGameNames, DataFileHeader **nameSprites, uint16 firstNum, uint16 selectedGame);
+	void setUpGameSprites(const Common::StringArray &saveGameNames, DataFileHeader **nameSprites, uint16 firstNum, uint16 selectedGame, const Common::String &dirtyString);
 	void showSprites(DataFileHeader **nameSprites, bool allowSave);
 	void handleKeyPress(Common::KeyState kbd, Common::String &textBuf);
 


Commit: 85064d65536d3056a8849fcb15a4e32fe3180043
    https://github.com/scummvm/scummvm/commit/85064d65536d3056a8849fcb15a4e32fe3180043
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2022-01-18T12:33:16Z

Commit Message:
SKY: Prevent saving empty string as name

>From the in-game Save panel.

Saving empty string is still allowed from the ScummVM GMM and it's translated to current date time.
There's a minor glitch there with the '/' character being shown as the wrong glyph in BaSS save/restore panel.
Also note, we keep the behavior of the original, so a string of blanks is still allowed as a save name.

Changed paths:
    engines/sky/control.cpp


diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp
index 6cd8124a2b2..7f61bd7ee7a 100644
--- a/engines/sky/control.cpp
+++ b/engines/sky/control.cpp
@@ -936,16 +936,19 @@ uint16 Control::saveRestorePanel(bool allowSave) {
 			clickRes = CANCEL_PRESSED;
 			quitPanel = true;
 		} else if (_action == kSkyActionConfirm) { // enter pressed
-			clickRes = handleClick(lookList[0]);
-			if (!_controlPanel) //game state was destroyed
-				return clickRes;
-			if (clickRes == GAME_SAVED) {
-				saveGameTexts[_selectedGame] = dirtyBufStr;
-				saveDescriptions(saveGameTexts);
+			// Note: The original engine code does not allow an empty string for a save name
+			// but it does allow a series of blank spaces as a name.
+			if (dirtyBufStr != "") {
+				clickRes = handleClick(lookList[0]);
+				if (!_controlPanel) //game state was destroyed
+					return clickRes;
+				if (clickRes == GAME_SAVED) {
+					saveGameTexts[_selectedGame] = dirtyBufStr;
+					saveDescriptions(saveGameTexts);
+				} else if (clickRes == NO_DISK_SPACE)
+					displayMessage(0, "Could not save the game. (%s)", _saveFileMan->popErrorDesc().c_str());
+				quitPanel = true;
 			}
-			else if (clickRes == NO_DISK_SPACE)
-				displayMessage(0, "Could not save the game. (%s)", _saveFileMan->popErrorDesc().c_str());
-			quitPanel = true;
 			_mouseClicked = false;
 			_action = kSkyActionNone;
 		} if (allowSave && _keyPressed.keycode) {
@@ -977,29 +980,34 @@ uint16 Control::saveRestorePanel(bool allowSave) {
 				if (_mouseClicked && lookList[cnt]->_onClick) {
 					_mouseClicked = false;
 
-					clickRes = handleClick(lookList[cnt]);
-					if (!_controlPanel) //game state was destroyed
-						return clickRes;
-
-					if (clickRes == SHIFTED) {
-						_selectedGame = _firstText;
-						dirtyBufStr = saveGameTexts[_selectedGame];
-						refreshNames = true;
-					}
-					if (clickRes == NO_DISK_SPACE) {
-						displayMessage(0, "Could not save the game. (%s)", _saveFileMan->popErrorDesc().c_str());
-						quitPanel = true;
-					}
-					if ((clickRes == CANCEL_PRESSED) || (clickRes == GAME_RESTORED))
-						quitPanel = true;
-
-					if (clickRes == GAME_SAVED) {
-						saveGameTexts[_selectedGame] = dirtyBufStr;
-						saveDescriptions(saveGameTexts);
-						quitPanel = true;
+					if (lookList[cnt]->_onClick != SAVE_A_GAME
+					    || (lookList[cnt]->_onClick == SAVE_A_GAME && dirtyBufStr != "")) {
+						// The save button will not animate for an empty string save name
+						// and the save action will be ignored
+						clickRes = handleClick(lookList[cnt]);
+						if (!_controlPanel) //game state was destroyed
+							return clickRes;
+
+						if (clickRes == SHIFTED) {
+							_selectedGame = _firstText;
+							dirtyBufStr = saveGameTexts[_selectedGame];
+							refreshNames = true;
+						}
+						if (clickRes == NO_DISK_SPACE) {
+							displayMessage(0, "Could not save the game. (%s)", _saveFileMan->popErrorDesc().c_str());
+							quitPanel = true;
+						}
+						if ((clickRes == CANCEL_PRESSED) || (clickRes == GAME_RESTORED))
+							quitPanel = true;
+
+						if (clickRes == GAME_SAVED) {
+							saveGameTexts[_selectedGame] = dirtyBufStr;
+							saveDescriptions(saveGameTexts);
+							quitPanel = true;
+						}
+						if (clickRes == RESTORE_FAILED)
+							refreshAll = true;
 					}
-					if (clickRes == RESTORE_FAILED)
-						refreshAll = true;
 				}
 			}
 


Commit: bd39fd3ec9e0e861cd0126b05f97ca5420f13a6c
    https://github.com/scummvm/scummvm/commit/bd39fd3ec9e0e861cd0126b05f97ca5420f13a6c
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2022-01-18T12:33:16Z

Commit Message:
SKY: Prevent GMM save or load if control panel is open

It was especially buggy when trying to save from GMM while the save panel of the game is open.

Changed paths:
    engines/sky/control.cpp
    engines/sky/control.h
    engines/sky/metaengine.cpp


diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp
index 7f61bd7ee7a..4d325e0993c 100644
--- a/engines/sky/control.cpp
+++ b/engines/sky/control.cpp
@@ -1141,6 +1141,10 @@ bool Control::loadSaveAllowed() {
 	return true;
 }
 
+bool Control::isControlPanelOpen() {
+	return _controlPanel;
+}
+
 int Control::displayMessage(const char *altButton, const char *message, ...) {
 	char buf[STRINGBUFLEN];
 	va_list va;
diff --git a/engines/sky/control.h b/engines/sky/control.h
index 806cc746d9d..da2508eeefd 100644
--- a/engines/sky/control.h
+++ b/engines/sky/control.h
@@ -187,6 +187,7 @@ public:
 	void showGameQuitMsg();
 	uint16 quickXRestore(uint16 slot);
 	bool loadSaveAllowed();
+	bool isControlPanelOpen();
 
 	SkyEngine *_vm;
 
diff --git a/engines/sky/metaengine.cpp b/engines/sky/metaengine.cpp
index 2131f411198..215723ba4db 100644
--- a/engines/sky/metaengine.cpp
+++ b/engines/sky/metaengine.cpp
@@ -356,11 +356,15 @@ Common::Error SkyEngine::saveGameState(int slot, const Common::String &desc, boo
 }
 
 bool SkyEngine::canLoadGameStateCurrently() {
-	return _systemVars->pastIntro && _skyControl->loadSaveAllowed();
+	return _systemVars->pastIntro
+	    && _skyControl->loadSaveAllowed()
+	    && !_skyControl->isControlPanelOpen();
 }
 
 bool SkyEngine::canSaveGameStateCurrently() {
-	return _systemVars->pastIntro && _skyControl->loadSaveAllowed();
+	return _systemVars->pastIntro
+	    && _skyControl->loadSaveAllowed()
+	    && !_skyControl->isControlPanelOpen();
 }
 
 } // End of namespace Sky




More information about the Scummvm-git-logs mailing list