2013-08-24 01:47:12 -05:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
2016-09-03 12:46:38 +02:00
|
|
|
*
|
2013-08-24 01:47:12 -05:00
|
|
|
* 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.
|
2016-09-03 12:46:38 +02:00
|
|
|
*
|
2013-08-24 01:47:12 -05:00
|
|
|
* 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 "common/scummsys.h"
|
|
|
|
|
2014-06-14 15:18:24 +07:00
|
|
|
#include "zvision/scripting/controls/lever_control.h"
|
2013-10-01 20:08:41 -05:00
|
|
|
|
2013-08-24 01:47:12 -05:00
|
|
|
#include "zvision/zvision.h"
|
2014-06-14 15:18:24 +07:00
|
|
|
#include "zvision/scripting/script_manager.h"
|
|
|
|
#include "zvision/graphics/render_manager.h"
|
2014-12-16 01:00:50 +02:00
|
|
|
#include "zvision/graphics/cursors/cursor_manager.h"
|
2013-08-24 01:47:12 -05:00
|
|
|
|
2013-10-01 20:08:41 -05:00
|
|
|
#include "common/stream.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/tokenizer.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "graphics/surface.h"
|
2014-12-16 00:48:16 +02:00
|
|
|
#include "video/video_decoder.h"
|
2013-10-01 20:08:41 -05:00
|
|
|
|
2013-08-24 01:47:12 -05:00
|
|
|
namespace ZVision {
|
|
|
|
|
|
|
|
LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
|
2014-07-12 21:35:50 +00:00
|
|
|
: Control(engine, key, CONTROL_LEVER),
|
2013-10-20 18:39:06 +00:00
|
|
|
_frameInfo(0),
|
|
|
|
_frameCount(0),
|
|
|
|
_startFrame(0),
|
|
|
|
_currentFrame(0),
|
|
|
|
_lastRenderedFrame(0),
|
|
|
|
_mouseIsCaptured(false),
|
|
|
|
_isReturning(false),
|
|
|
|
_accumulatedTime(0),
|
2014-12-19 15:37:33 +06:00
|
|
|
_returnRoutesCurrentFrame(0),
|
|
|
|
_animation(NULL),
|
|
|
|
_cursor(CursorIndex_Active),
|
|
|
|
_mirrored(false) {
|
2013-08-24 01:47:12 -05:00
|
|
|
|
|
|
|
// Loop until we find the closing brace
|
|
|
|
Common::String line = stream.readLine();
|
2014-12-16 01:58:05 +02:00
|
|
|
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
|
2013-08-24 01:47:12 -05:00
|
|
|
|
2014-11-12 16:05:48 +06:00
|
|
|
Common::String param;
|
|
|
|
Common::String values;
|
|
|
|
getParams(line, param, values);
|
|
|
|
|
2013-08-24 01:47:12 -05:00
|
|
|
while (!stream.eos() && !line.contains('}')) {
|
2014-11-12 16:05:48 +06:00
|
|
|
if (param.matchString("descfile", true)) {
|
2013-08-24 01:47:12 -05:00
|
|
|
char levFileName[25];
|
2014-12-23 02:20:17 +02:00
|
|
|
sscanf(values.c_str(), "%24s", levFileName);
|
2013-08-24 01:47:12 -05:00
|
|
|
|
|
|
|
parseLevFile(levFileName);
|
2014-11-12 16:05:48 +06:00
|
|
|
} else if (param.matchString("cursor", true)) {
|
2013-08-24 01:47:12 -05:00
|
|
|
char cursorName[25];
|
2014-12-23 02:20:17 +02:00
|
|
|
sscanf(values.c_str(), "%24s", cursorName);
|
2013-08-24 01:47:12 -05:00
|
|
|
|
2014-11-12 16:05:48 +06:00
|
|
|
_cursor = _engine->getCursorManager()->getCursorId(Common::String(cursorName));
|
2013-08-24 01:47:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
line = stream.readLine();
|
2014-12-16 01:58:05 +02:00
|
|
|
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
|
2014-11-12 16:05:48 +06:00
|
|
|
getParams(line, param, values);
|
2013-08-24 01:47:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
renderFrame(_currentFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
LeverControl::~LeverControl() {
|
2014-01-17 16:56:49 +07:00
|
|
|
if (_animation)
|
|
|
|
delete _animation;
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2013-08-29 02:06:24 -05:00
|
|
|
delete[] _frameInfo;
|
2013-08-24 01:47:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void LeverControl::parseLevFile(const Common::String &fileName) {
|
|
|
|
Common::File file;
|
2014-02-04 08:32:02 +07:00
|
|
|
if (!_engine->getSearchManager()->openFile(file, fileName)) {
|
2013-08-24 01:47:12 -05:00
|
|
|
warning("LEV file %s could could be opened", fileName.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:07:52 +07:00
|
|
|
Common::String line;
|
2014-11-12 16:05:48 +06:00
|
|
|
Common::String param;
|
|
|
|
Common::String values;
|
2013-08-24 01:47:12 -05:00
|
|
|
|
|
|
|
while (!file.eos()) {
|
2014-02-07 16:07:52 +07:00
|
|
|
line = file.readLine();
|
2014-11-12 16:05:48 +06:00
|
|
|
getLevParams(line, param, values);
|
2014-02-07 16:07:52 +07:00
|
|
|
|
2014-11-12 16:05:48 +06:00
|
|
|
if (param.matchString("animation_id", true)) {
|
2013-08-24 01:47:12 -05:00
|
|
|
// Not used
|
2014-11-12 16:05:48 +06:00
|
|
|
} else if (param.matchString("filename", true)) {
|
2014-12-16 00:48:16 +02:00
|
|
|
_animation = _engine->loadAnimation(values);
|
2014-11-12 16:05:48 +06:00
|
|
|
} else if (param.matchString("skipcolor", true)) {
|
2013-08-24 01:47:12 -05:00
|
|
|
// Not used
|
2014-11-12 16:05:48 +06:00
|
|
|
} else if (param.matchString("anim_coords", true)) {
|
2013-08-26 14:17:43 -05:00
|
|
|
int left, top, right, bottom;
|
2014-11-12 16:05:48 +06:00
|
|
|
sscanf(values.c_str(), "%d %d %d %d", &left, &top, &right, &bottom);
|
2013-08-26 14:17:43 -05:00
|
|
|
|
|
|
|
_animationCoords.left = left;
|
|
|
|
_animationCoords.top = top;
|
|
|
|
_animationCoords.right = right;
|
|
|
|
_animationCoords.bottom = bottom;
|
2014-11-12 16:05:48 +06:00
|
|
|
} else if (param.matchString("mirrored", true)) {
|
2013-08-24 01:47:12 -05:00
|
|
|
uint mirrored;
|
2014-11-12 16:05:48 +06:00
|
|
|
sscanf(values.c_str(), "%u", &mirrored);
|
2013-08-24 01:47:12 -05:00
|
|
|
|
|
|
|
_mirrored = mirrored == 0 ? false : true;
|
2014-11-12 16:05:48 +06:00
|
|
|
} else if (param.matchString("frames", true)) {
|
|
|
|
sscanf(values.c_str(), "%u", &_frameCount);
|
2013-08-24 01:47:12 -05:00
|
|
|
|
|
|
|
_frameInfo = new FrameInfo[_frameCount];
|
2014-11-12 16:05:48 +06:00
|
|
|
} else if (param.matchString("elsewhere", true)) {
|
2013-08-24 01:47:12 -05:00
|
|
|
// Not used
|
2014-11-12 16:05:48 +06:00
|
|
|
} else if (param.matchString("out_of_control", true)) {
|
2013-08-24 01:47:12 -05:00
|
|
|
// Not used
|
2014-11-12 16:05:48 +06:00
|
|
|
} else if (param.matchString("start_pos", true)) {
|
|
|
|
sscanf(values.c_str(), "%u", &_startFrame);
|
2013-08-24 01:47:12 -05:00
|
|
|
_currentFrame = _startFrame;
|
2014-11-12 16:05:48 +06:00
|
|
|
} else if (param.matchString("hotspot_deltas", true)) {
|
2013-08-24 01:47:12 -05:00
|
|
|
uint x;
|
|
|
|
uint y;
|
2014-11-12 16:05:48 +06:00
|
|
|
sscanf(values.c_str(), "%u %u", &x, &y);
|
2013-08-24 01:47:12 -05:00
|
|
|
|
|
|
|
_hotspotDelta.x = x;
|
|
|
|
_hotspotDelta.y = y;
|
2014-11-20 14:02:08 +06:00
|
|
|
} else if (param.matchString("venus_id", true)) {
|
2014-11-20 14:48:24 +06:00
|
|
|
_venusId = atoi(values.c_str());
|
2013-08-24 01:47:12 -05:00
|
|
|
} else {
|
|
|
|
uint frameNumber;
|
|
|
|
uint x, y;
|
|
|
|
|
2014-02-07 16:07:52 +07:00
|
|
|
line.toLowercase();
|
|
|
|
|
2013-08-24 01:47:12 -05:00
|
|
|
if (sscanf(line.c_str(), "%u:%u %u", &frameNumber, &x, &y) == 3) {
|
|
|
|
_frameInfo[frameNumber].hotspot.left = x;
|
|
|
|
_frameInfo[frameNumber].hotspot.top = y;
|
|
|
|
_frameInfo[frameNumber].hotspot.right = x + _hotspotDelta.x;
|
|
|
|
_frameInfo[frameNumber].hotspot.bottom = y + _hotspotDelta.y;
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:07:52 +07:00
|
|
|
Common::StringTokenizer tokenizer(line, " ^=()~");
|
2013-08-24 01:47:12 -05:00
|
|
|
tokenizer.nextToken();
|
|
|
|
tokenizer.nextToken();
|
|
|
|
|
|
|
|
Common::String token = tokenizer.nextToken();
|
|
|
|
while (!tokenizer.empty()) {
|
2014-02-07 16:07:52 +07:00
|
|
|
if (token == "d") {
|
2013-08-24 01:47:12 -05:00
|
|
|
token = tokenizer.nextToken();
|
|
|
|
|
|
|
|
uint angle;
|
|
|
|
uint toFrame;
|
|
|
|
sscanf(token.c_str(), "%u,%u", &toFrame, &angle);
|
|
|
|
|
|
|
|
_frameInfo[frameNumber].directions.push_back(Direction(angle, toFrame));
|
2014-02-07 16:07:52 +07:00
|
|
|
} else if (token.hasPrefix("p")) {
|
2013-08-31 17:53:13 -05:00
|
|
|
// Format: P(<from> to <to>)
|
|
|
|
tokenizer.nextToken();
|
|
|
|
tokenizer.nextToken();
|
|
|
|
token = tokenizer.nextToken();
|
|
|
|
uint to = atoi(token.c_str());
|
2013-08-24 01:47:12 -05:00
|
|
|
|
|
|
|
_frameInfo[frameNumber].returnRoute.push_back(to);
|
|
|
|
}
|
|
|
|
|
|
|
|
token = tokenizer.nextToken();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:07:52 +07:00
|
|
|
// Don't read lines in this place because last will not be parsed.
|
2013-08-24 01:47:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-15 18:10:27 +00:00
|
|
|
bool LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
|
2013-10-25 20:42:14 +00:00
|
|
|
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
|
2013-11-15 18:10:27 +00:00
|
|
|
return false;
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2013-08-24 01:47:12 -05:00
|
|
|
if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
|
2014-11-20 14:02:08 +06:00
|
|
|
setVenus();
|
2013-08-24 01:47:12 -05:00
|
|
|
_mouseIsCaptured = true;
|
|
|
|
_lastMousePos = backgroundImageSpacePos;
|
|
|
|
}
|
2013-11-15 18:10:27 +00:00
|
|
|
return false;
|
2013-08-24 01:47:12 -05:00
|
|
|
}
|
|
|
|
|
2013-11-15 18:10:27 +00:00
|
|
|
bool LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
|
2013-10-25 20:42:14 +00:00
|
|
|
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
|
2013-11-15 18:10:27 +00:00
|
|
|
return false;
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2013-08-31 18:09:24 -05:00
|
|
|
if (_mouseIsCaptured) {
|
|
|
|
_mouseIsCaptured = false;
|
|
|
|
_engine->getScriptManager()->setStateValue(_key, _currentFrame);
|
2013-08-24 01:47:12 -05:00
|
|
|
|
2013-08-31 18:09:24 -05:00
|
|
|
_isReturning = true;
|
|
|
|
_returnRoutesCurrentProgress = _frameInfo[_currentFrame].returnRoute.begin();
|
|
|
|
_returnRoutesCurrentFrame = _currentFrame;
|
|
|
|
}
|
2013-11-15 18:10:27 +00:00
|
|
|
return false;
|
2013-08-24 01:47:12 -05:00
|
|
|
}
|
|
|
|
|
2013-08-26 14:06:46 -05:00
|
|
|
bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
|
2013-10-25 20:42:14 +00:00
|
|
|
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
|
2013-08-30 15:34:42 -05:00
|
|
|
return false;
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2013-08-24 01:47:12 -05:00
|
|
|
bool cursorWasChanged = false;
|
|
|
|
|
|
|
|
if (_mouseIsCaptured) {
|
2014-12-09 19:37:33 +02:00
|
|
|
// Make sure the square distance between the last point and the current point is greater than 16
|
2013-08-24 01:47:12 -05:00
|
|
|
// This is a heuristic. This determines how responsive the lever is to mouse movement.
|
2014-12-09 19:37:33 +02:00
|
|
|
if (_lastMousePos.sqrDist(backgroundImageSpacePos) >= 16) {
|
2013-08-24 01:47:12 -05:00
|
|
|
int angle = calculateVectorAngle(_lastMousePos, backgroundImageSpacePos);
|
|
|
|
_lastMousePos = backgroundImageSpacePos;
|
|
|
|
|
2013-10-01 17:27:03 -05:00
|
|
|
for (Common::List<Direction>::iterator iter = _frameInfo[_currentFrame].directions.begin(); iter != _frameInfo[_currentFrame].directions.end(); ++iter) {
|
2013-10-01 17:15:44 -05:00
|
|
|
if (angle >= (int)iter->angle - ANGLE_DELTA && angle <= (int)iter->angle + ANGLE_DELTA) {
|
|
|
|
_currentFrame = iter->toFrame;
|
2013-08-24 01:47:12 -05:00
|
|
|
renderFrame(_currentFrame);
|
2015-01-15 00:40:07 -06:00
|
|
|
_engine->getScriptManager()->setStateValue(_key, _currentFrame);
|
2013-08-24 01:47:12 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-15 00:37:39 -06:00
|
|
|
_engine->getCursorManager()->changeCursor(_cursor);
|
|
|
|
cursorWasChanged = true;
|
2013-08-24 01:47:12 -05:00
|
|
|
} else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
|
2014-11-12 16:05:48 +06:00
|
|
|
_engine->getCursorManager()->changeCursor(_cursor);
|
2013-08-28 09:16:16 -05:00
|
|
|
cursorWasChanged = true;
|
2013-08-24 01:47:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return cursorWasChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LeverControl::process(uint32 deltaTimeInMillis) {
|
2013-10-25 20:42:14 +00:00
|
|
|
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
|
2013-08-30 15:34:42 -05:00
|
|
|
return false;
|
|
|
|
|
2013-08-31 17:54:34 -05:00
|
|
|
if (_isReturning) {
|
|
|
|
_accumulatedTime += deltaTimeInMillis;
|
|
|
|
while (_accumulatedTime >= ANIMATION_FRAME_TIME) {
|
|
|
|
_accumulatedTime -= ANIMATION_FRAME_TIME;
|
|
|
|
if (_returnRoutesCurrentFrame == *_returnRoutesCurrentProgress) {
|
|
|
|
_returnRoutesCurrentProgress++;
|
|
|
|
}
|
|
|
|
if (_returnRoutesCurrentProgress == _frameInfo[_currentFrame].returnRoute.end()) {
|
|
|
|
_isReturning = false;
|
|
|
|
_currentFrame = _returnRoutesCurrentFrame;
|
|
|
|
return false;
|
|
|
|
}
|
2013-08-24 01:47:12 -05:00
|
|
|
|
2013-08-31 17:54:34 -05:00
|
|
|
uint toFrame = *_returnRoutesCurrentProgress;
|
|
|
|
if (_returnRoutesCurrentFrame < toFrame) {
|
|
|
|
_returnRoutesCurrentFrame++;
|
|
|
|
} else if (_returnRoutesCurrentFrame > toFrame) {
|
|
|
|
_returnRoutesCurrentFrame--;
|
|
|
|
}
|
|
|
|
|
2013-09-25 02:30:02 -05:00
|
|
|
_engine->getScriptManager()->setStateValue(_key, _returnRoutesCurrentFrame);
|
2013-08-31 17:54:34 -05:00
|
|
|
renderFrame(_returnRoutesCurrentFrame);
|
|
|
|
}
|
|
|
|
}
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2013-08-24 01:47:12 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo) {
|
|
|
|
// Check for the easy angles first
|
|
|
|
if (pointOne.x == pointTwo.x && pointOne.y == pointTwo.y)
|
|
|
|
return -1; // This should never happen
|
|
|
|
else if (pointOne.x == pointTwo.x) {
|
2013-08-28 09:12:14 -05:00
|
|
|
if (pointTwo.y < pointOne.y)
|
2013-08-24 01:47:12 -05:00
|
|
|
return 90;
|
|
|
|
else
|
|
|
|
return 270;
|
|
|
|
} else if (pointOne.y == pointTwo.y) {
|
|
|
|
if (pointTwo.x > pointOne.x)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 180;
|
|
|
|
} else {
|
|
|
|
// Calculate the angle with trig
|
|
|
|
int16 xDist = pointTwo.x - pointOne.x;
|
|
|
|
int16 yDist = pointTwo.y - pointOne.y;
|
|
|
|
|
2013-08-28 09:10:59 -05:00
|
|
|
// Calculate the angle using arctan
|
|
|
|
// Then convert to degrees. (180 / 3.14159 = 57.2958)
|
2014-02-07 16:07:52 +07:00
|
|
|
int angle = int(atan((float)yDist / (float)abs(xDist)) * 57);
|
2013-08-24 01:47:12 -05:00
|
|
|
|
|
|
|
// Calculate what quadrant pointTwo is in
|
|
|
|
uint quadrant = ((yDist > 0 ? 1 : 0) << 1) | (xDist < 0 ? 1 : 0);
|
|
|
|
|
|
|
|
// Explanation of quadrants:
|
|
|
|
//
|
|
|
|
// yDist > 0 | xDist < 0 | Quadrant number
|
|
|
|
// 0 | 0 | 0
|
|
|
|
// 0 | 1 | 1
|
|
|
|
// 1 | 0 | 2
|
|
|
|
// 1 | 1 | 3
|
|
|
|
//
|
|
|
|
// Note: I know this doesn't line up with traditional mathematical quadrants
|
|
|
|
// but doing it this way allows you can use a switch and is a bit cleaner IMO.
|
|
|
|
//
|
|
|
|
// The graph below shows the 4 quadrants pointTwo can end up in as well
|
|
|
|
// as what the angle as calculated above refers to.
|
|
|
|
// Note: The calculated angle in quadrants 0 and 3 is negative
|
|
|
|
// due to arctan(-x) = -theta
|
|
|
|
//
|
|
|
|
// Origin => (pointOne.x, pointOne.y)
|
|
|
|
// * => (pointTwo.x, pointTwo.y)
|
|
|
|
//
|
2013-09-22 14:55:32 -05:00
|
|
|
// 90 |
|
|
|
|
// ^ |
|
|
|
|
// * | * |
|
|
|
|
// \ | / |
|
|
|
|
// \ | / |
|
|
|
|
// \ | / |
|
|
|
|
// Quadrant 1 \ | / Quadrant 0 |
|
|
|
|
// \ | / |
|
|
|
|
// \ | / |
|
|
|
|
// angle ( \|/ ) -angle |
|
|
|
|
// 180 <----------------------------------------> 0 |
|
|
|
|
// -angle ( /|\ ) angle |
|
|
|
|
// / | \ |
|
|
|
|
// / | \ |
|
|
|
|
// Quadrant 3 / | \ Quadrant 2 |
|
|
|
|
// / | \ |
|
|
|
|
// / | \ |
|
|
|
|
// / | \ |
|
|
|
|
// * | * |
|
|
|
|
// ^ |
|
|
|
|
// 270 |
|
2013-08-24 01:47:12 -05:00
|
|
|
|
|
|
|
// Convert the local angles to unit circle angles
|
|
|
|
switch (quadrant) {
|
|
|
|
case 0:
|
2014-02-07 16:07:52 +07:00
|
|
|
angle = -angle;
|
2013-08-24 01:47:12 -05:00
|
|
|
break;
|
|
|
|
case 1:
|
2014-02-07 16:07:52 +07:00
|
|
|
angle = angle + 180;
|
2013-08-24 01:47:12 -05:00
|
|
|
break;
|
|
|
|
case 2:
|
2014-02-07 16:07:52 +07:00
|
|
|
angle = 360 - angle;
|
2013-08-24 01:47:12 -05:00
|
|
|
break;
|
|
|
|
case 3:
|
2014-02-07 16:07:52 +07:00
|
|
|
angle = 180 + angle;
|
2013-08-24 01:47:12 -05:00
|
|
|
break;
|
2019-10-24 02:04:53 +01:00
|
|
|
default:
|
|
|
|
break;
|
2013-08-24 01:47:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return angle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LeverControl::renderFrame(uint frameNumber) {
|
2013-08-29 01:52:37 -05:00
|
|
|
if (frameNumber == 0) {
|
|
|
|
_lastRenderedFrame = frameNumber;
|
|
|
|
} else if (frameNumber < _lastRenderedFrame && _mirrored) {
|
|
|
|
_lastRenderedFrame = frameNumber;
|
|
|
|
frameNumber = (_frameCount * 2) - frameNumber - 1;
|
|
|
|
} else {
|
|
|
|
_lastRenderedFrame = frameNumber;
|
2013-08-28 09:14:32 -05:00
|
|
|
}
|
|
|
|
|
2014-01-07 18:39:16 +07:00
|
|
|
const Graphics::Surface *frameData;
|
2013-08-24 01:47:12 -05:00
|
|
|
|
2014-12-16 00:48:16 +02:00
|
|
|
_animation->seekToFrame(frameNumber);
|
|
|
|
frameData = _animation->decodeNextFrame();
|
2014-01-17 16:56:49 +07:00
|
|
|
if (frameData)
|
2014-10-10 16:49:38 +07:00
|
|
|
_engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _animationCoords);
|
2013-08-24 01:47:12 -05:00
|
|
|
}
|
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
void LeverControl::getLevParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values) {
|
|
|
|
const char *chrs = inputStr.c_str();
|
2014-11-12 16:05:48 +06:00
|
|
|
uint lbr;
|
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
for (lbr = 0; lbr < inputStr.size(); lbr++)
|
2014-11-12 16:05:48 +06:00
|
|
|
if (chrs[lbr] == ':')
|
|
|
|
break;
|
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
if (lbr >= inputStr.size())
|
2014-11-12 16:05:48 +06:00
|
|
|
return;
|
|
|
|
|
|
|
|
uint rbr;
|
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
for (rbr = lbr + 1; rbr < inputStr.size(); rbr++)
|
2014-11-12 16:05:48 +06:00
|
|
|
if (chrs[rbr] == '~')
|
|
|
|
break;
|
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
if (rbr >= inputStr.size())
|
2014-11-12 16:05:48 +06:00
|
|
|
return;
|
|
|
|
|
|
|
|
parameter = Common::String(chrs, chrs + lbr);
|
|
|
|
values = Common::String(chrs + lbr + 1, chrs + rbr);
|
|
|
|
}
|
|
|
|
|
2013-08-24 01:47:12 -05:00
|
|
|
} // End of namespace ZVision
|