コード例 #1
0
ファイル: saveload.cpp プロジェクト: BenCastricum/scummvm
bool StarTrekEngine::showSaveMenu() {
	GUI::SaveLoadChooser *dialog;
	Common::String desc;
	int slot;

	dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);

	slot = dialog->runModalWithCurrentTarget();
	desc = dialog->getResultString();

	if (desc.empty()) {
		// create our own description for the saved game, the user didnt enter it
		desc = dialog->createDefaultSaveDescription(slot);
	}

	if (desc.size() > 28)
		desc = Common::String(desc.c_str(), 28);

	delete dialog;

	if (slot < 0)
		return true;

	return saveGame(slot, desc);
}
コード例 #2
0
bool LabEngine::saveRestoreGame() {
	bool isOK = false;

	// The original had one screen for saving/loading. We have two.
	// Ask the user which screen to use.
	GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore"));

	int choice = saveOrLoad.runModal();
	if (choice == GUI::kMessageOK) {
		// Save
		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
		int slot = dialog->runModalWithCurrentTarget();
		if (slot >= 0) {
			Common::String desc = dialog->getResultString();

			if (desc.empty()) {
				// create our own description for the saved game, the user didn't enter it
				desc = dialog->createDefaultSaveDescription(slot);
			}

			isOK = saveGame(slot, desc);
		}
		delete dialog;
	} else {
		// Restore
		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
		int slot = dialog->runModalWithCurrentTarget();
		if (slot >= 0) {
			isOK = loadGame(slot);
		}
		delete dialog;
	}

	return isOK;
}
コード例 #3
0
ファイル: events.cpp プロジェクト: AReim1982/scummvm
bool Keyboard::getKey(Common::Event &event) {
	Common::KeyCode keycode = event.kbd.keycode;

	switch (keycode) {
	case Common::KEYCODE_F1:
		if (event.type == Common::EVENT_KEYUP)
			return false;
		// Display ScummVM version and translation strings
		for (int i = 0; i < 3; i++)
			_vm->_commandHandler->addCommand(kCmdInf, 1, kShowScummVMVersion + i, NULL);
		return false;
	case Common::KEYCODE_F5:
		if (_vm->canSaveGameStateCurrently()) {
			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
			int16 savegameId = dialog->runModalWithCurrentTarget();
			Common::String savegameDescription = dialog->getResultString();
			delete dialog;

			if (savegameId != -1)
				_vm->saveGameState(savegameId, savegameDescription);
		}
		return false;
	case Common::KEYCODE_F7:
		if (_vm->canLoadGameStateCurrently()) {
			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
			int16 savegameId = dialog->runModalWithCurrentTarget();
			delete dialog;

			if (savegameId != -1)
				_vm->loadGameState(savegameId);
		}
		return false;
	case Common::KEYCODE_d:
		if (event.kbd.flags & Common::KBD_CTRL) {
			// Start the debugger
			_vm->getDebugger()->attach();
			_vm->getDebugger()->onFrame();
			return false;
		}
		break;
	case Common::KEYCODE_x:
		if (event.kbd.flags & Common::KBD_ALT) {
			_vm->quit();
			return false;
		}
		break;
	case Common::KEYCODE_F10:
		if (_vm->_commandHandler->idle())
			_vm->switchScene(-1); // Exits the game.
		return false;
	default:
		break;
	}

	return true;
}
コード例 #4
0
ファイル: events.cpp プロジェクト: grayfoxier/scummvm
bool Keyboard::getKey(Common::Event &event, int &cgeCode) {
	Common::KeyCode keycode = event.kbd.keycode;
	if ((keycode == Common::KEYCODE_LCTRL) || (keycode == Common::KEYCODE_RCTRL)) {
		cgeCode = kKeyCtrl;
		return true;
	}
	if ((keycode == Common::KEYCODE_LALT) || (keycode == Common::KEYCODE_RALT)) {
		cgeCode = kKeyAlt;
		return true;
	}
	if (keycode == Common::KEYCODE_KP_ENTER) {
		cgeCode = 28;
		return true;
	}
	if (keycode == Common::KEYCODE_F5) {
		warning("keycode %d", event.kbd.ascii);
		if (_vm->canSaveGameStateCurrently()) {
			const EnginePlugin *plugin = NULL;
			EngineMan.findGame(_vm->_gameDescription->gameid, &plugin);

			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Save game:", "Save");
			dialog->setSaveMode(true);
			int16 savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
			Common::String savegameDescription = dialog->getResultString();
			delete dialog;
			_vm->saveGameState(savegameId, savegameDescription);
		}
		return false;
	} else if (keycode == Common::KEYCODE_F7) {
		if (_vm->canLoadGameStateCurrently()) {
			const EnginePlugin *plugin = NULL;
			EngineMan.findGame(_vm->_gameDescription->gameid, &plugin);

			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Restore game:", "Restore");
			dialog->setSaveMode(false);
			int16 savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
			delete dialog;
			_vm->loadGameState(savegameId);
		}
		return false;
	}

	// Scan through the ScummVM mapping list
	for (int idx = 0; idx < 0x60; idx++) {
		if (_scummVmCodes[idx] == event.kbd.ascii) {
			cgeCode = idx;
			return true;
		}
	}

	return false;
}
コード例 #5
0
ファイル: ringworld_logic.cpp プロジェクト: TomFrost/scummvm
void RingworldGame::handleSaveLoad(bool saveFlag, int &saveSlot, Common::String &saveName) {
	const EnginePlugin *plugin = 0;
	EngineMan.findGame(_vm->getGameId(), &plugin);
	GUI::SaveLoadChooser *dialog;
	if (saveFlag)
		dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"));
	else
		dialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"));

	dialog->setSaveMode(saveFlag);

	saveSlot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
	saveName = dialog->getResultString();

	delete dialog;
}
コード例 #6
0
ファイル: widget_files.cpp プロジェクト: 86400/scummvm
void WidgetFiles::showScummVMSaveDialog() {
	GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);

	int slot = dialog->runModalWithCurrentTarget();
	if (slot >= 0) {
		Common::String desc = dialog->getResultString();

		if (desc.empty()) {
			// create our own description for the saved game, the user didn't enter it
			desc = dialog->createDefaultSaveDescription(slot);
		}

		_vm->saveGameState(slot, desc);
	}

	close();
	delete dialog;
}
コード例 #7
0
ファイル: saves.cpp プロジェクト: BenCastricum/scummvm
bool SavesManager::saveGame() {
	Map &map = *g_vm->_map;

	if (map.mazeData()._mazeFlags & RESTRICTION_SAVE) {
		ErrorScroll::show(g_vm, Res.SAVE_OFF_LIMITS, WT_NONFREEZED_WAIT);
		return false;
	} else if (!g_vm->canSaveGameStateCurrently()) {
		return false;
	} else {
		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
		int slotNum = dialog->runModalWithCurrentTarget();
		Common::String saveName = dialog->getResultString();
		delete dialog;

		if (slotNum != -1)
			saveGameState(slotNum, saveName);

		return slotNum != -1;
	}
}
コード例 #8
0
ファイル: save_manager.cpp プロジェクト: lukecharman/scummvm
bool SaveManager::scummVMSaveLoadDialog(bool isSave) {
	GUI::SaveLoadChooser *dialog;
	Common::String desc;
	int slot;

	if (isSave) {
		dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);

		slot = dialog->runModalWithCurrentTarget();
		desc = dialog->getResultString();

		if (desc.empty()) {
			// create our own description for the saved game, the user didnt enter it
			desc = dialog->createDefaultSaveDescription(slot);
		}

		if (desc.size() > 28)
			desc = Common::String(desc.c_str(), 28);
	} else {
		dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
		slot = dialog->runModalWithCurrentTarget();
	}

	delete dialog;

	if (slot < 0)
		return false;

	if (isSave) {
		saveGame(slot, desc, false);
		return true;
	} else {
		Common::ErrorCode result = loadGame(slot).getCode();
		return (result == Common::kNoError);
	}
}
コード例 #9
0
ファイル: file.cpp プロジェクト: Bundesdrucker/scummvm
/**
 * Save game to supplied slot
 */
bool FileManager::saveGame(const int16 slot, const Common::String &descrip) {
	debugC(1, kDebugFile, "saveGame(%d, %s)", slot, descrip.c_str());

	int16 savegameId;
	Common::String savegameDescription;

	if (slot == -1) {
		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Save game:", "Save", true);
		savegameId = dialog->runModalWithCurrentTarget();
		savegameDescription = dialog->getResultString();
		delete dialog;
	} else {
		savegameId = slot;
		if (!descrip.empty()) {
			savegameDescription = descrip;
		} else {
			savegameDescription = Common::String::format("Quick save #%d", slot);
		}
	}

	if (savegameId < 0)                             // dialog aborted
		return false;

	Common::String savegameFile = _vm->getSavegameFilename(savegameId);
	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
	Common::OutSaveFile *out = saveMan->openForSaving(savegameFile);

	if (!out) {
		warning("Can't create file '%s', game not saved", savegameFile.c_str());
		return false;
	}

	// Write version.  We can't restore from obsolete versions
	out->writeByte(kSavegameVersion);

	if (savegameDescription == "") {
		savegameDescription = "Untitled savegame";
	}

	out->writeSint16BE(savegameDescription.size() + 1);
	out->write(savegameDescription.c_str(), savegameDescription.size() + 1);

	Graphics::saveThumbnail(*out);

	TimeDate curTime;
	_vm->_system->getTimeAndDate(curTime);

	uint32 saveDate = (curTime.tm_mday & 0xFF) << 24 | ((curTime.tm_mon + 1) & 0xFF) << 16 | ((curTime.tm_year + 1900) & 0xFFFF);
	uint16 saveTime = (curTime.tm_hour & 0xFF) << 8 | ((curTime.tm_min) & 0xFF);

	out->writeUint32BE(saveDate);
	out->writeUint16BE(saveTime);

	_vm->_object->saveObjects(out);

	const Status &gameStatus = _vm->getGameStatus();

	// Save whether hero image is swapped
	out->writeByte(_vm->_heroImage);

	// Save score
	out->writeSint16BE(_vm->getScore());

	// Save story mode
	out->writeByte((gameStatus._storyModeFl) ? 1 : 0);

	// Save jumpexit mode
	out->writeByte((_vm->_mouse->getJumpExitFl()) ? 1 : 0);

	// Save gameover status
	out->writeByte((gameStatus._gameOverFl) ? 1 : 0);

	// Save screen states
	for (int i = 0; i < _vm->_numStates; i++)
		out->writeByte(_vm->_screenStates[i]);

	_vm->_scheduler->saveSchedulerData(out);
	// Save palette table
	_vm->_screen->savePal(out);

	// Save maze status
	out->writeByte((_vm->_maze._enabledFl) ? 1 : 0);
	out->writeByte(_vm->_maze._size);
	out->writeSint16BE(_vm->_maze._x1);
	out->writeSint16BE(_vm->_maze._y1);
	out->writeSint16BE(_vm->_maze._x2);
	out->writeSint16BE(_vm->_maze._y2);
	out->writeSint16BE(_vm->_maze._x3);
	out->writeSint16BE(_vm->_maze._x4);
	out->writeByte(_vm->_maze._firstScreenIndex);

	out->writeByte((byte)_vm->getGameStatus()._viewState);

	out->finalize();

	delete out;

	return true;
}
コード例 #10
0
reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) {
	Common::String game_id;
 	int16 virtualId = argv[1].toSint16();
	int16 savegameId = -1;
	Common::String game_description;
	Common::String version;

	if (argc > 3)
		version = s->_segMan->getString(argv[3]);

	// We check here, we don't want to delete a users save in case we are within a kernel function
	if (s->executionStackBase) {
		warning("kSaveGame - won't save from within kernel function");
		return NULL_REG;
	}

	if (argv[0].isNull()) {
		// Direct call, from a patched Game::save
		if ((argv[1] != SIGNAL_REG) || (!argv[2].isNull()))
			error("kSaveGame: assumed patched call isn't accurate");

		// we are supposed to show a dialog for the user and let him choose where to save
		g_sci->_soundCmd->pauseAll(true); // pause music
		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
		savegameId = dialog->runModalWithCurrentTarget();
		game_description = dialog->getResultString();
		if (game_description.empty()) {
			// create our own description for the saved game, the user didnt enter it
			game_description = dialog->createDefaultSaveDescription(savegameId);
		}
		delete dialog;
		g_sci->_soundCmd->pauseAll(false); // unpause music ( we can't have it paused during save)
		if (savegameId < 0)
			return NULL_REG;

	} else {
		// Real call from script
		game_id = s->_segMan->getString(argv[0]);
		if (argv[2].isNull())
			error("kSaveGame: called with description being NULL");
		game_description = s->_segMan->getString(argv[2]);

		debug(3, "kSaveGame(%s,%d,%s,%s)", game_id.c_str(), virtualId, game_description.c_str(), version.c_str());

		Common::Array<SavegameDesc> saves;
		listSavegames(saves);

		if ((virtualId >= SAVEGAMEID_OFFICIALRANGE_START) && (virtualId <= SAVEGAMEID_OFFICIALRANGE_END)) {
			// savegameId is an actual Id, so search for it just to make sure
			savegameId = virtualId - SAVEGAMEID_OFFICIALRANGE_START;
			if (findSavegame(saves, savegameId) == -1)
				return NULL_REG;
		} else if (virtualId < SAVEGAMEID_OFFICIALRANGE_START) {
			// virtualId is low, we assume that scripts expect us to create new slot
			if (virtualId == s->_lastSaveVirtualId) {
				// if last virtual id is the same as this one, we assume that caller wants to overwrite last save
				savegameId = s->_lastSaveNewId;
			} else {
				uint savegameNr;
				// savegameId is in lower range, scripts expect us to create a new slot
				for (savegameId = 0; savegameId < SAVEGAMEID_OFFICIALRANGE_START; savegameId++) {
					for (savegameNr = 0; savegameNr < saves.size(); savegameNr++) {
						if (savegameId == saves[savegameNr].id)
							break;
					}
					if (savegameNr == saves.size())
						break;
				}
				if (savegameId == SAVEGAMEID_OFFICIALRANGE_START)
					error("kSavegame: no more savegame slots available");
			}
		} else {
			error("kSaveGame: invalid savegameId used");
		}

		// Save in case caller wants to overwrite last newly created save
		s->_lastSaveVirtualId = virtualId;
		s->_lastSaveNewId = savegameId;
	}

	s->r_acc = NULL_REG;

	Common::String filename = g_sci->getSavegameName(savegameId);
	Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();
	Common::OutSaveFile *out;

	out = saveFileMan->openForSaving(filename);
	if (!out) {
		warning("Error opening savegame \"%s\" for writing", filename.c_str());
	} else {
		if (!gamestate_save(s, out, game_description, version)) {
			warning("Saving the game failed");
		} else {
			s->r_acc = TRUE_REG; // save successful
		}

		out->finalize();
		if (out->err()) {
			warning("Writing the savegame failed");
			s->r_acc = NULL_REG; // write failure
		}
		delete out;
	}

	return s->r_acc;
}
コード例 #11
0
ファイル: events.cpp プロジェクト: 33d/scummvm
bool Keyboard::getKey(Common::Event &event) {
	Common::KeyCode keycode = event.kbd.keycode;

	if (((keycode == Common::KEYCODE_LALT) || (keycode == Common::KEYCODE_RALT)) && event.type == Common::EVENT_KEYDOWN)
		_keyAlt = true;
	else
		_keyAlt = false;

	switch (keycode) {
	case Common::KEYCODE_F1:
		if (event.type == Common::EVENT_KEYUP)
			return false;
		// Display ScummVM version and translation strings
		for (int i = 0; i < 5; i++)
			_vm->_commandHandler->addCommand(kCmdInf, 1, kShowScummVMVersion + i, NULL);
		return false;
	case Common::KEYCODE_F5:
		if (_vm->canSaveGameStateCurrently()) {
			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Save game:", "Save", true);
			int16 savegameId = dialog->runModalWithCurrentTarget();
			Common::String savegameDescription = dialog->getResultString();
			delete dialog;

			if (savegameId != -1)
				_vm->saveGameState(savegameId, savegameDescription);
			}
		return false;
	case Common::KEYCODE_F7:
		if (_vm->canLoadGameStateCurrently()) {
			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Restore game:", "Restore", false);
			int16 savegameId = dialog->runModalWithCurrentTarget();
			delete dialog;

			if (savegameId != -1)
				_vm->loadGameState(savegameId);
		}
		return false;
	case Common::KEYCODE_d:
		if (event.kbd.flags & Common::KBD_CTRL) {
		// Start the debugger
			_vm->getDebugger()->attach();
			_vm->getDebugger()->onFrame();
			return false;
		}
		break;
	case Common::KEYCODE_x:
		if (event.kbd.flags & Common::KBD_ALT) {
			_vm->quit();
			return false;
		}
		break;
	case Common::KEYCODE_0:
	case Common::KEYCODE_1:
	case Common::KEYCODE_2:
	case Common::KEYCODE_3:
	case Common::KEYCODE_4:
		if (event.kbd.flags & Common::KBD_ALT) {
			_vm->_commandHandler->addCommand(kCmdLevel, -1, keycode - Common::KEYCODE_0, NULL);
			return false;
		}
		// Fallthrough intended
	case Common::KEYCODE_5:
	case Common::KEYCODE_6:
	case Common::KEYCODE_7:
	case Common::KEYCODE_8:
		if (event.type == Common::EVENT_KEYDOWN && !(event.kbd.flags & Common::KBD_ALT) && keycode != Common::KEYCODE_0) {
			_vm->selectPocket(keycode - Common::KEYCODE_1);
			return false;
		}
		break;
	default:
		break;
	}

	return true;
}
コード例 #12
0
ファイル: events.cpp プロジェクト: YakBizzarro/scummvm
bool Keyboard::getKey(Common::Event &event) {
	Common::KeyCode keycode = event.kbd.keycode;

	if ((keycode == Common::KEYCODE_LALT) || (keycode == Common::KEYCODE_RALT))
		_keyAlt = true;
	else
		_keyAlt = false;

	switch (keycode) {
	case Common::KEYCODE_F1:
		if (event.type == Common::EVENT_KEYUP)
			return false;
		// Display ScummVM version and translation strings
		for (int i = 0; i < 5; i++)
			_vm->_commandHandler->addCommand(kCmdInf, 1, kShowScummVMVersion + i, NULL);
		return false;
	case Common::KEYCODE_F5:
		if (_vm->canSaveGameStateCurrently()) {
			const EnginePlugin *plugin = NULL;
			EngineMan.findGame(_vm->_gameDescription->gameid, &plugin);

			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Save game:", "Save");
			dialog->setSaveMode(true);
			int16 savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
			Common::String savegameDescription = dialog->getResultString();
			delete dialog;

			if (savegameId != -1)
				_vm->saveGameState(savegameId, savegameDescription);
			}
		return false;
	case Common::KEYCODE_F7:
		if (_vm->canLoadGameStateCurrently()) {
			const EnginePlugin *plugin = NULL;
			EngineMan.findGame(_vm->_gameDescription->gameid, &plugin);

			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Restore game:", "Restore");
			dialog->setSaveMode(false);
			int16 savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
			delete dialog;

			if (savegameId != -1)
				_vm->loadGameState(savegameId);
		}
		return false;
	case Common::KEYCODE_d:
		if (event.kbd.flags & Common::KBD_CTRL) {
		// Start the debugger
			_vm->getDebugger()->attach();
			_vm->getDebugger()->onFrame();
			return false;
		}
		break;
	case Common::KEYCODE_x:
		if (event.kbd.flags & Common::KBD_ALT) {
			_vm->quit();
			return false;
		}
		break;
	case Common::KEYCODE_0:
	case Common::KEYCODE_1:
	case Common::KEYCODE_2:
	case Common::KEYCODE_3:
	case Common::KEYCODE_4:
		if (event.kbd.flags & Common::KBD_ALT) {
			_vm->_commandHandler->addCommand(kCmdLevel, -1, keycode - '0', NULL);
			return false;
		}
	default:
		break;
	}

	return true;
}
コード例 #13
0
ファイル: menu.cpp プロジェクト: AReim1982/scummvm
void MenuSystem::initMenu(MenuID menuID) {
	_items.clear();

	memcpy(_vm->_screen->_frontScreen, _background->getPixels(), 640 * 400);

	switch (menuID) {
	case kMenuIdMain:
		drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrWhatCanIDoForYou));
		addClickTextItem(kItemIdLoad, 0, 116, 320, 0, _vm->getSysString(kStrLoad), 253, 255);
		addClickTextItem(kItemIdSave, 0, 136, 320, 0, _vm->getSysString(kStrSave), 253, 255);
		addClickTextItem(kItemIdToggleText, 0, 166, 320, 0, _vm->getSysString(_vm->_cfgText ? kStrTextOn : kStrTextOff), 253, 255);
		addClickTextItem(kItemIdToggleVoices, 0, 186, 320, 0, _vm->getSysString(_vm->_cfgVoices ? kStrVoicesOn : kStrVoicesOff), 253, 255);
		addClickTextItem(kItemIdVolumesMenu, 0, 216, 320, 0, _vm->getSysString(kStrVolume), 253, 255);
		addClickTextItem(kItemIdPlay, 0, 246, 320, 0, _vm->getSysString(kStrPlay), 253, 255);
		addClickTextItem(kItemIdQuit, 0, 276, 320, 0, _vm->getSysString(kStrQuit), 253, 255);
		break;
	case kMenuIdLoad:
		if (ConfMan.getBool("originalsaveload")) {
			shadeRect(80, 92, 440, 141, 226, 225);
			drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrLoadGame));
			addClickTextItem(kItemIdSavegameUp, 0, 156, 545, 1, "^", 253, 255);
			addClickTextItem(kItemIdSavegameDown, 0, 196, 545, 1, "\\", 253, 255);
			addClickTextItem(kItemIdCancel, 0, 276, 320, 0, _vm->getSysString(kStrCancel), 253, 255);
			for (int i = 1; i <= 7; i++) {
				Common::String saveDesc = Common::String::format("SAVEGAME %d", i);
				addClickTextItem((ItemID)(kItemIdSavegame1 + i - 1), 0, 116 + 20 * (i - 1), 300, 0, saveDesc.c_str(), 231, 234);
			}
			loadSavegamesList();
			setSavegameCaptions(true);
		} else {
			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
			int slot = dialog->runModalWithCurrentTarget();
			delete dialog;

			if (slot >= 0)
				_vm->requestLoadgame(slot);

			_running = false;
		}
		break;
	case kMenuIdSave:
		if (ConfMan.getBool("originalsaveload")) {
			shadeRect(80, 92, 440, 141, 226, 225);
			drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrSaveGame));
			addClickTextItem(kItemIdSavegameUp, 0, 156, 545, 1, "^", 253, 255);
			addClickTextItem(kItemIdSavegameDown, 0, 196, 545, 1, "\\", 253, 255);
			addClickTextItem(kItemIdCancel, 0, 276, 320, 0, _vm->getSysString(kStrCancel), 253, 255);
			for (int i = 1; i <= 7; i++) {
				Common::String saveDesc = Common::String::format("SAVEGAME %d", i);
				addClickTextItem((ItemID)(kItemIdSavegame1 + i - 1), 0, 116 + 20 * (i - 1), 300, 0, saveDesc.c_str(), 231, 234);
			}
			int newSlotNum = loadSavegamesList() + 1;
			_savegames.push_back(SavegameItem(newSlotNum, Common::String::format("GAME %04d", _savegames.size())));
			setSavegameCaptions(true);
		} else {
			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
			int slot = dialog->runModalWithCurrentTarget();
			Common::String desc = dialog->getResultString();
			if (desc.empty()) {
				// Create our own description for the saved game, the user didn't enter one
				desc = dialog->createDefaultSaveDescription(slot);
			}

			if (slot >= 0)
				_vm->requestSavegame(slot, desc);

			_running = false;
		}
		break;
	case kMenuIdVolumes:
		drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrAdjustVolume));
		drawString(0, 131, 200, 0, 246, _vm->getSysString(kStrMaster));
		drawString(0, 156, 200, 0, 244, _vm->getSysString(kStrVoices));
		drawString(0, 181, 200, 0, 244, _vm->getSysString(kStrMusic));
		drawString(0, 206, 200, 0, 244, _vm->getSysString(kStrSoundFx));
		drawString(0, 231, 200, 0, 244, _vm->getSysString(kStrBackground));
		addClickTextItem(kItemIdDone, 0, 276, 200, 0, _vm->getSysString(kStrDone), 253, 255);
		addClickTextItem(kItemIdCancel, 0, 276, 440, 0, _vm->getSysString(kStrCancel), 253, 255);
		addClickTextItem(kItemIdMasterDown, 0, 131 + 25 * 0, 348, 1, "[", 243, 246);
		addClickTextItem(kItemIdVoicesDown, 0, 131 + 25 * 1, 348, 1, "[", 243, 246);
		addClickTextItem(kItemIdMusicDown, 0, 131 + 25 * 2, 348, 1, "[", 243, 246);
		addClickTextItem(kItemIdSoundFXDown, 0, 131 + 25 * 3, 348, 1, "[", 243, 246);
		addClickTextItem(kItemIdBackgroundDown, 0, 131 + 25 * 4, 348, 1, "[", 243, 246);
		addClickTextItem(kItemIdMasterUp, 0, 131 + 25 * 0, 372, 1, "]", 243, 246);
		addClickTextItem(kItemIdVoicesUp, 0, 131 + 25 * 1, 372, 1, "]", 243, 246);
		addClickTextItem(kItemIdMusicUp, 0, 131 + 25 * 2, 372, 1, "]", 243, 246);
		addClickTextItem(kItemIdSoundFXUp, 0, 131 + 25 * 3, 372, 1, "]", 243, 246);
		addClickTextItem(kItemIdBackgroundUp, 0, 131 + 25 * 4, 372, 1, "]", 243, 246);
		drawVolumeBar(kItemIdMaster);
		drawVolumeBar(kItemIdVoices);
		drawVolumeBar(kItemIdMusic);
		drawVolumeBar(kItemIdSoundFX);
		drawVolumeBar(kItemIdBackground);
		break;
	default:
		break;
	}

	for (Common::Array<Item>::iterator iter = _items.begin(); iter != _items.end(); ++iter) {
		if ((*iter).enabled)
			drawItem((*iter).id, false);
	}

	// Check if the mouse is already over an item
	_currItemID = kItemIdNone;
	Common::Point mousePos = _vm->_system->getEventManager()->getMousePos();
	handleMouseMove(mousePos.x, mousePos.y);
}
コード例 #14
0
ファイル: loadsave.cpp プロジェクト: mikeliturbe/scummvm
void DMEngine::saveGame() {
    _menuMan->drawDisabledMenu();
    _eventMan->showMouse();

    switch (getGameLanguage()) { // localized
    default:
    case Common::EN_ANY:
        _dialog->dialogDraw(nullptr, nullptr, "SAVE AND PLAY", "SAVE AND QUIT", "CANCEL", "LOAD", false, false, false);
        break;
    case Common::DE_DEU:
        _dialog->dialogDraw(nullptr, nullptr, "SICHERN/SPIEL", "SICHERN/ENDEN", "WIDERRUFEN", "LOAD", false, false, false);
        break;
    case Common::FR_FRA:
        _dialog->dialogDraw(nullptr, nullptr, "GARDER/JOUER", "GARDER/SORTIR", "ANNULLER", "LOAD", false, false, false);
        break;
    }

    enum SaveAndPlayChoice {
        kSaveAndPlay = 1,
        kSaveAndQuit = 2,
        kCancel = 3,
        kLoad = 4
    };

    SaveAndPlayChoice saveAndPlayChoice = (SaveAndPlayChoice)_dialog->getChoice(4, kDMDialogCommandSetViewport, 0, kDMDialogChoiceNone);

    if (saveAndPlayChoice == kLoad) {
        GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
        int loadSlot = dialog->runModalWithCurrentTarget();
        if (loadSlot >= 0) {
            _loadSaveSlotAtRuntime = loadSlot;
            return;
        }

        saveAndPlayChoice = kCancel;
    }

    if (saveAndPlayChoice == kSaveAndQuit || saveAndPlayChoice == kSaveAndPlay) {
        GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
        int16 saveSlot = dialog->runModalWithCurrentTarget();
        Common::String saveDescription = dialog->getResultString();
        if (saveDescription.empty())
            saveDescription = "Nice save ^^";
        delete dialog;

        if (saveSlot >= 0) {
            switch (getGameLanguage()) { // localized
            default:
            case Common::EN_ANY:
                _dialog->dialogDraw(nullptr, "SAVING GAME . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
                break;
            case Common::DE_DEU:
                _dialog->dialogDraw(nullptr, "SPIEL WIRD GESICHERT . . .", nullptr, nullptr, nullptr, nullptr, false, false, false);
                break;
            case Common::FR_FRA:
                _dialog->dialogDraw(nullptr, "UN MOMENT A SAUVEGARDER DU JEU...", nullptr, nullptr, nullptr, nullptr, false, false, false);
                break;
            }

            uint16 champHandObjWeight = 0;
            if (!_championMan->_leaderEmptyHanded) {
                champHandObjWeight = _dungeonMan->getObjectWeight(_championMan->_leaderHandObject);
                _championMan->_champions[_championMan->_leaderIndex]._load -= champHandObjWeight;
            }

            if (!writeCompleteSaveFile(saveSlot, saveDescription, saveAndPlayChoice)) {
                _dialog->dialogDraw(nullptr, "Unable to open file for saving", "OK", nullptr, nullptr, nullptr, false, false, false);
                _dialog->getChoice(1, kDMDialogCommandSetViewport, 0, kDMDialogChoiceNone);
            }

            if (!_championMan->_leaderEmptyHanded) {
                _championMan->_champions[_championMan->_leaderIndex]._load += champHandObjWeight;
            }
        } else
            saveAndPlayChoice = kCancel;
    }


    if (saveAndPlayChoice == kSaveAndQuit) {
        _eventMan->hideMouse();
        endGame(false);
    }

    _restartGameAllowed = true;
    _menuMan->drawEnabledMenus();
    _eventMan->hideMouse();
}