actually huge overhaul OOPS lol.

trims off unnecessary data, supports bpm changes proper and according to my proposed system, also just happens to fix other issues with the chart editor
This commit is contained in:
MtH 2021-02-11 23:13:50 +01:00
parent 9b0bc41cc5
commit 404db74fd9
1 changed files with 56 additions and 44 deletions

View File

@ -2,6 +2,7 @@ package;
import Section.SwagSection;
import Song.SwagSong;
import Conductor.BPMChangeEvent;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.addons.display.FlxGridOverlay;
@ -117,11 +118,9 @@ class ChartingState extends MusicBeatState
song: 'Test',
notes: [],
bpm: 150,
sections: 0,
needsVoices: true,
player1: 'bf',
player2: 'dad',
sectionLengths: [],
speed: 1,
validScore: false
};
@ -140,6 +139,7 @@ class ChartingState extends MusicBeatState
loadSong(_song.song);
Conductor.changeBPM(_song.bpm);
Conductor.mapBPMChanges(_song);
bpmTxt = new FlxText(1000, 50, 0, "", 16);
bpmTxt.scrollFactor.set();
@ -366,6 +366,7 @@ class ChartingState extends MusicBeatState
vocals.time = 0;
FlxG.sound.music.pause();
FlxG.sound.music.time = 0;
changeSection();
};
}
@ -425,6 +426,7 @@ class ChartingState extends MusicBeatState
else if (wname == 'song_bpm')
{
tempBpm = Std.int(nums.value);
Conductor.mapBPMChanges(_song);
Conductor.changeBPM(Std.int(nums.value));
}
else if (wname == 'note_susLength')
@ -444,12 +446,27 @@ class ChartingState extends MusicBeatState
var updatedSection:Bool = false;
/* this function got owned LOL
function lengthBpmBullshit():Float
{
if (_song.notes[curSection].changeBPM)
return _song.notes[curSection].lengthInSteps * (_song.notes[curSection].bpm / _song.bpm);
else
return _song.notes[curSection].lengthInSteps;
}*/
function sectionStartTime():Float
{
var daBPM:Int = _song.bpm;
var daPos:Float = 0;
for (i in 0...curSection)
{
if (_song.notes[i].changeBPM) {
daBPM = _song.notes[i].bpm;
}
daPos += 4 * (1000 * 60 / daBPM);
}
return daPos;
}
override function update(elapsed:Float)
@ -459,23 +476,20 @@ class ChartingState extends MusicBeatState
Conductor.songPosition = FlxG.sound.music.time;
_song.song = typingShit.text;
strumLine.y = getYfromStrum(Conductor.songPosition % (Conductor.stepCrochet * lengthBpmBullshit()));
strumLine.y = getYfromStrum((Conductor.songPosition - sectionStartTime()) % (Conductor.stepCrochet * _song.notes[curSection].lengthInSteps));
if (curBeat % 4 == 0)
if (curBeat % 4 == 0 && curStep >= 16 * (curSection + 1))
{
if (curStep > 16 * (curSection + 1))
trace(curStep);
trace((_song.notes[curSection].lengthInSteps) * (curSection + 1));
trace('DUMBSHIT');
if (_song.notes[curSection + 1] == null)
{
trace(curStep);
trace((_song.notes[curSection].lengthInSteps) * (curSection + 1));
trace('DUMBSHIT');
if (_song.notes[curSection + 1] == null)
{
addSection();
}
changeSection(curSection + 1, false);
addSection();
}
changeSection(curSection + 1, false);
}
FlxG.watch.addQuick('daBeat', curBeat);
@ -674,21 +688,18 @@ class ChartingState extends MusicBeatState
function recalculateSteps():Int
{
var steps:Int = 0;
var timeShit:Float = 0;
for (i in 0...curSection)
var lastChange:BPMChangeEvent = {
stepTime: 0,
songTime: 0,
bpm: 0
}
for (i in 0...Conductor.bpmChangeMap.length)
{
steps += 16;
if (_song.notes[i].changeBPM)
timeShit += (((60 / _song.notes[i].bpm) * 1000) / 4) * 16;
else
timeShit += (((60 / _song.bpm) * 1000) / 4) * 16;
if (FlxG.sound.music.time > Conductor.bpmChangeMap[i].songTime)
lastChange = Conductor.bpmChangeMap[i];
}
steps += Math.floor((FlxG.sound.music.time - timeShit) / Conductor.stepCrochet);
curStep = steps;
curStep = lastChange.stepTime + Math.floor((FlxG.sound.music.time - lastChange.songTime) / Conductor.stepCrochet);
updateBeat();
return curStep;
@ -702,7 +713,7 @@ class ChartingState extends MusicBeatState
vocals.pause();
// Basically old shit from changeSection???
FlxG.sound.music.time = lengthBpmBullshit() * Conductor.stepCrochet * curSection;
FlxG.sound.music.time = sectionStartTime();
if (songBeginning)
{
@ -732,15 +743,15 @@ class ChartingState extends MusicBeatState
FlxG.sound.music.pause();
vocals.pause();
var daNum:Int = 0;
/*var daNum:Int = 0;
var daLength:Float = 0;
while (daNum <= sec)
{
daLength += lengthBpmBullshit();
daNum++;
}
}*/
FlxG.sound.music.time = (daLength - lengthBpmBullshit()) * Conductor.stepCrochet;
FlxG.sound.music.time = sectionStartTime();
vocals.time = FlxG.sound.music.time;
updateCurStep();
}
@ -815,10 +826,16 @@ class ChartingState extends MusicBeatState
if (_song.notes[curSection].changeBPM && _song.notes[curSection].bpm > 0)
{
Conductor.changeBPM(_song.notes[curSection].bpm);
FlxG.log.add('CHANGED BPM!');
}
else
{
Conductor.changeBPM(tempBpm);
//get last bpm
var daBPM:Int = _song.bpm;
for (i in 0...curSection)
if (_song.notes[i].changeBPM)
daBPM = _song.notes[i].bpm;
Conductor.changeBPM(daBPM);
}
/* // PORT BULLSHIT, INCASE THERE'S NO SUSTAIN DATA FOR A NOTE
@ -846,7 +863,7 @@ class ChartingState extends MusicBeatState
note.setGraphicSize(GRID_SIZE, GRID_SIZE);
note.updateHitbox();
note.x = Math.floor(daNoteInfo * GRID_SIZE);
note.y = Math.floor(getYfromStrum(daStrumTime)) % gridBG.height;
note.y = Math.floor(getYfromStrum((daStrumTime - sectionStartTime()) % (Conductor.stepCrochet * _song.notes[curSection].lengthInSteps)));
curRenderedNotes.add(note);
@ -925,7 +942,7 @@ class ChartingState extends MusicBeatState
private function addNote():Void
{
var noteStrum = getStrumTime(dummyArrow.y) + (curSection * (Conductor.stepCrochet * 16));
var noteStrum = getStrumTime(dummyArrow.y) + sectionStartTime();
var noteData = Math.floor(FlxG.mouse.x / GRID_SIZE);
var noteSus = 0;
@ -938,7 +955,7 @@ class ChartingState extends MusicBeatState
_song.notes[curSection].sectionNotes.push([noteStrum, (noteData + 4) % 8, noteSus]);
}
trace(getStrumTime(dummyArrow.y) + (curSection * (Conductor.stepCrochet * lengthBpmBullshit())));
trace(noteStrum);
trace(curSection);
updateGrid();
@ -957,6 +974,7 @@ class ChartingState extends MusicBeatState
return FlxMath.remapToRange(strumTime, 0, 16 * Conductor.stepCrochet, gridBG.y, gridBG.y + gridBG.height);
}
/*
function calculateSectionLengths(?sec:SwagSection):Int
{
var daLength:Int = 0;
@ -978,7 +996,7 @@ class ChartingState extends MusicBeatState
}
return daLength;
}
}*/
private var daSpacing:Float = 0.3;
@ -1014,10 +1032,7 @@ class ChartingState extends MusicBeatState
function autosaveSong():Void
{
FlxG.save.data.autosave = Json.stringify({
"song": _song,
"bpm": Conductor.bpm,
"sections": _song.notes.length,
'notes': _song.notes
"song": _song
});
FlxG.save.flush();
}
@ -1025,10 +1040,7 @@ class ChartingState extends MusicBeatState
private function saveLevel()
{
var json = {
"song": _song,
"bpm": Conductor.bpm,
"sections": _song.notes.length,
'notes': _song.notes
"song": _song
};
var data:String = Json.stringify(json);