mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-30 03:25:47 -05:00
stringify moved to SongEventSchema
This commit is contained in:
parent
210088a25d
commit
fa00140d23
1 changed files with 27 additions and 1 deletions
|
@ -15,7 +15,7 @@ abstract SongEventSchema(SongEventSchemaRaw)
|
|||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function getByName(name:String):SongEventSchemaField
|
||||
public function getByName(name:String):SongEventSchemaField
|
||||
{
|
||||
for (field in this)
|
||||
{
|
||||
|
@ -41,6 +41,32 @@ abstract SongEventSchema(SongEventSchemaRaw)
|
|||
{
|
||||
return this[k] = v;
|
||||
}
|
||||
|
||||
public function stringifyFieldValue(name:String, value:Dynamic):String
|
||||
{
|
||||
var field:SongEventSchemaField = getByName(name);
|
||||
if (field == null) return 'Unknown';
|
||||
|
||||
switch (field.type)
|
||||
{
|
||||
case SongEventFieldType.STRING:
|
||||
return Std.string(value);
|
||||
case SongEventFieldType.INTEGER:
|
||||
return Std.string(value);
|
||||
case SongEventFieldType.FLOAT:
|
||||
return Std.string(value);
|
||||
case SongEventFieldType.BOOL:
|
||||
return Std.string(value);
|
||||
case SongEventFieldType.ENUM:
|
||||
for (key in field.keys.keys())
|
||||
{
|
||||
if (field.keys.get(key) == value) return key;
|
||||
}
|
||||
return Std.string(value);
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef SongEventSchemaRaw = Array<SongEventSchemaField>;
|
||||
|
|
Loading…
Reference in a new issue