From e7442926a11937069ba34c03e6e0a36b8dace0f3 Mon Sep 17 00:00:00 2001 From: Lance David Selga Date: Sun, 15 Oct 2017 14:08:29 +0800 Subject: [PATCH 1/4] Add option "Unlimited" FPS cap --- src/itdelatrisu/opsu/options/Options.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/itdelatrisu/opsu/options/Options.java b/src/itdelatrisu/opsu/options/Options.java index 24019b17..9bf6d0e4 100644 --- a/src/itdelatrisu/opsu/options/Options.java +++ b/src/itdelatrisu/opsu/options/Options.java @@ -399,7 +399,8 @@ public void selectItem(int index, GameContainer container) { @Override public String getValueString() { - return String.format((getTargetFPS() == 60) ? "%dfps (vsync)" : "%dfps", getTargetFPS()); + return String.format((getTargetFPS() == -1) ? "Unlimited" : + (getTargetFPS() == 60) ? "%dfps (vsync)" : "%dfps", getTargetFPS()); } @Override @@ -407,7 +408,8 @@ public Object[] getItemList() { if (itemList == null) { itemList = new String[targetFPS.length]; for (int i = 0; i < targetFPS.length; i++) - itemList[i] = String.format((targetFPS[i] == 60) ? "%dfps (vsync)" : "%dfps", targetFPS[i]); + itemList[i] = String.format((targetFPS[i] == -1) ? "Unlimited" : + (targetFPS[i] == 60) ? "%dfps (vsync)" : "%dfps", targetFPS[i]); } return itemList; } @@ -954,7 +956,7 @@ public boolean hasFullscreenDisplayMode() { private static Skin skin; /** Frame limiters. */ - private static final int[] targetFPS = { 60, 120, 240 }; + private static final int[] targetFPS = { 60, 120, 240, -1 }; /** Index in targetFPS[] array. */ private static int targetFPSindex = 0; From a5195264b8acd35a3db6842ba8c7468c84ef9826 Mon Sep 17 00:00:00 2001 From: Lance David Selga Date: Wed, 18 Oct 2017 20:50:42 +0800 Subject: [PATCH 2/4] Limit quick-toggle choices to 60, 120 and 240 "Unlimited" would remain accessible through the Options menu --- src/itdelatrisu/opsu/options/Options.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/itdelatrisu/opsu/options/Options.java b/src/itdelatrisu/opsu/options/Options.java index 9bf6d0e4..146eef8b 100644 --- a/src/itdelatrisu/opsu/options/Options.java +++ b/src/itdelatrisu/opsu/options/Options.java @@ -987,7 +987,7 @@ private Options() {} * @param container the game container */ public static void setNextFPS(GameContainer container) { - int index = (targetFPSindex + 1) % targetFPS.length; + int index = (targetFPSindex + 1) % (targetFPS.length - 1); GameOption.TARGET_FPS.selectItem(index, container); UI.getNotificationManager().sendBarNotification(String.format("Frame limiter: %s", GameOption.TARGET_FPS.getValueString())); } From 321bb82e4cd4e5c5d74cbd89f8e0f66d4d210697 Mon Sep 17 00:00:00 2001 From: Lance David Selga Date: Thu, 19 Oct 2017 06:41:09 +0800 Subject: [PATCH 3/4] Document changes to `setNextFPS()` Add a comment stating that changes to `index` would skip the last option by default. --- src/itdelatrisu/opsu/options/Options.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/itdelatrisu/opsu/options/Options.java b/src/itdelatrisu/opsu/options/Options.java index 146eef8b..84e1f1da 100644 --- a/src/itdelatrisu/opsu/options/Options.java +++ b/src/itdelatrisu/opsu/options/Options.java @@ -987,7 +987,7 @@ private Options() {} * @param container the game container */ public static void setNextFPS(GameContainer container) { - int index = (targetFPSindex + 1) % (targetFPS.length - 1); + int index = (targetFPSindex + 1) % (targetFPS.length - 1); // Skip "Unlimited" option GameOption.TARGET_FPS.selectItem(index, container); UI.getNotificationManager().sendBarNotification(String.format("Frame limiter: %s", GameOption.TARGET_FPS.getValueString())); } From 197cdd1cf2c7f1152766c8fd22dd73b74117fa88 Mon Sep 17 00:00:00 2001 From: Lance David Selga Date: Thu, 19 Oct 2017 06:42:39 +0800 Subject: [PATCH 4/4] Remove "Unlimited" value from `getValueString()` Was used when calling `setNextFPS()`, displaying the notification bar when changing the target FPS rate. Not needed anymore since the shortcut call to "Unlimited" has been removed. --- src/itdelatrisu/opsu/options/Options.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/itdelatrisu/opsu/options/Options.java b/src/itdelatrisu/opsu/options/Options.java index 84e1f1da..4a694662 100644 --- a/src/itdelatrisu/opsu/options/Options.java +++ b/src/itdelatrisu/opsu/options/Options.java @@ -399,8 +399,7 @@ public void selectItem(int index, GameContainer container) { @Override public String getValueString() { - return String.format((getTargetFPS() == -1) ? "Unlimited" : - (getTargetFPS() == 60) ? "%dfps (vsync)" : "%dfps", getTargetFPS()); + return String.format((getTargetFPS() == 60) ? "%dfps (vsync)" : "%dfps", getTargetFPS()); } @Override