mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-26 17:46:08 -05:00
Make sure JSON data uses latest version/generatedBy when writing.
This commit is contained in:
parent
06daa9d402
commit
9088570b92
5 changed files with 44 additions and 2 deletions
|
@ -117,6 +117,9 @@ class SongMetadata implements ICloneable<SongMetadata>
|
|||
*/
|
||||
public function serialize(pretty:Bool = true):String
|
||||
{
|
||||
// Update generatedBy and version before writing.
|
||||
updateVersionToLatest();
|
||||
|
||||
var ignoreNullOptionals = true;
|
||||
var writer = new json2object.JsonWriter<SongMetadata>(ignoreNullOptionals);
|
||||
// I believe @:jignored should be ignored by the writer?
|
||||
|
@ -125,6 +128,12 @@ class SongMetadata implements ICloneable<SongMetadata>
|
|||
return writer.write(this, pretty ? ' ' : null);
|
||||
}
|
||||
|
||||
public function updateVersionToLatest():Void
|
||||
{
|
||||
this.version = SongRegistry.SONG_METADATA_VERSION;
|
||||
this.generatedBy = SongRegistry.DEFAULT_GENERATEDBY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a string representation suitable for debugging.
|
||||
*/
|
||||
|
@ -373,6 +382,12 @@ class SongMusicData implements ICloneable<SongMusicData>
|
|||
this.variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
|
||||
}
|
||||
|
||||
public function updateVersionToLatest():Void
|
||||
{
|
||||
this.version = SongRegistry.SONG_MUSIC_DATA_VERSION;
|
||||
this.generatedBy = SongRegistry.DEFAULT_GENERATEDBY;
|
||||
}
|
||||
|
||||
public function clone():SongMusicData
|
||||
{
|
||||
var result:SongMusicData = new SongMusicData(this.songName, this.artist, this.variation);
|
||||
|
@ -605,11 +620,20 @@ class SongChartData implements ICloneable<SongChartData>
|
|||
*/
|
||||
public function serialize(pretty:Bool = true):String
|
||||
{
|
||||
// Update generatedBy and version before writing.
|
||||
updateVersionToLatest();
|
||||
|
||||
var ignoreNullOptionals = true;
|
||||
var writer = new json2object.JsonWriter<SongChartData>(ignoreNullOptionals);
|
||||
return writer.write(this, pretty ? ' ' : null);
|
||||
}
|
||||
|
||||
public function updateVersionToLatest():Void
|
||||
{
|
||||
this.version = SongRegistry.SONG_CHART_DATA_VERSION;
|
||||
this.generatedBy = SongRegistry.DEFAULT_GENERATEDBY;
|
||||
}
|
||||
|
||||
public function clone():SongChartData
|
||||
{
|
||||
// We have to manually perform the deep clone here because Map.deepClone() doesn't work.
|
||||
|
|
|
@ -61,10 +61,18 @@ class ChartManifestData
|
|||
*/
|
||||
public function serialize(pretty:Bool = true):String
|
||||
{
|
||||
// Update generatedBy and version before writing.
|
||||
updateVersionToLatest();
|
||||
|
||||
var writer = new json2object.JsonWriter<ChartManifestData>();
|
||||
return writer.write(this, pretty ? ' ' : null);
|
||||
}
|
||||
|
||||
public function updateVersionToLatest():Void
|
||||
{
|
||||
this.version = CHART_MANIFEST_DATA_VERSION;
|
||||
}
|
||||
|
||||
public static function deserialize(contents:String):Null<ChartManifestData>
|
||||
{
|
||||
var parser = new json2object.JsonParser<ChartManifestData>();
|
||||
|
|
|
@ -58,9 +58,17 @@ class StageData
|
|||
*/
|
||||
public function serialize(pretty:Bool = true):String
|
||||
{
|
||||
// Update generatedBy and version before writing.
|
||||
updateVersionToLatest();
|
||||
|
||||
var writer = new json2object.JsonWriter<StageData>();
|
||||
return writer.write(this, pretty ? ' ' : null);
|
||||
}
|
||||
|
||||
public function updateVersionToLatest():Void
|
||||
{
|
||||
this.version = StageRegistry.STAGE_DATA_VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
typedef StageDataCharacters =
|
||||
|
|
|
@ -54,7 +54,7 @@ class CreditsDataHandler
|
|||
body: [
|
||||
{line: 'ninjamuffin99'},
|
||||
{line: 'PhantomArcade'},
|
||||
{line: 'KawaiSprite'},
|
||||
{line: 'Kawai Sprite'},
|
||||
{line: 'evilsk8r'},
|
||||
]
|
||||
}
|
||||
|
|
|
@ -386,12 +386,14 @@ class ChartEditorImportExportHandler
|
|||
var variationMetadata:Null<SongMetadata> = state.songMetadata.get(variation);
|
||||
if (variationMetadata != null)
|
||||
{
|
||||
variationMetadata.version = funkin.data.song.SongRegistry.SONG_METADATA_VERSION;
|
||||
variationMetadata.generatedBy = funkin.data.song.SongRegistry.DEFAULT_GENERATEDBY;
|
||||
zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-metadata.json', variationMetadata.serialize()));
|
||||
}
|
||||
var variationChart:Null<SongChartData> = state.songChartData.get(variation);
|
||||
if (variationChart != null)
|
||||
{
|
||||
variationChart.version = funkin.data.song.SongRegistry.SONG_CHART_DATA_VERSION;
|
||||
variationChart.generatedBy = funkin.data.song.SongRegistry.DEFAULT_GENERATEDBY;
|
||||
zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-chart.json', variationChart.serialize()));
|
||||
}
|
||||
|
@ -401,12 +403,12 @@ class ChartEditorImportExportHandler
|
|||
var variationMetadata:Null<SongMetadata> = state.songMetadata.get(variation);
|
||||
if (variationMetadata != null)
|
||||
{
|
||||
variationMetadata.generatedBy = funkin.data.song.SongRegistry.DEFAULT_GENERATEDBY;
|
||||
zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-metadata-$variationId.json', variationMetadata.serialize()));
|
||||
}
|
||||
var variationChart:Null<SongChartData> = state.songChartData.get(variation);
|
||||
if (variationChart != null)
|
||||
{
|
||||
variationChart.version = funkin.data.song.SongRegistry.SONG_CHART_DATA_VERSION;
|
||||
variationChart.generatedBy = funkin.data.song.SongRegistry.DEFAULT_GENERATEDBY;
|
||||
zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-chart-$variationId.json', variationChart.serialize()));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue