Skip to content

Commit

Permalink
Merge pull request #262 from tpenguinltg/restart-required
Browse files Browse the repository at this point in the history
Show restart button for options that require a restart
  • Loading branch information
itdelatrisu committed Feb 27, 2017
2 parents 1885016 + 8c42d32 commit 5e45f04
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
25 changes: 23 additions & 2 deletions src/itdelatrisu/opsu/options/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ public void read(String s) {
SCREEN_RESOLUTION ("Resolution", "ScreenResolution", "") {
private Resolution[] itemList = null;

@Override
public boolean isRestartRequired() { return true; }

@Override
public String getValueString() { return resolution.toString(); }

Expand Down Expand Up @@ -356,6 +359,9 @@ public void read(String s) {
}
},
FULLSCREEN ("Fullscreen mode", "Fullscreen", "Switches to dedicated fullscreen mode.", false) {
@Override
public boolean isRestartRequired() { return true; }

@Override
public void toggle(GameContainer container) {
// check if fullscreen mode is possible with this resolution
Expand All @@ -370,6 +376,9 @@ public void toggle(GameContainer container) {
SKIN ("Skin", "Skin", "") {
private String[] itemList = null;

@Override
public boolean isRestartRequired() { return true; }

/** Creates the list of available skins. */
private void createSkinList() {
File[] dirs = SkinLoader.getSkinDirectories(getSkinRootDir());
Expand Down Expand Up @@ -525,7 +534,10 @@ public void setValue(int value) {
@Override
public String getValueString() { return String.format("%dms", val); }
},
DISABLE_SOUNDS ("Disable all sound effects", "DisableSound", "May resolve Linux sound driver issues.\nRequires a restart.", false),
DISABLE_SOUNDS ("Disable all sound effects", "DisableSound", "May resolve Linux sound driver issues.\nRequires a restart.", false) {
@Override
public boolean isRestartRequired() { return true; }
},
KEY_LEFT ("Left game key", "keyOsuLeft", "Select this option to input a key.") {
@Override
public String getValueString() { return Keyboard.getKeyName(getGameKeyLeft()); }
Expand Down Expand Up @@ -643,7 +655,10 @@ public String getValueString() {
ENABLE_THEME_SONG ("Theme song", "MenuMusic", OpsuConstants.PROJECT_NAME + " will play themed music throughout the game, instead of using random beatmaps.", true),
REPLAY_SEEKING ("Replay seeking", "ReplaySeeking", "Enable a seeking bar on the left side of the screen during replays.", false),
DISABLE_UPDATER ("Disable automatic updates", "DisableUpdater", "Disable checking for updates when the game starts.", false),
ENABLE_WATCH_SERVICE ("Watch service", "WatchService", "Watch the beatmap directory for changes. Requires a restart.", false);
ENABLE_WATCH_SERVICE ("Watch service", "WatchService", "Watch the beatmap directory for changes. Requires a restart.", false) {
@Override
public boolean isRestartRequired() { return true; }
};

/** Option name. */
private final String name;
Expand Down Expand Up @@ -744,6 +759,12 @@ public enum OptionType { BOOLEAN, NUMERIC, SELECT }
*/
public OptionType getType() { return type; }

/**
* Returns whether a restart is required for the option to take effect.
* @return true if a restart is required, false otherwise
*/
public boolean isRestartRequired() { return false; }

/**
* Returns the boolean value for the option, if applicable.
* @return the boolean value
Expand Down
4 changes: 2 additions & 2 deletions src/itdelatrisu/opsu/options/OptionsOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public void itemSelected(int index, Object item) {
option.selectItem(index, OptionsOverlay.this.container);

// show restart button?
if (option == GameOption.SCREEN_RESOLUTION || option == GameOption.SKIN) {
if (option.isRestartRequired()) {
showRestartButton = true;
UI.getNotificationManager().sendBarNotification("Restart to apply changes.");
}
Expand Down Expand Up @@ -1017,7 +1017,7 @@ public void mouseReleased(int button, int x, int y) {
hoverOption.toggle(container);

// show restart button?
if (oldValue != hoverOption.getBooleanValue() && hoverOption == GameOption.FULLSCREEN) {
if (oldValue != hoverOption.getBooleanValue() && hoverOption.isRestartRequired()) {
showRestartButton = true;
UI.getNotificationManager().sendBarNotification("Restart to apply changes.");
}
Expand Down

0 comments on commit 5e45f04

Please sign in to comment.