2013-07-01 17:13:02 -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.
|
|
|
|
|
|
|
|
* 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 "common/scummsys.h"
|
|
|
|
|
2013-08-05 00:14:20 -05:00
|
|
|
#include "common/file.h"
|
|
|
|
|
|
|
|
#include "audio/decoders/wave.h"
|
|
|
|
|
2013-07-06 12:30:54 -05:00
|
|
|
#include "zvision/actions.h"
|
2013-07-03 18:21:25 -05:00
|
|
|
#include "zvision/zvision.h"
|
2013-07-11 00:18:23 -05:00
|
|
|
#include "zvision/script_manager.h"
|
2013-08-03 15:00:58 -05:00
|
|
|
#include "zvision/render_manager.h"
|
2013-07-11 00:18:23 -05:00
|
|
|
#include "zvision/action_node.h"
|
2013-08-05 00:14:20 -05:00
|
|
|
#include "zvision/zork_raw.h"
|
2013-08-10 17:18:29 -05:00
|
|
|
#include "zvision/zork_avi_decoder.h"
|
2013-07-01 17:13:02 -05:00
|
|
|
|
|
|
|
namespace ZVision {
|
|
|
|
|
2013-07-06 00:29:15 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2013-07-03 17:21:21 -05:00
|
|
|
// ActionAdd
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-07-30 14:28:47 -05:00
|
|
|
ActionAdd::ActionAdd(const Common::String &line) {
|
2013-08-03 13:43:46 -05:00
|
|
|
sscanf(line.c_str(), "%*[^(](%u,%u)", &_key, &_value);
|
2013-07-01 17:13:02 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 23:13:50 -05:00
|
|
|
bool ActionAdd::execute(ZVision *engine) {
|
|
|
|
engine->getScriptManager()->addToStateValue(_key, _value);
|
2013-07-01 17:13:02 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-03 17:21:21 -05:00
|
|
|
|
2013-07-06 00:29:15 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2013-07-03 17:21:21 -05:00
|
|
|
// ActionAssign
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-07-30 14:28:47 -05:00
|
|
|
ActionAssign::ActionAssign(const Common::String &line) {
|
2013-08-03 13:43:46 -05:00
|
|
|
sscanf(line.c_str(), "%*[^(](%u, %u)", &_key, &_value);
|
2013-07-03 17:21:21 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 23:13:50 -05:00
|
|
|
bool ActionAssign::execute(ZVision *engine) {
|
|
|
|
engine->getScriptManager()->setStateValue(_key, _value);
|
2013-07-03 17:21:21 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-06 00:29:15 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ActionAttenuate
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-07-30 14:28:47 -05:00
|
|
|
ActionAttenuate::ActionAttenuate(const Common::String &line) {
|
2013-08-03 13:43:46 -05:00
|
|
|
sscanf(line.c_str(), "%*[^(](%u, %d)", &_key, &_attenuation);
|
2013-07-06 00:29:15 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 23:13:50 -05:00
|
|
|
bool ActionAttenuate::execute(ZVision *engine) {
|
2013-07-06 00:29:15 -05:00
|
|
|
// TODO: Implement
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ActionChangeLocation
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-07-30 14:28:47 -05:00
|
|
|
ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
|
2013-08-03 13:43:46 -05:00
|
|
|
sscanf(line.c_str(), "%*[^(](%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_x);
|
2013-07-06 00:29:15 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 23:13:50 -05:00
|
|
|
bool ActionChangeLocation::execute(ZVision *engine) {
|
2013-07-06 00:29:15 -05:00
|
|
|
// TODO: Implement
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ActionCrossfade
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-07-30 14:28:47 -05:00
|
|
|
ActionCrossfade::ActionCrossfade(const Common::String &line) {
|
2013-07-30 14:33:53 -05:00
|
|
|
sscanf(line.c_str(),
|
2013-08-03 13:43:46 -05:00
|
|
|
"%*[^(](%u %u %u %u %u %u %u)",
|
2013-07-06 00:29:15 -05:00
|
|
|
&_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
|
|
|
|
}
|
|
|
|
|
2013-07-10 23:13:50 -05:00
|
|
|
bool ActionCrossfade::execute(ZVision *engine) {
|
2013-07-06 00:29:15 -05:00
|
|
|
// TODO: Implement
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-05 00:14:20 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ActionMusic
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
ActionMusic::ActionMusic(const Common::String &line) : _volume(255) {
|
|
|
|
uint type;
|
|
|
|
char fileNameBuffer[25];
|
|
|
|
uint loop;
|
|
|
|
uint volume = 255;
|
|
|
|
|
|
|
|
sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u %25s %u %u)", &_key, &type, fileNameBuffer, &loop, &volume);
|
|
|
|
|
|
|
|
// type 4 are midi sound effect files
|
|
|
|
if (type == 4) {
|
|
|
|
_soundType = Audio::Mixer::kSFXSoundType;
|
|
|
|
_fileName = Common::String::format("midi/%s/%u.wav", fileNameBuffer, loop);
|
|
|
|
_loop = false;
|
|
|
|
} else {
|
|
|
|
// TODO: See what the other types are so we can specify the correct Mixer::SoundType. In the meantime use kPlainSoundType
|
|
|
|
_soundType = Audio::Mixer::kPlainSoundType;
|
|
|
|
_fileName = Common::String(fileNameBuffer);
|
|
|
|
_loop = loop == 1 ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Volume is optional. If it doesn't appear, assume full volume
|
|
|
|
if (volume != 255) {
|
|
|
|
// Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255]
|
|
|
|
_volume = volume * 255 / 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ActionMusic::execute(ZVision *engine) {
|
|
|
|
Audio::RewindableAudioStream *audioStream;
|
|
|
|
|
|
|
|
if (_fileName.contains(".wav")) {
|
|
|
|
Common::File file;
|
|
|
|
if (file.open(_fileName)) {
|
|
|
|
audioStream = Audio::makeWAVStream(&file, DisposeAfterUse::NO);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
audioStream = makeRawZorkStream(_fileName, engine);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_loop) {
|
|
|
|
Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
|
|
|
|
engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume);
|
|
|
|
} else {
|
|
|
|
engine->_mixer->playStream(_soundType, 0, audioStream, -1, _volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-06 00:29:15 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ActionPreloadAnimation
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-07-30 14:28:47 -05:00
|
|
|
ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
|
2013-08-03 13:43:46 -05:00
|
|
|
char fileName[25];
|
|
|
|
|
2013-07-30 14:33:53 -05:00
|
|
|
// The two %*u are always 0 and dont seem to have a use
|
2013-08-03 13:43:46 -05:00
|
|
|
sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %u %u)", &_key, fileName, &_mask, &_framerate);
|
2013-07-06 00:29:15 -05:00
|
|
|
|
2013-08-03 13:43:46 -05:00
|
|
|
_fileName = Common::String(fileName);
|
2013-07-29 21:42:07 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 23:13:50 -05:00
|
|
|
bool ActionPreloadAnimation::execute(ZVision *engine) {
|
2013-07-06 00:29:15 -05:00
|
|
|
// TODO: Implement
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ActionPlayAnimation
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-07-30 14:28:47 -05:00
|
|
|
ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
|
2013-08-02 09:59:20 -05:00
|
|
|
char fileName[25];
|
2013-08-05 11:50:39 -05:00
|
|
|
uint loop;
|
2013-08-02 09:59:20 -05:00
|
|
|
|
2013-07-30 14:33:53 -05:00
|
|
|
// The two %*u are always 0 and dont seem to have a use
|
|
|
|
sscanf(line.c_str(),
|
2013-08-03 13:43:46 -05:00
|
|
|
"%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %u %*u %*u %u %u)",
|
2013-08-05 11:50:39 -05:00
|
|
|
&_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &loop, &_mask, &_framerate);
|
2013-08-02 09:59:20 -05:00
|
|
|
|
|
|
|
_fileName = Common::String(fileName);
|
2013-08-05 11:50:39 -05:00
|
|
|
_loop = loop == 1 ? true : false;
|
2013-07-06 00:29:15 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 23:13:50 -05:00
|
|
|
bool ActionPlayAnimation::execute(ZVision *engine) {
|
2013-07-06 00:29:15 -05:00
|
|
|
// TODO: Implement
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-10 17:12:23 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ActionQuit
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
bool ActionQuit::execute(ZVision *engine) {
|
|
|
|
engine->quitGame();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-06 00:29:15 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2013-07-03 17:21:21 -05:00
|
|
|
// ActionRandom
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-07-30 14:28:47 -05:00
|
|
|
ActionRandom::ActionRandom(const Common::String &line) {
|
2013-08-03 13:43:46 -05:00
|
|
|
sscanf(line.c_str(), "%*[^:]:%*[^:]:%u, %u)", &_key, &_max);
|
2013-07-03 17:21:21 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 23:13:50 -05:00
|
|
|
bool ActionRandom::execute(ZVision *engine) {
|
2013-07-30 14:25:31 -05:00
|
|
|
uint randNumber = engine->getRandomSource()->getRandomNumber(_max);
|
2013-07-10 23:13:50 -05:00
|
|
|
engine->getScriptManager()->setStateValue(_key, randNumber);
|
2013-07-03 17:21:21 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-06 00:29:15 -05:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2013-08-03 15:00:58 -05:00
|
|
|
// ActionSetScreen
|
2013-07-06 00:29:15 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-08-03 15:00:58 -05:00
|
|
|
ActionSetScreen::ActionSetScreen(const Common::String &line) {
|
|
|
|
char fileName[25];
|
|
|
|
sscanf(line.c_str(), "%*[^(](%25[^)])", fileName);
|
|
|
|
|
|
|
|
_fileName = Common::String(fileName);
|
2013-07-06 00:29:15 -05:00
|
|
|
}
|
|
|
|
|
2013-08-03 15:00:58 -05:00
|
|
|
bool ActionSetScreen::execute(ZVision *engine) {
|
|
|
|
RenderManager *renderManager = engine->getRenderManager();
|
|
|
|
renderManager->setBackgroundImage(_fileName);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-10 17:18:29 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ActionStreamVideo
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
ActionStreamVideo::ActionStreamVideo(const Common::String &line) {
|
|
|
|
char fileName[25];
|
|
|
|
uint skippable;
|
|
|
|
|
|
|
|
sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x, &_y, &_width, &_height, &_flags, &skippable);
|
|
|
|
|
|
|
|
_fileName = Common::String(fileName);
|
|
|
|
_skippable = (skippable == 0) ? false : true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ActionStreamVideo::execute(ZVision *engine) {
|
|
|
|
ZorkAVIDecoder decoder;
|
|
|
|
if (!decoder.loadFile(_fileName)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Rect destRect;
|
|
|
|
if ((_flags & 0x1) == 0x1) {
|
|
|
|
destRect = Common::Rect(_x, _y, _x + _width, _y + _height);
|
|
|
|
}
|
|
|
|
|
|
|
|
engine->playVideo(decoder, destRect, _skippable);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-03 15:00:58 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ActionTimer
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
ActionTimer::ActionTimer(const Common::String &line) {
|
2013-08-03 13:43:46 -05:00
|
|
|
sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u)", &_key, &_time);
|
2013-07-29 21:42:07 -05:00
|
|
|
}
|
|
|
|
|
2013-07-10 23:13:50 -05:00
|
|
|
bool ActionTimer::execute(ZVision *engine) {
|
2013-08-03 15:00:58 -05:00
|
|
|
engine->getScriptManager()->addActionNode(Common::SharedPtr<ActionNode>(new NodeTimer(_key, _time)));
|
2013-07-06 00:29:15 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-01 17:13:02 -05:00
|
|
|
} // End of namespace ZVision
|