From 956f3d46444bc043f9e3153c3dc76d76f6dee7ac Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 29 Sep 2011 19:26:17 -0400 Subject: PEGASUS: Add the auto dragger code --- engines/pegasus/items/autodragger.cpp | 91 +++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 engines/pegasus/items/autodragger.cpp (limited to 'engines/pegasus/items/autodragger.cpp') diff --git a/engines/pegasus/items/autodragger.cpp b/engines/pegasus/items/autodragger.cpp new file mode 100755 index 0000000000..baad699a7e --- /dev/null +++ b/engines/pegasus/items/autodragger.cpp @@ -0,0 +1,91 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * Additional copyright for this file: + * Copyright (C) 1995-1997 Presto Studios, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "pegasus/elements.h" +#include "pegasus/items/autodragger.h" + +namespace Pegasus { + +AutoDragger::AutoDragger() { + _draggingElement = NULL; + _lastTime = 0; + initCallBack(this, kCallBackAtExtremes); +} + +void AutoDragger::autoDrag(DisplayElement *dragElement, const Common::Point &startPoint, const Common::Point &stopPoint, + TimeValue dragTime, TimeScale dragScale) { + _draggingElement = dragElement; + + if (_draggingElement) { + _startLocation = startPoint; + _stopLocation = stopPoint; + _lastTime = 0; + _done = false; + _draggingElement->moveElementTo(_startLocation.x, _startLocation.y); + setScale(dragScale); + setSegment(0, dragTime); + setTime(0); + scheduleCallBack(kTriggerAtStop, 0, 0); + startIdling(); + start(); + } else { + stopDragging(); + } +} + +void AutoDragger::stopDragging() { + cancelCallBack(); + stopIdling(); + _draggingElement = 0; + _startLocation = Common::Point(); + _stopLocation = Common::Point(); + _lastTime = 0; + _done = true; +} + +bool AutoDragger::isDragging() { + return isIdling(); +} + +void AutoDragger::useIdleTime() { + TimeValue thisTime = getTime(); + + if (thisTime != _lastTime) { + uint32 offsetX = (_stopLocation.x - _startLocation.x) * thisTime / getDuration(); + uint32 offsetY = (_stopLocation.y - _startLocation.y) * thisTime / getDuration(); + _draggingElement->moveElementTo(_startLocation.x + offsetX, _startLocation.x + offsetY); + _lastTime = thisTime; + } + + if (_done) + stopDragging(); +} + +void AutoDragger::callBack() { + if (isIdling()) + _done = true; +} + +} // End of namespace Pegasus -- cgit v1.2.3 From 9be43b24ce9d7b4016139ce00b29c891717a12d3 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 30 Sep 2011 12:52:04 -0400 Subject: PEGASUS: Fix auto dragging --- engines/pegasus/items/autodragger.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/pegasus/items/autodragger.cpp') diff --git a/engines/pegasus/items/autodragger.cpp b/engines/pegasus/items/autodragger.cpp index baad699a7e..de03f8118f 100755 --- a/engines/pegasus/items/autodragger.cpp +++ b/engines/pegasus/items/autodragger.cpp @@ -73,9 +73,9 @@ void AutoDragger::useIdleTime() { TimeValue thisTime = getTime(); if (thisTime != _lastTime) { - uint32 offsetX = (_stopLocation.x - _startLocation.x) * thisTime / getDuration(); - uint32 offsetY = (_stopLocation.y - _startLocation.y) * thisTime / getDuration(); - _draggingElement->moveElementTo(_startLocation.x + offsetX, _startLocation.x + offsetY); + int32 offsetX = (_stopLocation.x - _startLocation.x) * (int32)thisTime / (int32)getDuration(); + int32 offsetY = (_stopLocation.y - _startLocation.y) * (int32)thisTime / (int32)getDuration(); + _draggingElement->moveElementTo(_startLocation.x + offsetX, _startLocation.y + offsetY); _lastTime = thisTime; } -- cgit v1.2.3 From 983bd16bb78b1a6aa8872f2086dbcbca6954f2fb Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 3 Apr 2012 15:23:08 -0400 Subject: PEGASUS: Fix file permissions --- engines/pegasus/items/autodragger.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 engines/pegasus/items/autodragger.cpp (limited to 'engines/pegasus/items/autodragger.cpp') diff --git a/engines/pegasus/items/autodragger.cpp b/engines/pegasus/items/autodragger.cpp old mode 100755 new mode 100644 -- cgit v1.2.3