Skip to content

Commit

Permalink
fix chart editor offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Jun 15, 2024
1 parent 3e6e1ee commit 32846cb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
5 changes: 4 additions & 1 deletion source/funkin/graphics/FlxSpriteExt.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 7 additions & 8 deletions source/funkin/objects/note/NoteStrum.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class NoteStrum extends FlxSpriteExt implements INoteData
public var modifiers:Map<String, BasicModifier> = [];
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 = '';

Expand All @@ -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() {
Expand All @@ -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<String> = null;
if (animation.curAnim != null) {
var name = animation.curAnim.name;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/states/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import funkin.states.editors.chart.ChartGridBase.getGridCoords;
class ChartingState extends MusicBeatState
{
public static var SONG:SongJson;
var notes:Array<SectionJson>;
public var notes:Array<SectionJson>;

public static var autoSaveChart:String;
public static var instance:ChartingState;
Expand Down
25 changes: 12 additions & 13 deletions source/funkin/states/editors/chart/ChartStrumLine.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package funkin.states.editors.chart;

import funkin.states.editors.chart.ChartGridBase.GRID_SIZE;

class ChartStrumLine extends FlxTypedSpriteGroup<Dynamic> {
class ChartStrumLine extends SpriteGroup
{
var strums:Array<NoteStrum> = [];
var eventBar:FlxSprite;

Expand All @@ -16,7 +16,7 @@ class ChartStrumLine extends FlxTypedSpriteGroup<Dynamic> {
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);
}
Expand All @@ -42,13 +42,13 @@ class ChartStrumLine extends FlxTypedSpriteGroup<Dynamic> {
var charIcons:Map<String, String> = [];
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);
}
Expand All @@ -69,12 +69,11 @@ class ChartStrumLine extends FlxTypedSpriteGroup<Dynamic> {

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;
}
}

0 comments on commit 32846cb

Please sign in to comment.