Updater for the Note Types list in Chart Editor
This commit is contained in:
@@ -0,0 +1 @@
|
||||
// yo just for testing
|
||||
@@ -205,10 +205,14 @@ class Charter extends UIState {
|
||||
null,
|
||||
{
|
||||
label: "Edit chart data",
|
||||
color: 0xFF959829, icon: 4,
|
||||
onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;},
|
||||
onSelect: chart_edit_data
|
||||
},
|
||||
{
|
||||
label: "Edit metadata information",
|
||||
color: 0xFF959829, icon: 4,
|
||||
onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;},
|
||||
onSelect: chart_edit_metadata
|
||||
}
|
||||
]
|
||||
@@ -270,19 +274,11 @@ class Charter extends UIState {
|
||||
},
|
||||
null,
|
||||
{
|
||||
label: "Add Note Type",
|
||||
label: "Edit Note Types List",
|
||||
color: 0xFF959829, icon: 4,
|
||||
onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;},
|
||||
closeOnSelect: false,
|
||||
onSelect: function (p) {trace(p);}
|
||||
},
|
||||
{
|
||||
label: "Edit Note Type",
|
||||
closeOnSelect: false,
|
||||
onSelect: function (p) {trace(p);}
|
||||
},
|
||||
{
|
||||
label: "Delete Note Type",
|
||||
closeOnSelect: false,
|
||||
onSelect: function (p) {trace(p);}
|
||||
onSelect: editNoteTypesList
|
||||
},
|
||||
null,
|
||||
{
|
||||
@@ -1239,6 +1235,9 @@ class Charter extends UIState {
|
||||
case CEditChartData(oldData, newData):
|
||||
PlayState.SONG.stage = oldData.stage;
|
||||
PlayState.SONG.scrollSpeed = oldData.speed;
|
||||
case CEditNoteTypes(oldArray, newArray):
|
||||
noteTypes = oldArray;
|
||||
changeNoteType();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1279,6 +1278,9 @@ class Charter extends UIState {
|
||||
case CEditChartData(oldData, newData):
|
||||
PlayState.SONG.stage = newData.stage;
|
||||
PlayState.SONG.scrollSpeed = newData.speed;
|
||||
case CEditNoteTypes(oldArray, newArray):
|
||||
noteTypes = newArray;
|
||||
changeNoteType();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1409,14 +1411,21 @@ class Charter extends UIState {
|
||||
undos.addToUndo(CEditSustains(undoChanges));
|
||||
}
|
||||
|
||||
inline function changeNoteType(newID:Int) {
|
||||
this.noteType = newID; buildNoteTypesUI();
|
||||
for(s in selection)
|
||||
inline public function changeNoteType(?newID:Int) {
|
||||
if(newID != null) noteType = newID;
|
||||
if(noteType < 0) noteType = 0;
|
||||
else if (noteType > noteTypes.length) noteType = noteTypes.length;
|
||||
|
||||
buildNoteTypesUI();
|
||||
for(s in selection)
|
||||
if (s is CharterNote) {
|
||||
var n:CharterNote = cast s;
|
||||
n.updatePos(n.step, n.id, n.susLength, newID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function editNoteTypesList(_)
|
||||
FlxG.state.openSubState(new EditNoteTypesList());
|
||||
|
||||
function buildNoteTypesUI() {
|
||||
var noteTopButton:UITopMenuButton = cast topMenuSpr.members[noteIndex];
|
||||
@@ -1444,30 +1453,11 @@ class Charter extends UIState {
|
||||
},
|
||||
null,
|
||||
{
|
||||
label: "Add Note Type",
|
||||
color: 0xFF1E8020, icon: 2,
|
||||
onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;},
|
||||
closeOnSelect: false,
|
||||
onSelect: function (_) {
|
||||
var addButton:UIContextMenuOptionSpr = _.button;
|
||||
addButton.label.text = "";
|
||||
var textBox:UITextBox = new UITextBox(addButton.x + 26, addButton.y+2, "TEST", 200, addButton.bHeight-4);
|
||||
addButton.members.push(textBox);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Edit Note Type",
|
||||
label: "Edit Note Types List",
|
||||
color: 0xFF959829, icon: 4,
|
||||
onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;},
|
||||
closeOnSelect: false,
|
||||
onSelect: function (p) {trace(p);},
|
||||
},
|
||||
{
|
||||
label: "Delete Note Type",
|
||||
color: 0xFF8F2222, icon: 3,
|
||||
onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2; button.icon.offset.y = -1;},
|
||||
closeOnSelect: false,
|
||||
onSelect: function (p) {trace(p);},
|
||||
onSelect: editNoteTypesList
|
||||
},
|
||||
null,
|
||||
{
|
||||
@@ -1560,6 +1550,7 @@ enum CharterChange {
|
||||
CEditSustains(notes:Array<NoteSustainChange>);
|
||||
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>);
|
||||
}
|
||||
|
||||
enum CharterCopyboardObject {
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package funkin.editors.charter;
|
||||
|
||||
import flixel.math.FlxPoint;
|
||||
import haxe.io.Path;
|
||||
|
||||
class EditNoteTypesList extends UISubstateWindow {
|
||||
public static var pathString:String = 'data/noteTypes/';
|
||||
|
||||
public var noteTypesList:UIButtonList<NoteTypeButton>;
|
||||
public var saveButton:UIButton;
|
||||
public var closeButton:UIButton;
|
||||
|
||||
public override function create() {
|
||||
FlxG.sound.music.pause();
|
||||
Charter.instance.vocals.pause();
|
||||
|
||||
winTitle = 'Note Types List Editor';
|
||||
winWidth = 380; winHeight = 390;
|
||||
|
||||
super.create();
|
||||
|
||||
var title:UIText;
|
||||
add(title = new UIText(windowSpr.x + 25, windowSpr.y + 15 + 16, 0, "Edit Note Types List", 28));
|
||||
|
||||
var noteTypesFileList = getNoteTypesList(true);
|
||||
if (noteTypesFileList.length == 0) noteTypesFileList = getNoteTypesList(false);
|
||||
var list:Array<String> = Charter.instance.noteTypes;
|
||||
|
||||
noteTypesList = new UIButtonList<NoteTypeButton>(15, title.y + title.height + 10, winWidth - 35, 260, "", FlxPoint.get(winWidth - 35, 60), null, 0);
|
||||
noteTypesList.addButton.callback = () -> noteTypesList.add(new NoteTypeButton(0, 0, "New Note Type", noteTypesFileList, noteTypesList));
|
||||
noteTypesList.cameraSpacing = 0;
|
||||
for (i in list)
|
||||
noteTypesList.add(new NoteTypeButton(0, 0, i, noteTypesFileList, noteTypesList));
|
||||
add(noteTypesList);
|
||||
noteTypesList.frames = Paths.getFrames('editors/ui/inputbox');
|
||||
|
||||
saveButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20 - 125, windowSpr.y + windowSpr.bHeight - 16 - 32, "Save & Close", function() {
|
||||
saveList();
|
||||
close();
|
||||
}, 125);
|
||||
add(saveButton);
|
||||
|
||||
closeButton = new UIButton(saveButton.x - 20, saveButton.y, "Close", function() {
|
||||
close();
|
||||
}, 125);
|
||||
add(closeButton);
|
||||
closeButton.color = 0xFFFF0000;
|
||||
closeButton.x -= closeButton.bWidth;
|
||||
}
|
||||
|
||||
public function getNoteTypesList(?mods:Bool = false) {
|
||||
var list:Array<String> = [];
|
||||
for (path in Paths.getFolderContent(pathString, true, mods ? MODS : BOTH)) if(Path.extension(path) == "hx") {
|
||||
var file:String = Path.withoutDirectory(Path.withoutExtension(path));
|
||||
if (!list.contains(file)) list.push(file);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public function saveList()
|
||||
{
|
||||
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.undos.addToUndo(CEditNoteTypes(oldList, newList));
|
||||
}
|
||||
}
|
||||
|
||||
class NoteTypeButton extends UIButton {
|
||||
public var textBox:UIAutoCompleteTextBox;
|
||||
public var deleteButton:UIButton;
|
||||
public var deleteIcon:FlxSprite;
|
||||
|
||||
public function new(x:Float, y:Float, name:String, list:Array<String>, parent:UIButtonList<NoteTypeButton>) {
|
||||
super(x, y, '', null, Std.int(parent.buttonSize.x), Std.int(parent.buttonSize.y));
|
||||
autoAlpha = false;
|
||||
|
||||
members.push(textBox = new UIAutoCompleteTextBox(5, bHeight/2 - 40, name, 250));
|
||||
textBox.suggestItems = list;
|
||||
textBox.antialiasing = true;
|
||||
|
||||
field.alignment = LEFT;
|
||||
field.x = textBox.x;
|
||||
field.y = textBox.y + textBox.height + 30;
|
||||
field.height = 9;
|
||||
|
||||
deleteButton = new UIButton(textBox.x + textBox.label.width + 10, textBox.y - 8, "", function () {
|
||||
parent.remove(this);
|
||||
}, 32);
|
||||
deleteButton.color = 0xFFFF0000;
|
||||
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.antialiasing = false;
|
||||
members.push(deleteIcon);
|
||||
}
|
||||
|
||||
private var lastName:String = null;
|
||||
override function update(elapsed) {
|
||||
deleteButton.y = y + bHeight / 2 - deleteButton.bHeight / 2 - 8;
|
||||
textBox.y = y + bHeight/2 - 20;
|
||||
deleteIcon.x = deleteButton.x + (15/2); deleteIcon.y = deleteButton.y + 8;
|
||||
|
||||
deleteButton.selectable = selectable;
|
||||
deleteButton.shouldPress = shouldPress;
|
||||
|
||||
super.update(elapsed);
|
||||
field.follow(this, textBox.x, textBox.x + textBox.height + 30);
|
||||
if(lastName != textBox.label.text) {
|
||||
lastName = textBox.label.text;
|
||||
field.text = 'Path: ${EditNoteTypesList.pathString}$lastName.hx';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user