aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2015-08-29 18:09:54 +0200
committerTorbjörn Andersson2015-08-29 18:09:54 +0200
commite734bb5078055521e04508ce19c5766b36817300 (patch)
tree2e86727caf746b7e87f6dc4a162736b2afd7fd7b
parent7f4268dc3dcf2cc6a34c605a7ddbd69d8740526e (diff)
downloadscummvm-rg350-e734bb5078055521e04508ce19c5766b36817300.tar.gz
scummvm-rg350-e734bb5078055521e04508ce19c5766b36817300.tar.bz2
scummvm-rg350-e734bb5078055521e04508ce19c5766b36817300.zip
SHERLOCK: Rework the "song" debugger command
Instead of taking a room number (which didn't work in Rose Tattoo), it now takes a song name. To see which songs are available, use the "songs" command. Note that this is still only works for Serrated Scalpel, since I haven't implemented getting a list of available songs for Rose Tattoo. I need to study the resource manager a bit first...
-rw-r--r--engines/sherlock/debugger.cpp28
-rw-r--r--engines/sherlock/debugger.h5
-rw-r--r--engines/sherlock/music.cpp11
-rw-r--r--engines/sherlock/music.h7
4 files changed, 44 insertions, 7 deletions
diff --git a/engines/sherlock/debugger.cpp b/engines/sherlock/debugger.cpp
index 2813a7eb69..b3c64e8e82 100644
--- a/engines/sherlock/debugger.cpp
+++ b/engines/sherlock/debugger.cpp
@@ -29,6 +29,7 @@
#include "audio/mixer.h"
#include "audio/decoders/aiff.h"
#include "audio/decoders/wave.h"
+#include "common/str-array.h"
namespace Sherlock {
@@ -45,8 +46,9 @@ Debugger::Debugger(SherlockEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
registerCmd("scene", WRAP_METHOD(Debugger, cmdScene));
registerCmd("song", WRAP_METHOD(Debugger, cmdSong));
+ registerCmd("songs", WRAP_METHOD(Debugger, cmdListSongs));
registerCmd("dumpfile", WRAP_METHOD(Debugger, cmdDumpFile));
- registerCmd("locations", WRAP_METHOD(Debugger, cmdLocations));
+ registerCmd("locations", WRAP_METHOD(Debugger, cmdLocations));
}
void Debugger::postEnter() {
@@ -87,15 +89,29 @@ bool Debugger::cmdScene(int argc, const char **argv) {
bool Debugger::cmdSong(int argc, const char **argv) {
if (argc != 2) {
- debugPrintf("Format: song <room>\n");
+ debugPrintf("Format: song <name>\n");
return true;
}
- if (!_vm->_music->loadSong(strToInt(argv[1]))) {
- debugPrintf("Invalid song number.\n");
- return true;
+ Common::StringArray songs;
+ _vm->_music->getSongNames(songs);
+
+ for (uint i = 0; i < songs.size(); i++) {
+ if (songs[i].equalsIgnoreCase(argv[1])) {
+ _vm->_music->loadSong(songs[i]);
+ return false;
+ }
}
- return false;
+
+ debugPrintf("Invalid song. Use the 'songs' command to see which ones are available.\n");
+ return true;
+}
+
+bool Debugger::cmdListSongs(int argc, const char **argv) {
+ Common::StringArray songs;
+ _vm->_music->getSongNames(songs);
+ debugPrintColumns(songs);
+ return true;
}
bool Debugger::cmdDumpFile(int argc, const char **argv) {
diff --git a/engines/sherlock/debugger.h b/engines/sherlock/debugger.h
index abc8ef012d..622098cf85 100644
--- a/engines/sherlock/debugger.h
+++ b/engines/sherlock/debugger.h
@@ -50,6 +50,11 @@ private:
bool cmdSong(int argc, const char **argv);
/**
+ * Lists all available songs
+ */
+ bool cmdListSongs(int argc, const char **argv);
+
+ /**
* Dumps a file to disk
*/
bool cmdDumpFile(int argc, const char **argv);
diff --git a/engines/sherlock/music.cpp b/engines/sherlock/music.cpp
index 99f7b45617..10796e47ea 100644
--- a/engines/sherlock/music.cpp
+++ b/engines/sherlock/music.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "common/algorithm.h"
#include "common/config-manager.h"
#include "common/mutex.h"
#include "sherlock/sherlock.h"
@@ -579,4 +580,14 @@ void Music::setMusicVolume(int volume) {
_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume);
}
+void Music::getSongNames(Common::StringArray &songs) {
+ songs.clear();
+ if (IS_SERRATED_SCALPEL) {
+ for (int i = 0; i < ARRAYSIZE(SONG_NAMES); i++) {
+ songs.push_back(SONG_NAMES[i]);
+ }
+ }
+ Common::sort(songs.begin(), songs.end());
+}
+
} // End of namespace Sherlock
diff --git a/engines/sherlock/music.h b/engines/sherlock/music.h
index ca203da019..afd3a429be 100644
--- a/engines/sherlock/music.h
+++ b/engines/sherlock/music.h
@@ -31,6 +31,7 @@
#include "audio/audiostream.h"
#include "audio/mixer.h"
#include "common/mutex.h"
+#include "common/str-array.h"
namespace Sherlock {
@@ -121,9 +122,13 @@ public:
* Sets the volume of the MIDI music with a value ranging from 0 to 127
*/
void setMusicVolume(int volume);
+
+ /**
+ * Gets the names of all the songs in the game. Used by the debugger.
+ */
+ void getSongNames(Common::StringArray &songs);
};
} // End of namespace Sherlock
#endif
-