[Scummvm-git-logs] scummvm master -> 78c4d97f81db3e73e3ace4fcfe852d0f4c6465ce
eriktorbjorn
noreply at scummvm.org
Tue Dec 5 06:29:00 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:
78c4d97f81 SCUMM: Make Mac Indy 3 verb gui independent of position
Commit: 78c4d97f81db3e73e3ace4fcfe852d0f4c6465ce
https://github.com/scummvm/scummvm/commit/78c4d97f81db3e73e3ace4fcfe852d0f4c6465ce
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2023-12-05T07:27:12+01:00
Commit Message:
SCUMM: Make Mac Indy 3 verb gui independent of position
The GUI is now drawn on a sub-surface of the screen, and everything
inside it is positioned relative to that surface. This removes some of
the need to adjust things by _screenDrawOffset.
Changed paths:
engines/scumm/gfx_mac.cpp
engines/scumm/gfx_mac.h
diff --git a/engines/scumm/gfx_mac.cpp b/engines/scumm/gfx_mac.cpp
index 806f650dd42..cb7fa83e598 100644
--- a/engines/scumm/gfx_mac.cpp
+++ b/engines/scumm/gfx_mac.cpp
@@ -2513,7 +2513,7 @@ void MacGui::setPalette(const byte *palette, uint size) {
_windowManager->passPalette(palette, size);
}
-bool MacGui::handleEvent(Common::Event &event) {
+bool MacGui::handleEvent(Common::Event event) {
return _windowManager->processEvent(event);
}
@@ -3319,10 +3319,6 @@ MacGui::MacDialogWindow *MacGui::drawBanner(char *message) {
return window;
}
-void MacGui::drawBitmap(Common::Rect r, const uint16 *bitmap, Color color) const {
- drawBitmap(_surface, r, bitmap, color);
-}
-
void MacGui::drawBitmap(Graphics::Surface *s, Common::Rect r, const uint16 *bitmap, Color color) const {
assert(r.width() <= 16);
@@ -4155,7 +4151,7 @@ void MacLoomGui::update(int delta) {
}
}
-bool MacLoomGui::handleEvent(Common::Event &event) {
+bool MacLoomGui::handleEvent(Common::Event event) {
if (MacGui::handleEvent(event))
return true;
@@ -4342,12 +4338,12 @@ byte MacIndy3Gui::Widget::translateChar(byte c) const {
return c;
}
-void MacIndy3Gui::Widget::fill(Common::Rect r) const {
+void MacIndy3Gui::Widget::fill(Common::Rect r) {
_gui->fill(r);
}
void MacIndy3Gui::Widget::drawBitmap(Common::Rect r, const uint16 *bitmap, Color color) const {
- _gui->drawBitmap(r, bitmap, color);
+ _gui->drawBitmap(_surface, r, bitmap, color);
}
// The shadow box is the basic outline of the verb buttons and the inventory
@@ -4369,7 +4365,7 @@ void MacIndy3Gui::Widget::drawShadowBox(Common::Rect r) const {
// The shadow frame is a rectangle with a highlight. It can be filled or
// unfilled.
-void MacIndy3Gui::Widget::drawShadowFrame(Common::Rect r, Color shadowColor, Color fillColor) const {
+void MacIndy3Gui::Widget::drawShadowFrame(Common::Rect r, Color shadowColor, Color fillColor) {
_surface->hLine(r.left, r.top, r.right - 1, kBlack);
_surface->hLine(r.left, r.bottom - 1, r.right - 1, kBlack);
_surface->vLine(r.left, r.top + 1, r.bottom - 2, kBlack);
@@ -4430,7 +4426,7 @@ void MacIndy3Gui::VerbWidget::undraw() {
// and conversation options.
// ---------------------------------------------------------------------------
-MacIndy3Gui::Button::Button(int x, int y, int width, int height) : VerbWidget(x, y + 2 * Widget::_vm->_screenDrawOffset, width, height) {
+MacIndy3Gui::Button::Button(int x, int y, int width, int height) : VerbWidget(x, y, width, height) {
}
void MacIndy3Gui::Button::reset() {
@@ -4572,7 +4568,7 @@ void MacIndy3Gui::Button::draw() {
// the scrollbar.
// ---------------------------------------------------------------------------
-MacIndy3Gui::Inventory::Inventory(int x, int y, int width, int height) : MacIndy3Gui::VerbWidget(x, y + 2 * Widget::_vm->_screenDrawOffset, width, height) {
+MacIndy3Gui::Inventory::Inventory(int x, int y, int width, int height) : MacIndy3Gui::VerbWidget(x, y, width, height) {
x = _bounds.left + 6;
y = _bounds.top + 6;
@@ -5110,42 +5106,48 @@ void MacIndy3Gui::Inventory::ScrollButton::draw() {
MacIndy3Gui::MacIndy3Gui(ScummEngine *vm, Common::String resourceFile) :
MacGui(vm, resourceFile), _visible(false) {
+ Common::Rect verbGuiArea(640, 112);
+ verbGuiArea.translate(0, 288 + 2 * _vm->_screenDrawOffset);
+
+ _verbGuiTop = verbGuiArea.top;
+ _verbGuiSurface = _surface->getSubArea(verbGuiArea);
+
// There is one widget for every verb in the game. Verbs include the
// inventory widget and conversation options.
Widget::_vm = _vm;
- Widget::_surface = _surface;
+ Widget::_surface = &_verbGuiSurface;
Widget::_gui = this;
- _widgets[ 1] = new Button(137, 312, 68, 18); // Open
- _widgets[ 2] = new Button(137, 332, 68, 18); // Close
- _widgets[ 3] = new Button( 67, 352, 68, 18); // Give
- _widgets[ 4] = new Button(277, 332, 68, 18); // Turn on
- _widgets[ 5] = new Button(277, 352, 68, 18); // Turn off
- _widgets[ 6] = new Button( 67, 312, 68, 18); // Push
- _widgets[ 7] = new Button( 67, 332, 68, 18); // Pull
- _widgets[ 8] = new Button(277, 312, 68, 18); // Use
- _widgets[ 9] = new Button(137, 352, 68, 18); // Look at
- _widgets[ 10] = new Button(207, 312, 68, 18); // Walk to
- _widgets[ 11] = new Button(207, 332, 68, 18); // Pick up
- _widgets[ 12] = new Button(207, 352, 68, 18); // What is
- _widgets[ 13] = new Button(347, 312, 68, 18); // Talk
- _widgets[ 14] = new Button( 97, 312, 121, 18); // Never mind.
- _widgets[ 32] = new Button(347, 332, 68, 18); // Travel
- _widgets[ 33] = new Button(347, 352, 68, 18); // To Indy
- _widgets[ 34] = new Button(347, 352, 68, 18); // To Henry
- _widgets[ 90] = new Button( 67, 292, 507, 18); // Travel 1
- _widgets[ 91] = new Button( 67, 312, 507, 18); // Travel 2
- _widgets[ 92] = new Button( 67, 332, 507, 18); // Travel 3
- _widgets[100] = new Button( 67, 292, 348, 18); // Sentence
- _widgets[101] = new Inventory(417, 292, 157, 78);
- _widgets[119] = new Button(324, 312, 91, 18); // Take this:
- _widgets[120] = new Button( 67, 292, 507, 18); // Converse 1
- _widgets[121] = new Button( 67, 312, 507, 18); // Converse 2
- _widgets[122] = new Button( 67, 332, 507, 18); // Converse 3
- _widgets[123] = new Button( 67, 352, 507, 18); // Converse 4
- _widgets[124] = new Button( 67, 352, 151, 18); // Converse 5
- _widgets[125] = new Button(423, 352, 151, 18); // Converse 6
+ _widgets[ 1] = new Button(137, 24, 68, 18); // Open
+ _widgets[ 2] = new Button(137, 44, 68, 18); // Close
+ _widgets[ 3] = new Button( 67, 64, 68, 18); // Give
+ _widgets[ 4] = new Button(277, 44, 68, 18); // Turn on
+ _widgets[ 5] = new Button(277, 64, 68, 18); // Turn off
+ _widgets[ 6] = new Button( 67, 24, 68, 18); // Push
+ _widgets[ 7] = new Button( 67, 44, 68, 18); // Pull
+ _widgets[ 8] = new Button(277, 24, 68, 18); // Use
+ _widgets[ 9] = new Button(137, 64, 68, 18); // Look at
+ _widgets[ 10] = new Button(207, 24, 68, 18); // Walk to
+ _widgets[ 11] = new Button(207, 44, 68, 18); // Pick up
+ _widgets[ 12] = new Button(207, 64, 68, 18); // What is
+ _widgets[ 13] = new Button(347, 24, 68, 18); // Talk
+ _widgets[ 14] = new Button( 97, 24, 121, 18); // Never mind.
+ _widgets[ 32] = new Button(347, 44, 68, 18); // Travel
+ _widgets[ 33] = new Button(347, 64, 68, 18); // To Indy
+ _widgets[ 34] = new Button(347, 64, 68, 18); // To Henry
+ _widgets[ 90] = new Button( 67, 4, 507, 18); // Travel 1
+ _widgets[ 91] = new Button( 67, 24, 507, 18); // Travel 2
+ _widgets[ 92] = new Button( 67, 44, 507, 18); // Travel 3
+ _widgets[100] = new Button( 67, 4, 348, 18); // Sentence
+ _widgets[101] = new Inventory(417, 4, 157, 78);
+ _widgets[119] = new Button(324, 24, 91, 18); // Take this:
+ _widgets[120] = new Button( 67, 4, 507, 18); // Converse 1
+ _widgets[121] = new Button( 67, 24, 507, 18); // Converse 2
+ _widgets[122] = new Button( 67, 44, 507, 18); // Converse 3
+ _widgets[123] = new Button( 67, 64, 507, 18); // Converse 4
+ _widgets[124] = new Button( 67, 64, 151, 18); // Converse 5
+ _widgets[125] = new Button(423, 64, 151, 18); // Converse 6
for (auto &it: _widgets)
it._value->setVerbid(it._key);
@@ -5966,7 +5968,7 @@ void MacIndy3Gui::drawVerbs() {
}
}
-bool MacIndy3Gui::handleEvent(Common::Event &event) {
+bool MacIndy3Gui::handleEvent(Common::Event event) {
if (MacGui::handleEvent(event))
return true;
@@ -5976,6 +5978,11 @@ bool MacIndy3Gui::handleEvent(Common::Event &event) {
if (!isPauseEvent && (!isVerbGuiActive() || _vm->_userPut <= 0))
return false;
+ // Make all mouse events relative to the verb GUI area
+
+ if (Common::isMouseEvent(event))
+ event.mouse.y -= _verbGuiTop;
+
if (event.type == Common::EVENT_LBUTTONDOWN) {
if (!_leftButtonIsPressed) {
debug(2, "MacIndy3Gui: Left button down");
@@ -5993,8 +6000,10 @@ bool MacIndy3Gui::handleEvent(Common::Event &event) {
_timer = 0;
}
} else if (event.type == Common::EVENT_MOUSEMOVE) {
- if (_leftButtonIsPressed)
- _leftButtonHeld = event.mouse;
+ if (_leftButtonIsPressed) {
+ _leftButtonHeld.x = event.mouse.x;
+ _leftButtonHeld.y = event.mouse.y;
+ }
}
// It probably doesn't make much of a difference, but if a widget
@@ -6024,22 +6033,28 @@ void MacIndy3Gui::show() {
_visible = true;
- _surface->fillRect(Common::Rect(0, 288 + 2 * (_vm->_screenDrawOffset), 640, 289 + 2 * (_vm->_screenDrawOffset)), kBlack);
- _surface->fillRect(Common::Rect(0, 373 + 2 * (_vm->_screenDrawOffset), 640, _vm->_useMacScreenCorrectHeight ? 480 : 400), kBlack);
+ // The top and bottom of the verb GUI area black. On a screen that's
+ // 400 pixels tall, the verb GUI extends all the way to the bottom. On
+ // a 480 pixel tall screen there will be an additional 40 pixels below
+ // that, but nothing should ever be drawn there and if it ever is, it's
+ // not the verb GUI's responsibility to clear it.
- fill(Common::Rect(0, 290 + 2 * (_vm->_screenDrawOffset), 640, 373 + 2 * (_vm->_screenDrawOffset)));
+ _verbGuiSurface.fillRect(Common::Rect(0, 0, 640, 1), kBlack);
+ _verbGuiSurface.fillRect(Common::Rect(0, 85, 640, _verbGuiSurface.h), kBlack);
+
+ fill(Common::Rect(0, 2, 640, 85));
const uint16 ulCorner[] = { 0xF000, 0xC000, 0x8000, 0x8000 };
const uint16 urCorner[] = { 0xF000, 0x3000, 0x1000, 0x1000 };
const uint16 llCorner[] = { 0x8000, 0x8000, 0xC000, 0xF000 };
const uint16 lrCorner[] = { 0x1000, 0x1000, 0x3000, 0xF000 };
- drawBitmap(Common::Rect( 0, 290 + 2 * (_vm->_screenDrawOffset), 4, 294 + 2 * (_vm->_screenDrawOffset)), ulCorner, kBlack);
- drawBitmap(Common::Rect(636, 290 + 2 * (_vm->_screenDrawOffset), 640, 294 + 2 * (_vm->_screenDrawOffset)), urCorner, kBlack);
- drawBitmap(Common::Rect( 0, 369 + 2 * (_vm->_screenDrawOffset), 4, 373 + 2 * (_vm->_screenDrawOffset)), llCorner, kBlack);
- drawBitmap(Common::Rect(636, 369 + 2 * (_vm->_screenDrawOffset), 640, 373 + 2 * (_vm->_screenDrawOffset)), lrCorner, kBlack);
+ drawBitmap(&_verbGuiSurface, Common::Rect( 0, 2, 4, 6), ulCorner, kBlack);
+ drawBitmap(&_verbGuiSurface, Common::Rect(636, 2, 640, 6), urCorner, kBlack);
+ drawBitmap(&_verbGuiSurface, Common::Rect( 0, 81, 4, 85), llCorner, kBlack);
+ drawBitmap(&_verbGuiSurface, Common::Rect(636, 81, 640, 85), lrCorner, kBlack);
- markScreenAsDirty(Common::Rect(0, 288 + 2 * (_vm->_screenDrawOffset), 640, _vm->_useMacScreenCorrectHeight ? 480 : 400));
+ markScreenAsDirty(Common::Rect(_verbGuiSurface.w, _verbGuiSurface.h));
}
void MacIndy3Gui::hide() {
@@ -6053,9 +6068,13 @@ void MacIndy3Gui::hide() {
reset();
+ // If the verb GUI is allowed, the area should be cleared. If the verb
+ // GUI is not allowed, the game is presumably using it for its own
+ // drawing, and we should leave it alone.
+
if (isVerbGuiAllowed()) {
- _surface->fillRect(Common::Rect(0, 288 + 2 * (_vm->_screenDrawOffset), 640, _vm->_useMacScreenCorrectHeight ? 480 : 400), kBlack);
- markScreenAsDirty(Common::Rect(0, 288 + 2 * (_vm->_screenDrawOffset), 640, _vm->_useMacScreenCorrectHeight ? 480 : 400));
+ _verbGuiSurface.fillRect(Common::Rect(_verbGuiSurface.w, _verbGuiSurface.h), kBlack);
+ markScreenAsDirty(Common::Rect(_verbGuiSurface.w, _verbGuiSurface.h));
}
}
@@ -6074,22 +6093,22 @@ void MacIndy3Gui::markScreenAsDirty(Common::Rect r) {
void MacIndy3Gui::copyDirtyRectsToScreen() {
for (uint i = 0; i < _dirtyRects.size(); i++) {
_system->copyRectToScreen(
- _surface->getBasePtr(_dirtyRects[i].left, _dirtyRects[i].top),
- _surface->pitch,
- _dirtyRects[i].left, _dirtyRects[i].top,
+ _verbGuiSurface.getBasePtr(_dirtyRects[i].left, _dirtyRects[i].top),
+ _verbGuiSurface.pitch,
+ _dirtyRects[i].left, _verbGuiTop + _dirtyRects[i].top,
_dirtyRects[i].width(), _dirtyRects[i].height());
}
_dirtyRects.clear();
}
-void MacIndy3Gui::fill(Common::Rect r) const {
- int pitch = _surface->pitch;
+void MacIndy3Gui::fill(Common::Rect r) {
+ int pitch = _verbGuiSurface.pitch;
// Fill the screen with either gray of a checkerboard pattern.
if (_vm->_renderMode == Common::kRenderMacintoshBW) {
- byte *row = (byte *)_surface->getBasePtr(r.left, r.top);
+ byte *row = (byte *)_verbGuiSurface.getBasePtr(r.left, r.top);
for (int y = r.top; y < r.bottom; y++) {
byte *ptr = row;
@@ -6098,7 +6117,7 @@ void MacIndy3Gui::fill(Common::Rect r) const {
row += pitch;
}
} else
- _surface->fillRect(r, kLightGray);
+ _verbGuiSurface.fillRect(r, kLightGray);
}
} // End of namespace Scumm
diff --git a/engines/scumm/gfx_mac.h b/engines/scumm/gfx_mac.h
index cc1151df8ec..64b64ff1454 100644
--- a/engines/scumm/gfx_mac.h
+++ b/engines/scumm/gfx_mac.h
@@ -582,7 +582,7 @@ public:
int toMacRoman(int unicode) const;
void setPalette(const byte *palette, uint size);
- virtual bool handleEvent(Common::Event &event);
+ virtual bool handleEvent(Common::Event event);
static void menuCallback(int id, Common::String &name, void *data);
virtual void initialize();
@@ -613,7 +613,6 @@ public:
MacDialogWindow *createDialog(int dialogId);
MacDialogWindow *drawBanner(char *message);
- 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;
};
@@ -624,7 +623,7 @@ public:
const Common::String name() const { return "Loom"; }
- bool handleEvent(Common::Event &event);
+ bool handleEvent(Common::Event event);
const Graphics::Font *getFontByScummId(int32 id);
@@ -689,7 +688,7 @@ public:
void reset();
void resetAfterLoad();
void update(int delta);
- bool handleEvent(Common::Event &event);
+ bool handleEvent(Common::Event event);
protected:
bool getFontParams(FontId fontId, int &id, int &size, int &slant) const;
@@ -703,6 +702,9 @@ protected:
bool runIqPointsDialog();
private:
+ int _verbGuiTop = 0;
+ Graphics::Surface _verbGuiSurface;
+
bool _visible = false;
bool _leftButtonIsPressed = false;
@@ -760,10 +762,10 @@ private:
byte translateChar(byte c) const;
// Primitives
- void fill(Common::Rect r) const;
+ void fill(Common::Rect r);
void drawBitmap(Common::Rect r, const uint16 *bitmap, Color color) const;
void drawShadowBox(Common::Rect r) const;
- void drawShadowFrame(Common::Rect r, Color shadowColor, Color fillColor) const;
+ void drawShadowFrame(Common::Rect r, Color shadowColor, Color fillColor);
void markScreenAsDirty(Common::Rect r) const;
};
@@ -895,7 +897,7 @@ private:
void show();
void hide();
- void fill(Common::Rect r) const;
+ void fill(Common::Rect r);
void markScreenAsDirty(Common::Rect r);
void copyDirtyRectsToScreen();
More information about the Scummvm-git-logs
mailing list