a lot of little fixes and alt animation per notes

This commit is contained in:
KadeDeveloper 2021-08-12 19:07:36 -07:00
parent 63ac4ec3d8
commit e09957267c
8 changed files with 152 additions and 89 deletions

View File

@ -4,6 +4,7 @@ import flixel.FlxSprite;
class ChartingBox extends FlxSprite
{
public var connectedNote:Note;
public var connectedNoteData:Array<Dynamic>;
public function new(x,y, originalNote:Note)
{

View File

@ -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<Dynamic> = [strum, note[1], note[2]];
var copiedNote:Array<Dynamic> = [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;

View File

@ -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;

View File

@ -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<Note> = [];
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;

View File

@ -423,23 +423,16 @@ class PlayState extends MusicBeatState
TimingStruct.clearTimings();
var convertedStuff:Array<Song.Event> = [];
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)
{

View File

@ -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());

View File

@ -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<Song.Event> = [];
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;

View File

@ -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)