[Scummvm-git-logs] scummvm master -> 923efc2a4e1ad208f44a38ee6aa80316fbda1ade

eriktorbjorn eriktorbjorn at telia.com
Sun Sep 4 08:31:58 CEST 2016


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

Summary:
40c65540fa GRAPHICS: Add setBackgroundPattern() to MacWindow
923efc2a4e MACVENTURE: Set background pattern for exits window


Commit: 40c65540fac262fbd70478eb8017f260780fb1a4
    https://github.com/scummvm/scummvm/commit/40c65540fac262fbd70478eb8017f260780fb1a4
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2016-09-04T08:31:39+02:00

Commit Message:
GRAPHICS: Add setBackgroundPattern() to MacWindow

Set a background pattern for the window surface. For instance, the
exits window in the MacVenture engine should have a light gray
background, rather than a white one, and this will allow it to get
one without having to draw it by itself.

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



diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index ea9a0a1..2a6e191 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -44,6 +44,9 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, Mac
 	_active = false;
 	_borderIsDirty = true;
 
+	_pattern = 0;
+	_hasPattern = false;
+
 	_highlightedPart = kBorderNone;
 
 	_scrollPos = _scrollSize = 0.0;
@@ -83,6 +86,10 @@ void MacWindow::resize(int w, int h) {
 
 	_surface.free();
 	_surface.create(w, h, PixelFormat::createFormatCLUT8());
+
+	if (_hasPattern)
+		drawPattern();
+
 	_borderSurface.free();
 	_borderSurface.create(w, h, PixelFormat::createFormatCLUT8());
 	_composeSurface.free();
@@ -115,6 +122,13 @@ void MacWindow::setDimensions(const Common::Rect &r) {
 	_contentIsDirty = true;
 }
 
+void MacWindow::setBackgroundPattern(int pattern) {
+	_pattern = pattern;
+	_hasPattern = true;
+	drawPattern();
+	_contentIsDirty = true;
+}
+
 bool MacWindow::draw(ManagedSurface *g, bool forceRedraw) {
 	if (!_borderIsDirty && !_contentIsDirty && !forceRedraw)
 		return false;
@@ -273,6 +287,19 @@ void MacWindow::drawSimpleBorder(ManagedSurface *g) {
 	}
 }
 
+void MacWindow::drawPattern() {
+	byte *pat = _wm->getPatterns()[_pattern - 1];
+	for (int y = 0; y < _surface.h; y++) {
+		for (int x = 0; x < _surface.w; x++) {
+			byte *dst = (byte *)_surface.getBasePtr(x, y);
+			if (pat[y % 8] & (1 << (7 - (x % 8))))
+				*dst = kColorBlack;
+			else
+				*dst = kColorWhite;
+		}
+	}
+}
+
 void MacWindow::setHighlight(WindowClick highlightedPart) {
 	if (_highlightedPart == highlightedPart)
 		return;
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index ee25a9e..5d06da3 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -216,6 +216,12 @@ public:
 	const Common::Rect &getInnerDimensions() { return _innerDims; }
 
 	/**
+	 * Set a background pattern for the window.
+	 * @param pattern
+	 */
+	void setBackgroundPattern(int pattern);
+
+	/**
 	 * Similar to that described in BaseMacWindow.
 	 * @param g See BaseMacWindow.
 	 * @param forceRedraw If true, the borders are guarranteed to redraw.
@@ -282,6 +288,7 @@ private:
 	void prepareBorderSurface(ManagedSurface *g);
 	void drawSimpleBorder(ManagedSurface *g);
 	void drawBorderFromSurface(ManagedSurface *g);
+	void drawPattern();
 	void drawBox(ManagedSurface *g, int x, int y, int w, int h);
 	void fillRect(ManagedSurface *g, int x, int y, int w, int h, int color);
 	const Font *getTitleFont();
@@ -298,6 +305,9 @@ private:
 
 	MacWindowBorder _macBorder;
 
+	int _pattern;
+	bool _hasPattern;
+
 	bool _scrollable;
 	bool _resizable;
 	bool _active;
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 6c51a2f..9e40c36 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -48,7 +48,9 @@ static const byte palette[] = {
 static byte fillPatterns[][8] = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, // kPatternSolid
 								  { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }, // kPatternStripes
 								  { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 }, // kPatternCheckers
-								  { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }  // kPatternCheckers2
+								  { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }, // kPatternCheckers2
+								  { 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22 }, // kPatternLightGray
+								  { 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd }  // kPatternDarkGray
 };
 
 static const byte macCursorArrow[] = {
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index c5a179a..96cc1e7 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -51,7 +51,9 @@ enum {
 	kPatternSolid = 1,
 	kPatternStripes = 2,
 	kPatternCheckers = 3,
-	kPatternCheckers2 = 4
+	kPatternCheckers2 = 4,
+	kPatternLightGray = 5,
+	kPatternDarkGray = 6
 };
 }
 using namespace MacGUIConstants;


Commit: 923efc2a4e1ad208f44a38ee6aa80316fbda1ade
    https://github.com/scummvm/scummvm/commit/923efc2a4e1ad208f44a38ee6aa80316fbda1ade
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2016-09-04T08:31:39+02:00

Commit Message:
MACVENTURE: Set background pattern for exits window

In the original, the background is actually a clickable object.
I don't know if we want to implement this as a dark gray
background pattern, or as a real object. For now, though, it's
a useful test case for setBackgroundPattern().

Changed paths:
    engines/macventure/gui.cpp



diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 7b725ba..7cfc211 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -253,6 +253,11 @@ void Gui::initWindows() {
 	_exitsWindow->setDimensions(getWindowData(kExitsWindow).bounds);
 	_exitsWindow->setActive(false);
 	_exitsWindow->setCallback(exitsWindowCallback, this);
+
+	// 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.
+	_exitsWindow->setBackgroundPattern(kPatternLightGray);
 	loadBorders(_exitsWindow, findWindowData(kExitsWindow).type);
 }
 
@@ -654,18 +659,11 @@ void Gui::drawInventories() {
 void Gui::drawExitsWindow() {
 
 	Graphics::ManagedSurface *srf = _exitsWindow->getSurface();
-	BorderBounds border = borderBounds(getWindowData(kExitsWindow).type);
-
-	srf->fillRect(Common::Rect(
-		border.leftOffset,
-		border.topOffset,
-		srf->w + border.rightOffset,
-		srf->h + border.bottomOffset), kColorWhite);
 
 	Common::Array<CommandButton>::const_iterator it = _exitsData->begin();
 	for (; it != _exitsData->end(); ++it) {
 		CommandButton button = *it;
-		button.draw(*_exitsWindow->getSurface());
+		button.draw(*srf);
 	}
 
 	findWindow(kExitsWindow)->setDirty(true);





More information about the Scummvm-git-logs mailing list