mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-26 17:46:08 -05:00
Fix an issue where the game would try and fail to load metadata for a newly created song in the Chart Editor.
This commit is contained in:
parent
459a96a791
commit
b56768d9b5
2 changed files with 18 additions and 8 deletions
|
@ -203,30 +203,39 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
|
|||
return ScriptedSong.listScriptClasses();
|
||||
}
|
||||
|
||||
function loadEntryMetadataFile(id:String, variation:String = ''):BaseRegistry.JsonFile
|
||||
function loadEntryMetadataFile(id:String, variation:String = ''):Null<BaseRegistry.JsonFile>
|
||||
{
|
||||
var entryFilePath:String = Paths.json('$dataFilePath/$id/$id${variation == '' ? '' : '-$variation'}-metadata');
|
||||
var rawJson:String = openfl.Assets.getText(entryFilePath).trim();
|
||||
if (!openfl.Assets.exists(entryFilePath)) return null;
|
||||
var rawJson:Null<String> = openfl.Assets.getText(entryFilePath);
|
||||
if (rawJson == null) return null;
|
||||
rawJson = rawJson.trim();
|
||||
return {fileName: entryFilePath, contents: rawJson};
|
||||
}
|
||||
|
||||
function loadMusicDataFile(id:String, variation:String = ''):BaseRegistry.JsonFile
|
||||
function loadMusicDataFile(id:String, variation:String = ''):Null<BaseRegistry.JsonFile>
|
||||
{
|
||||
var entryFilePath:String = Paths.file('music/$id/$id${variation == '' ? '' : '-$variation'}-metadata.json');
|
||||
var rawJson:String = openfl.Assets.getText(entryFilePath).trim();
|
||||
if (!openfl.Assets.exists(entryFilePath)) return null;
|
||||
var rawJson:String = openfl.Assets.getText(entryFilePath);
|
||||
if (rawJson == null) return null;
|
||||
rawJson = rawJson.trim();
|
||||
return {fileName: entryFilePath, contents: rawJson};
|
||||
}
|
||||
|
||||
function loadEntryChartFile(id:String, variation:String = ''):BaseRegistry.JsonFile
|
||||
function loadEntryChartFile(id:String, variation:String = ''):Null<BaseRegistry.JsonFile>
|
||||
{
|
||||
var entryFilePath:String = Paths.json('$dataFilePath/$id/$id${variation == '' ? '' : '-$variation'}-chart');
|
||||
var rawJson:String = openfl.Assets.getText(entryFilePath).trim();
|
||||
if (!openfl.Assets.exists(entryFilePath)) return null;
|
||||
var rawJson:String = openfl.Assets.getText(entryFilePath);
|
||||
if (rawJson == null) return null;
|
||||
rawJson = rawJson.trim();
|
||||
return {fileName: entryFilePath, contents: rawJson};
|
||||
}
|
||||
|
||||
public function fetchEntryMetadataVersion(id:String, variation:String = ''):Null<thx.semver.Version>
|
||||
{
|
||||
var entryStr:String = loadEntryMetadataFile(id, variation).contents;
|
||||
var entryStr:Null<String> = loadEntryMetadataFile(id, variation)?.contents;
|
||||
var entryVersion:thx.semver.Version = VersionUtil.getVersionFromJSON(entryStr);
|
||||
return entryVersion;
|
||||
}
|
||||
|
|
|
@ -51,8 +51,9 @@ class VersionUtil
|
|||
* @param input The JSON string to parse.
|
||||
* @return The semantic version, or null if it could not be parsed.
|
||||
*/
|
||||
public static function getVersionFromJSON(input:String):Null<thx.semver.Version>
|
||||
public static function getVersionFromJSON(input:Null<String>):Null<thx.semver.Version>
|
||||
{
|
||||
if (input == null) return null;
|
||||
var parsed = SerializerUtil.fromJSON(input);
|
||||
if (parsed == null) return null;
|
||||
if (parsed.version == null) return null;
|
||||
|
|
Loading…
Reference in a new issue