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