From daac5c83c8398579a50a37ba49555b54efbd1fb7 Mon Sep 17 00:00:00 2001 From: JordanSantiagoYT Date: Sun, 29 Oct 2023 15:15:41 -0400 Subject: [PATCH] YAAAA removed chart drawing, ez spam is much better ez spam can now use decimal numbers added the ability to undo in the chart editor by pressing CTRL + Z if you're on PC and V on the virtual pad if you're on android --- source/Main.hx | 8 +-- source/Song.hx | 2 +- source/editors/ChartingState.hx | 100 +++++++++++++++++++------------- 3 files changed, 64 insertions(+), 46 deletions(-) diff --git a/source/Main.hx b/source/Main.hx index f81ae00c326..fb1e350be47 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -214,9 +214,9 @@ class Main extends Sprite { } } - errorMessage += "\nUncaught Error: " - + e.error - + "\nPlease don't report this error to the GitHub page\n\n> Crash Handler written by: sqirra-rng"; + errorMessage += "\nUncaught Error: " + + e.error + + "\nPlease report this error to the GitHub page: https://github.com/JordanSantiagoYT/FNF-PsychEngine-NoBotplayLag\n\n> Crash Handler written by: sqirra-rng"; if (!FileSystem.exists(SUtil.getPath() + "crash/")) FileSystem.createDirectory(SUtil.getPath() + "crash/"); @@ -226,7 +226,7 @@ class Main extends Sprite { Sys.println(errorMessage); Sys.println("Crash dump saved in " + Path.normalize(path)); - Application.current.window.alert("Error! JS Engine v" + MainMenuState.psychEngineJSVersion + " (" + Main.__superCoolErrorMessagesArray[FlxG.random.int(0, Main.__superCoolErrorMessagesArray.length)] + ")", errorMessage); + Application.current.window.alert(errorMessage, "Error! JS Engine v" + MainMenuState.psychEngineJSVersion + " (" + Main.__superCoolErrorMessagesArray[FlxG.random.int(0, Main.__superCoolErrorMessagesArray.length)] + ")"); #if desktop DiscordClient.shutdown(); #end diff --git a/source/Song.hx b/source/Song.hx index 9d7ca5f1ae6..1c1d5c098a6 100644 --- a/source/Song.hx +++ b/source/Song.hx @@ -49,6 +49,7 @@ class Song public var songCredit:String; public var event7:String; public var event7Value:String; + public var validScore:Bool = true; public var player1:String = 'bf'; public var player2:String = 'dad'; public var gfVersion:String = 'gf'; @@ -146,7 +147,6 @@ class Song public static function parseJSONshit(rawJson:String):SwagSong { var swagShit:SwagSong = cast Json.parse(rawJson).song; - swagShit.validScore = true; return swagShit; } } diff --git a/source/editors/ChartingState.hx b/source/editors/ChartingState.hx index 53c27b479f7..b903be47fd0 100644 --- a/source/editors/ChartingState.hx +++ b/source/editors/ChartingState.hx @@ -53,7 +53,7 @@ import openfl.media.Sound; import openfl.net.FileReference; import openfl.utils.Assets as OpenFlAssets; import openfl.utils.ByteArray; - +import openfl.events.UncaughtErrorEvent; using StringTools; #if sys import flash.media.Sound; @@ -79,8 +79,8 @@ class ChartingState extends MusicBeatState private var noteTypeIntMap:Map = new Map(); private var noteTypeMap:Map> = new Map>(); public var ignoreWarnings = false; - var undos = []; - var redos = []; + public var undos = []; + public var redos = []; var eventStuff:Array = [ ['', "Nothing. Yep, that's right."], @@ -235,6 +235,8 @@ class ChartingState extends MusicBeatState public var mouseQuant:Bool = false; override function create() { + undos = []; + redos = []; if (PlayState.SONG != null) _song = PlayState.SONG; else @@ -420,7 +422,7 @@ class ChartingState extends MusicBeatState \nHold Alt and click on a note to change it to the selected note type \nHold CTRL and use the Mouse Wheel to decrease/increase the note's sustain length \nZ/X - Zoom in/out - \nC - Draw your charts! Easier charting for your Bambi fansongs lmao + \nCTRL + Z - Undo \n \n(Hold) CTRL + Left/Right - Shift the currently selected note \nEsc - Test your chart inside Chart Editor @@ -1277,11 +1279,11 @@ class ChartingState extends MusicBeatState check_stackActive = new FlxUICheckBox(10, 10, null, null, "Enable EZ Spam Mode", 100); check_stackActive.name = 'check_stackActive'; - stepperStackNum = new FlxUINumericStepper(10, 30, 1, 1, 0, 999999); + stepperStackNum = new FlxUINumericStepper(10, 30, 1, 1, 0, 999999, 4); stepperStackNum.name = 'stack_count'; blockPressWhileTypingOnStepper.push(stepperStackNum); - stepperStackOffset = new FlxUINumericStepper(10, 50, 1, 1, 0, 8192); + stepperStackOffset = new FlxUINumericStepper(10, 50, 1, 1, 0, 8192, 4); stepperStackOffset.name = 'stack_offset'; blockPressWhileTypingOnStepper.push(stepperStackOffset); @@ -1959,6 +1961,7 @@ class ChartingState extends MusicBeatState if (touch.justReleased) { if (touch.overlaps(curRenderedNotes)) { + saveUndo(_song); curRenderedNotes.forEachAlive(function(note:Note) { if (touch.overlaps(note)) { // trace('tryin to delete note...'); @@ -1972,11 +1975,12 @@ class ChartingState extends MusicBeatState && touch.x < gridBG.x + gridBG.width && touch.y > gridBG.y && touch.y < gridBG.y + (GRID_SIZE * getSectionBeats() * 4) * zoomList[curZoom]) { + saveUndo(_song); FlxG.log.add('added note'); addNote(); - var addCount:Int = 0; + var addCount:Float = 0; if (check_stackActive.checked) { - addCount = (Math.floor(stepperStackNum.value)) * Math.floor(stepperStackOffset.value) - 1; + addCount = stepperStackNum.value * stepperStackOffset.value - 1; } // var funnySnap:Float = ((GRID_SIZE * getSectionBeats() * 4 * zoomList[curZoom]) + Conductor.stepCrochet / stepperStackOffset.value); for(i in 0...Std.int(addCount)) { @@ -2011,6 +2015,7 @@ class ChartingState extends MusicBeatState { if (FlxG.mouse.overlaps(curRenderedNotes)) { + if (!FlxG.keys.pressed.CONTROL || !FlxG.keys.pressed.ALT) saveUndo(_song); curRenderedNotes.forEachAlive(function(note:Note) { if (FlxG.mouse.overlaps(note)) @@ -2041,16 +2046,18 @@ class ChartingState extends MusicBeatState && FlxG.mouse.y > gridBG.y && FlxG.mouse.y < gridBG.y + (GRID_SIZE * getSectionBeats() * 4) * zoomList[curZoom]) { + saveUndo(_song); FlxG.log.add('added note'); addNote(); - var addCount:Int = 0; + var addCount:Float = 0; if (check_stackActive.checked) { - addCount = (Math.floor(stepperStackNum.value)) * Math.floor(stepperStackOffset.value) - 1; + addCount = stepperStackNum.value * stepperStackOffset.value - 1; } // var funnySnap:Float = ((GRID_SIZE * getSectionBeats() * 4 * zoomList[curZoom]) + Conductor.stepCrochet / stepperStackOffset.value); for(i in 0...Std.int(addCount)) { addNote(curSelectedNote[0] + (_song.notes[curSec].changeBPM ? 15000/_song.notes[curSec].bpm : 15000/_song.bpm)/stepperStackOffset.value, curSelectedNote[1] + Math.floor(stepperStackSideOffset.value), currentType); } + updateGrid(false); updateNoteUI(); } @@ -2148,13 +2155,21 @@ class ChartingState extends MusicBeatState return; } - if(FlxG.keys.justPressed.Z #if android || virtualPad.buttonZ.justPressed #end && FlxG.keys.pressed.CONTROL) { + if (FlxG.keys.pressed.CONTROL) + { + if (FlxG.keys.justPressed.Z) + undo(); + } + + #if android + if (virtualPad.buttonV.justPressed) { undo(); } + #end - if(FlxG.keys.justPressed.Z #if android || virtualPad.buttonZ.justPressed #end && curZoom > 0 && !FlxG.keys.pressed.CONTROL) { + if(FlxG.keys.justPressed.Z && curZoom > 0 && !FlxG.keys.pressed.CONTROL #if android || virtualPad.buttonZ.justPressed && curZoom > 0 #end) { --curZoom; updateZoom(); updateGrid(); @@ -2165,19 +2180,6 @@ class ChartingState extends MusicBeatState updateGrid(); } - if (FlxG.keys.pressed.C && !FlxG.keys.pressed.CONTROL) - { - if (!FlxG.mouse.overlaps(curRenderedNotes)) //lmao cant place notes when your cursor already overlaps one - if (FlxG.mouse.x > gridBG.x - && FlxG.mouse.x < gridBG.x + gridBG.width - && FlxG.mouse.y > gridBG.y - && FlxG.mouse.y < gridBG.y + gridBG.height) - if (!FlxG.keys.pressed.CONTROL) //stop crashing - addNote(); //allows you to draw notes by holding left click - updateGrid(false); - updateNoteUI(); - } - if (FlxG.keys.justPressed.TAB) { if (FlxG.keys.pressed.SHIFT) @@ -2226,7 +2228,7 @@ class ChartingState extends MusicBeatState } if (FlxG.keys.pressed.CONTROL) { - if (FlxG.keys.pressed.RIGHT) + if (FlxG.keys.justPressed.RIGHT) if (curSelectedNote != null && curSelectedNote[1] > -1 && curSelectedNote[2] != null) { if (curSelectedNote[1] < 6 + 1) { curSelectedNote[1] += 1; @@ -2235,7 +2237,7 @@ class ChartingState extends MusicBeatState } updateGrid(false); } - if (FlxG.keys.pressed.LEFT) + if (FlxG.keys.justPressed.LEFT) if (curSelectedNote != null && curSelectedNote[1] > -1 && curSelectedNote[2] != null) { if (curSelectedNote[1] > 0) { curSelectedNote[1] -= 1; @@ -3382,6 +3384,7 @@ class ChartingState extends MusicBeatState if (note.overlapsPoint(new FlxPoint(strumLineNotes.members[d].x + 1,strumLine.y+1)) && note.noteData == d%4) { //trace('tryin to delete note...'); + saveUndo(_song); if(!delnote) deleteNote(note); delnote = true; } @@ -3389,6 +3392,7 @@ class ChartingState extends MusicBeatState } if (!delnote){ + saveUndo(_song); addNote(cs, d, style); } } @@ -3404,9 +3408,6 @@ class ChartingState extends MusicBeatState private function addNote(strum:Null = null, data:Null = null, type:Null = null, ?gridUpdate:Bool = true):Void { - //curUndoIndex++; - //var newsong = _song.notes; - // undos.push(newsong); var noteStrum = getStrumTime(dummyArrow.y * (getSectionBeats() / 4), false) + sectionStartTime(); var noteData = 0; //initialize this so github doesnt complain about this not being initialized yet #if android @@ -3460,15 +3461,6 @@ class ChartingState extends MusicBeatState //_song = redos[curRedoIndex]; } - function undo() - { - //redos.push(_song); - undos.pop(); - //_song.notes = undos[undos.length - 1]; - ///trace(_song.notes); - //updateGrid(); - } - function getStrumTime(yPos:Float, doZoomCalc:Bool = true):Float { var leZoom:Float = zoomList[curZoom]; @@ -3489,6 +3481,32 @@ class ChartingState extends MusicBeatState return GRID_SIZE * beats * 4 * zoomList[curZoom] * value + gridBG.y; } + public function saveUndo(_song:SwagSong) + { + var shit = Json.stringify({ //doin this so it doesnt act as a reference + "song": _song + }); + var song:SwagSong = Song.parseJSONshit(shit); + + undos.unshift(song.notes); + redos = []; //Reset redos + if (undos.length >= 100) //if you save more than 100 times, remove the oldest undo + undos.remove(undos[100]); + } + + public function undo() + { + if (undos.length > 0) { + _song.notes = undos[0]; + redos.unshift(undos[0]); + undos.splice(0, 1); + trace("Performed an Undo! Undos remaining: " + undos.length); + updateGrid(); + } else { + trace ("Hold on there! You can't undo if there's nothing to undo yet!"); + } + } + function getNotes():Array { var noteData:Array = []; @@ -3516,8 +3534,8 @@ class ChartingState extends MusicBeatState } MusicBeatState.resetState(); } - - function autosaveSong():Void + + public function autosaveSong():Void { FlxG.save.data.autosave = Json.stringify({ "song": _song