Compare commits

..

2 Commits

12 changed files with 266 additions and 48 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

@ -111,10 +111,6 @@ var last_mode := DisplayServer.WINDOW_MODE_WINDOWED
func _unhandled_input(event: InputEvent) -> void: func _unhandled_input(event: InputEvent) -> void:
#if event.is_action_type(): print_debug("Unhandled Input", event) #if event.is_action_type(): print_debug("Unhandled Input", event)
if event.is_action_pressed("ui_pause") and state == AppState.PLAY:
state = AppState.PAUSE
get_viewport().set_input_as_handled()
if not Engine.is_editor_hint(): if not Engine.is_editor_hint():
if event.is_action_pressed("toggle_fullscreen"): if event.is_action_pressed("toggle_fullscreen"):
get_viewport().set_input_as_handled() get_viewport().set_input_as_handled()

View File

@ -16,12 +16,15 @@ func _ready() -> void:
helpline_button.pressed.connect(func(): OS.shell_open("https://findahelpline.com/")) helpline_button.pressed.connect(func(): OS.shell_open("https://findahelpline.com/"))
#skip_story_button.pressed.connect(_process) #skip_story_button.pressed.connect(_process)
func _on_help_pressed(): func _on_help_pressed() -> void:
OS.shell_open("https://findahelpline.com/") OS.shell_open("https://findahelpline.com/")
var last_mouse_mode: Input.MouseMode var last_mouse_mode: Input.MouseMode
func appear(): func appear() -> void:
State.save_game.save_to_file(get_tree().root.get_texture()) if State.save_game:
State.save_game.save_to_file(get_tree().root.get_texture())
else:
push_warning("No save game exists.")
get_tree().paused = true get_tree().paused = true
show() show()
@ -30,12 +33,17 @@ func appear():
%ResumeButton.grab_focus.call_deferred() %ResumeButton.grab_focus.call_deferred()
func disappear(): func disappear() -> void:
Main.state = Main.AppState.PLAY Main.state = Main.AppState.PLAY
hide() hide()
Input.mouse_mode = last_mouse_mode Input.mouse_mode = last_mouse_mode
get_tree().paused = false get_tree().paused = false
func _unhandled_input(_event: InputEvent) -> void:
if not visible: return func _unhandled_input(event: InputEvent) -> void:
get_viewport().set_input_as_handled() if not visible:
return
if event.is_action_pressed("ui_pause") and Main.state == Main.AppState.PLAY:
Main.state = Main.AppState.PAUSE
get_viewport().set_input_as_handled()

View File

@ -0,0 +1,6 @@
extends Node
func _gui_input(event : InputEvent):
for child in get_children():
if child.has_method("_gui_input"):
child._gui_input(event)

View File

@ -0,0 +1 @@
uid://cjhic61ivhauc

View File

@ -0,0 +1,37 @@
@tool
extends Button
## A button representing a specific action, and offering a default prompt that can be changed
class_name PromptButton
var _action : StringName
@export_custom(PROPERTY_HINT_INPUT_NAME, "show_builtin") var action : StringName = &"ui_accept":
set(value):
_action = value
if is_node_ready():
_update_action()
else:
_update_action.call_deferred()
get: return _action
func _update_action():
text = _action
$ActionPrompt.action = _action
func _override_prompt(prompt: String):
if prompt:
text = prompt
else:
text = action
func appear(prompt: String = "") -> void:
_override_prompt(prompt)
show()
func vanish() -> void:
hide()

View File

@ -0,0 +1 @@
uid://d3gymb7uc8pkc

View File

@ -0,0 +1,42 @@
[gd_scene load_steps=7 format=3 uid="uid://nvbffevo54eh"]
[ext_resource type="Script" uid="uid://d3gymb7uc8pkc" path="res://ui/prompter/prompt_button.gd" id="1_j4nun"]
[ext_resource type="Texture2D" uid="uid://b7breoabkyifr" path="res://addons/input_prompts/icons/xbox/A.png" id="2_3b7la"]
[ext_resource type="Script" uid="uid://bbs1u7ojno7xo" path="res://addons/input_prompts/action_prompt/action_prompt.gd" id="3_flaeu"]
[sub_resource type="InputEventKey" id="InputEventKey_j4nun"]
keycode = 4194309
unicode = 4194309
[sub_resource type="InputEventKey" id="InputEventKey_3b7la"]
keycode = 4194310
unicode = 4194310
[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_flaeu"]
device = -1
pressed = true
[node name="PromptButton" type="Button" groups=["prompts"]]
text = "ui_accept"
script = ExtResource("1_j4nun")
[node name="ActionPrompt" type="TextureRect" parent="."]
clip_contents = true
custom_minimum_size = Vector2(58, 58)
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = -64.0
offset_top = -29.0
offset_right = -6.0
offset_bottom = 29.0
grow_vertical = 2
size_flags_vertical = 3
texture = ExtResource("2_3b7la")
expand_mode = 2
stretch_mode = 5
script = ExtResource("3_flaeu")
action = "ui_accept"
icon = 0
events = Array[InputEvent]([SubResource("InputEventKey_j4nun"), SubResource("InputEventKey_3b7la"), SubResource("InputEventJoypadButton_flaeu")])

View File

@ -0,0 +1,14 @@
extends Control
## Provides methods and pre-instantiated prompts that can be easily arranged.
class_name Prompter
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)

View File

@ -0,0 +1 @@
uid://de6ettn5s20va

View File

@ -1,17 +1,23 @@
[gd_scene load_steps=5 format=3 uid="uid://btmlxxbucfqa7"] [gd_scene load_steps=6 format=3 uid="uid://btmlxxbucfqa7"]
[ext_resource type="Texture2D" uid="uid://615hvpuiacvm" path="res://addons/input_prompts/icons/xbox/X.png" id="1_uowr1"] [ext_resource type="Script" uid="uid://de6ettn5s20va" path="res://ui/prompter/prompter.gd" id="1_ba0r8"]
[ext_resource type="Script" uid="uid://bbs1u7ojno7xo" path="res://addons/input_prompts/action_prompt/action_prompt.gd" id="2_xtx06"] [ext_resource type="FontFile" uid="uid://c5ql8u7tpd10j" path="res://import/fonts/KleeOne-SemiBold.ttf" id="3_xtx06"]
[ext_resource type="PackedScene" uid="uid://nvbffevo54eh" path="res://ui/prompter/prompt_button.tscn" id="5_fbpt0"]
[sub_resource type="InputEventKey" id="InputEventKey_uowr1"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ba0r8"]
device = -1 bg_color = Color(0, 0, 0, 0.5019608)
physical_keycode = 88 corner_radius_top_left = 10
unicode = 120 corner_radius_top_right = 10
corner_radius_bottom_right = 10
corner_radius_bottom_left = 10
[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_xtx06"] [sub_resource type="LabelSettings" id="LabelSettings_fbpt0"]
device = -1 font = ExtResource("3_xtx06")
button_index = 2 font_size = 48
pressed = true outline_size = 4
outline_color = Color(0, 0, 0, 1)
shadow_size = 4
shadow_color = Color(0, 0, 0, 0.78431374)
[node name="Prompter" type="MarginContainer"] [node name="Prompter" type="MarginContainer"]
anchors_preset = 15 anchors_preset = 15
@ -23,42 +29,146 @@ 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")
[node name="CenterContainer" type="CenterContainer" parent="."] [node name="SafeZone" type="Control" parent="."]
layout_mode = 2 layout_mode = 2
mouse_filter = 2
[node name="MarginContainer" type="MarginContainer" parent="CenterContainer"] [node name="CenterContainer" type="CenterContainer" parent="SafeZone"]
custom_minimum_size = Vector2(500, 500) layout_mode = 0
offset_right = 1836.0
offset_bottom = 996.0
mouse_filter = 2
[node name="MarginContainer" type="MarginContainer" parent="SafeZone/CenterContainer"]
custom_minimum_size = Vector2(700, 700)
layout_mode = 2 layout_mode = 2
theme_override_constants/margin_top = 42
theme_override_constants/margin_right = 42
[node name="VPrompt" type="VBoxContainer" parent="CenterContainer/MarginContainer"] [node name="TopCenter" type="PanelContainer" parent="SafeZone/CenterContainer/MarginContainer"]
custom_minimum_size = Vector2(480, 80) layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_ba0r8")
[node name="Label" type="Label" parent="SafeZone/CenterContainer/MarginContainer/TopCenter"]
layout_mode = 2
text = "object to interact with"
label_settings = SubResource("LabelSettings_fbpt0")
horizontal_alignment = 1
[node name="Control" type="Control" parent="SafeZone/CenterContainer/MarginContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 4 size_flags_horizontal = 4
size_flags_vertical = 8 size_flags_vertical = 8
[node name="CenterContainer" type="CenterContainer" parent="CenterContainer/MarginContainer/VPrompt"] [node name="VBoxContainer" type="VBoxContainer" parent="SafeZone/CenterContainer/MarginContainer/Control"]
custom_minimum_size = Vector2(32, 32) layout_mode = 1
layout_mode = 2 anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -157.0
offset_top = -144.0
offset_right = 253.0
grow_horizontal = 2
grow_vertical = 0
size_flags_horizontal = 4
size_flags_vertical = 8
theme_override_constants/separation = 48
alignment = 2
[node name="ActionPrompt" type="TextureRect" parent="CenterContainer/MarginContainer/VPrompt/CenterContainer"] [node name="collect_memento_ui" parent="SafeZone/CenterContainer/MarginContainer/Control/VBoxContainer" instance=ExtResource("5_fbpt0")]
unique_name_in_owner = true
custom_minimum_size = Vector2(48, 48)
layout_mode = 2
size_flags_vertical = 3
texture = ExtResource("1_uowr1")
stretch_mode = 5
script = ExtResource("2_xtx06")
action = "scene_skip"
icon = 0
events = Array[InputEvent]([null, SubResource("InputEventKey_uowr1"), SubResource("InputEventJoypadButton_xtx06")])
[node name="SkipButton" type="Button" parent="CenterContainer/MarginContainer/VPrompt"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 text = "collect_memento_ui"
text = "reveal full text (hold)" action = &"collect_memento_ui"
[connection signal="button_down" from="CenterContainer/MarginContainer/VPrompt/SkipButton" to="CenterContainer/MarginContainer/VPrompt" method="_on_skip_button_button_down"] [node name="option_memento_ui" parent="SafeZone/CenterContainer/MarginContainer/Control/VBoxContainer" instance=ExtResource("5_fbpt0")]
[connection signal="button_up" from="CenterContainer/MarginContainer/VPrompt/SkipButton" to="CenterContainer/MarginContainer/VPrompt" method="_on_skip_button_button_up"] unique_name_in_owner = true
[connection signal="toggled" from="CenterContainer/MarginContainer/VPrompt/SkipButton" to="CenterContainer/MarginContainer/VPrompt" method="_on_skip_button_toggled"] layout_mode = 2
text = "option_memento_ui"
action = &"option_memento_ui"
[node name="Top" type="PanelContainer" parent="SafeZone"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -230.5
offset_right = 230.5
offset_bottom = 98.33334
grow_horizontal = 2
[node name="Label" type="Label" parent="SafeZone/Top"]
layout_mode = 2
text = "a general explanation or hint about what is going on
or an evaluation such as on the card-board"
horizontal_alignment = 1
[node name="LeftBottom" type="Control" parent="SafeZone"]
anchors_preset = 0
offset_top = 996.0
offset_bottom = 996.0
size_flags_horizontal = 0
size_flags_vertical = 8
[node name="VBox" type="VBoxContainer" parent="SafeZone/LeftBottom"]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 64.0
offset_top = -240.0
offset_right = 386.0
grow_vertical = 0
size_flags_horizontal = 0
size_flags_vertical = 4
theme_override_constants/separation = 48
alignment = 2
[node name="Accept" parent="SafeZone/LeftBottom/VBox" instance=ExtResource("5_fbpt0")]
unique_name_in_owner = true
layout_mode = 2
[node name="Cancel" parent="SafeZone/LeftBottom/VBox" instance=ExtResource("5_fbpt0")]
unique_name_in_owner = true
layout_mode = 2
text = "ui_cancel"
action = &"ui_cancel"
[node name="Skip" parent="SafeZone/LeftBottom/VBox" instance=ExtResource("5_fbpt0")]
layout_mode = 2
text = "scene_skip"
action = &"scene_skip"
[node name="RightBottom" type="Control" parent="SafeZone"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -40.0
offset_top = -40.0
grow_horizontal = 0
grow_vertical = 0
[node name="VBox" type="VBoxContainer" parent="SafeZone/RightBottom"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -322.0
offset_top = -240.0
grow_horizontal = 0
grow_vertical = 0
size_flags_horizontal = 0
size_flags_vertical = 4
theme_override_constants/separation = 48
alignment = 2