STARTREK: Implement save loading from launcher
This commit is contained in:
parent
23b3782b52
commit
ae6c86bc7a
3 changed files with 37 additions and 17 deletions
|
@ -184,14 +184,15 @@ bool StarTrekEngine::saveOrLoadGameData(Common::SeekableReadStream *in, Common::
|
|||
ser.syncAsUint16LE(_gameMode);
|
||||
// TODO: sub_1d8eb (save) / sub_1d958 (load) (probably bridge / space combat state)
|
||||
|
||||
ser.syncString(_sound->_loadedMidiFilename);
|
||||
Common::String midiFilename = _sound->_loadedMidiFilename;
|
||||
ser.syncString(midiFilename);
|
||||
ser.syncAsSint16LE(_sound->_loopingMidiTrack);
|
||||
|
||||
if (ser.isLoading()) {
|
||||
if (_sound->_loadedMidiFilename.empty())
|
||||
if (midiFilename.empty())
|
||||
_sound->clearAllMidiSlots();
|
||||
else {
|
||||
_sound->loadMusicFile(_sound->_loadedMidiFilename);
|
||||
_sound->loadMusicFile(midiFilename);
|
||||
_sound->playMidiMusicTracks(_sound->_loopingMidiTrack, _sound->_loopingMidiTrack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,20 +119,38 @@ Common::Error StarTrekEngine::run() {
|
|||
initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT, &format);
|
||||
initializeEventsAndMouse();
|
||||
|
||||
bool shouldPlayIntro = false;
|
||||
bool loadedSave = false;
|
||||
|
||||
if (ConfMan.hasKey("save_slot")) {
|
||||
if (!loadGame(ConfMan.getInt("save_slot")))
|
||||
error("Failed to load savegame %d", ConfMan.getInt("save_slot"));
|
||||
shouldPlayIntro = false;
|
||||
loadedSave = true;
|
||||
_roomIndexToLoad = -1;
|
||||
}
|
||||
|
||||
if (!loadedSave) {
|
||||
if (shouldPlayIntro) {
|
||||
_frameIndex = 0;
|
||||
playIntro();
|
||||
debug("DONE");
|
||||
}
|
||||
|
||||
_frameIndex = 0;
|
||||
|
||||
_gameMode = -1;
|
||||
_lastGameMode = -1;
|
||||
}
|
||||
|
||||
runGameMode(GAMEMODE_AWAYMISSION);
|
||||
if (loadedSave)
|
||||
runGameMode(_gameMode, true);
|
||||
else
|
||||
runGameMode(GAMEMODE_AWAYMISSION, false);
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
Common::Error StarTrekEngine::runGameMode(int mode) {
|
||||
Common::Error StarTrekEngine::runGameMode(int mode, bool resume) {
|
||||
if (!resume) { // Only run this if not just resuming from a savefile
|
||||
_gameMode = mode;
|
||||
|
||||
_sound->stopAllVocSounds();
|
||||
|
@ -140,6 +158,7 @@ Common::Error StarTrekEngine::runGameMode(int mode) {
|
|||
_resetGameMode = true;
|
||||
if (_gameMode == GAMEMODE_START)
|
||||
_gameMode = GAMEMODE_BRIDGE;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (_resetGameMode) {
|
||||
|
|
|
@ -234,7 +234,7 @@ public:
|
|||
Angle atan2(int32 deltaX, int32 deltaZ);
|
||||
|
||||
// Game modes
|
||||
Common::Error runGameMode(int mode);
|
||||
Common::Error runGameMode(int mode, bool resume);
|
||||
|
||||
// Away missions
|
||||
void initAwayMission();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue