/** * Resets the palette and refreshes saves. */ void SavedGameState::init() { if (_noUI) { _game->popState(); return; } _txtStatus->setText(L""); if (_origin != OPT_BATTLESCAPE) { _game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(6)), Palette::backPos, 16); } else { applyBattlescapeTheme(); } try { _saves = SavedGame::getList(_game->getLanguage()); _lstSaves->clearList(); sortList(Options::saveOrder); } catch (Exception &e) { Log(LOG_ERROR) << e.what(); } }
/** * Builds the interface. */ void SaveGameState::buildUi() { _screen = false; // Create objects _txtStatus = new Text(320, 17, 0, 92); // Set palette if (_origin == OPT_BATTLESCAPE) { _game->getSavedGame()->getSavedBattle()->setPaletteByDepth(this); } else { setPalette("PAL_GEOSCAPE", 6); } add(_txtStatus); centerAllSurfaces(); // Set up objects _txtStatus->setColor(Palette::blockOffset(8) + 5); _txtStatus->setBig(); _txtStatus->setAlign(ALIGN_CENTER); _txtStatus->setText(tr("STR_SAVING_GAME")); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
/** * Initializes UI colors according to origin. */ void OptionsBaseState::init() { if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
/** * Initializes all the elements in the Confirmation screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. * @param save Name of the save file to delete. */ DeleteGameState::DeleteGameState(OptionsOrigin origin, const std::string &save) : _origin(origin) { _filename = Options::getUserFolder() + save; _screen = false; // Create objects _window = new Window(this, 256, 100, 32, 50, POPUP_BOTH); _btnYes = new TextButton(60, 18, 60, 122); _btnNo = new TextButton(60, 18, 200, 122); _txtMessage = new Text(246, 32, 37, 70); // Set palette if (_origin == OPT_BATTLESCAPE) { setPalette("PAL_BATTLESCAPE"); } else { setPalette("PAL_GEOSCAPE", 6); } add(_window); add(_btnYes); add(_btnNo); add(_txtMessage); centerAllSurfaces(); // Set up objects _window->setColor(Palette::blockOffset(8)+10); _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnYes->setColor(Palette::blockOffset(8)+10); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&DeleteGameState::btnYesClick); _btnYes->onKeyboardPress((ActionHandler)&DeleteGameState::btnYesClick, Options::keyOk); _btnNo->setColor(Palette::blockOffset(8)+10); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&DeleteGameState::btnNoClick); _btnNo->onKeyboardPress((ActionHandler)&DeleteGameState::btnNoClick, Options::keyCancel); _txtMessage->setColor(Palette::blockOffset(8)+10); _txtMessage->setAlign(ALIGN_CENTER); _txtMessage->setBig(); _txtMessage->setWordWrap(true); _txtMessage->setText(tr("STR_IS_IT_OK_TO_DELETE_THE_SAVED_GAME")); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
/** * Initializes all the elements in the Restore Defaults screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. * @param state Pointer to the base Options state. */ OptionsDefaultsState::OptionsDefaultsState(Game *game, OptionsOrigin origin, OptionsBaseState *state) : State(game), _origin(origin), _state(state) { _screen = false; // Create objects _window = new Window(this, 256, 100, 32, 50, POPUP_BOTH); _btnYes = new TextButton(60, 18, 60, 122); _btnNo = new TextButton(60, 18, 200, 122); _txtTitle = new Text(246, 32, 37, 70); // Set palette if (_origin == OPT_BATTLESCAPE) { setPalette("PAL_BATTLESCAPE"); } else { setPalette("PAL_GEOSCAPE", 0); } add(_window); add(_btnYes); add(_btnNo); add(_txtTitle); centerAllSurfaces(); // Set up objects _window->setColor(Palette::blockOffset(8)+10); _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnYes->setColor(Palette::blockOffset(8)+10); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&OptionsDefaultsState::btnYesClick); _btnYes->onKeyboardPress((ActionHandler)&OptionsDefaultsState::btnYesClick, Options::keyOk); _btnNo->setColor(Palette::blockOffset(8)+10); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&OptionsDefaultsState::btnNoClick); _btnNo->onKeyboardPress((ActionHandler)&OptionsDefaultsState::btnNoClick, Options::keyCancel); _txtTitle->setColor(Palette::blockOffset(8)+10); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setBig(); _txtTitle->setWordWrap(true); _txtTitle->setText(tr("STR_RESTORE_DEFAULTS_QUESTION")); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
/** * Initializes all the elements in the Confirm Load screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. * @param fileName Name of the save file without extension. */ ConfirmLoadState::ConfirmLoadState(OptionsOrigin origin, std::string fileName) : _origin(origin), _fileName(fileName) { _screen = false; // Create objects _window = new Window(this, 216, 100, 52, 50, POPUP_BOTH); _btnYes = new TextButton(50, 20, 70, 120); _btnNo = new TextButton(50, 20, 200, 120); _txtText = new Text(204, 58, 58, 60); // Set palette if (_origin == OPT_BATTLESCAPE) { setPalette("PAL_BATTLESCAPE"); } else { setPalette("PAL_GEOSCAPE", 6); } add(_window); add(_btnYes); add(_btnNo); add(_txtText); centerAllSurfaces(); // Set up objects _window->setColor(Palette::blockOffset(15)-1); _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnYes->setColor(Palette::blockOffset(15)-1); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&ConfirmLoadState::btnYesClick); _btnYes->onKeyboardPress((ActionHandler)&ConfirmLoadState::btnYesClick, Options::keyOk); _btnNo->setColor(Palette::blockOffset(15)-1); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&ConfirmLoadState::btnNoClick); _btnNo->onKeyboardPress((ActionHandler)&ConfirmLoadState::btnNoClick, Options::keyCancel); _txtText->setColor(Palette::blockOffset(15)-1); _txtText->setAlign(ALIGN_CENTER); _txtText->setBig(); _txtText->setWordWrap(true); _txtText->setText(tr("STR_MISSING_CONTENT_PROMPT")); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
/** * Initializes all the elements in the Confirmation screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. * @param save Name of the save file to delete. */ DeleteGameState::DeleteGameState(Game *game, OptionsOrigin origin, const std::wstring &save) : State(game), _origin(origin) { std::string file = Language::wstrToFs(save); _filename = Options::getUserFolder() + file + ".sav"; _screen = false; // Create objects _window = new Window(this, 256, 120, 32, 40, POPUP_BOTH); _btnYes = new TextButton(60, 18, 90, 112); _btnNo = new TextButton(60, 18, 170, 112); _txtMessage = new Text(246, 32, 37, 70); // Set palette if (_origin != OPT_BATTLESCAPE) { _game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(6)), Palette::backPos, 16); } add(_window); add(_btnYes); add(_btnNo); add(_txtMessage); centerAllSurfaces(); // Set up objects _window->setColor(Palette::blockOffset(8)+10); _window->setBackground(game->getResourcePack()->getSurface("BACK01.SCR")); _btnYes->setColor(Palette::blockOffset(8)+10); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&DeleteGameState::btnYesClick); _btnYes->onKeyboardPress((ActionHandler)&DeleteGameState::btnYesClick, (SDLKey)Options::getInt("keyOk")); _btnNo->setColor(Palette::blockOffset(8)+10); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&DeleteGameState::btnNoClick); _btnNo->onKeyboardPress((ActionHandler)&DeleteGameState::btnNoClick, (SDLKey)Options::getInt("keyCancel")); _txtMessage->setColor(Palette::blockOffset(8)+10); _txtMessage->setAlign(ALIGN_CENTER); _txtMessage->setBig(); _txtMessage->setWordWrap(true); _txtMessage->setText(tr("STR_IS_IT_OK_TO_DELETE_THE_SAVED_GAME")); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
/** * Initializes all the elements in the Abandon Game screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. */ AbandonGameState::AbandonGameState(OptionsOrigin origin) : _origin(origin) { _screen = false; int x; if (_origin == OPT_GEOSCAPE) { x = 20; } else { x = 52; } // Create objects _window = new Window(this, 216, 160, x, 20, POPUP_BOTH); _btnYes = new TextButton(50, 20, x+18, 140); _btnNo = new TextButton(50, 20, x+148, 140); _txtTitle = new Text(206, 17, x+5, 70); // Set palette setInterface("geoscape", false, _origin == OPT_BATTLESCAPE); add(_window, "genericWindow", "geoscape"); add(_btnYes, "genericButton2", "geoscape"); add(_btnNo, "genericButton2", "geoscape"); add(_txtTitle, "genericText", "geoscape"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&AbandonGameState::btnYesClick); _btnYes->onKeyboardPress((ActionHandler)&AbandonGameState::btnYesClick, Options::keyOk); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&AbandonGameState::btnNoClick); _btnNo->onKeyboardPress((ActionHandler)&AbandonGameState::btnNoClick, Options::keyCancel); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setBig(); _txtTitle->setText(tr("STR_ABANDON_GAME_QUESTION")); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
/** * Initializes all the elements in the Confirm Display Options screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. */ OptionsConfirmState::OptionsConfirmState(OptionsOrigin origin) : _origin(origin), _countdown(15) { _screen = false; // Create objects _window = new Window(this, 216, 100, 52, 50, POPUP_BOTH); _btnYes = new TextButton(50, 20, 70, 120); _btnNo = new TextButton(50, 20, 200, 120); _txtTitle = new Text(206, 20, 57, 70); _txtTimer = new Text(206, 20, 57, 100); _timer = new Timer(1000); // Set palette setInterface("mainMenu", false, _game->getSavedGame() ? _game->getSavedGame()->getSavedBattle() : 0); add(_window, "confirmVideo", "mainMenu"); add(_btnYes, "confirmVideo", "mainMenu"); add(_btnNo, "confirmVideo", "mainMenu"); add(_txtTitle, "confirmVideo", "mainMenu"); add(_txtTimer, "confirmVideo", "mainMenu"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&OptionsConfirmState::btnYesClick); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&OptionsConfirmState::btnNoClick); // no keyboard shortcuts to make sure users can see the message _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setWordWrap(true); _txtTitle->setText(tr("STR_DISPLAY_OPTIONS_CONFIRM")); _txtTimer->setAlign(ALIGN_CENTER); _txtTimer->setWordWrap(true); _txtTimer->setText(tr("STR_DISPLAY_OPTIONS_REVERT").arg(_countdown)); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } _timer->onTimer((StateHandler)&OptionsConfirmState::countdown); _timer->start(); }
/** * Refreshes the saves list. */ void ListGamesState::init() { State::init(); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } try { _saves = SavedGame::getList(_game->getLanguage(), _autoquick); _lstSaves->clearList(); sortList(Options::saveOrder); } catch (Exception &e) { Log(LOG_ERROR) << e.what(); } }
/** * Initializes all the elements in the Confirm Load screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. * @param fileName Name of the save file without extension. */ ConfirmLoadState::ConfirmLoadState(OptionsOrigin origin, const std::string &fileName) : _origin(origin), _fileName(fileName) { _screen = false; // Create objects _window = new Window(this, 216, 100, 52, 50, POPUP_BOTH); _btnYes = new TextButton(50, 20, 70, 120); _btnNo = new TextButton(50, 20, 200, 120); _txtText = new Text(204, 58, 58, 60); // Set palette setInterface("saveMenus", false, _game->getSavedGame() ? _game->getSavedGame()->getSavedBattle() : 0); add(_window, "confirmLoad", "saveMenus"); add(_btnYes, "confirmLoad", "saveMenus"); add(_btnNo, "confirmLoad", "saveMenus"); add(_txtText, "confirmLoad", "saveMenus"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK01.SCR")); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&ConfirmLoadState::btnYesClick); _btnYes->onKeyboardPress((ActionHandler)&ConfirmLoadState::btnYesClick, Options::keyOk); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&ConfirmLoadState::btnNoClick); _btnNo->onKeyboardPress((ActionHandler)&ConfirmLoadState::btnNoClick, Options::keyCancel); _txtText->setAlign(ALIGN_CENTER); _txtText->setBig(); _txtText->setWordWrap(true); _txtText->setText(tr("STR_MISSING_CONTENT_PROMPT")); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
/** * Initializes all the elements in the Restore Defaults screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. * @param state Pointer to the base Options state. */ OptionsDefaultsState::OptionsDefaultsState(OptionsOrigin origin, OptionsBaseState *state) : _origin(origin), _state(state) { _screen = false; // Create objects _window = new Window(this, 256, 100, 32, 50, POPUP_BOTH); _btnYes = new TextButton(60, 18, 60, 122); _btnNo = new TextButton(60, 18, 200, 122); _txtTitle = new Text(246, 32, 37, 70); // Set palette setInterface("mainMenu", false, _game->getSavedGame() ? _game->getSavedGame()->getSavedBattle() : 0); add(_window, "confirmDefaults", "mainMenu"); add(_btnYes, "confirmDefaults", "mainMenu"); add(_btnNo, "confirmDefaults", "mainMenu"); add(_txtTitle, "confirmDefaults", "mainMenu"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK01.SCR")); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&OptionsDefaultsState::btnYesClick); _btnYes->onKeyboardPress((ActionHandler)&OptionsDefaultsState::btnYesClick, Options::keyOk); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&OptionsDefaultsState::btnNoClick); _btnNo->onKeyboardPress((ActionHandler)&OptionsDefaultsState::btnNoClick, Options::keyCancel); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setBig(); _txtTitle->setWordWrap(true); _txtTitle->setText(tr("STR_RESTORE_DEFAULTS_QUESTION")); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
/** * Initializes all the elements in the Pause window. * @param game Pointer to the core game. * @param origin Game section that originated this state. */ PauseState::PauseState(Game *game, OptionsOrigin origin) : State(game), _origin(origin) { _screen = false; int x; if (_origin == OPT_GEOSCAPE) { x = 20; } else { x = 52; } // Create objects _window = new Window(this, 216, 160, x, 20, POPUP_BOTH); _btnLoad = new TextButton(180, 18, x+18, 52); _btnSave = new TextButton(180, 18, x+18, 74); _btnAbandon = new TextButton(180, 18, x+18, 96); _btnOptions = new TextButton(180, 18, x+18, 122); _btnCancel = new TextButton(180, 18, x+18, 150); _txtTitle = new Text(206, 15, x+5, 32); // Set palette if (_origin != OPT_BATTLESCAPE) { _game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(0)), Palette::backPos, 16); } add(_window); add(_btnLoad); add(_btnSave); add(_btnAbandon); add(_btnOptions); add(_btnCancel); add(_txtTitle); centerAllSurfaces(); // Set up objects _window->setColor(Palette::blockOffset(15)-1); _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnLoad->setColor(Palette::blockOffset(15)-1); _btnLoad->setText(tr("STR_LOAD_GAME")); _btnLoad->onMouseClick((ActionHandler)&PauseState::btnLoadClick); _btnSave->setColor(Palette::blockOffset(15)-1); _btnSave->setText(tr("STR_SAVE_GAME")); _btnSave->onMouseClick((ActionHandler)&PauseState::btnSaveClick); _btnAbandon->setColor(Palette::blockOffset(15)-1); _btnAbandon->setText(tr("STR_ABANDON_GAME")); _btnAbandon->onMouseClick((ActionHandler)&PauseState::btnAbandonClick); _btnOptions->setColor(Palette::blockOffset(15)-1); _btnOptions->setText(tr("STR_GAME_OPTIONS")); _btnOptions->onMouseClick((ActionHandler)&PauseState::btnOptionsClick); _btnCancel->setColor(Palette::blockOffset(15)-1); _btnCancel->setText(tr("STR_CANCEL_UC")); _btnCancel->onMouseClick((ActionHandler)&PauseState::btnCancelClick); _btnCancel->onKeyboardPress((ActionHandler)&PauseState::btnCancelClick, (SDLKey)Options::getInt("keyCancel")); if (origin == OPT_GEOSCAPE) _btnCancel->onKeyboardPress((ActionHandler)&PauseState::btnCancelClick, (SDLKey)Options::getInt("keyGeoOptions")); else if (origin == OPT_BATTLESCAPE) _btnCancel->onKeyboardPress((ActionHandler)&PauseState::btnCancelClick, (SDLKey)Options::getInt("keyBattleOptions")); _txtTitle->setColor(Palette::blockOffset(15)-1); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setBig(); _txtTitle->setText(tr("STR_OPTIONS_UC")); if (Options::getInt("autosave") >= 2) { _btnSave->setVisible(false); _btnLoad->setVisible(false); } if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
/** * Initializes all the elements in the Pause window. * @param game Pointer to the core game. * @param origin Game section that originated this state. */ PauseState::PauseState(OptionsOrigin origin) : _origin(origin) { _screen = false; int x; if (_origin == OPT_GEOSCAPE) { x = 20; } else { x = 52; } // Create objects _window = new Window(this, 216, 160, x, 20, POPUP_BOTH); _btnLoad = new TextButton(180, 18, x+18, 52); _btnSave = new TextButton(180, 18, x+18, 74); _btnAbandon = new TextButton(180, 18, x+18, 96); _btnOptions = new TextButton(180, 18, x+18, 122); _btnCancel = new TextButton(180, 18, x+18, 150); _txtTitle = new Text(206, 17, x+5, 32); // Set palette setInterface("pauseMenu", false, _game->getSavedGame() ? _game->getSavedGame()->getSavedBattle() : 0); add(_window, "window", "pauseMenu"); add(_btnLoad, "button", "pauseMenu"); add(_btnSave, "button", "pauseMenu"); add(_btnAbandon, "button", "pauseMenu"); add(_btnOptions, "button", "pauseMenu"); add(_btnCancel, "button", "pauseMenu"); add(_txtTitle, "text", "pauseMenu"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK01.SCR")); _btnLoad->setText(tr("STR_LOAD_GAME")); _btnLoad->onMouseClick((ActionHandler)&PauseState::btnLoadClick); _btnSave->setText(tr("STR_SAVE_GAME")); _btnSave->onMouseClick((ActionHandler)&PauseState::btnSaveClick); _btnAbandon->setText(tr("STR_ABANDON_GAME")); _btnAbandon->onMouseClick((ActionHandler)&PauseState::btnAbandonClick); _btnOptions->setText(tr("STR_GAME_OPTIONS")); _btnOptions->onMouseClick((ActionHandler)&PauseState::btnOptionsClick); _btnCancel->setText(tr("STR_CANCEL_UC")); _btnCancel->onMouseClick((ActionHandler)&PauseState::btnCancelClick); _btnCancel->onKeyboardPress((ActionHandler)&PauseState::btnCancelClick, Options::keyCancel); if (origin == OPT_GEOSCAPE) { _btnCancel->onKeyboardPress((ActionHandler)&PauseState::btnCancelClick, Options::keyGeoOptions); } else if (origin == OPT_BATTLESCAPE) { _btnCancel->onKeyboardPress((ActionHandler)&PauseState::btnCancelClick, Options::keyBattleOptions); } _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setBig(); _txtTitle->setText(tr("STR_OPTIONS_UC")); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } if (_game->getSavedGame()->isIronman()) { _btnLoad->setVisible(false); _btnSave->setVisible(false); _btnAbandon->setText(tr("STR_SAVE_AND_ABANDON_GAME")); } }