[Scummvm-git-logs] scummvm master -> 503e369c9f7935f5a81ebb74f4517b4d24a6fa56

scemino noreply at scummvm.org
Thu Apr 25 20:41:24 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:
bc401d0cbb TWP: Allow to select choice with UP/DOWN keys
aa5bef7e34 TWP: Fix skip text
986a18dcbd TWP: Use talk speed options during talking
6a38a1fa62 TWP: Add verb shake
503e369c9f TWP: Dialog choice shoud be selectable from the whole line


Commit: bc401d0cbbf58e629a8b24f51c4df7d8e9a97655
    https://github.com/scummvm/scummvm/commit/bc401d0cbbf58e629a8b24f51c4df7d8e9a97655
Author: scemino (scemino74 at gmail.com)
Date: 2024-04-25T22:41:13+02:00

Commit Message:
TWP: Allow to select choice with UP/DOWN keys

Changed paths:
    engines/twp/dialog.cpp
    engines/twp/dialog.h
    engines/twp/rectf.h
    engines/twp/twp.cpp
    engines/twp/twp.h


diff --git a/engines/twp/dialog.cpp b/engines/twp/dialog.cpp
index 0643fdd042f..847ad640ee9 100644
--- a/engines/twp/dialog.cpp
+++ b/engines/twp/dialog.cpp
@@ -517,4 +517,50 @@ void Dialog::drawCore(const Math::Matrix4 &trsf) {
 	}
 }
 
+int Dialog::getActiveSlot(const Math::Vector2d &pos) const {
+	int index = -1;
+	int num = 0;
+	for (int i = 0; i < MAXDIALOGSLOTS; i++) {
+		const DialogSlot *slot = &_slots[i];
+		if (!slot->_isValid)
+			continue;
+		const Math::Vector2d p = slot->getPos();
+		const Math::Vector2d s = slot->getSize();
+		const Rectf r(p.getX(), p.getY() + s.getY() / 2.f, s.getX(), s.getY());
+		if (r.contains(pos)) {
+			index = num;
+		}
+		num++;
+	}
+	return index;
+}
+
+Math::Vector2d Dialog::getChoicePos(int index) const {
+	int n = 0;
+	for (int i = 0; i < MAXDIALOGSLOTS; i++) {
+		const DialogSlot *slot = &_slots[i];
+		if (!slot->_isValid)
+			continue;
+		if (n == index) {
+			Math::Vector2d p(slot->getPos());
+			Math::Vector2d s(slot->getSize());
+			return Math::Vector2d(p.getX() + s.getX() / 2.f, p.getY() + s.getY() + 8.f);
+		}
+		n++;
+	}
+	return Math::Vector2d();
+}
+
+Math::Vector2d Dialog::getNextChoicePos(const Math::Vector2d &pos) {
+	int index = getActiveSlot(pos);
+	index = MIN(index + 1, numSlots() - 1);
+	return getChoicePos(index);
+}
+
+Math::Vector2d Dialog::getPreviousChoicePos(const Math::Vector2d &pos) {
+	int index = getActiveSlot(pos);
+	index = MAX(index - 1, 0);
+	return getChoicePos(index);
+}
+
 } // namespace Twp
diff --git a/engines/twp/dialog.h b/engines/twp/dialog.h
index ed17308ba74..5e28185f79c 100644
--- a/engines/twp/dialog.h
+++ b/engines/twp/dialog.h
@@ -195,6 +195,8 @@ public:
 	DialogState getState() const { return _state; }
 
 	void setMousePos(const Math::Vector2d &pos) { _mousePos = pos; }
+	Math::Vector2d getNextChoicePos(const Math::Vector2d &pos);
+	Math::Vector2d getPreviousChoicePos(const Math::Vector2d &pos);
 
 	void start(const Common::String &actor, const Common::String &name, const Common::String &node);
 	void selectLabel(int line, const Common::String &name);
@@ -218,6 +220,9 @@ private:
 	int numSlots() const;
 	void clearSlots();
 
+	Math::Vector2d getChoicePos(int index) const;
+	int getActiveSlot(const Math::Vector2d &pos) const;
+
 	virtual void drawCore(const Math::Matrix4 &trsf) override final;
 
 public:
diff --git a/engines/twp/rectf.h b/engines/twp/rectf.h
index 9337ebca9d1..06ffb5f1402 100644
--- a/engines/twp/rectf.h
+++ b/engines/twp/rectf.h
@@ -47,12 +47,12 @@ public:
 		} r;
 	};
 
-	inline float left() { return r.x; }
-	inline float right() { return r.x + r.w; }
-	inline float top() { return r.y + r.h; }
-	inline float bottom() { return r.y; }
+	inline float left() const { return r.x; }
+	inline float right() const { return r.x + r.w; }
+	inline float top() const { return r.y + r.h; }
+	inline float bottom() const { return r.y; }
 
-	bool contains(const Math::Vector2d &pos) {
+	bool contains(const Math::Vector2d &pos) const {
 		return pos.getX() >= r.x && pos.getX() <= (r.x + r.w) && pos.getY() >= r.y && pos.getY() <= r.y + r.h;
 	}
 };
diff --git a/engines/twp/twp.cpp b/engines/twp/twp.cpp
index 24acada2e9a..07590ec035e 100644
--- a/engines/twp/twp.cpp
+++ b/engines/twp/twp.cpp
@@ -105,16 +105,20 @@ TwpEngine::~TwpEngine() {
 	_mixer->stopAll();
 }
 
-Math::Vector2d TwpEngine::winToScreen(const Math::Vector2d &pos) {
+Math::Vector2d TwpEngine::winToScreen(const Math::Vector2d &pos) const {
 	return Math::Vector2d(pos.getX(), SCREEN_HEIGHT - pos.getY());
 }
 
-Math::Vector2d TwpEngine::roomToScreen(const Math::Vector2d &pos) {
+Math::Vector2d TwpEngine::screenToWin(const Math::Vector2d &pos) const {
+	return Math::Vector2d(pos.getX(), SCREEN_HEIGHT - pos.getY());
+}
+
+Math::Vector2d TwpEngine::roomToScreen(const Math::Vector2d &pos) const {
 	Math::Vector2d screenSize = _room->getScreenSize();
 	return Math::Vector2d(SCREEN_WIDTH, SCREEN_HEIGHT) * (pos - _gfx.cameraPos()) / screenSize;
 }
 
-Math::Vector2d TwpEngine::screenToRoom(const Math::Vector2d &pos) {
+Math::Vector2d TwpEngine::screenToRoom(const Math::Vector2d &pos) const {
 	Math::Vector2d screenSize = _room->getScreenSize();
 	return (pos * screenSize) / Math::Vector2d(SCREEN_WIDTH, SCREEN_HEIGHT) + _gfx.cameraPos();
 }
@@ -966,26 +970,34 @@ Common::Error TwpEngine::run() {
 					setVerbAction(1 + (int)e.customType - (int)TwpAction::kOpen);
 					break;
 				default:
-				break;
+					break;
 				}
 			} break;
 			case Common::EVENT_KEYDOWN:
 				switch (e.kbd.keycode) {
 				case Common::KEYCODE_LEFT:
-					if(_control)
+					if (_control)
 						_speed = MAX(_speed - 1, 1);
 					_cursor.holdLeft = true;
 					break;
 				case Common::KEYCODE_RIGHT:
-					if(_control)
+					if (_control)
 						_speed = MIN(_speed + 1, 8);
 					_cursor.holdRight = true;
 					break;
 				case Common::KEYCODE_UP:
-					_cursor.holdUp = true;
+					if (_dialog->getState() == WaitingForChoice) {
+						_cursor.pos = screenToWin(_dialog->getPreviousChoicePos(winToScreen(_cursor.pos)));
+					} else {
+						_cursor.holdUp = true;
+					}
 					break;
 				case Common::KEYCODE_DOWN:
-					_cursor.holdDown = true;
+					if (_dialog->getState() == WaitingForChoice) {
+						_cursor.pos = screenToWin(_dialog->getNextChoicePos(winToScreen(_cursor.pos)));
+					} else {
+						_cursor.holdDown = true;
+					}
 					break;
 				case Common::KEYCODE_LCTRL:
 					_control = true;
@@ -1069,16 +1081,16 @@ Common::Error TwpEngine::run() {
 		}
 
 		const float mouseMoveSpeed = 4.f;
-		if(_cursor.holdLeft) {
+		if (_cursor.holdLeft) {
 			_cursor.pos.setX(MAX(_cursor.pos.getX() - mouseMoveSpeed, 0.f));
 		}
-		if(_cursor.holdRight) {
+		if (_cursor.holdRight) {
 			_cursor.pos.setX(MIN(_cursor.pos.getX() + mouseMoveSpeed, (float)SCREEN_WIDTH));
 		}
-		if(_cursor.holdUp) {
+		if (_cursor.holdUp) {
 			_cursor.pos.setY(MAX(_cursor.pos.getY() - mouseMoveSpeed, 0.f));
 		}
-		if(_cursor.holdDown) {
+		if (_cursor.holdDown) {
 			_cursor.pos.setY(MIN(_cursor.pos.getY() + mouseMoveSpeed, (float)SCREEN_HEIGHT));
 		}
 
diff --git a/engines/twp/twp.h b/engines/twp/twp.h
index 798fc5095cc..4e73439ad53 100644
--- a/engines/twp/twp.h
+++ b/engines/twp/twp.h
@@ -132,9 +132,10 @@ public:
 	bool canSaveAutosaveCurrently() override { return false; }
 	void capture(Graphics::Surface &surface, int width, int height);
 
-	Math::Vector2d winToScreen(const Math::Vector2d &pos);
-	Math::Vector2d roomToScreen(const Math::Vector2d &pos);
-	Math::Vector2d screenToRoom(const Math::Vector2d &pos);
+	Math::Vector2d winToScreen(const Math::Vector2d &pos) const;
+	Math::Vector2d screenToWin(const Math::Vector2d &pos) const;
+	Math::Vector2d roomToScreen(const Math::Vector2d &pos) const;
+	Math::Vector2d screenToRoom(const Math::Vector2d &pos) const;
 
 	void setActor(Common::SharedPtr<Object> actor, bool userSelected = false);
 	Common::SharedPtr<Object> objAt(const Math::Vector2d &pos);


Commit: aa5bef7e340b567560bc43c82a19d25120a69e80
    https://github.com/scummvm/scummvm/commit/aa5bef7e340b567560bc43c82a19d25120a69e80
Author: scemino (scemino74 at gmail.com)
Date: 2024-04-25T22:41:13+02:00

Commit Message:
TWP: Fix skip text

Changed paths:
    engines/twp/metaengine.cpp


diff --git a/engines/twp/metaengine.cpp b/engines/twp/metaengine.cpp
index 29571a6debe..d2b233def7f 100644
--- a/engines/twp/metaengine.cpp
+++ b/engines/twp/metaengine.cpp
@@ -167,7 +167,7 @@ Common::Array<Common::Keymap *> TwpMetaEngine::initKeymaps(const char *target) c
 		{"SELECTCHOICE6", _s("Select Choice 6"), Twp::kSelectChoice6, "6", Common::EVENT_INVALID, Common::KEYCODE_INVALID},
 		{"SELECTNEXTACTOR", _s("Select Next Actor"), Twp::kSelectNextActor, "0", Common::EVENT_INVALID, Common::KEYCODE_INVALID},
 		{"SELECTPREVACTOR", _s("Select Previous Actor"), Twp::kSelectPreviousActor, "9", Common::EVENT_INVALID, Common::KEYCODE_INVALID},
-		{"SKIPTEXT", _s("Skip Text"), Twp::kSkipText, "MOUSE_MIDDLE|PERIOD", Common::EVENT_MBUTTONDOWN, Common::KEYCODE_INVALID},
+		{"SKIPTEXT", _s("Skip Text"), Twp::kSkipText, "MOUSE_MIDDLE|PERIOD", Common::EVENT_INVALID, Common::KEYCODE_INVALID},
 		{"SHOWHOTSPOTS", _s("Show hotspots"), Twp::kShowHotspots, "TAB", Common::EVENT_INVALID, Common::KEYCODE_INVALID},
 		{"OPEN", _s("Open"), Twp::kOpen, "q", Common::EVENT_INVALID, Common::KEYCODE_INVALID},
 		{"CLOSE", _s("Close"), Twp::kClose, "a", Common::EVENT_INVALID, Common::KEYCODE_INVALID},


Commit: 986a18dcbd4fa4114c6df8b8d797098150780d53
    https://github.com/scummvm/scummvm/commit/986a18dcbd4fa4114c6df8b8d797098150780d53
Author: scemino (scemino74 at gmail.com)
Date: 2024-04-25T22:41:13+02:00

Commit Message:
TWP: Use talk speed options during talking

Changed paths:
    engines/twp/motor.cpp
    engines/twp/motor.h


diff --git a/engines/twp/motor.cpp b/engines/twp/motor.cpp
index dfd9c852fc3..9883cf20508 100644
--- a/engines/twp/motor.cpp
+++ b/engines/twp/motor.cpp
@@ -371,6 +371,10 @@ void TalkingBase::setDuration(const Common::String &text) {
 	_duration = MAX(duration, sayLineMinTime);
 }
 
+float TalkingBase::getTalkSpeed() const {
+	return _actor->_sound ? 1.f : (ConfMan.getInt("talkspeed") + 1) / 60.f;
+}
+
 Talking::Talking(Common::SharedPtr<Object> obj, const Common::StringArray &texts, const Color &color) : TalkingBase(obj, 0.f) {
 	_color = color;
 	_texts.assign(texts.begin() + 1, texts.end());
@@ -412,7 +416,7 @@ void Talking::onUpdate(float elapsed) {
 	if (!isEnabled())
 		return;
 
-	_elapsed += elapsed;
+	_elapsed += elapsed * getTalkSpeed();
 	if (_actor->_sound) {
 		if (!g_twp->_audio->playing(_actor->_sound)) {
 			debugC(kDebugGame, "talking %s audio stopped", _actor->_key.c_str());
@@ -644,7 +648,7 @@ void SayLineAt::onUpdate(float elapsed) {
 	if (!isEnabled())
 		return;
 
-	_elapsed += elapsed;
+	_elapsed += elapsed * getTalkSpeed();
 	if (_actor && _actor->_sound) {
 		if (!g_twp->_audio->playing(_actor->_sound)) {
 			debugC(kDebugGame, "talking %s audio stopped", _actor->_key.c_str());
diff --git a/engines/twp/motor.h b/engines/twp/motor.h
index 93f1e2cd0f0..a305001a9d1 100644
--- a/engines/twp/motor.h
+++ b/engines/twp/motor.h
@@ -258,6 +258,7 @@ protected:
 	int onTalkieId(int id);
 	int loadActorSpeech(const Common::String &name);
 	void setDuration(const Common::String &text);
+	float getTalkSpeed() const;
 
 protected:
 	Common::SharedPtr<Object> _actor;


Commit: 6a38a1fa62a89551d2b287e233c668a46d7fe8f2
    https://github.com/scummvm/scummvm/commit/6a38a1fa62a89551d2b287e233c668a46d7fe8f2
Author: scemino (scemino74 at gmail.com)
Date: 2024-04-25T22:41:13+02:00

Commit Message:
TWP: Add verb shake

Changed paths:
    engines/twp/genlib.cpp
    engines/twp/hud.cpp
    engines/twp/hud.h
    engines/twp/objlib.cpp
    engines/twp/twp.cpp


diff --git a/engines/twp/genlib.cpp b/engines/twp/genlib.cpp
index 0c78c61ce42..c554a76b05d 100644
--- a/engines/twp/genlib.cpp
+++ b/engines/twp/genlib.cpp
@@ -312,7 +312,7 @@ static SQInteger findScreenPosition(HSQUIRRELVM v) {
 		if (!actorSlot)
 			return 0;
 		for (int i = 1; i < MAX_VERBS; i++) {
-			Verb vb = actorSlot->verbs[i];
+			const Verb &vb = actorSlot->verbSlots[i]._verb;
 			if (vb.id.id == verb) {
 				SpriteSheet *verbSheet = g_twp->_resManager->spriteSheet("VerbSheet");
 				const SpriteSheetFrame *verbFrame = &verbSheet->getFrame(Common::String::format("%s_en", vb.image.c_str()));
@@ -763,7 +763,7 @@ static SQInteger setVerb(HSQUIRRELVM v) {
 	debugC(kDebugGenScript, "setVerb %lld, %lld, %lld, %s", actorSlot, verbSlot, id, text.c_str());
 	VerbId verbId;
 	verbId.id = id;
-	g_twp->_hud->_actorSlots[actorSlot - 1].verbs[verbSlot] = Verb(verbId, image, fun, text, key, flags);
+	g_twp->_hud->_actorSlots[actorSlot - 1].verbSlots[verbSlot]._verb = Verb(verbId, image, fun, text, key, flags);
 	return 0;
 }
 
diff --git a/engines/twp/hud.cpp b/engines/twp/hud.cpp
index 87c52e417ab..2a8fa8b9ab6 100644
--- a/engines/twp/hud.cpp
+++ b/engines/twp/hud.cpp
@@ -21,11 +21,31 @@
 
 #include "common/config-manager.h"
 #include "twp/twp.h"
+#include "twp/motor.h"
 #include "twp/hud.h"
 #include "twp/resmanager.h"
 
 namespace Twp {
 
+class ShakeVerb : public Motor {
+public:
+	virtual ~ShakeVerb() {}
+	ShakeVerb(VerbSlot *slot, float amount) : _slot(slot), _amount(amount) {}
+
+private:
+	virtual void onUpdate(float elapsed) override {
+		_shakeTime += 40.f * elapsed;
+		_elapsed += elapsed;
+		_slot->_shakeOffset = Math::Vector2d(_amount * cos(_shakeTime + 0.3f), _amount * sin(_shakeTime));
+	}
+
+private:
+	VerbSlot *_slot = nullptr;
+	float _amount = 0.f;
+	float _shakeTime = 0.f;
+	float _elapsed = 0.f;
+};
+
 Verb::Verb() = default;
 
 Verb::Verb(VerbId verbId, const Common::String &img, const Common::String &f, const Common::String &t, const Common::String &k, int fl)
@@ -175,22 +195,17 @@ void Hud::drawCore(const Math::Matrix4 &trsf) {
 	_shader._normalColor = slot->verbUiColors.verbHighlight;
 	_shader._highlightColor = slot->verbUiColors.verbHighlightTint;
 
-	bool isOver = false;
 	for (int i = 1; i < MAX_VERBS; i++) {
-		const Verb &verb = slot->verbs[i];
-		if (verb.image.size() > 0) {
-			const SpriteSheetFrame &verbFrame = verbSheet->getFrame(Common::String::format("%s%s_%s", verb.image.c_str(), verbSuffix.c_str(), lang.c_str()));
-			bool over = verbFrame.spriteSourceSize.contains(_mousePos.getX(), _mousePos.getY());
-			isOver |= over;
-			Color color = (over || (verb.id.id == _defaultVerbId)) ? verbHighlight : verbColor;
-			if (_mouseClick && over) {
-				selectVerb(verb);
-			}
-			drawSprite(verbFrame, verbTexture, Color::withAlpha(color, getAlpha()), trsf);
+		const VerbSlot &verbSlot = slot->verbSlots[i];
+		if (verbSlot._verb.image.size() > 0) {
+			const SpriteSheetFrame &verbFrame = verbSheet->getFrame(Common::String::format("%s%s_%s", verbSlot._verb.image.c_str(), verbSuffix.c_str(), lang.c_str()));
+			Color color = (verbSlot._over || (verbSlot._verb.id.id == _defaultVerbId)) ? verbHighlight : verbColor;
+			Math::Matrix4 t(trsf);
+			t.translate(Math::Vector3d(verbSlot._shakeOffset.getX(), verbSlot._shakeOffset.getY(), 0.f));
+			drawSprite(verbFrame, verbTexture, Color::withAlpha(color, getAlpha()), t);
 		}
 	}
 	g_twp->getGfx().use(saveShader);
-	_over = isOver;
 }
 
 void Hud::update(float elapsed, const Math::Vector2d &pos, Common::SharedPtr<Object> hotspot, bool mouseClick) {
@@ -210,6 +225,42 @@ void Hud::update(float elapsed, const Math::Vector2d &pos, Common::SharedPtr<Obj
 		float alpha = MIN(_fadeTime, 2.0f) / 2.0f;
 		setAlpha(alpha);
 	}
+
+	ActorSlot *slot = actorSlot(_actor);
+	if (!slot)
+		return;
+
+	bool retroVerbs = ConfMan.getBool("retroVerbs");
+	Common::String lang = ConfMan.get("language");
+	Common::String verbSuffix = retroVerbs ? "_retro" : "";
+	SpriteSheet *verbSheet = g_twp->_resManager->spriteSheet("VerbSheet");
+	bool isOver = false;
+	for (int i = 1; i < MAX_VERBS; i++) {
+		VerbSlot &verbSlot = slot->verbSlots[i];
+		if (verbSlot._verb.image.size() > 0) {
+			const SpriteSheetFrame &verbFrame = verbSheet->getFrame(Common::String::format("%s%s_%s", verbSlot._verb.image.c_str(), verbSuffix.c_str(), lang.c_str()));
+			bool over = verbFrame.spriteSourceSize.contains(_mousePos.getX(), _mousePos.getY());
+			// shake choice when cursor is over
+			if ((verbSlot._shakeTime > 0.0f) && verbSlot._shake) {
+				verbSlot._shake->update(elapsed);
+				verbSlot._shakeTime -= elapsed;
+				if (verbSlot._shakeTime < 0.f) {
+					verbSlot._shakeTime = 0.f;
+				}
+			}
+			if (over && !verbSlot._over && verbSlot._shakeTime < 0.1f) {
+				verbSlot._shakeTime = 0.25f;
+				verbSlot._shake = Common::ScopedPtr<Motor>(new ShakeVerb(&verbSlot, 1.2f));
+				verbSlot._over = over;
+			}
+			verbSlot._over = over;
+			isOver |= over;
+			if (_mouseClick && over) {
+				selectVerb(verbSlot._verb);
+			}
+		}
+	}
+	_over = isOver;
 }
 
 void Hud::setVisible(bool visible) {
diff --git a/engines/twp/hud.h b/engines/twp/hud.h
index 5c8c28186b6..a8ffaa46675 100644
--- a/engines/twp/hud.h
+++ b/engines/twp/hud.h
@@ -60,10 +60,21 @@ struct Verb {
 	Verb(VerbId id, const Common::String &image, const Common::String &fun, const Common::String &text, const Common::String &key, int flags = 0);
 };
 
+struct VerbSlot {
+	Verb _verb;
+	float _shakeTime = 0.f;
+	Common::ScopedPtr<Motor> _shake;
+	Math::Vector2d _shakeOffset;
+	bool _over = false;
+
+	VerbSlot() {}
+	VerbSlot(Verb verb) : _verb(verb) {}
+};
+
 struct ActorSlot {
 public:
 	VerbUiColors verbUiColors;
-	Verb verbs[MAX_VERBS];
+	VerbSlot verbSlots[MAX_VERBS];
 	bool selectable = false;
 	Common::SharedPtr<Object> actor;
 
@@ -71,9 +82,9 @@ public:
 	ActorSlot();
 
 	Verb *getVerb(int id) {
-		for (auto &verb : verbs) {
-			if (verb.id.id == id) {
-				return &verb;
+		for (auto &verbSlot : verbSlots) {
+			if (verbSlot._verb.id.id == id) {
+				return &verbSlot._verb;
 			}
 		}
 		return nullptr;
diff --git a/engines/twp/objlib.cpp b/engines/twp/objlib.cpp
index fac645ea3f6..8a834ef4707 100644
--- a/engines/twp/objlib.cpp
+++ b/engines/twp/objlib.cpp
@@ -898,7 +898,7 @@ static SQInteger objectValidVerb(HSQUIRRELVM v) {
 	if (g_twp->_actor) {
 		ActorSlot *slot = g_twp->_hud->actorSlot(g_twp->_actor);
 		for (int i = 0; i < MAX_VERBS; i++) {
-			Verb *vb = &slot->verbs[i];
+			const Verb *vb = &slot->verbSlots[i]._verb;
 			if (vb->id.id == verb) {
 				if (sqrawexists(obj->_table, vb->fun)) {
 					sqpush(v, true);
diff --git a/engines/twp/twp.cpp b/engines/twp/twp.cpp
index 07590ec035e..157b202cf89 100644
--- a/engines/twp/twp.cpp
+++ b/engines/twp/twp.cpp
@@ -259,7 +259,7 @@ void TwpEngine::clickedAt(const Math::Vector2d &scrPos) {
 				cancelSentence(_actor);
 				if (_actor->_room == _room)
 					Object::walk(_actor, roomPos);
-				_hud->selectVerb(_hud->actorSlot(_actor)->verbs[0]);
+				_hud->selectVerb(_hud->actorSlot(_actor)->verbSlots[0]._verb);
 				_holdToMove = true;
 			}
 
@@ -804,7 +804,7 @@ static void setVerbAction(int verbSlot) {
 	ActorSlot *slot = g_twp->_hud->actorSlot(g_twp->_actor);
 	if (!slot)
 		return;
-	g_twp->_hud->selectVerb(slot->verbs[verbSlot]);
+	g_twp->_hud->selectVerb(slot->verbSlots[verbSlot]._verb);
 }
 
 Common::Error TwpEngine::run() {
@@ -1377,7 +1377,7 @@ void TwpEngine::enterRoom(Common::SharedPtr<Room> room, Common::SharedPtr<Object
 	_room->setOverlay(Color(0.f, 0.f, 0.f, 0.f));
 	_camera->setBounds(Rectf::fromMinMax(Math::Vector2d(), _room->_roomSize));
 	if (_actor && _hud->actorSlot(_actor))
-		_hud->selectVerb(_hud->actorSlot(_actor)->verbs[0]);
+		_hud->selectVerb(_hud->actorSlot(_actor)->verbSlots[0]._verb);
 
 	// move current actor to the new room
 	Math::Vector2d camPos;
@@ -1663,7 +1663,7 @@ void TwpEngine::resetVerb() {
 	_noun1 = nullptr;
 	_noun2 = nullptr;
 	_useFlag = UseFlag::ufNone;
-	_hud->_verb = _hud->actorSlot(_actor)->verbs[0];
+	_hud->_verb = _hud->actorSlot(_actor)->verbSlots[0]._verb;
 }
 
 bool TwpEngine::callVerb(Common::SharedPtr<Object> actor, VerbId verbId, Common::SharedPtr<Object> noun1, Common::SharedPtr<Object> noun2) {
@@ -1677,7 +1677,7 @@ bool TwpEngine::callVerb(Common::SharedPtr<Object> actor, VerbId verbId, Common:
 	Common::String noun2name = !noun2 ? "null" : noun2->_key;
 	ActorSlot *slot = _hud->actorSlot(actor);
 	Verb *verb = slot->getVerb(verbId.id);
-	Common::String verbFuncName = verb ? verb->fun : slot->verbs[0].fun;
+	Common::String verbFuncName = verb ? verb->fun : slot->verbSlots[0]._verb.fun;
 	debugC(kDebugGame, "callVerb(%s,%s,%s,%s)", name.c_str(), verbFuncName.c_str(), noun1name.c_str(), noun2name.c_str());
 
 	// test if object became untouchable


Commit: 503e369c9f7935f5a81ebb74f4517b4d24a6fa56
    https://github.com/scummvm/scummvm/commit/503e369c9f7935f5a81ebb74f4517b4d24a6fa56
Author: scemino (scemino74 at gmail.com)
Date: 2024-04-25T22:41:13+02:00

Commit Message:
TWP: Dialog choice shoud be selectable from the whole line

Changed paths:
    engines/twp/dialog.cpp


diff --git a/engines/twp/dialog.cpp b/engines/twp/dialog.cpp
index 847ad640ee9..f5ba74b1bcc 100644
--- a/engines/twp/dialog.cpp
+++ b/engines/twp/dialog.cpp
@@ -246,7 +246,7 @@ void Dialog::update(float dt) {
 		for (size_t i = 0; i < MAXDIALOGSLOTS; i++) {
 			DialogSlot *slot = &_slots[i];
 			if (slot->_isValid) {
-				Rectf rect = Rectf::fromPosAndSize(slot->getPos() - Math::Vector2d(0.f, -slot->getSize().getY() / 2.f), slot->getSize());
+				Rectf rect = Rectf::fromPosAndSize(slot->getPos() - Math::Vector2d(0.f, -slot->getSize().getY() / 2.f), Math::Vector2d(SCREEN_WIDTH - SLOTMARGIN, slot->getSize().getY()));
 				bool over = rect.contains(_mousePos);
 				// shake choice when cursor is over
 				if ((slot->_shakeTime > 0.0f) && slot->_shake) {
@@ -265,12 +265,13 @@ void Dialog::update(float dt) {
 					slot->_over = false;
 				}
 				// slide choice text wen text is too large
-				if (rect.r.w > (SCREEN_WIDTH - SLOTMARGIN)) {
+				const float width = slot->getSize().getX();
+				if (width > (SCREEN_WIDTH - SLOTMARGIN)) {
 					if (over) {
-						if ((rect.r.w + slot->getPos().getX()) > (SCREEN_WIDTH - SLOTMARGIN)) {
+						if ((width + slot->getPos().getX()) > (SCREEN_WIDTH - SLOTMARGIN)) {
 							slot->setPos(Math::Vector2d(slot->getPos().getX() - SLIDINGSPEED * dt, slot->getPos().getY()));
-							if ((rect.r.w + slot->getPos().getX()) < (SCREEN_WIDTH - SLOTMARGIN)) {
-								slot->setPos(Math::Vector2d((SCREEN_WIDTH - SLOTMARGIN) - rect.r.w, slot->getPos().getY()));
+							if ((width + slot->getPos().getX()) < (SCREEN_WIDTH - SLOTMARGIN)) {
+								slot->setPos(Math::Vector2d((SCREEN_WIDTH - SLOTMARGIN) - width, slot->getPos().getY()));
 							}
 						}
 					} else if (slot->getPos().getX() < SLOTMARGIN) {




More information about the Scummvm-git-logs mailing list