Chart Editor: Several bug fixes (#139)

* Fix a crash bug caused by unhandled null value.

* Fix bug where note preview wouldn't update on song load

* Fix note preview not updating when loading inst, fixed BF health icon positioning
This commit is contained in:
Eric 2023-08-30 18:29:09 -04:00 committed by GitHub
parent cb81371b4a
commit 3828179218
3 changed files with 16 additions and 6 deletions

View file

@ -833,6 +833,9 @@ class ChartEditorDialogHandler
songChartDataVariation = SongValidator.validateSongChartData(songChartDataVariation, 'import');
songChartData.set(variation, songChartDataVariation);
state.notePreviewDirty = true;
state.notePreviewViewportBoundsDirty = true;
state.noteDisplayDirty = true;
// Tell the user the load was successful.
NotificationManager.instance.addNotification(
@ -858,6 +861,9 @@ class ChartEditorDialogHandler
songChartDataVariation = SongValidator.validateSongChartData(songChartDataVariation, 'import');
songChartData.set(variation, songChartDataVariation);
state.notePreviewDirty = true;
state.notePreviewViewportBoundsDirty = true;
state.noteDisplayDirty = true;
// Tell the user the load was successful.
NotificationManager.instance.addNotification(

View file

@ -132,6 +132,8 @@ class ChartEditorNoteSprite extends FlxSprite
public function updateNotePosition(?origin:FlxObject)
{
if (this.noteData == null) return;
var cursorColumn:Int = this.noteData.data;
if (cursorColumn < 0) cursorColumn = 0;

View file

@ -569,7 +569,6 @@ class ChartEditorState extends HaxeUIState
/**
* Whether the note preview graphic needs to be FULLY rebuilt.
* The Bitmap can be modified by individual commands without using this.
*/
var notePreviewDirty:Bool = true;
@ -1317,7 +1316,7 @@ class ChartEditorState extends HaxeUIState
healthIconBF = new HealthIcon(currentSongCharacterPlayer);
healthIconBF.autoUpdate = false;
healthIconBF.size.set(0.5, 0.5);
healthIconBF.x = gridTiledSprite.x + GRID_SIZE * (STRUMLINE_SIZE * 2 + 1) + 15;
healthIconBF.x = gridTiledSprite.x + gridTiledSprite.width + 15;
healthIconBF.y = gridTiledSprite.y + 5;
healthIconBF.flipX = true;
add(healthIconBF);
@ -1797,7 +1796,7 @@ class ChartEditorState extends HaxeUIState
if (healthIconBF != null)
{
// Base X position to the right of the grid.
var baseHealthIconXPos:Float = gridTiledSprite?.x ?? 0.0 + GRID_SIZE * (STRUMLINE_SIZE * 2 + 1) + 15;
var baseHealthIconXPos:Float = (gridTiledSprite == null) ? (0) : (gridTiledSprite.x + gridTiledSprite.width + 15);
// Will be 0 when not bopping. When bopping, will increase to push the icon left.
var healthIconOffset:Float = healthIconBF.width - (HealthIcon.HEALTH_ICON_SIZE * 0.5);
healthIconBF.x = baseHealthIconXPos - healthIconOffset;
@ -2718,12 +2717,12 @@ class ChartEditorState extends HaxeUIState
trace('Creating new Note... (${renderedNotes.members.length})');
noteSprite.parentState = this;
// Setting note data resets position relative to the grid so we fix that.
noteSprite.updateNotePosition(renderedNotes);
// The note sprite handles animation playback and positioning.
noteSprite.noteData = noteData;
// Setting note data resets position relative to the grid so we fix that.
noteSprite.updateNotePosition(renderedNotes);
// Add hold notes that are now visible (and not already displayed).
if (noteSprite.noteData != null && noteSprite.noteData.length > 0 && displayedHoldNoteData.indexOf(noteSprite.noteData) == -1)
{
@ -3869,6 +3868,9 @@ class ChartEditorState extends HaxeUIState
scrollPositionInPixels = 0;
playheadPositionInPixels = 0;
notePreviewDirty = true;
notePreviewViewportBoundsDirty = true;
noteDisplayDirty = true;
moveSongToScrollPosition();
}