From 92a993442d8cbd62ff008bbfb9db4e3de7e51f87 Mon Sep 17 00:00:00 2001 From: Patrick Dawson Date: Tue, 10 Sep 2024 22:16:19 +0200 Subject: [PATCH] Add workaround for intermittent resource script errors --- addons/imgui-godot/scripts/ImGuiConfig.gd | 36 +++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/addons/imgui-godot/scripts/ImGuiConfig.gd b/addons/imgui-godot/scripts/ImGuiConfig.gd index d3866ddc..b6894c79 100644 --- a/addons/imgui-godot/scripts/ImGuiConfig.gd +++ b/addons/imgui-godot/scripts/ImGuiConfig.gd @@ -1,11 +1,37 @@ +@tool class_name ImGuiConfig extends Resource -@export_category("Font Settings") -@export var Fonts: Array[ImGuiFont] -@export var AddDefaultFont: bool = true - -@export_category("Other") @export_range(0.25, 4.0, 0.001, "or_greater") var Scale: float = 1.0 @export var IniFilename: String = "user://imgui.ini" @export_enum("RenderingDevice", "Canvas", "Dummy") var Renderer: String = "RenderingDevice" @export_range(-128, 128) var Layer: int = 128 + +@export_category("Font Settings") +#@export var Fonts: Array[ImGuiFont] +@export var AddDefaultFont: bool = true + +# HACK: workaround for intermittent Godot bug +var _fonts: Array + +func _get_property_list() -> Array[Dictionary]: + return [ + { + "name": "Fonts", + "class_name": &"", + "type": TYPE_ARRAY, + "hint": PROPERTY_HINT_TYPE_STRING, + "hint_string": "24/17:ImGuiFont", + "usage": PROPERTY_USAGE_SCRIPT_VARIABLE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE + } + ] + +func _get(property: StringName) -> Variant: + if property == &"Fonts": + return _fonts + return null + +func _set(property: StringName, value: Variant) -> bool: + if property == &"Fonts": + _fonts = value + return true + return false