2024-02-17 03:01:47 +00:00
|
|
|
package funkin.ui.debug.charting.toolboxes;
|
|
|
|
|
|
|
|
import haxe.ui.components.DropDown;
|
|
|
|
import haxe.ui.components.TextField;
|
|
|
|
import haxe.ui.events.UIEvent;
|
|
|
|
import funkin.ui.debug.charting.util.ChartEditorDropdowns;
|
2024-06-02 21:31:49 +00:00
|
|
|
import funkin.ui.debug.charting.components.ChartEditorNoteSprite;
|
|
|
|
import funkin.ui.debug.charting.components.ChartEditorHoldNoteSprite;
|
2024-06-02 00:44:16 +00:00
|
|
|
import funkin.play.notes.notestyle.NoteStyle;
|
|
|
|
import funkin.play.notes.notekind.NoteKindManager;
|
2024-02-17 03:01:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The toolbox which allows modifying information like Note Kind.
|
|
|
|
*/
|
|
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
|
|
|
@:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/toolboxes/note-data.xml"))
|
|
|
|
class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
|
|
|
|
{
|
|
|
|
var toolboxNotesNoteKind:DropDown;
|
|
|
|
var toolboxNotesCustomKind:TextField;
|
|
|
|
|
|
|
|
var _initializing:Bool = true;
|
|
|
|
|
|
|
|
public function new(chartEditorState2:ChartEditorState)
|
|
|
|
{
|
|
|
|
super(chartEditorState2);
|
|
|
|
|
|
|
|
initialize();
|
|
|
|
|
|
|
|
this.onDialogClosed = onClose;
|
|
|
|
|
|
|
|
this._initializing = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onClose(event:UIEvent)
|
|
|
|
{
|
|
|
|
chartEditorState.menubarItemToggleToolboxNoteData.selected = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function initialize():Void
|
|
|
|
{
|
|
|
|
toolboxNotesNoteKind.onChange = function(event:UIEvent) {
|
|
|
|
var noteKind:Null<String> = event?.data?.id ?? null;
|
|
|
|
if (noteKind == '') noteKind = null;
|
|
|
|
|
|
|
|
trace('ChartEditorToolboxHandler.buildToolboxNoteDataLayout() - Note kind changed: $noteKind');
|
|
|
|
|
|
|
|
// Edit the note data to place.
|
|
|
|
if (noteKind == '~CUSTOM~')
|
|
|
|
{
|
|
|
|
showCustom();
|
|
|
|
toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hideCustom();
|
|
|
|
chartEditorState.noteKindToPlace = noteKind;
|
|
|
|
toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_initializing && chartEditorState.currentNoteSelection.length > 0)
|
|
|
|
{
|
|
|
|
for (note in chartEditorState.currentNoteSelection)
|
|
|
|
{
|
2024-06-02 22:03:47 +00:00
|
|
|
// Edit the note data of any selected notes.
|
|
|
|
note.kind = chartEditorState.noteKindToPlace;
|
|
|
|
|
2024-06-02 21:31:49 +00:00
|
|
|
// update note sprites
|
2024-06-02 22:03:47 +00:00
|
|
|
for (noteSprite in chartEditorState.renderedNotes.members)
|
2024-06-02 21:31:49 +00:00
|
|
|
{
|
|
|
|
if (noteSprite.noteData == note)
|
|
|
|
{
|
2024-06-02 22:03:47 +00:00
|
|
|
noteSprite.noteStyle = NoteKindManager.getNoteStyleId(note.kind) ?? chartEditorState.currentSongNoteStyle;
|
2024-06-02 21:31:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// update hold note sprites
|
2024-06-02 22:03:47 +00:00
|
|
|
for (holdNoteSprite in chartEditorState.renderedHoldNotes.members)
|
2024-06-02 21:31:49 +00:00
|
|
|
{
|
|
|
|
if (holdNoteSprite.noteData == note)
|
|
|
|
{
|
2024-06-02 22:03:47 +00:00
|
|
|
holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(note.kind) ?? chartEditorState.currentSongNoteStyle;
|
2024-06-02 21:31:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2024-02-17 03:01:47 +00:00
|
|
|
}
|
|
|
|
chartEditorState.saveDataDirty = true;
|
|
|
|
chartEditorState.noteDisplayDirty = true;
|
|
|
|
chartEditorState.notePreviewDirty = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var startingValueNoteKind = ChartEditorDropdowns.populateDropdownWithNoteKinds(toolboxNotesNoteKind, '');
|
|
|
|
toolboxNotesNoteKind.value = startingValueNoteKind;
|
|
|
|
|
|
|
|
toolboxNotesCustomKind.onChange = function(event:UIEvent) {
|
|
|
|
var customKind:Null<String> = event?.target?.text;
|
|
|
|
chartEditorState.noteKindToPlace = customKind;
|
|
|
|
|
|
|
|
if (chartEditorState.currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
// Edit the note data of any selected notes.
|
|
|
|
for (note in chartEditorState.currentNoteSelection)
|
|
|
|
{
|
|
|
|
note.kind = chartEditorState.noteKindToPlace;
|
|
|
|
}
|
|
|
|
chartEditorState.saveDataDirty = true;
|
|
|
|
chartEditorState.noteDisplayDirty = true;
|
|
|
|
chartEditorState.notePreviewDirty = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override function refresh():Void
|
|
|
|
{
|
|
|
|
super.refresh();
|
|
|
|
|
|
|
|
toolboxNotesNoteKind.value = ChartEditorDropdowns.lookupNoteKind(chartEditorState.noteKindToPlace);
|
|
|
|
toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace;
|
|
|
|
}
|
|
|
|
|
|
|
|
function showCustom():Void
|
|
|
|
{
|
|
|
|
toolboxNotesCustomKindLabel.hidden = false;
|
|
|
|
toolboxNotesCustomKind.hidden = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideCustom():Void
|
|
|
|
{
|
|
|
|
toolboxNotesCustomKindLabel.hidden = true;
|
|
|
|
toolboxNotesCustomKind.hidden = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function build(chartEditorState:ChartEditorState):ChartEditorNoteDataToolbox
|
|
|
|
{
|
|
|
|
return new ChartEditorNoteDataToolbox(chartEditorState);
|
|
|
|
}
|
|
|
|
}
|