From a9043e5ec244c4f835cb7b417cc3b85323530ef8 Mon Sep 17 00:00:00 2001 From: Frakist <90983918+Frakist@users.noreply.github.com> Date: Sun, 29 Oct 2023 15:18:10 +0300 Subject: [PATCH] [WIP] notetypes ! --- assets/data/notes/Dodge_Note copy 2.hx | 3 + assets/data/notes/Dodge_Note copy 3.hx | 3 + assets/data/notes/Dodge_Note copy 4.hx | 3 + assets/data/notes/Dodge_Note copy 5.hx | 3 + assets/data/notes/Dodge_Note copy.hx | 3 + assets/data/notes/Dodge_Note.hx | 4 ++ source/funkin/editors/charter/Charter.hx | 67 ++++++++++++++++++-- source/funkin/editors/charter/CharterNote.hx | 13 +++- 8 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 assets/data/notes/Dodge_Note copy 2.hx create mode 100644 assets/data/notes/Dodge_Note copy 3.hx create mode 100644 assets/data/notes/Dodge_Note copy 4.hx create mode 100644 assets/data/notes/Dodge_Note copy 5.hx create mode 100644 assets/data/notes/Dodge_Note copy.hx create mode 100644 assets/data/notes/Dodge_Note.hx diff --git a/assets/data/notes/Dodge_Note copy 2.hx b/assets/data/notes/Dodge_Note copy 2.hx new file mode 100644 index 00000000..fd73eb8d --- /dev/null +++ b/assets/data/notes/Dodge_Note copy 2.hx @@ -0,0 +1,3 @@ +function onPlayerHit(event) { + trace(event.noteType); +} \ No newline at end of file diff --git a/assets/data/notes/Dodge_Note copy 3.hx b/assets/data/notes/Dodge_Note copy 3.hx new file mode 100644 index 00000000..fd73eb8d --- /dev/null +++ b/assets/data/notes/Dodge_Note copy 3.hx @@ -0,0 +1,3 @@ +function onPlayerHit(event) { + trace(event.noteType); +} \ No newline at end of file diff --git a/assets/data/notes/Dodge_Note copy 4.hx b/assets/data/notes/Dodge_Note copy 4.hx new file mode 100644 index 00000000..fd73eb8d --- /dev/null +++ b/assets/data/notes/Dodge_Note copy 4.hx @@ -0,0 +1,3 @@ +function onPlayerHit(event) { + trace(event.noteType); +} \ No newline at end of file diff --git a/assets/data/notes/Dodge_Note copy 5.hx b/assets/data/notes/Dodge_Note copy 5.hx new file mode 100644 index 00000000..fd73eb8d --- /dev/null +++ b/assets/data/notes/Dodge_Note copy 5.hx @@ -0,0 +1,3 @@ +function onPlayerHit(event) { + trace(event.noteType); +} \ No newline at end of file diff --git a/assets/data/notes/Dodge_Note copy.hx b/assets/data/notes/Dodge_Note copy.hx new file mode 100644 index 00000000..fd73eb8d --- /dev/null +++ b/assets/data/notes/Dodge_Note copy.hx @@ -0,0 +1,3 @@ +function onPlayerHit(event) { + trace(event.noteType); +} \ No newline at end of file diff --git a/assets/data/notes/Dodge_Note.hx b/assets/data/notes/Dodge_Note.hx new file mode 100644 index 00000000..7bd7dc64 --- /dev/null +++ b/assets/data/notes/Dodge_Note.hx @@ -0,0 +1,4 @@ +function onPlayerHit(event) { + trace(event.noteType); + trace(SONG.noteTypes); +} \ No newline at end of file diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index f24c1c32..09531f6c 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -52,6 +52,7 @@ class Charter extends UIState { public var gridBackdrops:CharterBackdropGroup; public var eventsBackdrop:EventBackdrop; public var addEventSpr:CharterEventAdd; + public var noteTypeWindow:UIButtonList; public var gridBackdropDummy:CharterBackdropDummy; public var noteHoverer:CharterNote; @@ -66,9 +67,10 @@ class Charter extends UIState { public var vocals:FlxSound; public var noteSnap:Int = 16; - public var quantArray:Array = [4, 8, 12, 16, 20, 24, 32, 48, 64, 192]; // different quants + public var curNoteType:String = null; + /** * ACTUAL CHART DATA */ @@ -399,6 +401,13 @@ class Charter extends UIState { songPosInfo.alignment = RIGHT; songPosInfo.optimized = true; uiGroup.add(songPosInfo); + noteTypeWindow = new UIButtonList(1, 200, 300, 500, "Note Types", FlxPoint.get(296, 30), FlxPoint.get(2, 2)); + noteTypeWindow.buttons.add(new CharterNoteTypeButton("Default Note", noteTypeWindow, this, null)); + noteTypeWindow.cameras = [uiCamera]; + noteTypeWindow.addButton.callback = function() { + noteTypeWindow.buttons.add(new CharterNoteTypeButton("New NoteType", noteTypeWindow, this, Paths.getFolderContent("data/notes"))); + } + playBackSlider = new UISlider(FlxG.width - 160 - 26 - 20, (23/2) - (12/2), 160, 1, [{start: 0.25, end: 1, size: 0.5}, {start: 1, end: 2, size: 0.5}], true); playBackSlider.onChange = function (v) { FlxG.sound.music.pitch = vocals.pitch = v; @@ -442,6 +451,7 @@ class Charter extends UIState { add(topMenuSpr); // add the ui group add(uiGroup); + add(noteTypeWindow); loadSong(); @@ -467,6 +477,13 @@ class Charter extends UIState { EventsData.reloadEvents(); PlayState.loadSong(__song, __diff, false, false); } + chart.noteTypes = [for (i in Paths.getFolderContent("data/notes")) haxe.io.Path.withoutExtension(i)]; + for (i in Paths.getFolderContent("images/game/notes")) + if (!chart.noteTypes.contains(haxe.io.Path.withoutExtension(i)) && haxe.io.Path.withoutExtension(i) != "default") chart.noteTypes.push(haxe.io.Path.withoutExtension(i)); + + for (i in chart.noteTypes) + noteTypeWindow.buttons.add(new CharterNoteTypeButton(haxe.io.Path.withoutExtension(i), noteTypeWindow, this, Paths.getFolderContent("data/notes"))); + for(i in noteTypeWindow.buttons.members) i.alpha = i.theType == "Default Note" ? 1 : 0.25; Conductor.setupSong(PlayState.SONG); @@ -491,7 +508,7 @@ class Charter extends UIState { for (note in strL.notes) { var n = new CharterNote(); var t = Conductor.getStepForTime(note.time); - n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, note.type, strumLines.members[i]); + n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, (PlayState.SONG.noteTypes[note.type] != null ? PlayState.SONG.noteTypes[note.type] : "Default Note"), strumLines.members[i]); notesGroup.members[notesCreated++] = n; } notesGroup.sortNotes(); @@ -689,7 +706,7 @@ class Charter extends UIState { if (mouseOnGrid && mousePos.y > 0 && mousePos.y < (__endStep)*40) { var note = new CharterNote(); var gridmult = 40 / (noteSnap / 16); - note.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : snap(mousePos.y, gridmult) / 40, 0, __endStep-1), id % 4, 0, 0, strumLines.members[Std.int(id/4)]); + note.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : snap(mousePos.y, gridmult) / 40, 0, __endStep-1), id % 4, 0, curNoteType, strumLines.members[Std.int(id/4)]); notesGroup.add(note); selection = [note]; undos.addToUndo(CCreateSelection([note])); @@ -730,7 +747,7 @@ class Charter extends UIState { noteHoverer.alpha = lerp(noteHoverer.alpha, 0.35, 0.25); addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0, 0.25); var gridmult = 40 / (noteSnap / 16); - if (noteHoverer.id != Math.floor(mousePos.x / 40) % 4) noteHoverer.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : snap(mousePos.y, gridmult) / 40, 0, __endStep-1), Math.floor(mousePos.x / 40) % 4, 0, 0, null); + if (noteHoverer.id != Math.floor(mousePos.x / 40) % 4) noteHoverer.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : snap(mousePos.y, gridmult) / 40, 0, __endStep-1), Math.floor(mousePos.x / 40) % 4, 0, null, null); else { noteHoverer.step = FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : snap(mousePos.y, gridmult) / 40, 0, __endStep-1); noteHoverer.y = noteHoverer.step * 40; @@ -842,7 +859,7 @@ class Charter extends UIState { for(note in strL.notes) { var n = new CharterNote(); var t = Conductor.getStepForTime(note.time); - n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, note.type, cStr); + n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, PlayState.SONG.noteTypes[note.type], cStr); notesGroup.add(n); } createSelection(toBeCreated, false); @@ -1332,8 +1349,9 @@ class Charter extends UIState { public inline function buildNote(note:CharterNote):ChartNote { var time = Conductor.getTimeForStep(note.step); + if (!PlayState.SONG.noteTypes.contains(note.type) && note.type != "Default Note") PlayState.SONG.noteTypes.push(note.type); return { - type: note.type, + type: (PlayState.SONG.noteTypes.contains(note.type) ? PlayState.SONG.noteTypes.indexOf(note.type) + 1 : -1), time: time, sLen: Conductor.getTimeForStep(note.step + note.susLength) - time, id: note.id @@ -1342,6 +1360,7 @@ class Charter extends UIState { public function buildChart() { PlayState.SONG.strumLines = []; + PlayState.SONG.noteTypes = []; for(s in strumLines) { s.strumLine.notes = []; PlayState.SONG.strumLines.push(s.strumLine); @@ -1350,6 +1369,7 @@ class Charter extends UIState { if (PlayState.SONG.strumLines[n.strumLineID] != null) PlayState.SONG.strumLines[n.strumLineID].notes.push(buildNote(n)); } + trace(PlayState.SONG.noteTypes); buildEvents(); } @@ -1391,7 +1411,7 @@ enum CharterChange { } enum CharterCopyboardObject { - CNote(step:Float, id:Int, strumLineID:Int, susLength:Float, type:Int); + CNote(step:Float, id:Int, strumLineID:Int, susLength:Float, type:String); CEvent(step:Float, events:Array); } @@ -1421,6 +1441,39 @@ typedef SelectionDragChange = { } } +class CharterNoteTypeButton extends UIButton { + public var theType:String; + public var textBox:UIAutoCompleteTextBox; + public function new(type:String, parent:UIButtonList, state:Charter, suggestList:Array) { + theType = type; + super(0,0,"" ,function() { + state.curNoteType = theType; + for(i in parent.buttons.members) + i.alpha = i == this ? 1 : 0.25; + },296,30); + if (suggestList != null && suggestList.length > 0) { + members.push(textBox = new UIAutoCompleteTextBox((bWidth - 200) / 2, y + 4, theType, 200, bHeight - 8)); + textBox.suggestItems = suggestList; + textBox.antialiasing = true; + textBox.onChange = function(typer:String) { + if (!chart.noteTypes.contains(typer) && chart.noteTypes.contains(theType)) + chart.noteTypes[chart.noteTypes.indexOf(theType)] = typer; + else if (chart.noteTypes.contains(typer) && chart.noteTypes.contains(theType)) + chart.noteTypes.remove(theType); + else chart.noteTypes.push(typer); + if (state.curNoteType == theType) state.curNoteType = typer; + theType = typer; + } + } + else field.text = type; + autoAlpha = false; + } + override function update(elapsed) { + super.update(elapsed); + if (textBox != null) textBox.y = y + 4; + //x = alpha == 0.25 ? -50 : 10; + } +} interface ICharterSelectable { public var x(default, set):Float; public var y(default, set):Float; diff --git a/source/funkin/editors/charter/CharterNote.hx b/source/funkin/editors/charter/CharterNote.hx index 45125936..9e7c8315 100644 --- a/source/funkin/editors/charter/CharterNote.hx +++ b/source/funkin/editors/charter/CharterNote.hx @@ -18,6 +18,7 @@ class CharterNote extends UISprite implements ICharterSelectable { ]; public var sustainSpr:FlxSprite; + public var noteTypeText:flixel.text.FlxText; var __doAnim:Bool = false; public var selected:Bool = false; @@ -38,6 +39,9 @@ class CharterNote extends UISprite implements ICharterSelectable { sustainSpr = new FlxSprite(10, 40); sustainSpr.makeGraphic(1, 1, -1); members.push(sustainSpr); + + noteTypeText = new flixel.text.FlxText(0, 0, 40, (type == null || type == "Default Note" ? "" : '${PlayState.SONG.noteTypes.indexOf(type)}'), 30); + noteTypeText.alignment = "center"; } public override function updateButtonHandler() { @@ -51,7 +55,7 @@ class CharterNote extends UISprite implements ICharterSelectable { public var step:Float; public var id:Int; public var susLength:Float; - public var type:Int; + public var type:String; public var strumLine:CharterStrumline; public var strumLineID(get, never):Int; @@ -64,11 +68,12 @@ class CharterNote extends UISprite implements ICharterSelectable { public function get_fullID():Int return (strumLineID * 4) + id; - public function updatePos(step:Float, id:Int, susLength:Float = 0, ?type:Int = 0, ?strumLine:CharterStrumline = null) { + public function updatePos(step:Float, id:Int, susLength:Float = 0, ?type:String = null, ?strumLine:CharterStrumline = null) { this.step = step; this.id = id; this.susLength = susLength; this.type = type; + noteTypeText.text = (type == null || type == "Default Note" ? "" : '${PlayState.SONG.noteTypes.indexOf(type)}'); if (strumLine != null) this.strumLine = strumLine; y = step * 40; @@ -123,7 +128,8 @@ class CharterNote extends UISprite implements ICharterSelectable { var __passed:Bool = false; public override function update(elapsed:Float) { super.update(elapsed); - + if(noteTypeText.exists) + noteTypeText.follow(this, 0, 0); if(sustainSpr.exists) sustainSpr.follow(this, 15, 20); @@ -164,5 +170,6 @@ class CharterNote extends UISprite implements ICharterSelectable { drawMembers(); drawSuper(); + if(noteTypeText.text != "") noteTypeText.draw(); } } \ No newline at end of file