[Scummvm-git-logs] scummvm master -> 3800f8f33f45e44a9c1dc52f1ec65210e26acae6
eriktorbjorn
noreply at scummvm.org
Tue Nov 21 18:00:42 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:
3800f8f33f SCUMM: Simplify launching of Mac Loom drafts inventory
Commit: 3800f8f33f45e44a9c1dc52f1ec65210e26acae6
https://github.com/scummvm/scummvm/commit/3800f8f33f45e44a9c1dc52f1ec65210e26acae6
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2023-11-21T18:58:24+01:00
Commit Message:
SCUMM: Simplify launching of Mac Loom drafts inventory
It's now the Mac dialog class that's responsible for saving/restoring
the screen shaking. (They were already responsible for pausing and
unpausing.) There are some other minor cleanups along the way, and the
drafts inventory can now be launched from the Apple menu.
Changed paths:
engines/scumm/gfx_mac.cpp
engines/scumm/gfx_mac.h
engines/scumm/input.cpp
engines/scumm/scumm.h
diff --git a/engines/scumm/gfx_mac.cpp b/engines/scumm/gfx_mac.cpp
index 80467bca7b8..91baf7646d9 100644
--- a/engines/scumm/gfx_mac.cpp
+++ b/engines/scumm/gfx_mac.cpp
@@ -189,12 +189,6 @@ Common::KeyState ScummEngine::mac_showOldStyleBannerAndPause(const char *msg, in
MacGui::MacDialogWindow *window = _macGui->drawBanner(bannerMsg);
- // Pause shake effect
- _shakeTempSavedState = _shakeEnabled;
- setShake(0);
-
- // Pause the engine
- PauseToken pt = pauseEngine();
Common::KeyState ks = Common::KEYCODE_INVALID;
if (waitTime) {
@@ -204,8 +198,6 @@ Common::KeyState ScummEngine::mac_showOldStyleBannerAndPause(const char *msg, in
delete window;
- // Finally, resume the engine, clear the input state, and restore the charset.
- pt.clear();
clearClickedStatus();
_messageBannerActive = false;
@@ -213,32 +205,6 @@ Common::KeyState ScummEngine::mac_showOldStyleBannerAndPause(const char *msg, in
return ks;
}
-void ScummEngine::mac_showDraftsInventory() {
- _messageBannerActive = true;
-
- // Draw the drafts inventory
- MacGui::MacDialogWindow *window = _macGui->drawDraftsInventory();
-
- // Pause shake effect
- _shakeTempSavedState = _shakeEnabled;
- setShake(0);
-
- // Pause the engine
- PauseToken pt = pauseEngine();
- Common::KeyState ks = Common::KEYCODE_INVALID;
-
- bool leftBtnPressed = false, rightBtnPressed = false;
- waitForBannerInput(-1, ks, leftBtnPressed, rightBtnPressed);
-
- delete window;
-
- // Finally, resume the engine, clear the input state, and restore the charset.
- pt.clear();
- clearClickedStatus();
-
- _messageBannerActive = false;
-}
-
// ===========================================================================
// Macintosh GUI
// ===========================================================================
@@ -1792,6 +1758,13 @@ bool MacGui::MacListBox::handleKeyDown(Common::Event &event) {
MacGui::MacDialogWindow::MacDialogWindow(MacGui *gui, OSystem *system, Graphics::Surface *from, Common::Rect bounds, MacDialogWindowStyle style) : _gui(gui), _system(system), _from(from), _bounds(bounds) {
_pauseToken = _gui->_vm->pauseEngine();
+ // Remember if the screen was shaking. We don't use the SCUMM engine's
+ // own _shakeTempSavedState to remember this, because there may be
+ // nested dialogs. They each need their own.
+
+ _shakeWasEnabled = _gui->_vm->_shakeEnabled;
+ _gui->_vm->setShake(0);
+
_backup = new Graphics::Surface();
_backup->create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
_backup->copyRectToSurface(*_from, 0, 0, bounds);
@@ -1854,6 +1827,7 @@ MacGui::MacDialogWindow::~MacDialogWindow() {
_widgets.clear();
_pauseToken.clear();
+ _gui->_vm->setShake(_shakeWasEnabled);
}
void MacGui::MacDialogWindow::copyToScreen(Graphics::Surface *s) const {
@@ -2559,6 +2533,9 @@ void MacGui::initialize() {
// TODO: This can be found in the STRS resource
Common::String aboutMenuDef = "About " + name() + "...<B;(-";
+ if (_vm->_game.id == GID_LOOM)
+ aboutMenuDef += ";Drafts Inventory";
+
menu->addStaticMenus(menuSubItems);
menu->createSubMenuFromString(0, aboutMenuDef.c_str(), 0);
@@ -3226,7 +3203,7 @@ MacGui::MacDialogWindow *MacGui::drawBanner(char *message) {
return window;
}
-MacGui::MacDialogWindow *MacGui::drawDraftsInventory() {
+void MacGui::runDraftsInventory() {
int base, xPos, textHeight, heightMultiplier, draft, inactiveColor,
unlockedColor, newDraftColor, notesColor;
@@ -3311,7 +3288,8 @@ MacGui::MacDialogWindow *MacGui::drawDraftsInventory() {
// Update the screen with all the new stuff!
window->show();
- return window;
+ delay();
+ delete window;
}
void MacGui::drawBitmap(Common::Rect r, const uint16 *bitmap, Color color) const {
@@ -3425,6 +3403,10 @@ bool MacLoomGui::handleMenu(int id, Common::String &name) {
return true;
switch (id) {
+ case 101: // Drafts inventory
+ runDraftsInventory();
+ break;
+
case 204: // Options
runOptionsDialog();
break;
diff --git a/engines/scumm/gfx_mac.h b/engines/scumm/gfx_mac.h
index 08f2eac1ede..941acee37ff 100644
--- a/engines/scumm/gfx_mac.h
+++ b/engines/scumm/gfx_mac.h
@@ -464,6 +464,8 @@ public:
class MacDialogWindow {
private:
+ bool _shakeWasEnabled;
+
Common::Rect _bounds;
int _margin;
@@ -605,7 +607,7 @@ public:
MacDialogWindow *createWindow(Common::Rect bounds, MacDialogWindowStyle style = kStyleNormal);
MacDialogWindow *createDialog(int dialogId);
MacDialogWindow *drawBanner(char *message);
- MacDialogWindow *drawDraftsInventory();
+ void runDraftsInventory();
void drawBitmap(Common::Rect r, const uint16 *bitmap, Color color) const;
void drawBitmap(Graphics::Surface *s, Common::Rect r, const uint16 *bitmap, Color color) const;
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index e39d229e47b..48545c54745 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -1168,7 +1168,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_d && lastKeyHit.hasFlags(Common::KBD_CTRL))) {
// Drafts menu
if (_macGui) {
- mac_showDraftsInventory();
+ _macGui->runDraftsInventory();
} else {
showDraftsInventory();
}
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 00948d0421d..2d55001d0cb 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -1408,7 +1408,6 @@ protected:
void mac_undrawIndy3TextBox();
void mac_undrawIndy3CreditsText();
Common::KeyState mac_showOldStyleBannerAndPause(const char *msg, int32 waitTime);
- void mac_showDraftsInventory();
const byte *postProcessDOSGraphics(VirtScreen *vs, int &pitch, int &x, int &y, int &width, int &height) const;
const byte *ditherVGAtoEGA(int &pitch, int &x, int &y, int &width, int &height) const;
More information about the Scummvm-git-logs
mailing list