mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-15 11:22:55 +00:00
store params in chart
chart editor still doesnt fully work
This commit is contained in:
parent
764cdee63d
commit
c41d846df5
|
@ -951,12 +951,18 @@ class SongNoteDataRaw implements ICloneable<SongNoteDataRaw>
|
|||
return this.kind = value;
|
||||
}
|
||||
|
||||
public function new(time:Float, data:Int, length:Float = 0, kind:String = '')
|
||||
@:alias("p")
|
||||
@:default([])
|
||||
@:optional
|
||||
public var params:Array<NoteParamData>;
|
||||
|
||||
public function new(time:Float, data:Int, length:Float = 0, kind:String = '', ?params:Array<NoteParamData>)
|
||||
{
|
||||
this.time = time;
|
||||
this.data = data;
|
||||
this.length = length;
|
||||
this.kind = kind;
|
||||
this.params = params ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1053,7 +1059,7 @@ class SongNoteDataRaw implements ICloneable<SongNoteDataRaw>
|
|||
|
||||
public function clone():SongNoteDataRaw
|
||||
{
|
||||
return new SongNoteDataRaw(this.time, this.data, this.length, this.kind);
|
||||
return new SongNoteDataRaw(this.time, this.data, this.length, this.kind, this.params);
|
||||
}
|
||||
|
||||
public function toString():String
|
||||
|
@ -1069,9 +1075,9 @@ class SongNoteDataRaw implements ICloneable<SongNoteDataRaw>
|
|||
@:forward
|
||||
abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw
|
||||
{
|
||||
public function new(time:Float, data:Int, length:Float = 0, kind:String = '')
|
||||
public function new(time:Float, data:Int, length:Float = 0, kind:String = '', ?params:Array<NoteParamData>)
|
||||
{
|
||||
this = new SongNoteDataRaw(time, data, length, kind);
|
||||
this = new SongNoteDataRaw(time, data, length, kind, params);
|
||||
}
|
||||
|
||||
public static function buildDirectionName(data:Int, strumlineSize:Int = 4):String
|
||||
|
@ -1183,3 +1189,30 @@ abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw
|
|||
+ (this.kind != '' ? ' [kind: ${this.kind}])' : ')');
|
||||
}
|
||||
}
|
||||
|
||||
class NoteParamData implements ICloneable<NoteParamData>
|
||||
{
|
||||
@:alias("n")
|
||||
public var name:String;
|
||||
|
||||
@:alias("v")
|
||||
@:jcustomparse(funkin.data.DataParse.dynamicValue)
|
||||
@:jcustomwrite(funkin.data.DataWrite.dynamicValue)
|
||||
public var value:Dynamic;
|
||||
|
||||
public function new(name:String, value:Dynamic)
|
||||
{
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public function clone():NoteParamData
|
||||
{
|
||||
return new NoteParamData(this.name, this.value);
|
||||
}
|
||||
|
||||
public function toString():String
|
||||
{
|
||||
return 'NoteParamData(${this.name}, ${this.value})';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package funkin.play.notes;
|
||||
|
||||
import funkin.data.song.SongData.SongNoteData;
|
||||
import funkin.data.song.SongData.NoteParamData;
|
||||
import funkin.play.notes.notestyle.NoteStyle;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.FlxSprite;
|
||||
|
@ -65,6 +66,22 @@ class NoteSprite extends FunkinSprite
|
|||
return this.noteData.kind = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of custom parameters for this note
|
||||
*/
|
||||
public var params(get, set):Array<NoteParamData>;
|
||||
|
||||
function get_params():Array<NoteParamData>
|
||||
{
|
||||
return this.noteData?.params ?? [];
|
||||
}
|
||||
|
||||
function set_params(value:Array<NoteParamData>):Array<NoteParamData>
|
||||
{
|
||||
if (this.noteData == null) return value;
|
||||
return this.noteData.params = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The data of the note (i.e. the direction.)
|
||||
*/
|
||||
|
@ -154,6 +171,23 @@ class NoteSprite extends FunkinSprite
|
|||
this.shader = hsvShader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the value of the param with the given name
|
||||
* @param name Name of the param
|
||||
* @return Null<Dynamic>
|
||||
*/
|
||||
public function getParam(name:String):Null<Dynamic>
|
||||
{
|
||||
for (param in params)
|
||||
{
|
||||
if (param.name == name)
|
||||
{
|
||||
return param.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
#if FLX_DEBUG
|
||||
/**
|
||||
* Call this to override how debug bounding boxes are drawn for this sprite.
|
||||
|
|
|
@ -5,6 +5,7 @@ import funkin.modding.events.ScriptEvent;
|
|||
import funkin.ui.debug.charting.util.ChartEditorDropdowns;
|
||||
import funkin.data.notestyle.NoteStyleRegistry;
|
||||
import funkin.play.notes.notestyle.NoteStyle;
|
||||
import funkin.play.notes.notekind.NoteKind.NoteKindParam;
|
||||
|
||||
class NoteKindManager
|
||||
{
|
||||
|
@ -100,9 +101,9 @@ class NoteKindManager
|
|||
/**
|
||||
* Retrive custom params of the given note kind
|
||||
* @param noteKind Name of the note kind
|
||||
* @return Array<NoteKind.NoteKindParam>
|
||||
* @return Array<NoteKindParam>
|
||||
*/
|
||||
public static function getParams(noteKind:String):Array<NoteKind.NoteKindParam>
|
||||
public static function getParams(noteKind:String):Array<NoteKindParam>
|
||||
{
|
||||
return noteKinds.get(noteKind)?.params ?? [];
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import funkin.data.song.SongData.SongEventData;
|
|||
import funkin.data.song.SongData.SongMetadata;
|
||||
import funkin.data.song.SongData.SongNoteData;
|
||||
import funkin.data.song.SongData.SongOffsets;
|
||||
import funkin.data.song.SongData.NoteParamData;
|
||||
import funkin.data.song.SongDataUtils;
|
||||
import funkin.data.song.SongRegistry;
|
||||
import funkin.data.stage.StageData;
|
||||
|
@ -539,6 +540,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
*/
|
||||
var noteKindToPlace:Null<String> = null;
|
||||
|
||||
/**
|
||||
* The note params to use for notes being placed in the chart. Defaults to `[]`.
|
||||
*/
|
||||
var noteParamsToPlace:Array<NoteParamData> = [];
|
||||
|
||||
/**
|
||||
* The event type to use for events being placed in the chart. Defaults to `''`.
|
||||
*/
|
||||
|
@ -2437,7 +2443,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
|
||||
gridGhostNote = new ChartEditorNoteSprite(this);
|
||||
gridGhostNote.alpha = 0.6;
|
||||
gridGhostNote.noteData = new SongNoteData(0, 0, 0, "");
|
||||
gridGhostNote.noteData = new SongNoteData(0, 0, 0, "", []);
|
||||
gridGhostNote.visible = false;
|
||||
add(gridGhostNote);
|
||||
gridGhostNote.zIndex = 11;
|
||||
|
@ -4731,7 +4737,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
else
|
||||
{
|
||||
// Create a note and place it in the chart.
|
||||
var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace);
|
||||
var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace, noteParamsToPlace.clone());
|
||||
|
||||
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
|
||||
|
||||
|
@ -4890,11 +4896,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
|
||||
if (gridGhostNote == null) throw "ERROR: Tried to handle cursor, but gridGhostNote is null! Check ChartEditorState.buildGrid()";
|
||||
|
||||
var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0, noteKindToPlace);
|
||||
var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0, noteKindToPlace,
|
||||
noteParamsToPlace.clone());
|
||||
|
||||
if (cursorColumn != noteData.data || noteKindToPlace != noteData.kind)
|
||||
if (cursorColumn != noteData.data || noteKindToPlace != noteData.kind || noteParamsToPlace != noteData.params)
|
||||
{
|
||||
noteData.kind = noteKindToPlace;
|
||||
noteData.params = noteParamsToPlace;
|
||||
noteData.data = cursorColumn;
|
||||
gridGhostNote.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, isPixelStyle()) ?? currentSongNoteStyle;
|
||||
gridGhostNote.playNoteAnimation();
|
||||
|
@ -5202,7 +5210,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
if (notesAtPos.length == 0 && !removeNoteInstead)
|
||||
{
|
||||
trace('Placing note. ${column}');
|
||||
var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, noteKindToPlace);
|
||||
var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, noteKindToPlace, noteParamsToPlace.clone());
|
||||
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
|
||||
currentLiveInputPlaceNoteData[column] = newNoteData;
|
||||
}
|
||||
|
@ -5655,6 +5663,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
FlxG.watch.addQuick('musicTime', audioInstTrack?.time ?? 0.0);
|
||||
|
||||
FlxG.watch.addQuick('noteKindToPlace', noteKindToPlace);
|
||||
FlxG.watch.addQuick('noteParamsToPlace', noteParamsToPlace);
|
||||
FlxG.watch.addQuick('eventKindToPlace', eventKindToPlace);
|
||||
|
||||
FlxG.watch.addQuick('scrollPosInPixels', scrollPositionInPixels);
|
||||
|
|
|
@ -9,6 +9,8 @@ import haxe.ui.core.Component;
|
|||
import haxe.ui.events.UIEvent;
|
||||
import funkin.ui.debug.charting.util.ChartEditorDropdowns;
|
||||
import funkin.play.notes.notekind.NoteKindManager;
|
||||
import funkin.play.notes.notekind.NoteKind.NoteKindParam;
|
||||
import funkin.data.song.SongData.NoteParamData;
|
||||
|
||||
/**
|
||||
* The toolbox which allows modifying information like Note Kind.
|
||||
|
@ -60,6 +62,13 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
|
|||
|
||||
trace('ChartEditorToolboxHandler.buildToolboxNoteDataLayout() - Note kind changed: $noteKind');
|
||||
|
||||
var noteKindParams:Array<NoteKindParam> = NoteKindManager.getParams(noteKind);
|
||||
var noteParamData:Array<NoteParamData> = [];
|
||||
for (noteKindParam in noteKindParams)
|
||||
{
|
||||
noteParamData.push(new NoteParamData(noteKindParam.name, noteKindParam.data.defaultValue));
|
||||
}
|
||||
|
||||
// Edit the note data to place.
|
||||
if (noteKind == '~CUSTOM~')
|
||||
{
|
||||
|
@ -71,10 +80,11 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
|
|||
{
|
||||
hideCustom();
|
||||
chartEditorState.noteKindToPlace = noteKind;
|
||||
chartEditorState.noteParamsToPlace = noteParamData;
|
||||
toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace;
|
||||
|
||||
clearNoteKindParams();
|
||||
for (param in NoteKindManager.getParams(noteKind))
|
||||
for (param in noteKindParams)
|
||||
{
|
||||
var paramLabel:Label = new Label();
|
||||
paramLabel.value = param.description;
|
||||
|
@ -107,10 +117,22 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
|
|||
|
||||
if (!_initializing && chartEditorState.currentNoteSelection.length > 0)
|
||||
{
|
||||
for (i in 0...toolboxNotesParams.length)
|
||||
{
|
||||
var toolboxComponent:Component = toolboxNotesParams[i].component;
|
||||
toolboxComponent.onChange = function(event:UIEvent) {
|
||||
for (note in chartEditorState.currentNoteSelection)
|
||||
{
|
||||
note.params[i].value = toolboxComponent.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (note in chartEditorState.currentNoteSelection)
|
||||
{
|
||||
// Edit the note data of any selected notes.
|
||||
note.kind = chartEditorState.noteKindToPlace;
|
||||
note.params = noteParamData.clone();
|
||||
|
||||
// update note sprites
|
||||
for (noteSprite in chartEditorState.renderedNotes.members)
|
||||
|
|
Loading…
Reference in a new issue