示例#1
0
int Engine::runDialog(GUI::Dialog &dialog) {
	pauseEngine(true);
	int result = dialog.runModal();
	pauseEngine(false);

	return result;
}
示例#2
0
void MohawkEngine_Riven::runLoadDialog() {
	GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);

	pauseEngine(true);
	int slot = slc.runModalWithCurrentTarget();
	pauseEngine(false);

	if (slot >= 0) {
		loadGameStateAndDisplayError(slot);
	}
}
示例#3
0
文件: agos.cpp 项目: bluddy/scummvm
void AGOSEngine::pause() {
	pauseEngine(true);

	while (_pause && !shouldQuit()) {
		delay(1);
		if (_keyPressed.keycode == Common::KEYCODE_PAUSE) {
			pauseEngine(false);
			_keyPressed.reset();
		}
	}
}
示例#4
0
Common::Error Sword2Engine::run() {
	// Get some falling RAM and put it in your pocket, never let it slip
	// away

	_debugger = NULL;
	_sound = NULL;
	_fontRenderer = NULL;
	_screen = NULL;
	_mouse = NULL;
	_logic = NULL;
	_resman = NULL;
	_memory = NULL;

	initGraphics(640, 480, true);
	_screen = new Screen(this, 640, 480);

	// Create the debugger as early as possible (but not before the
	// screen object!) so that errors can be displayed in it. In
	// particular, we want errors about missing files to be clearly
	// visible to the user.

	_debugger = new Debugger(this);

	_memory = new MemoryManager(this);
	_resman = new ResourceManager(this);

	if (!_resman->init())
		return Common::kUnknownError;

	_logic = new Logic(this);
	_fontRenderer = new FontRenderer(this);
	_sound = new Sound(this);
	_mouse = new Mouse(this);

	registerDefaultSettings();
	readSettings();

	initStartMenu();

	// During normal gameplay, we care neither about mouse button releases
	// nor the scroll wheel.
	setInputEventFilter(RD_LEFTBUTTONUP | RD_RIGHTBUTTONUP | RD_WHEELUP | RD_WHEELDOWN);

	setupPersistentResources();
	initialiseFontResourceFlags();

	if (_features & GF_DEMO)
		_logic->writeVar(DEMO, 1);
	else
		_logic->writeVar(DEMO, 0);

	if (_saveSlot != -1) {
		if (saveExists(_saveSlot))
			restoreGame(_saveSlot);
		else {
			RestoreDialog dialog(this);
			if (!dialog.runModal())
				startGame();
		}
	} else if (!_bootParam && saveExists() && !isPsx()) { // Initial load/restart panel disabled in PSX
		int32 pars[2] = { 221, FX_LOOP };                 // version because of missing panel resources
		bool result;

		_mouse->setMouse(NORMAL_MOUSE_ID);
		_logic->fnPlayMusic(pars);

		StartDialog dialog(this);

		result = (dialog.runModal() != 0);

		// If the game is started from the beginning, the cutscene
		// player will kill the music for us. Otherwise, the restore
		// will either have killed the music, or done a crossfade.

		if (shouldQuit())
			return Common::kNoError;

		if (result)
			startGame();
	} else
		startGame();

	_screen->initialiseRenderCycle();

	while (1) {
		_debugger->onFrame();

		// Handle GMM Loading
		if (_gmmLoadSlot != -1) {

			// Hide mouse cursor and fade screen
			_mouse->hideMouse();
			_screen->fadeDown();

			// Clean up and load game
			_logic->_router->freeAllRouteMem();

			// TODO: manage error handling
			restoreGame(_gmmLoadSlot);

			// Reset load slot
			_gmmLoadSlot = -1;

			// Show mouse
			_mouse->addHuman();
		}

		KeyboardEvent *ke = keyboardEvent();

		if (ke) {
			if ((ke->kbd.hasFlags(Common::KBD_CTRL) && ke->kbd.keycode == Common::KEYCODE_d) || ke->kbd.ascii == '#' || ke->kbd.ascii == '~') {
				_debugger->attach();
			} else if (ke->kbd.hasFlags(0) || ke->kbd.hasFlags(Common::KBD_SHIFT)) {
				switch (ke->kbd.keycode) {
				case Common::KEYCODE_p:
					if (isPaused()) {
						_screen->dimPalette(false);
						pauseEngine(false);
					} else {
						pauseEngine(true);
						_screen->dimPalette(true);
					}
					break;
#if 0
				// Disabled because of strange rumors about the
				// credits running spontaneously every few
				// minutes.
				case Common::KEYCODE_c:
					if (!_logic->readVar(DEMO) && !_mouse->isChoosing()) {
						ScreenInfo *screenInfo = _screen->getScreenInfo();
						_logic->fnPlayCredits(NULL);
						screenInfo->new_palette = 99;
					}
					break;
#endif
				default:
					break;
				}
			}
		}

		// skip GameCycle if we're paused
		if (!isPaused()) {
			_gameCycle++;
			gameCycle();
		}

		// We can't use this as termination condition for the loop,
		// because we want the break to happen before updating the
		// screen again.

		if (shouldQuit())
			break;

		// creates the debug text blocks
		_debugger->buildDebugText();

		_screen->buildDisplay();
	}

	return Common::kNoError;
}
示例#5
0
void StarkEngine::processEvents() {
	Common::Event e;
	while (g_system->getEventManager()->pollEvent(e)) {
		// Handle any buttons, keys and joystick operations

		if (isPaused()) {
			// Only pressing key P to resume the game is allowed when the game is paused
			if (e.type == Common::EVENT_KEYDOWN && e.kbd.keycode == Common::KEYCODE_p) {
				pauseEngine(false);
			}
			continue;
		} 

		if (e.type == Common::EVENT_KEYDOWN) {
			if (e.kbd.keycode == Common::KEYCODE_d) {
				if (e.kbd.flags & Common::KBD_CTRL) {
					_console->attach();
					_console->onFrame();
				}
			} else if (e.kbd.keycode == Common::KEYCODE_ESCAPE) {
				_userInterface->handleEscape();
			} else if ((e.kbd.keycode == Common::KEYCODE_RETURN
					|| e.kbd.keycode == Common::KEYCODE_KP_ENTER)) {
				if (e.kbd.hasFlags(Common::KBD_ALT)) {
					_gfx->toggleFullscreen();
				} else if (_userInterface->isInGameScreen()){
					_userInterface->selectFocusedDialogOption();
				}
			} else if (e.kbd.keycode == Common::KEYCODE_F1) {
				_userInterface->toggleScreen(Screen::kScreenDiaryIndex);
			} else if (e.kbd.keycode == Common::KEYCODE_F2) {
				if (_userInterface->isInSaveLoadMenuScreen() || canSaveGameStateCurrently()) {
					_userInterface->toggleScreen(Screen::kScreenSaveMenu);
				}
			} else if (e.kbd.keycode == Common::KEYCODE_F3) {
				_userInterface->toggleScreen(Screen::kScreenLoadMenu);
			} else if (e.kbd.keycode == Common::KEYCODE_F4) {
				_userInterface->toggleScreen(Screen::kScreenDialog);
			} else if (e.kbd.keycode == Common::KEYCODE_F5) {
				if (_diary->isEnabled()) {
					_userInterface->toggleScreen(Screen::kScreenDiaryPages);
				}
			} else if (e.kbd.keycode == Common::KEYCODE_F6) {
				_userInterface->toggleScreen(Screen::kScreenFMVMenu);
			} else if (e.kbd.keycode == Common::KEYCODE_F7) {
				_userInterface->toggleScreen(Screen::kScreenSettingsMenu);
			} else if (e.kbd.keycode == Common::KEYCODE_F8) {
				warning("TODO: Implement the screenshot saving to local game directory");
			} else if (e.kbd.keycode == Common::KEYCODE_F9) {
				if (_userInterface->isInGameScreen()) {
					_userInterface->requestToggleSubtitle();
				}
			} else if (e.kbd.keycode == Common::KEYCODE_F10) {
				if (_userInterface->isInGameScreen() || _userInterface->isInDiaryIndexScreen()) {
					if (_userInterface->confirm(GameMessage::kQuitGamePrompt)) {
						_userInterface->requestQuitToMainMenu();
					}
				}
			} else if (e.kbd.keycode == Common::KEYCODE_a) {
				if (_userInterface->isInGameScreen()) {
					_userInterface->cycleBackInventory();
				}
			} else if (e.kbd.keycode == Common::KEYCODE_s) {
				if (_userInterface->isInGameScreen()) {
					_userInterface->cycleForwardInventory();
				}
			} else if (e.kbd.keycode == Common::KEYCODE_i) {
				if (_userInterface->isInGameScreen()) {
					_userInterface->inventoryOpen(!_userInterface->isInventoryOpen());
				}
			} else if (e.kbd.keycode == Common::KEYCODE_x
					&& !e.kbd.hasFlags(Common::KBD_ALT)) {
				if (_userInterface->isInGameScreen()) {
					_userInterface->toggleExitDisplay();
				}
			} else if ((e.kbd.keycode == Common::KEYCODE_x
					|| e.kbd.keycode == Common::KEYCODE_q)
					&& e.kbd.hasFlags(Common::KBD_ALT)) {
				if (_userInterface->confirm(GameMessage::kQuitPrompt)) {
					_userInterface->notifyShouldExit();
				}
			} else if (e.kbd.keycode == Common::KEYCODE_p) {
				if (_userInterface->isInGameScreen()) {
					pauseEngine(true);
					debug("The game is paused");
				}
			} else if (e.kbd.keycode == Common::KEYCODE_PAGEUP) {
				if (_userInterface->isInGameScreen()) {
					if (_userInterface->isInventoryOpen()) {
						_userInterface->scrollInventoryUp();
					} else {
						_userInterface->scrollDialogUp();
					}
				}
			} else if (e.kbd.keycode == Common::KEYCODE_UP) {
				if (_userInterface->isInGameScreen()) {
					if (_userInterface->isInventoryOpen()) {
						_userInterface->scrollInventoryUp();
					} else {
						_userInterface->focusPrevDialogOption();
					}
				}
			} else if (e.kbd.keycode == Common::KEYCODE_PAGEDOWN) {
				if (_userInterface->isInGameScreen()) {
					if (_userInterface->isInventoryOpen()) {
						_userInterface->scrollInventoryDown();
					} else {
						_userInterface->scrollDialogDown();
					}
				}
			} else if (e.kbd.keycode == Common::KEYCODE_DOWN) {
				if (_userInterface->isInGameScreen()) {
					if (_userInterface->isInventoryOpen()) {
						_userInterface->scrollInventoryDown();
					} else {
						_userInterface->focusNextDialogOption();
					}
				}
			} else if (e.kbd.keycode >= Common::KEYCODE_1 && e.kbd.keycode <= Common::KEYCODE_9) {
				if (_userInterface->isInGameScreen()) {
					_userInterface->selectDialogOptionByIndex(e.kbd.keycode - Common::KEYCODE_1);
				}
			}

		} else if (e.type == Common::EVENT_LBUTTONUP) {
			_userInterface->handleMouseUp();
		} else if (e.type == Common::EVENT_MOUSEMOVE) {
			_userInterface->handleMouseMove(e.mouse);
		} else if (e.type == Common::EVENT_LBUTTONDOWN) {
			_userInterface->handleClick();
			if (_system->getMillis() - _lastClickTime < _doubleClickDelay) {
				_userInterface->handleDoubleClick();
			}
			_lastClickTime = _system->getMillis();
		} else if (e.type == Common::EVENT_RBUTTONDOWN) {
			_userInterface->handleRightClick();
		} else if (e.type == Common::EVENT_SCREEN_CHANGED) {
			_gfx->computeScreenViewport();
			_fontProvider->initFonts();
			_userInterface->onScreenChanged();
		}
	}
}