aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/game
diff options
context:
space:
mode:
authorLittleboy2011-06-24 11:43:10 -0400
committerLittleboy2011-06-24 11:43:10 -0400
commit3f4d2c8130ac1db51f9a2fc5fcb5a2413b215f45 (patch)
treee0f4e05c9252d41721bf585a615e525d9f0aab3e /engines/lastexpress/game
parent5d020fffad44c78414b91de7c26653b11b78b60f (diff)
downloadscummvm-rg350-3f4d2c8130ac1db51f9a2fc5fcb5a2413b215f45.tar.gz
scummvm-rg350-3f4d2c8130ac1db51f9a2fc5fcb5a2413b215f45.tar.bz2
scummvm-rg350-3f4d2c8130ac1db51f9a2fc5fcb5a2413b215f45.zip
LASTEXPRESS: Move subtitle-related methods to the SubtitleEntry class
Diffstat (limited to 'engines/lastexpress/game')
-rw-r--r--engines/lastexpress/game/sound.cpp103
-rw-r--r--engines/lastexpress/game/sound.h16
2 files changed, 19 insertions, 100 deletions
diff --git a/engines/lastexpress/game/sound.cpp b/engines/lastexpress/game/sound.cpp
index f8bee17d61..adb82816f5 100644
--- a/engines/lastexpress/game/sound.cpp
+++ b/engines/lastexpress/game/sound.cpp
@@ -127,7 +127,7 @@ SoundManager::SoundManager(LastExpressEngine *engine) : _engine(engine), _state(
// Sound cache
_soundCacheData = malloc(6 * SOUNDCACHE_ENTRY_SIZE);
- _drawSubtitles = 0;
+ _subtitlesFlag = 0;
_currentSubtitle = NULL;
_loopingSoundDuration = 0;
@@ -436,7 +436,7 @@ void SoundManager::removeEntry(SoundEntry *entry) {
// removeFromCache(entry);
if (entry->subtitle) {
- drawSubtitle(entry->subtitle);
+ entry->subtitle->draw();
SAFE_DELETE(entry->subtitle);
}
@@ -640,7 +640,7 @@ bool SoundManager::playSoundWithSubtitles(Common::String filename, SoundFlag fla
while (filename.size() > 4)
filename.deleteLastChar();
- showSubtitle(entry, filename);
+ entry->showSubtitle(filename);
entry->updateState();
}
@@ -785,7 +785,7 @@ void SoundManager::playSteam(CityIndex index) {
// Get the new sound entry and show subtitles
SoundEntry *entry = getEntry(kSoundType1);
if (entry)
- showSubtitle(entry, cities[index]);
+ entry->showSubtitle(cities[index]);
}
void SoundManager::playFightSound(byte action, byte a4) {
@@ -1762,7 +1762,7 @@ void SoundManager::updateSubtitles() {
for (Common::List<SubtitleEntry *>::iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
uint32 current_index = 0;
- SoundEntry *soundEntry = (*i)->sound;
+ SoundEntry *soundEntry = (*i)->getSoundEntry();
SoundStatus status = (SoundStatus)soundEntry->status.status;
if (!(status & kSoundStatus_40)
@@ -1786,103 +1786,20 @@ void SoundManager::updateSubtitles() {
if (_currentSubtitle == subtitle) {
if (subtitle)
- setupSubtitleAndDraw(subtitle);
+ subtitle->setupAndDraw();
return;
}
- if (_drawSubtitles & 1)
- drawSubtitleOnScreen(subtitle);
+ if (_subtitlesFlag & 1)
+ subtitle->drawOnScreen();
if (subtitle) {
- loadSubtitleData(subtitle);
- setupSubtitleAndDraw(subtitle);
+ subtitle->loadData();
+ subtitle->setupAndDraw();
}
}
-void SoundManager::showSubtitle(SoundEntry *entry, Common::String filename) {
- entry->subtitle = loadSubtitle(filename, entry);
-
- if (entry->subtitle->status.status2 & 4) {
- drawSubtitle(entry->subtitle);
- SAFE_DELETE(entry->subtitle);
- } else {
- entry->status.status |= kSoundStatus_20000;
- }
-}
-
-SubtitleEntry *SoundManager::loadSubtitle(Common::String filename, SoundEntry *soundEntry) {
- SubtitleEntry *entry = new SubtitleEntry();
- _subtitles.push_back(entry);
-
- // Set sound entry and filename
- entry->filename = filename + ".SBE";
- entry->sound = soundEntry;
-
- // Load subtitle data
- if (_engine->getResourceManager()->hasFile(filename)) {
- if (_drawSubtitles & 2)
- return entry;
-
- loadSubtitleData(entry);
- } else {
- entry->status.status = kSoundStatus_400;
- }
-
- return entry;
-}
-
-void SoundManager::loadSubtitleData(SubtitleEntry * entry) {
- entry->data = new SubtitleManager(_engine->getFont());
- entry->data->load(getArchive(entry->filename));
-
- _drawSubtitles |= 2;
- _currentSubtitle = entry;
-}
-
-void SoundManager::setupSubtitleAndDraw(SubtitleEntry *subtitle) {
- if (!subtitle->data) {
- subtitle->data = new SubtitleManager(_engine->getFont());
- subtitle->data->load(getArchive(subtitle->filename));
- }
-
- if (subtitle->data->getMaxTime() > subtitle->sound->time) {
- subtitle->status.status = kSoundStatus_400;
- } else {
- subtitle->data->setTime((uint16)subtitle->sound->time);
-
- if (_drawSubtitles & 1)
- drawSubtitleOnScreen(subtitle);
- }
-
- _currentSubtitle = subtitle;
-}
-
-void SoundManager::drawSubtitle(SubtitleEntry *subtitle) {
- // Remove subtitle from queue
- _subtitles.remove(subtitle);
-
- if (subtitle == _currentSubtitle) {
- drawSubtitleOnScreen(subtitle);
-
- _currentSubtitle = NULL;
- _drawSubtitles = 0;
- }
-}
-
-void SoundManager::drawSubtitleOnScreen(SubtitleEntry *subtitle) {
- if (!subtitle)
- error("SoundManager::drawSubtitleOnScreen: Invalid subtitle entry!");
-
- _drawSubtitles &= ~1;
-
- if (subtitle->data == NULL)
- return;
-
- if (_drawSubtitles & 1)
- _engine->getGraphicsManager()->draw(subtitle->data, GraphicsManager::kBackgroundOverlay);
-}
-
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/lastexpress/game/sound.h b/engines/lastexpress/game/sound.h
index a87bb9bb80..b2a1b4387b 100644
--- a/engines/lastexpress/game/sound.h
+++ b/engines/lastexpress/game/sound.h
@@ -107,6 +107,14 @@ public:
// Accessors
uint32 getFlag() { return _flag; }
+ int getSubtitleFlag() { return _subtitlesFlag; }
+ void setSubtitleFlag(int flag) { _subtitlesFlag = flag; }
+
+ // Subtitles
+ void addSubtitle(SubtitleEntry *entry) { _subtitles.push_back(entry); }
+ void removeSubtitle(SubtitleEntry *entry) { _subtitles.remove(entry); }
+ void setCurrentSubtitle(SubtitleEntry *entry) { _currentSubtitle = entry; }
+ SubtitleEntry *getCurrentSubtitle() { return _currentSubtitle; }
private:
typedef int32 *SoundBuffer;
@@ -161,15 +169,9 @@ private:
void removeEntry(SoundEntry *entry);
// Subtitles
- int _drawSubtitles;
+ int _subtitlesFlag;
Common::List<SubtitleEntry *> _subtitles;
SubtitleEntry *_currentSubtitle;
- void showSubtitle(SoundEntry *entry, Common::String filename);
- SubtitleEntry *loadSubtitle(Common::String filename, SoundEntry *soundEntry);
- void loadSubtitleData(SubtitleEntry * entry);
- void setupSubtitleAndDraw(SubtitleEntry *subtitle);
- void drawSubtitle(SubtitleEntry *subtitle);
- void drawSubtitleOnScreen(SubtitleEntry *subtitle);
// Sound filter
void applyFilter(SoundEntry *entry, int16 *buffer);