you can like write notes with keybinds

This commit is contained in:
KadeDev 2021-03-21 23:44:22 -07:00
parent 43e12a89bf
commit 931cbab58b

View File

@ -1,5 +1,7 @@
package; package;
import flixel.addons.ui.FlxUIText;
import haxe.zip.Writer;
import Conductor.BPMChangeEvent; import Conductor.BPMChangeEvent;
import Section.SwagSection; import Section.SwagSection;
import Song.SwagSong; import Song.SwagSong;
@ -56,7 +58,7 @@ class ChartingState extends MusicBeatState
var curSong:String = 'Dadbattle'; var curSong:String = 'Dadbattle';
var amountSteps:Int = 0; var amountSteps:Int = 0;
var bullshitUI:FlxGroup; var bullshitUI:FlxGroup;
var writingNotesText:FlxText;
var highlight:FlxSprite; var highlight:FlxSprite;
var GRID_SIZE:Int = 40; var GRID_SIZE:Int = 40;
@ -215,6 +217,19 @@ class ChartingState extends MusicBeatState
loadJson(_song.song.toLowerCase()); 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 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); 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); var tab_group_song = new FlxUI(null, UI_box);
tab_group_song.name = "Song"; tab_group_song.name = "Song";
tab_group_song.add(UI_songTitle); tab_group_song.add(UI_songTitle);
tab_group_song.add(restart);
tab_group_song.add(check_voices); tab_group_song.add(check_voices);
tab_group_song.add(check_mute_inst); tab_group_song.add(check_mute_inst);
tab_group_song.add(saveButton); tab_group_song.add(saveButton);
@ -326,17 +341,23 @@ class ChartingState extends MusicBeatState
var stepperSusLength:FlxUINumericStepper; var stepperSusLength:FlxUINumericStepper;
var tab_group_note:FlxUI;
function addNoteUI():Void 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'; 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 = new FlxUINumericStepper(10, 10, Conductor.stepCrochet / 2, 0, 0, Conductor.stepCrochet * 16 * 4);
stepperSusLength.value = 0; stepperSusLength.value = 0;
stepperSusLength.name = 'note_susLength'; stepperSusLength.name = 'note_susLength';
var applyLength:FlxButton = new FlxButton(100, 10, 'Apply'); var applyLength:FlxButton = new FlxButton(100, 10, 'Apply');
tab_group_note.add(writingNotesText);
tab_group_note.add(stepperSusLength); tab_group_note.add(stepperSusLength);
tab_group_note.add(applyLength); tab_group_note.add(applyLength);
@ -482,13 +503,57 @@ class ChartingState extends MusicBeatState
return daPos; return daPos;
} }
var writingNotes:Bool = false;
override function update(elapsed:Float) override function update(elapsed:Float)
{ {
curStep = recalculateSteps(); 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; Conductor.songPosition = FlxG.sound.music.time;
_song.song = typingShit.text; _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<Bool> = [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)); strumLine.y = getYfromStrum((Conductor.songPosition - sectionStartTime()) % (Conductor.stepCrochet * _song.notes[curSection].lengthInSteps));
if (curBeat % 4 == 0 && curStep >= 16 * (curSection + 1)) if (curBeat % 4 == 0 && curStep >= 16 * (curSection + 1))
@ -591,6 +656,16 @@ class ChartingState extends MusicBeatState
if (!typingShit.hasFocus) 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.keys.justPressed.SPACE)
{ {
if (FlxG.sound.music.playing) if (FlxG.sound.music.playing)
@ -669,14 +744,6 @@ class ChartingState extends MusicBeatState
if (FlxG.keys.justPressed.DOWN) if (FlxG.keys.justPressed.DOWN)
Conductor.changeBPM(Conductor.bpm - 1); */ 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)) bpmTxt.text = bpmTxt.text = Std.string(FlxMath.roundDecimal(Conductor.songPosition / 1000, 2))
+ " / " + " / "
+ Std.string(FlxMath.roundDecimal(FlxG.sound.music.length / 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]; var i = _song.notes[curSection].sectionNotes[n];
if (i == null) if (i == null)
continue; 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'); trace('GAMING');
_song.notes[curSection].sectionNotes.remove(i); _song.notes[curSection].sectionNotes.remove(i);