diff --git a/RemixedDungeon/src/android/java/com/nyrds/platform/game/Game.java b/RemixedDungeon/src/android/java/com/nyrds/platform/game/Game.java index de6634727..5fa9fe1ef 100644 --- a/RemixedDungeon/src/android/java/com/nyrds/platform/game/Game.java +++ b/RemixedDungeon/src/android/java/com/nyrds/platform/game/Game.java @@ -402,4 +402,8 @@ public static void openPlayStore() { } } + public static void updateFpsLimit() { + + } + } diff --git a/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/game/GameLoop.java b/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/game/GameLoop.java index 387ad2a75..f7a6e514c 100644 --- a/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/game/GameLoop.java +++ b/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/game/GameLoop.java @@ -218,15 +218,6 @@ public void onFrame() { switchScene(sceneClass.newInstance()); return; } - - while (!motionEvents.isEmpty()) { - Touchscreen.processEvent(motionEvents.poll()); - } - - while (!keysEvents.isEmpty()) { - Keys.processEvent(keysEvents.poll()); - } - } catch (LuaError e) { throw ModdingMode.modException(e); } catch (Exception e) { @@ -256,6 +247,14 @@ public void onFrame() { @SneakyThrows public void update() { synchronized (stepLock) { + while (!motionEvents.isEmpty()) { + Touchscreen.processEvent(motionEvents.poll()); + } + + while (!keysEvents.isEmpty()) { + Keys.processEvent(keysEvents.poll()); + } + elapsed = timeScale * step * 0.001f; if (scene != null) { scene.update(); diff --git a/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/game/GamePreferences.java b/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/game/GamePreferences.java index 8a8ee2e87..0ea717669 100644 --- a/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/game/GamePreferences.java +++ b/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/game/GamePreferences.java @@ -291,4 +291,12 @@ static public void useLocale(String lang) { public static void setSelectedLanguage() { useLocale(uiLanguage()); } + + public static void fps_limit(int value) { + Preferences.INSTANCE.put(CommonPrefs.KEY_FPS_LIMIT, value); + } + + public static int fps_limit() { + return Preferences.INSTANCE.getInt(CommonPrefs.KEY_FPS_LIMIT, 0); + } } diff --git a/RemixedDungeon/src/main/java/com/nyrds/platform/storage/CommonPrefs.java b/RemixedDungeon/src/main/java/com/nyrds/platform/storage/CommonPrefs.java index 5bac7deae..18c1dbefd 100644 --- a/RemixedDungeon/src/main/java/com/nyrds/platform/storage/CommonPrefs.java +++ b/RemixedDungeon/src/main/java/com/nyrds/platform/storage/CommonPrefs.java @@ -29,4 +29,5 @@ public class CommonPrefs { public static final String KEY_MUSIC_VOLUME = "music_volume"; public static final String KEY_SOUND_FX_VOLUME = "soundfx_volume"; + public static final String KEY_FPS_LIMIT = "fps_limit"; } diff --git a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/windows/WndMenuCommon.java b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/windows/WndMenuCommon.java index 2e6903ec9..6ff4caee7 100644 --- a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/windows/WndMenuCommon.java +++ b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/windows/WndMenuCommon.java @@ -6,6 +6,7 @@ import com.nyrds.pixeldungeon.windows.VBox; import com.nyrds.platform.audio.MusicManager; import com.nyrds.platform.audio.Sample; +import com.nyrds.platform.game.Game; import com.nyrds.platform.util.StringsManager; import com.watabou.noosa.Image; import com.watabou.pixeldungeon.Assets; @@ -38,25 +39,18 @@ public void onBackPressed() { } protected void addSoundControls(VBox menuItems) { - /* - menuItems.add(new MenuCheckBox(R.string.WndSettings_Music, GamePreferences.music()) { - @Override - protected void onClick() { - super.onClick(); - GamePreferences.music(checked()); - } - }); - - menuItems.add(new MenuCheckBox(R.string.WndSettings_Sound, GamePreferences.soundFx()) { + Slider fps = new Slider(R.string.WndSettings_FpsLimit, "30", "120", 0, 2) { @Override - protected void onClick() { - super.onClick(); - GamePreferences.soundFx(checked()); - Sample.INSTANCE.play(Assets.SND_CLICK); + protected void onChange() { + int value = getSelectedValue(); + GamePreferences.fps_limit(value); + Game.updateFpsLimit(); } - }); - */ + }; + fps.setSelectedValue(GamePreferences.fps_limit()); + fps.setSize(WIDTH,BUTTON_HEIGHT); + menuItems.add(fps); Slider sfx = new Slider(R.string.WndSettings_Sound, "0", "1", 0, 10) { @Override diff --git a/RemixedDungeon/src/main/res/values/strings_all.xml b/RemixedDungeon/src/main/res/values/strings_all.xml index b7fc91dff..460dbe41b 100644 --- a/RemixedDungeon/src/main/res/values/strings_all.xml +++ b/RemixedDungeon/src/main/res/values/strings_all.xml @@ -2978,5 +2978,6 @@ No, there was no place for her in the light, not anymore. She turned from the me Deleting %s This is Sparta!!! + FPS limit diff --git a/RemixedDungeonDesktop/src/libgdx/java/com/nyrds/platform/game/Game.java b/RemixedDungeonDesktop/src/libgdx/java/com/nyrds/platform/game/Game.java index 8cdde72dd..8db767bca 100644 --- a/RemixedDungeonDesktop/src/libgdx/java/com/nyrds/platform/game/Game.java +++ b/RemixedDungeonDesktop/src/libgdx/java/com/nyrds/platform/game/Game.java @@ -10,6 +10,7 @@ import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.PixmapIO; import com.nyrds.pixeldungeon.game.GameLoop; +import com.nyrds.pixeldungeon.game.GamePreferences; import com.nyrds.pixeldungeon.ml.BuildConfig; import com.nyrds.pixeldungeon.support.PlayGames; import com.nyrds.platform.app.RemixedDungeonApp; @@ -258,4 +259,9 @@ public static void takeScreenshot() { pixmap.dispose(); } + + public static void updateFpsLimit() { + int[] limit = {30, 60, 120}; + Gdx.graphics.setForegroundFPS(limit[GamePreferences.fps_limit()]); + } } diff --git a/RemixedDungeonDesktop/src/libgdx/java/com/nyrds/platform/game/RemixedDungeon.java b/RemixedDungeonDesktop/src/libgdx/java/com/nyrds/platform/game/RemixedDungeon.java index 09bd4752c..0a2e24c0a 100644 --- a/RemixedDungeonDesktop/src/libgdx/java/com/nyrds/platform/game/RemixedDungeon.java +++ b/RemixedDungeonDesktop/src/libgdx/java/com/nyrds/platform/game/RemixedDungeon.java @@ -45,10 +45,6 @@ public static boolean canDonate() { public static void landscape(boolean value) { } - public static boolean storedLandscape() { - return true; - } - public static boolean landscape() { return true; } @@ -95,6 +91,8 @@ public void create() { ModdingMode.selectMod(GamePreferences.activeMod()); GamePreferences.uiLanguage(GamePreferences.uiLanguage()); + updateFpsLimit(); + super.create(); }