Skip to content

Commit 2cccfbb

Browse files
committed
window centers only if res is different
1 parent 18e2845 commit 2cccfbb

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎source/funkin/backend/utils/WindowUtils.hx‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package funkin.backend.utils;
22

33
import lime.graphics.Image;
44
import openfl.Lib;
5-
import openfl.system.Capabilities;
65
#if windows
6+
import openfl.system.Capabilities;
77
import funkin.backend.utils.native.Windows;
88
#end
99

@@ -75,20 +75,25 @@ final class WindowUtils {
7575
* @param height The window's resolution height (Defaults to 720).
7676
* @param changeSize Should it also update the window size.
7777
**/
78-
public static function setResolution(?width:Int, ?height:Int, changeSize = #if windows true #else false #end) {
78+
public static function setResolution(?width:Int, ?height:Int, changeSize = true) {
7979

8080
var w = width == null ? Flags.GAME_WIDTH : width;
8181
var h = height == null ? Flags.GAME_HEIGHT : height;
8282

83+
if(FlxG.width == w && FlxG.height == h)
84+
return;
85+
8386
var win = Lib.application.window;
8487

8588
@:privateAccess {
86-
if(changeSize){
87-
win.resize(w, h);
88-
89-
win.x = Std.int((Capabilities.screenResolutionX / 2) - (w / 2));
90-
win.y = Std.int((Capabilities.screenResolutionY / 2) - (h / 2));
91-
}
89+
#if windows
90+
if(changeSize){
91+
win.resize(w, h);
92+
93+
win.x = Std.int((Capabilities.screenResolutionX / 2) - (w / 2));
94+
win.y = Std.int((Capabilities.screenResolutionY / 2) - (h / 2));
95+
}
96+
#end
9297

9398
FlxG.width = FlxG.initialWidth = w; FlxG.height = FlxG.initialHeight = h;
9499
}

0 commit comments

Comments
 (0)