DIRECTOR: LINGO: Implement moveableSprite of sprite

This commit is contained in:
Nathanael Gentry 2020-04-14 20:31:54 -04:00 committed by Eugene Sandulenko
parent d0c4fd90ad
commit f1822511d5
4 changed files with 24 additions and 7 deletions

View File

@ -128,6 +128,7 @@ public:
// events.cpp
void processEvents();
void setDraggedSprite(uint16 id);
void releaseDraggedSprite();
uint32 getMacTicks();
void waitForClick();

View File

@ -80,6 +80,19 @@ void DirectorEngine::processEvents() {
case Common::EVENT_MOUSEMOVE:
sc->_lastEventTime = g_director->getMacTicks();
sc->_lastRollTime = sc->_lastEventTime;
if (_draggingSprite) {
Sprite* draggedSprite = currentFrame->_sprites[_draggingSpriteId];
if (draggedSprite->_moveable) {
pos = g_system->getEventManager()->getMousePos();
Common::Point delta = pos - _draggingSpritePos;
draggedSprite->_currentPoint.x += delta.x;
draggedSprite->_currentPoint.y += delta.y;
_draggingSpritePos = pos;
} else {
releaseDraggedSprite();
}
}
break;
case Common::EVENT_LBUTTONDOWN:
@ -97,9 +110,9 @@ void DirectorEngine::processEvents() {
debugC(3, kDebugEvents, "event: Button Down @(%d, %d), sprite id: %d", pos.x, pos.y, spriteId);
_lingo->processEvent(kEventMouseDown);
if (currentFrame->_sprites[spriteId]->_moveable) {
warning("Moveable");
}
if (currentFrame->_sprites[spriteId]->_moveable)
g_director->setDraggedSprite(spriteId);
break;
case Common::EVENT_LBUTTONUP:
@ -110,6 +123,7 @@ void DirectorEngine::processEvents() {
debugC(3, kDebugEvents, "event: Button Up @(%d, %d), sprite id: %d", pos.x, pos.y, spriteId);
sc->_mouseIsDown = false;
releaseDraggedSprite();
_lingo->processEvent(kEventMouseUp);
sc->_currentMouseDownSpriteId = 0;
@ -158,8 +172,11 @@ void DirectorEngine::setDraggedSprite(uint16 id) {
_draggingSprite = true;
_draggingSpriteId = id;
_draggingSpritePos = g_system->getEventManager()->getMousePos();
}
warning("STUB: DirectorEngine::setDraggedSprite(%d)", id);
void DirectorEngine::releaseDraggedSprite() {
_draggingSprite = false;
_draggingSpriteId = 0;
}
void DirectorEngine::waitForClick() {

View File

@ -1445,10 +1445,7 @@ void LB::b_move(int nargs) {
void LB::b_moveableSprite(int nargs) {
Frame *frame = g_director->getCurrentScore()->_frames[g_director->getCurrentScore()->getCurrentFrame()];
// Will have no effect
frame->_sprites[g_lingo->_currentEntityId]->_moveable = true;
g_director->setDraggedSprite(frame->_sprites[g_lingo->_currentEntityId]->_castId);
}
void LB::b_pasteClipBoardInto(int nargs) {

View File

@ -677,6 +677,8 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
break;
case kTheMoveableSprite:
sprite->_moveable = d.u.i;
if (!d.u.i)
sprite->_currentPoint = sprite->_startPoint;
break;
case kTheMovieRate:
sprite->_movieRate = d.u.i;