Skip to content

Commit

Permalink
chartformat stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
VMan-2002 committed Aug 5, 2024
1 parent 50cfd31 commit a3f306e
Show file tree
Hide file tree
Showing 7 changed files with 520 additions and 3 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Version 2.0.0 Breaking Changes
...or not? They're just really big and I don't want it to mess up other developments

(so, more like Version 2.0.0 Big Changes)
They're really big and I don't want it to mess up other developments

Putting fundamental changes intended for v2.0.0 here
201 changes: 201 additions & 0 deletions source/chartformat/ChartFormat.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
package chartformat;

class ChartFormat {
//basic info
public var song:String;
public var title:Null<String>;
public var bpm:Float = 100.0;
public var speed:Float = 1.0;
public var attributes:Array<Array<Dynamic>>;

//gameplay
public var validScore:Bool = true;
public var events:Array<EventFormatVE>;
public var notes:Array<SectionFormatVE>;

public function new(song:String) {
this.song = song;
attributes = new Array<Array<String>>();
events = new Array<EventFormatVE>();
notes = new Array<SectionFormatVE>();
setAttributesFromMap([
"noteTypes" => ["Normal Note"]
]);
}

public function getAttribute(name:String) {
for (thing in attributes) {
if (thing[0] == name)
return thing;
}
return [name];
}

public function setAttribute(dat:Array<Dynamic>) {
for (i => thing in attributes.keyValueIterator()) {
if (thing[0] == dat[0])
return attributes[i] = dat;
}
attributes.push(dat);
return dat;
}

public function setAttributesFromMap(attrib:Map<String, Array<Dynamic>>) {
attributes.resize(0);
for (n => dat in attrib) {
attributes.push(cast([n], Array<Dynamic>).concat(dat));
}
}

public function addAttributesFromMap(attrib:Map<String, Array<Dynamic>>) {
for (n => dat in attrib) {
setAttribute(cast([n], Array<Dynamic>).concat(dat));
}
}

public function attributesToMap() {
var result = new Map<String, Array<Dynamic>>();
for (thing in attributes) {
result.set(thing[0], thing.slice(1));
}
return result;
}

inline static function condSet(map, cond, name, val) {
if (cond)
map.set(name, val);
}

public static function fromOld(dat:ChartFormatOld) {
var result = new ChartFormat(dat.song);
result.title = dat.newtitle;
result.bpm = dat.bpm;
result.speed = dat.speed;
result.validScore = dat.validScore;
var attributes = new Map<String, Array<Dynamic>>();
var empty = new Array<String>();
if (dat.attributes == null) {
for (thing in dat.attributes) {
var newAttribute = [];
for (n in thing) {
newAttribute.push(Std.string(n));
}
attributes.set(newAttribute.shift(), newAttribute);
}
}
for (thing in dat.actions)
attributes.set(thing, empty);
attributes.set("healthDrain", [Std.string(dat.healthDrain == null ? 0 : dat.healthDrain), Std.string(dat.healthDrainMin == null ? 0 : dat.healthDrainMin)]);
condSet(attributes, dat.usedNoteTypes != null && dat.usedNoteTypes.length != 0, "noteTypes", dat.usedNoteTypes);
condSet(attributes, dat.hide_girlfriend == true, "hideGirlfriend", empty);
condSet(attributes, dat.moreStrumLines == null, "strumLineCount", [Std.string(dat.moreStrumLines + 2)]);
attributes.set("voicesName", [dat.voicesName]);
condSet(attributes, dat.needsVoices == false, "needsVoices", [false]);
attributes.set("instName", [dat.instName]);
attributes.set("voicesOpponentName", [dat.voicesOpponentName]);
condSet(attributes, dat.threeLanes == true, "threeLanes", empty);
condSet(attributes, dat.picospeaker != null && dat.picospeaker != "", "picoSpeaker", [dat.picospeaker]);
condSet(attributes, dat.picocharts != null && dat.picocharts.length != 0, "linkedCharts", dat.picocharts);
condSet(attributes, dat.loopbackPoint != null, "loopTime", [Std.string(dat.loopbackPoint)]);
condSet(attributes, dat.timeSignature != null && dat.timeSignature != 4, "sectionBeats", [Std.string(dat.timeSignature)]);

attributes.set("characters", [dat.player1 == null ? "bf" : dat.player1, dat.player2 == null ? "mr_placeholder_guy" : dat.player2, dat.gfVersion == null ? "gf" : dat.gfVersion].concat(dat.moreCharacters == null ? [] : dat.moreCharacters));
condSet(attributes, dat.stage != "stage" && dat.stage != null, "stage", [dat.stage]);
condSet(attributes, dat.noteSkin != null && dat.noteSkin != "normal" && dat.noteSkin != "" && dat.noteSkinOpponent != null && dat.noteSkinOpponent.length != 0, "noteSkin", dat.noteSkinOpponent != null ? [dat.noteSkin].concat(dat.noteSkinOpponent) : [dat.noteSkin]);
condSet(attributes, dat.uiStyle != null && dat.uiStyle != "" && dat.uiStyle != "normal", "uiStyle", [dat.uiStyle]);
result.setAttributesFromMap(attributes);
//this is wacky

//todo: notes and events
}

public static function fromPsych(dat:ChartFormatPsych) {
var result = new ChartFormat(dat.song);
result.bpm = dat.bpm;
result.speed = dat.speed;
result.validScore = true;

var attributes = new Map<String, Array<Dynamic>>();
attributes.set("characters", [dat.player1, dat.player2]);
attributes.set("stage", [dat.stage]);
condSet(attributes, dat.needsVoices == false, "needsVoices", [false]);
result.setAttributesFromMap(attributes);

var noteTypes:Array<String> = ["Normal Note"];
var ntOld = ['Normal Note', 'Alt Animation', 'Hey', 'Hurt Note', 'GF Sing', 'No Animation'];
for (section in dat.notes) {
var newSection:SectionFormatVE = {
notes: [],
chars: section.gfSection ? [2, section.mustHitSection ? 1 : 0] : null,
bpm: section.changeBPM ? section.bpm : null,
mania: null,
mustHitSection: section.mustHitSection,
focusCharacter: section.gfSection ? 2 : null,
beats: section.sectionBeats
}
for (note in section.sectionNotes) {
var nt:String = (note.length < 4 || note[3] == null) ? "Normal Note" : (Std.isOfType(note[3], String) ? note[3] : ntOld[note[3]]);
newSection.notes.push({
t: note[0],
d: note[1],
l: note[2],
n: noteTypes.indexOf(nt)
});
}
result.notes.push(newSection);
}

//todo: events

return result;
}

public static function fromLeather(dat:ChartFormatLeather) {
var result = new ChartFormat(dat.song);
result.bpm = dat.bpm;
result.speed = dat.speed;
result.validScore = dat.validScore;

var attributes = new Map<String, Array<Dynamic>>();
var gf = dat.gf;
if (gf == null)
gf = dat.gfVersion == null ? dat.player3 : dat.gfVersion;
attributes.set("characters", [dat.player1, dat.player2, gf]);
if (dat.specialAudioName != null) {
attributes.set("instName", ["Inst-" + dat.specialAudioName]);
attributes.set("voicesName", ["Voices-" + dat.specialAudioName]);
}
if (dat.keyCount != null || dat.playerKeyCount != null) {
var kc = dat.keyCount == null ? 4 : dat.keyCount;
attributes.set("mania", [(dat.playerKeyCount != null ? dat.playerKeyCount : kc) + "k", kc + "k"]);
}
if (dat.ui_Skin != null) {
attributes.set("uiStyle", [dat.ui_Skin]);
attributes.set("noteSkin", [dat.ui_Skin]);
}

//todo: notes and events
}
}

typedef SectionFormatVE = {
var notes:Array<NoteFormatVE>;
var chars:Null<Array<Int>>;
var bpm:Float;
var mania:Null<Array<Null<String>>>;
var mustHitSection:Bool;
var focusCharacter:Null<Int>;
var beats:Float;
}

typedef NoteFormatVE = {
var t:Float; //strumTime
var d:Int; //noteData
var l:Float; //sustainLength
var n:Int; //noteType
}

typedef EventFormatVE = {
var t:Float; //strumTime
var d:Int; //index in attributes -> "events"
}
2 changes: 2 additions & 0 deletions source/chartformat/ChartFormatDetector.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package chartformat;

51 changes: 51 additions & 0 deletions source/chartformat/ChartFormatLeather.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package chartformat;

typedef ChartFormatLeather = {
var song:String;
var notes:Array<SectionFormatLeather>;
var bpm:Float;
var needsVoices:Bool;
var speed:Float;

var player1:String;
var player2:String;
var gf:Null<String>;
var stage:String;
var validScore:Bool;
var modchartPath:String;
var keyCount:Null<Int>;
var playerKeyCount:Null<Int>;
var timescale:Array<Int>;
var chartOffset:Null<Int>; // in milliseconds
// shaggy pog
var mania:Null<Int>;
var ui_Skin:Null<String>;
var cutscene:String;
var endCutscene:String;
var eventObjects:Array<EventFormatLeather>;
var events:Null<Array<Array<Dynamic>>>;
var specialAudioName:Null<String>;
var gfVersion:Null<String>;
var player3:Null<String>;
}

typedef SectionFormatLeather =
{
var sectionNotes:Array<Dynamic>;
var lengthInSteps:Int;
var typeOfSection:Int;
var mustHitSection:Bool;
var bpm:Float;
var changeBPM:Bool;
var altAnim:Bool;

var timeScale:Array<Int>;
var changeTimeScale:Bool;
}

typedef EventFormatLeather = {
var name:String;
var position:Float;
var value:Float;
var type:String;
}
77 changes: 77 additions & 0 deletions source/chartformat/ChartFormatOld.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package chartformat;

typedef ChartFormatOld = {
var song:String;
var newtitle:Null<String>; //display name
var notes:Array<SectionFormatOld>;
var bpm:Float;
var needsVoices:Bool;
var speed:Float;

var player1:String;
var player2:String;
var validScore:Bool;

var gfVersion:String;
var maniaStr:Null<String>;
var mania:Null<Int>; //for Kade/Psych (7k and 9k vs shaggy charts dont get interpreted right)
var keyCount:Null<Int>; //for Leather
var stage:String;
var usedNoteTypes:Array<String>;

var healthDrain:Null<Float>;
var healthDrainMin:Null<Float>;

var moreCharacters:Array<String>;

var actions:Array<String>;
var attributes:Array<Array<Dynamic>>;
var noteSkin:String;
var noteSkinOpponent:Array<String>;
var uiStyle:String;

var vmanEventTime:Array<Float>;
var vmanEventOrder:Array<Int>;
var vmanEventData:Array<Dynamic>;

var hide_girlfriend:Null<Bool>;

var moreStrumLines:Null<Int>;

var timeSignature:Null<Int>;

var voicesName:Null<String>;
var voicesOpponentName:Null<String>;
var instName:Null<String>;

var threeLanes:Null<Bool>; //Pasta night :))))))

var picospeaker:Null<String>; //Week 7 stress
var picocharts:Null<Array<String>>; //It dont Crap

var loopbackPoint:Null<Float>; //Music that is just endless on it's own
}

typedef SectionFormatOld = {
var sectionNotes:Array<Array<Dynamic>>; // putting here so i remember:
//sectionNotes[i][0]: strumTime
//sectionNotes[i][1]: noteData
//sectionNotes[i][2]: sustainLength
//sectionNotes[i][3]: noteType
var notesMoreLayers:Array<Array<Array<Dynamic>>>;
var lengthInSteps:Int;
var typeOfSection:Int;
var mustHitSection:Bool;
var bpm:Float;
var changeBPM:Bool;
var altAnim:Bool;
var gfSection:Bool;
var focusCharacter:Null<Int>;
var changeMania:Bool;
//var maniaArr:Array<String>;
var maniaStr:String;
var changeTimeSignature:Bool;
var timeSignature:Int;
var sectionBeats:Int;
var dType:Int; //this exists because Final Destination!!!
}
37 changes: 37 additions & 0 deletions source/chartformat/ChartFormatPsych.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package chartformat;

typedef ChartFormatPsych =
{
var song:String;
var notes:Array<SectionFormatPsych>;
var events:Array<Dynamic>;
var bpm:Float;
var needsVoices:Bool;
var speed:Float;

var player1:String;
var player2:String;
var gfVersion:String;
var stage:String;

@:optional var gameOverChar:String;
@:optional var gameOverSound:String;
@:optional var gameOverLoop:String;
@:optional var gameOverEnd:String;

@:optional var disableNoteRGB:Bool;

@:optional var arrowSkin:String;
@:optional var splashSkin:String;
}

typedef SectionFormatPsych =
{
var sectionNotes:Array<Dynamic>;
var sectionBeats:Float;
var mustHitSection:Bool;
var gfSection:Bool;
var bpm:Float;
var changeBPM:Bool;
var altAnim:Bool;
}
Loading

0 comments on commit a3f306e

Please sign in to comment.