generated from SGDA/GodotExampleProject
feat: interactibles now emit signals and are parametrable through text and ids
This commit is contained in:
@ -1,17 +1,35 @@
|
||||
extends Area2D
|
||||
class_name Interactible
|
||||
|
||||
@export_file("*.tscn") var scene_to_trigger : String
|
||||
# @export_file("*.tscn") var scene_to_trigger: String
|
||||
@export var message: String
|
||||
@export var event: String
|
||||
|
||||
signal event_triggered(event_id: String)
|
||||
|
||||
@onready var rich_text_label: RichTextLabel = $RichTextLabel
|
||||
|
||||
@onready var confirm_panel: Panel = %ConfirmPanel
|
||||
@onready var message_box: Label = %MessageBox
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
rich_text_label.visible = false
|
||||
confirm_panel.visible = false
|
||||
message_box.text = message.to_upper()
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
rich_text_label.visible = true
|
||||
|
||||
func _on_body_exited(body: Node2D) -> void:
|
||||
rich_text_label.visible = false
|
||||
confirm_panel.visible = false
|
||||
|
||||
func show_confirm():
|
||||
confirm_panel.visible = true
|
||||
|
||||
func _on_confirm_button_pressed() -> void:
|
||||
confirm_panel.visible = false
|
||||
event_triggered.emit(event)
|
||||
|
||||
func _on_cancel_button_pressed() -> void:
|
||||
confirm_panel.visible = false
|
||||
|
@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cjo7jm55bkqk3"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cjo7jm55bkqk3"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dl18owt8pb11r" path="res://scenes/interactibles/interactible.gd" id="1_7dp4u"]
|
||||
[ext_resource type="FontFile" uid="uid://detctsm8oy251" path="res://assets/PansyHand/pansyhand.ttf" id="2_u3pc4"]
|
||||
[ext_resource type="Script" uid="uid://1nf36h0gms3q" path="res://addons/maaacks_menus_template/base/scripts/capture_focus.gd" id="3_dyo5s"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_oyfc1"]
|
||||
radius = 20.0
|
||||
@ -23,5 +24,70 @@ offset_bottom = 23.0
|
||||
theme_override_fonts/normal_font = ExtResource("2_u3pc4")
|
||||
text = "INTERACT"
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -140.0
|
||||
offset_top = -151.0
|
||||
offset_right = 140.0
|
||||
offset_bottom = -31.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="ConfirmPanel" type="Panel" parent="CenterContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(280, 120)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/ConfirmPanel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MessageBox" type="Label" parent="CenterContainer/ConfirmPanel/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "ENTRER DANS LA POSTE ?"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="CenterContainer/ConfirmPanel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/ConfirmPanel/VBoxContainer/CenterContainer"]
|
||||
custom_minimum_size = Vector2(256, 0)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 16
|
||||
script = ExtResource("3_dyo5s")
|
||||
|
||||
[node name="ConfirmButton" type="Button" parent="CenterContainer/ConfirmPanel/VBoxContainer/CenterContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "FUCK YES"
|
||||
|
||||
[node name="CancelButton" type="Button" parent="CenterContainer/ConfirmPanel/VBoxContainer/CenterContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "OH HELL NAH"
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
[connection signal="body_exited" from="." to="." method="_on_body_exited"]
|
||||
[connection signal="pressed" from="CenterContainer/ConfirmPanel/VBoxContainer/CenterContainer/HBoxContainer/ConfirmButton" to="." method="_on_confirm_button_pressed"]
|
||||
[connection signal="pressed" from="CenterContainer/ConfirmPanel/VBoxContainer/CenterContainer/HBoxContainer/CancelButton" to="." method="_on_cancel_button_pressed"]
|
||||
|
Reference in New Issue
Block a user