mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-24 19:45:07 +00:00
PETKA: implemented update method for QObject
This commit is contained in:
parent
06d99e210f
commit
48a8318285
@ -29,6 +29,7 @@
|
||||
#include "graphics/surface.h"
|
||||
|
||||
#include "petka/flc.h"
|
||||
#include "petka/sound.h"
|
||||
#include "petka/petka.h"
|
||||
#include "petka/video.h"
|
||||
#include "petka/q_system.h"
|
||||
@ -43,7 +44,7 @@ QVisibleObject::QVisibleObject()
|
||||
: _resourceId(-1), _z(240) {}
|
||||
|
||||
QMessageObject::QMessageObject()
|
||||
: _id(-1), _dialogColor(-1), _time(0) {}
|
||||
: _id(-1), _dialogColor(-1), _time(0), _sound(nullptr) {}
|
||||
|
||||
void QMessageObject::processMessage(const QMessage &msg) {
|
||||
for (uint i = 0; i < _reactions.size(); ++i) {
|
||||
@ -103,7 +104,7 @@ void QMessageObject::processMessage(const QMessage &msg) {
|
||||
|
||||
break;
|
||||
case kStatus:
|
||||
_status = (int8) msg.arg1;
|
||||
_status = (int8)msg.arg1;
|
||||
break;
|
||||
case kOn:
|
||||
_isActive = true;
|
||||
@ -150,6 +151,13 @@ void QObject::draw() {
|
||||
if (!flc) {
|
||||
return;
|
||||
}
|
||||
if (_animate && _startSound) {
|
||||
if (_sound) {
|
||||
_sound->play(!_notLoopedSound);
|
||||
_startSound = false;
|
||||
}
|
||||
}
|
||||
|
||||
Common::Rect screen(640, 480);
|
||||
Common::Rect dest(flc->getBounds());
|
||||
//flcRect.translate(_x, _y);
|
||||
@ -203,4 +211,31 @@ void QObject::show(bool v) {
|
||||
QMessageObject::show(v);
|
||||
}
|
||||
|
||||
void QObject::update(int time) {
|
||||
if (!_animate || !_isShown)
|
||||
return;
|
||||
_time += time;
|
||||
FlicDecoder *flc = g_vm->resMgr()->loadFlic(_resourceId);
|
||||
if (flc) {
|
||||
while (_time > flc->getDelay()) {
|
||||
if (_sound && _hasSound && flc->getCurFrame() == 0) {
|
||||
_startSound = true;
|
||||
_hasSound = false;
|
||||
}
|
||||
g_vm->videoSystem()->addDirtyRect(Common::Point(_x, _y), *flc);
|
||||
flc->setFrame(-1);
|
||||
if (flc->getCurFrame() == flc->getFrameCount() - 1) {
|
||||
if (_notLoopedSound) {
|
||||
_hasSound = _sound != nullptr;
|
||||
}
|
||||
g_vm->getQSystem()->addMessage(_id, kEnd, _resourceId, 0, 0, 0, 0);
|
||||
}
|
||||
if (flc->getCurFrame() + 1 == flc->getFrameCount() / 2) {
|
||||
g_vm->getQSystem()->addMessage(_id, kHalf, _resourceId, 0, 0, 0, 0);
|
||||
}
|
||||
_time -= flc->getDelay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -43,6 +43,7 @@ public:
|
||||
int32 _z;
|
||||
};
|
||||
|
||||
class Sound;
|
||||
|
||||
class QMessageObject : public QVisibleObject {
|
||||
public:
|
||||
@ -66,8 +67,9 @@ public:
|
||||
int _field_38;
|
||||
int _isActive;
|
||||
int _startSound;
|
||||
int _field_44;
|
||||
int _hasSound;
|
||||
int _notLoopedSound;
|
||||
Sound *_sound;
|
||||
int8 _status;
|
||||
uint16 _id;
|
||||
Common::String _name;
|
||||
@ -80,6 +82,7 @@ public:
|
||||
class QObject : public QMessageObject {
|
||||
public:
|
||||
void draw() override;
|
||||
void update(int time) override;
|
||||
void updateZ() override;
|
||||
bool isInPoint(int x, int y) override;
|
||||
void show(bool v) override;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "audio/mixer.h"
|
||||
|
||||
#include "common/hash-str.h"
|
||||
#include "common/ptr.h"
|
||||
|
||||
namespace Common {
|
||||
class SeekableReadStream;
|
||||
|
Loading…
x
Reference in New Issue
Block a user