From 32846cba443faeb6b800f0a57f96f039841db243 Mon Sep 17 00:00:00 2001 From: MaybeMaru <97055307+MaybeMaru@users.noreply.github.com> Date: Sat, 15 Jun 2024 14:48:54 +0200 Subject: [PATCH] fix chart editor offsets --- source/funkin/graphics/FlxSpriteExt.hx | 5 +++- source/funkin/objects/note/NoteStrum.hx | 15 ++++++----- source/funkin/states/editors/ChartingState.hx | 2 +- .../states/editors/chart/ChartStrumLine.hx | 25 +++++++++---------- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/source/funkin/graphics/FlxSpriteExt.hx b/source/funkin/graphics/FlxSpriteExt.hx index af1e6d51..82b14b02 100644 --- a/source/funkin/graphics/FlxSpriteExt.hx +++ b/source/funkin/graphics/FlxSpriteExt.hx @@ -417,7 +417,10 @@ class FlxSpriteExt extends FlxSkewedSprite static final __scaleDiff:FlxPoint = FlxPoint.get(); inline public function getScaleDiff():FlxPoint { var jsonScale:Float = spriteJson.scale; - return __scaleDiff.set(scale.x / jsonScale, scale.y / jsonScale); + return __scaleDiff.set( + Math.abs(scale.x) / jsonScale, + Math.abs(scale.y) / jsonScale + ); } public var scaleOffset:Bool = false; diff --git a/source/funkin/objects/note/NoteStrum.hx b/source/funkin/objects/note/NoteStrum.hx index f75ae76d..9ff35fbe 100644 --- a/source/funkin/objects/note/NoteStrum.hx +++ b/source/funkin/objects/note/NoteStrum.hx @@ -9,9 +9,10 @@ class NoteStrum extends FlxSpriteExt implements INoteData public var modifiers:Map = []; public var initPos:FlxPoint; public var centerOffset:FlxPoint; - + public var swagWidth:Float = 110; - public var swagHeight:Float = 110; + public var swagHeight:Float = 110; + public var staticTime:Float = 0; public var curSkin:String = ''; @@ -31,8 +32,8 @@ class NoteStrum extends FlxSpriteExt implements INoteData centerOffset = FlxPoint.get(); this.noteData = noteData; ID = noteData; + scaleOffset = true; loadSkin(); - applyCurOffset(true); } override function destroy() { @@ -50,11 +51,12 @@ class NoteStrum extends FlxSpriteExt implements INoteData curSkin = skin; loadJsonInput(SkinUtil.getSkinData(skin).strumData, 'skins/$skin'); getWidth(); + applyCurOffset(true); } } // For centered notes - inline function getWidth():Void { + public inline function getWidth():Void { var lastAnim:Null = null; if (animation.curAnim != null) { var name = animation.curAnim.name; @@ -67,10 +69,7 @@ class NoteStrum extends FlxSpriteExt implements INoteData swagHeight = height; centerOffsets(); - centerOffset.set( - offset.x, - offset.y - ); + centerOffset.copyFrom(offset); if (lastAnim != null) { playStrumAnim(lastAnim); diff --git a/source/funkin/states/editors/ChartingState.hx b/source/funkin/states/editors/ChartingState.hx index 26581ecb..2764b449 100644 --- a/source/funkin/states/editors/ChartingState.hx +++ b/source/funkin/states/editors/ChartingState.hx @@ -21,7 +21,7 @@ import funkin.states.editors.chart.ChartGridBase.getGridCoords; class ChartingState extends MusicBeatState { public static var SONG:SongJson; - var notes:Array; + public var notes:Array; public static var autoSaveChart:String; public static var instance:ChartingState; diff --git a/source/funkin/states/editors/chart/ChartStrumLine.hx b/source/funkin/states/editors/chart/ChartStrumLine.hx index 96c1bd93..60f1bfaf 100644 --- a/source/funkin/states/editors/chart/ChartStrumLine.hx +++ b/source/funkin/states/editors/chart/ChartStrumLine.hx @@ -2,8 +2,8 @@ package funkin.states.editors.chart; import funkin.states.editors.chart.ChartGridBase.GRID_SIZE; -class ChartStrumLine extends FlxTypedSpriteGroup { - +class ChartStrumLine extends SpriteGroup +{ var strums:Array = []; var eventBar:FlxSprite; @@ -16,7 +16,7 @@ class ChartStrumLine extends FlxTypedSpriteGroup { var strum = new NoteStrum(i * GRID_SIZE, 0, i % Conductor.NOTE_DATA_LENGTH); strum.alpha = 0.8; strum.setGraphicSize(GRID_SIZE, GRID_SIZE); - strum.updateHitbox(); + strum.getWidth(); // recalculate this because fuck shit ass fuck fuck crap ass strums.push(strum); add(strum); } @@ -42,13 +42,13 @@ class ChartStrumLine extends FlxTypedSpriteGroup { var charIcons:Map = []; private function getCharIcon(char:String = "bf") { if (charIcons.exists(char)) return charIcons.get(char); - var ico = Character.getCharData(char).icon; - charIcons.set(char, ico); - return ico; + var icon = Character.getCharData(char).icon; + charIcons.set(char, icon); + return icon; } public function updateWithData() { - var sectionData = ChartingState.SONG.notes[ChartingState.sectionIndex]; + var sectionData = ChartingState.instance.notes[ChartingState.sectionIndex]; if (sectionData == null) return; updateHeads(getCharIcon(ChartingState.SONG.players[0]), getCharIcon(ChartingState.SONG.players[1]), sectionData.mustHitSection); } @@ -69,12 +69,11 @@ class ChartStrumLine extends FlxTypedSpriteGroup { public function pressStrum(data:Int = 0) { data %= Conductor.STRUMS_LENGTH; - var isStatic = strums[data].animation.curAnim.name.startsWith('static'); - isStatic ? strums[data].playStrumAnim("confirm", true) : strums[data].animation.curAnim.curFrame = 0; - strums[data].staticTime = Conductor.stepCrochetMills; - } + var strum = strums[data]; + if (strum == null) return; - override function update(elapsed:Float) { - super.update(elapsed); + var isConfirm = (strum.animation.curAnim != null && strum.animation.curAnim.name.startsWith('confirm')); + isConfirm ? strum.animation.curAnim.curFrame = 0 : strum.playStrumAnim("confirm", true); + strum.staticTime = Conductor.stepCrochetMills; } } \ No newline at end of file