コード例 #1
0
ファイル: gui_hof.cpp プロジェクト: CatalystG/scummvm
int GUI_HoF::loadMenu(Button *caller) {
	updateSaveFileList(_vm->_targetName);

	if (!_vm->_menuDirectlyToLoad) {
		updateMenuButton(caller);
		restorePage1(_vm->_screenBuffer);
		backUpPage1(_vm->_screenBuffer);
	}

	_savegameOffset = 0;
	setupSavegameNames(_loadMenu, 5);
	initMenu(_loadMenu);
	_isLoadMenu = true;
	_noLoadProcess = false;
	_vm->_gameToLoad = -1;
	updateAllMenuButtons();

	_screen->updateScreen();
	while (_isLoadMenu) {
		processHighlights(_loadMenu);
		getInput();
	}

	if (_noLoadProcess) {
		if (!_vm->_menuDirectlyToLoad) {
			restorePage1(_vm->_screenBuffer);
			backUpPage1(_vm->_screenBuffer);
			initMenu(*_currentMenu);
			updateAllMenuButtons();
		}
	} else if (_vm->_gameToLoad >= 0) {
		restorePage1(_vm->_screenBuffer);
		restorePalette();
		_vm->loadGameStateCheck(_vm->_gameToLoad);
		if (_vm->_gameToLoad == 0) {
			_restartGame = true;
			for (int i = 0; i < 23; ++i)
				_vm->resetCauldronStateTable(i);
			_vm->runStartScript(1, 1);
		}
		_displayMenu = false;
		_loadedSave = true;
	}

	return 0;
}
コード例 #2
0
ファイル: gui.cpp プロジェクト: N02775223/scummvm
void GUI::updateSaveSlotsList(Common::String targetName, bool force) {
    if (!_saveSlotsListUpdateNeeded && !force)
        return;

    _saveSlotsListUpdateNeeded = false;

    if (_savegameList) {
        for (int i = 0; i < _savegameListSize; i++)
            delete[] _savegameList[i];
        delete[] _savegameList;
    }

    updateSaveFileList(targetName, true);
    int numSaves = _savegameListSize = _saveSlots.size();
    bool allowEmptySlots = (_vm->game() == GI_EOB1 || _vm->game() == GI_EOB2);

    if (_savegameListSize) {
        if (allowEmptySlots)
            _savegameListSize = 990;

        KyraEngine_v1::SaveHeader header;
        Common::InSaveFile *in;

        _savegameList = new char*[_savegameListSize];
        memset(_savegameList, 0, _savegameListSize * sizeof(char *));

        for (int i = 0; i < numSaves; i++) {
            in = _vm->openSaveForReading(_vm->getSavegameFilename(targetName, _saveSlots[i]).c_str(), header, targetName == _vm->_targetName);
            char **listEntry = &_savegameList[allowEmptySlots ? _saveSlots[i] : i];
            if (in) {
                *listEntry = new char[header.description.size() + 1];
                Common::strlcpy(*listEntry, header.description.c_str(), header.description.size() + 1);
                Util::convertISOToDOS(*listEntry);
                delete in;
            } else {
                *listEntry = 0;
                error("GUI::updateSavegameList(): Unexpected missing save file for slot: %d.", _saveSlots[i]);
            }
        }

    } else {
        _savegameList = 0;
    }
}