[Scummvm-git-logs] scummvm master -> 730af6eae64851951c0f40cf9be6add0c7f29593

AndywinXp noreply at scummvm.org
Sun Oct 8 20:47:46 UTC 2023


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:
730af6eae6 SWORD1: Improve accuracy of menu bars handling


Commit: 730af6eae64851951c0f40cf9be6add0c7f29593
    https://github.com/scummvm/scummvm/commit/730af6eae64851951c0f40cf9be6add0c7f29593
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-10-08T22:47:39+02:00

Commit Message:
SWORD1: Improve accuracy of menu bars handling

More specifically:
- Improve handling of menu bar fading during a palette fade;
- Fix _getOff not being handled if top menu was disabled.

Changed paths:
    engines/sword1/menu.cpp
    engines/sword1/mouse.cpp
    engines/sword1/sword1.cpp
    engines/sword1/sword1.h


diff --git a/engines/sword1/menu.cpp b/engines/sword1/menu.cpp
index 2d2604bc0d3..4b3bfb1fe26 100644
--- a/engines/sword1/menu.cpp
+++ b/engines/sword1/menu.cpp
@@ -389,14 +389,39 @@ void Menu::setToTargetState() {
 	// Note that we are only doing this for the top menu:
 	// I haven't seen any instance of a bottom menu (dialog)
 	// being able to immediately open after a palette fade.
-	if (_objectBarStatus == MENU_CLOSING)
+	if (_objectBarStatus == MENU_CLOSING) {
 		_objectBarStatus = MENU_CLOSED;
+		_fadeObject = 0;
+		for (int i = 0; i < 16; i++) {
+			if (_objects[i])
+				_objects[i]->draw(_fadeEffectTop, _fadeObject);
+			else
+				_screen->showFrame(i * 40, 0, 0xffffffff, 0, _fadeEffectTop, _fadeObject);
+		}
+	}
 
 	if (_objectBarStatus == MENU_OPENING) {
 		_objectBarStatus = MENU_OPEN;
 		_fadeObject = 8;
 		showMenu(MENU_TOP);
 	}
+
+	if (_subjectBarStatus == MENU_CLOSING) {
+		_subjectBarStatus = MENU_CLOSED;
+		_fadeSubject = 0;
+		for (int i = 0; i < 16; i++) {
+			if (_subjects[i])
+				_subjects[i]->draw(_fadeEffectBottom, _fadeSubject);
+			else
+				_screen->showFrame(i * 40, 440, 0xffffffff, 0, _fadeEffectBottom, _fadeSubject);
+		}
+	}
+
+	if (_subjectBarStatus == MENU_OPENING) {
+		_subjectBarStatus = MENU_OPEN;
+		_fadeSubject = 8;
+		showMenu(MENU_TOP);
+	}
 }
 
 int Menu::logicChooser(Object *compact) {
diff --git a/engines/sword1/mouse.cpp b/engines/sword1/mouse.cpp
index 9354f3abbce..65615900873 100644
--- a/engines/sword1/mouse.cpp
+++ b/engines/sword1/mouse.cpp
@@ -141,7 +141,7 @@ void Mouse::engine(uint16 x, uint16 y, uint16 eventFlags) {
 	//-
 	int32 touchedId = 0;
 	uint16 clicked = 0;
-	if (y > 40) {
+	if ((y > 40 && _inTopMenu) || !_inTopMenu) {
 		for (uint16 priority = 0; (priority < 10) && (!touchedId); priority++) {
 			for (uint16 cnt = 0; (cnt < _numObjs) && (!touchedId); cnt++) {
 				if ((_objList[cnt].compact->o_priority == priority) &&
diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp
index bcbb3cf9cf9..1f9ef16d10f 100644
--- a/engines/sword1/sword1.cpp
+++ b/engines/sword1/sword1.cpp
@@ -1230,7 +1230,7 @@ static void vblCallback(void *refCon) {
 			if ((vm->_vblCount == 3) || (vm->_vblCount == 7)) {
 				vm->updateBottomMenu();
 			}
-		} else {
+		} else if (vm->fadeDirectionIsUp()) {
 			// This is an optimization for all the locks introduced
 			// with the fade palette changes: we disable the menu
 			// updates whenever the palette is fading, and we bring
@@ -1254,6 +1254,10 @@ bool SwordEngine::screenIsFading() {
 	return _screen->stillFading() != 0;
 }
 
+bool SwordEngine::fadeDirectionIsUp() {
+	return _screen->stillFading() == 1;
+}
+
 void SwordEngine::installTimerRoutines() {
 	debug(2, "SwordEngine::installTimerRoutines(): Installing timers...");
 	_ticker = 0;
diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h
index e270baca835..448d098732b 100644
--- a/engines/sword1/sword1.h
+++ b/engines/sword1/sword1.h
@@ -124,6 +124,7 @@ public:
 	void startFadePaletteUp(int speed);
 	void waitForFade();
 	bool screenIsFading();
+	bool fadeDirectionIsUp();
 	void setMenuToTargetState();
 
 	void showDebugInfo();




More information about the Scummvm-git-logs mailing list