FlxG.scaleMode.width now gray can stop bullying me

This commit is contained in:
Yoshman29
2023-01-25 12:54:14 +01:00
parent 37cd5ef677
commit 943988c10a
3 changed files with 70 additions and 1 deletions
+1 -1
View File
@@ -1 +1 @@
2190
2193
@@ -0,0 +1,63 @@
package funkin.system;
import flixel.FlxG;
import flixel.system.scaleModes.RatioScaleMode;
class FunkinRatioScaleMode extends RatioScaleMode {
@:isVar public var width(get, set):Null<Int> = null;
@:isVar public var height(get, set):Null<Int> = null;
public override function updateGameSize(Width:Int, Height:Int):Void
{
var ratio:Float = width / height;
var realRatio:Float = Width / Height;
var scaleY:Bool = realRatio < ratio;
if (fillScreen)
{
scaleY = !scaleY;
}
if (scaleY)
{
gameSize.x = Width;
gameSize.y = Math.floor(gameSize.x / ratio);
}
else
{
gameSize.y = Height;
gameSize.x = Math.floor(gameSize.y * ratio);
}
@:privateAccess {
FlxG.width = width;
FlxG.height = height;
for(c in FlxG.cameras.list) {
c.width = width;
c.height = height;
}
}
}
public function resetSize() {
width = null;
height = null;
}
private inline function get_width():Null<Int>
return this.width == null ? FlxG.initialWidth : this.width;
private inline function get_height():Null<Int>
return this.height == null ? FlxG.initialHeight : this.height;
private inline function set_width(v:Null<Int>):Null<Int> {
this.width = v;
@:privateAccess
FlxG.game.onResize(null);
return v;
}
private inline function set_height(v:Null<Int>):Null<Int> {
this.height = v;
@:privateAccess
FlxG.game.onResize(null);
return v;
}
}
+6
View File
@@ -39,6 +39,8 @@ class Main extends Sprite
{
public static var instance:Main;
public static var scaleMode:FunkinRatioScaleMode;
var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom).
var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).
var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions.
@@ -203,6 +205,8 @@ class Main extends Sprite
refreshAssets();
FlxG.scaleMode = scaleMode = new FunkinRatioScaleMode();
Conductor.init();
AudioSwitchFix.init();
WindowsAPI.setDarkMode(true);
@@ -238,6 +242,8 @@ class Main extends Sprite
// manual asset clearing since base openfl one doesnt clear lime one
// doesnt clear bitmaps since flixel fork does it auto
scaleMode.resetSize();
var cache = cast(Assets.cache, AssetCache);
for (key=>font in cache.font)
cache.removeFont(key);