BBVS: Migrate engine to Path

This commit is contained in:
Le Philousophe 2023-10-31 19:26:15 +01:00 committed by Eugene Sandulenko
parent 905ea1386e
commit 6cfc214d5b
9 changed files with 23 additions and 23 deletions

View File

@ -1310,7 +1310,7 @@ void BbvsEngine::updateDialogConditions() {
void BbvsEngine::playSpeech(int soundNum) {
debug(5, "playSpeech(%0d)", soundNum);
Common::String sndFilename = Common::String::format("snd/snd%05d.aif", soundNum);
Common::Path sndFilename(Common::String::format("snd/snd%05d.aif", soundNum));
Common::File *fd = new Common::File();
fd->open(sndFilename);
Audio::AudioStream *audioStream = Audio::makeAIFFStream(fd, DisposeAfterUse::YES);

View File

@ -36,7 +36,7 @@ GameModule::~GameModule() {
unload();
}
void GameModule::load(const char *filename) {
void GameModule::load(const Common::Path &filename) {
debug(0, "GameModule::load()");
unload();
@ -44,7 +44,7 @@ void GameModule::load(const char *filename) {
Common::File fd;
if (!fd.open(filename))
error("GameModule::load() Could not open %s", filename);
error("GameModule::load() Could not open %s", filename.toString(Common::Path::kNativeSeparator).c_str());
loadBgSprites(fd);
loadCameraInits(fd);

View File

@ -134,7 +134,7 @@ public:
GameModule();
~GameModule();
void load(const char *filename);
void load(const Common::Path &filename);
int getFieldC();
int getButtheadObjectIndex();

View File

@ -41,20 +41,20 @@ static const int kAfterVideoSceneNumDemo[] = {
void BbvsEngine::loadScene(int sceneNum) {
debug(0, "BbvsEngine::loadScene() sceneNum: %d", sceneNum);
Common::String sprFilename = Common::String::format("vnm/vspr%04d.vnm", sceneNum);
Common::String gamFilename = Common::String::format("vnm/game%04d.vnm", sceneNum);
Common::Path sprFilename(Common::String::format("vnm/vspr%04d.vnm", sceneNum));
Common::Path gamFilename(Common::String::format("vnm/game%04d.vnm", sceneNum));
_screen->clear();
_spriteModule->load(sprFilename.c_str());
_gameModule->load(gamFilename.c_str());
_spriteModule->load(sprFilename);
_gameModule->load(gamFilename);
Palette palette = _spriteModule->getPalette();
_screen->setPalette(palette);
// Preload sounds
for (uint i = 0; i < _gameModule->getPreloadSoundsCount(); ++i) {
Common::String filename = Common::String::format("snd/snd%05d.aif", _gameModule->getPreloadSound(i));
Common::Path filename(Common::String::format("snd/snd%05d.aif", _gameModule->getPreloadSound(i)));
_sound->loadSound(filename);
}

View File

@ -36,18 +36,18 @@ Sound::~Sound() {
delete _stream;
}
void Sound::load(const Common::String &filename) {
void Sound::load(const Common::Path &filename) {
Common::File *fd = new Common::File();
if (!fd->open(filename)) {
delete fd;
error("SoundMan::loadSound() Could not load %s", filename.c_str());
error("SoundMan::loadSound() Could not load %s", filename.toString(Common::Path::kNativeSeparator).c_str());
}
_stream = Audio::makeAIFFStream(fd, DisposeAfterUse::YES);
_filename = filename;
}
void Sound::play(bool loop) {
debug(0, "Sound::play() [%s] loop:%d", _filename.c_str(), loop);
debug(0, "Sound::play() [%s] loop:%d", _filename.toString(Common::Path::kNativeSeparator).c_str(), loop);
stop();
_stream->rewind();
@ -75,7 +75,7 @@ SoundMan::~SoundMan() {
unloadSounds();
}
void SoundMan::loadSound(const Common::String &filename) {
void SoundMan::loadSound(const Common::Path &filename) {
Sound *sound = new Sound();
sound->load(filename);
_sounds.push_back(sound);

View File

@ -35,7 +35,7 @@ class Sound {
public:
Sound();
~Sound();
void load(const Common::String &filename);
void load(const Common::Path &filename);
void play(bool loop);
void stop();
bool isPlaying();
@ -43,13 +43,13 @@ protected:
Audio::RewindableAudioStream *_stream;
Audio::SoundHandle _handle;
// Keep the filename for debugging purposes
Common::String _filename;
Common::Path _filename;
};
class SoundMan {
public:
~SoundMan();
void loadSound(const Common::String &fileName);
void loadSound(const Common::Path &fileName);
void playSound(uint index, bool loop = false);
void stopSound(uint index);
bool isSoundPlaying(uint index);

View File

@ -39,12 +39,12 @@ SpriteModule::~SpriteModule() {
unload();
}
void SpriteModule::load(const char *filename) {
void SpriteModule::load(const Common::Path &filename) {
unload();
Common::File fd;
if (!fd.open(filename))
error("SpriteModule::load() Could not open %s", filename);
error("SpriteModule::load() Could not open %s", filename.toString(Common::Path::kNativeSeparator).c_str());
fd.readUint32LE(); // Skip magic
fd.readUint32LE(); // Skip unused

View File

@ -48,7 +48,7 @@ class SpriteModule {
public:
SpriteModule();
~SpriteModule();
void load(const char *filename);
void load(const Common::Path &filename);
int getSpriteCount() { return _spritesCount; }
Sprite getSprite(int index);
Palette getPalette();

View File

@ -28,16 +28,16 @@
namespace Bbvs {
void BbvsEngine::playVideo(int videoNum) {
Common::String videoFilename;
Common::Path videoFilename;
if (videoNum >= 100)
videoFilename = Common::String::format("snd/snd%05d.aif", videoNum + 1400);
videoFilename = Common::Path(Common::String::format("snd/snd%05d.aif", videoNum + 1400));
else
videoFilename = Common::String::format("vid/video%03d.avi", videoNum - 1);
videoFilename = Common::Path(Common::String::format("vid/video%03d.avi", videoNum - 1));
Video::AVIDecoder videoDecoder;
if (!videoDecoder.loadFile(videoFilename)) {
warning("Unable to open video %s", videoFilename.c_str());
warning("Unable to open video %s", videoFilename.toString(Common::Path::kNativeSeparator).c_str());
return;
}