[Scummvm-git-logs] scummvm master -> 606cf9c3d288f3981e56e025dc5f6e95861acde1

Strangerke noreply at scummvm.org
Mon May 13 21:57:17 UTC 2024


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:
606cf9c3d2 BAGEL: Use fatalError in opt_window, quit_dialog, restart_dialog and restart_dialog


Commit: 606cf9c3d288f3981e56e025dc5f6e95861acde1
    https://github.com/scummvm/scummvm/commit/606cf9c3d288f3981e56e025dc5f6e95861acde1
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-13T22:57:09+01:00

Commit Message:
BAGEL: Use fatalError in opt_window, quit_dialog, restart_dialog and restart_dialog

Changed paths:
    engines/bagel/dialogs/opt_window.cpp
    engines/bagel/dialogs/quit_dialog.cpp
    engines/bagel/dialogs/restart_dialog.cpp
    engines/bagel/dialogs/restore_dialog.cpp


diff --git a/engines/bagel/dialogs/opt_window.cpp b/engines/bagel/dialogs/opt_window.cpp
index 2cc4cb51679..ffce4725dff 100644
--- a/engines/bagel/dialogs/opt_window.cpp
+++ b/engines/bagel/dialogs/opt_window.cpp
@@ -135,6 +135,8 @@ CBagOptWindow::CBagOptWindow() {
 	for (int i = 0; i < NUM_SYS_BUTTONS; i++) {
 		_pButtons[i] = nullptr;
 	}
+
+	_pSavePalette = nullptr;
 }
 
 ErrorCode CBagOptWindow::detach() {
@@ -222,22 +224,17 @@ ErrorCode CBagOptWindow::attach() {
 		assert(_pButtons[i] == nullptr);
 
 		_pButtons[i] = new CBofBmpButton;
-		if (_pButtons[i] != nullptr) {
-			CBofBitmap *pUp, *pDown, *pFocus, *pDis;
-
-			pUp = loadBitmap(buildSysDir(g_stButtons[i]._pszUp), pPal);
-			pDown = loadBitmap(buildSysDir(g_stButtons[i]._pszDown), pPal);
-			pFocus = loadBitmap(buildSysDir(g_stButtons[i]._pszFocus), pPal);
-			pDis = loadBitmap(buildSysDir(g_stButtons[i]._pszDisabled), pPal);
+		if (_pButtons[i] == nullptr)
+			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 
-			_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
+		CBofBitmap *pUp = loadBitmap(buildSysDir(g_stButtons[i]._pszUp), pPal);
+		CBofBitmap *pDown = loadBitmap(buildSysDir(g_stButtons[i]._pszDown), pPal);
+		CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stButtons[i]._pszFocus), pPal);
+		CBofBitmap *pDis = loadBitmap(buildSysDir(g_stButtons[i]._pszDisabled), pPal);
 
-			_pButtons[i]->create(g_stButtons[i]._pszName, g_stButtons[i]._nLeft, g_stButtons[i]._nTop, g_stButtons[i]._nWidth, g_stButtons[i]._nHeight, this, g_stButtons[i]._nID);
-			_pButtons[i]->show();
-		} else {
-			reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
-			break;
-		}
+		_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
+		_pButtons[i]->create(g_stButtons[i]._pszName, g_stButtons[i]._nLeft, g_stButtons[i]._nTop, g_stButtons[i]._nWidth, g_stButtons[i]._nHeight, this, g_stButtons[i]._nID);
+		_pButtons[i]->show();
 	}
 
 	char szBuf1[MAX_DIRPATH];
@@ -258,79 +255,67 @@ ErrorCode CBagOptWindow::attach() {
 	CBofRect cRect;
 	cRect.setRect(73, 48, 73 + 120 - 1, 48 + 20 - 1);
 	_pMidiVolumeScroll = new CBofScrollBar;
-	if (_pMidiVolumeScroll != nullptr) {
-		_pMidiVolumeScroll->create("", &cRect, this, MIDI_VOL_ID);
-
-		_pMidiVolumeScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
-		_pMidiVolumeScroll->setScrollRange(VOLUME_MIN, VOLUME_MAX, true);
-		_pMidiVolumeScroll->show();
+	if (_pMidiVolumeScroll == nullptr)
+		fatalError(ERR_MEMORY, "Could not allocate the Midi Volume Scroll Bar");
 
-	} else {
-		reportError(ERR_MEMORY, "Could not allocate the Midi Volume Scroll Bar");
-	}
+	_pMidiVolumeScroll->create("", &cRect, this, MIDI_VOL_ID);
+	_pMidiVolumeScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
+	_pMidiVolumeScroll->setScrollRange(VOLUME_MIN, VOLUME_MAX, true);
+	_pMidiVolumeScroll->show();
 
 	// Digital Audio volume control
 	cRect.setRect(73, 98, 73 + 120 - 1, 98 + 20 - 1);
 	_pWaveVolumeScroll = new CBofScrollBar;
-	if (_pWaveVolumeScroll != nullptr) {
-		_pWaveVolumeScroll->create("", &cRect, this, WAVE_VOL_ID);
+	if (_pWaveVolumeScroll == nullptr)
+		fatalError(ERR_MEMORY, "Could not allocate the Wave Volume Scroll Bar");
 
-		_pWaveVolumeScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
-		_pWaveVolumeScroll->setScrollRange(VOLUME_MIN, VOLUME_MAX, true);
-		_pWaveVolumeScroll->show();
-
-	} else {
-		reportError(ERR_MEMORY, "Could not allocate the Wave Volume Scroll Bar");
-	}
+	_pWaveVolumeScroll->create("", &cRect, this, WAVE_VOL_ID);
+	_pWaveVolumeScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
+	_pWaveVolumeScroll->setScrollRange(VOLUME_MIN, VOLUME_MAX, true);
+	_pWaveVolumeScroll->show();
 
 	// Pan Correction control
 	cRect.setRect(73, 268, 73 + 120 - 1, 268 + 20 - 1);
 	_pCorrectionScroll = new CBofScrollBar;
-	if (_pCorrectionScroll != nullptr) {
-		_pCorrectionScroll->create("", &cRect, this, CORRECTION_ID);
-
-		_pCorrectionScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
-		_pCorrectionScroll->setScrollRange(0, 6, true);
-		_pCorrectionScroll->show();
+	if (_pCorrectionScroll == nullptr)
+		fatalError(ERR_MEMORY, "Could not allocate the Pan Correction Scroll Bar");
 
-	} else {
-		reportError(ERR_MEMORY, "Could not allocate the Pan Correction Scroll Bar");
-	}
+	_pCorrectionScroll->create("", &cRect, this, CORRECTION_ID);
+	_pCorrectionScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
+	_pCorrectionScroll->setScrollRange(0, 6, true);
+	_pCorrectionScroll->show();
 
 	// Pan Speed control
 	cRect.setRect(73, 318, 73 + 120 - 1, 318 + 20 - 1);
 	_pPanSpeedScroll = new CBofScrollBar;
-	if (_pPanSpeedScroll != nullptr) {
-		_pPanSpeedScroll->create("", &cRect, this, PANSPEED_ID);
+	if (_pPanSpeedScroll == nullptr)
+		fatalError(ERR_MEMORY, "Could not allocate the Pan Speed Scroll Bar");
 
-		_pPanSpeedScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
-		_pPanSpeedScroll->setScrollRange(0, 5, true);
-		_pPanSpeedScroll->show();
-
-	} else {
-		reportError(ERR_MEMORY, "Could not allocate the Pan Speed Scroll Bar");
-	}
+	_pPanSpeedScroll->create("", &cRect, this, PANSPEED_ID);
+	_pPanSpeedScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
+	_pPanSpeedScroll->setScrollRange(0, 5, true);
+	_pPanSpeedScroll->show();
 
 	cRect.setRect(FLYTHROUGHS_LEFT, FLYTHROUGHS_TOP, FLYTHROUGHS_LEFT + CHECKBOX_WIDTH, FLYTHROUGHS_TOP + CHECKBOX_HEIGHT);
 	_pFlythroughs = new CBofCheckButton();
-	if (_pFlythroughs != nullptr) {
-		_pFlythroughs->loadColorScheme(&_cColorScheme);
-		_errCode = _pFlythroughs->create("", &cRect, this, FLYTHROUGHS_ID);
-		_pFlythroughs->show();
-	}
+	if (_pFlythroughs == nullptr)
+		fatalError(ERR_MEMORY, "Unable to allocate a CBofCheckButton");
+
+	_pFlythroughs->loadColorScheme(&_cColorScheme);
+	_errCode = _pFlythroughs->create("", &cRect, this, FLYTHROUGHS_ID);
+	_pFlythroughs->show();
 
 	cRect.setRect(PANIMATIONS_LEFT, PANIMATIONS_TOP, PANIMATIONS_LEFT + CHECKBOX_WIDTH, PANIMATIONS_TOP + CHECKBOX_HEIGHT);
 	_pPanimations = new CBofCheckButton();
-	if (_pPanimations != nullptr) {
-		_pPanimations->loadColorScheme(&_cColorScheme);
-		_errCode = _pPanimations->create("", &cRect, this, PAN_CHECK_ID);
-		_pPanimations->show();
-	}
+	if (_pPanimations == nullptr)
+		fatalError(ERR_MEMORY, "Unable to allocate a CBofCheckButton");
 
-	loadIniSettings();
+	_pPanimations->loadColorScheme(&_cColorScheme);
+	_errCode = _pPanimations->create("", &cRect, this, PAN_CHECK_ID);
+	_pPanimations->show();
 
+	loadIniSettings();
 	putDialogData();
-
 	CBagCursor::showSystemCursor();
 
 	return _errCode;
diff --git a/engines/bagel/dialogs/quit_dialog.cpp b/engines/bagel/dialogs/quit_dialog.cpp
index 6ed366fcc84..01b96aa2d92 100644
--- a/engines/bagel/dialogs/quit_dialog.cpp
+++ b/engines/bagel/dialogs/quit_dialog.cpp
@@ -78,20 +78,17 @@ void CBagQuitDialog::onInitDialog() {
 		assert(_pButtons[i] == nullptr);
 
 		_pButtons[i] = new CBofBmpButton;
-		if (_pButtons[i] != nullptr) {
-			CBofBitmap *pUp = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszUp), pPal);
-			CBofBitmap *pDown = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszDown), pPal);
-			CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszFocus), pPal);
-			CBofBitmap *pDis = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszDisabled), pPal);
-
-			_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
-
-			_pButtons[i]->create(g_stQuitButtons[i]._pszName, g_stQuitButtons[i]._nLeft, g_stQuitButtons[i]._nTop, g_stQuitButtons[i]._nWidth, g_stQuitButtons[i]._nHeight, this, g_stQuitButtons[i]._nID);
-			_pButtons[i]->show();
-		} else {
-			reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
-			break;
-		}
+		if (_pButtons[i] == nullptr)
+			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
+
+		CBofBitmap *pUp = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszUp), pPal);
+		CBofBitmap *pDown = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszDown), pPal);
+		CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszFocus), pPal);
+		CBofBitmap *pDis = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszDisabled), pPal);
+
+		_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
+		_pButtons[i]->create(g_stQuitButtons[i]._pszName, g_stQuitButtons[i]._nLeft, g_stQuitButtons[i]._nTop, g_stQuitButtons[i]._nWidth, g_stQuitButtons[i]._nHeight, this, g_stQuitButtons[i]._nID);
+		_pButtons[i]->show();
 	}
 
 	// Show System cursor
diff --git a/engines/bagel/dialogs/restart_dialog.cpp b/engines/bagel/dialogs/restart_dialog.cpp
index e23b6bfed91..cb7c56398b1 100644
--- a/engines/bagel/dialogs/restart_dialog.cpp
+++ b/engines/bagel/dialogs/restart_dialog.cpp
@@ -88,19 +88,17 @@ void CBagRestartDialog::onInitDialog() {
 		assert(_pButtons[i] == nullptr);
 
 		_pButtons[i] = new CBofBmpButton;
-		if (_pButtons[i] != nullptr) {
-			CBofBitmap *pUp = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszUp), pPal);
-			CBofBitmap *pDown = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszDown), pPal);
-			CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszFocus), pPal);
-			CBofBitmap *pDis = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszDisabled), pPal);
-
-			_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
-			_pButtons[i]->create(g_stRestartButtons[i]._pszName, g_stRestartButtons[i]._nLeft, g_stRestartButtons[i]._nTop, g_stRestartButtons[i]._nWidth, g_stRestartButtons[i]._nHeight, this, g_stRestartButtons[i]._nID);
-			_pButtons[i]->show();
-		} else {
-			reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
-			break;
-		}
+		if (_pButtons[i] == nullptr)
+			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
+
+		CBofBitmap *pUp = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszUp), pPal);
+		CBofBitmap *pDown = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszDown), pPal);
+		CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszFocus), pPal);
+		CBofBitmap *pDis = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszDisabled), pPal);
+
+		_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
+		_pButtons[i]->create(g_stRestartButtons[i]._pszName, g_stRestartButtons[i]._nLeft, g_stRestartButtons[i]._nTop, g_stRestartButtons[i]._nWidth, g_stRestartButtons[i]._nHeight, this, g_stRestartButtons[i]._nID);
+		_pButtons[i]->show();
 	}
 
 	// Show System cursor
@@ -133,7 +131,6 @@ void CBagRestartDialog::onPaint(CBofRect *pRect) {
 	assert(isValidObject(this));
 
 	paintBackdrop(pRect);
-
 	validateAnscestors();
 }
 
diff --git a/engines/bagel/dialogs/restore_dialog.cpp b/engines/bagel/dialogs/restore_dialog.cpp
index 96f3240f240..d919ef4eb9d 100644
--- a/engines/bagel/dialogs/restore_dialog.cpp
+++ b/engines/bagel/dialogs/restore_dialog.cpp
@@ -114,20 +114,17 @@ ErrorCode CBagRestoreDialog::attach() {
 		assert(_pButtons[i] == nullptr);
 
 		_pButtons[i] = new CBofBmpButton;
-		if (_pButtons[i] != nullptr) {
-			CBofBitmap *pUp = loadBitmap(buildSysDir(g_stButtons[i]._pszUp), pPal);
-			CBofBitmap *pDown = loadBitmap(buildSysDir(g_stButtons[i]._pszDown), pPal);
-			CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stButtons[i]._pszFocus), pPal);
-			CBofBitmap *pDis = loadBitmap(buildSysDir(g_stButtons[i]._pszDisabled), pPal);
+		if (_pButtons[i] == nullptr)
+			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 
-			_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
+		CBofBitmap *pUp = loadBitmap(buildSysDir(g_stButtons[i]._pszUp), pPal);
+		CBofBitmap *pDown = loadBitmap(buildSysDir(g_stButtons[i]._pszDown), pPal);
+		CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stButtons[i]._pszFocus), pPal);
+		CBofBitmap *pDis = loadBitmap(buildSysDir(g_stButtons[i]._pszDisabled), pPal);
 
-			_pButtons[i]->create(g_stButtons[i]._pszName, g_stButtons[i]._nLeft, g_stButtons[i]._nTop, g_stButtons[i]._nWidth, g_stButtons[i]._nHeight, this, g_stButtons[i]._nID);
-			_pButtons[i]->show();
-		} else {
-			reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
-			break;
-		}
+		_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
+		_pButtons[i]->create(g_stButtons[i]._pszName, g_stButtons[i]._nLeft, g_stButtons[i]._nTop, g_stButtons[i]._nWidth, g_stButtons[i]._nHeight, this, g_stButtons[i]._nID);
+		_pButtons[i]->show();
 	}
 
 	if (_nSelectedItem == -1) {
@@ -154,67 +151,61 @@ ErrorCode CBagRestoreDialog::attach() {
 	CBofRect cRect(LIST_X, LIST_Y, LIST_X + LIST_DX - 1, LIST_Y + LIST_DY - 1);
 
 	_pListBox = new CBofListBox();
-	if (_pListBox != nullptr) {
-		_pListBox->create("SaveGameList", &cRect, this);
+	if (_pListBox == nullptr)
+		fatalError(ERR_MEMORY, "Unable to allocate a CBofListBox");
 
-		_pListBox->setPointSize(LIST_FONT_SIZE);
-		_pListBox->setItemHeight(LIST_TEXT_DY);
+	_pListBox->create("SaveGameList", &cRect, this);
+	_pListBox->setPointSize(LIST_FONT_SIZE);
+	_pListBox->setItemHeight(LIST_TEXT_DY);
 
-		// Set a color for selection highlighting
-		if (_pBackdrop != nullptr) {
-			CBofPalette *pPal2 = _pBackdrop->getPalette();
-			byte iPalIdx = pPal2->getNearestIndex(RGB(255, 0, 0));
+	// Set a color for selection highlighting
+	if (_pBackdrop != nullptr) {
+		CBofPalette *pPal2 = _pBackdrop->getPalette();
+		byte iPalIdx = pPal2->getNearestIndex(RGB(255, 0, 0));
 
-			_pListBox->setHighlightColor(pPal2->getColor(iPalIdx));
-		}
+		_pListBox->setHighlightColor(pPal2->getColor(iPalIdx));
+	}
 
-		// Fill the list box with save game entries
-		for (int i = 0; i < nNumSavedGames; i++) {
-			Common::String desc = "Empty";
+	// Fill the list box with save game entries
+	for (int i = 0; i < nNumSavedGames; i++) {
+		Common::String desc = "Empty";
 
-			for (const auto &entry : _savesList) {
-				if (entry.getSaveSlot() == (i + 1)) {
-					desc = entry.getDescription();
-					break;
-				}
+		for (const auto &entry : _savesList) {
+			if (entry.getSaveSlot() == (i + 1)) {
+				desc = entry.getDescription();
+				break;
 			}
-
-			_pListBox->addToTail(desc.c_str(), false);
-		}
-
-		// Must be a valid item by now
-		if (_nSelectedItem != -1) {
-			_pListBox->setSelectedItem(_nSelectedItem, false);
 		}
 
-		_pListBox->show();
-		_pListBox->updateWindow();
+		_pListBox->addToTail(desc.c_str(), false);
+	}
 
-	} else {
-		reportError(ERR_MEMORY, "Unable to allocate a CBofListBox");
+	// Must be a valid item by now
+	if (_nSelectedItem != -1) {
+		_pListBox->setSelectedItem(_nSelectedItem, false);
 	}
 
+	_pListBox->show();
+	_pListBox->updateWindow();
+
 	if (!errorOccurred()) {
 		// There could not already be a text field
 		assert(_pText == nullptr);
 
 		_pText = new CBofText;
-		if (_pText != nullptr) {
-			cRect.setRect(170, 405, 470, 435);
-			_pText->setupText(&cRect, JUSTIFY_LEFT, FORMAT_CENTER_LEFT);
-			_pText->SetSize(16);
-			_pText->setWeight(TEXT_BOLD);
+		if (_pText == nullptr)
+			fatalError(ERR_MEMORY, "Could not allocate a CBofText for the Restore Dialog");
 
-			// Set initial selected item
-			if (_pListBox != nullptr && _nSelectedItem != -1) {
-				_pText->setText(_pListBox->getText(_nSelectedItem));
-
-			} else {
-				_pText->setText("");
-			}
+		cRect.setRect(170, 405, 470, 435);
+		_pText->setupText(&cRect, JUSTIFY_LEFT, FORMAT_CENTER_LEFT);
+		_pText->SetSize(16);
+		_pText->setWeight(TEXT_BOLD);
 
+		// Set initial selected item
+		if (_pListBox != nullptr && _nSelectedItem != -1) {
+			_pText->setText(_pListBox->getText(_nSelectedItem));
 		} else {
-			reportError(ERR_MEMORY, "Could not allocate a CBofText for the Restore Dialog");
+			_pText->setText("");
 		}
 	}
 




More information about the Scummvm-git-logs mailing list