[Scummvm-git-logs] scummvm master -> 6700c810fad3764dd1fc20c667ba362f77d48b0d

sev- noreply at scummvm.org
Wed May 31 11:29:39 UTC 2023


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
84b2442fac DIRECTOR: Allow calling/reference to window using index
23f1229e67 GRAPHICS: MACGUI: Refactor resize() to extract inner window resizing
4f07e8dec4 GRAPHICS: MACGUI: Added support to change inner dimension of macwindow derived object
6700c810fa DIRECTOR: Get/Set `rect` property of window, allow dynamic resize/move.


Commit: 84b2442facf478f1a62abbb5e218a9a9e2d471d3
    https://github.com/scummvm/scummvm/commit/84b2442facf478f1a62abbb5e218a9a9e2d471d3
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-05-31T13:29:33+02:00

Commit Message:
DIRECTOR: Allow calling/reference to window using index

Initially, window can only handle calls by string parameters, ie `window "abc"`, however a window can also be called using its index in windowList, ex. `window 1`, this patch adds support to check reference type (ie checking using STRING or INT) and return window by index if applicable.

`rect of window` of `workshop` used this feature to create a window named ball then referring to it using `window 1`, previously multiple windows were getting created, however now the existing window will be returned.

Changed paths:
    engines/director/lingo/lingo-builtins.cpp


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index dddb9bdde9e..7f9ebd1bcb3 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -3162,6 +3162,23 @@ void LB::b_window(int nargs) {
 		}
 	}
 
+	// Refer window by-indexing, lingo can request using "window #index" where #index is the index of window that is previously
+	// created, in tutorial workshop `rect of window`, a window is created using 'open(window "ball")' and the same window is
+	// referenced by 'window 1', ie 'put the rect of window 1 into field 9'
+	if (d.type == INT || d.type == FLOAT) {
+		int windowIndex = d.asInt() - 1;
+
+		if (windowIndex >= 0 && windowIndex < (int)windowList->arr.size()) {
+			if (windowList->arr[windowIndex].type == OBJECT && windowList->arr[windowIndex].u.obj->getObjType() == kWindowObj) {
+				Window *window = static_cast<Window *>(windowList->arr[windowIndex].u.obj);
+				g_lingo->push(window);
+				return;
+			}
+		} else {
+			warning("LB::b_window: Window referenced by index %d, out of bounds.", windowIndex);
+		}
+	}
+
 	Graphics::MacWindowManager *wm = g_director->getMacWindowManager();
 	Window *window = new Window(wm->getNextId(), false, false, false, wm, g_director, false);
 	window->setName(windowName);


Commit: 23f1229e67d224c0b4aa59aa28090ea8519ea3ac
    https://github.com/scummvm/scummvm/commit/23f1229e67d224c0b4aa59aa28090ea8519ea3ac
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-05-31T13:29:33+02:00

Commit Message:
GRAPHICS: MACGUI: Refactor resize() to extract inner window resizing

resize function is extracted to new function resize and resizeInner,
also a new private function rebuildSurface is created to handle common
code of refreshing/rebuilding surface after modifying inner or outer
window dimensions.

Changed paths:
    engines/director/lingo/lingo-builtins.cpp
    engines/director/movie.cpp
    engines/director/window.cpp
    graphics/macgui/mactextwindow.cpp
    graphics/macgui/mactextwindow.h
    graphics/macgui/macwindow.cpp
    graphics/macgui/macwindow.h


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 7f9ebd1bcb3..21818526f4e 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -3183,7 +3183,7 @@ void LB::b_window(int nargs) {
 	Window *window = new Window(wm->getNextId(), false, false, false, wm, g_director, false);
 	window->setName(windowName);
 	window->setTitle(windowName);
-	window->resize(1, 1, true);
+	window->resizeInner(1, 1);
 	window->setVisible(false, true);
 	wm->addWindowInitialized(window);
 	windowList->arr.push_back(window);
diff --git a/engines/director/movie.cpp b/engines/director/movie.cpp
index f3bbaa44339..b58c6be1ae9 100644
--- a/engines/director/movie.cpp
+++ b/engines/director/movie.cpp
@@ -209,7 +209,7 @@ bool Movie::loadArchive() {
 	// If the stage dimensions are different, delete it and start again.
 	// Otherwise, do not clear it so there can be a nice transition.
 	if (_window->getSurface()->w != _movieRect.width() || _window->getSurface()->h != _movieRect.height()) {
-		_window->resize(_movieRect.width(), _movieRect.height(), true);
+		_window->resizeInner(_movieRect.width(), _movieRect.height());
 		recenter = true;
 	}
 
diff --git a/engines/director/window.cpp b/engines/director/window.cpp
index a1bc99b23e4..169aebbedeb 100644
--- a/engines/director/window.cpp
+++ b/engines/director/window.cpp
@@ -227,7 +227,7 @@ Datum Window::getStageRect() {
 }
 
 void Window::reset() {
-	resize(_composeSurface->w, _composeSurface->h, true);
+	resizeInner(_composeSurface->w, _composeSurface->h);
 	_contentIsDirty = true;
 }
 
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index 1b51ced7863..1783e4acf38 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -99,7 +99,7 @@ void MacTextWindow::init(bool cursorHandler) {
 	}
 }
 
-void MacTextWindow::resize(int w, int h, bool inner) {
+void MacTextWindow::resize(int w, int h) {
 	if (_composeSurface->w == w && _composeSurface->h == h)
 		return;
 
diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h
index 7ee7d67515f..aea850f5104 100644
--- a/graphics/macgui/mactextwindow.h
+++ b/graphics/macgui/mactextwindow.h
@@ -33,7 +33,7 @@ public:
 	MacTextWindow(MacWindowManager *wm, const Font *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, MacMenu *menu, bool cursorHandler = true);
 	virtual ~MacTextWindow();
 
-	virtual void resize(int w, int h, bool inner = false) override;
+	virtual void resize(int w, int h) override;
 	void setDimensions(const Common::Rect &r) override;
 
 	virtual bool processEvent(Common::Event &event) override;
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index dc53f6a29ff..216f3a245f3 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -90,20 +90,29 @@ void MacWindow::setActive(bool active) {
 
 bool MacWindow::isActive() const { return _active; }
 
-void MacWindow::resize(int w, int h, bool inner) {
+void MacWindow::resize(int w, int h) {
 	if (_composeSurface->w == w && _composeSurface->h == h)
 		return;
 
-	if (inner) {
-		_innerDims.setWidth(w);
-		_innerDims.setHeight(h);
-		updateOuterDims();
-	} else {
-		_dims.setWidth(w);
-		_dims.setHeight(h);
-		updateInnerDims();
-	}
+	_dims.setWidth(w);
+	_dims.setHeight(h);
+	updateInnerDims();
+	
+	rebuildSurface();
+}
+
+void MacWindow::resizeInner(int w, int h) {
+	if (_composeSurface->w == w && _composeSurface->h == h)
+		return;
+
+	_innerDims.setWidth(w);
+	_innerDims.setHeight(h);
+	updateOuterDims();
+
+	rebuildSurface();
+}
 
+void MacWindow::rebuildSurface() {
 	_composeSurface->free();
 	_composeSurface->create(_innerDims.width(), _innerDims.height(), _wm->_pixelformat);
 
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index 724b4e1e27c..92d42d5fd81 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -212,12 +212,18 @@ public:
 	void move(int x, int y);
 
 	/*
-	 * Change the width and the height of the window.
+	 * Change the width and the height of the window (outer dimensions).
 	 * @param w New width of the window.
 	 * @param h New height of the window.
-	 * @param inner True to set the inner dimensions.
 	 */
-	virtual void resize(int w, int h, bool inner = false);
+	virtual void resize(int w, int h);
+
+	/*
+	 * Change the width and the height of the inner window.
+	 * @param w New width of the window.
+	 * @param h New height of the window.
+	 */
+	virtual void resizeInner(int w, int h);
 
 	/**
 	 * Change the dimensions of the window ([0, 0, 0, 0] by default).
@@ -354,6 +360,7 @@ public:
 	void updateInnerDims();
 
 private:
+	void rebuildSurface(); // Propagate dimensions change and recreate patter/borders, etc.
 	void drawBorderFromSurface(ManagedSurface *g, uint32 flags);
 	void drawPattern();
 	void drawBox(ManagedSurface *g, int x, int y, int w, int h);


Commit: 4f07e8dec4fcc2d5b6a4c505fcec77a914ace853
    https://github.com/scummvm/scummvm/commit/4f07e8dec4fcc2d5b6a4c505fcec77a914ace853
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-05-31T13:29:33+02:00

Commit Message:
GRAPHICS: MACGUI: Added support to change inner dimension of macwindow derived object

Added setInnerDimension which calls resize (with bool inner dimension change: true), moveto and finally updateOuterDimension.

This was implemented to match window rectangle size as used by window property `rect`, `rect of window` in `workshop` uses this.

Changed paths:
    graphics/macgui/macwindow.cpp
    graphics/macgui/macwindow.h


diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 216f3a245f3..7f314935e61 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -147,6 +147,15 @@ void MacWindow::setDimensions(const Common::Rect &r) {
 	_wm->setFullRefresh(true);
 }
 
+void MacWindow::setInnerDimensions(const Common::Rect &r) {
+	resizeInner(r.width(), r.height());
+	_innerDims.moveTo(r.left, r.top);
+	updateOuterDims();
+
+	_contentIsDirty = true;
+	_wm->setFullRefresh(true);
+}
+
 void MacWindow::setBackgroundPattern(int pattern) {
 	_pattern = pattern;
 	_hasPattern = true;
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index 92d42d5fd81..9b966278fc6 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -233,6 +233,14 @@ public:
 	 */
 	void setDimensions(const Common::Rect &r) override;
 
+	/**
+	 * Change the inner dimension of the window.
+	 * Note that this changes the window inner dimension and calculates
+	 * outer dimension (ie with border, etc)
+	 * @param r The desired dimensions of the window.
+	 */
+	void setInnerDimensions(const Common::Rect &r);
+
 	/**
 	 * Set a background pattern for the window.
 	 * @param pattern


Commit: 6700c810fad3764dd1fc20c667ba362f77d48b0d
    https://github.com/scummvm/scummvm/commit/6700c810fad3764dd1fc20c667ba362f77d48b0d
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-05-31T13:29:33+02:00

Commit Message:
DIRECTOR: Get/Set `rect` property of window, allow dynamic resize/move.

Adds the support to get/set field 'rect' of window object, interally it modifies the inner dimension of window object.

'mcluhan' used this to set window dimensions of background windows (through tell), Additionally `rect of window` in `workshop` also uses this patch for setting/getting field `rect` of window.

Changed paths:
    engines/director/lingo/lingo-object.cpp
    engines/director/window.cpp
    engines/director/window.h


diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp
index b925208091c..121c3e6b30b 100644
--- a/engines/director/lingo/lingo-object.cpp
+++ b/engines/director/lingo/lingo-object.cpp
@@ -618,6 +618,8 @@ bool Window::setField(int field, const Datum &value) {
 	case kTheWindowType:
 		setWindowType(value.asInt());
 		return true;
+	case kTheRect:
+		return setStageRect(value);
 	default:
 		warning("Window::setField: unhandled field '%s'", g_lingo->field2str(field));
 		return false;
diff --git a/engines/director/window.cpp b/engines/director/window.cpp
index 169aebbedeb..e24f4de1c2f 100644
--- a/engines/director/window.cpp
+++ b/engines/director/window.cpp
@@ -215,17 +215,32 @@ void Window::setStageColor(uint32 stageColor, bool forceReset) {
 }
 
 Datum Window::getStageRect() {
-	Graphics::ManagedSurface *surface = getSurface();
+	Common::Rect rect = getInnerDimensions();
 	Datum d;
 	d.type = RECT;
 	d.u.farr = new FArray;
-	d.u.farr->arr.push_back(0);
-	d.u.farr->arr.push_back(0);
-	d.u.farr->arr.push_back(surface->w);
-	d.u.farr->arr.push_back(surface->h);
+	d.u.farr->arr.push_back(rect.left);
+	d.u.farr->arr.push_back(rect.top);
+	d.u.farr->arr.push_back(rect.right);
+	d.u.farr->arr.push_back(rect.bottom);
+
 	return d;
 }
 
+bool Window::setStageRect(Datum datum) {
+	if (datum.type != RECT) {
+		warning("Window::setStageRect(): bad argument passed to rect field");
+		return false;
+	}
+
+	// Unpack rect from datum
+	Common::Rect rect = Common::Rect(datum.u.farr->arr[0].asInt(), datum.u.farr->arr[1].asInt(), datum.u.farr->arr[2].asInt(), datum.u.farr->arr[3].asInt());
+
+	setInnerDimensions(rect);
+
+	return true;
+}
+
 void Window::reset() {
 	resizeInner(_composeSurface->w, _composeSurface->h);
 	_contentIsDirty = true;
diff --git a/engines/director/window.h b/engines/director/window.h
index 70199f75b59..6e8098a1d96 100644
--- a/engines/director/window.h
+++ b/engines/director/window.h
@@ -142,6 +142,7 @@ public:
 	void setTitleVisible(bool titleVisible) { _titleVisible = titleVisible; updateBorderType(); };
 	bool isTitleVisible() { return _titleVisible; };
 	Datum getStageRect();
+	bool setStageRect(Datum datum);
 
 	void updateBorderType();
 




More information about the Scummvm-git-logs mailing list