From 931cbab58bf27e25410f45aa2eee675e5a03e23c Mon Sep 17 00:00:00 2001 From: KadeDev Date: Sun, 21 Mar 2021 23:44:22 -0700 Subject: [PATCH] you can like write notes with keybinds --- source/ChartingState.hx | 91 +++++++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 12 deletions(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 0864401..60650f3 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -1,5 +1,7 @@ package; +import flixel.addons.ui.FlxUIText; +import haxe.zip.Writer; import Conductor.BPMChangeEvent; import Section.SwagSection; import Song.SwagSong; @@ -56,7 +58,7 @@ class ChartingState extends MusicBeatState var curSong:String = 'Dadbattle'; var amountSteps:Int = 0; var bullshitUI:FlxGroup; - + var writingNotesText:FlxText; var highlight:FlxSprite; var GRID_SIZE:Int = 40; @@ -215,6 +217,19 @@ class ChartingState extends MusicBeatState loadJson(_song.song.toLowerCase()); }); + + var restart = new FlxButton(10,140,"Reset", function() + { + for (ii in 0..._song.notes.length) + { + for (i in 0..._song.notes[ii].sectionNotes.length) + { + _song.notes[ii].sectionNotes = []; + } + } + resetSection(true); + }); + var loadAutosaveBtn:FlxButton = new FlxButton(reloadSongJson.x, reloadSongJson.y + 30, 'load autosave', loadAutosave); var stepperSpeed:FlxUINumericStepper = new FlxUINumericStepper(10, 80, 0.1, 1, 0.1, 10, 1); @@ -243,7 +258,7 @@ class ChartingState extends MusicBeatState var tab_group_song = new FlxUI(null, UI_box); tab_group_song.name = "Song"; tab_group_song.add(UI_songTitle); - + tab_group_song.add(restart); tab_group_song.add(check_voices); tab_group_song.add(check_mute_inst); tab_group_song.add(saveButton); @@ -326,17 +341,23 @@ class ChartingState extends MusicBeatState var stepperSusLength:FlxUINumericStepper; + var tab_group_note:FlxUI; + function addNoteUI():Void { - var tab_group_note = new FlxUI(null, UI_box); + tab_group_note = new FlxUI(null, UI_box); tab_group_note.name = 'Note'; + writingNotesText = new FlxUIText(20,100, 0, ""); + writingNotesText.setFormat("Arial",20,FlxColor.WHITE,FlxTextAlign.LEFT,FlxTextBorderStyle.OUTLINE,FlxColor.BLACK); + stepperSusLength = new FlxUINumericStepper(10, 10, Conductor.stepCrochet / 2, 0, 0, Conductor.stepCrochet * 16 * 4); stepperSusLength.value = 0; stepperSusLength.name = 'note_susLength'; var applyLength:FlxButton = new FlxButton(100, 10, 'Apply'); + tab_group_note.add(writingNotesText); tab_group_note.add(stepperSusLength); tab_group_note.add(applyLength); @@ -482,13 +503,57 @@ class ChartingState extends MusicBeatState return daPos; } + var writingNotes:Bool = false; + override function update(elapsed:Float) { curStep = recalculateSteps(); + if (FlxG.keys.justPressed.ALT && UI_box.selected_tab == 0) + { + writingNotes = !writingNotes; + } + + if (writingNotes) + writingNotesText.text = "WRITING NOTES"; + else + writingNotesText.text = ""; + Conductor.songPosition = FlxG.sound.music.time; _song.song = typingShit.text; + var upP = controls.UP_P; + var rightP = controls.RIGHT_P; + var downP = controls.DOWN_P; + var leftP = controls.LEFT_P; + + var controlArray:Array = [leftP, downP, upP, rightP]; + + if ((upP || rightP || downP || leftP) && writingNotes) + { + for(i in 0...controlArray.length) + { + if (controlArray[i]) + { + for (n in 0..._song.notes[curSection].sectionNotes.length) + { + var note = _song.notes[curSection].sectionNotes[n]; + if (note == null) + continue; + if (note[0] == Conductor.songPosition && note[1] % 4 == i) + { + trace('GAMING'); + _song.notes[curSection].sectionNotes.remove(note); + } + } + trace('adding note'); + _song.notes[curSection].sectionNotes.push([Conductor.songPosition, i, 0]); + updateGrid(); + } + } + + } + strumLine.y = getYfromStrum((Conductor.songPosition - sectionStartTime()) % (Conductor.stepCrochet * _song.notes[curSection].lengthInSteps)); if (curBeat % 4 == 0 && curStep >= 16 * (curSection + 1)) @@ -591,6 +656,16 @@ class ChartingState extends MusicBeatState if (!typingShit.hasFocus) { + var shiftThing:Int = 1; + if (FlxG.keys.pressed.SHIFT) + shiftThing = 4; + if (!writingNotes) + { + if (FlxG.keys.justPressed.RIGHT || FlxG.keys.justPressed.D) + changeSection(curSection + shiftThing); + if (FlxG.keys.justPressed.LEFT || FlxG.keys.justPressed.A) + changeSection(curSection - shiftThing); + } if (FlxG.keys.justPressed.SPACE) { if (FlxG.sound.music.playing) @@ -669,14 +744,6 @@ class ChartingState extends MusicBeatState if (FlxG.keys.justPressed.DOWN) Conductor.changeBPM(Conductor.bpm - 1); */ - var shiftThing:Int = 1; - if (FlxG.keys.pressed.SHIFT) - shiftThing = 4; - if (FlxG.keys.justPressed.RIGHT || FlxG.keys.justPressed.D) - changeSection(curSection + shiftThing); - if (FlxG.keys.justPressed.LEFT || FlxG.keys.justPressed.A) - changeSection(curSection - shiftThing); - bpmTxt.text = bpmTxt.text = Std.string(FlxMath.roundDecimal(Conductor.songPosition / 1000, 2)) + " / " + Std.string(FlxMath.roundDecimal(FlxG.sound.music.length / 1000, 2)) @@ -944,7 +1011,7 @@ class ChartingState extends MusicBeatState var i = _song.notes[curSection].sectionNotes[n]; if (i == null) continue; - if (i[0] == note.strumTime + 1 && i[1] % 4 == note.noteData) + if (i[0] == note.strumTime + (note.strumTime == 0 ? 0 : 1) && i[1] % 4 == note.noteData) { trace('GAMING'); _song.notes[curSection].sectionNotes.remove(i);