From e09957267c32553770d4644a77b51688b915719e Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Thu, 12 Aug 2021 19:07:36 -0700 Subject: [PATCH 1/3] a lot of little fixes and alt animation per notes --- source/ChartingBox.hx | 1 + source/ChartingState.hx | 116 ++++++++++++++++++++++++--------------- source/FreeplayState.hx | 3 +- source/Note.hx | 6 +- source/PlayState.hx | 53 ++++-------------- source/ResultsScreen.hx | 4 +- source/Song.hx | 56 +++++++++++++++++++ source/StoryMenuState.hx | 2 +- 8 files changed, 152 insertions(+), 89 deletions(-) diff --git a/source/ChartingBox.hx b/source/ChartingBox.hx index 905a3f9..e9d933b 100644 --- a/source/ChartingBox.hx +++ b/source/ChartingBox.hx @@ -4,6 +4,7 @@ import flixel.FlxSprite; class ChartingBox extends FlxSprite { public var connectedNote:Note; + public var connectedNoteData:Array; public function new(x,y, originalNote:Note) { diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 0f7b7f5..2c6f9af 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -1326,6 +1326,8 @@ class ChartingState extends MusicBeatState FlxG.sound.music.time = FlxG.sound.music.length; } + public var check_naltAnim:FlxUICheckBox; + function addNoteUI():Void { tab_group_note = new FlxUI(null, UI_box); @@ -1338,6 +1340,25 @@ class ChartingState extends MusicBeatState stepperSusLength.value = 0; stepperSusLength.name = 'note_susLength'; + check_naltAnim = new FlxUICheckBox(10, 150, null, null, "Toggle Alternative Animation", 100); + check_naltAnim.callback = function() + { + if (curSelectedNote != null) + { + for(i in selectedBoxes) + { + i.connectedNoteData[3] = check_naltAnim.checked; + + for(ii in _song.notes) + { + for(n in ii.sectionNotes) + if (n[0] == i.connectedNoteData[0] && n[1] == i.connectedNoteData[1]) + n[3] = i.connectedNoteData[3]; + } + } + } + } + var stepperSusLengthLabel = new FlxText(74,10,'Note Sustain Length'); var applyLength:FlxButton = new FlxButton(10, 100, 'Apply Data'); @@ -1345,6 +1366,7 @@ class ChartingState extends MusicBeatState tab_group_note.add(stepperSusLength); tab_group_note.add(stepperSusLengthLabel); tab_group_note.add(applyLength); + tab_group_note.add(check_naltAnim); UI_box.addGroup(tab_group_note); @@ -1379,6 +1401,8 @@ class ChartingState extends MusicBeatState var newData = [strum,i[1],i[2]]; ii.sectionNotes.push(newData); + var thing = ii.sectionNotes[ii.sectionNotes.length - 1]; + var note:Note = new Note(strum, Math.floor(i[1] % 4),null,false,true); note.rawNoteData = i[1]; note.sustainLength = i[2]; @@ -1392,6 +1416,7 @@ class ChartingState extends MusicBeatState note.y = Math.floor(getYfromStrum(strum) * zoomFactor); var box = new ChartingBox(note.x,note.y,note); + box.connectedNoteData = thing; selectedBoxes.add(box); curRenderedNotes.add(note); @@ -1666,27 +1691,10 @@ class ChartingState extends MusicBeatState } } - for(i in shownNotes) + for(ii in selectedBoxes.members) { - if (i.charterSelected) - { - var movedBox = false; - for(ii in selectedBoxes.members) - { - if (ii.connectedNote.strumTime == i.strumTime && ii.connectedNote.noteData == i.noteData) - { - movedBox = true; - ii.x = i.x; - ii.y = i.y; - } - } - - if (!movedBox) - { - var box = new ChartingBox(i.x,i.y,i); - selectedBoxes.add(box); - } - } + ii.x = ii.connectedNote.x; + ii.y = ii.connectedNote.y; } var doInput = true; @@ -1814,13 +1822,19 @@ class ChartingState extends MusicBeatState { trace("released!"); waitingForRelease = false; - for(i in shownNotes) + + while(selectedBoxes.members.length != 0 && selectBox.width > 10 && selectBox.height > 10) + { + selectedBoxes.members[0].connectedNote.charterSelected = false; + selectedBoxes.members[0].destroy(); + selectedBoxes.members.remove(selectedBoxes.members[0]); + } + + for(i in curRenderedNotes) { if (i.overlaps(selectBox) && !i.charterSelected) { - i.charterSelected = true; - var box = new ChartingBox(i.x,i.y,i); - selectedBoxes.add(box); + selectNote(i, false); } } selectBox.destroy(); @@ -1831,6 +1845,7 @@ class ChartingState extends MusicBeatState { lastAction = "delete"; var notesToBeDeleted = []; + deletedNotes = []; for(i in 0...selectedBoxes.members.length) { deletedNotes.push([selectedBoxes.members[i].connectedNote.strumTime,selectedBoxes.members[i].connectedNote.rawNoteData,selectedBoxes.members[i].connectedNote.sustainLength]); @@ -1847,6 +1862,7 @@ class ChartingState extends MusicBeatState { lastAction = "delete"; var notesToBeDeleted = []; + deletedNotes = []; for(i in 0...selectedBoxes.members.length) { deletedNotes.push([selectedBoxes.members[i].connectedNote.strumTime,selectedBoxes.members[i].connectedNote.rawNoteData,selectedBoxes.members[i].connectedNote.sustainLength]); @@ -1867,7 +1883,7 @@ class ChartingState extends MusicBeatState { copiedNotes = []; for(i in selectedBoxes.members) - copiedNotes.push([i.connectedNote.strumTime,i.connectedNote.rawNoteData,i.connectedNote.sustainLength]); + copiedNotes.push([i.connectedNote.strumTime,i.connectedNote.rawNoteData,i.connectedNote.sustainLength,i.connectedNote.isAlt]); var firstNote = copiedNotes[0][0]; @@ -2522,7 +2538,7 @@ class ChartingState extends MusicBeatState { var strum = note[0] + Conductor.stepCrochet * (_song.notes[daSec].lengthInSteps * sectionNum); - var copiedNote:Array = [strum, note[1], note[2]]; + var copiedNote:Array = [strum, note[1], note[2],note[3]]; sect.sectionNotes.push(copiedNote); } @@ -2565,6 +2581,13 @@ class ChartingState extends MusicBeatState if (curSelectedNote != null) { stepperSusLength.value = curSelectedNote[2]; + if (curSelectedNote[3] != null) + check_naltAnim.checked = curSelectedNote[3]; + else + { + curSelectedNote[3] = false; + check_naltAnim.checked = false; + } } } @@ -2605,7 +2628,7 @@ class ChartingState extends MusicBeatState var daStrumTime = i[0]; var daSus = i[2]; - var note:Note = new Note(daStrumTime, daNoteInfo % 4,null,false,true); + var note:Note = new Note(daStrumTime, daNoteInfo % 4,null,false,true,i[3]); note.rawNoteData = daNoteInfo; note.sustainLength = daSus; note.setGraphicSize(Math.floor(GRID_SIZE), Math.floor(GRID_SIZE)); @@ -2669,10 +2692,19 @@ class ChartingState extends MusicBeatState _song.notes.push(sec); } - function selectNote(note:Note):Void + function selectNote(note:Note, ?deleteAllBoxes:Bool = true):Void { var swagNum:Int = 0; + + if (deleteAllBoxes) + while(selectedBoxes.members.length != 0) + { + selectedBoxes.members[0].connectedNote.charterSelected = false; + selectedBoxes.members[0].destroy(); + selectedBoxes.members.remove(selectedBoxes.members[0]); + } + for (i in getSectionByTime(note.strumTime).sectionNotes) { if (i[0] == note.strumTime && i[1] == note.rawNoteData) @@ -2680,25 +2712,21 @@ class ChartingState extends MusicBeatState curSelectedNote = getSectionByTime(note.strumTime).sectionNotes[swagNum]; if (curSelectedNoteObject != null) curSelectedNoteObject.charterSelected = false; - curSelectedNoteObject = note; - - while(selectedBoxes.members.length != 0) - { - selectedBoxes.members[0].connectedNote.charterSelected = false; - selectedBoxes.members[0].destroy(); - selectedBoxes.members.remove(selectedBoxes.members[0]); - } - - var box = new ChartingBox(note.x,note.y,note); - selectedBoxes.add(box); - curSelectedNoteObject.charterSelected = true; + curSelectedNoteObject = note; + if (!note.charterSelected) + { + var box = new ChartingBox(note.x,note.y,note); + box.connectedNoteData = i; + selectedBoxes.add(box); + curSelectedNoteObject.charterSelected = true; + } + } swagNum += 1; } - updateGrid(); updateNoteUI(); } @@ -2955,9 +2983,9 @@ class ChartingState extends MusicBeatState var noteSus = 0; if (n != null) - section.sectionNotes.push([n.strumTime, n.noteData, n.sustainLength]); + section.sectionNotes.push([n.strumTime, n.noteData, n.sustainLength, false]); else - section.sectionNotes.push([noteStrum, noteData, noteSus]); + section.sectionNotes.push([noteStrum, noteData, noteSus, false]); var thingy = section.sectionNotes[section.sectionNotes.length - 1]; @@ -2990,6 +3018,7 @@ class ChartingState extends MusicBeatState note.y = Math.floor(getYfromStrum(noteStrum) * zoomFactor); var box = new ChartingBox(note.x,note.y,note); + box.connectedNoteData = thingy; selectedBoxes.add(box); curRenderedNotes.add(note); @@ -3015,6 +3044,7 @@ class ChartingState extends MusicBeatState } var box = new ChartingBox(note.x,note.y,note); + box.connectedNoteData = thingy; selectedBoxes.add(box); curSelectedNoteObject.charterSelected = true; diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index 93b0fdf..5148bf2 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -379,7 +379,8 @@ class FreeplayState extends MusicBeatState } - PlayState.SONG = hmm; + + PlayState.SONG = Song.conversionChecks(hmm); PlayState.isStoryMode = false; PlayState.storyDifficulty = curDifficulty; PlayState.storyWeek = songs[curSelected].week; diff --git a/source/Note.hx b/source/Note.hx index b642de9..659a7d6 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -35,6 +35,8 @@ class Note extends FlxSprite public var originColor:Int = 0; // The sustain note's original note's color public var noteSection:Int = 0; + public var isAlt:Bool = false; + public var noteCharterObject:FlxSprite; public var noteScore:Float = 1; @@ -63,13 +65,15 @@ class Note extends FlxSprite public var children:Array = []; - public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false, ?inCharter:Bool = false) + public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false, ?inCharter:Bool = false, ?isAlt:Bool = false) { super(); if (prevNote == null) prevNote = this; + this.isAlt = isAlt; + this.prevNote = prevNote; isSustainNote = sustainNote; diff --git a/source/PlayState.hx b/source/PlayState.hx index a7f8760..a823847 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -423,23 +423,16 @@ class PlayState extends MusicBeatState TimingStruct.clearTimings(); - var convertedStuff:Array = []; - var currentIndex = 0; for (i in SONG.eventObjects) { - var name = Reflect.field(i,"name"); - var type = Reflect.field(i,"type"); - var pos = Reflect.field(i,"position"); - var value = Reflect.field(i,"value"); - - if (type == "BPM Change") + if (i.type == "BPM Change") { - var beat:Float = pos; + var beat:Float = i.position; var endBeat:Float = Math.POSITIVE_INFINITY; - TimingStruct.addTiming(beat,value,endBeat, 0); // offset in this case = start time since we don't have a offset + TimingStruct.addTiming(beat,i.value,endBeat, 0); // offset in this case = start time since we don't have a offset if (currentIndex != 0) { @@ -451,39 +444,8 @@ class PlayState extends MusicBeatState currentIndex++; } - convertedStuff.push(new Song.Event(name,pos,value,type)); } - SONG.eventObjects = convertedStuff; - - var ba = SONG.bpm; - - var index = 0; - - trace("conversion stuff " + SONG.song + " " + SONG.notes.length); - - for(i in SONG.notes) - { - var currentBeat = 4 * index; - - var currentSeg = TimingStruct.getTimingAtBeat(currentBeat); - - if (currentSeg == null) - continue; - - var beat:Float = currentSeg.startBeat + (currentBeat - currentSeg.startBeat); - - if (i.changeBPM && i.bpm != ba) - { - trace("converting changebpm for section " + index); - ba = i.bpm; - SONG.eventObjects.push(new Song.Event("FNF BPM Change " + index,beat,i.bpm,"BPM Change")); - } - - index++; - } - - trace('INFORMATION ABOUT WHAT U PLAYIN WIT:\nFRAMES: ' + PlayStateChangeables.safeFrames + '\nZONE: ' + Conductor.safeZoneOffset + '\nTS: ' + Conductor.timeScale + '\nBotPlay : ' + PlayStateChangeables.botPlay); @@ -1939,6 +1901,8 @@ class PlayState extends MusicBeatState susLength = susLength / Conductor.stepCrochet; unspawnNotes.push(swagNote); + swagNote.isAlt = songNotes[3]; + if (susLength > 0) swagNote.isParent = true; @@ -1951,6 +1915,7 @@ class PlayState extends MusicBeatState var sustainNote:Note = new Note(daStrumTime + (Conductor.stepCrochet * susNote) + Conductor.stepCrochet, daNoteData, oldNote, true); sustainNote.scrollFactor.set(); unspawnNotes.push(sustainNote); + sustainNote.isAlt = songNotes[3]; sustainNote.mustPress = gottaHitNote; @@ -3080,6 +3045,12 @@ class PlayState extends MusicBeatState altAnim = '-alt'; } + if (daNote.isAlt) + { + altAnim = '-alt'; + trace("YOO WTF THIS IS AN ALT NOTE????"); + } + // Accessing the animation name directly to play it if (!daNote.isParent && daNote.parent != null) { diff --git a/source/ResultsScreen.hx b/source/ResultsScreen.hx index 5e39fce..7c7920a 100644 --- a/source/ResultsScreen.hx +++ b/source/ResultsScreen.hx @@ -282,9 +282,9 @@ class ResultsScreen extends FlxSubState music.fadeOut(0.3); if (PlayState.isSM) - PlayState.SONG = Song.loadFromJsonRAW(poop); + PlayState.SONG = Song.conversionChecks(Song.loadFromJsonRAW(poop)); else - PlayState.SONG = Song.loadFromJson(poop, PlayState.rep.replay.songName); + PlayState.SONG = Song.conversionChecks(Song.loadFromJson(poop, PlayState.rep.replay.songName)); PlayState.isStoryMode = false; PlayState.storyDifficulty = PlayState.rep.replay.songDiff; LoadingState.loadAndSwitchState(new PlayState()); diff --git a/source/Song.hx b/source/Song.hx index e86f9f0..36cd923 100644 --- a/source/Song.hx +++ b/source/Song.hx @@ -113,6 +113,62 @@ class Song return parseJSONshit(rawJson); } + public static function conversionChecks(song:SwagSong):SwagSong + { + var ba = song.bpm; + + var index = 0; + trace("conversion stuff " + song.song + " " + song.notes.length); + var convertedStuff:Array = []; + + + if (song.eventObjects == null) + song.eventObjects = []; + + + for(i in song.eventObjects) + { + var name = Reflect.field(i,"name"); + var type = Reflect.field(i,"type"); + var pos = Reflect.field(i,"position"); + var value = Reflect.field(i,"value"); + + convertedStuff.push(new Song.Event(name,pos,value,type)); + } + + song.eventObjects = convertedStuff; + + for(i in song.notes) + { + var currentBeat = 4 * index; + + var currentSeg = TimingStruct.getTimingAtBeat(currentBeat); + + if (currentSeg == null) + continue; + + var beat:Float = currentSeg.startBeat + (currentBeat - currentSeg.startBeat); + + if (i.changeBPM && i.bpm != ba) + { + trace("converting changebpm for section " + index); + ba = i.bpm; + song.eventObjects.push(new Song.Event("FNF BPM Change " + index,beat,i.bpm,"BPM Change")); + } + + for(ii in i.sectionNotes) + { + if (ii[3] == null) + ii[3] = false; + } + + index++; + } + + return song; + + } + public static function parseJSONshit(rawJson:String):SwagSong { var swagShit:SwagSong = cast Json.parse(rawJson).song; diff --git a/source/StoryMenuState.hx b/source/StoryMenuState.hx index b2bcce0..e046ed6 100644 --- a/source/StoryMenuState.hx +++ b/source/StoryMenuState.hx @@ -369,7 +369,7 @@ class StoryMenuState extends MusicBeatState PlayState.shits = 0; PlayState.goods = 0; PlayState.campaignMisses = 0; - PlayState.SONG = Song.loadFromJson(poop, PlayState.storyPlaylist[0]); + PlayState.SONG = Song.conversionChecks(Song.loadFromJson(poop, PlayState.storyPlaylist[0])); PlayState.storyWeek = curWeek; PlayState.campaignScore = 0; new FlxTimer().start(1, function(tmr:FlxTimer) From b2fef2db49f45ae9d05d3b0265b83bf8ddeb01f8 Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 02:12:21 -0700 Subject: [PATCH 2/3] fix steps reseting in gameplay --- source/MusicBeatState.hx | 2 ++ source/PlayState.hx | 56 ++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/source/MusicBeatState.hx b/source/MusicBeatState.hx index 202f5ba..47dac29 100644 --- a/source/MusicBeatState.hx +++ b/source/MusicBeatState.hx @@ -101,6 +101,7 @@ class MusicBeatState extends FlxUIState } else if (ste < curStep) { + trace("reset steps for some reason?? at " + Conductor.songPosition); //Song reset? curStep = ste; updateBeat(); @@ -126,6 +127,7 @@ class MusicBeatState extends FlxUIState else if (nextStep < curStep) { //Song reset? + trace("(no bpm change) reset steps for some reason?? at " + Conductor.songPosition); curStep = nextStep; updateBeat(); stepHit(); diff --git a/source/PlayState.hx b/source/PlayState.hx index a823847..fc424da 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2226,36 +2226,42 @@ class PlayState extends MusicBeatState } } - if (updateFrame == 4) - { - TimingStruct.clearTimings(); - - var currentIndex = 0; - for (i in SONG.eventObjects) - { - if (i.type == "BPM Change") + if (updateFrame == 4) + { + TimingStruct.clearTimings(); + + var currentIndex = 0; + for (i in SONG.eventObjects) { - var beat:Float = i.position; - - var endBeat:Float = Math.POSITIVE_INFINITY; - - TimingStruct.addTiming(beat,i.value,endBeat, 0); // offset in this case = start time since we don't have a offset - - if (currentIndex != 0) + if (i.type == "BPM Change") { - var data = TimingStruct.AllTimings[currentIndex - 1]; - data.endBeat = beat; - data.length = (data.endBeat - data.startBeat) / (data.bpm / 60); - TimingStruct.AllTimings[currentIndex].startTime = data.startTime + data.length; + var beat:Float = i.position; + + var endBeat:Float = Math.POSITIVE_INFINITY; + + TimingStruct.addTiming(beat,i.value,endBeat, 0); // offset in this case = start time since we don't have a offset + + if (currentIndex != 0) + { + var data = TimingStruct.AllTimings[currentIndex - 1]; + data.endBeat = beat; + data.length = (data.endBeat - data.startBeat) / (data.bpm / 60); + var step = ((60 / data.bpm) * 1000) / 4; + TimingStruct.AllTimings[currentIndex].startStep = Math.floor(((data.endBeat / (data.bpm / 60)) * 1000) / step); + TimingStruct.AllTimings[currentIndex].startTime = data.startTime + data.length; + } + + currentIndex++; } - - currentIndex++; } - } + + recalculateAllSectionTimes(); + + regenerateLines(); + updateFrame++; + } + else if (updateFrame != 5) updateFrame++; - } - else if (updateFrame != 5) - updateFrame++; var timingSeg = TimingStruct.getTimingAtTimestamp(Conductor.songPosition); From 5f8ca9beb4247f1bd6b4599575730c8b22d7e203 Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 02:12:40 -0700 Subject: [PATCH 3/3] oops don't add this lol --- source/PlayState.hx | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index fc424da..3de8d13 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2255,9 +2255,6 @@ class PlayState extends MusicBeatState } } - recalculateAllSectionTimes(); - - regenerateLines(); updateFrame++; } else if (updateFrame != 5)