MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / btnOkClick

Method btnOkClick

src/Menu/OptionsBaseState.cpp:211–247  ·  view source on GitHub ↗

* Saves the new options and returns to the proper origin screen. * @param action Pointer to an action. */

Source from the content-addressed store, hash-verified

209 * @param action Pointer to an action.
210 */
211void OptionsBaseState::btnOkClick(Action *)
212{
213 int dX = Options::baseXResolution;
214 int dY = Options::baseYResolution;
215 Screen::updateScale(Options::battlescapeScale, Options::newBattlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, _origin == OPT_BATTLESCAPE);
216 Screen::updateScale(Options::geoscapeScale, Options::newGeoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, _origin != OPT_BATTLESCAPE);
217 dX = Options::baseXResolution - dX;
218 dY = Options::baseYResolution - dY;
219 recenter(dX, dY);
220 Options::switchDisplay();
221 Options::save();
222 _game->loadLanguage(Options::language);
223 SDL_WM_GrabInput(Options::captureMouse);
224 _game->getScreen()->resetDisplay();
225 _game->setVolume(Options::soundVolume, Options::musicVolume, Options::uiVolume);
226 if (Options::reload && _origin == OPT_MENU)
227 {
228 _game->setState(new StartState(_game));
229 }
230 else
231 {
232 // Confirm any video options changes
233 if (Options::displayWidth != Options::newDisplayWidth ||
234 Options::displayHeight != Options::newDisplayHeight ||
235 Options::useOpenGL != Options::newOpenGL ||
236 Options::useScaleFilter != Options::newScaleFilter ||
237 Options::useHQXFilter != Options::newHQXFilter ||
238 Options::useOpenGLShader != Options::newOpenGLShader)
239 {
240 _game->pushState(new OptionsConfirmState(_game, _origin));
241 }
242 else
243 {
244 restart(_game, _origin);
245 }
246 }
247}
248
249/**
250 * Loads previous options and returns to the previous screen.

Callers

nothing calls this directly

Calls 8

switchDisplayFunction · 0.85
saveFunction · 0.85
loadLanguageMethod · 0.80
resetDisplayMethod · 0.80
getScreenMethod · 0.80
setVolumeMethod · 0.80
setStateMethod · 0.80
pushStateMethod · 0.80

Tested by

no test coverage detected