[Scummvm-git-logs] scummvm master -> b599b254f59de6c8c3b901991e4147cc94dfc421
AndywinXp
noreply at scummvm.org
Mon Nov 20 13:39:26 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:
b599b254f5 SCUMM: MACGUI: Implement Loom's Drafts inventory using a MacDialogWindow
Commit: b599b254f59de6c8c3b901991e4147cc94dfc421
https://github.com/scummvm/scummvm/commit/b599b254f59de6c8c3b901991e4147cc94dfc421
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-11-20T14:39:17+01:00
Commit Message:
SCUMM: MACGUI: Implement Loom's Drafts inventory using a MacDialogWindow
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 e0e33361b05..99486091531 100644
--- a/engines/scumm/gfx_mac.cpp
+++ b/engines/scumm/gfx_mac.cpp
@@ -213,6 +213,32 @@ 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
// ===========================================================================
@@ -3137,6 +3163,97 @@ MacGui::MacDialogWindow *MacGui::drawBanner(char *message) {
return window;
}
+MacGui::MacDialogWindow *MacGui::drawDraftsInventory() {
+ int base, xPos, textHeight, heightMultiplier, draft, xOffset, inactiveColor,
+ unlockedColor, newDraftColor, titleColor, notesColor, notesWidth;
+
+ char notesBuf[6];
+ const char *names[18] = {
+ "Drafts",
+ "Opening:", "Straw Into Gold:", "Dyeing:",
+ "Night Vision:", "Twisting:", "Sleep:",
+ "Emptying:", "Invisibility:", "Terror:",
+ "Sharpening:", "Reflection:", "Healing:",
+ "Silence:", "Shaping:", "Unmaking:",
+ "Transcendence:",
+ "Unknown:"
+ };
+
+ const char *notes = "cdefgabC";
+
+ // ACT 1: Draw the Mac dialog window
+ MacGui::MacDialogWindow *window = createWindow(Common::Rect(110, 20, 540, 252));
+ const Graphics::Font *font = getFont(kSystemFont);
+
+ Graphics::Surface *s = window->innerSurface();
+
+ // ACT 2: Draw the drafts text
+ //
+ // Drafts are stored in SCUMM global variables; we choose the appropriate
+ // first entry in the variables at which these drafts start.
+ base = 55;
+
+ // TODO: Can these be drawn in different styles? (e.g. Checkerboard)
+ unlockedColor = kBlack;
+ inactiveColor = kBlack;
+ newDraftColor = kBlack;
+
+ xOffset = 0;
+ notesWidth = 30;
+
+ for (int i = 0; i < 16; i++) {
+ draft = _vm->_scummVars[base + i * 2];
+
+ // In which row are we rendering our text?
+ heightMultiplier = i < 8 ? i : (i % 8);
+ textHeight = 24;
+
+ // Has the draft been unlocked by the player?
+ titleColor = (draft & 0x2000) ? unlockedColor : inactiveColor;
+
+ // Has the new draft been used at least once?
+ notesColor = (draft & 0x4000) ? unlockedColor : newDraftColor;
+
+ // Has the draft been unlocked? Great: put it in our text buffer
+ // otherwise just prepare to render the "????" string.
+ if (draft & 0x2000) {
+ Common::sprintf_s(notesBuf, sizeof(notesBuf), "%c%c%c%c",
+ notes[draft & 0x0007],
+ notes[(draft & 0x0038) >> 3],
+ notes[(draft & 0x01c0) >> 6],
+ notes[(draft & 0x0e00) >> 9]);
+ } else {
+ notesColor = inactiveColor;
+ Common::sprintf_s(notesBuf, sizeof(notesBuf), "????");
+ }
+
+ // Where are we positioning the text?
+ // Left column or right column?
+ xPos = i < 8 ? 40 : 260;
+
+ // Draw the titles of the drafts...
+ if (draft & 0x2000) {
+ font->drawString(s, (char *)names[i + 1], xPos - 20, 24 + textHeight * heightMultiplier, s->w, notesColor, Graphics::kTextAlignLeft);
+ } else {
+ // Draw "Unknown:" as the title of the draft
+ font->drawString(s, (char *)names[17], xPos - 20, 24 + textHeight * heightMultiplier, s->w, notesColor, Graphics::kTextAlignLeft);
+ }
+
+ // Draw the notes of the draft...
+ font->drawString(s, (char *)notesBuf, xPos + 100, 24 + textHeight * heightMultiplier, s->w, notesColor, Graphics::kTextAlignLeft);
+ }
+
+ // Draw "Drafts" on top of the dialog
+ font->drawString(s, (char *)names[0], 0, 4, s->w, kBlack, Graphics::kTextAlignCenter);
+
+ // Draw a vertical line to separate the two columns
+ s->drawLine(210, 44, 210, 184, kBlack);
+
+ // Update the screen with all the new stuff!
+ window->show();
+ return window;
+}
+
void MacGui::drawBitmap(Common::Rect r, const uint16 *bitmap, Color color) const {
drawBitmap(_surface, r, bitmap, color);
}
diff --git a/engines/scumm/gfx_mac.h b/engines/scumm/gfx_mac.h
index f3df770d302..75152bdfa6b 100644
--- a/engines/scumm/gfx_mac.h
+++ b/engines/scumm/gfx_mac.h
@@ -604,6 +604,7 @@ public:
MacDialogWindow *createWindow(Common::Rect bounds, MacDialogWindowStyle style = kStyleNormal);
MacDialogWindow *createDialog(int dialogId);
MacDialogWindow *drawBanner(char *message);
+ MacDialogWindow *drawDraftsInventory();
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 c10a24b3a5e..e39d229e47b 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -1167,7 +1167,11 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
if (enhancementEnabled(kEnhUIUX) && _game.id == GID_LOOM &&
mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_d && lastKeyHit.hasFlags(Common::KBD_CTRL))) {
// Drafts menu
- showDraftsInventory();
+ if (_macGui) {
+ mac_showDraftsInventory();
+ } else {
+ showDraftsInventory();
+ }
}
if (snapScrollKeyEnabled) {
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 2d55001d0cb..00948d0421d 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -1408,6 +1408,7 @@ 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