From e111e91a9c9f7acbbcda9fe9008eb0a9c8d47de6 Mon Sep 17 00:00:00 2001 From: Jenny Crowe Date: Wed, 24 Jan 2024 20:31:25 -0700 Subject: [PATCH 1/7] Editor: Added ability to set units for event properties. Fixed bug where event icon tooltip wouldn't show an enum text value correctly. --- source/funkin/data/event/SongEventSchema.hx | 31 +++++++++++++++---- .../funkin/play/event/FocusCameraSongEvent.hx | 6 ++-- .../toolboxes/ChartEditorEventDataToolbox.hx | 10 ++++++ 3 files changed, 39 insertions(+), 8 deletions(-) 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; From 8573a725bd0d716f43e93491dddffb6a96de4149 Mon Sep 17 00:00:00 2001 From: Jenny Crowe Date: Fri, 26 Jan 2024 18:19:35 -0700 Subject: [PATCH 2/7] acacagh assets update --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 7e19c4cfa..b2f8b6a78 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 7e19c4cfa7db57178f03ed4a58a9fd4d2b93dea7 +Subproject commit b2f8b6a780316959d0a79adc6dbf61f9e4ca675f From 4f7c2cd511e3cf0087466bc810978cfadc8e8571 Mon Sep 17 00:00:00 2001 From: Jenny Crowe Date: Fri, 26 Jan 2024 18:30:41 -0700 Subject: [PATCH 3/7] Now using hbox to more easily append unit label --- .../toolboxes/ChartEditorEventDataToolbox.hx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx index 9ae4cbb01..7b163ad3d 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx @@ -18,6 +18,7 @@ import haxe.ui.core.Component; import funkin.data.event.SongEventRegistry; import haxe.ui.components.TextField; import haxe.ui.containers.Box; +import haxe.ui.containers.HBox; import haxe.ui.containers.Frame; import haxe.ui.events.UIEvent; import haxe.ui.data.ArrayDataSource; @@ -214,18 +215,21 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox input.text = field.type; } - target.addComponent(input); + // Putting in a box so we can add a unit label easily if there is one. + var inputBox:HBox = new HBox(); + inputBox.addComponent(input); + // Add a unit label if applicable. 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); + inputBox.addComponent(units); } + target.addComponent(inputBox); + // Update the value of the event data. input.onChange = function(event:UIEvent) { var value = event.target.value; From bfb032dc7fc98c6067fe4a9aff7fc95a4421be0a Mon Sep 17 00:00:00 2001 From: Jenny Crowe Date: Fri, 26 Jan 2024 18:51:36 -0700 Subject: [PATCH 4/7] Added units to other song events. --- source/funkin/data/event/SongEventSchema.hx | 7 ++++++- source/funkin/play/event/FocusCameraSongEvent.hx | 4 ++-- source/funkin/play/event/SetCameraBopSongEvent.hx | 6 ++++-- source/funkin/play/event/ZoomCameraSongEvent.hx | 6 ++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/source/funkin/data/event/SongEventSchema.hx b/source/funkin/data/event/SongEventSchema.hx index c910cbf5a..ac7e44373 100644 --- a/source/funkin/data/event/SongEventSchema.hx +++ b/source/funkin/data/event/SongEventSchema.hx @@ -78,7 +78,12 @@ abstract SongEventSchema(SongEventSchemaRaw) { if (field.units == null || field.units == '') return value; - return value + ' ${field.units}'; + var unit:String = field.units; + + // These units look better when placed immediately next to the value, rather than after a space. + if (unit == 'x' || unit == '°') return value + '${unit}'; + + return value + ' ${unit}'; } } diff --git a/source/funkin/play/event/FocusCameraSongEvent.hx b/source/funkin/play/event/FocusCameraSongEvent.hx index 034d79894..847df4a60 100644 --- a/source/funkin/play/event/FocusCameraSongEvent.hx +++ b/source/funkin/play/event/FocusCameraSongEvent.hx @@ -146,7 +146,7 @@ class FocusCameraSongEvent extends SongEvent defaultValue: 0, step: 10.0, type: SongEventFieldType.FLOAT, - units: "px", + units: "px" }, { name: "y", @@ -154,7 +154,7 @@ class FocusCameraSongEvent extends SongEvent defaultValue: 0, step: 10.0, type: SongEventFieldType.FLOAT, - units: "px", + units: "px" } ]); } diff --git a/source/funkin/play/event/SetCameraBopSongEvent.hx b/source/funkin/play/event/SetCameraBopSongEvent.hx index d0e01346f..a82577a5f 100644 --- a/source/funkin/play/event/SetCameraBopSongEvent.hx +++ b/source/funkin/play/event/SetCameraBopSongEvent.hx @@ -78,14 +78,16 @@ class SetCameraBopSongEvent extends SongEvent title: 'Intensity', defaultValue: 1.0, step: 0.1, - type: SongEventFieldType.FLOAT + type: SongEventFieldType.FLOAT, + units: 'x' }, { name: 'rate', - title: 'Rate (beats/zoom)', + title: 'Rate', defaultValue: 4, step: 1, type: SongEventFieldType.INTEGER, + units: 'beats/zoom' } ]); } diff --git a/source/funkin/play/event/ZoomCameraSongEvent.hx b/source/funkin/play/event/ZoomCameraSongEvent.hx index a35a12e1e..809130499 100644 --- a/source/funkin/play/event/ZoomCameraSongEvent.hx +++ b/source/funkin/play/event/ZoomCameraSongEvent.hx @@ -106,14 +106,16 @@ class ZoomCameraSongEvent extends SongEvent title: 'Zoom Level', defaultValue: 1.0, step: 0.1, - type: SongEventFieldType.FLOAT + type: SongEventFieldType.FLOAT, + units: 'x' }, { name: 'duration', - title: 'Duration (in steps)', + title: 'Duration', defaultValue: 4.0, step: 0.5, type: SongEventFieldType.FLOAT, + units: 'steps' }, { name: 'ease', From 47430763141d1106a9349bc622e900779f8171ce Mon Sep 17 00:00:00 2001 From: Jenny Crowe Date: Fri, 26 Jan 2024 19:01:05 -0700 Subject: [PATCH 5/7] Added % as a unit to not include a space for when displaying in the event tooltip --- source/funkin/data/event/SongEventSchema.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/data/event/SongEventSchema.hx b/source/funkin/data/event/SongEventSchema.hx index ac7e44373..ca63f62f8 100644 --- a/source/funkin/data/event/SongEventSchema.hx +++ b/source/funkin/data/event/SongEventSchema.hx @@ -81,7 +81,7 @@ abstract SongEventSchema(SongEventSchemaRaw) var unit:String = field.units; // These units look better when placed immediately next to the value, rather than after a space. - if (unit == 'x' || unit == '°') return value + '${unit}'; + if (unit == 'x' || unit == '°' || unit == '%') return value + '${unit}'; return value + ' ${unit}'; } From 387ff4e816871a21cdd966a99724068f25ed5636 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 2 Feb 2024 22:38:34 -0500 Subject: [PATCH 6/7] Replace multiple conditions with array. --- source/funkin/data/event/SongEventSchema.hx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/funkin/data/event/SongEventSchema.hx b/source/funkin/data/event/SongEventSchema.hx index ca63f62f8..9591e601e 100644 --- a/source/funkin/data/event/SongEventSchema.hx +++ b/source/funkin/data/event/SongEventSchema.hx @@ -9,6 +9,11 @@ import funkin.play.event.ScriptedSongEvent; @:forward(name, title, type, keys, min, max, step, units, defaultValue, iterator) abstract SongEventSchema(SongEventSchemaRaw) { + /** + * These units look better when placed immediately next to the value, rather than after a space. + */ + static final NO_SPACE_UNITS:Array = ['x', '°', '%']; + public function new(?fields:Array) { this = fields; @@ -80,10 +85,7 @@ abstract SongEventSchema(SongEventSchemaRaw) var unit:String = field.units; - // These units look better when placed immediately next to the value, rather than after a space. - if (unit == 'x' || unit == '°' || unit == '%') return value + '${unit}'; - - return value + ' ${unit}'; + return value + (NO_SPACE_UNITS.contains(unit) ? '' : ' ') + '${unit}'; } } From 30cb53d8c2c2c756ccd5e6270ee6e7066fc6dade Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 5 Feb 2024 13:02:23 -0500 Subject: [PATCH 7/7] haxeui-core update --- hmm.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hmm.json b/hmm.json index 4b2885a87..251c5c499 100644 --- a/hmm.json +++ b/hmm.json @@ -54,7 +54,7 @@ "name": "haxeui-core", "type": "git", "dir": null, - "ref": "5b2d5b8e7e470cf637953e1369c80a1f42016a75", + "ref": "8a7846b", "url": "https://github.com/haxeui/haxeui-core" }, {