[Scummvm-git-logs] scummvm master -> 5a78354380a9204afcf0f023a18cc465b2b57466
klusark
noreply at scummvm.org
Tue Nov 10 23:35:06 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:
5a78354380 GRIM: Implement SetOffscreenTextPos
Commit: 5a78354380a9204afcf0f023a18cc465b2b57466
https://github.com/scummvm/scummvm/commit/5a78354380a9204afcf0f023a18cc465b2b57466
Author: Joel Teichroeb (joel at teichroeb.net)
Date: 2026-11-10T18:30:41-05:00
Commit Message:
GRIM: Implement SetOffscreenTextPos
The original stores the position where the subtitles of actors that are not
on the screen are shown. Dialogs move it to the top of the screen and put it
back when they end.
Assisted-by: Claude:claude-sonnet-5-5
Changed paths:
engines/grim/actor.cpp
engines/grim/emi/lua_v2.cpp
engines/grim/emi/lua_v2.h
engines/grim/grim.cpp
engines/grim/grim.h
engines/grim/lua_v1_text.cpp
diff --git a/engines/grim/actor.cpp b/engines/grim/actor.cpp
index 10060290b76..b659eaa81e8 100644
--- a/engines/grim/actor.cpp
+++ b/engines/grim/actor.cpp
@@ -1286,8 +1286,9 @@ void Actor::sayLine(const char *msgId, bool background, float x, float y) {
_mustPlaceText = true;
} else {
_mustPlaceText = false;
- textObject->setX(640 / 2);
- textObject->setY(463);
+ const Common::Point &pos = g_grim->getOffscreenTextPos();
+ textObject->setX(pos.x);
+ textObject->setY(pos.y);
}
}
textObject->setText(msgId, _mustPlaceText);
@@ -1814,8 +1815,9 @@ void Actor::draw() {
TextObject *textObject = TextObject::getPool().getObject(_sayLineText);
if (textObject) {
if (p1.x == 1000 || p2.x == -1000 || p2.x == -1000) {
- textObject->setX(640 / 2);
- textObject->setY(463);
+ const Common::Point &pos = g_grim->getOffscreenTextPos();
+ textObject->setX(pos.x);
+ textObject->setY(pos.y);
} else {
textObject->setX((p1.x + p2.x) / 2);
textObject->setY(p1.y);
diff --git a/engines/grim/emi/lua_v2.cpp b/engines/grim/emi/lua_v2.cpp
index 7cb952407a2..506fdbf7d30 100644
--- a/engines/grim/emi/lua_v2.cpp
+++ b/engines/grim/emi/lua_v2.cpp
@@ -246,6 +246,21 @@ void Lua_V2::GetTextCharPosition() {
}
}
+void Lua_V2::SetOffscreenTextPos() {
+ // Unlike in Grim the coordinates are normalized, from -1 to 1 with y going up
+ // from the bottom, that is 0, 0 is the center. Anything that is not a number
+ // selects the default, 0 for x and 0.875 for y.
+ lua_Object xObj = lua_getparam(1);
+ lua_Object yObj = lua_getparam(2);
+
+ Common::Point pos = g_grim->getDefaultOffscreenTextPos();
+ if (lua_isnumber(xObj))
+ pos.x = (int)(320.f * (1.f + lua_getnumber(xObj)));
+ if (lua_isnumber(yObj))
+ pos.y = (int)(240.f * (1.f - lua_getnumber(yObj)));
+ g_grim->setOffscreenTextPos(pos);
+}
+
void Lua_V2::GetTextObjectDimensions() {
lua_Object textObj = lua_getparam(1);
diff --git a/engines/grim/emi/lua_v2.h b/engines/grim/emi/lua_v2.h
index 46e2d829b4a..fbf48219b7f 100644
--- a/engines/grim/emi/lua_v2.h
+++ b/engines/grim/emi/lua_v2.h
@@ -168,6 +168,7 @@ protected:
DECLARE_LUA_OPCODE(GetFontDimensions) override;
DECLARE_LUA_OPCODE(GetTextObjectDimensions) override;
DECLARE_LUA_OPCODE(GetTextCharPosition) override;
+ DECLARE_LUA_OPCODE(SetOffscreenTextPos) override;
DECLARE_LUA_OPCODE(SetActorRestChore) override;
DECLARE_LUA_OPCODE(SetActorWalkChore) override;
DECLARE_LUA_OPCODE(SetActorTurnChores) override;
diff --git a/engines/grim/grim.cpp b/engines/grim/grim.cpp
index c84f3cc2a3e..549a38870d2 100644
--- a/engines/grim/grim.cpp
+++ b/engines/grim/grim.cpp
@@ -161,6 +161,8 @@ GrimEngine::GrimEngine(OSystem *syst, uint32 gameFlags, GrimGameType gameType, C
_printLineDefaults.setFont(nullptr);
_printLineDefaults.setJustify(TextObject::LJUSTIFY);
+ _offscreenTextPos = getDefaultOffscreenTextPos();
+
_sayLineDefaults.setX(0);
_sayLineDefaults.setY(100);
_sayLineDefaults.setWidth(0);
@@ -1711,6 +1713,11 @@ void GrimEngine::pauseEngineIntern(bool pause) {
}
}
+Common::Point GrimEngine::getDefaultOffscreenTextPos() const {
+ // EMI shows them at the top of the screen
+ return Common::Point(320, _gameType == GType_MONKEY4 ? 30 : 450);
+}
+
void GrimEngine::debugLua(const Common::String &str) {
lua_dostring(str.c_str());
}
diff --git a/engines/grim/grim.h b/engines/grim/grim.h
index 3bd29bd1803..793bd3a8606 100644
--- a/engines/grim/grim.h
+++ b/engines/grim/grim.h
@@ -197,6 +197,10 @@ public:
TextObjectDefaults _sayLineDefaults, _printLineDefaults, _blastTextDefaults;
+ const Common::Point &getOffscreenTextPos() const { return _offscreenTextPos; }
+ void setOffscreenTextPos(const Common::Point &pos) { _offscreenTextPos = pos; }
+ Common::Point getDefaultOffscreenTextPos() const;
+
void debugLua(const Common::String &str);
protected:
@@ -267,6 +271,7 @@ protected:
Actor *_selectedActor;
Iris *_iris;
TextObject::Ptr _movieSubtitle;
+ Common::Point _offscreenTextPos;
bool _buildActiveActorsList;
Common::List<Actor *> _activeActors;
diff --git a/engines/grim/lua_v1_text.cpp b/engines/grim/lua_v1_text.cpp
index c565d82ebc5..645ebc1d86b 100644
--- a/engines/grim/lua_v1_text.cpp
+++ b/engines/grim/lua_v1_text.cpp
@@ -165,8 +165,17 @@ void Lua_V1::BlastText() {
}
void Lua_V1::SetOffscreenTextPos() {
- // called with (0,0) on dialog entry, (nil, nil) on dialog exit
- warning("Lua_V1::SetOffscreenTextPos: implement opcode");
+ // called with (320, 0) on dialog entry, (nil, nil) on dialog exit.
+ // Anything that is not a number selects the default position.
+ lua_Object xObj = lua_getparam(1);
+ lua_Object yObj = lua_getparam(2);
+
+ Common::Point pos = g_grim->getDefaultOffscreenTextPos();
+ if (lua_isnumber(xObj))
+ pos.x = (int)lua_getnumber(xObj);
+ if (lua_isnumber(yObj))
+ pos.y = (int)lua_getnumber(yObj);
+ g_grim->setOffscreenTextPos(pos);
}
void Lua_V1::TextFileGetLine() {
More information about the Scummvm-git-logs
mailing list