move file dialog to unloaded scene
This commit is contained in:
parent
8b1fe0a9be
commit
b2c9bbf9a2
|
@ -2,12 +2,6 @@ extends Control
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
$FileDialog.mode = FileDialog.FILE_MODE_OPEN_FILE
|
||||
$FileDialog.access = FileDialog.ACCESS_FILESYSTEM
|
||||
$FileDialog.use_native_dialog = true
|
||||
|
||||
$MarginContainer/Unloaded/Button.pressed.connect(_on_button_pressed)
|
||||
|
||||
Global.state_changed.connect(_update_state)
|
||||
if Global.current_state == Global.State.UNLOADED:
|
||||
pass
|
||||
|
@ -17,17 +11,6 @@ func _ready():
|
|||
var current_scene = s.instantiate()
|
||||
$MarginContainer.add_child(current_scene)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
func _on_button_pressed():
|
||||
$FileDialog.show()
|
||||
print("button pressed")
|
||||
|
||||
func _on_file_dialog_file_selected(path):
|
||||
Global.load_db(path)
|
||||
|
||||
func _update_state(old: Global.State, new: Global.State):
|
||||
print("updated state")
|
||||
pass
|
||||
|
||||
|
|
|
@ -27,7 +27,3 @@ metadata/_edit_use_anchors_ = true
|
|||
|
||||
[node name="Unloaded" parent="MarginContainer" instance=ExtResource("2_diny5")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="FileDialog" type="FileDialog" parent="."]
|
||||
|
||||
[connection signal="file_selected" from="FileDialog" to="." method="_on_file_dialog_file_selected"]
|
||||
|
|
12
godot/unloaded.gd
Normal file
12
godot/unloaded.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends CenterContainer
|
||||
|
||||
func _ready():
|
||||
$FileDialog.mode = FileDialog.FILE_MODE_OPEN_FILE
|
||||
$FileDialog.access = FileDialog.ACCESS_FILESYSTEM
|
||||
$FileDialog.use_native_dialog = true
|
||||
|
||||
func _on_button_pressed():
|
||||
$FileDialog.show()
|
||||
|
||||
func _on_file_dialog_file_selected(path):
|
||||
Global.load_db(path)
|
|
@ -1,8 +1,16 @@
|
|||
[gd_scene format=3 uid="uid://b71wpb1vts86r"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://b71wpb1vts86r"]
|
||||
|
||||
[ext_resource type="Script" path="res://unloaded.gd" id="1_ibvef"]
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer"]
|
||||
script = ExtResource("1_ibvef")
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
custom_minimum_size = Vector2(200, 200)
|
||||
layout_mode = 2
|
||||
text = "Load database"
|
||||
|
||||
[node name="FileDialog" type="FileDialog" parent="."]
|
||||
|
||||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||
[connection signal="file_selected" from="FileDialog" to="." method="_on_file_dialog_file_selected"]
|
||||
|
|
Loading…
Reference in a new issue