Begin UI refactor
This commit is contained in:
@@ -5,5 +5,5 @@ class_name ConversationElement
|
||||
@export_multiline var label: String
|
||||
|
||||
func sceneItem() -> int:
|
||||
# await UI.TEXTBOX.setTextAndWait(label)
|
||||
await UI.TEXTBOX.setTextAndWait(label)
|
||||
return CutsceneSingleton.CUTSCENE_CONTINUE
|
||||
|
||||
@@ -11,7 +11,7 @@ func _ready() -> void:
|
||||
func _exit_tree() -> void:
|
||||
OVERWORLD.mapChanged.disconnect(onMapChanged)
|
||||
|
||||
func onMapChanged(newMap:PackedScene, playerDestinationNodeName:String) -> void:
|
||||
func onMapChanged(newMap:PackedScene, _playerDestinationNodeName:String) -> void:
|
||||
print("New map time.", newMap)
|
||||
for childScene in map.get_children():
|
||||
map.remove_child(childScene)
|
||||
|
||||
@@ -62,6 +62,8 @@ func _applyFriction(delta:float) -> void:
|
||||
entity.velocity.z *= delta * FRICTION
|
||||
|
||||
func _canMove() -> bool:
|
||||
if !UI.TEXTBOX.isClosed:
|
||||
return false
|
||||
return true
|
||||
|
||||
#
|
||||
|
||||
@@ -28,6 +28,7 @@ PARTY="*res://party/Party.gd"
|
||||
COOKING="*res://cooking/Cooking.gd"
|
||||
SAVE="*res://save/Save.gd"
|
||||
ControllerIcons="*res://addons/controller_icons/ControllerIcons.gd"
|
||||
UI="*res://ui/UISingleton.gd"
|
||||
|
||||
[debug]
|
||||
|
||||
|
||||
@@ -5,3 +5,5 @@
|
||||
[node name="InitialScene" type="Node3D"]
|
||||
|
||||
[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 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)
|
||||
|
||||
@@ -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")]
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
class_name PauseSingleton extends Node
|
||||
|
||||
var cutscenePaused:bool = false
|
||||
# var cutscenePaused:bool = false
|
||||
|
||||
func cutscenePause() -> void:
|
||||
cutscenePaused = true
|
||||
# func cutscenePause() -> void:
|
||||
# cutscenePaused = true
|
||||
|
||||
func cutsceneResume() -> void:
|
||||
cutscenePaused = false
|
||||
# func cutsceneResume() -> void:
|
||||
# cutscenePaused = false
|
||||
|
||||
func isMovementPaused() -> bool:
|
||||
if cutscenePaused:
|
||||
return true
|
||||
# func isMovementPaused() -> bool:
|
||||
# if cutscenePaused:
|
||||
# return true
|
||||
|
||||
# if !UI.TEXTBOX.isClosed:
|
||||
# return true
|
||||
# if !UI.TEXTBOX.isClosed:
|
||||
# return true
|
||||
|
||||
# if UI.PAUSE.isOpen():
|
||||
# return true
|
||||
# if UI.PAUSE.isOpen():
|
||||
# return true
|
||||
|
||||
if OVERWORLD.isMapChanging():
|
||||
return true
|
||||
# if OVERWORLD.isMapChanging():
|
||||
# return true
|
||||
|
||||
return false
|
||||
# return false
|
||||
|
||||
func menuPause() -> void:
|
||||
# if UI.PAUSE.isOpen():
|
||||
# UI.PAUSE.close()
|
||||
# else:
|
||||
# UI.PAUSE.open()
|
||||
pass
|
||||
# func menuPause() -> void:
|
||||
# # if UI.PAUSE.isOpen():
|
||||
# # UI.PAUSE.close()
|
||||
# # else:
|
||||
# # UI.PAUSE.open()
|
||||
# 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"]
|
||||
|
||||
[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://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
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 1
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_son71")
|
||||
TEXTBOX = NodePath("VNTextbox")
|
||||
PAUSE = NodePath("PauseMenu")
|
||||
DEBUG = NodePath("DebugMenu")
|
||||
debugMenu = NodePath("DebugMenu")
|
||||
textBox = NodePath("VNTextbox")
|
||||
metadata/_custom_type_script = "uid://dq3qyyayugt5l"
|
||||
|
||||
[node name="DebugMenu" parent="." instance=ExtResource("4_u132g")]
|
||||
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)
|
||||
if btnCooking:
|
||||
btnCooking.pressed.connect(onCookingPressed)
|
||||
isClosed = false
|
||||
isClosed = true
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if btnInitial:
|
||||
|
||||
@@ -9,6 +9,7 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_c1p3i")
|
||||
btnInitial = NodePath("HBoxContainer/InitialScene")
|
||||
btnOverworld = NodePath("HBoxContainer/OverworldScene")
|
||||
@@ -16,6 +17,16 @@ btnBattle = NodePath("HBoxContainer/BattleScene")
|
||||
btnCooking = NodePath("HBoxContainer/CookingScene")
|
||||
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="."]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
|
||||
Reference in New Issue
Block a user