void RingworldGame::processEvent(Event &event) { if (event.eventType == EVENT_KEYPRESS) { switch (event.kbd.keycode) { case Common::KEYCODE_F1: // F1 - Help MessageDialog::show(HELP_MSG, OK_BTN_STRING); break; case Common::KEYCODE_F2: { // F2 - Sound Options ConfigDialog *dlg = new ConfigDialog(); dlg->runModal(); delete dlg; _globals->_soundManager.syncSounds(); _globals->_events.setCursorFromFlag(); break; } case Common::KEYCODE_F3: // F3 - Quit quitGame(); event.handled = false; break; case Common::KEYCODE_F4: // F4 - Restart restartGame(); _globals->_events.setCursorFromFlag(); break; case Common::KEYCODE_F7: // F7 - Restore restoreGame(); _globals->_events.setCursorFromFlag(); break; case Common::KEYCODE_F10: // F10 - Pause GfxDialog::setPalette(); MessageDialog::show(GAME_PAUSED_MSG, OK_BTN_STRING); _globals->_events.setCursorFromFlag(); break; default: break; } } }
void Ringworld2Game::processEvent(Event &event) { if (event.eventType == EVENT_KEYPRESS) { switch (event.kbd.keycode) { case Common::KEYCODE_F1: // F1 - Help HelpDialog::show(); break; case Common::KEYCODE_F2: // F2 - Sound Options SoundDialog::execute(); break; case Common::KEYCODE_F3: // F3 - Quit quitGame(); event.handled = false; break; case Common::KEYCODE_F4: // F4 - Restart restartGame(); g_globals->_events.setCursorFromFlag(); break; case Common::KEYCODE_F7: // F7 - Restore restoreGame(); g_globals->_events.setCursorFromFlag(); break; case Common::KEYCODE_F8: // F8 - Credits warning("TODO: Show Credits"); break; case Common::KEYCODE_F10: // F10 - Pause GfxDialog::setPalette(); MessageDialog::show(GAME_PAUSED_MSG, OK_BTN_STRING); g_globals->_events.setCursorFromFlag(); break; default: break; } } }
/*======================================================================*/ void restore(void) { #ifdef HAVE_GLK frefid_t saveFileRef; strid_t saveFile; saveFileRef = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Read, 0); if (saveFileRef == NULL) return; saveFile = glk_stream_open_file(saveFileRef, filemode_Read, 0); if (saveFile == NULL) return; #else char str[1000]; FILE *saveFile; current.location = where(HERO, TRUE); /* First save ? */ if (saveFileName[0] == '\0') { strcpy(saveFileName, adventureName); strcat(saveFileName, ".sav"); } printMessage(M_RESTOREFROM); sprintf(str, "(%s) : ", saveFileName); output(str); #ifdef USE_READLINE readline(str); #else gets(str); #endif col = 1; if (str[0] == '\0') { strcpy(str, saveFileName); } if ((saveFile = fopen(str, READ_MODE)) == NULL) error(M_SAVEMISSING); strcpy(saveFileName, str); /* Save it for future use */ #endif restoreGame(saveFile); fclose(saveFile); }
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; }