Merge pull request '[Feature]: Scenen Wechsel' (!1) from task/td-37-scene-management into trunk
All checks were successful
Quality Check / Linting (push) Successful in 6s

Reviewed-on: #1
Reviewed-by: SZUT-Kevin <kevin.schmidt@hmmh.de>
This commit is contained in:
Snoweuph 2025-02-12 12:55:12 +00:00 committed by Euph Forge
commit fd00046f84
Signed by: Euph Forge
GPG key ID: 85A06461FB6BDBB7
3 changed files with 11 additions and 8 deletions

View file

@ -1,8 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://bqfijb7bk2g7j"]
[gd_scene load_steps=3 format=3 uid="uid://bqfijb7bk2g7j"]
[ext_resource type="Theme" uid="uid://bt4hxdwromnxs" path="res://ui/theme.tres" id="1_6qgep"]
[ext_resource type="Script" path="res://scripts/ui/switch_to_scene.gd" id="2_c477a"]
[ext_resource type="PackedScene" uid="uid://ctqxikky2g0nj" path="res://scenes/theme_test.tscn" id="3_j7pbg"]
[node name="Root" type="Panel"]
anchors_preset = 15
@ -40,4 +39,4 @@ autowrap_mode = 0
layout_mode = 2
text = "Theme Test Scene"
script = ExtResource("2_c477a")
scene = ExtResource("3_j7pbg")
scene_name = "theme_test"

View file

@ -1,5 +1,6 @@
[gd_scene load_steps=6 format=3 uid="uid://ctqxikky2g0nj"]
[gd_scene load_steps=7 format=3 uid="uid://ctqxikky2g0nj"]
[ext_resource type="Script" path="res://scripts/ui/switch_to_scene.gd" id="1_7goww"]
[ext_resource type="Script" path="res://scripts/ui/websocket_time.gd" id="1_qy4dl"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ujhhp"]
@ -1577,7 +1578,9 @@ size_flags_vertical = 3
[node name="Button" type="Button" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
layout_mode = 2
text = "Just a Button"
text = "Back to Main Menu"
script = ExtResource("1_7goww")
scene_name = "main_menu"
[node name="ToggleButton" type="Button" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
layout_mode = 2

View file

@ -1,6 +1,6 @@
extends Button
@export var scene: PackedScene
@export var scene_name: String
func _ready() -> void:
@ -8,6 +8,7 @@ func _ready() -> void:
func _on_Button_pressed() -> void:
if not scene:
if not scene_name:
push_error("Scene to switch to is not configured")
get_tree().change_scene_to_packed(scene)
return
get_tree().change_scene_to_file("res://scenes/" + scene_name + ".tscn")