From bed249dca08f4e1178ac08639c31ccf801ebb8ca Mon Sep 17 00:00:00 2001 From: MAJigsaw77 <77043862+MAJigsaw77@users.noreply.github.com> Date: Sun, 15 Mar 2026 06:04:25 +0200 Subject: [PATCH] Remove the framerate options on `web` --- source/Main.hx | 7 ----- source/funkin/Preferences.hx | 34 +++------------------ source/funkin/ui/options/PreferencesMenu.hx | 4 +-- 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/source/Main.hx b/source/Main.hx index c0e0ed3b6..8cc43d146 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -164,13 +164,6 @@ class Main extends Sprite }); #end - // Don't call anything from the preferences until the save is loaded! - #if web - // set this variable (which is a function) from the lime version at lime/_internal/backend/html5/HTML5Application.hx - // The framerate cap will more thoroughly initialize via Preferences in InitState.hx - funkin.Preferences.lockedFramerateFunction = untyped js.Syntax.code("window.requestAnimationFrame"); - #end - WindowUtil.setVSyncMode(funkin.Preferences.vsyncMode); // Force a `FunkinCamera` to be the default camera. diff --git a/source/funkin/Preferences.hx b/source/funkin/Preferences.hx index c9941abba..19d0912d8 100644 --- a/source/funkin/Preferences.hx +++ b/source/funkin/Preferences.hx @@ -344,7 +344,7 @@ class Preferences static function get_vsyncMode():lime.ui.WindowVSyncMode { - #if mobile + #if (mobile || web) return lime.ui.WindowVSyncMode.OFF; #else var value = Save?.instance?.options?.vsyncMode ?? "Off"; @@ -365,7 +365,7 @@ class Preferences static function set_vsyncMode(value:lime.ui.WindowVSyncMode):lime.ui.WindowVSyncMode { - #if mobile + #if (mobile || web) return lime.ui.WindowVSyncMode.OFF; #else var string; @@ -395,7 +395,7 @@ class Preferences static function get_unlockedFramerate():Bool { - #if mobile + #if (mobile || web) return false; #else return Save?.instance?.options?.unlockedFramerate ?? false; @@ -404,7 +404,7 @@ class Preferences static function set_unlockedFramerate(value:Bool):Bool { - #if mobile + #if (mobile || web) return false; #else if (value != Save.instance.options.unlockedFramerate) @@ -419,27 +419,6 @@ class Preferences #end } - #if web - // We create a haxe version of this just for readability. - // We use these to override `window.requestAnimationFrame` in Javascript to uncap the framerate / "animation" request rate - // Javascript is crazy since u can just do stuff like that lol - - public static function unlockedFramerateFunction(callback, element) - { - var currTime = Date.now().getTime(); - var timeToCall = 0; - var id = js.Browser.window.setTimeout(function() - { - callback(currTime + timeToCall); - }, timeToCall); - return id; - } - - // Lime already implements their own little framerate cap, so we can just use that - // This also gets set in the init function in Main.hx, since we need to definitely override it - public static var lockedFramerateFunction = untyped js.Syntax.code("window.requestAnimationFrame"); - #end - /** * If >0, the game will display a semi-opaque background under the notes. * `0` for no background, `100` for solid black if you're freaky like that @@ -539,10 +518,7 @@ class Preferences static function toggleFramerateCap(unlocked:Bool):Void { - #if web - var framerateFunction = unlocked ? unlockedFramerateFunction : lockedFramerateFunction; - untyped js.Syntax.code("window.requestAnimationFrame = framerateFunction;"); - #else + #if !(mobile || web) FlxG.drawFramerate = unlocked ? 0 : framerate; FlxG.updateFramerate = unlocked ? 0 : framerate; #end diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index c0b3ef720..540e0ebea 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -177,8 +177,8 @@ class PreferencesMenu extends Page }, Preferences.autoFullscreen); #end - // disable on mobile since it barely has any effect - #if !mobile + // disable on mobile and web since it barely has any effect + #if !(mobile || web) createPrefItemEnum('VSync', "When enabled, the game attempts to match the framerate with your monitor's refresh rate.", ["Off" => WindowVSyncMode.OFF, "On" => WindowVSyncMode.ON, "Adaptive" => WindowVSyncMode.ADAPTIVE,], function(key:String, value:WindowVSyncMode):Void {