[Scummvm-git-logs] scummvm master -> 8a7a56560b60e6ec080335b623eb587c00be3c2c

neuromancer noreply at scummvm.org
Mon Nov 2 17:17:27 UTC 2026


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

Summary:
8a7a56560b HOLLYWOOD: implemented hotspot labeling


Commit: 8a7a56560b60e6ec080335b623eb587c00be3c2c
    https://github.com/scummvm/scummvm/commit/8a7a56560b60e6ec080335b623eb587c00be3c2c
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2026-11-02T18:16:56+01:00

Commit Message:
HOLLYWOOD: implemented hotspot labeling

Changed paths:
    engines/hollywood/metaengine.cpp
    engines/hollywood/monsters/gameplay/game_loop.cpp
    engines/hollywood/monsters/gameplay/hotspots.cpp
    engines/hollywood/monsters/gameplay/hotspots.h
    engines/hollywood/monsters/hollywood.cpp
    engines/hollywood/monsters/hollywood.h
    engines/hollywood/monsters/scenes/playable/playable_scene.cpp


diff --git a/engines/hollywood/metaengine.cpp b/engines/hollywood/metaengine.cpp
index d656dc932e6..b3d60fe4934 100644
--- a/engines/hollywood/metaengine.cpp
+++ b/engines/hollywood/metaengine.cpp
@@ -20,7 +20,11 @@
  */
 
 #include "base/plugins.h"
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymap.h"
+#include "backends/keymapper/standard-actions.h"
 #include "common/config-manager.h"
+#include "common/translation.h"
 #include "engines/advancedDetector.h"
 #include "graphics/thumbnail.h"
 
@@ -83,7 +87,12 @@ void HollywoodMetaEngine::getSavegameThumbnail(Graphics::Surface &thumb) {
 Common::Array<Common::Keymap *> HollywoodMetaEngine::initKeymaps(const char *target) const {
 	if (getGameId(target) == "runaway")
 		return RunawayEngine::initKeymaps();
-	return MetaEngine::initKeymaps(target);
+	Common::KeymapArray keymaps = MetaEngine::initKeymaps(target);
+	Common::Action *action = new Common::Action(Common::kStandardActionToggleHotspots, _("Show hotspots"));
+	action->setEvent(Common::EVENT_HOTSPOTS_SHOW);
+	action->addDefaultInputMapping("h");
+	keymaps[0]->addAction(action);
+	return keymaps;
 }
 
 } // End of namespace Hollywood
diff --git a/engines/hollywood/monsters/gameplay/game_loop.cpp b/engines/hollywood/monsters/gameplay/game_loop.cpp
index c0c9e204b9b..007b8ad65a1 100644
--- a/engines/hollywood/monsters/gameplay/game_loop.cpp
+++ b/engines/hollywood/monsters/gameplay/game_loop.cpp
@@ -213,6 +213,7 @@ bool GameplayLoop::run() {
 		_delegate->presentGameplayFrame(_hoverCaption, _panelState);
 	}
 
+	_vm->drawSceneHotspots();
 	_vm->cursor()->leaveInteractiveMode();
 	return true;
 }
@@ -233,6 +234,7 @@ bool GameplayLoop::pollEvents() {
 			return true;
 		case Common::EVENT_MAINMENU:
 			{
+				_vm->drawSceneHotspots();
 				const bool previousCanSave = _vm->canSave();
 				_vm->setCanSave(true);
 				_vm->openMainMenuDialog();
@@ -323,6 +325,7 @@ void GameplayLoop::handleKeyUp(const Common::KeyState &keyState) {
 }
 
 void GameplayLoop::handleLeftClick() {
+	_vm->drawSceneHotspots();
 	if (_panelState.inventoryPanelVisible) {
 		const uint16 cursorX = _vm->cursor()->surfaceX();
 		const uint16 cursorY = _vm->cursor()->surfaceY();
@@ -560,6 +563,7 @@ void GameplayLoop::closeInventoryPanel() {
 }
 
 void GameplayLoop::openOptionsMenu() {
+	_vm->drawSceneHotspots();
 	const Common::String previousLanguage = _vm->textTranslation()->language();
 	const bool restoreInventoryPanel = _panelState.inventoryPanelVisible;
 	const bool restoreVerbPanel = _panelState.verbPanelVisible && !restoreInventoryPanel;
diff --git a/engines/hollywood/monsters/gameplay/hotspots.cpp b/engines/hollywood/monsters/gameplay/hotspots.cpp
index c1d7ad19bfb..5c074c9a47e 100644
--- a/engines/hollywood/monsters/gameplay/hotspots.cpp
+++ b/engines/hollywood/monsters/gameplay/hotspots.cpp
@@ -19,6 +19,10 @@
  *
  */
 
+#include "common/frac.h"
+#include "common/system.h"
+#include "common/ustr.h"
+#include "graphics/hotspot_renderer.h"
 #include "graphics/surface.h"
 
 #include "hollywood/monsters/hollywood.h"
@@ -29,6 +33,79 @@
 
 namespace Hollywood {
 
+class HollywoodHotspotRenderer : public Graphics::HotspotRenderer {
+protected:
+	void prepareRender(const Common::Array<Graphics::HotspotInfo> &hotspots,
+			int gameWidth, int gameHeight, int overlayWidth, int overlayHeight) override {
+		_screenSize = Common::Point(gameWidth, gameHeight);
+		_gameArea = Common::Rect(overlayWidth, overlayHeight);
+
+		const int stretchMode = g_system->getStretchMode();
+		const OSystem::GraphicsMode *mode = g_system->getSupportedStretchModes();
+		while (mode && mode->name && mode->id != stretchMode)
+			++mode;
+		if (!mode || !mode->name)
+			return;
+
+		const bool fit = !strcmp(mode->name, "fit");
+		const bool center = !strcmp(mode->name, "center");
+		const bool integral = !strcmp(mode->name, "pixel-perfect") || !strcmp(mode->name, "even-pixels");
+		if (!fit && !center && !integral)
+			return;
+
+		// Desktop backends can center the game inside a larger overlay.
+		const Common::Rect safeArea = g_system->getSafeOverlayArea();
+		if (safeArea.isEmpty())
+			return;
+
+		int width = safeArea.width();
+		int height = safeArea.height();
+		const frac_t aspect = intToFrac(gameWidth) / gameHeight;
+		if (fit) {
+			const frac_t overlayAspect = intToFrac(width) / height;
+			if (overlayAspect < aspect)
+				height = intToFrac(width) / aspect;
+			else if (overlayAspect > aspect)
+				width = fracToInt(height * aspect);
+		} else {
+			width = gameWidth * g_system->getScaleFactor();
+			height = intToFrac(width) / aspect;
+			if (width > safeArea.width() || height > safeArea.height()) {
+				const int divisor = 1 + MAX((width - 1) / safeArea.width(), (height - 1) / safeArea.height());
+				width /= divisor;
+				height /= divisor;
+			} else if (integral) {
+				const int factor = MIN(safeArea.width() / width, safeArea.height() / height);
+				width *= factor;
+				height *= factor;
+			}
+		}
+
+		int16 left = (overlayWidth - width) / 2;
+		int16 top = (overlayHeight - height) / 2;
+		safeArea.constrain(left, top, width, height);
+		_gameArea = Common::Rect(left, top, left + width, top + height);
+		_sizeScale = _style.scaleWithGame ? MIN((float)width / gameWidth, (float)height / gameHeight) : 1.0f;
+		_markerSize = MAX(2, (int)(_style.markerSize * _sizeScale));
+		_pointRadius = MAX(1, (int)(_style.pointRadius * _sizeScale));
+		_lineThickness = MAX(1, (int)(_style.lineThickness * _sizeScale));
+	}
+
+	Common::Point placeHotspot(const Graphics::HotspotInfo &hotspot, Common::Point position) override {
+		return Common::Point(
+			_gameArea.left + hotspot.position.x * _gameArea.width() / _screenSize.x,
+			_gameArea.top + hotspot.position.y * _gameArea.height() / _screenSize.y);
+	}
+
+private:
+	Common::Point _screenSize;
+	Common::Rect _gameArea;
+};
+
+Graphics::HotspotRenderer *HollywoodEngine::createHotspotRenderer() {
+	return new HollywoodHotspotRenderer();
+}
+
 const uint kSceneChunk3ColorToItemMapOffset = 0x100;
 const uint kSceneColorMapSize = 0x100;
 const uint kSceneVerbCount = 8;
@@ -154,6 +231,59 @@ byte SceneHotspotTable::resolveItemAt(const Graphics::Surface &savedFramebuffer,
 	return 0;
 }
 
+void SceneHotspotTable::getHotspotPositions(Common::Array<Graphics::HotspotInfo> &hotspots,
+		const Graphics::Surface &savedFramebuffer, uint16 xOffset, uint16 yOffset) const {
+	const int width = MIN<int>(HollywoodEngine::kScreenWidth, savedFramebuffer.w - xOffset);
+	const int height = MIN<int>(HollywoodEngine::kScreenHeight, savedFramebuffer.h - yOffset);
+	Common::Rect bounds[HollywoodEngine::kSceneItemCount];
+	for (int y = 0; y < height; ++y) {
+		for (int x = 0; x < width; ++x) {
+			const byte item = resolveItemAt(savedFramebuffer, x, y, xOffset, yOffset);
+			if (item == 0 || item >= ARRAYSIZE(bounds))
+				continue;
+			const Common::Rect pixel(x, y, x + 1, y + 1);
+			if (bounds[item].isEmpty())
+				bounds[item] = pixel;
+			else
+				bounds[item].extend(pixel);
+		}
+	}
+
+	for (uint item = 1; item < ARRAYSIZE(bounds); ++item) {
+		const Common::String name = itemName(item);
+		if (bounds[item].isEmpty() || name.empty())
+			continue;
+
+		const Common::Point center = bounds[item].center();
+		Common::Point position = center;
+		// Irregular or disconnected hit regions may not contain their center.
+		if (resolveItemAt(savedFramebuffer, center.x, center.y, xOffset, yOffset) != item) {
+			uint bestDistance = width * width + height * height;
+			for (int y = bounds[item].top; y < bounds[item].bottom; ++y) {
+				for (int x = bounds[item].left; x < bounds[item].right; ++x) {
+					const Common::Point point(x, y);
+					const uint distance = point.sqrDist(center);
+					if (distance < bestDistance && resolveItemAt(savedFramebuffer, x, y, xOffset, yOffset) == item) {
+						position = point;
+						bestDistance = distance;
+					}
+				}
+			}
+		}
+
+		Common::U32String label(name, Common::kDos850);
+		for (uint i = 0; i < name.size(); ++i) {
+			switch ((byte)name[i]) {
+			case '%': label.setChar('\'', i); break;
+			case 0xf0: label.setChar(0x201c, i); break;
+			case 0xf1: label.setChar(0x201d, i); break;
+			default: break;
+			}
+		}
+		hotspots.push_back(Graphics::HotspotInfo(position, label));
+	}
+}
+
 byte SceneHotspotTable::defaultStripForItem(byte itemId) const {
 	if (itemId >= _itemDefaultStrips.size())
 		return 0;
diff --git a/engines/hollywood/monsters/gameplay/hotspots.h b/engines/hollywood/monsters/gameplay/hotspots.h
index 81f49775644..ad6c4e8ff04 100644
--- a/engines/hollywood/monsters/gameplay/hotspots.h
+++ b/engines/hollywood/monsters/gameplay/hotspots.h
@@ -30,6 +30,7 @@
 #include "hollywood/monsters/scenes/scene_data.h"
 
 namespace Graphics {
+struct HotspotInfo;
 struct Surface;
 }
 
@@ -65,6 +66,8 @@ public:
 
 	byte resolveItemAt(const Graphics::Surface &savedFramebuffer, uint16 cursorX, uint16 cursorY,
 		uint16 xOffset, uint16 yOffset) const;
+	void getHotspotPositions(Common::Array<Graphics::HotspotInfo> &hotspots,
+		const Graphics::Surface &savedFramebuffer, uint16 xOffset, uint16 yOffset) const;
 	byte defaultStripForItem(byte itemId) const;
 	bool hasVerbAction(byte itemId, byte stripIndex) const;
 	SceneVerbActionRecord verbActionRecord(byte itemId, byte stripIndex) const;
diff --git a/engines/hollywood/monsters/hollywood.cpp b/engines/hollywood/monsters/hollywood.cpp
index 0d5da86c200..40b971579de 100644
--- a/engines/hollywood/monsters/hollywood.cpp
+++ b/engines/hollywood/monsters/hollywood.cpp
@@ -34,6 +34,7 @@
 #include "hollywood/monsters/console.h"
 #include "hollywood/debug.h"
 #include "hollywood/monsters/font.h"
+#include "hollywood/monsters/gameplay/game_loop.h"
 #include "hollywood/monsters/gameplay/travel_screen.h"
 #include "hollywood/resource.h"
 #include "hollywood/monsters/scenes/intro/demo_montage.h"
@@ -159,7 +160,8 @@ HollywoodEngine::HollywoodEngine(OSystem *syst, const ADGameDescription *gameDes
 		_sceneRestartRequested(false),
 		_debugSceneSolveRequest(0),
 		_scene7100RescueFailureVariant(false),
-		_canSave(false) {
+		_canSave(false),
+		_hotspotScene(nullptr) {
 }
 
 HollywoodEngine::~HollywoodEngine() {
@@ -390,6 +392,21 @@ bool HollywoodEngine::hasFeature(EngineFeature f) const {
 		f == kSupportsSavingDuringRuntime;
 }
 
+void HollywoodEngine::drawSceneHotspots(const GameplayLoopDelegate *scene) {
+	if (!_showHotspots)
+		return;
+
+	_hotspotScene = scene;
+	drawHotspots();
+	_hotspotScene = nullptr;
+}
+
+void HollywoodEngine::getHotspotPositions(Common::Array<Graphics::HotspotInfo> &hotspots) {
+	if (_hotspotScene && !_hotspotScene->shouldExitGameplayLoop())
+		_hotspotScene->hotspots().getHotspotPositions(hotspots, _hotspotScene->savedFramebuffer(),
+			_hotspotScene->viewportXOffset(), _hotspotScene->viewportYOffset());
+}
+
 void HollywoodEngine::syncSoundSettings() {
 	Engine::syncSoundSettings();
 
diff --git a/engines/hollywood/monsters/hollywood.h b/engines/hollywood/monsters/hollywood.h
index 54235ad3cb8..c763be1b09d 100644
--- a/engines/hollywood/monsters/hollywood.h
+++ b/engines/hollywood/monsters/hollywood.h
@@ -41,6 +41,7 @@ class Serializer;
 
 namespace Hollywood {
 
+class GameplayLoopDelegate;
 class HollywoodFont;
 
 class HollywoodEngine : public Engine {
@@ -92,6 +93,7 @@ public:
 	}
 	bool canSave() const { return _canSave; }
 	void setCanSave(bool canSave) { _canSave = canSave; }
+	void drawSceneHotspots(const GameplayLoopDelegate *scene = nullptr);
 
 	enum {
 		kScreenWidth = 640,
@@ -101,6 +103,11 @@ public:
 		kSceneItemCount = 21
 	};
 
+protected:
+	void getHotspotPositions(Common::Array<Graphics::HotspotInfo> &hotspots) override;
+	Graphics::HotspotRenderer *createHotspotRenderer() override;
+	bool hideCursorForHotspots() const override { return false; }
+
 private:
 	uint nextSubtitleLanguageIndex() const;
 	Common::Error syncGameStream(Common::Serializer &s);
@@ -120,6 +127,7 @@ private:
 	uint16 _debugSceneSolveRequest;
 	bool _scene7100RescueFailureVariant;
 	bool _canSave;
+	const GameplayLoopDelegate *_hotspotScene;
 };
 
 } // End of namespace Hollywood
diff --git a/engines/hollywood/monsters/scenes/playable/playable_scene.cpp b/engines/hollywood/monsters/scenes/playable/playable_scene.cpp
index ddabff45c57..bdcd7328b96 100644
--- a/engines/hollywood/monsters/scenes/playable/playable_scene.cpp
+++ b/engines/hollywood/monsters/scenes/playable/playable_scene.cpp
@@ -3486,6 +3486,7 @@ void PlayableScene::presentFrame(const SceneHoverCaption *hoverCaption, const Ga
 	const bool screenChanged = _surfaceState.updatePresentedScreenCache();
 	if (screenChanged || paletteChanged)
 		g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
+	_vm->drawSceneHotspots(hoverCaption && !(panelState && panelState->visible()) ? this : nullptr);
 	g_system->updateScreen();
 }
 




More information about the Scummvm-git-logs mailing list