diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 43d2cb9ba..5c592ef40 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -86,6 +86,8 @@ class Charter extends UIState { public var clipboard:Array = []; + public var noteTypeDropdown:UIDropDown; + public function new(song:String, diff:String, reload:Bool = true) { super(); __song = song; @@ -225,12 +227,24 @@ class Charter extends UIState { }, null, { - label: "(0) Default Note", - keybind: [ZERO] + label: "Switch to default note type", + keybind: [ZERO], + onSelect: _note_defaultnote + }, + { + label: "Switch to previous note type", + keybind: [ONE], + onSelect: _note_prevnote + }, + { + label: "Switch to next note type", + keybind: [TWO], + onSelect: _note_nextnote }, { - label: "(1) Hurt Note", - keybind: [ONE] + label: "Edit note types", + keybind: [], + onSelect: _edit_notetype } ] }, @@ -405,6 +419,13 @@ class Charter extends UIState { addEventSpr.alpha = 0; addEventSpr.cameras = [charterCamera]; + var noteTypes:Array = ['default']; + noteTypeDropdown = new UIDropDown(10,105,200,32,noteTypes); + noteTypeDropdown.onChange = function(n) { + for(note in selection) + note.updatePos(note.step,note.id,note.susLength,n); + } + uiGroup.add(noteTypeDropdown); // adds grid and notes so that they're ALWAYS behind the UI add(gridBackdrop); @@ -465,6 +486,7 @@ class Charter extends UIState { for(e in eventsGroup.members) e.refreshEventIcons(); + _reload_notetypes(); refreshBPMSensitive(); } @@ -499,6 +521,8 @@ class Charter extends UIState { selection.remove(n); else selection = [n]; + + noteTypeDropdown.setOption(n.type); } if (FlxG.mouse.justReleasedRight) { if (!selection.contains(n)) @@ -612,8 +636,9 @@ class Charter extends UIState { var id = Math.floor(mousePos.x / 40); if (id >= 0 && id < 4 * gridBackdrop.strumlinesAmount && mousePos.y >= 0) { var note = new CharterNote(); - note.updatePos(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Math.floor(mousePos.y / 40), id, 0, 0); + note.updatePos(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Math.floor(mousePos.y / 40), id, 0, noteTypeDropdown.index); notesGroup.add(note); + trace(note.type); selection = [note]; addToUndo(CPlaceNote(note)); } @@ -922,7 +947,8 @@ class Charter extends UIState { } function _file_saveas(_) { - openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false)), { + buildChart(); // note types are not saved i think + openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false), null, "\t"), { defaultSaveFile: '${__diff.toLowerCase()}.json' })); } @@ -1161,13 +1187,57 @@ class Charter extends UIState { #end + function _edit_notetype(t):Void + { + var state = new NoteTypeScreen(PlayState.SONG); + state.closeCallback = function() { _reload_notetypes(); }; + state.closeRemoveNoteCallback = function(n) { + _reload_notetypes(); + noteTypeDropdown.setOption(0); + notesGroup.forEach(function(note) { + if(note.type == n) + note.updatePos(note.step, note.id, note.susLength, 0); + if(note.type >= n) + note.updatePos(note.step, note.id, note.susLength, note.type-1); + }); + }; + FlxG.state.openSubState(state); + } + + inline function _note_defaultnote(_) + noteTypeDropdown.setOption(0); + + + inline function _note_prevnote(_) { + if(noteTypeDropdown.index == 0) + noteTypeDropdown.setOption(noteTypeDropdown.options.length - 1); + else + noteTypeDropdown.setOption(noteTypeDropdown.index - 1); + } + + inline function _note_nextnote(_) { + if(noteTypeDropdown.index == noteTypeDropdown.options.length - 1) + noteTypeDropdown.setOption(0); + else + noteTypeDropdown.setOption(noteTypeDropdown.index + 1); + } + + + public function _reload_notetypes() + { + var noteTypes:Array = ['default']; + for(noteType in PlayState.SONG.noteTypes) + noteTypes.push(noteType); + noteTypeDropdown.options = noteTypes; + } + function changeNoteSustain(change:Float) { if (selection.length <= 0 || change == 0) return; addToUndo(CSustainChange([ for(n in selection) { var old:Float = n.susLength; - n.updatePos(n.step, n.id, Math.max(n.susLength + change, 0)); + n.updatePos(n.step, n.id, Math.max(n.susLength + change, 0),n.type); { before: old, diff --git a/source/funkin/editors/charter/CharterNote.hx b/source/funkin/editors/charter/CharterNote.hx index c5214a44d..4cb23bd89 100644 --- a/source/funkin/editors/charter/CharterNote.hx +++ b/source/funkin/editors/charter/CharterNote.hx @@ -17,6 +17,7 @@ class CharterNote extends UISprite { public var sustainSpr:FlxSprite; public var selected:Bool = false; + public var numberLabel:UIText; var __doAnim:Bool = false; @@ -37,6 +38,11 @@ class CharterNote extends UISprite { sustainSpr = new FlxSprite(10, 40); sustainSpr.makeGraphic(1, 1, -1); members.push(sustainSpr); + + numberLabel = new UIText(30,20,200,'',24,FlxColor.WHITE); + numberLabel.borderStyle = OUTLINE; + numberLabel.borderSize = 1; + numberLabel.borderColor = FlxColor.BLACK; } public override function updateButtonHandler() { @@ -75,6 +81,9 @@ class CharterNote extends UISprite { default: 0; // how is that even possible }; + // 0 is default ! + numberLabel.text = type == 0 ? '' : Std.string(this.type); + sustainSpr.color = colors[animation.curAnim.curFrame]; if (!__doAnim) { @@ -113,6 +122,7 @@ class CharterNote extends UISprite { super.update(elapsed); sustainSpr.follow(this, 15, 20); + numberLabel.follow(this, 19, 15); if (__passed != (__passed = step < Conductor.curStepFloat)) { alpha = __passed ? 0.6 : 1; @@ -131,5 +141,7 @@ class CharterNote extends UISprite { public override function draw() { drawMembers(); drawSuper(); + if(type != 0) + numberLabel.draw(); } } \ No newline at end of file diff --git a/source/funkin/editors/charter/NoteTypeScreen.hx b/source/funkin/editors/charter/NoteTypeScreen.hx new file mode 100644 index 000000000..a26cb6dc8 --- /dev/null +++ b/source/funkin/editors/charter/NoteTypeScreen.hx @@ -0,0 +1,84 @@ +package funkin.editors.charter; + +import funkin.backend.chart.ChartData; +import flixel.math.FlxPoint; +import funkin.backend.chart.ChartData.ChartMetaData; + +using StringTools; + +class NoteTypeScreen extends UISubstateWindow { + public var data:ChartData; + public var addButton:UIButton; + public var closeButton:UIButton; + public var removeButton:UIButton; + + public var scrollSpeedStepper:UINumericStepper; + public var stageBox:UITextBox; + + public var noteTypeDropdown:UIDropDown; + + public var noteTypeNameBox:UITextBox; + + public var closeRemoveNoteCallback:Int->Void; + + public function new(data:ChartData) { + super(); + this.data = data; + } + + public override function create() { + FlxG.sound.music.pause(); + Charter.instance.vocals.pause(); + + function addLabelOn(ui:UISprite, text:String) + add(new UIText(ui.x, ui.y - 24, 0, text)); + + winTitle = 'Edit note types'; + winWidth = 420; winHeight = 69*4; // guys look, the funny numbers! + + super.create(); + + noteTypeDropdown = new UIDropDown(windowSpr.x + 20, windowSpr.y + 60,200,32,PlayState.SONG.noteTypes); + addLabelOn(noteTypeDropdown, "Note"); + add(noteTypeDropdown); + + addButton = new UIButton(windowSpr.x + 200 + 40, windowSpr.y + 60 + 32 + 16, "Add new note type", function() { + noteTypeDropdown.visible = false; + noteTypeDropdown.active = false; + removeButton.visible = false; + removeButton.active = false; + + addButton.field.text = 'Create note type'; + addButton.callback = function() {onSave(); close();} + + noteTypeNameBox = new UITextBox(windowSpr.x + 20, windowSpr.y + 60, ''); + add(noteTypeNameBox); + + }, 125); + add(addButton); + + removeButton = new UIButton(windowSpr.x + 200 + 40, windowSpr.y + 60, "Remove note type", function() { + onRemove(); + close(); + }, 125); + add(removeButton); + + closeButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20 - 125, windowSpr.y + windowSpr.bHeight - 16 - 32, "Cancel", function() { + close(); + }, 125); + add(closeButton); + closeButton.x -= closeButton.bWidth; + } + + public function onSave() + { + PlayState.SONG.noteTypes.push(noteTypeNameBox.label.text); + } + + public function onRemove() + { + closeRemoveNoteCallback(noteTypeDropdown.index + 1); + PlayState.SONG.noteTypes.remove(noteTypeDropdown.label.text); + } + +} \ No newline at end of file