Begin UI refactor

This commit is contained in:
2026-01-09 20:52:47 -06:00
parent e7f55fd731
commit bcf5249067
16 changed files with 92 additions and 50 deletions

View File

@@ -5,3 +5,5 @@
[node name="InitialScene" type="Node3D"]
[node name="MainMenu" parent="." instance=ExtResource("1_hu3pf")]
z_as_relative = false
mouse_filter = 2

View File

@@ -4,6 +4,7 @@ class_name RootScene extends Node3D
@export var initial:Node3D = null
@export var battle:Node3D = null
@export var cooking:Node3D = null
@export var currentScene:Node = null
func _enter_tree() -> void:
SCENE.sceneChanged.connect(onSceneChange)
@@ -13,13 +14,15 @@ func _exit_tree() -> void:
push_error("RootScene should not be removed from the scene tree. This is a bug.")
func removeAndHide(node:Node3D) -> void:
if node && node.get_parent() == self:
remove_child(node)
if node && node.get_parent():
node.get_parent().remove_child(node)
node.visible = false
func addAndShow(node:Node3D) -> void:
if node && node.get_parent() != self:
add_child(node)
if node && currentScene:
if node.get_parent() && node.get_parent() != currentScene:
node.get_parent().remove_child(node)
currentScene.add_child(node)
node.visible = true
func onSceneChange(newScene:SceneSingleton.SceneType) -> void:
@@ -48,8 +51,8 @@ func onSceneChange(newScene:SceneSingleton.SceneType) -> void:
removeAndHide(battle)
addAndShow(cooking)
SceneSingleton.SceneType.UNSET:
pass
_:
pass
removeAndHide(initial)
removeAndHide(overworld)
removeAndHide(battle)
removeAndHide(cooking)

View File

@@ -1,17 +1,19 @@
[gd_scene load_steps=6 format=3 uid="uid://ckkewlcugc8ro"]
[gd_scene load_steps=7 format=3 uid="uid://ckkewlcugc8ro"]
[ext_resource type="Script" uid="uid://ml70iui7qpo4" path="res://scene/RootScene.gd" id="1_nky1x"]
[ext_resource type="PackedScene" uid="uid://dy54m7dvjgqta" path="res://battle/BattleScene.tscn" id="2_0idls"]
[ext_resource type="PackedScene" uid="uid://bs41nqi3ocih3" path="res://scene/InitialScene.tscn" id="2_hkmoa"]
[ext_resource type="PackedScene" uid="uid://c0k1t3tyiaojl" path="res://overworld/OverworldScene.tscn" id="2_o1wvd"]
[ext_resource type="PackedScene" uid="uid://cxkd4frxvt873" path="res://cooking/CookingScene.tscn" id="5_aj1eq"]
[ext_resource type="PackedScene" uid="uid://baos0arpiskbp" path="res://ui/RootUI.tscn" id="6_ajii0"]
[node name="RootScene" type="Node3D" node_paths=PackedStringArray("overworld", "initial", "battle", "cooking")]
[node name="RootScene" type="Node3D" node_paths=PackedStringArray("overworld", "initial", "battle", "cooking", "currentScene")]
script = ExtResource("1_nky1x")
overworld = NodePath("OverworldScene")
initial = NodePath("InitialScene")
battle = NodePath("BattleScene")
cooking = NodePath("CookingScene")
currentScene = NodePath("CurrentScene")
metadata/_custom_type_script = "uid://ml70iui7qpo4"
[node name="InitialScene" parent="." instance=ExtResource("2_hkmoa")]
@@ -25,3 +27,7 @@ visible = false
[node name="CookingScene" parent="." instance=ExtResource("5_aj1eq")]
visible = false
[node name="CurrentScene" type="Node" parent="."]
[node name="RootUI" parent="." instance=ExtResource("6_ajii0")]