[Scummvm-git-logs] scummvm master -> dc5d474160bcba1eb04fad4474f6294d74f4a6fe

sev- sev at scummvm.org
Sun Sep 19 13:22:11 UTC 2021


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

Summary:
3e88a642f0 MACVENTURE: Fix/Refactor code to work with changes made in macgui and other parts of ScummVM
40f825de6a MACVENTURE: Fix bounds for selecting objects
e43d08ff43 MACVENTURE: Fix Inventory window Width and Height reading
5f569ce0a6 MACVENTURE: Fix Main window working while there is still need for click to continue
d754ed0e27 MACVENTURE: Fix missing characters in some words in output console
bf46669cf8 MACGUI: Add methods to find top window at at a given point
2e4117e388 MACVENTURE: Add title to windows
04a2a1f87c MACGUI: Fix code formatting according to coding conventions
0638fca683 MACVENTURE: Remove unnecessary adding of NULL character to string
6bc5d0e9ae MACVENTURE: Fix object not dropping at left side of window
dd6508500c MACVENTURE: Fix Output console text width
9ad16ff273 MACVENTURE: Initialize struct according to C++98 convention
9f479e06f4 MACVENTURE: fixed whitespaces
1287dce313 MACGUI: whitespace issues
b73889d2e0 MACVENTURE: pass by reference
37de1b3146 MACGUI: const for some methods
dc5d474160 MACVENTURE: re-use the read stream to reduce heap allocations


Commit: 3e88a642f0443eb87296c03ac5509463561d408b
    https://github.com/scummvm/scummvm/commit/3e88a642f0443eb87296c03ac5509463561d408b
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: Fix/Refactor code to work with changes made in macgui and other parts of ScummVM

Changed paths:
    engines/macventure/gui.cpp
    engines/macventure/gui.h
    engines/macventure/macventure.cpp
    engines/macventure/windows.cpp
    engines/macventure/windows.h


diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 65a96b8b12..87df6ab31e 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -217,41 +217,65 @@ void Gui::clearControls() {
 }
 
 void Gui::initWindows() {
+	Common::Rect bounds;
+	BorderBounds bbs = {0 , 0, 0, 0, 0, 0};
 	// Game Controls Window
 	_controlsWindow = _wm.addWindow(false, false, false);
-	_controlsWindow->setDimensions(getWindowData(kCommandsWindow).bounds);
+	
+
+	bounds = getWindowData(kCommandsWindow).bounds;
+	bbs = borderBounds(findWindowData(kCommandsWindow).type);
+	loadBorders(_controlsWindow, findWindowData(kCommandsWindow).type);
+	_controlsWindow->resize(bounds.width(), bounds.height(), true);
+	_controlsWindow->move(bounds.left - bbs.leftOffset, bounds.top - bbs.topOffset);
+
 	_controlsWindow->setActive(false);
 	_controlsWindow->setCallback(commandsWindowCallback, this);
-	loadBorders(_controlsWindow, findWindowData(kCommandsWindow).type);
 
 	// Main Game Window
 	_mainGameWindow = _wm.addWindow(false, false, false);
-	_mainGameWindow->setDimensions(getWindowData(kMainGameWindow).bounds);
+	bounds = getWindowData(kMainGameWindow).bounds;
+	bbs = borderBounds(findWindowData(kMainGameWindow).type);
+
+	loadBorders(_mainGameWindow, findWindowData(kMainGameWindow).type);
+	_mainGameWindow->resize(bounds.width(), bounds.height(), true);
+	_mainGameWindow->move(bounds.left - bbs.leftOffset, bounds.top - bbs.topOffset);
+
 	_mainGameWindow->setActive(false);
 	_mainGameWindow->setCallback(mainGameWindowCallback, this);
-	loadBorders(_mainGameWindow, findWindowData(kMainGameWindow).type);
 
 	// In-game Output Console
 	_outConsoleWindow = _wm.addWindow(true, true, false);
-	// HACK We have to hand-create the dimensions, otherwise they don't fit
-	const WindowData &wd = getWindowData(kOutConsoleWindow);
-	Common::Rect dimensions = wd.bounds;
-	dimensions.setWidth(dimensions.width() - borderBounds(wd.type).rightOffset);
-	_outConsoleWindow->setDimensions(dimensions);
+
+	bounds = getWindowData(kOutConsoleWindow).bounds;
+	bbs = borderBounds(findWindowData(kOutConsoleWindow).type);
+	loadBorders(_outConsoleWindow, findWindowData(kOutConsoleWindow).type);
+	_outConsoleWindow->resize(bounds.width() - bbs.rightScrollbarWidth, bounds.height() - bbs.bottomScrollbarHeight, true);
+	_outConsoleWindow->move(bounds.left - bbs.leftOffset, bounds.top - bbs.topOffset);
 	_outConsoleWindow->setActive(false);
 	_outConsoleWindow->setCallback(outConsoleWindowCallback, this);
-	loadBorders(_outConsoleWindow, findWindowData(kOutConsoleWindow).type);
 
 	// Self Window
 	_selfWindow = _wm.addWindow(false, true, false);
-	_selfWindow->setDimensions(getWindowData(kSelfWindow).bounds);
+	
+	bounds = getWindowData(kSelfWindow).bounds;
+	bbs = borderBounds(findWindowData(kSelfWindow).type);
+	loadBorders(_selfWindow, findWindowData(kSelfWindow).type);
+	_selfWindow->resize(bounds.width(), bounds.height(), true);
+	_selfWindow->move(bounds.left - bbs.leftOffset, bounds.top - bbs.topOffset);
+
 	_selfWindow->setActive(false);
 	_selfWindow->setCallback(selfWindowCallback, this);
-	loadBorders(_selfWindow, findWindowData(kSelfWindow).type);
 
 	// Exits Window
 	_exitsWindow = _wm.addWindow(false, false, false);
-	_exitsWindow->setDimensions(getWindowData(kExitsWindow).bounds);
+	
+	bounds = getWindowData(kExitsWindow).bounds;
+	bbs = borderBounds(findWindowData(kExitsWindow).type);
+	loadBorders(_exitsWindow, findWindowData(kExitsWindow).type);
+	_exitsWindow->resize(bounds.width(), bounds.height(), true);
+	_exitsWindow->move(bounds.left - bbs.leftOffset, bounds.top - bbs.topOffset);
+
 	_exitsWindow->setActive(false);
 	_exitsWindow->setCallback(exitsWindowCallback, this);
 
@@ -259,7 +283,6 @@ void Gui::initWindows() {
 	// object that can be used to refer to the room itself. In that case,
 	// the background should be kPatternDarkGray.
 	_exitsWindow->setBackgroundPattern(kPatternLightGray);
-	loadBorders(_exitsWindow, findWindowData(kExitsWindow).type);
 }
 
 const WindowData &Gui::getWindowData(WindowReference reference) {
@@ -332,7 +355,7 @@ void Gui::assignObjReferences() {
 }
 
 WindowReference Gui::createInventoryWindow(ObjID objRef) {
-	Graphics::MacWindow *newWindow = _wm.addWindow(true, true, true);
+	Graphics::MacWindow *newWindow = _wm.addWindow(true, true, false);
 	WindowData newData;
 	GlobalSettings settings = _engine->getGlobalSettings();
 	newData.refcon = (WindowReference)(_inventoryWindows.size() + kInventoryStart); // This is a HACK
@@ -341,12 +364,12 @@ WindowReference Gui::createInventoryWindow(ObjID objRef) {
 		newData.bounds = _windowData->back().bounds; // Inventory windows are always last
 		newData.bounds.translate(newData.bounds.left + settings._invOffsetX, newData.bounds.top + settings._invOffsetY);
 	} else {
-		BorderBounds bbs = borderBounds(kInvWindow);
 		newData.bounds = Common::Rect(
-			settings._invLeft - bbs.leftOffset,
-			settings._invTop - bbs.topOffset,
+			settings._invLeft,
+			settings._invTop,
 			settings._invLeft + settings._invWidth,
-			settings._invTop + settings._invHeight);
+			settings._invTop + settings._invHeight
+		);
 	}
 	newData.type = kInvWindow;
 	newData.hasCloseBox = true;
@@ -354,10 +377,14 @@ WindowReference Gui::createInventoryWindow(ObjID objRef) {
 	newData.objRef = objRef;
 	_windowData->push_back(newData);
 
+	BorderBounds bbs = borderBounds(newData.type);
 	newWindow->setDimensions(newData.bounds);
-	newWindow->setCallback(inventoryWindowCallback, this);
-	newWindow->setCloseable(true);
 	loadBorders(newWindow, newData.type);
+	newWindow->resize(newData.bounds.width() - bbs.rightScrollbarWidth, newData.bounds.height() - bbs.bottomScrollbarHeight, true);
+	newWindow->move(newData.bounds.left - bbs.leftOffset, newData.bounds.top - bbs.topOffset);
+	newWindow->setCallback(inventoryWindowCallback, this);
+	//newWindow->setCloseable(true);
+	
 	_inventoryWindows.push_back(newWindow);
 
 	debugC(1, kMVDebugGUI, "Create new inventory window. Reference: %d", newData.refcon);
@@ -371,14 +398,51 @@ void Gui::loadBorders(Graphics::MacWindow *target, MVWindowType type) {
 
 void Gui::loadBorder(Graphics::MacWindow *target, MVWindowType type, bool active) {
 
-	Common::SeekableReadStream *stream = _engine->getBorderFile(type, active);
+    Common::SeekableReadStream *stream;
 
-	if (stream) {
-		BorderBounds bbs = borderBounds(type);
-		target->loadBorder(*stream, active, bbs.leftOffset, bbs.rightOffset, bbs.topOffset, bbs.bottomOffset);
+    bool activeFlag = (active ? Graphics::kWindowBorderActive : 0);    
+    bool canHaveTitle = false;
+    bool canHaveScrollbar = false;
 
-		delete stream;
-	}
+    if (type == MacVenture::kInvWindow || type == MacVenture::kZoomDoc) {
+        canHaveScrollbar = true;
+    }
+
+    if (type == MacVenture::kInvWindow || type == MacVenture::kZoomDoc || type == MacVenture::kNoGrowDoc || type == MacVenture::kRDoc4) {
+        canHaveTitle = true;
+    }
+    
+	Graphics::BorderOffsets offsets = borderOffsets(type);
+    stream = _engine->getBorderFile(type, active);
+    
+	if (stream) {
+        target->loadBorder(*stream, activeFlag, offsets);
+        delete stream;
+    }
+
+    if (canHaveTitle) {
+        stream = _engine->getBorderFile(type, active);
+        if (stream) {
+            target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderTitle , offsets);
+            delete stream;
+        }
+    }
+
+    if (canHaveScrollbar) {
+        stream = _engine->getBorderFile(type, active);
+        if (stream) {
+            target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderScrollbar, offsets);
+            delete stream;
+        }
+    }
+
+    if (canHaveTitle && canHaveScrollbar) {
+        stream = _engine->getBorderFile(type, active);
+        if (stream) {
+            target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderTitle | Graphics::kWindowBorderScrollbar, offsets);
+            delete stream;
+        }
+    }
 }
 
 void Gui::loadGraphics() {
@@ -477,13 +541,12 @@ bool Gui::loadWindows() {
 		bottom = res->readUint16BE();
 		right = res->readUint16BE();
 		data.type = (MVWindowType)res->readUint16BE();
-		BorderBounds bbs = borderBounds(data.type);
 		data.bounds = Common::Rect(
-			left - bbs.leftOffset,
-			top - bbs.topOffset,
-			right + bbs.rightOffset,
-			bottom + bbs.bottomOffset);
-
+			left,
+			top,
+			right, 
+			bottom
+		);
 		data.visible = res->readUint16BE();
 		data.hasCloseBox = res->readUint16BE();
 		data.refcon = (WindowReference)id; id++;
@@ -544,17 +607,8 @@ bool Gui::loadControls() {
 			data.title = Common::String(title);
 			delete[] title;
 		}
-		if (data.type != kControlExitBox) {
-			BorderBounds bbs = borderBounds(getWindowData(kCommandsWindow).type);
-			// We just want to move the button, not change it's size
-			data.bounds = Common::Rect(left + bbs.leftOffset, top + bbs.topOffset, right + bbs.leftOffset, bottom + bbs.topOffset);
-		} else {
-			data.bounds = Common::Rect(left, top, right, bottom);
-		}
-
-
+		data.bounds = Common::Rect(left, top, right, bottom);
 		_controlData->push_back(CommandButton(data, this));
-
 		delete res;
 	}
 
@@ -597,7 +651,6 @@ void Gui::drawCommandsWindow() {
 
 void Gui::drawMainGameWindow() {
 	const WindowData &data = getWindowData(kMainGameWindow);
-	BorderBounds border = borderBounds(data.type);
 	ObjID objRef = data.objRef;
 
 	_mainGameWindow->setDirty(true);
@@ -607,8 +660,8 @@ void Gui::drawMainGameWindow() {
 
 		_assets[objRef]->blitInto(
 			_mainGameWindow->getWindowSurface(),
-			border.leftOffset,
-			border.topOffset,
+			0,
+			0,
 			kBlitDirect);
 	}
 
@@ -617,9 +670,7 @@ void Gui::drawMainGameWindow() {
 	if (DebugMan.isDebugChannelEnabled(kMVDebugGUI)) {
 		Graphics::MacWindow *win = findWindow(data.refcon);
 		Common::Rect innerDims = win->getInnerDimensions();
-		int x = win->getDimensions().left;
-		int y = win->getDimensions().top;
-		innerDims.translate(-x, -y);
+		innerDims.translate(-innerDims.left, -innerDims.top);
 		win->getWindowSurface()->frameRect(innerDims, kColorGreen);
 	}
 
@@ -647,9 +698,7 @@ void Gui::drawInventories() {
 
 		if (DebugMan.isDebugChannelEnabled(kMVDebugGUI)) {
 			Common::Rect innerDims = win->getInnerDimensions();
-			int x = win->getDimensions().left;
-			int y = win->getDimensions().top;
-			innerDims.translate(-x, -y);
+			innerDims.translate(-innerDims.left, -innerDims.top);
 			srf->frameRect(innerDims, kColorGreen);
 		}
 
@@ -723,7 +772,7 @@ void Gui::drawObjectsInWindow(const WindowData &targetData, Graphics::ManagedSur
 			surface->frameRect(testBounds, kColorGreen);
 		}
 	}
-	Common::Point composePosition = Common::Point(border.leftOffset, border.topOffset);
+	Common::Point composePosition = Common::Point(0, 0);//border.leftOffset, border.topOffset);
 	surface->transBlitFrom(composeSurface, composePosition, kColorGreen);
 }
 
@@ -844,7 +893,7 @@ void Gui::updateExit(ObjID obj) {
 	if (!_engine->isObjExit(obj)) {
 		return;
 	}
-	BorderBounds border = borderBounds(getWindowData(kExitsWindow).type);
+	//BorderBounds border = borderBounds(getWindowData(kExitsWindow).type);
 
 	int ctl = -1;
 	int i = 0;
@@ -865,8 +914,8 @@ void Gui::updateExit(ObjID obj) {
 		data.titleLength = 0;
 		data.refcon = (ControlAction)obj; // Objects can be exits (actions)
 		Common::Point pos = _engine->getObjExitPosition(obj);
-		pos.x += border.leftOffset;
-		pos.y += border.topOffset;
+		//pos.x += border.leftOffset;
+		//pos.y += border.topOffset;
 		data.bounds = Common::Rect(pos.x, pos.y, pos.x + kExitButtonWidth, pos.y + kExitButtonHeight);
 		data.visible = true;
 
@@ -923,8 +972,8 @@ void Gui::quitGame() {
 
 void Gui::createInnerSurface(Graphics::ManagedSurface *innerSurface, Graphics::ManagedSurface *outerSurface, const BorderBounds &borders) {
 	innerSurface->create(
-		outerSurface->w - borders.leftOffset - borders.rightOffset,
-		outerSurface->h - borders.topOffset - borders.bottomOffset,
+		outerSurface->w,// - borders.leftOffset - borders.rightOffset,
+		outerSurface->h,// - borders.topOffset - borders.bottomOffset,
 		outerSurface->format);
 }
 
@@ -961,14 +1010,14 @@ WindowReference Gui::findWindowAtPoint(Common::Point point) {
 
 Common::Point Gui::getGlobalScrolledSurfacePosition(WindowReference reference) {
 	const WindowData &data = getWindowData(reference);
-	BorderBounds border = borderBounds(data.type);
+	//BorderBounds border = borderBounds(data.type);
 	Graphics::MacWindow *win = findWindow(reference);
 	if (!win) {
 		return Common::Point(0, 0);
 	}
 	return Common::Point(
-		win->getDimensions().left + border.leftOffset - data.scrollPos.x,
-		win->getDimensions().top + border.topOffset - data.scrollPos.y);
+		win->getInnerDimensions().left - data.scrollPos.x,
+		win->getInnerDimensions().top - data.scrollPos.y);
 }
 
 WindowData &Gui::findWindowData(WindowReference reference) {
@@ -1293,26 +1342,28 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
 			_engine->selectControl(kClickToContinue);
 			return true;
 		}
-
+		BorderBounds bbs = borderBounds(findWindowData(kCommandsWindow).type);
 		Common::Point position(
-			event.mouse.x - _controlsWindow->getDimensions().left,
-			event.mouse.y - _controlsWindow->getDimensions().top);
-
+			event.mouse.x - bbs.leftOffset,
+			event.mouse.y - bbs.topOffset
+		);
+		
 		CommandButton data;
 		if (!_controlData)
 			return false;
-
+		bool flag = false;
 		Common::Array<CommandButton>::iterator it = _controlData->begin();
 		for (; it != _controlData->end(); ++it) {
 			if (it->isInsideBounds(position)) {
 				it->select();
 				data = *it;
+				flag = true;
 			} else {
 				it->unselect();
 			}
 		}
-
-		_engine->selectControl(data.getData().refcon);
+		if (flag)
+			_engine->selectControl(data.getData().refcon);
 		_engine->refreshReady();
 		_engine->preparedToRun();
 	}
@@ -1358,9 +1409,10 @@ bool MacVenture::Gui::processExitsEvents(WindowClick click, Common::Event &event
 			return true;
 		}
 
+		BorderBounds bbs = borderBounds(findWindowData(kExitsWindow).type);
 		Common::Point position(
-			event.mouse.x - _exitsWindow->getDimensions().left,
-			event.mouse.y - _exitsWindow->getDimensions().top);
+			event.mouse.x - bbs.leftOffset,
+			event.mouse.y - bbs.topOffset);
 
 		CommandButton button;
 		if (!_exitsData)
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index 4db6e5fa3e..e5df789210 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -61,6 +61,7 @@ class ImageAsset;
 class Dialog;
 
 BorderBounds borderBounds(MVWindowType type);
+Graphics::BorderOffsets borderOffsets(MVWindowType type);
 
 enum MenuAction {
 	kMenuActionAbout,
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index f679dc8996..0d149e947f 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -1015,12 +1015,6 @@ ObjID MacVentureEngine::getParent(ObjID objID) {
 Common::Rect MacVentureEngine::getObjBounds(ObjID objID) {
 	Common::Point pos = getObjPosition(objID);
 
-	WindowReference win = findParentWindow(objID);
-	if (win != kNoWindow) { // If it's not in a window YET, we don't really care about the border
-		BorderBounds bounds = borderBounds(_gui->getWindowData(win).type); // HACK
-		pos.x += bounds.leftOffset;
-		pos.y += bounds.topOffset;
-	}
 	Common::Point measures = _gui->getObjMeasures(objID);
 	uint w = measures.x;
 	uint h = measures.y;
diff --git a/engines/macventure/windows.cpp b/engines/macventure/windows.cpp
index 555da5b78d..d76d43b049 100644
--- a/engines/macventure/windows.cpp
+++ b/engines/macventure/windows.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "macventure/windows.h"
+#include "graphics/macgui/macwindowborder.h"
 
 namespace MacVenture {
 
@@ -39,23 +40,24 @@ BorderBounds borderBounds(MVWindowType type) {
 	case MacVenture::kDBox:
 		break;
 	case MacVenture::kPlainDBox:
-		return BorderBounds(3, 3, 3, 3);
+		return BorderBounds(1, 1, 1, 2);
 	case MacVenture::kAltBox:
-		return BorderBounds(0, 0, 0, 0); // Hand-tested
+		return BorderBounds(2, 2, 2, 2); // Hand-tested
 	case MacVenture::kNoGrowDoc:
-		return BorderBounds(1, 20, 1, 1);
+		return BorderBounds(2, 20, 2, 2);
 	case MacVenture::kMovableDBox:
 		break;
 	case MacVenture::kZoomDoc:
-		return BorderBounds(1, 20, 17, 1);
+		return BorderBounds(2, 21, 17, 2, 15, 0);
 	case MacVenture::kZoomNoGrow:
 		break;
 	case MacVenture::kInvWindow:
-		return BorderBounds(1, 20, 17, 17);
+		//return BorderBounds(4, 10, 10, 10);
+		return BorderBounds(4, 21, 19, 18, 15, 15);
 	case MacVenture::kRDoc16:
 		break;
 	case MacVenture::kRDoc4:
-		return BorderBounds(1, 20, 1, 1);
+		return BorderBounds(2, 20, 3, 3);
 	case MacVenture::kRDoc6:
 		break;
 	case MacVenture::kRDoc10:
@@ -66,4 +68,68 @@ BorderBounds borderBounds(MVWindowType type) {
 
 	return BorderBounds(0, 0, 0, 0);
 }
+
+Graphics::BorderOffsets borderOffsets(MVWindowType type) {
+	BorderBounds bbs = borderBounds(type);
+
+	Graphics::BorderOffsets offsets;
+	offsets.left = bbs.leftOffset;
+	offsets.right = bbs.rightOffset;
+	offsets.top = bbs.topOffset;
+	offsets.bottom = bbs.bottomOffset;
+
+	offsets.titleTop = -1;
+	offsets.titleBottom = -1;
+	offsets.titlePos = 0;
+	offsets.dark = false;
+	offsets.upperScrollHeight = 0;
+	offsets.lowerScrollHeight = 0;
+
+	switch (type) {
+	case MacVenture::kDocument:
+		break;
+	case MacVenture::kDBox:
+		break;
+	case MacVenture::kPlainDBox:
+		break;
+	case MacVenture::kAltBox:
+		break;
+	case MacVenture::kNoGrowDoc:
+		offsets.titleTop = 0;
+		offsets.titleBottom = 0;
+		offsets.titlePos = 10;
+		break;
+	case MacVenture::kMovableDBox:
+		break;
+	case MacVenture::kZoomDoc:
+		offsets.titleTop = 0;
+		offsets.titleBottom = 0;
+		offsets.titlePos = 10;
+
+		offsets.upperScrollHeight = 20;
+		offsets.lowerScrollHeight = 20;
+		break;
+	case MacVenture::kZoomNoGrow:
+		offsets.titleTop = 0;
+		offsets.titleBottom = 0;
+		offsets.titlePos = 10;
+		break;
+	case MacVenture::kInvWindow:
+		offsets.titleTop = 0;
+		offsets.titleBottom = 0;
+		offsets.titlePos = 10;
+		
+		offsets.upperScrollHeight = 20;
+		offsets.lowerScrollHeight = 20;
+		break;
+	case MacVenture::kRDoc4:
+		offsets.titleTop = 0;
+		offsets.titleBottom = 0;
+		offsets.titlePos = 10;
+		break;
+	default:
+		break;
+	}
+	return offsets;
+}
 } // End of namespace MacVenture
diff --git a/engines/macventure/windows.h b/engines/macventure/windows.h
index b43fcc00ee..e1add0eb13 100644
--- a/engines/macventure/windows.h
+++ b/engines/macventure/windows.h
@@ -99,9 +99,15 @@ struct BorderBounds {
 	uint16 topOffset;
 	uint16 rightOffset;
 	uint16 bottomOffset;
-
+	uint16 rightScrollbarWidth;
+	uint16 bottomScrollbarHeight;
+	
 	BorderBounds(uint16 l, uint16 t, uint16 r, uint16 b) :
-	leftOffset(l), topOffset(t), rightOffset(r), bottomOffset(b) {}
+	leftOffset(l), topOffset(t), rightOffset(r), bottomOffset(b), rightScrollbarWidth(0), bottomScrollbarHeight(0) {}
+
+	BorderBounds(uint16 l, uint16 t, uint16 r, uint16 b, uint16 rs, uint16 bs) :
+	leftOffset(l), topOffset(t), rightOffset(r), bottomOffset(b), rightScrollbarWidth(rs), bottomScrollbarHeight(bs) {}
+
 };
 }
 #endif


Commit: 40f825de6abfcd15a9fe53efc9e454d5dce67313
    https://github.com/scummvm/scummvm/commit/40f825de6abfcd15a9fe53efc9e454d5dce67313
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: Fix bounds for selecting objects

Changed paths:
    engines/macventure/gui.cpp


diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 87df6ab31e..410d719fd7 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -1491,7 +1491,7 @@ void Gui::selectForDrag(Common::Point cursorPosition) {
 	Graphics::MacWindow *win = findWindow(ref);
 	WindowData &data = findWindowData((WindowReference) ref);
 
-	Common::Rect clickRect = calculateClickRect(cursorPosition + data.scrollPos, win->getDimensions());
+	Common::Rect clickRect = calculateClickRect(cursorPosition + data.scrollPos, win->getInnerDimensions());
 	checkSelect(data, cursorPosition, clickRect, (WindowReference)ref);
 }
 


Commit: e43d08ff437e951e04688e8a0d8922444089422b
    https://github.com/scummvm/scummvm/commit/e43d08ff437e951e04688e8a0d8922444089422b
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: Fix Inventory window Width and Height reading

Changed paths:
    engines/macventure/macventure.cpp


diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index 0d149e947f..b23df09ed4 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -1141,8 +1141,8 @@ void GlobalSettings::loadSettings(Common::SeekableReadStream *dataStream) {
 	dataStream->readUint16BE(); // unknown
 	_invTop = dataStream->readUint16BE();
 	_invLeft = dataStream->readUint16BE();
-	_invWidth = dataStream->readUint16BE();
 	_invHeight = dataStream->readUint16BE();
+	_invWidth = dataStream->readUint16BE();
 	_invOffsetY = dataStream->readUint16BE();
 	_invOffsetX = dataStream->readSint16BE();
 	_defaultFont = dataStream->readUint16BE();


Commit: 5f569ce0a6076f17394dcd1603c8c54aa1bed774
    https://github.com/scummvm/scummvm/commit/5f569ce0a6076f17394dcd1603c8c54aa1bed774
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: Fix Main window working while there is still need for click to continue

Changed paths:
    engines/macventure/gui.cpp


diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 410d719fd7..94121ae62f 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -1487,7 +1487,9 @@ void Gui::selectForDrag(Common::Point cursorPosition) {
 	if (ref == kNoWindow) {
 		return;
 	}
-
+	if(_engine->needsClickToContinue())
+		return;
+	
 	Graphics::MacWindow *win = findWindow(ref);
 	WindowData &data = findWindowData((WindowReference) ref);
 


Commit: d754ed0e272ec8110d27eb2a089d22f80e6fba5d
    https://github.com/scummvm/scummvm/commit/d754ed0e272ec8110d27eb2a089d22f80e6fba5d
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: Fix missing characters in some words in output console

Changed paths:
    engines/macventure/text.cpp


diff --git a/engines/macventure/text.cpp b/engines/macventure/text.cpp
index 8e3223ec32..de59f6032c 100644
--- a/engines/macventure/text.cpp
+++ b/engines/macventure/text.cpp
@@ -145,29 +145,16 @@ void TextAsset::decodeHuffman() {
 		} else if (symbol == 2) { // Composite
 			if (stream.getBit()) { // TextID
 				ObjID embedId = stream.getBits(15);
-				uint pos = stream.pos(); // HACK, part 1
+			
 				TextAsset embedded(_engine, embedId, _sourceObj, _targetObj, _container, _isOld, _huffman);
-				stream.rewind();// HACK, part 2
-				stream.skip(pos);
-
-				_decoded.replace(_decoded.end(), _decoded.end(), *embedded.decode());
-
-				// Another HACK, to get around that EOS char I insert at the end
-				_decoded.replace(_decoded.end() - 1, _decoded.end(), "");
+				_decoded += *embedded.decode();
 			} else { //Composite obj string
 				ObjID embedId = stream.getBits(8);
-				uint pos = stream.pos(); // HACK, part 1
-
-				_decoded.replace(_decoded.end(), _decoded.end(), getNoun(embedId));
-				stream.rewind();// HACK, part 2
-				stream.skip(pos);
-
-				// Another HACK, to get around that EOS char I insert at the end
-				_decoded.replace(_decoded.end() - 1, _decoded.end(), "");
+				_decoded += getNoun(embedId);
 			}
 		} else { // Plain ascii
 			c = symbol & 0xFF;
-			_decoded.replace(_decoded.end(), _decoded.end(), Common::String(c));
+			_decoded += Common::String(c);
 		}
 	}
 	_decoded += '\0';


Commit: bf46669cf8de2b6d71794dbb13fd59a125cb9c3c
    https://github.com/scummvm/scummvm/commit/bf46669cf8de2b6d71794dbb13fd59a125cb9c3c
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACGUI: Add methods to find top window at at a given point

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


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index f365f8d6d5..abe437c0a2 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -691,6 +691,32 @@ void MacWindowManager::setActiveWindow(int id) {
 	_fullRefresh = true;
 }
 
+MacWindow* MacWindowManager::findWindowAtPoint(int16 x, int16 y) {
+	Common::List<Graphics::BaseMacWindow *>::iterator it;
+	Graphics::MacWindow* win = nullptr;
+
+	for (it = _windowStack.begin(); it != _windowStack.end(); it++) {
+		if ((*it)->getDimensions().contains(x, y)) {
+			win = reinterpret_cast<Graphics::MacWindow *> (*it);
+		}
+	}
+	
+	return win;
+}
+
+MacWindow* MacWindowManager::findWindowAtPoint(Common::Point point) {
+	Common::List<Graphics::BaseMacWindow *>::iterator it;
+	Graphics::MacWindow* win = nullptr;
+
+	for (it = _windowStack.begin(); it != _windowStack.end(); it++) {
+		if ((*it)->getDimensions().contains(point)) {
+			win = reinterpret_cast<Graphics::MacWindow *> (*it);
+		}
+	}
+	
+	return win;
+}
+
 void MacWindowManager::removeWindow(MacWindow *target) {
 	_windowsToRemove.push_back(target);
 	_needsRemoval = true;
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 3d9c482817..7930a28db3 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -223,6 +223,18 @@ public:
 	 */
 	void setActiveWindow(int id);
 
+	/**
+	 * Return Top Window containing a point
+	 * @param x x coordinate of point
+	 * @param y y coordiante of point
+	 */ 
+	MacWindow* findWindowAtPoint(int16 x, int16 y);
+	/**
+	 * Return Top Window containing a point
+	 * @param point Point
+	 */ 
+	MacWindow* findWindowAtPoint(Common::Point point);
+
 	/**
 	 * Mark a window for removal.
 	 * Note that the window data will be destroyed.


Commit: 2e4117e388d13af0464f7f4d84c1931dbb040fa5
    https://github.com/scummvm/scummvm/commit/2e4117e388d13af0464f7f4d84c1931dbb040fa5
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: Add title to windows

Changed paths:
    engines/macventure/gui.cpp
    engines/macventure/windows.cpp


diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 94121ae62f..d841d60114 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -254,7 +254,7 @@ void Gui::initWindows() {
 	_outConsoleWindow->move(bounds.left - bbs.leftOffset, bounds.top - bbs.topOffset);
 	_outConsoleWindow->setActive(false);
 	_outConsoleWindow->setCallback(outConsoleWindowCallback, this);
-
+	_outConsoleWindow->setTitle("Untitled");
 	// Self Window
 	_selfWindow = _wm.addWindow(false, true, false);
 	
@@ -278,7 +278,7 @@ void Gui::initWindows() {
 
 	_exitsWindow->setActive(false);
 	_exitsWindow->setCallback(exitsWindowCallback, this);
-
+	_exitsWindow->setTitle(findWindowData(kExitsWindow).title);
 	// TODO: In the original, the background is actually a clickable
 	// object that can be used to refer to the room itself. In that case,
 	// the background should be kPatternDarkGray.
@@ -294,12 +294,13 @@ const Graphics::Font &Gui::getCurrentFont() {
 }
 
 void Gui::bringToFront(WindowReference winID) {
-	findWindow(winID)->setActive(true);
+	_wm.setActiveWindow(findWindow(winID)->getId());
 }
 
 void Gui::setWindowTitle(WindowReference winID, Common::String string) {
 	findWindowData(winID).title = string;
 	findWindowData(winID).titleLength = string.size();
+	findWindow(winID)->setTitle(string);
 }
 
 void Gui::updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array<ObjID> &children) {
@@ -378,7 +379,8 @@ WindowReference Gui::createInventoryWindow(ObjID objRef) {
 	_windowData->push_back(newData);
 
 	BorderBounds bbs = borderBounds(newData.type);
-	newWindow->setDimensions(newData.bounds);
+	//newWindow->setDimensions(newData.bounds);
+	//newWindow->setActive(false);
 	loadBorders(newWindow, newData.type);
 	newWindow->resize(newData.bounds.width() - bbs.rightScrollbarWidth, newData.bounds.height() - bbs.bottomScrollbarHeight, true);
 	newWindow->move(newData.bounds.left - bbs.leftOffset, newData.bounds.top - bbs.topOffset);
@@ -996,12 +998,13 @@ void Gui::moveDraggedObject(Common::Point target) {
 
 WindowReference Gui::findWindowAtPoint(Common::Point point) {
 	Common::List<WindowData>::iterator it;
-	Graphics::MacWindow *win;
-	for (it = _windowData->begin(); it != _windowData->end(); it++) {
-		win = findWindow(it->refcon);
-		if (win && it->refcon != kDiplomaWindow) { //HACK, diploma should be cosnidered
-			if (win->getDimensions().contains(point)) {
-				return it->refcon;
+	Graphics::MacWindow *win = _wm.findWindowAtPoint(point);
+	if (win != nullptr) {
+		for (it = _windowData->begin(); it != _windowData->end(); it++) {
+			if ( win == findWindow(it->refcon) && it->refcon != kDiplomaWindow) { //HACK, diploma should be cosnidered
+				if (win->getDimensions().contains(point)) {
+					return it->refcon;
+				}
 			}
 		}
 	}
diff --git a/engines/macventure/windows.cpp b/engines/macventure/windows.cpp
index d76d43b049..876bd2207a 100644
--- a/engines/macventure/windows.cpp
+++ b/engines/macventure/windows.cpp
@@ -97,14 +97,14 @@ Graphics::BorderOffsets borderOffsets(MVWindowType type) {
 	case MacVenture::kNoGrowDoc:
 		offsets.titleTop = 0;
 		offsets.titleBottom = 0;
-		offsets.titlePos = 10;
+		offsets.titlePos = 0;
 		break;
 	case MacVenture::kMovableDBox:
 		break;
 	case MacVenture::kZoomDoc:
 		offsets.titleTop = 0;
 		offsets.titleBottom = 0;
-		offsets.titlePos = 10;
+		offsets.titlePos = 0;
 
 		offsets.upperScrollHeight = 20;
 		offsets.lowerScrollHeight = 20;
@@ -112,20 +112,20 @@ Graphics::BorderOffsets borderOffsets(MVWindowType type) {
 	case MacVenture::kZoomNoGrow:
 		offsets.titleTop = 0;
 		offsets.titleBottom = 0;
-		offsets.titlePos = 10;
+		offsets.titlePos = 0;
 		break;
 	case MacVenture::kInvWindow:
 		offsets.titleTop = 0;
 		offsets.titleBottom = 0;
-		offsets.titlePos = 10;
-		
+		offsets.titlePos = 0;
+
 		offsets.upperScrollHeight = 20;
 		offsets.lowerScrollHeight = 20;
 		break;
 	case MacVenture::kRDoc4:
 		offsets.titleTop = 0;
 		offsets.titleBottom = 0;
-		offsets.titlePos = 10;
+		offsets.titlePos = 0;
 		break;
 	default:
 		break;


Commit: 04a2a1f87ccac87c80d84db6ccdc3fe4d0ad9ad8
    https://github.com/scummvm/scummvm/commit/04a2a1f87ccac87c80d84db6ccdc3fe4d0ad9ad8
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACGUI: Fix code formatting according to coding conventions

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


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index abe437c0a2..1a2d3707fd 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -691,7 +691,7 @@ void MacWindowManager::setActiveWindow(int id) {
 	_fullRefresh = true;
 }
 
-MacWindow* MacWindowManager::findWindowAtPoint(int16 x, int16 y) {
+MacWindow *MacWindowManager::findWindowAtPoint(int16 x, int16 y) {
 	Common::List<Graphics::BaseMacWindow *>::iterator it;
 	Graphics::MacWindow* win = nullptr;
 
@@ -704,7 +704,7 @@ MacWindow* MacWindowManager::findWindowAtPoint(int16 x, int16 y) {
 	return win;
 }
 
-MacWindow* MacWindowManager::findWindowAtPoint(Common::Point point) {
+MacWindow *MacWindowManager::findWindowAtPoint(Common::Point point) {
 	Common::List<Graphics::BaseMacWindow *>::iterator it;
 	Graphics::MacWindow* win = nullptr;
 
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 7930a28db3..aa165bc191 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -228,12 +228,12 @@ public:
 	 * @param x x coordinate of point
 	 * @param y y coordiante of point
 	 */ 
-	MacWindow* findWindowAtPoint(int16 x, int16 y);
+	MacWindow *findWindowAtPoint(int16 x, int16 y);
 	/**
 	 * Return Top Window containing a point
 	 * @param point Point
 	 */ 
-	MacWindow* findWindowAtPoint(Common::Point point);
+	MacWindow *findWindowAtPoint(Common::Point point);
 
 	/**
 	 * Mark a window for removal.


Commit: 0638fca683d095ecbbebed328fd5982aada73719
    https://github.com/scummvm/scummvm/commit/0638fca683d095ecbbebed328fd5982aada73719
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: Remove unnecessary adding of NULL character to string

Changed paths:
    engines/macventure/text.cpp


diff --git a/engines/macventure/text.cpp b/engines/macventure/text.cpp
index de59f6032c..bb2f9cb5e3 100644
--- a/engines/macventure/text.cpp
+++ b/engines/macventure/text.cpp
@@ -157,7 +157,6 @@ void TextAsset::decodeHuffman() {
 			_decoded += Common::String(c);
 		}
 	}
-	_decoded += '\0';
 	debugC(3, kMVDebugText, "Decoded string [%d] (new encoding): %s", _id, _decoded.c_str());
 }
 Common::String TextAsset::getNoun(ObjID subval) {


Commit: 6bc5d0e9aea161740a86bf1ddecc164c494c1114
    https://github.com/scummvm/scummvm/commit/6bc5d0e9aea161740a86bf1ddecc164c494c1114
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: Fix object not dropping at left side of window

Changed paths:
    engines/macventure/gui.cpp


diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index d841d60114..355ab57efb 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -1144,7 +1144,7 @@ void Gui::selectDraggable(ObjID child, WindowReference origin, Common::Point cli
 
 void Gui::handleDragRelease(bool shiftPressed, bool isDoubleClick) {
 	if (_draggedObj.id != 0) {
-		WindowReference destinationWindow = findWindowAtPoint(_draggedObj.pos);
+		WindowReference destinationWindow = findWindowAtPoint(_draggedObj.pos - _draggedObj.mouseOffset);
 		if (destinationWindow == kNoWindow) {
 			return;
 		}


Commit: dd6508500c4bc0c454fdbfe6de92d2ef2202dd77
    https://github.com/scummvm/scummvm/commit/dd6508500c4bc0c454fdbfe6de92d2ef2202dd77
Author: DivyamAhuja (39771050+DivyamAhuja at users.noreply.github.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: Fix Output console text width

Changed paths:
    engines/macventure/gui.cpp


diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 355ab57efb..a20c7c5a43 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -927,7 +927,7 @@ void Gui::updateExit(ObjID obj) {
 
 void Gui::printText(const Common::String &text) {
 	debugC(1, kMVDebugGUI, "Print Text: %s", text.c_str());
-	_consoleText->printLine(text, _outConsoleWindow->getDimensions().width());
+	_consoleText->printLine(text, _outConsoleWindow->getInnerDimensions().width());
 }
 
 void Gui::showPrebuiltDialog(PrebuiltDialogs type) {


Commit: 9ad16ff2731b82987d605ef60d04168d0528d9c5
    https://github.com/scummvm/scummvm/commit/9ad16ff2731b82987d605ef60d04168d0528d9c5
Author: Divyam Ahuja (ahujadivyam at gmail.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: Initialize struct according to C++98 convention

Changed paths:
    engines/macventure/gui.cpp


diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index a20c7c5a43..486e47c647 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -218,7 +218,7 @@ void Gui::clearControls() {
 
 void Gui::initWindows() {
 	Common::Rect bounds;
-	BorderBounds bbs = {0 , 0, 0, 0, 0, 0};
+	BorderBounds bbs(0 , 0, 0, 0, 0, 0);
 	// Game Controls Window
 	_controlsWindow = _wm.addWindow(false, false, false);
 	


Commit: 9f479e06f4942caf52b198feb7148459a585ced5
    https://github.com/scummvm/scummvm/commit/9f479e06f4942caf52b198feb7148459a585ced5
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: fixed whitespaces

Changed paths:
    engines/macventure/gui.cpp


diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 486e47c647..fe6d492684 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -221,7 +221,7 @@ void Gui::initWindows() {
 	BorderBounds bbs(0 , 0, 0, 0, 0, 0);
 	// Game Controls Window
 	_controlsWindow = _wm.addWindow(false, false, false);
-	
+
 
 	bounds = getWindowData(kCommandsWindow).bounds;
 	bbs = borderBounds(findWindowData(kCommandsWindow).type);
@@ -257,7 +257,7 @@ void Gui::initWindows() {
 	_outConsoleWindow->setTitle("Untitled");
 	// Self Window
 	_selfWindow = _wm.addWindow(false, true, false);
-	
+
 	bounds = getWindowData(kSelfWindow).bounds;
 	bbs = borderBounds(findWindowData(kSelfWindow).type);
 	loadBorders(_selfWindow, findWindowData(kSelfWindow).type);
@@ -269,7 +269,7 @@ void Gui::initWindows() {
 
 	// Exits Window
 	_exitsWindow = _wm.addWindow(false, false, false);
-	
+
 	bounds = getWindowData(kExitsWindow).bounds;
 	bbs = borderBounds(findWindowData(kExitsWindow).type);
 	loadBorders(_exitsWindow, findWindowData(kExitsWindow).type);
@@ -386,7 +386,7 @@ WindowReference Gui::createInventoryWindow(ObjID objRef) {
 	newWindow->move(newData.bounds.left - bbs.leftOffset, newData.bounds.top - bbs.topOffset);
 	newWindow->setCallback(inventoryWindowCallback, this);
 	//newWindow->setCloseable(true);
-	
+
 	_inventoryWindows.push_back(newWindow);
 
 	debugC(1, kMVDebugGUI, "Create new inventory window. Reference: %d", newData.refcon);
@@ -399,52 +399,51 @@ void Gui::loadBorders(Graphics::MacWindow *target, MVWindowType type) {
 }
 
 void Gui::loadBorder(Graphics::MacWindow *target, MVWindowType type, bool active) {
+	Common::SeekableReadStream *stream;
 
-    Common::SeekableReadStream *stream;
+	bool activeFlag = (active ? Graphics::kWindowBorderActive : 0);
+	bool canHaveTitle = false;
+	bool canHaveScrollbar = false;
 
-    bool activeFlag = (active ? Graphics::kWindowBorderActive : 0);    
-    bool canHaveTitle = false;
-    bool canHaveScrollbar = false;
+	if (type == MacVenture::kInvWindow || type == MacVenture::kZoomDoc) {
+		canHaveScrollbar = true;
+	}
 
-    if (type == MacVenture::kInvWindow || type == MacVenture::kZoomDoc) {
-        canHaveScrollbar = true;
-    }
+	if (type == MacVenture::kInvWindow || type == MacVenture::kZoomDoc || type == MacVenture::kNoGrowDoc || type == MacVenture::kRDoc4) {
+		canHaveTitle = true;
+	}
 
-    if (type == MacVenture::kInvWindow || type == MacVenture::kZoomDoc || type == MacVenture::kNoGrowDoc || type == MacVenture::kRDoc4) {
-        canHaveTitle = true;
-    }
-    
 	Graphics::BorderOffsets offsets = borderOffsets(type);
-    stream = _engine->getBorderFile(type, active);
-    
+	stream = _engine->getBorderFile(type, active);
+
 	if (stream) {
-        target->loadBorder(*stream, activeFlag, offsets);
-        delete stream;
-    }
-
-    if (canHaveTitle) {
-        stream = _engine->getBorderFile(type, active);
-        if (stream) {
-            target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderTitle , offsets);
-            delete stream;
-        }
-    }
-
-    if (canHaveScrollbar) {
-        stream = _engine->getBorderFile(type, active);
-        if (stream) {
-            target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderScrollbar, offsets);
-            delete stream;
-        }
-    }
-
-    if (canHaveTitle && canHaveScrollbar) {
-        stream = _engine->getBorderFile(type, active);
-        if (stream) {
-            target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderTitle | Graphics::kWindowBorderScrollbar, offsets);
-            delete stream;
-        }
-    }
+		target->loadBorder(*stream, activeFlag, offsets);
+		delete stream;
+	}
+
+	if (canHaveTitle) {
+		stream = _engine->getBorderFile(type, active);
+		if (stream) {
+			target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderTitle, offsets);
+			delete stream;
+		}
+	}
+
+	if (canHaveScrollbar) {
+		stream = _engine->getBorderFile(type, active);
+		if (stream) {
+			target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderScrollbar, offsets);
+			delete stream;
+		}
+	}
+
+	if (canHaveTitle && canHaveScrollbar) {
+		stream = _engine->getBorderFile(type, active);
+		if (stream) {
+			target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderTitle | Graphics::kWindowBorderScrollbar, offsets);
+			delete stream;
+		}
+	}
 }
 
 void Gui::loadGraphics() {
@@ -546,7 +545,7 @@ bool Gui::loadWindows() {
 		data.bounds = Common::Rect(
 			left,
 			top,
-			right, 
+			right,
 			bottom
 		);
 		data.visible = res->readUint16BE();
@@ -774,7 +773,7 @@ void Gui::drawObjectsInWindow(const WindowData &targetData, Graphics::ManagedSur
 			surface->frameRect(testBounds, kColorGreen);
 		}
 	}
-	Common::Point composePosition = Common::Point(0, 0);//border.leftOffset, border.topOffset);
+	Common::Point composePosition = Common::Point(0, 0);
 	surface->transBlitFrom(composeSurface, composePosition, kColorGreen);
 }
 
@@ -895,7 +894,6 @@ void Gui::updateExit(ObjID obj) {
 	if (!_engine->isObjExit(obj)) {
 		return;
 	}
-	//BorderBounds border = borderBounds(getWindowData(kExitsWindow).type);
 
 	int ctl = -1;
 	int i = 0;
@@ -1001,7 +999,7 @@ WindowReference Gui::findWindowAtPoint(Common::Point point) {
 	Graphics::MacWindow *win = _wm.findWindowAtPoint(point);
 	if (win != nullptr) {
 		for (it = _windowData->begin(); it != _windowData->end(); it++) {
-			if ( win == findWindow(it->refcon) && it->refcon != kDiplomaWindow) { //HACK, diploma should be cosnidered
+			if (win == findWindow(it->refcon) && it->refcon != kDiplomaWindow) { //HACK, diploma should be considered
 				if (win->getDimensions().contains(point)) {
 					return it->refcon;
 				}
@@ -1350,7 +1348,7 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
 			event.mouse.x - bbs.leftOffset,
 			event.mouse.y - bbs.topOffset
 		);
-		
+
 		CommandButton data;
 		if (!_controlData)
 			return false;
@@ -1490,11 +1488,11 @@ void Gui::selectForDrag(Common::Point cursorPosition) {
 	if (ref == kNoWindow) {
 		return;
 	}
-	if(_engine->needsClickToContinue())
+	if (_engine->needsClickToContinue())
 		return;
-	
+
 	Graphics::MacWindow *win = findWindow(ref);
-	WindowData &data = findWindowData((WindowReference) ref);
+	WindowData &data = findWindowData((WindowReference)ref);
 
 	Common::Rect clickRect = calculateClickRect(cursorPosition + data.scrollPos, win->getInnerDimensions());
 	checkSelect(data, cursorPosition, clickRect, (WindowReference)ref);


Commit: 1287dce3136e89aba5e362c4a9be46d16f5d1fe2
    https://github.com/scummvm/scummvm/commit/1287dce3136e89aba5e362c4a9be46d16f5d1fe2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACGUI: whitespace issues

Changed paths:
    graphics/macgui/macwindowmanager.cpp


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 1a2d3707fd..a0a1485877 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -693,27 +693,27 @@ void MacWindowManager::setActiveWindow(int id) {
 
 MacWindow *MacWindowManager::findWindowAtPoint(int16 x, int16 y) {
 	Common::List<Graphics::BaseMacWindow *>::iterator it;
-	Graphics::MacWindow* win = nullptr;
+	Graphics::MacWindow *win = nullptr;
 
 	for (it = _windowStack.begin(); it != _windowStack.end(); it++) {
 		if ((*it)->getDimensions().contains(x, y)) {
-			win = reinterpret_cast<Graphics::MacWindow *> (*it);
+			win = reinterpret_cast<Graphics::MacWindow *>(*it);
 		}
 	}
-	
+
 	return win;
 }
 
 MacWindow *MacWindowManager::findWindowAtPoint(Common::Point point) {
 	Common::List<Graphics::BaseMacWindow *>::iterator it;
-	Graphics::MacWindow* win = nullptr;
+	Graphics::MacWindow *win = nullptr;
 
 	for (it = _windowStack.begin(); it != _windowStack.end(); it++) {
 		if ((*it)->getDimensions().contains(point)) {
-			win = reinterpret_cast<Graphics::MacWindow *> (*it);
+			win = reinterpret_cast<Graphics::MacWindow *>(*it);
 		}
 	}
-	
+
 	return win;
 }
 


Commit: b73889d2e0a21492541a72563f5bff9e0c735045
    https://github.com/scummvm/scummvm/commit/b73889d2e0a21492541a72563f5bff9e0c735045
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: pass by reference

Changed paths:
    engines/macventure/gui.cpp
    engines/macventure/gui.h
    engines/macventure/macventure.cpp
    engines/macventure/macventure.h


diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index fe6d492684..c7e60e1636 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -297,7 +297,7 @@ void Gui::bringToFront(WindowReference winID) {
 	_wm.setActiveWindow(findWindow(winID)->getId());
 }
 
-void Gui::setWindowTitle(WindowReference winID, Common::String string) {
+void Gui::setWindowTitle(WindowReference winID, const Common::String &string) {
 	findWindowData(winID).title = string;
 	findWindowData(winID).titleLength = string.size();
 	findWindow(winID)->setTitle(string);
@@ -937,11 +937,10 @@ bool Gui::isDialogOpen() {
 	return _dialog != NULL;
 }
 
-void Gui::setTextInput(Common::String str) {
+void Gui::setTextInput(const Common::String &str) {
 	_engine->setTextInput(str);
 }
 
-
 void Gui::closeDialog() {
 	delete _dialog;
 	_dialog = NULL;
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index e5df789210..d5855a33b5 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -136,7 +136,7 @@ public:
 
 	// Modifiers
 	void bringToFront(WindowReference window);
-	void setWindowTitle(WindowReference winID, Common::String string);
+	void setWindowTitle(WindowReference winID, const Common::String &string);
 	void updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array<ObjID> &children);
 	void ensureInventoryOpen(WindowReference reference, ObjID id);
 
@@ -154,7 +154,7 @@ public:
 	bool isDialogOpen();
 
 	void getTextFromUser();
-	void setTextInput(Common::String str);
+	void setTextInput(const Common::String &str);
 	void closeDialog();
 
 	void loadGame();
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index b23df09ed4..25f39687a2 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -447,7 +447,7 @@ bool MacVentureEngine::showTextEntry(ObjID text, ObjID srcObj, ObjID destObj) {
 	return true;
 }
 
-void MacVentureEngine::setTextInput(Common::String content) {
+void MacVentureEngine::setTextInput(const Common::String &content) {
 	_prepared = true;
 	_userInput = content;
 	_clickToContinue = false;
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index c20f82c370..0cd48dc7ce 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -242,7 +242,7 @@ public:
 	void updateWindow(WindowReference winID);
 
 	bool showTextEntry(ObjID text, ObjID srcObj, ObjID destObj);
-	void setTextInput(Common::String content);
+	void setTextInput(const Common::String &content);
 	Common::String getUserInput();
 
 	// Data retrieval


Commit: 37de1b314669ff7de7fd1a4f78ab8397e96417bb
    https://github.com/scummvm/scummvm/commit/37de1b314669ff7de7fd1a4f78ab8397e96417bb
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACGUI: const for some methods

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


diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 8cbd994857..6fe5b56f5a 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -89,7 +89,7 @@ void MacWindow::setActive(bool active) {
 	_borderIsDirty = true;
 }
 
-bool MacWindow::isActive() { return _active; }
+bool MacWindow::isActive() const { return _active; }
 
 void MacWindow::resize(int w, int h, bool inner) {
 	if (_composeSurface->w == w && _composeSurface->h == h)
@@ -178,7 +178,7 @@ void MacWindow::blit(ManagedSurface *g, Common::Rect &dest) {
 	g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), dest, transcolor);
 }
 
-uint32 MacWindow::getBorderFlags() {
+uint32 MacWindow::getBorderFlags() const {
 	uint32 flags = 0;
 	if (_active)
 		flags |= kWindowBorderActive;
@@ -343,7 +343,7 @@ void MacWindow::fillRect(ManagedSurface *g, int x, int y, int w, int h, int colo
 	g->fillRect(r, color);
 }
 
-WindowClick MacWindow::isInBorder(int x, int y) {
+WindowClick MacWindow::isInBorder(int x, int y) const {
 	if (_innerDims.contains(x, y))
 		return kBorderInner;
 
@@ -360,7 +360,7 @@ WindowClick MacWindow::isInBorder(int x, int y) {
 	return kBorderBorder;
 }
 
-bool MacWindow::isInCloseButton(int x, int y) {
+bool MacWindow::isInCloseButton(int x, int y) const {
 	int bLeft = kBorderWidth;
 	int bTop = kBorderWidth;
 	if (_macBorder.hasOffsets()) {
@@ -370,7 +370,7 @@ bool MacWindow::isInCloseButton(int x, int y) {
 	return (x >= _innerDims.left - bLeft && x < _innerDims.left && y >= _innerDims.top - bTop && y < _innerDims.top);
 }
 
-bool MacWindow::isInResizeButton(int x, int y) {
+bool MacWindow::isInResizeButton(int x, int y) const {
 	int bRight = kBorderWidth;
 	int bBottom = kBorderWidth;
 	if (_macBorder.hasOffsets()) {
@@ -380,7 +380,7 @@ bool MacWindow::isInResizeButton(int x, int y) {
 	return (x >= _innerDims.right && x < _innerDims.right + bRight && y >= _innerDims.bottom && y < _innerDims.bottom + bBottom);
 }
 
-WindowClick MacWindow::isInScroll(int x, int y) {
+WindowClick MacWindow::isInScroll(int x, int y) const {
 	int bTop = kBorderWidth;
 	int bRight = kBorderWidth;
 	int bBottom = kBorderWidth;
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index 92531c0399..f2e478a443 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -263,7 +263,7 @@ public:
 	 * Accessor to determine whether a window is active.
 	 * @return True if the window is active.
 	 */
-	bool isActive();
+	bool isActive() const;
 
 	/**
 	 * Mutator to change the title of the window.
@@ -274,7 +274,7 @@ public:
 	 * Accessor to get the title of the window.
 	 * @return Title.
 	 */
-	Common::String getTitle() { return _title; };
+	const Common::String &getTitle() const { return _title; };
 
 	/**
 	 * Highlight the target part of the window.
@@ -331,14 +331,14 @@ public:
 	 * Accessor to get the border type.
 	 * @return Border type.
 	 */
-	int getBorderType() { return _borderType; };
+	int getBorderType() const { return _borderType; };
 
 	/**
 	 * We should call this method whenever we need border flags
 	 * don't calc border flags yourself
 	 * @return Border flags
 	 */
-	uint32 getBorderFlags();
+	uint32 getBorderFlags() const;
 
 	void addDirtyRect(const Common::Rect &r);
 	void markAllDirty();
@@ -360,14 +360,14 @@ private:
 	void updateInnerDims();
 	void updateOuterDims();
 
-	bool isInCloseButton(int x, int y);
-	bool isInResizeButton(int x, int y);
-	WindowClick isInScroll(int x, int y);
+	bool isInCloseButton(int x, int y) const;
+	bool isInResizeButton(int x, int y) const;
+	WindowClick isInScroll(int x, int y) const;
 
 protected:
 	void drawBorder();
-	WindowClick isInBorder(int x, int y);
-	BorderOffsets getBorderOffsets() { return _macBorder.getOffset(); }
+	WindowClick isInBorder(int x, int y) const;
+	BorderOffsets getBorderOffsets() const { return _macBorder.getOffset(); }
 
 protected:
 	ManagedSurface _borderSurface;
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index dd00726bae..13ba76bf95 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -110,7 +110,7 @@ void MacWindowBorder::addBorder(TransparentSurface *source, uint32 flags, int ti
 		setOffsets(_border[flags]->getPadding());
 }
 
-bool MacWindowBorder::hasOffsets() {
+bool MacWindowBorder::hasOffsets() const {
 	return _borderOffsets.left > -1 && _borderOffsets.right > -1
 		&& _borderOffsets.top > -1 && _borderOffsets.bottom > -1;
 }
@@ -137,6 +137,10 @@ BorderOffsets &MacWindowBorder::getOffset() {
 	return _borderOffsets;
 }
 
+const BorderOffsets &MacWindowBorder::getOffset() const {
+	return _borderOffsets;
+}
+
 void MacWindowBorder::setTitle(const Common::String& title, int width, MacWindowManager *wm) {
 	_title = title;
 	const Graphics::Font *font = wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12));
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 4dc8e1058e..7f60444383 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -89,7 +89,7 @@ public:
 	 * Accessor function for the custom offsets.
 	 * @return True if custom offsets have been indicated (setOffsets has been called previously).
 	 */
-	bool hasOffsets();
+	bool hasOffsets() const;
 
 	/**
 	 * Mutator method to indicate the custom border offsets.
@@ -115,6 +115,7 @@ public:
 	 * @return The desired offset in pixels.
 	 */
 	BorderOffsets &getOffset();
+	const BorderOffsets &getOffset() const;
 
 	/**
 	 * Blit the desired border (active or inactive) into a destination surface.


Commit: dc5d474160bcba1eb04fad4474f6294d74f4a6fe
    https://github.com/scummvm/scummvm/commit/dc5d474160bcba1eb04fad4474f6294d74f4a6fe
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-19T15:21:56+02:00

Commit Message:
MACVENTURE: re-use the read stream to reduce heap allocations

Changed paths:
    engines/macventure/gui.cpp


diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index c7e60e1636..ef8fd82976 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -418,32 +418,29 @@ void Gui::loadBorder(Graphics::MacWindow *target, MVWindowType type, bool active
 
 	if (stream) {
 		target->loadBorder(*stream, activeFlag, offsets);
-		delete stream;
 	}
 
 	if (canHaveTitle) {
-		stream = _engine->getBorderFile(type, active);
 		if (stream) {
+			stream->seek(0);
 			target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderTitle, offsets);
-			delete stream;
 		}
 	}
 
 	if (canHaveScrollbar) {
-		stream = _engine->getBorderFile(type, active);
 		if (stream) {
+			stream->seek(0);
 			target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderScrollbar, offsets);
-			delete stream;
 		}
 	}
 
 	if (canHaveTitle && canHaveScrollbar) {
-		stream = _engine->getBorderFile(type, active);
 		if (stream) {
+			stream->seek(0);
 			target->loadBorder(*stream, activeFlag | Graphics::kWindowBorderTitle | Graphics::kWindowBorderScrollbar, offsets);
-			delete stream;
 		}
 	}
+	delete stream;
 }
 
 void Gui::loadGraphics() {




More information about the Scummvm-git-logs mailing list