diff --git a/source/funkin/data/event/SongEventSchema.hx b/source/funkin/data/event/SongEventSchema.hx index 7ebaa5ae1..c910cbf5a 100644 --- a/source/funkin/data/event/SongEventSchema.hx +++ b/source/funkin/data/event/SongEventSchema.hx @@ -6,7 +6,7 @@ import funkin.data.song.SongData.SongEventData; import funkin.util.macro.ClassMacro; import funkin.play.event.ScriptedSongEvent; -@:forward(name, tittlte, type, keys, min, max, step, defaultValue, iterator) +@:forward(name, title, type, keys, min, max, step, units, defaultValue, iterator) abstract SongEventSchema(SongEventSchemaRaw) { public function new(?fields:Array) @@ -42,7 +42,7 @@ abstract SongEventSchema(SongEventSchemaRaw) return this[k] = v; } - public function stringifyFieldValue(name:String, value:Dynamic):String + public function stringifyFieldValue(name:String, value:Dynamic, addUnits:Bool = true):String { var field:SongEventSchemaField = getByName(name); if (field == null) return 'Unknown'; @@ -52,21 +52,34 @@ abstract SongEventSchema(SongEventSchemaRaw) case SongEventFieldType.STRING: return Std.string(value); case SongEventFieldType.INTEGER: - return Std.string(value); + var returnValue:String = Std.string(value); + if (addUnits) return addUnitsToString(returnValue, field); + return returnValue; case SongEventFieldType.FLOAT: - return Std.string(value); + var returnValue:String = Std.string(value); + if (addUnits) return addUnitsToString(returnValue, field); + return returnValue; case SongEventFieldType.BOOL: return Std.string(value); case SongEventFieldType.ENUM: + var valueString:String = Std.string(value); for (key in field.keys.keys()) { - if (field.keys.get(key) == value) return key; + // Comparing these values as strings because comparing Dynamic variables is jank. + if (Std.string(field.keys.get(key)) == valueString) return key; } - return Std.string(value); + return valueString; default: return 'Unknown'; } } + + function addUnitsToString(value:String, field:SongEventSchemaField) + { + if (field.units == null || field.units == '') return value; + + return value + ' ${field.units}'; + } } typedef SongEventSchemaRaw = Array; @@ -115,6 +128,12 @@ typedef SongEventSchemaField = */ ?step:Float, + /** + * Used for INTEGER and FLOAT values. + * The units that the value is expressed in (pixels, percent, etc). + */ + ?units:String, + /** * An optional default value for the field. */ diff --git a/source/funkin/play/event/FocusCameraSongEvent.hx b/source/funkin/play/event/FocusCameraSongEvent.hx index 83c978ba8..034d79894 100644 --- a/source/funkin/play/event/FocusCameraSongEvent.hx +++ b/source/funkin/play/event/FocusCameraSongEvent.hx @@ -135,10 +135,10 @@ class FocusCameraSongEvent extends SongEvent return new SongEventSchema([ { name: "char", - title: "Character", + title: "Target", defaultValue: 0, type: SongEventFieldType.ENUM, - keys: ["Position" => -1, "Boyfriend" => 0, "Dad" => 1, "Girlfriend" => 2] + keys: ["Position" => -1, "Player" => 0, "Opponent" => 1, "Girlfriend" => 2] }, { name: "x", @@ -146,6 +146,7 @@ class FocusCameraSongEvent extends SongEvent defaultValue: 0, step: 10.0, type: SongEventFieldType.FLOAT, + units: "px", }, { name: "y", @@ -153,6 +154,7 @@ class FocusCameraSongEvent extends SongEvent defaultValue: 0, step: 10.0, type: SongEventFieldType.FLOAT, + units: "px", } ]); } diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx index fbd1562b4..9ae4cbb01 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx @@ -216,6 +216,16 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox target.addComponent(input); + if (field.units != null && field.units != "") + { + var units:Label = new Label(); + units.text = field.units; + units.verticalAlign = "center"; + units.left = 85; + units.top = 4; + input.addComponent(units); + } + // Update the value of the event data. input.onChange = function(event:UIEvent) { var value = event.target.value;