mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-25 04:01:03 +00:00
EMI: Implemented PlayChore and PauseChore.
This commit is contained in:
parent
95c4650706
commit
765ecf7870
@ -32,7 +32,7 @@ namespace Grim {
|
||||
|
||||
// Should initialize the status variables so the chore can't play unexpectedly
|
||||
Chore::Chore(char name[32], int id, Costume *owner, int length, int numTracks) :
|
||||
_hasPlayed(false), _playing(false), _looping(false), _currTime(-1),
|
||||
_hasPlayed(false), _playing(false), _looping(false), _paused(false), _currTime(-1),
|
||||
_numTracks(numTracks), _length(length), _choreId(id), _owner(owner) {
|
||||
|
||||
memcpy(_name, name, 32);
|
||||
@ -65,6 +65,7 @@ void Chore::load(TextSplitter &ts) {
|
||||
|
||||
void Chore::play(uint msecs) {
|
||||
_playing = true;
|
||||
_paused = false;
|
||||
_hasPlayed = true;
|
||||
_looping = false;
|
||||
_currTime = -1;
|
||||
@ -77,6 +78,7 @@ void Chore::play(uint msecs) {
|
||||
|
||||
void Chore::playLooping(uint msecs) {
|
||||
_playing = true;
|
||||
_paused = false;
|
||||
_hasPlayed = true;
|
||||
_looping = true;
|
||||
_currTime = -1;
|
||||
@ -137,6 +139,7 @@ void Chore::setLastFrame() {
|
||||
|
||||
_currTime = -1;
|
||||
_playing = false;
|
||||
_paused = false;
|
||||
_hasPlayed = true;
|
||||
_looping = false;
|
||||
|
||||
@ -148,7 +151,7 @@ void Chore::setLastFrame() {
|
||||
}
|
||||
|
||||
void Chore::update(uint time) {
|
||||
if (!_playing)
|
||||
if (!_playing || _paused)
|
||||
return;
|
||||
|
||||
int newTime;
|
||||
@ -202,6 +205,17 @@ void Chore::fadeOut(uint msecs) {
|
||||
fade(Animation::FadeOut, msecs);
|
||||
}
|
||||
|
||||
void Chore::setPaused(bool paused) {
|
||||
_paused = paused;
|
||||
|
||||
for (int i = 0; i < _numTracks; i++) {
|
||||
Component *comp = getComponentForTrack(i);
|
||||
if (comp) {
|
||||
comp->setPaused(paused);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Chore::advance(uint msecs) {
|
||||
setKeys(_currTime, _currTime + msecs);
|
||||
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
void setLastFrame();
|
||||
void fadeIn(uint msecs);
|
||||
void fadeOut(uint msecs);
|
||||
void setPaused(bool paused);
|
||||
|
||||
bool isPlaying() { return _playing; }
|
||||
bool isLooping() { return _looping; }
|
||||
@ -84,7 +85,7 @@ protected:
|
||||
ChoreTrack *_tracks;
|
||||
char _name[32];
|
||||
|
||||
bool _hasPlayed, _playing, _looping;
|
||||
bool _hasPlayed, _playing, _looping, _paused;
|
||||
int _currTime;
|
||||
|
||||
friend class EMICostume;
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
virtual void reset() { }
|
||||
virtual void fade(Animation::FadeMode, int) { }
|
||||
virtual void advance(uint msecs) { }
|
||||
virtual void setPaused(bool paused) { }
|
||||
virtual void resetColormap() { }
|
||||
virtual void saveState(SaveGame *) { }
|
||||
virtual void restoreState(SaveGame *) { }
|
||||
|
@ -294,8 +294,8 @@ void AnimationStateEmi::stop() {
|
||||
deactivate();
|
||||
}
|
||||
|
||||
void AnimationStateEmi::pause() {
|
||||
_paused = true;
|
||||
void AnimationStateEmi::setPaused(bool paused) {
|
||||
_paused = paused;
|
||||
}
|
||||
|
||||
void AnimationStateEmi::setLooping(bool loop) {
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
void update(uint time);
|
||||
void play();
|
||||
void stop();
|
||||
void pause();
|
||||
void setPaused(bool paused);
|
||||
void setLooping(bool loop);
|
||||
void setSkeleton(Skeleton *skel);
|
||||
void fade(Animation::FadeMode mode, int fadeLength);
|
||||
|
@ -64,7 +64,7 @@ void EMIAnimComponent::setKey(int f) {
|
||||
_animState->play();
|
||||
break;
|
||||
case 2: // Pause
|
||||
_animState->pause();
|
||||
_animState->setPaused(true);
|
||||
break;
|
||||
case 3: // Loop
|
||||
_animState->setLooping(true);
|
||||
@ -121,6 +121,10 @@ void EMIAnimComponent::advance(uint msecs) {
|
||||
_animState->advance(msecs);
|
||||
}
|
||||
|
||||
void EMIAnimComponent::setPaused(bool paused) {
|
||||
_animState->setPaused(paused);
|
||||
}
|
||||
|
||||
void EMIAnimComponent::draw() {
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
void reset();
|
||||
void fade(Animation::FadeMode mode, int fadeLength);
|
||||
void advance(uint msecs);
|
||||
void setPaused(bool paused);
|
||||
void draw();
|
||||
|
||||
private:
|
||||
|
@ -42,7 +42,7 @@ void EMIChore::addComponent(Component *component) {
|
||||
}
|
||||
|
||||
void EMIChore::update(uint time) {
|
||||
if (!_playing)
|
||||
if (!_playing || _paused)
|
||||
return;
|
||||
|
||||
if (_fadeMode != Animation::None) {
|
||||
|
@ -307,7 +307,11 @@ void Lua_V2::PlayChore() {
|
||||
if (!lua_isuserdata(choreObj) || lua_tag(choreObj) != MKTAG('C','H','O','R'))
|
||||
return;
|
||||
int chore = lua_getuserdata(choreObj);
|
||||
warning("Lua_V2::PlayChore: stub, chore: %d", chore);
|
||||
|
||||
Chore *c = EMIChore::getPool().getObject(chore);
|
||||
if (c) {
|
||||
c->setPaused(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Lua_V2::PauseChore() {
|
||||
@ -316,7 +320,11 @@ void Lua_V2::PauseChore() {
|
||||
if (!lua_isuserdata(choreObj) || lua_tag(choreObj) != MKTAG('C','H','O','R'))
|
||||
return;
|
||||
int chore = lua_getuserdata(choreObj);
|
||||
warning("Lua_V2::PauseChore: stub, chore: %d", chore);
|
||||
|
||||
Chore *c = EMIChore::getPool().getObject(chore);
|
||||
if (c) {
|
||||
c->setPaused(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Lua_V2::StopChore() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user