Initial commit
This commit is contained in:
44
engines/pink/objects/actions/action.cpp
Normal file
44
engines/pink/objects/actions/action.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pink/archive.h"
|
||||
#include "pink/objects/actions/action.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
void Action::deserialize(Archive &archive) {
|
||||
NamedObject::deserialize(archive);
|
||||
_actor = static_cast<Actor *>(archive.readObject());
|
||||
}
|
||||
|
||||
bool Action::initPalette(Screen *screen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Action::pause(bool paused) {}
|
||||
|
||||
Coordinates Action::getCoordinates() {
|
||||
return Coordinates();
|
||||
}
|
||||
|
||||
|
||||
} // End of namespace Pink
|
||||
53
engines/pink/objects/actions/action.h
Normal file
53
engines/pink/objects/actions/action.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_ACTION_H
|
||||
#define PINK_ACTION_H
|
||||
|
||||
#include "pink/objects/object.h"
|
||||
#include "pink/objects/walk/walk_mgr.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class Actor;
|
||||
class Screen;
|
||||
|
||||
class Action : public NamedObject {
|
||||
public:
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
virtual bool initPalette(Screen *screen);
|
||||
|
||||
virtual void start() = 0;
|
||||
virtual void end() = 0;
|
||||
|
||||
virtual void pause(bool paused);
|
||||
|
||||
virtual Coordinates getCoordinates();
|
||||
Actor *getActor() const { return _actor; }
|
||||
|
||||
protected:
|
||||
Actor *_actor;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
111
engines/pink/objects/actions/action_cel.cpp
Normal file
111
engines/pink/objects/actions/action_cel.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/substream.h"
|
||||
|
||||
#include "pink/archive.h"
|
||||
#include "pink/cel_decoder.h"
|
||||
#include "pink/screen.h"
|
||||
#include "pink/pink.h"
|
||||
#include "pink/objects/actions/action_cel.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
#include "pink/objects/pages/game_page.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
ActionCEL::~ActionCEL() {
|
||||
end();
|
||||
}
|
||||
|
||||
void ActionCEL::deserialize(Archive &archive) {
|
||||
Action::deserialize(archive);
|
||||
_fileName = archive.readString();
|
||||
_z = archive.readDWORD();
|
||||
}
|
||||
|
||||
bool ActionCEL::initPalette(Screen *screen) {
|
||||
loadDecoder();
|
||||
if (_decoder.getCurFrame() == -1) {
|
||||
_decoder.decodeNextFrame();
|
||||
_decoder.rewind();
|
||||
}
|
||||
screen->setPalette(_decoder.getPalette());
|
||||
return true;
|
||||
}
|
||||
|
||||
void ActionCEL::start() {
|
||||
loadDecoder();
|
||||
_decoder.start();
|
||||
this->onStart();
|
||||
_actor->getPage()->getGame()->getScreen()->addSprite(this);
|
||||
}
|
||||
|
||||
void ActionCEL::end() {
|
||||
_actor->getPage()->getGame()->getScreen()->removeSprite(this);
|
||||
_decoder.close();
|
||||
}
|
||||
|
||||
void ActionCEL::pause(bool paused) {
|
||||
_decoder.pauseVideo(paused);
|
||||
}
|
||||
|
||||
Coordinates ActionCEL::getCoordinates() {
|
||||
loadDecoder();
|
||||
|
||||
Coordinates coords;
|
||||
coords.point = _decoder.getCenter();
|
||||
coords.z = getZ();
|
||||
|
||||
return coords;
|
||||
}
|
||||
|
||||
void ActionCEL::loadDecoder() {
|
||||
if (!_decoder.isVideoLoaded()) {
|
||||
_decoder.loadStream(_actor->getPage()->getResourceStream(_fileName));
|
||||
Common::Point point = _decoder.getCenter();
|
||||
_bounds = Common::Rect::center(point.x, point.y, _decoder.getWidth(), _decoder.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
void ActionCEL::setFrame(uint frame) {
|
||||
_decoder.rewind();
|
||||
|
||||
for (uint i = 0; i < frame; ++i) {
|
||||
_decoder.skipFrame();
|
||||
}
|
||||
|
||||
_decoder.clearDirtyRects();
|
||||
_actor->getPage()->getGame()->getScreen()->addDirtyRect(_bounds);
|
||||
}
|
||||
|
||||
void ActionCEL::decodeNext() {
|
||||
_decoder.decodeNextFrame();
|
||||
_actor->getPage()->getGame()->getScreen()->addDirtyRects(this);
|
||||
}
|
||||
|
||||
void ActionCEL::setCenter(Common::Point center) {
|
||||
_actor->getPage()->getGame()->getScreen()->addDirtyRect(_bounds);
|
||||
_bounds = Common::Rect::center(center.x, center.y, _decoder.getWidth(), _decoder.getHeight());
|
||||
_actor->getPage()->getGame()->getScreen()->addDirtyRect(_bounds);
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
73
engines/pink/objects/actions/action_cel.h
Normal file
73
engines/pink/objects/actions/action_cel.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_ACTION_CEL_H
|
||||
#define PINK_ACTION_CEL_H
|
||||
|
||||
#include "pink/cel_decoder.h"
|
||||
#include "pink/objects/actions/action.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class CelDecoder;
|
||||
|
||||
class ActionCEL : public Action {
|
||||
public:
|
||||
~ActionCEL() override;
|
||||
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
bool initPalette(Screen *screen) override;
|
||||
|
||||
void start() override;
|
||||
void end() override;
|
||||
|
||||
bool needsUpdate() { return _decoder.needsUpdate(); }
|
||||
virtual void update() {};
|
||||
|
||||
void pause(bool paused) override;
|
||||
|
||||
Coordinates getCoordinates() override;
|
||||
|
||||
const Common::Rect &getBounds() const { return _bounds; }
|
||||
uint32 getZ() { return _z; }
|
||||
CelDecoder *getDecoder() { return &_decoder; }
|
||||
|
||||
void setCenter(Common::Point center);
|
||||
|
||||
|
||||
void loadDecoder();
|
||||
|
||||
protected:
|
||||
virtual void onStart() = 0;
|
||||
|
||||
void decodeNext();
|
||||
void setFrame(uint frame);
|
||||
|
||||
CelDecoder _decoder;
|
||||
Common::String _fileName;
|
||||
Common::Rect _bounds;
|
||||
uint32 _z;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
42
engines/pink/objects/actions/action_hide.cpp
Normal file
42
engines/pink/objects/actions/action_hide.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pink/archive.h"
|
||||
#include "pink/pink.h"
|
||||
#include "pink/objects/actions/action_hide.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
void ActionHide::toConsole() const {
|
||||
debugC(6, kPinkDebugLoadingObjects, "\tActionHide: _name = %s", _name.c_str());
|
||||
}
|
||||
|
||||
void ActionHide::start() {
|
||||
debugC(6, kPinkDebugActions, "Actor %s has now ActionHide %s", _actor->getName().c_str(), _name.c_str());
|
||||
_actor->endAction();
|
||||
}
|
||||
|
||||
void ActionHide::end() {
|
||||
debugC(6, kPinkDebugActions, "ActionHide %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
|
||||
}
|
||||
|
||||
} //End of namespace Pink
|
||||
39
engines/pink/objects/actions/action_hide.h
Normal file
39
engines/pink/objects/actions/action_hide.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_ACTION_HIDE_H
|
||||
#define PINK_ACTION_HIDE_H
|
||||
|
||||
#include "pink/objects/actions/action.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class ActionHide : public Action {
|
||||
public:
|
||||
void toConsole() const override;
|
||||
|
||||
void start() override;
|
||||
void end() override;
|
||||
};
|
||||
|
||||
} //End of namespace Pink
|
||||
|
||||
#endif
|
||||
129
engines/pink/objects/actions/action_loop.cpp
Normal file
129
engines/pink/objects/actions/action_loop.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/random.h"
|
||||
|
||||
#include "pink/pink.h"
|
||||
#include "pink/cel_decoder.h"
|
||||
#include "pink/objects/actions/action_loop.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
#include "pink/objects/pages/page.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
void ActionLoop::deserialize(Archive &archive) {
|
||||
ActionPlay::deserialize(archive);
|
||||
uint16 style;
|
||||
_intro = archive.readDWORD();
|
||||
style = archive.readWORD();
|
||||
switch (style) {
|
||||
case kPingPong:
|
||||
_style = kPingPong;
|
||||
break;
|
||||
case kRandom:
|
||||
_style = kRandom;
|
||||
break;
|
||||
default:
|
||||
_style = kForward;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ActionLoop::toConsole() const {
|
||||
debugC(6, kPinkDebugLoadingObjects, "\tActionLoop: _name = %s, _fileName = %s, z = %u, _startFrame = %u,"
|
||||
" _endFrame = %d, _intro = %u, _style = %u",
|
||||
_name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame, _intro, _style);
|
||||
}
|
||||
|
||||
void ActionLoop::update() {
|
||||
int32 frame = _decoder.getCurFrame();
|
||||
|
||||
if (!_inLoop) {
|
||||
if (frame < (int32)_startFrame) {
|
||||
decodeNext();
|
||||
return;
|
||||
} else
|
||||
_inLoop = true;
|
||||
}
|
||||
|
||||
switch (_style) {
|
||||
case kPingPong:
|
||||
if (_forward) {
|
||||
if (frame < _stopFrame) {
|
||||
decodeNext();
|
||||
} else {
|
||||
_forward = false;
|
||||
ActionCEL::setFrame(_stopFrame - 1);
|
||||
decodeNext();
|
||||
}
|
||||
} else {
|
||||
if (frame > (int32)_startFrame) {
|
||||
ActionCEL::setFrame(frame - 1);
|
||||
} else {
|
||||
_forward = true;
|
||||
}
|
||||
decodeNext();
|
||||
}
|
||||
break;
|
||||
|
||||
case kRandom: {
|
||||
Common::RandomSource &rnd = _actor->getPage()->getGame()->getRnd();
|
||||
ActionCEL::setFrame(rnd.getRandomNumberRng(_startFrame, _stopFrame));
|
||||
decodeNext();
|
||||
break;
|
||||
}
|
||||
|
||||
case kForward:
|
||||
if (frame == _stopFrame) {
|
||||
ActionCEL::setFrame(_startFrame);
|
||||
}
|
||||
decodeNext();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ActionLoop::onStart() {
|
||||
if (_intro) {
|
||||
uint startFrame = _startFrame;
|
||||
_startFrame = 0;
|
||||
ActionPlay::onStart();
|
||||
_startFrame = startFrame;
|
||||
_inLoop = false;
|
||||
} else {
|
||||
ActionPlay::onStart();
|
||||
_inLoop = true;
|
||||
}
|
||||
|
||||
if (!isTalk())
|
||||
_actor->endAction();
|
||||
|
||||
_forward = true;
|
||||
}
|
||||
|
||||
void ActionLoop::end() {
|
||||
ActionCEL::end();
|
||||
debugC(6, kPinkDebugActions, "ActionLoop %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
56
engines/pink/objects/actions/action_loop.h
Normal file
56
engines/pink/objects/actions/action_loop.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_ACTION_LOOP_H
|
||||
#define PINK_ACTION_LOOP_H
|
||||
|
||||
#include "pink/objects/actions/action_play.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class ActionLoop : public ActionPlay {
|
||||
public:
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
void toConsole() const override;
|
||||
|
||||
void update() override;
|
||||
|
||||
void end() override;
|
||||
|
||||
protected:
|
||||
void onStart() override;
|
||||
virtual bool isTalk() { return false; }
|
||||
|
||||
enum Style {
|
||||
kPingPong = 2,
|
||||
kRandom = 3,
|
||||
kForward = 4
|
||||
};
|
||||
Style _style;
|
||||
bool _intro;
|
||||
bool _inLoop;
|
||||
bool _forward;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
77
engines/pink/objects/actions/action_play.cpp
Normal file
77
engines/pink/objects/actions/action_play.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/debug.h"
|
||||
|
||||
#include "pink/archive.h"
|
||||
#include "pink/cel_decoder.h"
|
||||
#include "pink/pink.h"
|
||||
#include "pink/objects/actions/action_play.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
void ActionPlay::deserialize(Archive &archive) {
|
||||
ActionStill::deserialize(archive);
|
||||
_stopFrame = archive.readDWORD();
|
||||
}
|
||||
|
||||
void ActionPlay::toConsole() const {
|
||||
debugC(6, kPinkDebugLoadingObjects, "\tActionPlay: _name = %s, _fileName = %s, z = %u, _startFrame = %u,"
|
||||
" _endFrame = %d", _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame);
|
||||
}
|
||||
|
||||
void ActionPlay::end() {
|
||||
ActionCEL::end();
|
||||
debugC(6, kPinkDebugActions, "ActionPlay %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
|
||||
}
|
||||
|
||||
void ActionPlay::update() {
|
||||
ActionCEL::update();
|
||||
if (_decoder.getCurFrame() >= _stopFrame) {
|
||||
_decoder.setEndOfTrack();
|
||||
assert(!_decoder.needsUpdate());
|
||||
_actor->endAction();
|
||||
} else
|
||||
decodeNext();
|
||||
}
|
||||
|
||||
void ActionPlay::pause(bool paused) {
|
||||
ActionCEL::pause(paused);
|
||||
}
|
||||
|
||||
void ActionPlay::onStart() {
|
||||
debugC(6, kPinkDebugActions, "Actor %s has now ActionPlay %s", _actor->getName().c_str(), _name.c_str());
|
||||
int32 frameCount = _decoder.getFrameCount();
|
||||
|
||||
if ((int32)_startFrame >= frameCount) {
|
||||
_startFrame = 0;
|
||||
}
|
||||
|
||||
if (_stopFrame == -1 || _stopFrame >= frameCount) {
|
||||
_stopFrame = frameCount - 1;
|
||||
}
|
||||
|
||||
ActionCEL::setFrame(_startFrame);
|
||||
// doesn't need to decode startFrame here. Update method will decode
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
49
engines/pink/objects/actions/action_play.h
Normal file
49
engines/pink/objects/actions/action_play.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_ACTION_PLAY_H
|
||||
#define PINK_ACTION_PLAY_H
|
||||
|
||||
#include "pink/objects/actions/action_still.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class ActionPlay : public ActionStill {
|
||||
public:
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
void toConsole() const override;
|
||||
|
||||
void end() override;
|
||||
|
||||
void update() override;
|
||||
|
||||
void pause(bool paused) override;
|
||||
|
||||
protected:
|
||||
void onStart() override;
|
||||
|
||||
int32 _stopFrame;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
110
engines/pink/objects/actions/action_play_with_sfx.cpp
Normal file
110
engines/pink/objects/actions/action_play_with_sfx.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pink/cel_decoder.h"
|
||||
#include "pink/sound.h"
|
||||
#include "pink/pink.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
#include "pink/objects/actions/action_play_with_sfx.h"
|
||||
#include "pink/objects/pages/game_page.h"
|
||||
#include "pink/objects/sequences/sequencer.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
ActionPlayWithSfx::~ActionPlayWithSfx() {
|
||||
ActionPlay::end();
|
||||
for (uint i = 0; i < _sfxArray.size(); ++i) {
|
||||
delete _sfxArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
void ActionPlayWithSfx::deserialize(Pink::Archive &archive) {
|
||||
ActionPlay::deserialize(archive);
|
||||
_isLoop = archive.readDWORD();
|
||||
_sfxArray.deserialize(archive);
|
||||
}
|
||||
|
||||
void ActionPlayWithSfx::toConsole() const {
|
||||
debugC(6, kPinkDebugLoadingObjects, "\tActionPlayWithSfx: _name = %s, _fileName = %s, z = %u, _startFrame = %u,"
|
||||
" _endFrame = %d, _isLoop = %u", _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame, _isLoop);
|
||||
for (uint i = 0; i < _sfxArray.size(); ++i) {
|
||||
_sfxArray[i]->toConsole();
|
||||
}
|
||||
}
|
||||
|
||||
void ActionPlayWithSfx::update() {
|
||||
int currFrame = _decoder.getCurFrame();
|
||||
if (_isLoop && currFrame == _stopFrame) {
|
||||
ActionCEL::setFrame(_startFrame);
|
||||
decodeNext();
|
||||
} else
|
||||
ActionPlay::update();
|
||||
|
||||
currFrame++;
|
||||
for (uint i = 0; i < _sfxArray.size(); ++i) {
|
||||
if (_sfxArray[i]->getFrame() == currFrame)
|
||||
_sfxArray[i]->play();
|
||||
}
|
||||
}
|
||||
|
||||
void ActionPlayWithSfx::onStart() {
|
||||
ActionPlay::onStart();
|
||||
if (_isLoop)
|
||||
_actor->endAction();
|
||||
}
|
||||
|
||||
void ActionPlayWithSfx::end() {
|
||||
ActionCEL::end();
|
||||
debugC(6, kPinkDebugActions, "ActionPlayWithSfx %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
|
||||
// original bug fix
|
||||
if (_actor->getPage()->getSequencer() && _actor->getPage()->getSequencer()->isSkipping()) {
|
||||
for (uint i = 0; i < _sfxArray.size(); ++i) {
|
||||
_sfxArray[i]->end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActionSfx::deserialize(Pink::Archive &archive) {
|
||||
_frame = archive.readDWORD();
|
||||
_volume = archive.readDWORD();
|
||||
assert(_volume <= 100);
|
||||
_sfxName = archive.readString();
|
||||
_sprite = (ActionPlayWithSfx *)archive.readObject();
|
||||
}
|
||||
|
||||
void ActionSfx::toConsole() const {
|
||||
debugC(6, kPinkDebugLoadingObjects, "\t\tActionSfx: _sfx = %s, _volume = %u, _frame = %u", _sfxName.c_str(), _volume, _frame);
|
||||
}
|
||||
|
||||
void ActionSfx::play() {
|
||||
Page *page = _sprite->getActor()->getPage();
|
||||
if (!_sound.isPlaying()) {
|
||||
debugC(kPinkDebugActions, "ActionSfx %s of %s is now playing", _sfxName.c_str(), _sprite->getName().c_str());
|
||||
int8 balance = (_sprite->getDecoder()->getCenter().x * 396875 / 1000000) - 127;
|
||||
_sound.play(page->getResourceStream(_sfxName), Audio::Mixer::kSFXSoundType, _volume, balance);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionSfx::end() {
|
||||
_sound.stop();
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
77
engines/pink/objects/actions/action_play_with_sfx.h
Normal file
77
engines/pink/objects/actions/action_play_with_sfx.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_ACTION_PLAY_WITH_SFX_H
|
||||
#define PINK_ACTION_PLAY_WITH_SFX_H
|
||||
|
||||
#include "pink/objects/actions/action_play.h"
|
||||
#include "pink/sound.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class ActionSfx;
|
||||
|
||||
class ActionPlayWithSfx : public ActionPlay {
|
||||
public:
|
||||
ActionPlayWithSfx()
|
||||
: _isLoop(false) {}
|
||||
~ActionPlayWithSfx() override;
|
||||
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
void toConsole() const override;
|
||||
|
||||
void update() override;
|
||||
|
||||
void end() override;
|
||||
|
||||
protected:
|
||||
void onStart() override;
|
||||
|
||||
private:
|
||||
Array<ActionSfx *> _sfxArray;
|
||||
bool _isLoop;
|
||||
};
|
||||
|
||||
class Page;
|
||||
|
||||
class ActionSfx : public Object {
|
||||
public:
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
void toConsole() const override;
|
||||
|
||||
void play();
|
||||
void end();
|
||||
|
||||
int32 getFrame() { return _frame; }
|
||||
|
||||
private:
|
||||
ActionPlayWithSfx *_sprite;
|
||||
Common::String _sfxName;
|
||||
Sound _sound;
|
||||
byte _volume;
|
||||
int32 _frame;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
86
engines/pink/objects/actions/action_sound.cpp
Normal file
86
engines/pink/objects/actions/action_sound.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/debug.h"
|
||||
|
||||
#include "pink/archive.h"
|
||||
#include "pink/pink.h"
|
||||
#include "pink/screen.h"
|
||||
#include "pink/sound.h"
|
||||
#include "pink/objects/actions/action_sound.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
#include "pink/objects/pages/game_page.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
ActionSound::~ActionSound() {
|
||||
end();
|
||||
}
|
||||
|
||||
void ActionSound::deserialize(Archive &archive) {
|
||||
Action::deserialize(archive);
|
||||
_fileName = archive.readString();
|
||||
_volume = archive.readDWORD();
|
||||
assert(_volume <= 100);
|
||||
_isLoop = (bool)archive.readDWORD();
|
||||
_isBackground = (bool)archive.readDWORD();
|
||||
}
|
||||
|
||||
void ActionSound::toConsole() const {
|
||||
debugC(6, kPinkDebugLoadingObjects, "\tActionSound: _name = %s, _fileName = %s, _volume = %u, _isLoop = %u,"
|
||||
" _isBackground = %u", _name.c_str(), _fileName.c_str(), _volume, _isLoop, _isBackground);
|
||||
}
|
||||
|
||||
void ActionSound::start() {
|
||||
Audio::Mixer::SoundType soundType = _isBackground ? Audio::Mixer::kMusicSoundType : Audio::Mixer::kSFXSoundType;
|
||||
|
||||
Page *page = _actor->getPage();
|
||||
if (!_isLoop) {
|
||||
Screen *screen = page->getGame()->getScreen();
|
||||
screen->addSound(this);
|
||||
} else
|
||||
_actor->endAction();
|
||||
|
||||
_sound.play(page->getResourceStream(_fileName), soundType, _volume, 0, _isLoop);
|
||||
|
||||
debugC(6, kPinkDebugActions, "Actor %s has now ActionSound %s", _actor->getName().c_str(), _name.c_str());
|
||||
}
|
||||
|
||||
void ActionSound::end() {
|
||||
_sound.stop();
|
||||
if (!_isLoop) {
|
||||
Screen *screen = _actor->getPage()->getGame()->getScreen();
|
||||
screen->removeSound(this);
|
||||
}
|
||||
|
||||
debugC(6, kPinkDebugActions, "ActionSound %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
|
||||
}
|
||||
|
||||
void ActionSound::update() {
|
||||
if (!_sound.isPlaying())
|
||||
_actor->endAction();
|
||||
}
|
||||
|
||||
void ActionSound::pause(bool paused) {
|
||||
_sound.pause(paused);
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
54
engines/pink/objects/actions/action_sound.h
Normal file
54
engines/pink/objects/actions/action_sound.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_ACTION_SOUND_H
|
||||
#define PINK_ACTION_SOUND_H
|
||||
|
||||
#include "pink/objects/actions/action.h"
|
||||
#include "pink/sound.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class ActionSound : public Action {
|
||||
public:
|
||||
~ActionSound() override;
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
void toConsole() const override;
|
||||
|
||||
void start() override;
|
||||
void end() override;
|
||||
|
||||
void update();
|
||||
|
||||
void pause(bool paused) override;
|
||||
|
||||
private:
|
||||
Common::String _fileName;
|
||||
Sound _sound;
|
||||
byte _volume;
|
||||
bool _isLoop;
|
||||
bool _isBackground;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
74
engines/pink/objects/actions/action_still.cpp
Normal file
74
engines/pink/objects/actions/action_still.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/debug.h"
|
||||
|
||||
#include "pink/archive.h"
|
||||
#include "pink/cel_decoder.h"
|
||||
#include "pink/pink.h"
|
||||
#include "pink/objects/actions/action_still.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
void ActionStill::deserialize(Archive &archive) {
|
||||
ActionCEL::deserialize(archive);
|
||||
_startFrame = archive.readDWORD();
|
||||
}
|
||||
|
||||
void ActionStill::toConsole() const {
|
||||
debugC(6, kPinkDebugLoadingObjects, "\tActionStill: _name = %s, _fileName = %s, _z =%u _startFrame = %u",
|
||||
_name.c_str(), _fileName.c_str(), _z, _startFrame);
|
||||
}
|
||||
|
||||
void ActionStill::end() {
|
||||
ActionCEL::end();
|
||||
debugC(6, kPinkDebugActions, "ActionStill %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
|
||||
}
|
||||
|
||||
void ActionStill::pause(bool paused) {}
|
||||
|
||||
void ActionStill::onStart() {
|
||||
debugC(6, kPinkDebugActions, "Actor %s has now ActionStill %s", _actor->getName().c_str(), _name.c_str());
|
||||
|
||||
if (_startFrame >= _decoder.getFrameCount())
|
||||
_startFrame = 0;
|
||||
|
||||
setFrame(_startFrame);
|
||||
|
||||
_decoder.setEndOfTrack();
|
||||
assert(!_decoder.needsUpdate());
|
||||
|
||||
_actor->endAction();
|
||||
}
|
||||
|
||||
void ActionStill::setFrame(uint frame) {
|
||||
ActionCEL::setFrame(frame);
|
||||
decodeNext();
|
||||
}
|
||||
|
||||
void ActionStill::nextFrameLooped() {
|
||||
if (_decoder.getFrameCount() != 0) {
|
||||
setFrame((_decoder.getCurFrame() + 1) % _decoder.getFrameCount());
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
51
engines/pink/objects/actions/action_still.h
Normal file
51
engines/pink/objects/actions/action_still.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_ACTION_STILL_H
|
||||
#define PINK_ACTION_STILL_H
|
||||
|
||||
#include "pink/objects/actions/action_cel.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class ActionStill : public ActionCEL {
|
||||
public:
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
void toConsole() const override;
|
||||
|
||||
void end() override;
|
||||
|
||||
void pause(bool paused) override;
|
||||
|
||||
void setFrame(uint frame);
|
||||
|
||||
void nextFrameLooped();
|
||||
|
||||
protected:
|
||||
void onStart() override;
|
||||
|
||||
uint32 _startFrame;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
68
engines/pink/objects/actions/action_talk.cpp
Normal file
68
engines/pink/objects/actions/action_talk.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pink/archive.h"
|
||||
#include "pink/cel_decoder.h"
|
||||
#include "pink/pink.h"
|
||||
#include "pink/sound.h"
|
||||
#include "pink/objects/actions/action_talk.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
#include "pink/objects/pages/game_page.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
void ActionTalk::deserialize(Archive &archive) {
|
||||
ActionLoop::deserialize(archive);
|
||||
_vox = archive.readString();
|
||||
}
|
||||
|
||||
void ActionTalk::toConsole() const {
|
||||
debugC(6, kPinkDebugLoadingObjects, "\tActionTalk: _name = %s, _fileName = %s, z = %u, _startFrame = %u,"
|
||||
" _endFrame = %d, _intro = %u, _style = %u, _vox = %s",
|
||||
_name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame, _intro, _style, _vox.c_str());
|
||||
}
|
||||
|
||||
void ActionTalk::update() {
|
||||
ActionLoop::update();
|
||||
if (!_sound.isPlaying()) {
|
||||
_decoder.setEndOfTrack();
|
||||
assert(!_decoder.needsUpdate());
|
||||
_actor->endAction();
|
||||
}
|
||||
}
|
||||
|
||||
void ActionTalk::end() {
|
||||
ActionPlay::end();
|
||||
_sound.stop();
|
||||
}
|
||||
|
||||
void ActionTalk::pause(bool paused) {
|
||||
ActionCEL::pause(paused);
|
||||
_sound.pause(paused);
|
||||
}
|
||||
|
||||
void ActionTalk::onStart() {
|
||||
ActionLoop::onStart();
|
||||
int8 balance = (_decoder.getCenter().x * 51 - 16160) / 320;
|
||||
_sound.play(_actor->getPage()->getResourceStream(_vox), Audio::Mixer::kSpeechSoundType, 100, balance);
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
54
engines/pink/objects/actions/action_talk.h
Normal file
54
engines/pink/objects/actions/action_talk.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_ACTION_TALK_H
|
||||
#define PINK_ACTION_TALK_H
|
||||
|
||||
#include "pink/objects/actions/action_loop.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class Sound;
|
||||
|
||||
class ActionTalk : public ActionLoop {
|
||||
public:
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
void toConsole() const override;
|
||||
|
||||
void update() override;
|
||||
|
||||
void end() override;
|
||||
|
||||
void pause(bool paused) override;
|
||||
|
||||
protected:
|
||||
void onStart() override;
|
||||
bool isTalk() override { return true; }
|
||||
|
||||
private:
|
||||
Common::String _vox;
|
||||
Sound _sound;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
219
engines/pink/objects/actions/action_text.cpp
Normal file
219
engines/pink/objects/actions/action_text.cpp
Normal file
@@ -0,0 +1,219 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/substream.h"
|
||||
#include "common/unicode-bidi.h"
|
||||
|
||||
#include "graphics/paletteman.h"
|
||||
|
||||
#include "pink/archive.h"
|
||||
#include "pink/screen.h"
|
||||
#include "pink/pink.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
#include "pink/objects/actions/action_text.h"
|
||||
#include "pink/objects/pages/page.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
ActionText::ActionText() {
|
||||
_txtWnd = nullptr;
|
||||
_macText = nullptr;
|
||||
|
||||
_xLeft = _xRight = 0;
|
||||
_yTop = _yBottom = 0;
|
||||
|
||||
_centered = 0;
|
||||
_scrollBar = 0;
|
||||
|
||||
_textRGB = 0;
|
||||
_backgroundRGB = 0;
|
||||
|
||||
_textColorIndex = 0;
|
||||
_backgroundColorIndex = 0;
|
||||
}
|
||||
|
||||
ActionText::~ActionText() {
|
||||
end();
|
||||
}
|
||||
|
||||
void ActionText::deserialize(Archive &archive) {
|
||||
Action::deserialize(archive);
|
||||
_fileName = archive.readString();
|
||||
|
||||
_xLeft = archive.readDWORD();
|
||||
_yTop = archive.readDWORD();
|
||||
_xRight = archive.readDWORD();
|
||||
_yBottom = archive.readDWORD();
|
||||
|
||||
_centered = archive.readDWORD();
|
||||
_scrollBar = archive.readDWORD();
|
||||
|
||||
byte r = archive.readByte();
|
||||
byte g = archive.readByte();
|
||||
byte b = archive.readByte();
|
||||
(void)archive.readByte(); // skip Alpha
|
||||
_textRGB = r << 16 | g << 8 | b;
|
||||
|
||||
r = archive.readByte();
|
||||
g = archive.readByte();
|
||||
b = archive.readByte();
|
||||
(void)archive.readByte(); // skip Alpha
|
||||
_backgroundRGB = r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
void ActionText::toConsole() const {
|
||||
debugC(6, kPinkDebugLoadingObjects, "\tActionText: _name = %s, _fileName = %s, "
|
||||
"_xLeft = %u, _yTop = %u, _xRight = %u, _yBottom = %u _centered = %u, _scrollBar = %u, _textColor = %u _backgroundColor = %u",
|
||||
_name.c_str(), _fileName.c_str(), _xLeft, _yTop, _xRight, _yBottom, _centered, _scrollBar, _textRGB, _backgroundRGB);
|
||||
}
|
||||
|
||||
void ActionText::start() {
|
||||
findColorsInPalette();
|
||||
Screen *screen = _actor->getPage()->getGame()->getScreen();
|
||||
Graphics::TextAlign align = _centered ? Graphics::kTextAlignCenter : Graphics::kTextAlignLeft;
|
||||
Common::SeekableReadStream *stream = _actor->getPage()->getResourceStream(_fileName);
|
||||
|
||||
char *str = new char[stream->size()];
|
||||
stream->read(str, stream->size());
|
||||
delete stream;
|
||||
|
||||
Common::Language language = _actor->getPage()->getGame()->getLanguage();
|
||||
screen->getWndManager()._language = language;
|
||||
switch(language) {
|
||||
case Common::DA_DNK:
|
||||
// fall through
|
||||
case Common::ES_ESP:
|
||||
// fall through
|
||||
case Common::FR_FRA:
|
||||
// fall through
|
||||
case Common::PT_BRA:
|
||||
// fall through
|
||||
case Common::DE_DEU:
|
||||
// fall through
|
||||
case Common::IT_ITA:
|
||||
// fall through
|
||||
case Common::NL_NLD:
|
||||
_text = Common::String(str).decode(Common::kWindows1252);
|
||||
break;
|
||||
|
||||
case Common::FI_FIN:
|
||||
// fall through
|
||||
case Common::SV_SWE:
|
||||
_text = Common::String(str).decode(Common::kWindows1257);
|
||||
break;
|
||||
|
||||
case Common::HE_ISR:
|
||||
_text = Common::String(str).decode(Common::kWindows1255);
|
||||
if (!_centered) {
|
||||
align = Graphics::kTextAlignRight;
|
||||
}
|
||||
break;
|
||||
|
||||
case Common::PL_POL:
|
||||
_text = Common::String(str).decode(Common::kWindows1250);
|
||||
break;
|
||||
|
||||
case Common::RU_RUS:
|
||||
_text = Common::String(str).decode(Common::kWindows1251);
|
||||
break;
|
||||
|
||||
case Common::EN_GRB:
|
||||
// fall through
|
||||
case Common::EN_ANY:
|
||||
// fall through
|
||||
default:
|
||||
_text = Common::String(str);
|
||||
break;
|
||||
}
|
||||
|
||||
_text.trim();
|
||||
delete[] str;
|
||||
|
||||
while ( _text.size() > 0 && (_text[ _text.size() - 1 ] == '\n' || _text[ _text.size() - 1 ] == '\r') )
|
||||
_text.deleteLastChar();
|
||||
|
||||
if (_scrollBar) {
|
||||
_txtWnd = screen->getWndManager().addTextWindow(screen->getTextFont(), _textColorIndex, _backgroundColorIndex,
|
||||
_xRight - _xLeft, align, nullptr);
|
||||
_txtWnd->setTextColorRGB(_textRGB);
|
||||
_txtWnd->enableScrollbar(true);
|
||||
// it will hide the scrollbar when the text height is smaller than the window height
|
||||
_txtWnd->setMode(Graphics::kWindowModeDynamicScrollbar);
|
||||
_txtWnd->move(_xLeft, _yTop);
|
||||
_txtWnd->resize(_xRight - _xLeft, _yBottom - _yTop);
|
||||
_txtWnd->setEditable(false);
|
||||
_txtWnd->setSelectable(false);
|
||||
|
||||
_txtWnd->appendText(_text);
|
||||
screen->addTextWindow(_txtWnd);
|
||||
|
||||
} else {
|
||||
screen->addTextAction(this);
|
||||
|
||||
_macText = new Graphics::MacText(_text, &screen->getWndManager(), screen->getTextFont(), _textColorIndex, _backgroundColorIndex, _xRight - _xLeft, align);
|
||||
}
|
||||
}
|
||||
|
||||
Common::Rect ActionText::getBound() {
|
||||
return Common::Rect(_xLeft, _yTop, _xRight, _yBottom);
|
||||
}
|
||||
|
||||
void ActionText::end() {
|
||||
Screen *screen = _actor->getPage()->getGame()->getScreen();
|
||||
screen->addDirtyRect(this->getBound());
|
||||
if (_scrollBar && _txtWnd) {
|
||||
screen->getWndManager().removeWindow(_txtWnd);
|
||||
screen->removeTextWindow(_txtWnd);
|
||||
_txtWnd = nullptr;
|
||||
} else {
|
||||
screen->removeTextAction(this);
|
||||
delete _macText;
|
||||
}
|
||||
}
|
||||
|
||||
void ActionText::draw(Graphics::ManagedSurface *surface) {
|
||||
int yOffset = 0;
|
||||
// we need to first fill this area with backgroundColor, in order to wash away the previous text
|
||||
surface->fillRect(Common::Rect(_xLeft, _yTop, _xRight, _yBottom), _backgroundColorIndex);
|
||||
|
||||
if (_centered) {
|
||||
yOffset = (_yBottom - _yTop) / 2 - _macText->getTextHeight() / 2;
|
||||
}
|
||||
_macText->drawToPoint(surface, Common::Rect(0, 0, _xRight - _xLeft, _yBottom - _yTop), Common::Point(_xLeft, _yTop + yOffset));
|
||||
}
|
||||
|
||||
#define BLUE(rgb) ((rgb) & 0xFF)
|
||||
#define GREEN(rgb) (((rgb) >> 8) & 0xFF)
|
||||
#define RED(rgb) (((rgb) >> 16) & 0xFF)
|
||||
|
||||
void ActionText::findColorsInPalette() {
|
||||
byte palette[256 * 3];
|
||||
g_system->getPaletteManager()->grabPalette(palette, 0, 256);
|
||||
g_paletteLookup->setPalette(palette, 256);
|
||||
|
||||
debug(2, "textcolorindex: %06x", _textRGB);
|
||||
_textColorIndex = g_paletteLookup->findBestColor(RED(_textRGB), GREEN(_textRGB), BLUE(_textRGB));
|
||||
debug(2, "backgroundColorIndex: %06x", _backgroundRGB);
|
||||
_backgroundColorIndex = g_paletteLookup->findBestColor(RED(_backgroundRGB), GREEN(_backgroundRGB), BLUE(_backgroundRGB));
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
77
engines/pink/objects/actions/action_text.h
Normal file
77
engines/pink/objects/actions/action_text.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_ACTION_TEXT_H
|
||||
#define PINK_ACTION_TEXT_H
|
||||
|
||||
#include "common/events.h"
|
||||
|
||||
#include "graphics/macgui/macwindow.h"
|
||||
#include "graphics/macgui/macmenu.h"
|
||||
#include "graphics/macgui/mactextwindow.h"
|
||||
|
||||
#include "pink/objects/actions/action.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class ActionText : public Action {
|
||||
public:
|
||||
ActionText();
|
||||
~ActionText() override;
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
void toConsole() const override;
|
||||
|
||||
void start() override;
|
||||
void end() override;
|
||||
|
||||
void draw(Graphics::ManagedSurface *surface); // only for non-scrollable text
|
||||
|
||||
Common::Rect getBound();
|
||||
|
||||
private:
|
||||
|
||||
void findColorsInPalette();
|
||||
void loadBorder(Graphics::MacWindow *target, Common::String filename, uint32 flags);
|
||||
|
||||
private:
|
||||
Common::String _fileName;
|
||||
Common::U32String _text;
|
||||
Graphics::MacTextWindow *_txtWnd;
|
||||
Graphics::MacText *_macText;
|
||||
|
||||
uint32 _xLeft;
|
||||
uint32 _yTop;
|
||||
uint32 _xRight;
|
||||
uint32 _yBottom;
|
||||
|
||||
uint32 _centered;
|
||||
uint32 _scrollBar;
|
||||
uint32 _textRGB;
|
||||
uint32 _backgroundRGB;
|
||||
|
||||
byte _textColorIndex;
|
||||
byte _backgroundColorIndex;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
93
engines/pink/objects/actions/walk_action.cpp
Normal file
93
engines/pink/objects/actions/walk_action.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pink/archive.h"
|
||||
#include "pink/cel_decoder.h"
|
||||
#include "pink/pink.h"
|
||||
#include "pink/objects/actions/walk_action.h"
|
||||
#include "pink/objects/actors/actor.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
void WalkAction::deserialize(Archive &archive) {
|
||||
ActionCEL::deserialize(archive);
|
||||
uint32 calcFramePositions = archive.readDWORD();
|
||||
_toCalcFramePositions = calcFramePositions;
|
||||
}
|
||||
|
||||
void WalkAction::toConsole() const {
|
||||
debugC(6, kPinkDebugLoadingObjects, "\tWalkAction: _name = %s, _fileName = %s, _calcFramePositions = %u",
|
||||
_name.c_str(), _fileName.c_str(), _toCalcFramePositions);
|
||||
}
|
||||
|
||||
void WalkAction::onStart() {
|
||||
if (_toCalcFramePositions) {
|
||||
_start = _mgr->getStartCoords().point;
|
||||
_end = _mgr->getEndCoords().point;
|
||||
|
||||
if (!_horizontal) {
|
||||
_end.y = getCoordinates().point.y;
|
||||
_start.y = _end.y;
|
||||
_frameCount = _decoder.getFrameCount();
|
||||
}
|
||||
else {
|
||||
_frameCount = (uint)abs(3 * (_start.x - _end.x) / (int)_z);
|
||||
if (!_frameCount)
|
||||
_frameCount = 1;
|
||||
}
|
||||
setCenter(_start);
|
||||
_curFrame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void WalkAction::update() {
|
||||
if (_toCalcFramePositions) {
|
||||
if (_curFrame < _frameCount)
|
||||
_curFrame++;
|
||||
const double k = _curFrame / (double) _frameCount;
|
||||
Common::Point newCenter;
|
||||
newCenter.x = (_end.x - _start.x) * k + _start.x;
|
||||
if (_horizontal) {
|
||||
newCenter.y = (_end.y - _start.y) * k + _start.y;
|
||||
} else {
|
||||
newCenter.y = getCoordinates().point.y;
|
||||
}
|
||||
if (_decoder.getCurFrame() < (int)_decoder.getFrameCount() - 1)
|
||||
decodeNext();
|
||||
else {
|
||||
setFrame(0);
|
||||
}
|
||||
setCenter(newCenter);
|
||||
if (_curFrame >= _frameCount - 1) {
|
||||
_decoder.setEndOfTrack();
|
||||
_actor->endAction();
|
||||
}
|
||||
} else {
|
||||
if (_decoder.getCurFrame() < (int)_decoder.getFrameCount() - 1)
|
||||
decodeNext();
|
||||
else {
|
||||
_decoder.setEndOfTrack();
|
||||
_actor->endAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
55
engines/pink/objects/actions/walk_action.h
Normal file
55
engines/pink/objects/actions/walk_action.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_WALK_ACTION_H
|
||||
#define PINK_WALK_ACTION_H
|
||||
|
||||
#include "pink/objects/actions/action_cel.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class WalkAction : public ActionCEL {
|
||||
public:
|
||||
void deserialize(Archive &archive) override;
|
||||
|
||||
void toConsole() const override;
|
||||
|
||||
void update() override;
|
||||
|
||||
void setWalkMgr(WalkMgr *mgr) { _mgr = mgr; }
|
||||
void setType(bool horizontal) { _horizontal = horizontal; }
|
||||
|
||||
protected:
|
||||
void onStart() override;
|
||||
|
||||
private:
|
||||
WalkMgr *_mgr;
|
||||
Common::Point _start;
|
||||
Common::Point _end;
|
||||
uint _curFrame;
|
||||
uint _frameCount;
|
||||
bool _horizontal;
|
||||
bool _toCalcFramePositions;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user