Skip to content

Commit

Permalink
Revert "bruh"
Browse files Browse the repository at this point in the history
This reverts commit cc068ea.
  • Loading branch information
charlesisfeline committed Jul 16, 2024
1 parent 70bf8cd commit 5b8d0d8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 322 deletions.
137 changes: 3 additions & 134 deletions source/funkin/data/song/SongData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class SongChartData implements ICloneable<SongChartData>
public var version:Version;

public var scrollSpeed:Map<String, Float>;
public var events:Array<Array<SongEventData>>;
public var events:Array<SongEventData>;
public var notes:Map<String, Array<SongNoteData>>;

@:default(funkin.data.song.SongRegistry.DEFAULT_GENERATEDBY)
Expand All @@ -580,7 +580,7 @@ class SongChartData implements ICloneable<SongChartData>
@:jignored
public var variation:String;

public function new(scrollSpeed:Map<String, Float>, events:Array<Array<SongEventData>>, notes:Map<String, Array<SongNoteData>>)
public function new(scrollSpeed:Map<String, Float>, events:Array<SongEventData>, notes:Map<String, Array<SongNoteData>>)
{
this.version = SongRegistry.SONG_CHART_DATA_VERSION;

Expand Down Expand Up @@ -648,9 +648,7 @@ class SongChartData implements ICloneable<SongChartData>
{
noteDataClone.set(key, this.notes.get(key).deepClone());
}
var eventDataClone:Array<Array<SongEventData>> = this.events.map(function(events) {
return events.deepClone();
});
var eventDataClone:Array<SongEventData> = this.events.deepClone();

var result:SongChartData = new SongChartData(this.scrollSpeed.clone(), eventDataClone, noteDataClone);
result.version = this.version;
Expand All @@ -669,135 +667,6 @@ class SongChartData implements ICloneable<SongChartData>
}
}

class SongEventListDataRaw implements ICloneable<SongEventListDataRaw>
{
/**
* The timestamp of the event. The timestamp is in the format of the song's time format.
*/
@:alias("t")
public var time(default, set):Float;

function set_time(value:Float):Float
{
_stepTime = null;
return time = value;
}

/**
* The list of events.
*/
@:alias("e")
public var events:Array<SongEventData>;

public function new(time:Float, events:Array<SongEventData>)
{
this.time = time;
this.events = events;
}

@:jignored
var _stepTime:Null<Float> = null;

public function getStepTime(force:Bool = false):Float
{
if (_stepTime != null && !force) return _stepTime;

return _stepTime = Conductor.instance.getTimeInSteps(this.time);
}

public function clone():SongEventListDataRaw
{
return new SongEventListDataRaw(this.time, this.events.deepClone());
}
}

/**
* Wrap SongEventListData in an abstract so we can overload operators.
*/
@:forward
abstract SongEventListData(SongEventListDataRaw) from SongEventListDataRaw to SongEventListDataRaw
{
public function new(time:Float, events:Array<SongEventData>)
{
this = new SongEventListDataRaw(time, events);
}

public function clone():SongEventListData
{
return new SongEventListData(this.time, this.events.deepClone());
}

@:op(A == B)
public function op_equals(other:SongEventListData):Bool
{
if (this.time != other.time || this.events.length != other.events.length)
{
return false;
}

for (i in 0...this.events.length)
{
if (this.events[i] != other.events[i])
{
return false;
}
}

return true;
}

@:op(A != B)
public function op_notEquals(other:SongEventListData):Bool
{
return !op_equals(other);
}

@:op(A > B)
public function op_greaterThan(other:SongEventListData):Bool
{
return this.time > other.time;
}

@:op(A < B)
public function op_lessThan(other:SongEventListData):Bool
{
return this.time < other.time;
}

@:op(A >= B)
public function op_greaterThanOrEquals(other:SongEventListData):Bool
{
return this.time >= other.time;
}

@:op(A <= B)
public function op_lessThanOrEquals(other:SongEventListData):Bool
{
return this.time <= other.time;
}

/**
* Produces a string representation suitable for debugging.
*/
public function toString():String
{
var eventsToString:String = '';
for (eventList in this.events)
{
for (event in eventList)
{
eventsToString += '${event.toString()}\n ';
}
}

return 'SongEventListData(\n'
+ ' Timestamp: ${this.time}ms\n'
+ ' ${this.events.length} Events:\n'
+ ' ${eventsToString}\n'
+ ')';
}
}

class SongEventDataRaw implements ICloneable<SongEventDataRaw>
{
/**
Expand Down
115 changes: 2 additions & 113 deletions source/funkin/data/song/SongRegistry.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>

public static final SONG_METADATA_VERSION_RULE:thx.semver.VersionRule = "2.2.x";

public static final SONG_CHART_DATA_VERSION:thx.semver.Version = "2.1.0";
public static final SONG_CHART_DATA_VERSION:thx.semver.Version = "2.0.0";

public static final SONG_CHART_DATA_VERSION_RULE:thx.semver.VersionRule = "2.1.x";
public static final SONG_CHART_DATA_VERSION_RULE:thx.semver.VersionRule = "2.0.x";

public static final SONG_MUSIC_DATA_VERSION:thx.semver.Version = "2.0.0";

Expand Down Expand Up @@ -169,45 +169,6 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
return cleanMetadata(parser.value, variation);
}

public function parseEntryChartData(id:String, ?variation:String):Null<SongChartData>
{
variation = variation == null ? Constants.DEFAULT_VARIATION : variation;

var parser = new json2object.JsonParser<SongChartData>();
parser.ignoreUnknownVariables = true;

switch (loadEntryChartDataFile(id, variation))
{
case {fileName: fileName, contents: contents}:
parser.fromJson(contents, fileName);
default:
return null;
}

if (parser.errors.length > 0)
{
printErrors(parser.errors, id);
return null;
}
return cleanChartData(parser.value, variation);
}

public function parseEntryMetadataRaw(contents:String, ?fileName:String = 'raw', ?variation:String):Null<SongChartData>
{
variation = variation == null ? Constants.DEFAULT_VARIATION : variation;

var parser = new json2object.JsonParser<SongChartData>();
parser.ignoreUnknownVariables = true;
parser.fromJson(contents, fileName);

if (parser.errors.length > 0)
{
printErrors(parser.errors, fileName);
return null;
}
return cleanChartData(parser.value, variation);
}

public function parseEntryMetadataWithMigration(id:String, variation:String, version:thx.semver.Version):Null<SongMetadata>
{
variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
Expand Down Expand Up @@ -252,42 +213,6 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
}
}

public function parseEntryChartDataWithMigration(id:String, variation:String, version:thx.semver.Version):Null<SongMetadata>
{
variation = variation == null ? Constants.DEFAULT_VARIATION : variation;

// If a version rule is not specified, do not check against it.
if (SONG_CHART_DATA_VERSION_RULE == null || VersionUtil.validateVersion(version, SONG_CHART_DATA_VERSION_RULE))
{
return parseEntryChartData(id, variation);
}
else if (VersionUtil.validateVersion(version, "2.0.x"))
{
return parseEntryChartData_v2_0_0(id, variation);
}
else
{
throw '[${registryId}] ChartData entry ${id}:${variation} does not support migration to version ${SONG_CHART_DATA_VERSION_RULE}.';
}
}

public function parseEntryChartDataRawWithMigration(contents:String, ?fileName:String = 'raw', version:thx.semver.Version):Null<SongChartData>
{
// If a version rule is not specified, do not check against it.
if (SONG_CHART_DATA_VERSION_RULE == null || VersionUtil.validateVersion(version, SONG_CHART_DATA_VERSION_RULE))
{
return parseEntryChartDataRaw(contents, fileName);
}
else if (VersionUtil.validateVersion(version, "2.0.x"))
{
return parseEntryChartDataRaw_v2_0_0(contents, fileName);
}
else
{
throw '[${registryId}] ChartData entry "${fileName}" does not support migration to version ${SONG_CHART_DATA_VERSION_RULE}.';
}
}

function parseEntryMetadata_v2_1_0(id:String, ?variation:String):Null<SongMetadata>
{
variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
Expand Down Expand Up @@ -332,28 +257,6 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
return cleanMetadata(parser.value.migrate(), variation);
}

function parseEntryChartData_v2_0_0(id:String, ?variation:String):Null<SongChartData>
{
variation = variation == null ? Constants.DEFAULT_VARIATION : variation;

var parser = new json2object.JsonParser<SongChartData_v2_0_0>();
parser.ignoreUnknownVariables = true;

switch (loadEntryChartDataFile(id, variation))
{
case {fileName: fileName, contents: contents}:
parser.fromJson(contents, fileName);
default:
return null;
}
if (parser.errors.length > 0)
{
printErrors(parser.errors, id);
return null;
}
return cleanChartData(parser.value.migrate(), variation);
}

function parseEntryMetadataRaw_v2_1_0(contents:String, ?fileName:String = 'raw'):Null<SongMetadata>
{
var parser = new json2object.JsonParser<SongMetadata_v2_1_0>();
Expand Down Expand Up @@ -382,20 +285,6 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
return parser.value.migrate();
}

function parseEntryChartDataRaw_v2_0_0(contents:String, ?fileName:String = 'raw'):Null<SongChartData>
{
var parser = new json2object.JsonParser<SongChartData_v2_0_0>();
parser.ignoreUnknownVariables = true;
parser.fromJson(contents, fileName);

if (parser.errors.length > 0)
{
printErrors(parser.errors, fileName);
return null;
}
return parser.value.migrate();
}

public function parseMusicData(id:String, ?variation:String):Null<SongMusicData>
{
variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
Expand Down
19 changes: 0 additions & 19 deletions source/funkin/data/song/migrator/SongDataMigrator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ package funkin.data.song.migrator;
import funkin.data.song.SongData.SongMetadata;
import funkin.data.song.SongData.SongPlayData;
import funkin.data.song.SongData.SongCharacterData;
import funkin.data.song.SongData.SongChartData;
import funkin.data.song.SongData.SongEventData;
import funkin.data.song.migrator.SongData_v2_0_0.SongMetadata_v2_0_0;
import funkin.data.song.migrator.SongData_v2_0_0.SongPlayData_v2_0_0;
import funkin.data.song.migrator.SongData_v2_0_0.SongPlayableChar_v2_0_0;
import funkin.data.song.migrator.SongData_v2_0_0.SongChartData_v2_0_0;

using funkin.data.song.migrator.SongDataMigrator; // Does this even work lol?

Expand Down Expand Up @@ -116,20 +113,4 @@ class SongDataMigrator

return result;
}

public static overload extern inline function migrate(input:SongData_v2_0_0.SongChartData_v2_0_0):SongMetadata
{
return migrate_SongChartData_v2_0_0(input);
}

public static function migrate_SongChartData_v2_0_0(input:SongData_v2_0_0.SongChartData_v2_0_0):SongMetadata
{
var events:Array<Array<SongEventData>> = [for (event in input.events) [event]];

var result:SongChartData = new SongChartData(input.scrollSpeed, events, input.notes);
result.version = SongRegistry.SONG_CHART_DATA_VERSION;
result.generatedBy = input.generatedBy;

return result;
}
}
Loading

0 comments on commit 5b8d0d8

Please sign in to comment.