aboutsummaryrefslogtreecommitdiff
path: root/engines/director/score.cpp
diff options
context:
space:
mode:
authorDmitry Iskrich2016-06-27 16:28:46 +0300
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commite93960e200319b61bae57bfc4c1d75d710744fb2 (patch)
tree63a0e4e8ca9004f016c7d0ce584bfc85d5077a95 /engines/director/score.cpp
parent8a884ad08cd7e638f3be19cfb49a4642f88eb7bd (diff)
downloadscummvm-rg350-e93960e200319b61bae57bfc4c1d75d710744fb2.tar.gz
scummvm-rg350-e93960e200319b61bae57bfc4c1d75d710744fb2.tar.bz2
scummvm-rg350-e93960e200319b61bae57bfc4c1d75d710744fb2.zip
DIRECTOR: Add to Score jump labels commands
Diffstat (limited to 'engines/director/score.cpp')
-rw-r--r--engines/director/score.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index a84228741b..5b05ed67fe 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -406,6 +406,63 @@ void Score::loadCastInfo(Common::SeekableSubReadStreamEndian &stream, uint16 id)
_castsInfo[id] = ci;
}
+void Score::goToLoop() {
+ //This command has the playback head contonuously return to the first marker to to the left and then loop back.
+ //If no marker are to the left of the playback head, the playback head continues to the right.
+ Common::HashMap<uint16, Common::String>::iterator i;
+
+ for (i = _labels.begin(); i != _labels.end(); ++i) {
+ if (i->_value == _currentLabel) {
+ _currentFrame = i->_key;
+ return;
+ }
+ }
+}
+
+void Score::goToNext() {
+ Common::HashMap<uint16, Common::String>::iterator i;
+
+ for (i = _labels.begin(); i != _labels.end(); ++i) {
+ if (i->_value == _currentLabel) {
+ if (i != _labels.end()) {
+ //return to the first marker to to the right
+ ++i;
+ _currentFrame = i->_key;
+ return;
+ } else {
+ //if no markers are to the right of the playback head,
+ //the playback head goes to the first marker to the left
+ _currentFrame = i->_key;
+ return;
+ }
+ }
+ }
+ //If there are not markers to the left,
+ //the playback head goes to frame 1, (Director frame array start from 1, engine from 0)
+ _currentFrame = 0;
+}
+void Score::goToPrevious() {
+ //One label
+ if (_labels.begin() == _labels.end()) {
+ _currentFrame = _labels.begin()->_key;
+ return;
+ }
+
+ Common::HashMap<uint16, Common::String>::iterator previous = _labels.begin();
+ Common::HashMap<uint16, Common::String>::iterator i = previous++; //because iterator havent decrement operator
+
+ for (i = _labels.begin(); i != _labels.end(); ++i, ++previous) {
+ if (i->_value == _currentLabel) {
+ _currentFrame = previous->_key;
+ return;
+ } else {
+ _currentFrame = i->_key;
+ return;
+ }
+ }
+ _currentFrame = 0;
+}
+
Common::String Score::getString(Common::String str) {
if (str.size() == 0) {
return str;
@@ -613,6 +670,9 @@ void Score::update() {
//TODO Director 6 step: send prepareFrame event to all sprites and the script channel in upcoming frame
//_lingo->processEvent(kEventPrepareFrame, _currentFrame);
_currentFrame++;
+ if (_labels.contains(_currentFrame)) {
+ _currentLabel = _labels[_currentFrame];
+ }
_frames[_currentFrame]->prepareFrame(this);
//Stage is drawn between the prepareFrame and enterFrame events (Lingo in a Nutshell)