Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix note and receptor scaling and note tail offsets #3351

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion source/funkin/play/notes/StrumlineNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class StrumlineNote extends FlxSprite
noteStyle.applyStrumlineFrames(this);
noteStyle.applyStrumlineAnimations(this, this.direction);

this.setGraphicSize(Std.int(Strumline.STRUMLINE_SIZE * noteStyle.getStrumlineScale()));
var scale = noteStyle.getStrumlineScale();
this.scale.set(scale, scale);
this.updateHitbox();
noteStyle.applyStrumlineOffsets(this);

Expand Down
5 changes: 3 additions & 2 deletions source/funkin/play/notes/SustainTrail.hx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class SustainTrail extends FlxSprite
public var bottomClip:Float = 0.9;

public var isPixel:Bool;
public var noteStyleOffsets:Array<Float>;

var graphicWidth:Float = 0;
var graphicHeight:Float = 0;
Expand All @@ -107,6 +108,7 @@ class SustainTrail extends FlxSprite
this.noteDirection = noteDirection;

setupHoldNoteGraphic(noteStyle);
noteStyleOffsets = noteStyle.getHoldNoteOffsets();

indices = new DrawData<Int>(12, true, TRIANGLE_VERTEX_INDICES);

Expand Down Expand Up @@ -137,7 +139,6 @@ class SustainTrail extends FlxSprite

zoom = 1.0;
zoom *= noteStyle.fetchHoldNoteScale();
zoom *= 0.7;

// CALCULATE SIZE
graphicWidth = graphic.width / 8 * zoom; // amount of notes * 2
Expand Down Expand Up @@ -202,7 +203,7 @@ class SustainTrail extends FlxSprite
{
width = graphicWidth;
height = graphicHeight;
offset.set(0, 0);
offset.set(noteStyleOffsets[0], noteStyleOffsets[1]);
origin.set(width * 0.5, height * 0.5);
}

Expand Down
19 changes: 17 additions & 2 deletions source/funkin/play/notes/notestyle/NoteStyle.hx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
buildNoteAnimations(target);

// Set the scale.
target.setGraphicSize(Strumline.STRUMLINE_SIZE * getNoteScale());
var scale = getNoteScale();
target.scale.set(scale, scale);
target.updateHitbox();
}

Expand Down Expand Up @@ -224,6 +225,13 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
return data?.scale ?? 1.0;
}

public function getHoldNoteOffsets():Array<Float>
{
var data = _data?.assets?.holdNote;
if (data == null && fallback != null) return fallback.getHoldNoteOffsets();
return data?.offsets ?? [0.0, 0.0];
}

public function applyStrumlineFrames(target:StrumlineNote):Void
{
// TODO: Add support for multi-Sparrow.
Expand Down Expand Up @@ -304,9 +312,16 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
return thx.Arrays.filterNull(result);
}

public function getStrumlineOffsets():Array<Float>
{
var data = _data?.assets?.noteStrumline;
if (data == null && fallback != null) return fallback.getStrumlineOffsets();
return data?.offsets ?? [0.0, 0.0];
}

public function applyStrumlineOffsets(target:StrumlineNote):Void
{
var offsets = _data?.assets?.noteStrumline?.offsets ?? [0.0, 0.0];
var offsets = getStrumlineOffsets();
target.x += offsets[0];
target.y += offsets[1];
}
Expand Down