diff --git a/assets/songs/blammed/cutscene.hx b/assets/songs/blammed/cutscene.hx index 3df9ace2..cdeddd82 100644 --- a/assets/songs/blammed/cutscene.hx +++ b/assets/songs/blammed/cutscene.hx @@ -1,4 +1,3 @@ -import flixel.addons.display.FlxBackdrop; import flixel.util.FlxGradient; var cars = []; diff --git a/source/funkin/graphics/FlxBackdropExt.hx b/source/funkin/graphics/FlxBackdropExt.hx new file mode 100644 index 00000000..dd3d6a85 --- /dev/null +++ b/source/funkin/graphics/FlxBackdropExt.hx @@ -0,0 +1,153 @@ +package funkin.graphics; + +import flixel.graphics.frames.FlxFrame; +import flixel.addons.display.FlxBackdrop; +import flixel.math.FlxMatrix; +import flixel.util.FlxAxes; + +using flixel.util.FlxColorTransformUtil; + +// TODO: make this override FlxSpriteExt instead, im just lazy to convert the rest of the class rn lmao +class FlxBackdropExt extends FlxBackdrop +{ + var tileMatrix:FlxMatrix; + var tileSize:FlxPoint = FlxPoint.get(); + + public function new(?graphic:Null, repeatAxes:FlxAxes = XY, spacingX:Float = 0.0, spacingY:Float = 0.0) { + super(graphic, repeatAxes, spacingX, spacingY); + + this.tileMatrix = new FlxMatrix(); + } + + override function destroy() { + super.destroy(); + tileMatrix = null; + tileSize = FlxDestroyUtil.put(tileSize); + } + + private inline function prepareFrameMatrix(frame:FlxFrame, mat:FlxMatrix):Void + { + var flipX = (flipX != _frame.flipX); + var flipY = (flipY != _frame.flipY); + + if (animation.curAnim != null) + { + flipX != animation.curAnim.flipX; + flipY != animation.curAnim.flipY; + } + + @:privateAccess { + final tileMat = frame.tileMatrix; + mat.a = tileMat[0]; + mat.b = tileMat[1]; + mat.c = tileMat[2]; + mat.d = tileMat[3]; + mat.tx = tileMat[4]; + mat.ty = tileMat[5]; + } + + if (frame.angle == 180) { + mat.rotateBy180(); + mat.tx = (mat.tx + frame.sourceSize.y); + mat.ty = (mat.ty + frame.sourceSize.x); + } + + if (lodScale != 1.0) + CoolUtil.matrixScale(mat, lodScale, lodScale); + + if (flipX != frame.flipX) { + CoolUtil.matrixScale(mat, -1, 1); + mat.tx = (mat.tx + frame.sourceSize.x); + } + + if (flipY != frame.flipY) { + CoolUtil.matrixScale(mat, 1, -1); + mat.tx = (mat.tx + frame.sourceSize.y); + } + } + + override function drawComplex(camera:FlxCamera) + { + if (repeatAxes == NONE) + { + super.drawComplex(camera); + return; + } + + prepareFrameMatrix(_frame, _matrix); + _matrix.translate(-origin.x, -origin.y); + + tileSize.set( + (_frame.frame.width + spacing.x) * scale.x * lodScale, + (_frame.frame.height + spacing.y) * scale.y * lodScale, + ); + + CoolUtil.matrixScale(_matrix, scale.x, scale.y); + + if (angle != 0) { + if (_angleChanged) { + final rads:Float = angle * CoolUtil.TO_RADS; + _cosAngle = CoolUtil.cos(rads); + _sinAngle = CoolUtil.sin(rads); + _angleChanged = false; + } + _matrix.rotateWithTrig(_cosAngle, _sinAngle); + } + + getScreenPosition(_point, camera).subtractPoint(offset); + + var tilesX = 1; + var tilesY = 1; + + final viewMargins = camera.getViewMarginRect(); + final bounds = getScreenBounds(camera); + + if (repeatAxes.x) + { + final origTileSizeX = (frameWidth + spacing.x) * scale.x; + final left = modMin(bounds.right, origTileSizeX, viewMargins.left) - bounds.width; + final right = modMax(bounds.left, origTileSizeX, viewMargins.right) + origTileSizeX; + tilesX = Math.round((right - left) / tileSize.x); + _point.x = left + _point.x - bounds.x; + } + + if (repeatAxes.y) + { + final origTileSizeY = (frameHeight + spacing.y) * scale.y; + final top = modMin(bounds.bottom, origTileSizeY, viewMargins.top) - bounds.height; + final bottom = modMax(bounds.top, origTileSizeY, viewMargins.bottom) + origTileSizeY; + tilesY = Math.round((bottom - top) / tileSize.y); + _point.y = top + _point.y - bounds.y; + } + + viewMargins.put(); + bounds.put(); + + _point.addPoint(origin); + + var hasColors = (colorTransform != null) ? (colorTransform.hasRGBMultipliers() || colorTransform.hasRGBAOffsets()) : false; + var quad = camera.startQuadBatch(_frame.parent, hasColors, hasColors, blend, antialiasing, shader); + + for (tileX in 0...tilesX) + { + for (tileY in 0...tilesY) + { + tileMatrix.copyFrom(_matrix); + tileMatrix.translate(_point.x + (tileSize.x * tileX), _point.y + (tileSize.y * tileY)); + quad.addQuad(_frame, tileMatrix, colorTransform); + } + } + } + + public var lodScale(default, null):Float = 1.0; + + override function set_graphic(value:FlxGraphic):FlxGraphic + { + if (graphic != value) { + lodScale = (value is LodGraphic) ? cast(value, LodGraphic).lodScale : 1.0; + graphic = value; + } + + return value; + } +} \ No newline at end of file diff --git a/source/funkin/states/menus/MainMenuState.hx b/source/funkin/states/menus/MainMenuState.hx index 28babf73..b863bff1 100644 --- a/source/funkin/states/menus/MainMenuState.hx +++ b/source/funkin/states/menus/MainMenuState.hx @@ -59,10 +59,7 @@ class MainMenuState extends MusicBeatState { menuItem.ID = i; } - var menuCam:FlxCamera = new FlxCamera(); - FlxG.cameras.add(menuCam); - FlxG.cameras.setDefaultDrawTarget(menuCam, true); - menuCam.follow(camFollow, null, 0.06); + FlxG.camera.follow(camFollow, null, 0.06); var versionText:String = 'Mau Engin v${Main.engineVersion}\nFriday Night Funkin v${Application.current.meta.get('version')}'; diff --git a/source/funkin/states/options/items/ModItem.hx b/source/funkin/states/options/items/ModItem.hx index af145510..de35770e 100644 --- a/source/funkin/states/options/items/ModItem.hx +++ b/source/funkin/states/options/items/ModItem.hx @@ -40,9 +40,13 @@ class ModItem extends FlxSpriteGroup { enableButton = new FlxSpriteExt(modBox.width,modBox.height).loadImageTiled('options/modButton', 60, 58); enableButton.animation.add('on', [0]); enableButton.animation.add('off', [1]); + add(enableButton); + + enableButton.width *= enableButton.lodScale; + enableButton.height *= enableButton.lodScale; + enableButton.x -= enableButton.width + 5; enableButton.y -= enableButton.height + 5; - add(enableButton); enabled = ModdingUtil.activeMods.get(mod.folder); updateUI(); diff --git a/source/funkin/util/modding/FunkScript.hx b/source/funkin/util/modding/FunkScript.hx index f2828685..a8b68328 100644 --- a/source/funkin/util/modding/FunkScript.hx +++ b/source/funkin/util/modding/FunkScript.hx @@ -115,6 +115,7 @@ class FunkScript extends hscript.Script implements IFlxDestroyable { set('FlxG', flixel.FlxG); set('FlxSpriteExt', funkin.graphics.FlxSpriteExt); // Both r the same lol, just for backwards compatibility set('FlxSprite', funkin.graphics.FlxSpriteExt); + set('FlxBackdrop', funkin.graphics.FlxBackdropExt); // Just a lil fix for lod set('FlxText', flixel.text.FlxText); set('FlxTypedGroup', TypedGroup); set('FlxSpriteGroup', flixel.group.FlxSpriteGroup); diff --git a/source/funkin/util/song/Conductor.hx b/source/funkin/util/song/Conductor.hx index b68571c9..c415aa41 100644 --- a/source/funkin/util/song/Conductor.hx +++ b/source/funkin/util/song/Conductor.hx @@ -9,7 +9,8 @@ typedef BPMChangeEvent = { var bpm:Float; } -class Conductor { +class Conductor +{ inline public static var NOTE_DATA_LENGTH:Int = 4; inline public static var STRUMS_LENGTH:Int = NOTE_DATA_LENGTH * 2;