Begin UI refactor
This commit is contained in:
@@ -5,5 +5,5 @@ class_name ConversationElement
|
|||||||
@export_multiline var label: String
|
@export_multiline var label: String
|
||||||
|
|
||||||
func sceneItem() -> int:
|
func sceneItem() -> int:
|
||||||
# await UI.TEXTBOX.setTextAndWait(label)
|
await UI.TEXTBOX.setTextAndWait(label)
|
||||||
return CutsceneSingleton.CUTSCENE_CONTINUE
|
return CutsceneSingleton.CUTSCENE_CONTINUE
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ func _ready() -> void:
|
|||||||
func _exit_tree() -> void:
|
func _exit_tree() -> void:
|
||||||
OVERWORLD.mapChanged.disconnect(onMapChanged)
|
OVERWORLD.mapChanged.disconnect(onMapChanged)
|
||||||
|
|
||||||
func onMapChanged(newMap:PackedScene, playerDestinationNodeName:String) -> void:
|
func onMapChanged(newMap:PackedScene, _playerDestinationNodeName:String) -> void:
|
||||||
print("New map time.", newMap)
|
print("New map time.", newMap)
|
||||||
for childScene in map.get_children():
|
for childScene in map.get_children():
|
||||||
map.remove_child(childScene)
|
map.remove_child(childScene)
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ func _applyFriction(delta:float) -> void:
|
|||||||
entity.velocity.z *= delta * FRICTION
|
entity.velocity.z *= delta * FRICTION
|
||||||
|
|
||||||
func _canMove() -> bool:
|
func _canMove() -> bool:
|
||||||
|
if !UI.TEXTBOX.isClosed:
|
||||||
|
return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ PARTY="*res://party/Party.gd"
|
|||||||
COOKING="*res://cooking/Cooking.gd"
|
COOKING="*res://cooking/Cooking.gd"
|
||||||
SAVE="*res://save/Save.gd"
|
SAVE="*res://save/Save.gd"
|
||||||
ControllerIcons="*res://addons/controller_icons/ControllerIcons.gd"
|
ControllerIcons="*res://addons/controller_icons/ControllerIcons.gd"
|
||||||
|
UI="*res://ui/UISingleton.gd"
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
|
|
||||||
|
|||||||
@@ -5,3 +5,5 @@
|
|||||||
[node name="InitialScene" type="Node3D"]
|
[node name="InitialScene" type="Node3D"]
|
||||||
|
|
||||||
[node name="MainMenu" parent="." instance=ExtResource("1_hu3pf")]
|
[node name="MainMenu" parent="." instance=ExtResource("1_hu3pf")]
|
||||||
|
z_as_relative = false
|
||||||
|
mouse_filter = 2
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ class_name RootScene extends Node3D
|
|||||||
@export var initial:Node3D = null
|
@export var initial:Node3D = null
|
||||||
@export var battle:Node3D = null
|
@export var battle:Node3D = null
|
||||||
@export var cooking:Node3D = null
|
@export var cooking:Node3D = null
|
||||||
|
@export var currentScene:Node = null
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
func _enter_tree() -> void:
|
||||||
SCENE.sceneChanged.connect(onSceneChange)
|
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.")
|
push_error("RootScene should not be removed from the scene tree. This is a bug.")
|
||||||
|
|
||||||
func removeAndHide(node:Node3D) -> void:
|
func removeAndHide(node:Node3D) -> void:
|
||||||
if node && node.get_parent() == self:
|
if node && node.get_parent():
|
||||||
remove_child(node)
|
node.get_parent().remove_child(node)
|
||||||
node.visible = false
|
node.visible = false
|
||||||
|
|
||||||
func addAndShow(node:Node3D) -> void:
|
func addAndShow(node:Node3D) -> void:
|
||||||
if node && node.get_parent() != self:
|
if node && currentScene:
|
||||||
add_child(node)
|
if node.get_parent() && node.get_parent() != currentScene:
|
||||||
|
node.get_parent().remove_child(node)
|
||||||
|
currentScene.add_child(node)
|
||||||
node.visible = true
|
node.visible = true
|
||||||
|
|
||||||
func onSceneChange(newScene:SceneSingleton.SceneType) -> void:
|
func onSceneChange(newScene:SceneSingleton.SceneType) -> void:
|
||||||
@@ -48,8 +51,8 @@ func onSceneChange(newScene:SceneSingleton.SceneType) -> void:
|
|||||||
removeAndHide(battle)
|
removeAndHide(battle)
|
||||||
addAndShow(cooking)
|
addAndShow(cooking)
|
||||||
|
|
||||||
SceneSingleton.SceneType.UNSET:
|
|
||||||
pass
|
|
||||||
|
|
||||||
_:
|
_:
|
||||||
pass
|
removeAndHide(initial)
|
||||||
|
removeAndHide(overworld)
|
||||||
|
removeAndHide(battle)
|
||||||
|
removeAndHide(cooking)
|
||||||
|
|||||||
@@ -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="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://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://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://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://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")
|
script = ExtResource("1_nky1x")
|
||||||
overworld = NodePath("OverworldScene")
|
overworld = NodePath("OverworldScene")
|
||||||
initial = NodePath("InitialScene")
|
initial = NodePath("InitialScene")
|
||||||
battle = NodePath("BattleScene")
|
battle = NodePath("BattleScene")
|
||||||
cooking = NodePath("CookingScene")
|
cooking = NodePath("CookingScene")
|
||||||
|
currentScene = NodePath("CurrentScene")
|
||||||
metadata/_custom_type_script = "uid://ml70iui7qpo4"
|
metadata/_custom_type_script = "uid://ml70iui7qpo4"
|
||||||
|
|
||||||
[node name="InitialScene" parent="." instance=ExtResource("2_hkmoa")]
|
[node name="InitialScene" parent="." instance=ExtResource("2_hkmoa")]
|
||||||
@@ -25,3 +27,7 @@ visible = false
|
|||||||
|
|
||||||
[node name="CookingScene" parent="." instance=ExtResource("5_aj1eq")]
|
[node name="CookingScene" parent="." instance=ExtResource("5_aj1eq")]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
|
[node name="CurrentScene" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="RootUI" parent="." instance=ExtResource("6_ajii0")]
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
class_name PauseSingleton extends Node
|
class_name PauseSingleton extends Node
|
||||||
|
|
||||||
var cutscenePaused:bool = false
|
# var cutscenePaused:bool = false
|
||||||
|
|
||||||
func cutscenePause() -> void:
|
# func cutscenePause() -> void:
|
||||||
cutscenePaused = true
|
# cutscenePaused = true
|
||||||
|
|
||||||
func cutsceneResume() -> void:
|
# func cutsceneResume() -> void:
|
||||||
cutscenePaused = false
|
# cutscenePaused = false
|
||||||
|
|
||||||
func isMovementPaused() -> bool:
|
# func isMovementPaused() -> bool:
|
||||||
if cutscenePaused:
|
# if cutscenePaused:
|
||||||
return true
|
# return true
|
||||||
|
|
||||||
# if !UI.TEXTBOX.isClosed:
|
# if !UI.TEXTBOX.isClosed:
|
||||||
# return true
|
# return true
|
||||||
|
|
||||||
# if UI.PAUSE.isOpen():
|
# if UI.PAUSE.isOpen():
|
||||||
# return true
|
# return true
|
||||||
|
|
||||||
if OVERWORLD.isMapChanging():
|
# if OVERWORLD.isMapChanging():
|
||||||
return true
|
# return true
|
||||||
|
|
||||||
return false
|
# return false
|
||||||
|
|
||||||
func menuPause() -> void:
|
# func menuPause() -> void:
|
||||||
# if UI.PAUSE.isOpen():
|
# # if UI.PAUSE.isOpen():
|
||||||
# UI.PAUSE.close()
|
# # UI.PAUSE.close()
|
||||||
# else:
|
# # else:
|
||||||
# UI.PAUSE.open()
|
# # UI.PAUSE.open()
|
||||||
pass
|
# pass
|
||||||
11
ui/RootUI.gd
Normal file
11
ui/RootUI.gd
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
class_name RootUI extends Control
|
||||||
|
|
||||||
|
@export var debugMenu:DebugMenu
|
||||||
|
@export var textBox:VNTextbox
|
||||||
|
|
||||||
|
func _enter_tree() -> void:
|
||||||
|
UI.rootUi = self
|
||||||
|
|
||||||
|
func _exit_tree() -> void:
|
||||||
|
if UI.rootUi == self:
|
||||||
|
UI.rootUi = null
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
[gd_scene load_steps=5 format=3 uid="uid://baos0arpiskbp"]
|
[gd_scene load_steps=5 format=3 uid="uid://baos0arpiskbp"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://ui/component/VNTextbox.tscn" id="1_1mtk3"]
|
[ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://ui/component/VNTextbox.tscn" id="1_1mtk3"]
|
||||||
[ext_resource type="Script" uid="uid://dq3qyyayugt5l" path="res://ui/UI.gd" id="1_son71"]
|
[ext_resource type="Script" uid="uid://dq3qyyayugt5l" path="res://ui/RootUI.gd" id="1_son71"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c0i5e2dj11d8c" path="res://ui/pause/PauseMenu.tscn" id="2_atyu8"]
|
[ext_resource type="PackedScene" uid="uid://c0i5e2dj11d8c" path="res://ui/pause/PauseMenu.tscn" id="2_atyu8"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b38dr0wkix76t" path="res://ui/debugmenu/DebugMenu.tscn" id="4_u132g"]
|
[ext_resource type="PackedScene" uid="uid://b38dr0wkix76t" path="res://ui/debugmenu/DebugMenu.tscn" id="4_u132g"]
|
||||||
|
|
||||||
[node name="UI" type="Control" node_paths=PackedStringArray("TEXTBOX", "PAUSE", "DEBUG")]
|
[node name="RootUI" type="Control" node_paths=PackedStringArray("debugMenu", "textBox")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
mouse_filter = 1
|
mouse_filter = 2
|
||||||
script = ExtResource("1_son71")
|
script = ExtResource("1_son71")
|
||||||
TEXTBOX = NodePath("VNTextbox")
|
debugMenu = NodePath("DebugMenu")
|
||||||
PAUSE = NodePath("PauseMenu")
|
textBox = NodePath("VNTextbox")
|
||||||
DEBUG = NodePath("DebugMenu")
|
metadata/_custom_type_script = "uid://dq3qyyayugt5l"
|
||||||
|
|
||||||
[node name="DebugMenu" parent="." instance=ExtResource("4_u132g")]
|
[node name="DebugMenu" parent="." instance=ExtResource("4_u132g")]
|
||||||
visible = false
|
visible = false
|
||||||
10
ui/UI.gd
10
ui/UI.gd
@@ -1,10 +0,0 @@
|
|||||||
class_name UISingleton extends Control
|
|
||||||
|
|
||||||
# @deprecated
|
|
||||||
@export var TEXTBOX: VNTextbox
|
|
||||||
|
|
||||||
# @deprecated
|
|
||||||
@export var PAUSE: PauseMenu
|
|
||||||
|
|
||||||
# @deprecated
|
|
||||||
@export var DEBUG: DebugMenu
|
|
||||||
15
ui/UISingleton.gd
Normal file
15
ui/UISingleton.gd
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
var rootUi:RootUI = null
|
||||||
|
|
||||||
|
var DEBUG_MENU:
|
||||||
|
get():
|
||||||
|
if rootUi && rootUi.debugMenu:
|
||||||
|
return rootUi.debugMenu
|
||||||
|
return null
|
||||||
|
|
||||||
|
var TEXTBOX:
|
||||||
|
get():
|
||||||
|
if rootUi && rootUi.textBox:
|
||||||
|
return rootUi.textBox
|
||||||
|
return null
|
||||||
1
ui/UISingleton.gd.uid
Normal file
1
ui/UISingleton.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://c0m8hvpqj3xcb
|
||||||
@@ -20,7 +20,7 @@ func _enter_tree() -> void:
|
|||||||
btnBattle.pressed.connect(onBattlePressed)
|
btnBattle.pressed.connect(onBattlePressed)
|
||||||
if btnCooking:
|
if btnCooking:
|
||||||
btnCooking.pressed.connect(onCookingPressed)
|
btnCooking.pressed.connect(onCookingPressed)
|
||||||
isClosed = false
|
isClosed = true
|
||||||
|
|
||||||
func _exit_tree() -> void:
|
func _exit_tree() -> void:
|
||||||
if btnInitial:
|
if btnInitial:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ anchor_right = 1.0
|
|||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
mouse_filter = 2
|
||||||
script = ExtResource("1_c1p3i")
|
script = ExtResource("1_c1p3i")
|
||||||
btnInitial = NodePath("HBoxContainer/InitialScene")
|
btnInitial = NodePath("HBoxContainer/InitialScene")
|
||||||
btnOverworld = NodePath("HBoxContainer/OverworldScene")
|
btnOverworld = NodePath("HBoxContainer/OverworldScene")
|
||||||
@@ -16,6 +17,16 @@ btnBattle = NodePath("HBoxContainer/BattleScene")
|
|||||||
btnCooking = NodePath("HBoxContainer/CookingScene")
|
btnCooking = NodePath("HBoxContainer/CookingScene")
|
||||||
metadata/_custom_type_script = "uid://bekdew700opvq"
|
metadata/_custom_type_script = "uid://bekdew700opvq"
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(1, 1, 1, 0.619608)
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 40.0
|
offset_right = 40.0
|
||||||
|
|||||||
Reference in New Issue
Block a user