mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
TWP: Add moveCursorTo
This commit is contained in:
parent
2c601ad06a
commit
fd3a29faf3
@ -675,4 +675,16 @@ void Jiggle::onUpdate(float elapsed) {
|
||||
_node->setRotationOffset(_amount * sin(_jiggleTime));
|
||||
}
|
||||
|
||||
MoveCursorTo::MoveCursorTo(const Math::Vector2d &pos, float time)
|
||||
: _pos(pos),
|
||||
_tween(g_twp->_cursor.pos, pos, time, intToInterpolationMethod(IK_LINEAR)) {
|
||||
}
|
||||
|
||||
void MoveCursorTo::onUpdate(float elapsed) {
|
||||
_tween.update(elapsed);
|
||||
g_twp->_cursor.pos = _tween.current();
|
||||
if (!_tween.running())
|
||||
disable();
|
||||
}
|
||||
|
||||
} // namespace Twp
|
||||
|
@ -319,6 +319,19 @@ private:
|
||||
float _jiggleTime = 0.f;
|
||||
};
|
||||
|
||||
class MoveCursorTo : public Motor {
|
||||
public:
|
||||
MoveCursorTo(const Math::Vector2d &pos, float time);
|
||||
virtual ~MoveCursorTo() {}
|
||||
|
||||
private:
|
||||
virtual void onUpdate(float elapsed) override;
|
||||
|
||||
private:
|
||||
Tween<Math::Vector2d> _tween;
|
||||
Math::Vector2d _pos;
|
||||
};
|
||||
|
||||
} // namespace Twp
|
||||
|
||||
#endif
|
||||
|
@ -715,8 +715,16 @@ static SQInteger moveCursorTo(HSQUIRRELVM v) {
|
||||
if (SQ_FAILED(sqget(v, 4, t)))
|
||||
return sq_throwerror(v, "Failed to get time");
|
||||
|
||||
g_twp->_cursor.pos = Math::Vector2d(x, y);
|
||||
// TODO: use time
|
||||
Math::Vector2d pos;
|
||||
if (g_twp->_room) {
|
||||
pos = g_twp->roomToScreen(Math::Vector2d(x, y));
|
||||
} else {
|
||||
pos = g_twp->screenToWin(Math::Vector2d(x, y));
|
||||
}
|
||||
pos.setX(CLIP(pos.getX(), 0.f, (float)SCREEN_WIDTH));
|
||||
pos.setY(CLIP(pos.getY(), 0.f, (float)SCREEN_HEIGHT));
|
||||
pos = g_twp->screenToWin(pos);
|
||||
g_twp->_moveCursorTo = Common::ScopedPtr<Motor>(new MoveCursorTo(pos, t));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -455,6 +455,8 @@ void TwpEngine::update(float elapsed) {
|
||||
_noOverride->update(elapsed);
|
||||
if (_talking)
|
||||
_talking->update(elapsed);
|
||||
if (_moveCursorTo)
|
||||
_moveCursorTo->update(elapsed);
|
||||
|
||||
// update mouse pos
|
||||
Math::Vector2d scrPos = winToScreen(_cursor.pos);
|
||||
@ -569,7 +571,7 @@ void TwpEngine::update(float elapsed) {
|
||||
bool isNotInDialog = _dialog->getState() == DialogState::None;
|
||||
for (auto it = threads.begin(); it != threads.end(); it++) {
|
||||
Common::SharedPtr<Thread> thread(*it);
|
||||
if ((isNotInDialog || !thread->isGlobal()) && thread->update(elapsed)) {
|
||||
if ((isNotInDialog || !thread->isGlobal() || !thread->_pauseable) && thread->update(elapsed)) {
|
||||
threadsToRemove.push_back(thread);
|
||||
}
|
||||
}
|
||||
|
@ -267,6 +267,7 @@ public:
|
||||
unique_ptr<HotspotMarkerNode> _hotspotMarker;
|
||||
unique_ptr<FadeShader> _fadeShader;
|
||||
unique_ptr<LightingNode> _lightingNode;
|
||||
unique_ptr<Motor> _moveCursorTo;
|
||||
|
||||
private:
|
||||
Gfx _gfx;
|
||||
|
Loading…
Reference in New Issue
Block a user