aboutsummaryrefslogtreecommitdiff
path: root/engines/pink
diff options
context:
space:
mode:
authorwhiterandrek2018-03-27 19:20:09 +0300
committerEugene Sandulenko2018-06-28 23:51:32 +0200
commit7168242832e8bd71e0e2a2617f6e8e6e56e6cd8e (patch)
tree7f59df4980101eb6df92e4b431b0c9093f1e20cb /engines/pink
parentdbc709a140fc2d01d35dcd3515c45ea9621fe18b (diff)
downloadscummvm-rg350-7168242832e8bd71e0e2a2617f6e8e6e56e6cd8e.tar.gz
scummvm-rg350-7168242832e8bd71e0e2a2617f6e8e6e56e6cd8e.tar.bz2
scummvm-rg350-7168242832e8bd71e0e2a2617f6e8e6e56e6cd8e.zip
PINK: small fixes and implemented skipping of sequence by buttons
Diffstat (limited to 'engines/pink')
-rw-r--r--engines/pink/archive.cpp4
-rw-r--r--engines/pink/file.cpp19
-rw-r--r--engines/pink/file.h9
-rw-r--r--engines/pink/objects/actions/action_sound.cpp19
-rw-r--r--engines/pink/objects/actions/action_sound.h2
-rw-r--r--engines/pink/objects/actors/actor.h2
-rw-r--r--engines/pink/objects/actors/lead_actor.cpp11
-rw-r--r--engines/pink/objects/actors/lead_actor.h3
-rw-r--r--engines/pink/objects/module.cpp3
-rw-r--r--engines/pink/objects/sequences/sequence_context.cpp8
-rw-r--r--engines/pink/objects/sequences/sequence_context.h2
-rw-r--r--engines/pink/objects/sequences/sequencer.cpp5
-rw-r--r--engines/pink/objects/sequences/sequencer.h1
-rw-r--r--engines/pink/pink.cpp2
-rw-r--r--engines/pink/pink.h2
15 files changed, 62 insertions, 30 deletions
diff --git a/engines/pink/archive.cpp b/engines/pink/archive.cpp
index 6bd29596c4..919d5fc797 100644
--- a/engines/pink/archive.cpp
+++ b/engines/pink/archive.cpp
@@ -308,7 +308,7 @@ Object *Archive::readObject() {
Object *Archive::parseObject(bool &isCopyReturned) {
char className[kMaxClassLength];
int objectId = 0;
- Object *res = 0;
+ Object *res = nullptr;
uint obTag = _file.readUint16LE();
@@ -355,7 +355,7 @@ Object *Archive::parseObject(bool &isCopyReturned) {
}
uint Archive::findObjectId(const char *name) {
- RuntimeClass * found = static_cast<RuntimeClass*>
+ RuntimeClass *found = static_cast<RuntimeClass*>
(bsearch(name, classMap, sizeof(classMap) / sizeof(RuntimeClass) , sizeof(RuntimeClass), [] (const void *a, const void *b) {
return strcmp((const char *) a, *(const char **) b);
}));
diff --git a/engines/pink/file.cpp b/engines/pink/file.cpp
index d5e9059a94..2c27dab2d4 100644
--- a/engines/pink/file.cpp
+++ b/engines/pink/file.cpp
@@ -30,13 +30,7 @@ OrbFile::OrbFile()
: File(), _timestamp(0),
_tableOffset(0),
_tableSize(0),
- _table(nullptr)
-{
- debug("Object Description size: %u", sizeof(ObjectDescription));
- debug("Resource Description size: %u", sizeof(ResourceDescription));
- debug("OrbFile size: %lu", sizeof(OrbFile));
- debug("BroFile size: %lu", sizeof(BroFile));
-}
+ _table(nullptr) {}
OrbFile::~OrbFile() {
delete[] _table;
@@ -69,13 +63,10 @@ bool OrbFile::open(const Common::String &name) {
_tableSize = readUint32LE();
_table = new ObjectDescription[_tableSize];
- debug("Orb has %u object descriptions", _tableSize);
-
seek(_tableOffset);
for (size_t i = 0; i < _tableSize; ++i) {
_table[i].load(*this);
- debug("Object description %s loaded", _table[i].name);
}
return true;
@@ -83,10 +74,8 @@ bool OrbFile::open(const Common::String &name) {
void OrbFile::loadGame(PinkEngine *game) {
seekToObject("PinkGame");
-
Archive archive(*this);
archive.mapObject((Object *) game); // hack
-
game->load(archive);
}
@@ -126,7 +115,7 @@ ResourceDescription *OrbFile::getResDescTable(ObjectDescription *objDesc){
seek(objDesc->resourcesOffset);
ResourceDescription *table = new ResourceDescription[size];
- for (uint i = 0; i < size; ++i) {
+ for (size_t i = 0; i < size; ++i) {
table[i].load(*this);
}
@@ -143,7 +132,7 @@ bool BroFile::open(Common::String &name, uint32 orbTimestamp) {
debug("Bro v%hu.%hu loaded", major, minor);
- if (minor || major != 1){
+ if (major != 1 || minor != 0){
return false;
}
@@ -167,7 +156,7 @@ void ResourceDescription::load(Common::File &file) {
uint16 temp;
file.read(&temp, sizeof(temp));
- inBro = temp;
+ inBro = (bool) temp;
}
} // End of namespace Pink \ No newline at end of file
diff --git a/engines/pink/file.h b/engines/pink/file.h
index 36a6af2026..ddaba37292 100644
--- a/engines/pink/file.h
+++ b/engines/pink/file.h
@@ -44,17 +44,17 @@ struct ResourceDescription {
uint32 offset;
uint32 size;
bool inBro; // in original it is short.
- // Don't know what's better to use.(Perhaps no diffrence because of padding)
+ // Don't know what's better to use.(Perhaps no difference because of padding)
};
class PinkEngine;
+
class Object;
class OrbFile : public Common::File {
public:
OrbFile();
virtual ~OrbFile();
-
virtual bool open(const Common::String &name);
void loadGame(PinkEngine *game);
@@ -67,7 +67,7 @@ public:
uint32 getTimestamp();
private:
- void seekToObject(const char * name);
+ void seekToObject(const char *name);
uint32 _timestamp;
uint32 _tableOffset;
@@ -77,9 +77,6 @@ private:
class BroFile : public Common::File {
public:
- BroFile() = default;
- virtual ~BroFile() = default;
-
virtual bool open(Common::String &name, uint32 orbTimestamp);
};
diff --git a/engines/pink/objects/actions/action_sound.cpp b/engines/pink/objects/actions/action_sound.cpp
index 42d279553b..44dfda45c7 100644
--- a/engines/pink/objects/actions/action_sound.cpp
+++ b/engines/pink/objects/actions/action_sound.cpp
@@ -35,6 +35,10 @@ ActionSound::ActionSound()
: _sound(nullptr), _isStopped(1)
{}
+ActionSound::~ActionSound(){
+ end();
+}
+
void ActionSound::deserialize(Archive &archive) {
Action::deserialize(archive);
archive >> _fileName;
@@ -66,14 +70,17 @@ void ActionSound::start(bool unk) {
}
void ActionSound::end() {
- debug("ActionSound %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
+ if (_sound) {
+ debug("ActionSound %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
- Director *director = _actor->getPage()->getGame()->getDirector();
- director->removeSound(this);
+ Director *director = _actor->getPage()->getGame()->getDirector();
+ director->removeSound(this);
+
+ _sound->stop();
- _sound->stop();
- delete _sound;
- _sound = nullptr;
+ delete _sound;
+ _sound = nullptr;
+ }
}
void ActionSound::update() {
diff --git a/engines/pink/objects/actions/action_sound.h b/engines/pink/objects/actions/action_sound.h
index e4bb2f1822..3c71da454e 100644
--- a/engines/pink/objects/actions/action_sound.h
+++ b/engines/pink/objects/actions/action_sound.h
@@ -32,6 +32,8 @@ class Sound;
class ActionSound : public Action {
public:
ActionSound();
+ ~ActionSound();
+
virtual void deserialize(Archive &archive);
virtual void toConsole();
diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h
index 2dc9769275..1d6fdf4bd4 100644
--- a/engines/pink/objects/actors/actor.h
+++ b/engines/pink/objects/actors/actor.h
@@ -59,7 +59,7 @@ public:
bool initPallete(Director *director);
- void update() {};
+ virtual void update() {};
protected:
GamePage *_page;
diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp
index 55861131d7..7f750e13ad 100644
--- a/engines/pink/objects/actors/lead_actor.cpp
+++ b/engines/pink/objects/actors/lead_actor.cpp
@@ -32,6 +32,7 @@
namespace Pink {
void LeadActor::deserialize(Archive &archive) {
+ _state = kReady;
Actor::deserialize(archive);
_state = kReady;
_cursorMgr = static_cast<CursorMgr*>(archive.readObject());
@@ -79,6 +80,16 @@ void LeadActor::update() {
}
}
+void LeadActor::OnKeyboardButtonClick(Common::KeyCode code) {
+ switch (code) {
+ case Common::KEYCODE_SPACE:
+ case Common::KEYCODE_RIGHT:
+ _sequencer->skipSequence();
+
+ }
+
+}
+
void ParlSqPink::toConsole() {
debug("ParlSqPink: _name = %s", _name.c_str());
for (int i = 0; i < _actions.size(); ++i) {
diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h
index d7c45e02bd..b60e35c95d 100644
--- a/engines/pink/objects/actors/lead_actor.h
+++ b/engines/pink/objects/actors/lead_actor.h
@@ -23,6 +23,7 @@
#ifndef PINK_LEAD_ACTOR_H
#define PINK_LEAD_ACTOR_H
+#include <common/keyboard.h>
#include "actor.h"
namespace Pink {
@@ -44,6 +45,7 @@ public:
kUnk_Loading // ????
};
+
virtual void deserialize(Archive &archive);
virtual void toConsole();
@@ -56,6 +58,7 @@ public:
void start(bool isHandler);
void update();
+ void OnKeyboardButtonClick(Common::KeyCode code);
private:
State _state;
CursorMgr *_cursorMgr;
diff --git a/engines/pink/objects/module.cpp b/engines/pink/objects/module.cpp
index eb6d792c72..f78f290abe 100644
--- a/engines/pink/objects/module.cpp
+++ b/engines/pink/objects/module.cpp
@@ -64,7 +64,10 @@ void Module::changePage(const Common::String &pageName) {
GamePage *page = nullptr;
page = findPage(pageName);
assert(_page != page);
+
//_page->clear
+
+
page->init(kLoadingNewGame);
}
diff --git a/engines/pink/objects/sequences/sequence_context.cpp b/engines/pink/objects/sequences/sequence_context.cpp
index 007213c537..62717d0595 100644
--- a/engines/pink/objects/sequences/sequence_context.cpp
+++ b/engines/pink/objects/sequences/sequence_context.cpp
@@ -71,4 +71,12 @@ SequenceContext::SequenceContext(Sequence *sequence, Sequencer *sequencer)
}
}
+int SequenceContext::getNextItemIndex() const {
+ return _nextItemIndex;
+}
+
+Sequence *SequenceContext::getSequence() const {
+ return _sequence;
+}
+
} // End of namespace Pink \ No newline at end of file
diff --git a/engines/pink/objects/sequences/sequence_context.h b/engines/pink/objects/sequences/sequence_context.h
index 0727127097..47b35ee977 100644
--- a/engines/pink/objects/sequences/sequence_context.h
+++ b/engines/pink/objects/sequences/sequence_context.h
@@ -49,6 +49,8 @@ class SequenceContext {
public:
SequenceContext(Sequence *sequence, Sequencer* sequencer);
+ int getNextItemIndex() const;
+ Sequence *getSequence() const;
public:
Sequence *_sequence;
diff --git a/engines/pink/objects/sequences/sequencer.cpp b/engines/pink/objects/sequences/sequencer.cpp
index fea28e5f52..272065b284 100644
--- a/engines/pink/objects/sequences/sequencer.cpp
+++ b/engines/pink/objects/sequences/sequencer.cpp
@@ -81,4 +81,9 @@ void Sequencer::removeContext(SequenceContext *context) {
_context = 0;
}
+void Sequencer::skipSequence() {
+ if (_context && _context->getNextItemIndex() < _context->getSequence()->getItems().size())
+ _context->getSequence()->start(0);
+}
+
} // End of namespace Pink \ No newline at end of file
diff --git a/engines/pink/objects/sequences/sequencer.h b/engines/pink/objects/sequences/sequencer.h
index 55e8529988..3ddf38762c 100644
--- a/engines/pink/objects/sequences/sequencer.h
+++ b/engines/pink/objects/sequences/sequencer.h
@@ -49,6 +49,7 @@ public:
void update();
+ void skipSequence();
public:
SequenceContext *_context;
diff --git a/engines/pink/pink.cpp b/engines/pink/pink.cpp
index 5ced8cb0c1..40bfaedbf6 100644
--- a/engines/pink/pink.cpp
+++ b/engines/pink/pink.cpp
@@ -29,6 +29,7 @@
#include "engines/pink/objects/actors/lead_actor.h"
#include <graphics/surface.h>
+
namespace Pink {
Pink::PinkEngine::PinkEngine(OSystem *system, const ADGameDescription *desc)
@@ -105,6 +106,7 @@ Common::Error Pink::PinkEngine::run() {
break;
case Common::EVENT_KEYDOWN:
+ _actor->OnKeyboardButtonClick(event.kbd.keycode);
break;
// don't know why it is used in original
diff --git a/engines/pink/pink.h b/engines/pink/pink.h
index 591d288de4..63a9a21fca 100644
--- a/engines/pink/pink.h
+++ b/engines/pink/pink.h
@@ -91,6 +91,8 @@ private:
Common::Error init();
void loadModule(int index);
+
+
Console *_console;
Common::RandomSource _rnd;