[Scummvm-git-logs] scummvm master -> 4da41d8f5b5502d3cbc0b5a47f4bda83c612a38f

mduggan noreply at scummvm.org
Sat Jul 20 09:41:49 UTC 2024


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:
4da41d8f5b DGDS: Fix HoC buttons and menus to match original


Commit: 4da41d8f5b5502d3cbc0b5a47f4bda83c612a38f
    https://github.com/scummvm/scummvm/commit/4da41d8f5b5502d3cbc0b5a47f4bda83c612a38f
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-07-20T19:40:43+10:00

Commit Message:
DGDS: Fix HoC buttons and menus to match original

HoC mostly pixel-correct to original menus and inventory now.

Changed paths:
    engines/dgds/dialog.cpp
    engines/dgds/request.cpp
    engines/dgds/request.h


diff --git a/engines/dgds/dialog.cpp b/engines/dgds/dialog.cpp
index 299a0d00977..f85065039f5 100644
--- a/engines/dgds/dialog.cpp
+++ b/engines/dgds/dialog.cpp
@@ -124,7 +124,7 @@ void Dialog::drawType2BackgroundDragon(Graphics::ManagedSurface *dst, const Comm
 		// TODO: Maybe should measure the font?
 		_state->_loc.y += 11;
 		_state->_loc.height -= 11;
-		RequestData::drawHeader(dst, _rect.x, _rect.y, _rect.width, 4, title, 0, true);
+		RequestData::drawHeader(dst, _rect.x, _rect.y, _rect.width, 4, title, 0, true, 0, 15);
 	}
 
 	if (hasFlag(kDlgFlagFlatBg)) {
@@ -153,7 +153,7 @@ void Dialog::drawType2BackgroundChina(Graphics::ManagedSurface *dst, const Commo
 		// TODO: Maybe should measure the font?
 		_state->_loc.y += 11;
 		_state->_loc.height -= 11;
-		RequestData::drawHeader(dst, _rect.x, _rect.y, _rect.width, 2, title, _fontColor, false);
+		RequestData::drawHeader(dst, _rect.x, _rect.y, _rect.width, 2, title, _fontColor, false, 0, 0);
 	}
 }
 
@@ -169,7 +169,7 @@ void Dialog::drawType2BackgroundBeamish(Graphics::ManagedSurface *dst, const Com
 		// TODO: Maybe should measure the font?
 		_state->_loc.y += 11;
 		_state->_loc.height -= 11;
-		RequestData::drawHeader(dst, _rect.x, _rect.y, _rect.width, 2, title, _fontColor, false);
+		RequestData::drawHeader(dst, _rect.x, _rect.y, _rect.width, 2, title, _fontColor, false, 0, 0);
 	}
 }
 
diff --git a/engines/dgds/request.cpp b/engines/dgds/request.cpp
index 34197adcc9b..106e4d5ce07 100644
--- a/engines/dgds/request.cpp
+++ b/engines/dgds/request.cpp
@@ -37,7 +37,7 @@ namespace Dgds {
 
 // TODO: The following colors are from Rise of the Dragon.  Will need to check
 // if the same ones are hard-coded in the other games.
-static const byte ButtonColors[] = {
+static const byte DragonButtonColors[] = {
 	0x73, 0xF0, 0x7B, 0xDF, 0x5F, 0x5F, 0x7E, 0x27, 0x16, 0x73, 0x27, 0x16, 0xDF
 };
 
@@ -45,6 +45,9 @@ static const byte SliderColors[] = {
 	0x7B, 0x4D, 0xF4, 0x54, 0xDF, 0x74, 0x58
 };
 
+static const byte DragonHeaderTxtColor = 0;
+static const byte DragonHeaderTopColor = 0;
+static const byte DragonHeaderBottomColor = 15;
 static const byte DragonFallbackColors[] = {
 	0x7, 0x7, 0x8, 0x7, 0x0, 0xF, 0x7, 0xC,
 	0x4, 0x0, 0xF, 0xF, 0xC, 0x4, 0x7, 0xF,
@@ -52,6 +55,15 @@ static const byte DragonFallbackColors[] = {
 };
 
 static const byte ChinaBackgroundColor = 23;
+static const byte ChinaHeaderTxtColor = 25;
+static const byte ChinaHeaderTopColor = 16;
+static const byte ChinaHeaderBottomColor = 20;
+static const byte ChinaButtonColorsOn[] = {
+	0x10, 0x11, 0x10, 0x10, 0x10, 0x06, 0x14, 0x1A,
+};
+static const byte ChinaButtonColorsOff[] = {
+	0x10, 0x14, 0x06, 0x18, 0x10, 0x11, 0x14, 0x13,
+};
 
 // TODO: Work out correct fill color for willy beamish
 static const byte WillyBackgroundColor = 23;
@@ -326,50 +338,109 @@ void Gadget::setVisible(bool visible) {
 		_flags3 |= 0x40;
 }
 
-void ButtonGadget::draw(Graphics::ManagedSurface *dst) const {
-	// TODO: Bounds calculation here might depend on parent.
-
-	int16 x = _x + _parentX;
-	int16 y = _y + _parentY;
+byte ButtonGadget::drawDragonBg(Graphics::ManagedSurface *dst, bool enabled) const {
+	Common::Point pt = topLeft();
+	int16 x = pt.x;
+	int16 y = pt.y;
 
 	int16 right = x + _width;
 	int16 x2 = right - 1;
 	int16 bottom = (y + _height) - 1;
 
-	byte fill = ButtonColors[0];
+	byte fill = DragonButtonColors[0];
 	dst->drawLine(x, y, x2, y, fill);
 	dst->drawLine(x + 2, y + 2, right - 3, y + 2, fill);
 	dst->drawLine(x + 1, bottom - 2, x + 1, bottom - 2, fill);
 	dst->drawLine(right - 2, bottom - 2, right - 2, bottom - 2, fill);
 	dst->drawLine(x + 1, bottom - 1, right - 2, bottom - 1, fill);
 
-	fill = ButtonColors[1];
+	fill = DragonButtonColors[1];
 	dst->drawLine(x, y + 1, x, bottom, fill);
 	dst->drawLine(x2, y + 1, x2, bottom, fill);
 	dst->drawLine(x + 2, y + 3, x + 2, bottom - 2, fill);
 	dst->drawLine(right - 3, y + 3, right - 3, bottom - 2, fill);
 	dst->drawLine(x + 3,bottom - 2, right - 4, bottom - 2, fill);
 
-	fill = ButtonColors[2];
+	fill = DragonButtonColors[2];
 	dst->drawLine(x + 1, y + 2, x + 1, bottom - 3, fill);
 	dst->drawLine(right - 2, y + 2, right - 2, bottom - 3, fill);
-	dst->drawLine(x + 1, bottom, right - 2, bottom, ButtonColors[3]);
-	dst->drawLine(x + 1, y + 1, right - 2, y + 1, ButtonColors[4]);
+	dst->drawLine(x + 1, bottom, right - 2, bottom, DragonButtonColors[3]);
+	dst->drawLine(x + 1, y + 1, right - 2, y + 1, DragonButtonColors[4]);
 
-	bool enabled = !(_flags3 & 9);
 	int colOffset;
-	if (!enabled) {
-		colOffset = 9;
-	}  else {
+	if (enabled) {
 		colOffset = 5;
+	}  else {
+		colOffset = 9;
 	}
 
-	dst->drawLine(x + 3, y + 3, right - 4, y + 3, ButtonColors[colOffset + 1]);
+	dst->drawLine(x + 3, y + 3, right - 4, y + 3, DragonButtonColors[colOffset + 1]);
 
 	// TODO: This is done with a different call in the game.. is there some reason for that?
-	dst->fillRect(Common::Rect(x + 3, y + 4, x + 3 + _width - 6, y + 4 + _height - 8), ButtonColors[colOffset + 2]);
+	dst->fillRect(Common::Rect(x + 3, y + 4, x + 3 + _width - 6, y + 4 + _height - 8), DragonButtonColors[colOffset + 2]);
+
+	dst->drawLine(x + 3, bottom - 3, right - 4, bottom - 3, DragonButtonColors[colOffset + 3]);
+
+	return DragonButtonColors[colOffset];
+}
+
+byte ButtonGadget::drawChinaBg(Graphics::ManagedSurface *dst, bool enabled) const {
+	Common::Point pt = topLeft();
+	int16 x = pt.x;
+	int16 x2 = x + _width - 1;
+	int16 y = pt.y;
+	int16 y2 = y + _height - 1;
+	int cnum = 0;
+	const byte *colors = (enabled ? ChinaButtonColorsOn : ChinaButtonColorsOff);
+
+	for (int i = 0; i < 7; i++) {
+		byte drawCol = colors[cnum];
+		cnum++;
+		if (i < 3) {
+			dst->drawLine(x + i + 1, y + i, x2 - i, y + i, drawCol);
+			dst->drawLine(x2 - i, y + i + 1, x2 - i, y2 - i, drawCol);
+		} else if (i < 4) {
+			int16 rheight, rwidth;
+			if (_height + -6 < 3)
+				rheight = 2;
+			else
+				rheight = _height + -6;
+
+			if (_width + -6 < 3)
+				rwidth = 2;
+			else
+				rwidth = _width + -6;
 
-	dst->drawLine(x + 3, bottom - 3, right - 4, bottom - 3, ButtonColors[colOffset + 3]);
+			dst->fillRect(Common::Rect(Common::Point(x + 3, y + 3), rwidth, rheight), drawCol);
+		} else {
+			int16 x2_ = 6 - i;
+			dst->drawLine(x + x2_, y + x2_, x + x2_, y2 - x2_, drawCol);
+			dst->drawLine(x + x2_, y2 - x2_, (x2 - x2_) + -1, y2 - x2_, drawCol);
+		}
+    }
+    return colors[7];
+}
+
+byte ButtonGadget::drawWillyBg(Graphics::ManagedSurface *dst, bool enabled) const {
+	// TODO: Write code to draw Willy Beamish type buttons..
+	return drawChinaBg(dst, enabled);
+}
+
+void ButtonGadget::draw(Graphics::ManagedSurface *dst) const {
+	DgdsGameId gameId = static_cast<DgdsEngine *>(g_engine)->getGameId();
+	bool enabled = !(_flags3 & 9);
+
+	byte textCol;
+	if (gameId == GID_DRAGON)
+		textCol = drawDragonBg(dst, enabled);
+	else if (gameId == GID_HOC)
+		textCol = drawChinaBg(dst, enabled);
+	else
+		textCol = drawWillyBg(dst, enabled);
+
+	Common::Point pt = topLeft();
+	int16 x = pt.x;
+	int16 y = pt.y;
 
 	if (!_buttonName.empty()) {
 		const DgdsFont *font = RequestData::getMenuFont();
@@ -394,11 +465,11 @@ void ButtonGadget::draw(Graphics::ManagedSurface *dst) const {
 
 		yoffset = y + yoffset / 2;
 		int lineWidth = font->getStringWidth(line1);
-		font->drawString(dst, line1, x + (_width - lineWidth) / 2 + 1, yoffset + 2, lineWidth, ButtonColors[colOffset]);
+		font->drawString(dst, line1, x + (_width - lineWidth) / 2 + 1, yoffset + 2, lineWidth, textCol);
 
 		if (linebreak != Common::String::npos) {
 			lineWidth = font->getStringWidth(line2);
-			font->drawString(dst, line2, x + (_width - lineWidth) / 2 + 1, yoffset + fontHeight, lineWidth, ButtonColors[colOffset]);
+			font->drawString(dst, line2, x + (_width - lineWidth) / 2 + 1, yoffset + fontHeight, lineWidth, textCol);
 		}
 	}
 
@@ -702,7 +773,7 @@ void RequestData::drawCorners(Graphics::ManagedSurface *dst, uint16 startNum, ui
 }
 
 /*static*/
-void RequestData::drawHeader(Graphics::ManagedSurface *dst, int16 x, int16 y, int16 width, int16 yoffset, const Common::String &header, byte fontCol, bool addBox) {
+void RequestData::drawHeader(Graphics::ManagedSurface *dst, int16 x, int16 y, int16 width, int16 yoffset, const Common::String &header, byte fontCol, bool drawBox, byte boxTopColor, byte boxBottomColor) {
 	if (!header.empty()) {
 		const DgdsFont *font = getMenuFont();
 		int hwidth = font->getStringWidth(header);
@@ -713,11 +784,11 @@ void RequestData::drawHeader(Graphics::ManagedSurface *dst, int16 x, int16 y, in
 		int hbottom = htop + hheight;
 
 		font->drawString(dst, header, hleft + 1, htop + 2, hwidth, fontCol);
-		if (addBox) {
-			dst->drawLine(hleft - 3, htop, hright, htop, 0);
-			dst->drawLine(hright, htop + 1, hright, hbottom, 0);
-			dst->drawLine(hleft - 3, htop + 1, hleft - 3, hbottom, 15);
-			dst->drawLine(hleft - 2, hbottom, hleft + hwidth + 2, hbottom, 15);
+		if (drawBox) {
+			dst->drawLine(hleft - 3, htop, hright, htop, boxTopColor);
+			dst->drawLine(hright, htop + 1, hright, hbottom, boxTopColor);
+			dst->drawLine(hleft - 3, htop + 1, hleft - 3, hbottom, boxBottomColor);
+			dst->drawLine(hleft - 2, hbottom, hleft + hwidth + 2, hbottom, boxBottomColor);
 		}
 	}
 }
@@ -762,8 +833,10 @@ void RequestData::drawBackgroundWithSliderArea(Graphics::ManagedSurface *dst, in
 	dst->transBlitFrom(*corners[9], Common::Point(x, (y + sliderBgHeight) - corners[9]->h));
 	dst->transBlitFrom(*corners[10], Common::Point((x + width) - corners[10]->w, (y + sliderBgHeight) - corners[10]->h));
 
-	drawHeader(dst, x, y, width, 9, header, 0,
-		static_cast<DgdsEngine *>(g_engine)->getGameId() == GID_DRAGON);
+	if (static_cast<DgdsEngine *>(g_engine)->getGameId() == GID_DRAGON)
+		drawHeader(dst, x, y, width, 9, header, DragonHeaderTxtColor, true, DragonHeaderTopColor, DragonHeaderBottomColor);
+	else
+		drawHeader(dst, x, y + 4, width, 9, header, ChinaHeaderTxtColor, true, ChinaHeaderTopColor, ChinaHeaderBottomColor);
 }
 
 
@@ -782,7 +855,10 @@ void RequestData::drawBackgroundNoSliders(Graphics::ManagedSurface *dst, const C
 		fillBackground(dst, _rect.x + 5, _rect.y + 5, _rect.width - 10, _rect.height - 10, 0);
 	uint16 cornerOffset = (gameId == GID_DRAGON ? 11 : (gameId == GID_HOC ? 1 : 0));
 	drawCorners(dst, cornerOffset, _rect.x, _rect.y, _rect.width, _rect.height);
-	drawHeader(dst, _rect.x, _rect.y, _rect.width, 4, header, 0, gameId == GID_DRAGON);
+	if (gameId == GID_DRAGON)
+		drawHeader(dst, _rect.x, _rect.y, _rect.width, 4, header, DragonHeaderTxtColor, true, DragonHeaderTopColor, DragonHeaderBottomColor);
+	else
+		drawHeader(dst, _rect.x, _rect.y + 4, _rect.width, 4, header, ChinaHeaderTxtColor, true, ChinaHeaderTopColor, ChinaHeaderBottomColor);
 }
 
 /*static*/
diff --git a/engines/dgds/request.h b/engines/dgds/request.h
index ca423f46d21..47910024b5b 100644
--- a/engines/dgds/request.h
+++ b/engines/dgds/request.h
@@ -113,6 +113,11 @@ class ButtonGadget : public Gadget {
 public:
 	void draw(Graphics::ManagedSurface *dst) const override;
 	void toggle(bool enable) override;
+private:
+	// Each of these return the text color
+	byte drawDragonBg(Graphics::ManagedSurface *dst, bool enabled) const;
+	byte drawChinaBg(Graphics::ManagedSurface *dst, bool enabled) const;
+	byte drawWillyBg(Graphics::ManagedSurface *dst, bool enabled) const;
 };
 
 // extended gadget type 1 is 62 (0x3e) bytes
@@ -200,7 +205,7 @@ public:
 
 	static void fillBackground(Graphics::ManagedSurface *dst, uint16 x, uint16 y, uint16 width, uint16 height, int16 startoffset);
 	static void drawCorners(Graphics::ManagedSurface *dst, uint16 startNum, uint16 x, uint16 y, uint16 width, uint16 height);
-	static void drawHeader(Graphics::ManagedSurface *dst, int16 x, int16 y, int16 width, int16 yoffset, const Common::String &header, byte fontCol, bool addBox);
+	static void drawHeader(Graphics::ManagedSurface *dst, int16 x, int16 y, int16 width, int16 yoffset, const Common::String &header, byte fontCol, bool drawBox, byte boxTopColor, byte boxBottomColor);
 	Gadget *findGadgetByNumWithFlags3Not0x40(int16 num);
 
 private:




More information about the Scummvm-git-logs mailing list