From e76734a506f7722512b811e9885a42acbd7be5d0 Mon Sep 17 00:00:00 2001 From: Pierre-Thomas Meisels Date: Tue, 31 Oct 2023 07:45:38 +0100 Subject: [PATCH] enh: allow editing of event guid. Mark it red when wrong. (#171) --- .../tool/property_editors/FmodPathEditorProperty.gd | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/demo/addons/fmod/tool/property_editors/FmodPathEditorProperty.gd b/demo/addons/fmod/tool/property_editors/FmodPathEditorProperty.gd index 2cc63598..f6ba7d08 100644 --- a/demo/addons/fmod/tool/property_editors/FmodPathEditorProperty.gd +++ b/demo/addons/fmod/tool/property_editors/FmodPathEditorProperty.gd @@ -3,12 +3,18 @@ var ui: Control var guid_property: String var path_property: String +var regex := RegEx.new() + +var default_line_edit_modulate: Color func initialize(open_project_explorer_callable: Callable, path_prop: String, guid_prop: String): + regex.compile("{\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}}") guid_property = guid_prop path_property = path_prop var guid_and_path_ui: FmodGuidAndPathPropertyEditorUi = %FmodGuidAndPathPropertyEditorUi + default_line_edit_modulate = guid_and_path_ui.get_node("%GuidLineEdit").modulate + var open_project_explorer_event = func open_project_explorer_event(): open_project_explorer_callable.call(self._set_path_and_guid) guid_and_path_ui.set_callables(open_project_explorer_event, _set_path, _set_guid) @@ -22,6 +28,11 @@ func _set_path(path: String): emit_changed(path_property, path) func _set_guid(guid: String): + var line_edit := %FmodGuidAndPathPropertyEditorUi.get_node("%GuidLineEdit") as LineEdit + if not regex.search(guid): + line_edit.modulate = Color.RED + return + line_edit.modulate = default_line_edit_modulate emit_changed(guid_property, guid) func _set_path_and_guid(path: String, guid: String):