diff --git a/source/funkin/backend/system/Main.hx b/source/funkin/backend/system/Main.hx index 78369f607..5795c4a1a 100644 --- a/source/funkin/backend/system/Main.hx +++ b/source/funkin/backend/system/Main.hx @@ -49,6 +49,10 @@ class Main extends Sprite public static var game:FunkinGame; + /** + * The time since the game was focused last time in seconds. + */ + public static var timeSinceFocus(get, never):Float; public static var time:Int = 0; // You can pretty much ignore everything from here on - your code should go in your states. @@ -152,6 +156,7 @@ class Main extends Sprite Conductor.init(); AudioSwitchFix.init(); EventManager.init(); + FlxG.signals.focusGained.add(onFocus); FlxG.signals.preStateSwitch.add(onStateSwitch); FlxG.signals.postStateSwitch.add(onStateSwitchPost); @@ -190,6 +195,10 @@ class Main extends Sprite {asset: diamond, width: 32, height: 32}, new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4)); } + public static function onFocus() { + _tickFocused = FlxG.game.ticks; + } + private static function onStateSwitch() { scaleMode.resetSize(); } @@ -209,4 +218,9 @@ class Main extends Sprite MemoryUtil.clearMajor(); } + + private static var _tickFocused:Float = 0; + public static function get_timeSinceFocus():Float { + return (FlxG.game.ticks - _tickFocused) / 1000; + } } diff --git a/source/funkin/options/OptionsScreen.hx b/source/funkin/options/OptionsScreen.hx index 455808215..b703d994e 100644 --- a/source/funkin/options/OptionsScreen.hx +++ b/source/funkin/options/OptionsScreen.hx @@ -45,7 +45,7 @@ class OptionsScreen extends FlxTypedSpriteGroup { if (members.length > 0) { members[curSelected].selected = true; - if (controls.ACCEPT || FlxG.mouse.justReleased) + if (controls.ACCEPT || (FlxG.mouse.justReleased && Main.timeSinceFocus > 0.25)) members[curSelected].onSelect(); if (controls.LEFT_P) members[curSelected].onChangeSelection(-1);