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

mduggan noreply at scummvm.org
Sat Jul 20 00:32:18 UTC 2024


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

Summary:
6eecc57d48 DGDS: Update shekel count when viewing them in inventory
2f284fcc12 DGDS: Implement drop operation for HoC swap char button
2bd84e77bc DGDS: Small rendering fixes to be more like original
de1b7a07dd DGDS: Fix dialogs for strings with empty lines at end
cb5eb5b661 DGDS: Improve inventory rendering for HoC


Commit: 6eecc57d48e010d6d2492b55df988cc3b1ba984b
    https://github.com/scummvm/scummvm/commit/6eecc57d48e010d6d2492b55df988cc3b1ba984b
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-07-20T09:44:20+10:00

Commit Message:
DGDS: Update shekel count when viewing them in inventory

Changed paths:
    engines/dgds/dialog.cpp


diff --git a/engines/dgds/dialog.cpp b/engines/dgds/dialog.cpp
index fed7607aa83..9a1be3ef7c2 100644
--- a/engines/dgds/dialog.cpp
+++ b/engines/dgds/dialog.cpp
@@ -189,8 +189,18 @@ void Dialog::drawType2(Graphics::ManagedSurface *dst, DialogDrawStage stage) {
 		txt = _str;
 	}
 
+	// Special case for HoC to update the Shekel count in their description.
+	// This is how the original game does it too.
+	DgdsEngine *engine = static_cast<DgdsEngine *>(g_engine);
+	if (_fileNum == 0x5d && _num == 0x32 && engine->getGameId() == GID_HOC) {
+		int16 shekels = engine->getGDSScene()->getGlobal(44);
+		const Common::String numstr = Common::String::format("%3d", shekels);
+		uint32 offset = txt.find("###");
+		if (offset != Common::String::npos)
+			txt.replace(offset, 3, numstr);
+	}
+
 	if (stage == kDlgDrawStageBackground) {
-		DgdsEngine *engine = static_cast<DgdsEngine *>(g_engine);
 		if (engine->getGameId() == GID_DRAGON)
 			drawType2BackgroundDragon(dst, title);
 		else if (engine->getGameId() == GID_HOC)


Commit: 2f284fcc12413bb088aa8dd33fd1d1b14aaec741
    https://github.com/scummvm/scummvm/commit/2f284fcc12413bb088aa8dd33fd1d1b14aaec741
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-07-20T09:44:20+10:00

Commit Message:
DGDS: Implement drop operation for HoC swap char button

Changed paths:
    engines/dgds/dgds.cpp
    engines/dgds/scene.cpp


diff --git a/engines/dgds/dgds.cpp b/engines/dgds/dgds.cpp
index 7a401768177..1f45050909e 100644
--- a/engines/dgds/dgds.cpp
+++ b/engines/dgds/dgds.cpp
@@ -748,6 +748,7 @@ Common::Error DgdsEngine::syncGame(Common::Serializer &s) {
 		_storedAreaBuffer.fillRect(Common::Rect(SCREEN_WIDTH, SCREEN_HEIGHT), 0);
 	}
 
+	debug("%s", _scene->dump("").c_str());
 	_scene->runEnterSceneOps();
 
 	return Common::kNoError;
diff --git a/engines/dgds/scene.cpp b/engines/dgds/scene.cpp
index d0c1cd562ca..5e422131607 100644
--- a/engines/dgds/scene.cpp
+++ b/engines/dgds/scene.cpp
@@ -1721,6 +1721,15 @@ static bool _isInRect(const Common::Point &pt, const DgdsRect rect) {
 			&& rect.y <= pt.y && (rect.y + rect.height) > pt.y;
 }
 
+static const ObjectInteraction * _findInteraction(const Common::Array<ObjectInteraction> &interList, int16 droppedNum, int16 targetNum) {
+	for (const auto &i : interList) {
+		if (i.matches(droppedNum, targetNum)) {
+			return &i;
+		}
+	}
+	return nullptr;
+}
+
 void SDSScene::onDragFinish(const Common::Point &pt) {
 	assert(_dragItem);
 
@@ -1741,43 +1750,59 @@ void SDSScene::onDragFinish(const Common::Point &pt) {
 	for (const auto &item : gdsScene->getGameItems()) {
 		if (item._inSceneNum == _num && _isInRect(pt, item._rect)) {
 			debug("Dragged item %d onto item %d @ (%d, %d)", dragItem->_num, item._num, pt.x, pt.y);
-			for (const auto &i : gdsScene->getObjInteractions2()) {
-				if (i.matches(dragItem->_num, item._num)) {
-					debug(" --> exec %d drag ops for item %d", i.opList.size(), item._num);
-					if (!runOps(i.opList, globals->getGameMinsToAddOnObjInteraction()))
-						return;
-					break;
-				}
+			const ObjectInteraction *i = _findInteraction(gdsScene->getObjInteractions2(), dragItem->_num, item._num);
+			if (i) {
+				debug(" --> exec %d drag ops for item %d", i->opList.size(), item._num);
+				if (!runOps(i->opList, globals->getGameMinsToAddOnObjInteraction()))
+					return;
 			}
 		}
 	}
 
+	SDSScene *scene = engine->getScene();
 	for (const auto &area : _hotAreaList) {
 		if (!_isInRect(pt, area._rect))
 			continue;
 
+		// FIXME: This is copied in inventory too
+		static const byte HOC_CHARACTER_QUALS[] = {0, 9, 7, 8};
+
 		if (area._num == 0) {
 			debug("Item %d dropped on inventory.", dragItem->_num);
 			dragItem->_inSceneNum = 2;
-			if (engine->getGameId() == GID_HOC) {
-				// FIXME: This is copied in inventory too
-				static const byte HOC_CHARACTER_QUALS[] = {0, 9, 7, 8};
+			if (engine->getGameId() == GID_HOC)
 				dragItem->_quality = HOC_CHARACTER_QUALS[gdsScene->getGlobal(0x33)];
+
+			const ObjectInteraction *i = _findInteraction(scene->getObjInteractions1(), dragItem->_num, 0xffff);
+			if (i) {
+				debug(" --> exec %d drag ops for area %d", i->opList.size(), 0xffff);
+				if (!runOps(i->opList, globals->getGameMinsToAddOnObjInteraction()))
+					return;
+			}
+		} else if (area._num == 0xffff) {
+			debug("Item %d dropped on other character button.", dragItem->_num);
+			dragItem->_inSceneNum = 2;
+			if (engine->getGameId() == GID_HOC)
+				dragItem->_quality = HOC_CHARACTER_QUALS[gdsScene->getGlobal(0x34)];
+
+			const ObjectInteraction *i = _findInteraction(scene->getObjInteractions1(), dragItem->_num, 0xffff);
+			if (i) {
+				debug(" --> exec %d drag ops for area %d", i->opList.size(), 0xffff);
+				if (!runOps(i->opList, globals->getGameMinsToAddOnObjInteraction()))
+					return;
 			}
 		} else {
 			debug("Dragged item %d onto area %d @ (%d, %d)", dragItem->_num, area._num, pt.x, pt.y);
-			for (const auto &i : engine->getScene()->getObjInteractions1()) {
-				if (i.matches(dragItem->_num, area._num)) {
-					debug(" --> exec %d drag ops for area %d", i.opList.size(), area._num);
-					if (engine->getGameId() == GID_HOC && dragItem->_num == 98 && area._num == 25 && gdsScene->getGlobal(355) == 0) {
-						// FIXME: Why is that not executed by the runOps() call below?
-						warning("HACK for giving money to the ticket agent");
-						gdsScene->setGlobal(355, 1);
-					}
-					if (!runOps(i.opList, globals->getGameMinsToAddOnObjInteraction()))
-						return;
-					break;
+			const ObjectInteraction *i = _findInteraction(scene->getObjInteractions1(), dragItem->_num, area._num);
+			if (i) {
+				debug(" --> exec %d drag ops for area %d", i->opList.size(), area._num);
+				if (engine->getGameId() == GID_HOC && dragItem->_num == 98 && area._num == 25 && gdsScene->getGlobal(355) == 0) {
+					// FIXME: Why is that not executed by the runOps() call below?
+					warning("HACK for giving money to the ticket agent");
+					gdsScene->setGlobal(355, 1);
 				}
+				if (!runOps(i->opList, globals->getGameMinsToAddOnObjInteraction()))
+					return;
 			}
 		}
 	}


Commit: 2bd84e77bce6e825eec735ebb50defa28368b552
    https://github.com/scummvm/scummvm/commit/2bd84e77bce6e825eec735ebb50defa28368b552
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-07-20T09:44:20+10:00

Commit Message:
DGDS: Small rendering fixes to be more like original

Thanks to @eriktorbjorn for noticing the inconsistencies and suggesting fixes.

* Adjust X position of timestamp in RotD inventory
* Fix y offset of type 2 dialogs
* Make inventory button visible in background after opening inventory

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


diff --git a/engines/dgds/dgds.cpp b/engines/dgds/dgds.cpp
index 1f45050909e..26f7b96d846 100644
--- a/engines/dgds/dgds.cpp
+++ b/engines/dgds/dgds.cpp
@@ -165,10 +165,13 @@ bool DgdsEngine::changeScene(int sceneNum) {
 	_gameGlobals->setLastSceneNum(sceneNum);
 
 	// Save the current foreground if we are going to the inventory, clear it otherwise.
-	if (sceneNum == 2)
+	if (sceneNum == 2) {
+		// Slight hack - draw the inv button here to keep it in the scene
+		checkDrawInventoryButton();
 		_backgroundBuffer.blitFrom(_compositionBuffer);
-	else
+	} else {
 		_backgroundBuffer.fillRect(Common::Rect(SCREEN_WIDTH, SCREEN_HEIGHT), 0);
+	}
 
 	_scene->runLeaveSceneOps();
 
diff --git a/engines/dgds/dialog.cpp b/engines/dgds/dialog.cpp
index 9a1be3ef7c2..8491074d2f1 100644
--- a/engines/dgds/dialog.cpp
+++ b/engines/dgds/dialog.cpp
@@ -122,8 +122,8 @@ void Dialog::drawType2BackgroundDragon(Graphics::ManagedSurface *dst, const Comm
 	RequestData::drawCorners(dst, 11, _rect.x, _rect.y, _rect.width, _rect.height);
 	if (!title.empty()) {
 		// TODO: Maybe should measure the font?
-		_state->_loc.y += 10;
-		_state->_loc.height -= 10;
+		_state->_loc.y += 11;
+		_state->_loc.height -= 11;
 		RequestData::drawHeader(dst, _rect.x, _rect.y, _rect.width, 4, title, 0, true);
 	}
 
@@ -136,6 +136,8 @@ void Dialog::drawType2BackgroundDragon(Graphics::ManagedSurface *dst, const Comm
 	RequestData::drawCorners(dst, 19, _state->_loc.x - 2, _state->_loc.y - 2,
 							_state->_loc.width + 4, _state->_loc.height + 4);
 
+	_state->_loc.y++;
+	_state->_loc.height--;
 	_state->_loc.x += 8;
 	_state->_loc.width -= 16;
 }
diff --git a/engines/dgds/inventory.cpp b/engines/dgds/inventory.cpp
index f392df1e957..953a0fae19a 100644
--- a/engines/dgds/inventory.cpp
+++ b/engines/dgds/inventory.cpp
@@ -40,7 +40,7 @@ Inventory::Inventory() : _isOpen(false), _prevPageBtn(nullptr), _nextPageBtn(nul
 
 void Inventory::open() {
 	// Allow double-open becuase that's how the inventory shows item
-	// descriptions.r
+	// descriptions.
 	_isOpen = true;
 	DgdsEngine *engine = static_cast<DgdsEngine *>(g_engine);
 	int curScene = engine->getScene()->getNum();
@@ -160,7 +160,7 @@ void Inventory::drawTime(Graphics::ManagedSurface &surf) {
 	surf.fillRect(Common::Rect(clockpos, _invClock->_width, _invClock->_height), 0);
 	RequestData::drawCorners(&surf, 19, clockpos.x - 2, clockpos.y - 2,
 								_invClock->_width + 4, _invClock->_height + 4);
-	font->drawString(&surf, timeStr, clockpos.x, clockpos.y, font->getStringWidth(timeStr), _invClock->_col3);
+	font->drawString(&surf, timeStr, clockpos.x + 4, clockpos.y, font->getStringWidth(timeStr), _invClock->_col3);
 }
 
 void Inventory::drawItems(Graphics::ManagedSurface &surf) {
diff --git a/engines/dgds/request.cpp b/engines/dgds/request.cpp
index 3625ceb0754..533b87d83da 100644
--- a/engines/dgds/request.cpp
+++ b/engines/dgds/request.cpp
@@ -707,7 +707,7 @@ void RequestData::drawHeader(Graphics::ManagedSurface *dst, int16 x, int16 y, in
 			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, hbottom, 15);
+			dst->drawLine(hleft - 2, hbottom, hleft + hwidth + 2, hbottom, 15);
 		}
 	}
 }


Commit: de1b7a07dd486c96e2f98bfa76a46103ec21ceb4
    https://github.com/scummvm/scummvm/commit/de1b7a07dd486c96e2f98bfa76a46103ec21ceb4
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-07-20T10:28:28+10:00

Commit Message:
DGDS: Fix dialogs for strings with empty lines at end

Changed paths:
    engines/dgds/dialog.cpp


diff --git a/engines/dgds/dialog.cpp b/engines/dgds/dialog.cpp
index 8491074d2f1..299a0d00977 100644
--- a/engines/dgds/dialog.cpp
+++ b/engines/dgds/dialog.cpp
@@ -224,6 +224,16 @@ static void _filledCircle(int x, int y, int xr, int yr, Graphics::ManagedSurface
 	Graphics::drawEllipse(x - xr, y - yr, x + xr, y + yr, fgcol, false, _drawPixel, dst);
 }
 
+// Find the last line that will be printed - we don't use empty lines
+static uint _countPrintedLines(const Common::Array<Common::String> &lines) {
+	uint nprinted = 0;
+	for (uint i = 0; i < lines.size(); i++) {
+		if (!lines[i].empty())
+			nprinted = i;
+	}
+	return nprinted + 1;
+}
+
 // Comic thought box made up of circles with 2 circles going up to it.
 // Draw circles with 5/4 more pixels in x because the pixels are not square.
 void Dialog::drawType3(Graphics::ManagedSurface *dst, DialogDrawStage stage) {
@@ -372,11 +382,12 @@ void Dialog::drawFindSelectionXY() {
 	if (_state->_strMouseLoc) {
 		Common::Array<Common::String> lines;
 		int maxWidth = font->wordWrapText(_str, _state->_loc.width, lines);
+		uint nlines = _countPrintedLines(lines);
 
 		if (hasFlag(kDlgFlagLeftJust)) {
 			x = x + (_state->_loc.width - maxWidth - 1) / 2;
 			_state->_lastMouseX = x;
-			y = y + (_state->_loc.height - ((int)lines.size() * _state->_charHeight) - 1) / 2;
+			y = y + (_state->_loc.height - ((int)nlines * _state->_charHeight) - 1) / 2;
 			_state->_lastMouseY = y;
 		}
 
@@ -453,9 +464,10 @@ void Dialog::drawFindSelectionTxtOffset() {
 
 	Common::Array<Common::String> lines;
 	int maxWidth = font->wordWrapText(_str, _state->_loc.width, lines);
+	uint numPrintedLines = _countPrintedLines(lines);
 
 	if (hasFlag(kDlgFlagLeftJust)) {
-		int textHeight = lines.size() * lineHeight;
+		int textHeight = numPrintedLines * lineHeight;
 		dlgx += (_state->_loc.width - maxWidth - 1) / 2;
 		dlgy += (_state->_loc.height - textHeight - 1) / 2;
 	}
@@ -498,8 +510,9 @@ void Dialog::drawForeground(Graphics::ManagedSurface *dst, uint16 fontcol, const
 	const DgdsFont *font = getDlgTextFont();
 	const int h = font->getFontHeight();
 	font->wordWrapText(txt, _state->_loc.width, lines);
+	uint numPrintedLines = _countPrintedLines(lines);
 
-	int ystart = _state->_loc.y + (_state->_loc.height - (int)lines.size() * h) / 2;
+	int ystart = _state->_loc.y + (_state->_loc.height - (int)numPrintedLines * h) / 2;
 
 	int x = _state->_loc.x;
 


Commit: cb5eb5b661402878f4ea2d55ba497624233b2d97
    https://github.com/scummvm/scummvm/commit/cb5eb5b661402878f4ea2d55ba497624233b2d97
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-07-20T10:29:24+10:00

Commit Message:
DGDS: Improve inventory rendering for HoC

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


diff --git a/engines/dgds/inventory.cpp b/engines/dgds/inventory.cpp
index 953a0fae19a..fdc76ebfff3 100644
--- a/engines/dgds/inventory.cpp
+++ b/engines/dgds/inventory.cpp
@@ -33,8 +33,8 @@ namespace Dgds {
 Inventory::Inventory() : _isOpen(false), _prevPageBtn(nullptr), _nextPageBtn(nullptr),
 	_invClock(nullptr), _itemZoomBox(nullptr), _exitButton(nullptr), _clockSkipMinBtn(nullptr),
 	_itemArea(nullptr), _clockSkipHrBtn(nullptr), _dropBtn(nullptr), _itemBox(nullptr),
-	_highlightItemNo(-1), _itemOffset(0), _openedFromSceneNum(0), _showZoomBox(false),
-	_fullWidth(-1)
+	_giveToBtn(nullptr), _changeCharBtn(nullptr), _highlightItemNo(-1), _itemOffset(0),
+	_openedFromSceneNum(0), _showZoomBox(false), _fullWidth(-1)
 {
 }
 
@@ -81,6 +81,10 @@ void Inventory::setRequestData(const REQFileData &data) {
 
 	_clockSkipMinBtn = dynamic_cast<ButtonGadget *>(req.findGadgetByNumWithFlags3Not0x40(24));
 	_clockSkipHrBtn = dynamic_cast<ButtonGadget *>(req.findGadgetByNumWithFlags3Not0x40(25));
+
+	_giveToBtn = dynamic_cast<ButtonGadget *>(req.findGadgetByNumWithFlags3Not0x40(29));
+	_changeCharBtn = dynamic_cast<ButtonGadget *>(req.findGadgetByNumWithFlags3Not0x40(27));
+
 	_dropBtn = dynamic_cast<ButtonGadget *>(req.findGadgetByNumWithFlags3Not0x40(16));
 	_itemArea = dynamic_cast<ImageGadget *>(req.findGadgetByNumWithFlags3Not0x40(8));
 
@@ -119,6 +123,8 @@ void Inventory::drawHeader(Graphics::ManagedSurface &surf) {
 
 void Inventory::draw(Graphics::ManagedSurface &surf, int itemCount) {
 	RequestData &boxreq = _reqData._requests[0];
+	DgdsEngine *engine = static_cast<DgdsEngine *>(g_engine);
+	DgdsGameId gameId = engine->getGameId();
 
 	if (_showZoomBox) {
 		_itemZoomBox->_flags3 &= ~0x40;
@@ -142,6 +148,30 @@ void Inventory::draw(Graphics::ManagedSurface &surf, int itemCount) {
 		_nextPageBtn->_flags3 &= ~0x40;
 	}
 
+	//
+	// Decide whether the time buttons should be visible (only in Dragon)
+	//
+	if (gameId != GID_DRAGON) {
+		if (_clockSkipMinBtn)
+			_clockSkipMinBtn->_flags3 |= 0x40;
+		if (_clockSkipHrBtn)
+			_clockSkipHrBtn->_flags3 |= 0x40;
+	}
+
+	//
+	// Decide whether the give-to and swap char buttons should be visible (only in China)
+	//
+	if (gameId == GID_HOC) {
+		if (engine->getGDSScene()->getGlobal(0x34) != 0) {
+			// other char available, buttons visible
+			_giveToBtn->_flags3 &= ~0x40;
+			_changeCharBtn->_flags3 &= ~0x40;
+		} else {
+			_giveToBtn->_flags3 |= 0x40;
+			_changeCharBtn->_flags3 |= 0x40;
+		}
+	}
+
 	boxreq.drawInvType(&surf);
 
 	drawHeader(surf);
diff --git a/engines/dgds/inventory.h b/engines/dgds/inventory.h
index 212a1e33735..657f6acda3b 100644
--- a/engines/dgds/inventory.h
+++ b/engines/dgds/inventory.h
@@ -75,6 +75,8 @@ private:
 	ButtonGadget *_clockSkipHrBtn;
 	ButtonGadget *_dropBtn;
 	ImageGadget *_itemArea;
+	ButtonGadget *_giveToBtn;
+	ButtonGadget *_changeCharBtn;
 
 	REQFileData _reqData;
 	int _highlightItemNo;	// -1 means no item highlighted.
diff --git a/engines/dgds/request.cpp b/engines/dgds/request.cpp
index 533b87d83da..83bbcfcec59 100644
--- a/engines/dgds/request.cpp
+++ b/engines/dgds/request.cpp
@@ -588,8 +588,11 @@ void ImageGadget::draw(Graphics::ManagedSurface *dst) const {
 	// Note: not quite the same as the original logic here, but gets the same result.
 	_drawFrame(dst, xoff, yoff, _width, _height, _sval1I, _sval1I);
 
-	// NOTE: This only get done in inventory in original?
-	RequestData::drawCorners(dst, 19, xoff - 2, yoff - 2, _width + 4, _height + 4);
+	// NOTE: This only done in inventory in originals
+	if (static_cast<DgdsEngine *>(g_engine)->getGameId() == GID_DRAGON)
+		RequestData::drawCorners(dst, 19, xoff - 2, yoff - 2, _width + 4, _height + 4);
+	else
+		RequestData::drawCorners(dst, 19, xoff - 4, yoff - 4, _width + 8, _height + 8);
 }
 
 Common::String RequestData::dump() const {




More information about the Scummvm-git-logs mailing list