feat: prompter is now an autoload
This commit is contained in:
parent
a49325eb37
commit
86af2e812a
|
|
@ -38,6 +38,7 @@ PromptManager="*res://addons/input_prompts/input_prompt_manager.gd"
|
||||||
Steam="*res://dev-util/steam.gd"
|
Steam="*res://dev-util/steam.gd"
|
||||||
Main="*res://singletons/main/main.tscn"
|
Main="*res://singletons/main/main.tscn"
|
||||||
I18n="*res://dev-util/i18n.gd"
|
I18n="*res://dev-util/i18n.gd"
|
||||||
|
P="*res://ui/prompter/prompter.tscn"
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ func perform() -> void:
|
||||||
|
|
||||||
func _update_action():
|
func _update_action():
|
||||||
text = action
|
text = action
|
||||||
action_prompt.action = action
|
$ActionPrompt.action = action
|
||||||
|
|
||||||
|
|
||||||
func _override_prompt(prompt: String):
|
func _override_prompt(prompt: String):
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,16 @@ class_name Prompter
|
||||||
signal performed(action: String)
|
signal performed(action: String)
|
||||||
|
|
||||||
var _prompts : Dictionary[StringName, Control] = {}
|
var _prompts : Dictionary[StringName, Control] = {}
|
||||||
|
static var _instance : Prompter = null
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
_register_prompts()
|
_register_prompts()
|
||||||
test()
|
clear()
|
||||||
|
|
||||||
func _register_prompts() -> void:
|
func _register_prompts() -> void:
|
||||||
|
assert(not _instance, "Cannot have two prompters (are you trying to run the prompter itself?)")
|
||||||
|
_instance = self
|
||||||
|
|
||||||
for prompt in get_tree().get_nodes_in_group("prompts") as Array[PromptButton]:
|
for prompt in get_tree().get_nodes_in_group("prompts") as Array[PromptButton]:
|
||||||
_prompts[prompt.name] = prompt
|
_prompts[prompt.name] = prompt
|
||||||
prompt.get_parent().remove_child(prompt)
|
prompt.get_parent().remove_child(prompt)
|
||||||
|
|
@ -24,10 +28,19 @@ func _perform(action : StringName):
|
||||||
performed.emit(action)
|
performed.emit(action)
|
||||||
|
|
||||||
|
|
||||||
func test() -> void:
|
func _clear(container: Control) -> void:
|
||||||
await get_tree().create_timer(0.5).timeout
|
for child in container.get_children():
|
||||||
var prompts := pick("ui_cancel", "ui_accept")
|
container.remove_child(child)
|
||||||
show_left_bottom(prompts)
|
|
||||||
|
|
||||||
|
func _clearInteraction() -> void:
|
||||||
|
%Interaction.text = ""
|
||||||
|
%Interaction.get_parent().hide()
|
||||||
|
|
||||||
|
|
||||||
|
func _clearInstruction() -> void:
|
||||||
|
%Instruction.text = ""
|
||||||
|
%Instruction.get_parent().hide()
|
||||||
|
|
||||||
|
|
||||||
func _show(container: Control, controls: Array[Control], overrides: Array[StringName] = []) -> void:
|
func _show(container: Control, controls: Array[Control], overrides: Array[StringName] = []) -> void:
|
||||||
|
|
@ -38,17 +51,37 @@ func _show(container: Control, controls: Array[Control], overrides: Array[String
|
||||||
control.appear(override)
|
control.appear(override)
|
||||||
|
|
||||||
|
|
||||||
func _clear(container: Control) -> void:
|
|
||||||
for child in container.get_children():
|
func test() -> void:
|
||||||
container.remove_child(child)
|
await get_tree().create_timer(0.5).timeout
|
||||||
|
var prompts := pick("ui_cancel", "ui_accept")
|
||||||
|
show_left_bottom(prompts)
|
||||||
|
interaction("Hello World.")
|
||||||
|
instruction("lorem ipsum dolor sit amet")
|
||||||
|
await get_tree().create_timer(2.5).timeout
|
||||||
|
clear()
|
||||||
|
|
||||||
|
func interaction(text: String) -> void:
|
||||||
|
if not text: _clearInteraction()
|
||||||
|
%Interaction.text = text
|
||||||
|
%Interaction.get_parent().show()
|
||||||
|
|
||||||
|
|
||||||
|
func instruction(text: String) -> void:
|
||||||
|
if not text: _clearInstruction()
|
||||||
|
%Instruction.text = text
|
||||||
|
%Instruction.get_parent().show()
|
||||||
|
|
||||||
|
|
||||||
func show_left_bottom(controls: Array[Control], overrides: Array[StringName] = []) -> void:
|
func show_left_bottom(controls: Array[Control], overrides: Array[StringName] = []) -> void:
|
||||||
_show(%LeftBottom, controls, overrides)
|
_show(%LeftBottom, controls, overrides)
|
||||||
|
|
||||||
|
|
||||||
func clear_left_bottom() -> void:
|
func clear() -> void:
|
||||||
_clear(%LeftBottom)
|
_clear(%LeftBottom)
|
||||||
|
_clear(%RightBottom)
|
||||||
|
_clearInteraction()
|
||||||
|
_clearInstruction()
|
||||||
|
|
||||||
|
|
||||||
## Selects a list of up to three prompts to be passed to the show_xxxxx() functions
|
## Selects a list of up to three prompts to be passed to the show_xxxxx() functions
|
||||||
|
|
|
||||||
|
|
@ -25,46 +25,56 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
mouse_filter = 2
|
||||||
theme_override_constants/margin_left = 42
|
theme_override_constants/margin_left = 42
|
||||||
theme_override_constants/margin_top = 42
|
theme_override_constants/margin_top = 42
|
||||||
theme_override_constants/margin_right = 42
|
theme_override_constants/margin_right = 42
|
||||||
theme_override_constants/margin_bottom = 42
|
theme_override_constants/margin_bottom = 42
|
||||||
script = ExtResource("1_ba0r8")
|
script = ExtResource("1_ba0r8")
|
||||||
|
|
||||||
[node name="SafeZone" type="Control" parent="."]
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
layout_mode = 2
|
layer = 10
|
||||||
|
|
||||||
|
[node name="SafeZone" type="Control" parent="CanvasLayer"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 0
|
||||||
|
offset_left = 42.0
|
||||||
|
offset_top = 42.0
|
||||||
|
offset_right = 1878.0
|
||||||
|
offset_bottom = 1038.0
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
|
|
||||||
[node name="CenterContainer" type="CenterContainer" parent="SafeZone"]
|
[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer/SafeZone"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 1836.0
|
offset_right = 1836.0
|
||||||
offset_bottom = 996.0
|
offset_bottom = 996.0
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
|
|
||||||
[node name="CenterZone" type="MarginContainer" parent="SafeZone/CenterContainer"]
|
[node name="CenterZone" type="MarginContainer" parent="CanvasLayer/SafeZone/CenterContainer"]
|
||||||
custom_minimum_size = Vector2(700, 700)
|
custom_minimum_size = Vector2(700, 700)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_constants/margin_top = 42
|
theme_override_constants/margin_top = 42
|
||||||
theme_override_constants/margin_right = 42
|
theme_override_constants/margin_right = 42
|
||||||
|
|
||||||
[node name="TopCenter" type="PanelContainer" parent="SafeZone/CenterContainer/CenterZone"]
|
[node name="TopCenter" type="PanelContainer" parent="CanvasLayer/SafeZone/CenterContainer/CenterZone"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 0
|
size_flags_vertical = 0
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ba0r8")
|
theme_override_styles/panel = SubResource("StyleBoxFlat_ba0r8")
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="SafeZone/CenterContainer/CenterZone/TopCenter"]
|
[node name="Interaction" type="Label" parent="CanvasLayer/SafeZone/CenterContainer/CenterZone/TopCenter"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "object to interact with"
|
text = "object to interact with"
|
||||||
label_settings = SubResource("LabelSettings_fbpt0")
|
label_settings = SubResource("LabelSettings_fbpt0")
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="CenterAnchor" type="Control" parent="SafeZone/CenterContainer/CenterZone"]
|
[node name="CenterAnchor" type="Control" parent="CanvasLayer/SafeZone/CenterContainer/CenterZone"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 8
|
size_flags_vertical = 8
|
||||||
|
|
||||||
[node name="Center" type="VBoxContainer" parent="SafeZone/CenterContainer/CenterZone/CenterAnchor"]
|
[node name="Center" type="VBoxContainer" parent="CanvasLayer/SafeZone/CenterContainer/CenterZone/CenterAnchor"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 7
|
anchors_preset = 7
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
|
|
@ -81,16 +91,16 @@ size_flags_vertical = 8
|
||||||
theme_override_constants/separation = 48
|
theme_override_constants/separation = 48
|
||||||
alignment = 2
|
alignment = 2
|
||||||
|
|
||||||
[node name="collect_memento_ui" parent="SafeZone/CenterContainer/CenterZone/CenterAnchor/Center" instance=ExtResource("5_fbpt0")]
|
[node name="collect_memento_ui" parent="CanvasLayer/SafeZone/CenterContainer/CenterZone/CenterAnchor/Center" instance=ExtResource("5_fbpt0")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "collect_memento_ui"
|
text = "collect_memento_ui"
|
||||||
|
|
||||||
[node name="option_memento_ui" parent="SafeZone/CenterContainer/CenterZone/CenterAnchor/Center" instance=ExtResource("5_fbpt0")]
|
[node name="option_memento_ui" parent="CanvasLayer/SafeZone/CenterContainer/CenterZone/CenterAnchor/Center" instance=ExtResource("5_fbpt0")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "option_memento_ui"
|
text = "option_memento_ui"
|
||||||
action = &"option_memento_ui"
|
action = &"option_memento_ui"
|
||||||
|
|
||||||
[node name="Top" type="PanelContainer" parent="SafeZone"]
|
[node name="Top" type="PanelContainer" parent="CanvasLayer/SafeZone"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 5
|
anchors_preset = 5
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
|
|
@ -100,20 +110,21 @@ offset_right = 230.5
|
||||||
offset_bottom = 98.33334
|
offset_bottom = 98.33334
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="SafeZone/Top"]
|
[node name="Instruction" type="Label" parent="CanvasLayer/SafeZone/Top"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "a general explanation or hint about what is going on
|
text = "a general explanation or hint about what is going on
|
||||||
or an evaluation such as on the card-board"
|
or an evaluation such as on the card-boardin"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="LeftBottomAnchor" type="Control" parent="SafeZone"]
|
[node name="LeftBottomAnchor" type="Control" parent="CanvasLayer/SafeZone"]
|
||||||
anchors_preset = 0
|
anchors_preset = 0
|
||||||
offset_top = 996.0
|
offset_top = 996.0
|
||||||
offset_bottom = 996.0
|
offset_bottom = 996.0
|
||||||
size_flags_horizontal = 0
|
size_flags_horizontal = 0
|
||||||
size_flags_vertical = 8
|
size_flags_vertical = 8
|
||||||
|
|
||||||
[node name="LeftBottom" type="VBoxContainer" parent="SafeZone/LeftBottomAnchor"]
|
[node name="LeftBottom" type="VBoxContainer" parent="CanvasLayer/SafeZone/LeftBottomAnchor"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 2
|
anchors_preset = 2
|
||||||
|
|
@ -128,20 +139,20 @@ size_flags_vertical = 4
|
||||||
theme_override_constants/separation = 48
|
theme_override_constants/separation = 48
|
||||||
alignment = 2
|
alignment = 2
|
||||||
|
|
||||||
[node name="ui_accept" parent="SafeZone/LeftBottomAnchor/LeftBottom" instance=ExtResource("5_fbpt0")]
|
[node name="ui_accept" parent="CanvasLayer/SafeZone/LeftBottomAnchor/LeftBottom" instance=ExtResource("5_fbpt0")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="ui_cancel" parent="SafeZone/LeftBottomAnchor/LeftBottom" instance=ExtResource("5_fbpt0")]
|
[node name="ui_cancel" parent="CanvasLayer/SafeZone/LeftBottomAnchor/LeftBottom" instance=ExtResource("5_fbpt0")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "ui_cancel"
|
text = "ui_cancel"
|
||||||
action = &"ui_cancel"
|
action = &"ui_cancel"
|
||||||
|
|
||||||
[node name="scene_skip" parent="SafeZone/LeftBottomAnchor/LeftBottom" instance=ExtResource("5_fbpt0")]
|
[node name="scene_skip" parent="CanvasLayer/SafeZone/LeftBottomAnchor/LeftBottom" instance=ExtResource("5_fbpt0")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "scene_skip"
|
text = "scene_skip"
|
||||||
action = &"scene_skip"
|
action = &"scene_skip"
|
||||||
|
|
||||||
[node name="RightBottomAnchor" type="Control" parent="SafeZone"]
|
[node name="RightBottomAnchor" type="Control" parent="CanvasLayer/SafeZone"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 3
|
anchors_preset = 3
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
|
|
@ -153,7 +164,7 @@ offset_top = -40.0
|
||||||
grow_horizontal = 0
|
grow_horizontal = 0
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
|
|
||||||
[node name="RightBottom" type="VBoxContainer" parent="SafeZone/RightBottomAnchor"]
|
[node name="RightBottom" type="VBoxContainer" parent="CanvasLayer/SafeZone/RightBottomAnchor"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 3
|
anchors_preset = 3
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue