Skip to content

Commit 59c78ae

Browse files
authored
Escape GaeaEditorSettings calls during runtime (#577)
* Escape GaeaEditorSettings calls during runtime
1 parent 1127f6d commit 59c78ae

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

addons/gaea/editor/graph_editor/graph_edit.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ func _on_scroll_offset_changed(offset: Vector2) -> void:
774774

775775

776776
func _on_editor_script_changed(script: Script):
777-
var editor := EditorInterface.get_script_editor().get_current_editor()
777+
var editor: ScriptEditorBase = EditorInterface.get_script_editor().get_current_editor()
778778
if not editor.edited_script_changed.is_connected(_on_edited_script_changed):
779779
editor.edited_script_changed.connect(_on_edited_script_changed.bind(script))
780780

addons/gaea/graph/graph_nodes/graph_node.gd

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ func _open_preview(for_output: StringName) -> void:
237237

238238
func _set_titlebar() -> void:
239239
var type: GaeaValue.Type = resource.get_type()
240+
var base_color: Color = resource.get_title_color()
240241
var titlebar: StyleBoxFlat
241242
var titlebar_selected: StyleBoxFlat
242243
if type != GaeaValue.Type.NULL:
@@ -246,19 +247,19 @@ func _set_titlebar() -> void:
246247
not _titlebar_styleboxes.has(type)
247248
or (
248249
_titlebar_styleboxes.get(type).get("for_color", Color.TRANSPARENT)
249-
!= resource.get_title_color()
250+
!= base_color
250251
)
251252
):
252253
titlebar = get_theme_stylebox("titlebar", "GraphNode").duplicate()
253254
titlebar_selected = get_theme_stylebox("titlebar_selected", "GraphNode").duplicate()
254-
titlebar.bg_color = titlebar.bg_color.blend(Color(resource.get_title_color(), 0.3))
255+
titlebar.bg_color = titlebar.bg_color.blend(Color(base_color, 0.3))
255256
titlebar_selected.bg_color = titlebar.bg_color
256257
_titlebar_styleboxes.set(
257258
type,
258259
{
259260
"titlebar": titlebar,
260261
"selected": titlebar_selected,
261-
"for_color": resource.get_title_color()
262+
"for_color": base_color
262263
}
263264
)
264265
else:

addons/gaea/graph/graph_nodes/special/output/output_node_resource.gd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ func _get_scene_script() -> GDScript:
8989

9090
## Output nodes have a special titlebar color.
9191
func get_title_color() -> Color:
92-
return GaeaEditorSettings.get_configured_output_color()
92+
if Engine.is_editor_hint():
93+
# gdlint:ignore = duplicated-load
94+
var gaea_editor_settings: GDScript = load("uid://duu3vekk7pxwk")
95+
return gaea_editor_settings.get_configured_output_color()
96+
return super()
9397

9498

9599
func _get_output_ports_list() -> Array[StringName]:

addons/gaea/resources/gaea_value.gd

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ static func get_type_string(type: Type) -> String:
6969
return String(Type.find_key(type)).capitalize().replace(" ", "")
7070

7171

72-
## Returns the configured color for slots of [param type].
73-
static func get_color(type: Type) -> Color:
74-
if GaeaEditorSettings.CONFIGURABLE_SLOT_COLORS.has(type):
75-
return GaeaEditorSettings.get_configured_color_for_value_type(type)
76-
return get_default_color(type)
77-
78-
7972
## Returns the default value for [param type]. Returns [code]null[/code] if there's none.
8073
static func get_default_value(type: Type) -> Variant:
8174
match type:
@@ -157,6 +150,16 @@ static func from_old_slot_type(old_type: int) -> GaeaValue.Type:
157150
return GaeaValue.Type.NULL
158151

159152

153+
## Returns the configured color for slots of [param type].
154+
static func get_color(type: Type) -> Color:
155+
if Engine.is_editor_hint():
156+
# gdlint:ignore = duplicated-load
157+
var gaea_editor_settings: GDScript = load("uid://duu3vekk7pxwk")
158+
if gaea_editor_settings.CONFIGURABLE_SLOT_COLORS.has(type):
159+
return gaea_editor_settings.get_configured_color_for_value_type(type)
160+
return get_default_color(type)
161+
162+
160163
## Returns the default color for slots of [param type].
161164
static func get_default_color(type: Type) -> Color:
162165
match type:
@@ -210,8 +213,8 @@ static func get_display_icon(type: Type) -> Texture2D:
210213
Type.MATERIAL:
211214
return load("uid://b0vqox8bodse")
212215
Type.TEXTURE:
213-
var editor_interface = Engine.get_singleton("EditorInterface")
214-
return editor_interface.get_base_control().get_theme_icon(&"Image", &"EditorIcons")
216+
if Engine.is_editor_hint():
217+
return Engine.get_singleton(&"EditorInterface").get_base_control().get_theme_icon(&"Image", &"EditorIcons")
215218
# Dictionary types
216219
Type.SAMPLE:
217220
return load("uid://dkccxw7yq1mth")
@@ -222,8 +225,11 @@ static func get_display_icon(type: Type) -> Texture2D:
222225

223226
## Returns the configured icon for slots of [param type].
224227
static func get_slot_icon(type: Type) -> Texture2D:
225-
if GaeaEditorSettings.CONFIGURABLE_SLOT_COLORS.has(type):
226-
return GaeaEditorSettings.get_configured_icon_for_value_type(type)
228+
if Engine.is_editor_hint():
229+
# gdlint:ignore = duplicated-load
230+
var gaea_editor_settings: GDScript = load("uid://duu3vekk7pxwk")
231+
if gaea_editor_settings.CONFIGURABLE_SLOT_COLORS.has(type):
232+
return gaea_editor_settings.get_configured_icon_for_value_type(type)
227233
return get_default_slot_icon(type)
228234

229235

@@ -240,7 +246,8 @@ static func get_default_slot_icon(type: Type) -> Texture2D:
240246
Type.VECTOR3I, Type.VECTOR3:
241247
return load("uid://dbvw3j8fnmhpu")
242248
Type.ANY:
243-
return EditorInterface.get_editor_theme().get_icon("NodeInfo", "EditorIcons")
249+
if Engine.is_editor_hint():
250+
return Engine.get_singleton(&"EditorInterface").get_editor_theme().get_icon("NodeInfo", "EditorIcons")
244251
# Simple types
245252
Type.RANGE:
246253
return load("uid://dfsmxavxasx7x")

0 commit comments

Comments
 (0)