From bebcd640e1cc58026cbc6653732da2278f35867d Mon Sep 17 00:00:00 2001 From: Matteo Piccina Date: Thu, 11 Jan 2024 19:19:16 +0100 Subject: [PATCH] Add popup poc --- tools/configurator/components/popup.gd | 19 +++++++++++ tools/configurator/components/popup.tscn | 39 ++++++++++++++++++++++ tools/configurator/main.gd | 6 ++++ tools/configurator/main.tscn | 5 +-- tools/configurator/popup_content_test.tscn | 15 +++++++++ 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 tools/configurator/components/popup.gd create mode 100644 tools/configurator/components/popup.tscn create mode 100644 tools/configurator/popup_content_test.tscn diff --git a/tools/configurator/components/popup.gd b/tools/configurator/components/popup.gd new file mode 100644 index 00000000..6087eb90 --- /dev/null +++ b/tools/configurator/components/popup.gd @@ -0,0 +1,19 @@ +extends Control + +var content = null + +# Called when the node enters the scene tree for the first time. +func _ready(): + if (content != null): + $Panel/VBoxContainer/ContentContainer.add_child(content) + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func set_content(new_content): + content = load(new_content).instantiate() + +func _on_back_pressed(): + queue_free() diff --git a/tools/configurator/components/popup.tscn b/tools/configurator/components/popup.tscn new file mode 100644 index 00000000..429d4986 --- /dev/null +++ b/tools/configurator/components/popup.tscn @@ -0,0 +1,39 @@ +[gd_scene load_steps=2 format=3 uid="uid://ixg127wfv7wo"] + +[ext_resource type="Script" path="res://components/popup.gd" id="1_ck1vn"] + +[node name="Popup" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_ck1vn") + +[node name="Panel" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="Panel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Button" type="Button" parent="Panel/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 0 +text = "Back" + +[node name="ContentContainer" type="Panel" parent="Panel/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[connection signal="pressed" from="Panel/VBoxContainer/Button" to="." method="_on_back_pressed"] diff --git a/tools/configurator/main.gd b/tools/configurator/main.gd index a91e71fe..27ba1a84 100644 --- a/tools/configurator/main.gd +++ b/tools/configurator/main.gd @@ -19,3 +19,9 @@ func findElements(node: Node, className: String, result: Array = []) -> Array: func _on_control_mouse_entered(control: Node): control.grab_focus() + + +func _on_quickresume_advanced_pressed(): + var popup = load("res://components/popup.tscn").instantiate() as Control + popup.set_content("res://popup_content_test.tscn") + $Background.add_child(popup) diff --git a/tools/configurator/main.tscn b/tools/configurator/main.tscn index f515eaed..963c229d 100644 --- a/tools/configurator/main.tscn +++ b/tools/configurator/main.tscn @@ -104,11 +104,9 @@ grow_vertical = 2 [node name="TabContainer" type="TabContainer" parent="Background/MarginContainer"] layout_mode = 2 tab_alignment = 1 -current_tab = 7 script = ExtResource("3_id6l4") [node name="System" type="MarginContainer" parent="Background/MarginContainer/TabContainer"] -visible = false layout_mode = 2 theme_override_constants/margin_right = 240 @@ -719,6 +717,7 @@ size_flags_vertical = 1 text = "|| ------( )--------" [node name="About" type="MarginContainer" parent="Background/MarginContainer/TabContainer"] +visible = false layout_mode = 2 theme_override_constants/margin_right = 240 @@ -907,3 +906,5 @@ frame_progress = 0.299789 sprite_frames = SubResource("SpriteFrames_p8gbs") animation = &"speech" frame_progress = 0.664627 + +[connection signal="pressed" from="Background/MarginContainer/TabContainer/System/ScrollContainer/VBoxContainer/game_control_container/GridContainer/Button" to="." method="_on_quickresume_advanced_pressed"] diff --git a/tools/configurator/popup_content_test.tscn b/tools/configurator/popup_content_test.tscn new file mode 100644 index 00000000..1086382c --- /dev/null +++ b/tools/configurator/popup_content_test.tscn @@ -0,0 +1,15 @@ +[gd_scene format=3 uid="uid://bihon3xtx45y7"] + +[node name="PopupContentTest" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Button" type="Button" parent="."] +layout_mode = 1 +offset_right = 12.0 +offset_bottom = 8.0 +text = "Test"