1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-04 22:04:29 +00:00

Fix some issues with events unintentionally sharing data after being edited via the toolbox.

This commit is contained in:
EliteMasterEric 2024-03-21 23:57:26 -04:00
parent 494a3c9e86
commit 5e0de6d1ce
5 changed files with 28 additions and 7 deletions

View file

@ -706,7 +706,7 @@ abstract SongEventData(SongEventDataRaw) from SongEventDataRaw to SongEventDataR
this = new SongEventDataRaw(time, eventKind, value);
}
public inline function valueAsStruct(?defaultKey:String = "key"):Dynamic
public function valueAsStruct(?defaultKey:String = "key"):Dynamic
{
if (this.value == null) return {};
if (Std.isOfType(this.value, Array))

View file

@ -878,6 +878,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
*/
var noteDisplayDirty:Bool = true;
var noteTooltipsDirty:Bool = true;
/**
* Whether the selected charactesr have been modified and the health icons need to be updated.
*/
@ -1541,6 +1543,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Make sure view is updated when the variation changes.
noteDisplayDirty = true;
notePreviewDirty = true;
noteTooltipsDirty = true;
notePreviewViewportBoundsDirty = true;
switchToCurrentInstrumental();
@ -1562,6 +1565,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Make sure view is updated when the difficulty changes.
noteDisplayDirty = true;
notePreviewDirty = true;
noteTooltipsDirty = true;
notePreviewViewportBoundsDirty = true;
// Make sure the difficulty we selected is in the list of difficulties.
@ -3663,8 +3667,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
selectionSquare.width = eventSprite.width;
selectionSquare.height = eventSprite.height;
}
// Additional cleanup on notes.
if (noteTooltipsDirty) eventSprite.updateTooltipText();
}
noteTooltipsDirty = false;
// Sort the notes DESCENDING. This keeps the sustain behind the associated note.
renderedNotes.sort(FlxSort.byY, FlxSort.DESCENDING); // TODO: .group.insertionSort()

View file

@ -51,7 +51,12 @@ class SetItemSelectionCommand implements ChartEditorCommand
}
var eventData = eventSelected.valueAsStruct(defaultKey);
state.eventDataToPlace = eventData;
var eventDataClone = Reflect.copy(eventData);
if (eventDataClone != null)
{
state.eventDataToPlace = eventDataClone;
}
state.refreshToolbox(ChartEditorState.CHART_EDITOR_TOOLBOX_EVENT_DATA_LAYOUT);
}

View file

@ -164,8 +164,7 @@ class ChartEditorEventSprite extends FlxSprite
this.eventData = value;
// Update the position to match the note data.
updateEventPosition();
// Update the tooltip text.
this.tooltip.tipData = {text: this.eventData.buildTooltip()};
updateTooltipText();
return this.eventData;
}
}
@ -188,6 +187,13 @@ class ChartEditorEventSprite extends FlxSprite
this.updateTooltipPosition();
}
public function updateTooltipText():Void
{
if (this.eventData == null) return;
if (this.isGhost) return;
this.tooltip.tipData = {text: this.eventData.buildTooltip()};
}
public function updateTooltipPosition():Void
{
// No tooltip for ghost sprites.

View file

@ -258,14 +258,15 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox
// Edit the event data of any existing events.
if (!_initializing && chartEditorState.currentEventSelection.length > 0)
{
for (event in chartEditorState.currentEventSelection)
for (songEvent in chartEditorState.currentEventSelection)
{
event.eventKind = chartEditorState.eventKindToPlace;
event.value = chartEditorState.eventDataToPlace;
songEvent.eventKind = chartEditorState.eventKindToPlace;
songEvent.value = Reflect.copy(chartEditorState.eventDataToPlace);
}
chartEditorState.saveDataDirty = true;
chartEditorState.noteDisplayDirty = true;
chartEditorState.notePreviewDirty = true;
chartEditorState.noteTooltipsDirty = true;
}
}
}