From be3ffd6e4f1bbf447db17816f066724ae1530dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Fri, 5 Jan 2024 03:26:55 +0100 Subject: [PATCH] possibility to undo and redo note type changes yay --- .../editors/{character => }/delete-button.png | Bin .../editors/character/CharacterAnimButtons.hx | 2 +- source/funkin/editors/charter/Charter.hx | 26 +++++++++++++----- .../editors/charter/CharterEventScreen.hx | 2 +- .../editors/charter/CharterStrumlineScreen.hx | 2 +- .../editors/charter/EditNoteTypesList.hx | 4 +-- source/funkin/editors/ui/UIFileExplorer.hx | 2 +- 7 files changed, 25 insertions(+), 13 deletions(-) rename assets/images/editors/{character => }/delete-button.png (100%) diff --git a/assets/images/editors/character/delete-button.png b/assets/images/editors/delete-button.png similarity index 100% rename from assets/images/editors/character/delete-button.png rename to assets/images/editors/delete-button.png diff --git a/source/funkin/editors/character/CharacterAnimButtons.hx b/source/funkin/editors/character/CharacterAnimButtons.hx index bccc51a4..106f589f 100644 --- a/source/funkin/editors/character/CharacterAnimButtons.hx +++ b/source/funkin/editors/character/CharacterAnimButtons.hx @@ -55,7 +55,7 @@ class CharacterAnimButtons extends UIButton { deleteButton.autoAlpha = false; members.push(deleteButton); - deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 8).loadGraphic(Paths.image('editors/character/delete-button')); + deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 8).loadGraphic(Paths.image('editors/delete-button')); deleteIcon.antialiasing = false; members.push(deleteIcon); } diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 14857520..bb337350 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1237,7 +1237,9 @@ class Charter extends UIState { PlayState.SONG.scrollSpeed = oldData.speed; case CEditNoteTypes(oldArray, newArray): noteTypes = oldArray; - changeNoteType(); + changeNoteType(null, false); + case CEditSpecNotesType(notes, oldTypes, newTypes): + for(i=>note in notes) note.updatePos(note.step, note.id, note.susLength, oldTypes[i]); } } @@ -1280,7 +1282,9 @@ class Charter extends UIState { PlayState.SONG.scrollSpeed = newData.speed; case CEditNoteTypes(oldArray, newArray): noteTypes = newArray; - changeNoteType(); + changeNoteType(null, false); + case CEditSpecNotesType(notes, oldTypes, newTypes): + for(i=>note in notes) note.updatePos(note.step, note.id, note.susLength, newTypes[i]); } } @@ -1411,17 +1415,24 @@ class Charter extends UIState { undos.addToUndo(CEditSustains(undoChanges)); } - inline public function changeNoteType(?newID:Int) { + inline public function changeNoteType(?newID:Int, checkSelection:Bool = true) { if(newID != null) noteType = newID; - if(noteType < 0) noteType = 0; - else if (noteType > noteTypes.length) noteType = noteTypes.length; - + noteType = Std.int(FlxMath.bound(noteType, 0, noteTypes.length)); buildNoteTypesUI(); - for(s in selection) + + var changedNotes:{notes:Array, oldTypes:Array, newTypes:Array} = {notes:[], oldTypes:[], newTypes:[]}; + for(note in notesGroup) if(note.type < 0 || note.type > noteTypes.length) { + changedNotes.notes.push(note); changedNotes.oldTypes.push(note.type); changedNotes.newTypes.push(0); + note.updatePos(note.step, note.id, note.susLength, 0); + } + + if(checkSelection) for(s in selection) if (s is CharterNote) { var n:CharterNote = cast s; + changedNotes.notes.push(n); changedNotes.oldTypes.push(n.type); changedNotes.newTypes.push(newID); n.updatePos(n.step, n.id, n.susLength, newID); } + if(changedNotes.notes.length > 0) undos.addToUndo(CEditSpecNotesType(changedNotes.notes, changedNotes.oldTypes, changedNotes.newTypes)); } function editNoteTypesList(_) @@ -1551,6 +1562,7 @@ enum CharterChange { CEditEvent(event:CharterEvent, oldEvents:Array, newEvents:Array); CEditChartData(oldData:{stage:String, speed:Float}, newData:{stage:String, speed:Float}); CEditNoteTypes(oldArray:Array, newArray:Array); + CEditSpecNotesType(notes:Array, oldNoteTypes:Array, newNoteTypes:Array); } enum CharterCopyboardObject { diff --git a/source/funkin/editors/charter/CharterEventScreen.hx b/source/funkin/editors/charter/CharterEventScreen.hx index 257922c2..d8bce306 100644 --- a/source/funkin/editors/charter/CharterEventScreen.hx +++ b/source/funkin/editors/charter/CharterEventScreen.hx @@ -237,7 +237,7 @@ class EventButton extends UIButton { deleteButton.autoAlpha = false; members.push(deleteButton); - deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 4).loadGraphic(Paths.image('editors/character/delete-button')); + deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 4).loadGraphic(Paths.image('editors/delete-button')); deleteIcon.antialiasing = false; members.push(deleteIcon); } diff --git a/source/funkin/editors/charter/CharterStrumlineScreen.hx b/source/funkin/editors/charter/CharterStrumlineScreen.hx index 23f1ba6d..25784230 100644 --- a/source/funkin/editors/charter/CharterStrumlineScreen.hx +++ b/source/funkin/editors/charter/CharterStrumlineScreen.hx @@ -217,7 +217,7 @@ class CharacterButton extends UIButton { deleteButton.autoAlpha = false; members.push(deleteButton); - deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 8).loadGraphic(Paths.image('editors/character/delete-button')); + deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 8).loadGraphic(Paths.image('editors/delete-button')); deleteIcon.antialiasing = false; members.push(deleteIcon); } diff --git a/source/funkin/editors/charter/EditNoteTypesList.hx b/source/funkin/editors/charter/EditNoteTypesList.hx index 4b8ea1b4..18481d9c 100644 --- a/source/funkin/editors/charter/EditNoteTypesList.hx +++ b/source/funkin/editors/charter/EditNoteTypesList.hx @@ -63,7 +63,7 @@ class EditNoteTypesList extends UISubstateWindow { var oldList:Array = Charter.instance.noteTypes; var newList:Array = [for (note in noteTypesList.buttons.members) note.textBox.label.text]; Charter.instance.noteTypes = newList; - Charter.instance.changeNoteType(); + Charter.instance.changeNoteType(null, false); Charter.instance.undos.addToUndo(CEditNoteTypes(oldList, newList)); } } @@ -93,7 +93,7 @@ class NoteTypeButton extends UIButton { deleteButton.autoAlpha = false; members.push(deleteButton); - deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 8).loadGraphic(Paths.image('editors/character/delete-button')); // Yeah yeah its for characters, but tbh goes fire here too + deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 8).loadGraphic(Paths.image('editors/delete-button')); deleteIcon.antialiasing = false; members.push(deleteIcon); } diff --git a/source/funkin/editors/ui/UIFileExplorer.hx b/source/funkin/editors/ui/UIFileExplorer.hx index 35c42a3a..8ddd6101 100644 --- a/source/funkin/editors/ui/UIFileExplorer.hx +++ b/source/funkin/editors/ui/UIFileExplorer.hx @@ -40,7 +40,7 @@ class UIFileExplorer extends UISliceSprite { deleteButton.color = 0xFFFF0000; members.push(deleteButton); - deleteIcon = new FlxSprite(deleteButton.x + ((58 - 16)/2) - 8, deleteButton.y + ((58 - 16)/2) - 8).loadGraphic(Paths.image('editors/character/delete-button')); + deleteIcon = new FlxSprite(deleteButton.x + ((58 - 16)/2) - 8, deleteButton.y + ((58 - 16)/2) - 8).loadGraphic(Paths.image('editors/delete-button')); deleteIcon.antialiasing = false; members.push(deleteIcon);