mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-11-26 06:09:02 +00:00
Update rendering for custom note styles
This commit is contained in:
parent
1fe44fa368
commit
f76309c91e
|
|
@ -109,6 +109,14 @@ typedef NoteStyleAssetData<T> =
|
||||||
@:optional
|
@:optional
|
||||||
var isPixel:Bool;
|
var isPixel:Bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, animations will be played on the graphic.
|
||||||
|
* @default `false` to save performance.
|
||||||
|
*/
|
||||||
|
@:default(false)
|
||||||
|
@:optional
|
||||||
|
var animated:Bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The structure of this data depends on the asset.
|
* The structure of this data depends on the asset.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ class NoteSprite extends FunkinSprite
|
||||||
{
|
{
|
||||||
if (frames == null) return value;
|
if (frames == null) return value;
|
||||||
|
|
||||||
animation.play(DIRECTION_COLORS[value] + 'Scroll');
|
playNoteAnimation(value);
|
||||||
|
|
||||||
this.direction = value;
|
this.direction = value;
|
||||||
return this.direction;
|
return this.direction;
|
||||||
|
|
@ -152,9 +152,6 @@ class NoteSprite extends FunkinSprite
|
||||||
this.hsvShader = new HSVShader();
|
this.hsvShader = new HSVShader();
|
||||||
|
|
||||||
setupNoteGraphic(noteStyle);
|
setupNoteGraphic(noteStyle);
|
||||||
|
|
||||||
// Disables the update() function for performance.
|
|
||||||
this.active = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -165,10 +162,10 @@ class NoteSprite extends FunkinSprite
|
||||||
{
|
{
|
||||||
noteStyle.buildNoteSprite(this);
|
noteStyle.buildNoteSprite(this);
|
||||||
|
|
||||||
setGraphicSize(Strumline.STRUMLINE_SIZE);
|
|
||||||
updateHitbox();
|
|
||||||
|
|
||||||
this.shader = hsvShader;
|
this.shader = hsvShader;
|
||||||
|
|
||||||
|
// `false` disables the update() function for performance.
|
||||||
|
this.active = noteStyle.isNoteAnimated();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -211,6 +208,11 @@ class NoteSprite extends FunkinSprite
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
function playNoteAnimation(value:Int):Void
|
||||||
|
{
|
||||||
|
animation.play(DIRECTION_COLORS[value] + 'Scroll');
|
||||||
|
}
|
||||||
|
|
||||||
public function desaturate():Void
|
public function desaturate():Void
|
||||||
{
|
{
|
||||||
this.hsvShader.saturation = 0.2;
|
this.hsvShader.saturation = 0.2;
|
||||||
|
|
|
||||||
|
|
@ -717,6 +717,7 @@ class Strumline extends FlxSpriteGroup
|
||||||
|
|
||||||
noteSprite.x = this.x;
|
noteSprite.x = this.x;
|
||||||
noteSprite.x += getXPos(DIRECTIONS[note.getDirection() % KEY_COUNT]);
|
noteSprite.x += getXPos(DIRECTIONS[note.getDirection() % KEY_COUNT]);
|
||||||
|
noteSprite.x -= (noteSprite.width - Strumline.STRUMLINE_SIZE) / 2; // Center it
|
||||||
noteSprite.x -= NUDGE;
|
noteSprite.x -= NUDGE;
|
||||||
// noteSprite.x += INITIAL_OFFSET;
|
// noteSprite.x += INITIAL_OFFSET;
|
||||||
noteSprite.y = -9999;
|
noteSprite.y = -9999;
|
||||||
|
|
|
||||||
|
|
@ -89,12 +89,14 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
||||||
|
|
||||||
target.frames = atlas;
|
target.frames = atlas;
|
||||||
|
|
||||||
target.scale.x = _data.assets.note.scale;
|
|
||||||
target.scale.y = _data.assets.note.scale;
|
|
||||||
target.antialiasing = !_data.assets.note.isPixel;
|
target.antialiasing = !_data.assets.note.isPixel;
|
||||||
|
|
||||||
// Apply the animations.
|
// Apply the animations.
|
||||||
buildNoteAnimations(target);
|
buildNoteAnimations(target);
|
||||||
|
|
||||||
|
// Set the scale.
|
||||||
|
target.setGraphicSize(Strumline.STRUMLINE_SIZE * getNoteScale());
|
||||||
|
target.updateHitbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
var noteFrames:FlxAtlasFrames = null;
|
var noteFrames:FlxAtlasFrames = null;
|
||||||
|
|
@ -156,6 +158,16 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
||||||
target.animation.addByPrefix('redScroll', rightData.prefix, rightData.frameRate, rightData.looped, rightData.flipX, rightData.flipY);
|
target.animation.addByPrefix('redScroll', rightData.prefix, rightData.frameRate, rightData.looped, rightData.flipX, rightData.flipY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isNoteAnimated():Bool
|
||||||
|
{
|
||||||
|
return _data.assets.note.animated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNoteScale():Float
|
||||||
|
{
|
||||||
|
return _data.assets.note.scale;
|
||||||
|
}
|
||||||
|
|
||||||
function fetchNoteAnimationData(dir:NoteDirection):AnimationData
|
function fetchNoteAnimationData(dir:NoteDirection):AnimationData
|
||||||
{
|
{
|
||||||
var result:Null<AnimationData> = switch (dir)
|
var result:Null<AnimationData> = switch (dir)
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,12 @@ class ChartEditorNoteSprite extends FlxSprite
|
||||||
var prefix:String = noteStyle.id.toTitleCase();
|
var prefix:String = noteStyle.id.toTitleCase();
|
||||||
|
|
||||||
var frameCollection:FlxAtlasFrames = Paths.getSparrowAtlas(noteStyle.getNoteAssetPath(), noteStyle.getNoteAssetLibrary());
|
var frameCollection:FlxAtlasFrames = Paths.getSparrowAtlas(noteStyle.getNoteAssetPath(), noteStyle.getNoteAssetLibrary());
|
||||||
|
if (frameCollection == null)
|
||||||
|
{
|
||||||
|
trace('Could not retrieve frame collection for ${noteStyle}: ${Paths.image(noteStyle.getNoteAssetPath(), noteStyle.getNoteAssetLibrary())}');
|
||||||
|
FlxG.log.error('Could not retrieve frame collection for ${noteStyle}: ${Paths.image(noteStyle.getNoteAssetPath(), noteStyle.getNoteAssetLibrary())}');
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (frame in frameCollection.frames)
|
for (frame in frameCollection.frames)
|
||||||
{
|
{
|
||||||
// cloning the frame because else
|
// cloning the frame because else
|
||||||
|
|
@ -221,9 +227,9 @@ class ChartEditorNoteSprite extends FlxSprite
|
||||||
switch (baseAnimationName)
|
switch (baseAnimationName)
|
||||||
{
|
{
|
||||||
case 'tap':
|
case 'tap':
|
||||||
this.setGraphicSize(0, ChartEditorState.GRID_SIZE);
|
this.setGraphicSize(ChartEditorState.GRID_SIZE, 0);
|
||||||
|
this.updateHitbox();
|
||||||
}
|
}
|
||||||
this.updateHitbox();
|
|
||||||
|
|
||||||
var bruhStyle:NoteStyle = fetchNoteStyle(this.noteStyle);
|
var bruhStyle:NoteStyle = fetchNoteStyle(this.noteStyle);
|
||||||
this.antialiasing = !bruhStyle._data?.assets?.note?.isPixel ?? true;
|
this.antialiasing = !bruhStyle._data?.assets?.note?.isPixel ?? true;
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var heightToSet:Int = Std.int(Math.max(DIALOG_HEIGHT, toolboxNotesGrid.height + HEIGHT_OFFSET)) + MINIMIZE_FIX;
|
var heightToSet:Int = Std.int(Math.max(DIALOG_HEIGHT, (toolboxNotesGrid?.height ?? 50) + HEIGHT_OFFSET)) + MINIMIZE_FIX;
|
||||||
if (this.height != heightToSet)
|
if (this.height != heightToSet)
|
||||||
{
|
{
|
||||||
this.height = heightToSet;
|
this.height = heightToSet;
|
||||||
|
|
|
||||||
|
|
@ -195,11 +195,11 @@ class ChartEditorDropdowns
|
||||||
{
|
{
|
||||||
dropDown.dataSource.clear();
|
dropDown.dataSource.clear();
|
||||||
|
|
||||||
var returnValue:DropDownEntry = lookupNoteKind('~CUSTOM');
|
var returnValue:DropDownEntry = lookupNoteKind('');
|
||||||
|
|
||||||
for (noteKindId in NOTE_KINDS.keys())
|
for (noteKindId in NOTE_KINDS.keys())
|
||||||
{
|
{
|
||||||
var noteKind:String = NOTE_KINDS.get(noteKindId) ?? 'Default';
|
var noteKind:String = NOTE_KINDS.get(noteKindId) ?? 'Unknown';
|
||||||
|
|
||||||
var value:DropDownEntry = {id: noteKindId, text: noteKind};
|
var value:DropDownEntry = {id: noteKindId, text: noteKind};
|
||||||
if (startingKindId == noteKindId) returnValue = value;
|
if (startingKindId == noteKindId) returnValue = value;
|
||||||
|
|
@ -216,7 +216,7 @@ class ChartEditorDropdowns
|
||||||
{
|
{
|
||||||
if (noteKindId == null) return lookupNoteKind('');
|
if (noteKindId == null) return lookupNoteKind('');
|
||||||
if (!NOTE_KINDS.exists(noteKindId)) return {id: '~CUSTOM~', text: 'Custom'};
|
if (!NOTE_KINDS.exists(noteKindId)) return {id: '~CUSTOM~', text: 'Custom'};
|
||||||
return {id: noteKindId ?? '', text: NOTE_KINDS.get(noteKindId) ?? 'Default'};
|
return {id: noteKindId ?? '', text: NOTE_KINDS.get(noteKindId) ?? 'Unknown'};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue