fix: tool scripts were causing havoc on inherited scene editing§

This commit is contained in:
tiger tiger tiger 2026-01-23 14:12:12 +01:00
parent f9655a47e6
commit 6b9a338a20
5 changed files with 32 additions and 21 deletions

View File

@ -47,6 +47,7 @@ func _update_events():
# TODO: Find a cleaner way to cast these values # TODO: Find a cleaner way to cast these values
var tmp: Array = [] var tmp: Array = []
if Engine.is_editor_hint(): if Engine.is_editor_hint():
print("reading project settings")
tmp = ProjectSettings.get_setting("input/" + action)["events"] tmp = ProjectSettings.get_setting("input/" + action)["events"]
else: else:
tmp = InputMap.action_get_events(action) tmp = InputMap.action_get_events(action)

View File

@ -72,6 +72,7 @@ import/blender/enabled=false
interactables="" interactables=""
signage2="" signage2=""
signage1="" signage1=""
prompts="All PromptButton inheritors."
[gui] [gui]

View File

@ -4,35 +4,34 @@ extends Button
class_name PromptButton class_name PromptButton
var _action : StringName var _action : StringName
var _override : String
@export_custom(PROPERTY_HINT_INPUT_NAME, "show_builtin") var action : StringName = &"ui_accept": @export_custom(PROPERTY_HINT_INPUT_NAME, "show_builtin") var action : StringName = &"ui_accept":
set(value): set(value):
_action = value
if is_node_ready(): if is_node_ready():
_set_action(value) _update_action()
else: else:
_set_action.call_deferred(value) _update_action.call_deferred()
get: return _action get: return _action
func _set_action(value: StringName): func _update_action():
if _action == text or not text or not _action: text = _action
text = value
_action = value
$ActionPrompt.action = _action $ActionPrompt.action = _action
func appear(prompt: String = "") -> void:
assert(not _override, "Prompt is already in use, overridden from '" + _override + "' to '" + text + "'") func _override_prompt(prompt: String):
if prompt: if prompt:
_override = text
text = prompt text = prompt
else:
text = action
func appear(prompt: String = "") -> void:
_override_prompt(prompt)
show() show()
func vanish() -> void: func vanish() -> void:
hide() hide()
if _override:
text = _override
_override = ""
else:
text = action # TODO: this is a bit backwards and doesn't allow manual overrides in editor

View File

@ -16,23 +16,25 @@ unicode = 4194310
device = -1 device = -1
pressed = true pressed = true
[node name="PromptButton" type="Button"] [node name="PromptButton" type="Button" groups=["prompts"]]
text = "ui_accept" text = "ui_accept"
script = ExtResource("1_j4nun") script = ExtResource("1_j4nun")
[node name="ActionPrompt" type="TextureRect" parent="."] [node name="ActionPrompt" type="TextureRect" parent="."]
custom_minimum_size = Vector2(32, 32) clip_contents = true
custom_minimum_size = Vector2(58, 58)
layout_mode = 1 layout_mode = 1
anchors_preset = 4 anchors_preset = 4
anchor_top = 0.5 anchor_top = 0.5
anchor_bottom = 0.5 anchor_bottom = 0.5
offset_left = -90.0 offset_left = -64.0
offset_top = -50.0 offset_top = -29.0
offset_right = 10.0 offset_right = -6.0
offset_bottom = 50.0 offset_bottom = 29.0
grow_vertical = 2 grow_vertical = 2
size_flags_vertical = 3 size_flags_vertical = 3
texture = ExtResource("2_3b7la") texture = ExtResource("2_3b7la")
expand_mode = 2
stretch_mode = 5 stretch_mode = 5
script = ExtResource("3_flaeu") script = ExtResource("3_flaeu")
action = "ui_accept" action = "ui_accept"

View File

@ -4,3 +4,11 @@ class_name Prompter
signal action_performed(action: String) signal action_performed(action: String)
var _prompts : Dictionary[StringName, Control] = {}
func _ready() -> void:
for prompt in get_tree().get_nodes_in_group("prompts"):
_prompts[prompt.name] = prompt
prompt.get_parent().remove_child(prompt)
print(prompt)