mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2025-04-15 00:14:48 -04:00
editing them works now
still need to implement String and do some testing
This commit is contained in:
parent
c41d846df5
commit
44d9785317
4 changed files with 128 additions and 71 deletions
source/funkin
data/song
play/notes/notekind
ui/debug/charting
|
@ -1057,9 +1057,19 @@ class SongNoteDataRaw implements ICloneable<SongNoteDataRaw>
|
|||
_stepLength = null;
|
||||
}
|
||||
|
||||
public function cloneParams():Array<NoteParamData>
|
||||
{
|
||||
var params:Array<NoteParamData> = [];
|
||||
for (param in this.params)
|
||||
{
|
||||
params.push(param.clone());
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public function clone():SongNoteDataRaw
|
||||
{
|
||||
return new SongNoteDataRaw(this.time, this.data, this.length, this.kind, this.params);
|
||||
return new SongNoteDataRaw(this.time, this.data, this.length, this.kind, cloneParams());
|
||||
}
|
||||
|
||||
public function toString():String
|
||||
|
@ -1121,7 +1131,7 @@ abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw
|
|||
if (other.kind == '' || this.kind == null) return false;
|
||||
}
|
||||
|
||||
return this.time == other.time && this.data == other.data && this.length == other.length;
|
||||
return this.time == other.time && this.data == other.data && this.length == other.length && this.params == other.params;
|
||||
}
|
||||
|
||||
@:op(A != B)
|
||||
|
@ -1140,7 +1150,7 @@ abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw
|
|||
if (other.kind == '') return true;
|
||||
}
|
||||
|
||||
return this.time != other.time || this.data != other.data || this.length != other.length;
|
||||
return this.time != other.time || this.data != other.data || this.length != other.length || this.params != other.params;
|
||||
}
|
||||
|
||||
@:op(A > B)
|
||||
|
@ -1177,7 +1187,7 @@ abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw
|
|||
|
||||
public function clone():SongNoteData
|
||||
{
|
||||
return new SongNoteData(this.time, this.data, this.length, this.kind);
|
||||
return new SongNoteData(this.time, this.data, this.length, this.kind, this.params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -103,8 +103,13 @@ class NoteKindManager
|
|||
* @param noteKind Name of the note kind
|
||||
* @return Array<NoteKindParam>
|
||||
*/
|
||||
public static function getParams(noteKind:String):Array<NoteKindParam>
|
||||
public static function getParams(noteKind:Null<String>):Array<NoteKindParam>
|
||||
{
|
||||
if (noteKind == null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
return noteKinds.get(noteKind)?.params ?? [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4737,7 +4737,8 @@ 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, noteParamsToPlace.clone());
|
||||
var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace,
|
||||
ChartEditorState.cloneNoteParams(noteParamsToPlace));
|
||||
|
||||
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
|
||||
|
||||
|
@ -4897,7 +4898,7 @@ 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,
|
||||
noteParamsToPlace.clone());
|
||||
ChartEditorState.cloneNoteParams(noteParamsToPlace));
|
||||
|
||||
if (cursorColumn != noteData.data || noteKindToPlace != noteData.kind || noteParamsToPlace != noteData.params)
|
||||
{
|
||||
|
@ -5210,7 +5211,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, noteParamsToPlace.clone());
|
||||
var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, noteKindToPlace, ChartEditorState.cloneNoteParams(noteParamsToPlace));
|
||||
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
|
||||
currentLiveInputPlaceNoteData[column] = newNoteData;
|
||||
}
|
||||
|
@ -6532,6 +6533,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
public static function cloneNoteParams(paramsToClone:Array<NoteParamData>):Array<NoteParamData>
|
||||
{
|
||||
var params:Array<NoteParamData> = [];
|
||||
for (param in paramsToClone)
|
||||
{
|
||||
params.push(param.clone());
|
||||
}
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,77 +62,30 @@ 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~')
|
||||
{
|
||||
showCustom();
|
||||
clearNoteKindParams();
|
||||
toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace;
|
||||
}
|
||||
else
|
||||
{
|
||||
hideCustom();
|
||||
chartEditorState.noteKindToPlace = noteKind;
|
||||
chartEditorState.noteParamsToPlace = noteParamData;
|
||||
toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace;
|
||||
|
||||
clearNoteKindParams();
|
||||
for (param in noteKindParams)
|
||||
{
|
||||
var paramLabel:Label = new Label();
|
||||
paramLabel.value = param.description;
|
||||
paramLabel.verticalAlign = "center";
|
||||
paramLabel.horizontalAlign = "right";
|
||||
|
||||
var paramStepper:NumberStepper = new NumberStepper();
|
||||
paramStepper.value = param.data.defaultValue;
|
||||
paramStepper.percentWidth = 100;
|
||||
paramStepper.step = param.data.step ?? 1;
|
||||
|
||||
// this check should be unnecessary but for some reason
|
||||
// even when these are null it will set it to 0
|
||||
if (param.data.min != null)
|
||||
{
|
||||
paramStepper.min = param.data.min;
|
||||
}
|
||||
if (param.data.max != null)
|
||||
{
|
||||
paramStepper.max = param.data.max;
|
||||
}
|
||||
if (param.data.precision != null)
|
||||
{
|
||||
paramStepper.precision = param.data.precision;
|
||||
}
|
||||
|
||||
addNoteKindParam(paramLabel, paramStepper);
|
||||
}
|
||||
}
|
||||
|
||||
createNoteKindParams(noteKind);
|
||||
|
||||
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();
|
||||
trace(note.params);
|
||||
note.params = ChartEditorState.cloneNoteParams(chartEditorState.noteParamsToPlace);
|
||||
trace(note.params);
|
||||
|
||||
// update note sprites
|
||||
for (noteSprite in chartEditorState.renderedNotes.members)
|
||||
|
@ -187,6 +140,8 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
|
|||
|
||||
toolboxNotesNoteKind.value = ChartEditorDropdowns.lookupNoteKind(chartEditorState.noteKindToPlace);
|
||||
toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace;
|
||||
|
||||
createNoteKindParams(chartEditorState.noteKindToPlace);
|
||||
}
|
||||
|
||||
function showCustom():Void
|
||||
|
@ -201,6 +156,82 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
|
|||
toolboxNotesCustomKind.hidden = true;
|
||||
}
|
||||
|
||||
function createNoteKindParams(noteKind:Null<String>):Void
|
||||
{
|
||||
clearNoteKindParams();
|
||||
|
||||
var setParamsToPlace:Bool = false;
|
||||
if (!_initializing)
|
||||
{
|
||||
for (note in chartEditorState.currentNoteSelection)
|
||||
{
|
||||
if (note.kind == chartEditorState.noteKindToPlace)
|
||||
{
|
||||
chartEditorState.noteParamsToPlace = ChartEditorState.cloneNoteParams(note.params);
|
||||
setParamsToPlace = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var noteKindParams:Array<NoteKindParam> = NoteKindManager.getParams(noteKind);
|
||||
|
||||
for (i in 0...noteKindParams.length)
|
||||
{
|
||||
var param:NoteKindParam = noteKindParams[i];
|
||||
|
||||
var paramLabel:Label = new Label();
|
||||
paramLabel.value = param.description;
|
||||
paramLabel.verticalAlign = "center";
|
||||
paramLabel.horizontalAlign = "right";
|
||||
|
||||
var paramStepper:NumberStepper = new NumberStepper();
|
||||
paramStepper.value = (setParamsToPlace ? chartEditorState.noteParamsToPlace[i].value : param.data.defaultValue);
|
||||
paramStepper.percentWidth = 100;
|
||||
paramStepper.step = param.data.step ?? 1;
|
||||
|
||||
// this check should be unnecessary but for some reason
|
||||
// even when these are null it will set it to 0
|
||||
if (param.data.min != null)
|
||||
{
|
||||
paramStepper.min = param.data.min;
|
||||
}
|
||||
if (param.data.max != null)
|
||||
{
|
||||
paramStepper.max = param.data.max;
|
||||
}
|
||||
if (param.data.precision != null)
|
||||
{
|
||||
paramStepper.precision = param.data.precision;
|
||||
}
|
||||
|
||||
paramStepper.onChange = function(event:UIEvent) {
|
||||
chartEditorState.noteParamsToPlace[i].value = paramStepper.value;
|
||||
|
||||
for (note in chartEditorState.currentNoteSelection)
|
||||
{
|
||||
if (note.params[i].name == param.name)
|
||||
{
|
||||
note.params[i].value = paramStepper.value;
|
||||
trace(note.params[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addNoteKindParam(paramLabel, paramStepper);
|
||||
}
|
||||
|
||||
if (!setParamsToPlace)
|
||||
{
|
||||
var noteParamData:Array<NoteParamData> = [];
|
||||
for (param in noteKindParams)
|
||||
{
|
||||
noteParamData.push(new NoteParamData(param.name, param.data.defaultValue));
|
||||
}
|
||||
chartEditorState.noteParamsToPlace = noteParamData;
|
||||
}
|
||||
}
|
||||
|
||||
function addNoteKindParam(label:Label, component:Component):Void
|
||||
{
|
||||
toolboxNotesParams.push({label: label, component: component});
|
||||
|
@ -210,6 +241,17 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
|
|||
this.height = Math.max(DIALOG_HEIGHT, DIALOG_HEIGHT - 30 + toolboxNotesParams.length * 30);
|
||||
}
|
||||
|
||||
function clearNoteKindParams():Void
|
||||
{
|
||||
for (param in toolboxNotesParams)
|
||||
{
|
||||
toolboxNotesGrid.removeComponent(param.component);
|
||||
toolboxNotesGrid.removeComponent(param.label);
|
||||
}
|
||||
toolboxNotesParams = [];
|
||||
this.height = DIALOG_HEIGHT;
|
||||
}
|
||||
|
||||
override function update(elapsed:Float):Void
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
@ -227,17 +269,6 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
|
|||
}
|
||||
}
|
||||
|
||||
function clearNoteKindParams():Void
|
||||
{
|
||||
for (param in toolboxNotesParams)
|
||||
{
|
||||
toolboxNotesGrid.removeComponent(param.component);
|
||||
toolboxNotesGrid.removeComponent(param.label);
|
||||
}
|
||||
toolboxNotesParams = [];
|
||||
this.height = DIALOG_HEIGHT;
|
||||
}
|
||||
|
||||
public static function build(chartEditorState:ChartEditorState):ChartEditorNoteDataToolbox
|
||||
{
|
||||
return new ChartEditorNoteDataToolbox(chartEditorState);
|
||||
|
|
Loading…
Add table
Reference in a new issue