Skip to content

Commit c252db7

Browse files
author
Justin Davis
committed
fix: remove hardcoded paths in addon scripts
- Replace hardcoded 'res://addons/godot_pulse/' paths with dynamic script-relative paths - plugin.gd: Use get_script().get_path() for autoload registration - CustomPanel.gd: Dynamically locate MetricRow.gd relative to current script - MetricRow.gd: Dynamically locate MiniGraph.gd in sibling widgets directory - Update packaged godot_pulse_v1.0.0.zip with fixes This enables the addon to be relocated without breaking internal script references.
1 parent afd3b1e commit c252db7

5 files changed

Lines changed: 15 additions & 4 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"tar": true,
1414
"git config": true,
15-
"git commit": true
15+
"git commit": true,
16+
"git add": true
1617
}
1718
}

addons/godot_pulse/plugin.gd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ func _enter_tree() -> void:
99

1010
# Check if we have .NET support before registering the C# autoload
1111
if OS.has_feature("dotnet"):
12-
add_autoload_singleton("GodotPulse", "res://addons/godot_pulse/autoload/GodotPulse.cs")
12+
# Dynamically construct autoload path based on plugin location
13+
var plugin_dir = get_script().get_path().get_basename().get_basename()
14+
var autoload_path = plugin_dir + "/autoload/GodotPulse.cs"
15+
add_autoload_singleton("GodotPulse", autoload_path)
1316
else:
1417
printerr("GodotPulse: .NET support not detected. Core sampling will be disabled.")
1518

addons/godot_pulse/ui/panels/CustomPanel.gd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ func _process(_delta: float) -> void:
5050

5151
func _create_metric_row(name: String) -> HBoxContainer:
5252
var row = HBoxContainer.new()
53-
row.set_script(load("res://addons/godot_pulse/ui/panels/MetricRow.gd"))
53+
# Dynamically construct path relative to this script
54+
var current_dir = get_script().get_path().get_basename()
55+
var metric_row_path = current_dir + "/MetricRow.gd"
56+
row.set_script(load(metric_row_path))
5457
row.set_meta("metric_name", name)
5558
return row

addons/godot_pulse/ui/panels/MetricRow.gd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ func _init() -> void:
1919

2020
_graph = Control.new()
2121
_graph.custom_minimum_size = Vector2(50, 20)
22-
_graph.set_script(load("res://addons/godot_pulse/ui/widgets/MiniGraph.gd"))
22+
# Dynamically construct path to MiniGraph in sibling widgets directory
23+
var panels_dir = get_script().get_path().get_basename()
24+
var widgets_dir = panels_dir.get_basename() # Go up to ui directory
25+
var mini_graph_path = widgets_dir + "/widgets/MiniGraph.gd"
26+
_graph.set_script(load(mini_graph_path))
2327

2428
add_child(_label)
2529
add_child(_value_label)

godot_pulse_v1.0.0.zip

370 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)