new chart system implementation progress
This commit is contained in:
@@ -6,17 +6,23 @@ import openfl.utils.Assets;
|
||||
|
||||
class Chart {
|
||||
public static function parse(songName:String, difficulty:String = "normal"):ChartData {
|
||||
var chartPath = Paths.chart(songName, difficulty);
|
||||
var base:ChartData = {
|
||||
strumLines: [],
|
||||
noteTypes: [],
|
||||
events: [],
|
||||
meta: {
|
||||
name: songName,
|
||||
bpm: 0
|
||||
bpm: 0,
|
||||
beatsPerMesure: 4,
|
||||
stepsPerBeat: 4
|
||||
},
|
||||
scrollSpeed: 2,
|
||||
stage: "stage",
|
||||
codenameChart: true
|
||||
codenameChart: true,
|
||||
fromMods: Paths.assetsTree.existsSpecific(chartPath, "TEXT", MODS)
|
||||
};
|
||||
var chartPath = Paths.chart(songName, difficulty);
|
||||
|
||||
if (!Assets.exists(chartPath)) {
|
||||
Logs.trace('Chart for song ${songName} ($difficulty) at "$chartPath" was not found.', ERROR, RED);
|
||||
return base;
|
||||
@@ -39,6 +45,7 @@ class Chart {
|
||||
data = field;
|
||||
}
|
||||
|
||||
base.scrollSpeed = data.speed;
|
||||
base.stage = data.stage;
|
||||
base.meta.name = data.song;
|
||||
base.meta.bpm = data.bpm;
|
||||
@@ -46,13 +53,25 @@ class Chart {
|
||||
base.strumLines.push({
|
||||
characters: [data.player2],
|
||||
opponent: true,
|
||||
position: "dad",
|
||||
notes: []
|
||||
});
|
||||
base.strumLines.push({
|
||||
characters: [data.player1],
|
||||
opponent: false,
|
||||
position: "boyfriend",
|
||||
notes: []
|
||||
});
|
||||
if (data.gf != "none") {
|
||||
base.strumLines.push({
|
||||
characters: [data.gf != null ? data.gf : "gf"],
|
||||
opponent: true,
|
||||
position: "girlfriend",
|
||||
notes: [],
|
||||
visible: false,
|
||||
strumLinePos: 0.5
|
||||
});
|
||||
}
|
||||
|
||||
var camFocusedBF:Bool = false;
|
||||
var beatsPerMesure:Float = data.beatsPerMesure.getDefault(4);
|
||||
@@ -61,10 +80,12 @@ class Chart {
|
||||
var curCrochet:Float = ((60 / curBPM) * 1000);
|
||||
|
||||
if (data.notes != null) for(section in data.notes) {
|
||||
if (section == null) continue; // Yoshi Engine charts crash fix
|
||||
if (section == null) {
|
||||
curTime += curCrochet * beatsPerMesure;
|
||||
continue; // Yoshi Engine charts crash fix
|
||||
}
|
||||
|
||||
if (camFocusedBF != (camFocusedBF = section.mustHitSection)) {
|
||||
// TODO: auto-add event for cam movement
|
||||
base.events.push({
|
||||
time: curTime,
|
||||
type: CAM_MOVEMENT,
|
||||
@@ -73,10 +94,22 @@ class Chart {
|
||||
}
|
||||
|
||||
if (section.sectionNotes != null) for(note in section.sectionNotes) {
|
||||
if (note[1] < 0) continue;
|
||||
|
||||
var daStrumTime:Float = note[0];
|
||||
var daNoteData:Int = Std.int(note[1] % 8);
|
||||
var daNoteType:Int = Std.int(note[1] / 8);
|
||||
var gottaHitNote:Bool = daNoteData >= 4 ? !section.mustHitSection : section.mustHitSection;
|
||||
|
||||
if (note.length > 2) {
|
||||
if (note[3] is Int)
|
||||
daNoteType = addNoteType(base, data.noteTypes[Std.int(note[3])-1]);
|
||||
else if (note[3] is String)
|
||||
daNoteType = addNoteType(base, note[3]);
|
||||
} else {
|
||||
daNoteType = addNoteType(base, data.noteTypes[daNoteType-1]);
|
||||
}
|
||||
|
||||
|
||||
base.strumLines[gottaHitNote ? 1 : 0].notes.push({
|
||||
time: daStrumTime,
|
||||
@@ -88,7 +121,7 @@ class Chart {
|
||||
|
||||
if (section.changeBPM && section.bpm != curBPM) {
|
||||
// TODO: BPM CHANGE EVENT
|
||||
curCrochet = ((60 / section.bpm) * 1000);
|
||||
curCrochet = ((60 / (curBPM = section.bpm)) * 1000);
|
||||
}
|
||||
|
||||
curTime += curCrochet * beatsPerMesure;
|
||||
@@ -96,6 +129,19 @@ class Chart {
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
private static function addNoteType(chart:ChartData, noteTypeName:String):Int {
|
||||
switch(noteTypeName.trim()) {
|
||||
case "Default Note" | null | "":
|
||||
return 0;
|
||||
default:
|
||||
var index = chart.noteTypes.indexOf(noteTypeName);
|
||||
if (index > -1)
|
||||
return index+1;
|
||||
chart.noteTypes.push(noteTypeName);
|
||||
return chart.noteTypes.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef ChartData = {
|
||||
@@ -104,11 +150,17 @@ typedef ChartData = {
|
||||
public var meta:ChartMetaData;
|
||||
public var codenameChart:Bool;
|
||||
public var stage:String;
|
||||
public var scrollSpeed:Float;
|
||||
public var fromMods:Bool;
|
||||
public var noteTypes:Array<String>;
|
||||
}
|
||||
|
||||
typedef ChartMetaData = {
|
||||
public var name:String;
|
||||
public var bpm:Float;
|
||||
public var ?beatsPerMesure:Float;
|
||||
public var ?stepsPerBeat:Float;
|
||||
public var ?needsVoices:Bool;
|
||||
public var ?icon:String;
|
||||
public var ?color:Dynamic;
|
||||
public var ?difficulties:Array<String>;
|
||||
@@ -120,7 +172,9 @@ typedef ChartStrumLine = {
|
||||
var characters:Array<String>;
|
||||
var opponent:Bool;
|
||||
var notes:Array<ChartNote>;
|
||||
var position:String;
|
||||
var ?strumLinePos:Float; // 0.25 = default opponent pos, 0.75 = default boyfriend pos
|
||||
var ?visible:Null<Bool>;
|
||||
}
|
||||
|
||||
typedef ChartNote = {
|
||||
|
||||
Reference in New Issue
Block a user