From b3d8b02cb84ff0615f800904b7a971f8c046136c Mon Sep 17 00:00:00 2001 From: yugecin Date: Sun, 20 Nov 2016 13:24:37 +0100 Subject: [PATCH] restart when the skin changed --- src/itdelatrisu/opsu/Options.java | 4 ++++ src/itdelatrisu/opsu/states/OptionsMenu.java | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index 634842a3..8f1eba32 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -1419,6 +1419,10 @@ public class Options { // This class should not be instantiated. private Options() {} + public static String getSkinName() { + return skinName; + } + public static int getResolutionIdx() { return resolutionIdx; } diff --git a/src/itdelatrisu/opsu/states/OptionsMenu.java b/src/itdelatrisu/opsu/states/OptionsMenu.java index 817933dd..8478095c 100644 --- a/src/itdelatrisu/opsu/states/OptionsMenu.java +++ b/src/itdelatrisu/opsu/states/OptionsMenu.java @@ -521,19 +521,24 @@ public class OptionsMenu extends BasicGameState { } } - private String resolutionOptions; + /** + * This string is built with option values when entering the options menu. + * When leaving the options menu, this string is checked against the new optionstring with the same options. + * If those do not match, it means some option has change which requires a restart + */ + private String restartOptions; @Override public void enter(GameContainer container, StateBasedGame game) throws SlickException { UI.enter(); currentTab = OptionTab.DANCE; - resolutionOptions = "" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions(); + restartOptions = "" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions() + Options.getSkinName(); } @Override public void leave(GameContainer container, StateBasedGame game) throws SlickException { - if (!("" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions()).equals(resolutionOptions)) { + if (!("" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions() + Options.getSkinName()).equals(restartOptions)) { container.setForceExit(false); container.exit(); }