possibility to undo and redo note type changes yay

This commit is contained in:
⍚~Nex
2024-01-05 03:26:55 +01:00
parent 0b76255e07
commit be3ffd6e4f
7 changed files with 25 additions and 13 deletions

Before

Width:  |  Height:  |  Size: 193 B

After

Width:  |  Height:  |  Size: 193 B

@@ -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);
}
+19 -7
View File
@@ -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<CharterNote>, oldTypes:Array<Int>, newTypes:Array<Int>} = {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<ChartEvent>, newEvents:Array<ChartEvent>);
CEditChartData(oldData:{stage:String, speed:Float}, newData:{stage:String, speed:Float});
CEditNoteTypes(oldArray:Array<String>, newArray:Array<String>);
CEditSpecNotesType(notes:Array<CharterNote>, oldNoteTypes:Array<Int>, newNoteTypes:Array<Int>);
}
enum CharterCopyboardObject {
@@ -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);
}
@@ -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);
}
@@ -63,7 +63,7 @@ class EditNoteTypesList extends UISubstateWindow {
var oldList:Array<String> = Charter.instance.noteTypes;
var newList:Array<String> = [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);
}
+1 -1
View File
@@ -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);