Add popup poc

This commit is contained in:
Matteo Piccina 2024-01-11 19:19:16 +01:00
parent e383af3964
commit bebcd640e1
5 changed files with 82 additions and 2 deletions

View file

@ -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()

View file

@ -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"]

View file

@ -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)

View file

@ -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"]

View file

@ -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"