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

whoozle noreply at scummvm.org
Mon Jul 27 20:24:05 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:
da6b777306 PHOENIXVR: Store cursor offset in CachedCursor structure


Commit: da6b777306e256a4e47e46c9b4c679f7cf5f00fa
    https://github.com/scummvm/scummvm/commit/da6b777306e256a4e47e46c9b4c679f7cf5f00fa
Author: Vladimir Menshakov (vladimir.menshakov at gmail.com)
Date: 2026-07-27T21:19:05+01:00

Commit Message:
PHOENIXVR: Store cursor offset in CachedCursor structure

V2 Cursor_Load can provide explicit offset of cursor active point.

Changed paths:
    engines/phoenixvr/commands_v2.cpp
    engines/phoenixvr/phoenixvr.cpp
    engines/phoenixvr/phoenixvr.h


diff --git a/engines/phoenixvr/commands_v2.cpp b/engines/phoenixvr/commands_v2.cpp
index 77972b825eb..99b2a89df40 100644
--- a/engines/phoenixvr/commands_v2.cpp
+++ b/engines/phoenixvr/commands_v2.cpp
@@ -199,13 +199,14 @@ struct Stop_All_Sounds : public Command {
 struct Cursor_Load : public Command {
 	Common::String index;
 	Common::String path;
-	Common::String width;
-	Common::String height;
+	Common::String offsetX;
+	Common::String offsetY;
 
-	Cursor_Load(const Common::Array<Common::String> &args) : index(args[0]), path(args[1]), width(args.size() > 2 ? args[2].c_str() : "0"), height(args.size() > 3 ? args[3].c_str() : "0") {}
+	Cursor_Load(const Common::Array<Common::String> &args) : index(args[0]), path(args[1]),
+															 offsetX(args.size() > 2 ? args[2].c_str() : "-1"), offsetY(args.size() > 3 ? args[3].c_str() : "-1") {}
 
 	void exec(ExecutionContext &ctx) const override {
-		g_engine->loadCursor(valueOf(index), path, valueOf(width), valueOf(height));
+		g_engine->loadCursor(valueOf(index), path, valueOf(offsetX), valueOf(offsetY));
 	}
 };
 
diff --git a/engines/phoenixvr/phoenixvr.cpp b/engines/phoenixvr/phoenixvr.cpp
index cfac7595f4b..f56db041174 100644
--- a/engines/phoenixvr/phoenixvr.cpp
+++ b/engines/phoenixvr/phoenixvr.cpp
@@ -1279,31 +1279,34 @@ Graphics::ManagedSurface *PhoenixVREngine::loadSurface(const Common::String &pat
 	return s;
 }
 
-Graphics::ManagedSurface *PhoenixVREngine::loadCursor(const Common::String &path, int w, int h) {
+PhoenixVREngine::CachedCursor *PhoenixVREngine::loadCursor(const Common::String &path, int offsetX, int offsetY) {
 	if (path.empty())
 		return nullptr;
 	auto it = _cursorCache.find(path);
 	if (it != _cursorCache.end())
-		return it->_value.get();
+		return &it->_value;
 	Common::ScopedPtr<Graphics::ManagedSurface> s(loadSurface(path));
 	if (!s) {
 		warning("can't load cursor from %s", path.c_str());
 		return nullptr;
 	}
-	if (w > 0 && h > 0) {
-		s.reset(s->scale(w, h, true));
+	if (offsetX < 0 || offsetY < 0) {
+		offsetX = s->w / 2;
+		offsetY = s->h / 2;
 	}
 	auto &cursor = _cursorCache[path];
-	cursor = Common::move(s);
-	return cursor.get();
+	cursor.offset.x = offsetX;
+	cursor.offset.y = offsetY;
+	cursor.surface = Common::move(s);
+	return &cursor;
 }
 
-void PhoenixVREngine::loadCursor(int idx, const Common::String &path, int w, int h) {
-	debug("load cursor %d %s %d %d", idx, path.c_str(), w, h);
+void PhoenixVREngine::loadCursor(int idx, const Common::String &path, int offsetX, int offsetY) {
+	debug("load cursor %d %s %d %d", idx, path.c_str(), offsetX, offsetY);
 	auto &desc = _loadedCursors[idx];
 	desc.path = path;
 	_cursorCache.erase(path);
-	loadCursor(desc.path, w, h);
+	loadCursor(desc.path, offsetX, offsetY);
 }
 
 void PhoenixVREngine::spriteLoad(const Common::String &name, const Common::String &path) {
@@ -1832,7 +1835,7 @@ void PhoenixVREngine::tick(float dt) {
 	if (_nextWarp < 0 && _nextScript.empty())
 		renderVR(dt);
 
-	Graphics::ManagedSurface *cursor = nullptr;
+	CachedCursor *cursor = nullptr;
 	auto &cursors = _cursors[_warpIdx];
 	bool anyMatched = false;
 	int messengerInventoryHover = -1;
@@ -1896,10 +1899,10 @@ void PhoenixVREngine::tick(float dt) {
 	if (!cursor)
 		cursor = loadCursor(anyMatched ? _defaultCursor[1] : _defaultCursor[0]);
 	if (cursor) {
-		if (cursor->format.aBits() != 0)
-			_screen->blendBlitFrom(*cursor, _mousePos - Common::Point(cursor->w / 2, cursor->h / 2));
+		if (cursor->surface->format.aBits() != 0)
+			_screen->blendBlitFrom(*cursor->surface, _mousePos - cursor->offset);
 		else
-			_screen->simpleBlitFrom(*cursor, _mousePos - Common::Point(cursor->w / 2, cursor->h / 2));
+			_screen->simpleBlitFrom(*cursor->surface, _mousePos - cursor->offset);
 	}
 }
 
diff --git a/engines/phoenixvr/phoenixvr.h b/engines/phoenixvr/phoenixvr.h
index 251e3c8dbd9..a12f8584d73 100644
--- a/engines/phoenixvr/phoenixvr.h
+++ b/engines/phoenixvr/phoenixvr.h
@@ -131,7 +131,7 @@ public:
 	bool goToWarp(const Common::String &warp, bool savePrev = false);
 	void goToLevel(const Common::String &name);
 	void returnToWarp();
-	void loadCursor(int idx, const Common::String &path, int w, int h);
+	void loadCursor(int idx, const Common::String &path, int offsetX, int offsetY);
 	void setCursorDefault(int idx, const Common::String &path);
 	void setCursorDefault(int idx, int cursorIdx);
 	void setCursor(const Common::String &path, const Common::String &warp, int idx);
@@ -268,12 +268,17 @@ private:
 		Common::String name;
 	};
 
+	struct CachedCursor {
+		Common::ScopedPtr<Graphics::ManagedSurface> surface;
+		Common::Point offset;
+	};
+
 	static Common::String removeDrive(const Common::String &path);
 	Common::SeekableReadStream *open(const Common::String &name, Common::String *origName = nullptr);
 	Common::SeekableReadStream *tryOpen(const Common::Path &name, Common::String *origName);
 
 	Graphics::ManagedSurface *loadSurface(const Common::String &path);
-	Graphics::ManagedSurface *loadCursor(const Common::String &path, int w = 0, int h = 0);
+	CachedCursor *loadCursor(const Common::String &path, int offsetX = -1, int offsetY = -1);
 	PointF currentVRPos() const {
 		return RectF::transform(_angleX.angle(), _angleY.angle(), _fov);
 	}
@@ -356,7 +361,7 @@ private:
 	};
 	Common::Array<PreloadedCursor> _loadedCursors;
 
-	Common::HashMap<Common::String, Common::ScopedPtr<Graphics::ManagedSurface>, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _cursorCache;
+	Common::HashMap<Common::String, CachedCursor, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _cursorCache;
 	Common::HashMap<Common::String, Common::ScopedPtr<Graphics::ManagedSurface>, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _loadedSprites;
 	struct Sprite {
 		Common::String name;




More information about the Scummvm-git-logs mailing list