Fixed UI system

This commit is contained in:
2025-05-06 16:08:46 -05:00
parent b0d9106772
commit 85a7ed99bf
44 changed files with 158 additions and 87 deletions

View File

@@ -24,9 +24,10 @@ COOKING="*res://scripts/Singletons/Cooking.gd"
ITEM="*res://scripts/Singletons/Item.gd"
OVERWORLD="*res://scripts/Singletons/Overworld.gd"
PAUSE="*res://scripts/Singletons/Pause.gd"
QUEST="*res://scripts/Singletons/Quest.gd"
QUEST="*res://scenes/Singletons/Quest.tscn"
SCENE_MANAGER="*res://scripts/Singletons/SceneManager.gd"
VN="*res://scenes/Singletons/VN.tscn"
UI="*res://scenes/Singletons/UI.tscn"
[dotnet]

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=8 format=3 uid="uid://yhtpoum3eek7"]
[ext_resource type="Script" uid="uid://ixwikdguyhf0" path="res://scripts/Entities/RosaController.gd" id="1_3g383"]
[ext_resource type="Script" uid="uid://jd50n00bo05y" path="res://scripts/Entities/RosaCamera.gd" id="2_tr66j"]
[ext_resource type="Script" uid="uid://ixwikdguyhf0" path="res://scripts/Entity/RosaController.gd" id="1_3g383"]
[ext_resource type="Script" uid="uid://jd50n00bo05y" path="res://scripts/Entity/RosaCamera.gd" id="2_tr66j"]
[ext_resource type="Shader" uid="uid://7h2axb2tsh17" path="res://shaders/NPC Shader.gdshader" id="3_j5vis"]
[ext_resource type="Texture2D" uid="uid://cofrgefp8e617" path="res://textures/human.png" id="4_rvn3n"]

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=7 format=3 uid="uid://dr4b2pmsknuhc"]
[ext_resource type="Script" uid="uid://d23qg1ovkbxst" path="res://scripts/Entities/BasicNPCEntity.gd" id="1_1muh7"]
[ext_resource type="Script" uid="uid://d23qg1ovkbxst" path="res://scripts/Entity/BasicNPCEntity.gd" id="1_1muh7"]
[ext_resource type="Shader" uid="uid://7h2axb2tsh17" path="res://shaders/NPC Shader.gdshader" id="1_xgcv1"]
[ext_resource type="Texture2D" uid="uid://cofrgefp8e617" path="res://textures/human.png" id="4_vo0ku"]

View File

@@ -1,29 +1,25 @@
[gd_scene format=3 uid="uid://w1q5eoiejmy3"]
[gd_scene load_steps=2 format=3 uid="uid://w1q5eoiejmy3"]
[node name="MainMenu" type="Node3D"]
[ext_resource type="PackedScene" uid="uid://bimrljk1rn7af" path="res://scenes/UI/SubsceneUI.tscn" id="1_yqorp"]
[node name="UI" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MainMenu" type="Node"]
[node name="Label" type="Label" parent="UI"]
[node name="SubsceneUI" parent="." instance=ExtResource("1_yqorp")]
[node name="Label" type="Label" parent="SubsceneUI"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -68.0
offset_top = -11.5
offset_right = 68.0
offset_bottom = 11.5
offset_left = -133.5
offset_top = -37.5
offset_right = 133.5
offset_bottom = 37.5
grow_horizontal = 2
grow_vertical = 2
text = "Thyme and Magic
text = "Thyme and Magic - Prototype
Press tab to bring up debug menu."
horizontal_alignment = 1

View File

@@ -4,8 +4,8 @@
[ext_resource type="PackedScene" uid="uid://dr4b2pmsknuhc" path="res://scenes/Entities/TestNPC.tscn" id="2_cg1ph"]
[ext_resource type="PackedScene" uid="uid://lh713g04d3bg" path="res://scenes/Maps/TestMap/TestMapGround.tscn" id="3_gxq5o"]
[ext_resource type="PackedScene" uid="uid://boj5o4fx41rv8" path="res://scenes/Maps/TestMap/TestMapBuilding.tscn" id="4_brp0k"]
[ext_resource type="Script" uid="uid://tkfc88q8m86f" path="res://scripts/Events/EventConversation.gd" id="5_cg1ph"]
[ext_resource type="Script" uid="uid://y7ckj1tn5cro" path="res://scripts/Events/EventTextbox.gd" id="6_gxq5o"]
[ext_resource type="Script" uid="uid://tkfc88q8m86f" path="res://scripts/Event/EventConversation.gd" id="5_cg1ph"]
[ext_resource type="Script" uid="uid://y7ckj1tn5cro" path="res://scripts/Event/EventTextbox.gd" id="6_gxq5o"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_e1h75"]
sky_horizon_color = Color(0.59625, 0.6135, 0.6375, 1)

View File

@@ -1,21 +1,19 @@
[gd_scene load_steps=3 format=3 uid="uid://klfo3l0dxlht"]
[gd_scene load_steps=4 format=3 uid="uid://klfo3l0dxlht"]
[ext_resource type="Script" uid="uid://d36d3fnpi8y30" path="res://scripts/Singletons/Debug.gd" id="1_5spvt"]
[ext_resource type="PackedScene" uid="uid://bimrljk1rn7af" path="res://scenes/UI/SubsceneUI.tscn" id="2_5o7yr"]
[ext_resource type="PackedScene" uid="uid://verg13jtqwvh" path="res://scenes/UI/DebugMenu.tscn" id="2_c2xgb"]
[node name="Debug" type="Node2D"]
[node name="Debug" type="Node"]
script = ExtResource("1_5spvt")
[node name="UI" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="SubsceneUI" parent="." instance=ExtResource("2_5o7yr")]
layer = 3
[node name="DebugMenu" parent="UI" instance=ExtResource("2_c2xgb")]
[node name="DebugMenu" parent="SubsceneUI" instance=ExtResource("2_c2xgb")]
layout_mode = 0
anchors_preset = 0
anchor_bottom = 0.0
offset_right = 207.0
offset_bottom = 206.0
grow_vertical = 1

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cs3kmmd0rfm8w"]
[ext_resource type="Script" uid="uid://d0060jeyftia7" path="res://scripts/Singletons/Quest.gd" id="1_v2h4q"]
[node name="Quest" type="Node"]
script = ExtResource("1_v2h4q")

37
scenes/Singletons/UI.tscn Normal file
View File

@@ -0,0 +1,37 @@
[gd_scene load_steps=2 format=3 uid="uid://b5bwpsh0gcicf"]
[ext_resource type="Script" uid="uid://dahhuhiu8u88b" path="res://scripts/Singletons/UI.gd" id="1_g3au4"]
[node name="UI" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_g3au4")
metadata/_custom_type_script = "uid://dahhuhiu8u88b"
[node name="LayerGame" type="Control" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="LayerVN" type="Control" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="LayerDebug" type="Control" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

View File

@@ -1,18 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://b6pl1cq5y05ad"]
[gd_scene load_steps=4 format=3 uid="uid://b6pl1cq5y05ad"]
[ext_resource type="Script" uid="uid://benvf7v4p4i2l" path="res://scripts/Singletons/VN.gd" id="1_01fad"]
[ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://scenes/UI/VNTextbox.tscn" id="2_adm0d"]
[ext_resource type="PackedScene" uid="uid://bimrljk1rn7af" path="res://scenes/UI/SubsceneUI.tscn" id="2_hxsm8"]
[node name="VN" type="Node"]
script = ExtResource("1_01fad")
[node name="UI" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="SubsceneUI" parent="." instance=ExtResource("2_hxsm8")]
layer = 1
[node name="VNTextbox" parent="UI" instance=ExtResource("2_adm0d")]
[node name="VNTextbox" parent="SubsceneUI" instance=ExtResource("2_adm0d")]
layout_mode = 1

13
scenes/UI/SubsceneUI.tscn Normal file
View File

@@ -0,0 +1,13 @@
[gd_scene load_steps=2 format=3 uid="uid://bimrljk1rn7af"]
[ext_resource type="Script" uid="uid://x3cc7wsnn0xd" path="res://scripts/UI/SubsceneUI.gd" id="1_m23s2"]
[node name="SubsceneUI" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_m23s2")
metadata/_custom_type_script = "uid://x3cc7wsnn0xd"

View File

@@ -1,5 +1,5 @@
class_name OverworldEntityEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
const OverworldEntity = preload("res://scripts/Entities/OverworldEntity.gd");
const OverworldEntity = preload("res://scripts/Entity/OverworldEntity.gd");
var entity:OverworldEntity;

View File

@@ -1,5 +1,5 @@
class_name OverworldConversationEvent extends "res://scripts/Cutscene/Cutscene.gd"
const OverworldEntity = preload("res://scripts/Entities/OverworldEntity.gd");
const OverworldEntity = preload("res://scripts/Entity/OverworldEntity.gd");
const TextboxEvent = preload("res://scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd");
const PauseEvent = preload("res://scripts/Cutscene/Event/CutscenePauseEvent.gd");
const OverworldChangeDirectionEvent = preload("res://scripts/Cutscene/Event/Entity/OverworldChangeDirectionEvent.gd");

View File

@@ -1,5 +1,5 @@
class_name BasicNPCEntity extends "res://scripts/Entities/OverworldEntity.gd"
const Event = preload("res://scripts/Events/Event.gd");
class_name BasicNPCEntity extends "res://scripts/Entity/OverworldEntity.gd"
const Event = preload("res://scripts/Event/Event.gd");
enum BasicNPCMoveType {
STILL,

View File

@@ -1,4 +1,4 @@
class_name RosaController extends "res://scripts/Entities/OverworldEntity.gd"
class_name RosaController extends "res://scripts/Entity/OverworldEntity.gd"
var interactRange = 0.7;

View File

@@ -1,4 +1,4 @@
class_name EventEntityTurn extends "res://scripts/Events/Event.gd"
class_name EventEntityTurn extends "res://scripts/Event/Event.gd"
@export var entity:OverworldEntity = null
@export var direction:OverworldEntity.Direction = OverworldEntity.Direction.SOUTH

View File

@@ -1,6 +1,6 @@
class_name Event extends Node
const OverworldEntity = preload("res://scripts/Entities/OverworldEntity.gd");
const OverworldEntity = preload("res://scripts/Entity/OverworldEntity.gd");
var started:bool = false;

View File

@@ -1,4 +1,4 @@
class_name EventConversation extends "res://scripts/Events/Flow/EventGroup.gd"
class_name EventConversation extends "res://scripts/Event/Flow/EventGroup.gd"
@export var startPauseType:PauseSystem.PauseType = PauseSystem.PauseType.ENTITY_PAUSED
@export var endPauseType:PauseSystem.PauseType = PauseSystem.PauseType.NOT_PAUSED

View File

@@ -1,4 +1,4 @@
class_name EventPause extends "res://scripts/Events/Event.gd"
class_name EventPause extends "res://scripts/Event/Event.gd"
const PauseSystem = preload("res://scripts/Singletons/Pause.gd")

View File

@@ -1,4 +1,4 @@
class_name EventTextbox extends "res://scripts/Events/Event.gd"
class_name EventTextbox extends "res://scripts/Event/Event.gd"
# @export var text:Array[String] = [ "Hello Text" ];
@export_multiline var text:String = "Hello Text"
@@ -8,4 +8,4 @@ func start() -> void:
VN.getTextbox().setText(self.text);
func isDone() -> bool:
return super.isDone() && VN.getTextbox().isClosed;
return super.isDone() && VN.getTextbox().isClosed;

View File

@@ -1,4 +1,4 @@
class_name EventGroup extends "res://scripts/Events/Flow/EventWithChildren.gd"
class_name EventGroup extends "res://scripts/Event/Flow/EventWithChildren.gd"
enum ProcessType {
SEQUENTIAL,

View File

@@ -1,34 +1,12 @@
class_name EventWithChildren extends "res://scripts/Events/Event.gd"
class_name EventWithChildren extends "res://scripts/Event/Event.gd"
var childEvents:Array[Event] = []
var extraEvents:Array[Event] = []
func _init() -> void:
super._init()
# _updateChildEvents()
# self.child_entered_tree.connect(onChildEntered)
# self.child_exiting_tree.connect(onChildExited)
# self.child_order_changed.connect(onChildOrderChanged)
func start():
super.start()
_updateChildEvents()
func _updateChildEvents() -> void:
childEvents = []
for child in get_children():
if child is Event:
childEvents.append(child)
func onChildEntered(child:Node) -> void:
_updateChildEvents()
func onChildExited(child:Node) -> void:
_updateChildEvents()
func onChildOrderChanged() -> void:
_updateChildEvents()
func reset() -> void:
super.reset()
_cleanupExtraEvents()
@@ -37,6 +15,12 @@ func end() -> void:
super.end()
_cleanupExtraEvents()
func _updateChildEvents() -> void:
childEvents = []
for child in get_children():
if child is Event:
childEvents.append(child)
func _cleanupExtraEvents():
for event in extraEvents:
remove_child(event)

View File

@@ -3,7 +3,7 @@ extends Node
var debugMenu:DebugMenu
func _ready() -> void:
debugMenu = $UI/DebugMenu;
debugMenu = $SubsceneUI/DebugMenu;
debugMenu.hide()
func _process(delta: float) -> void:
@@ -16,8 +16,7 @@ func _process(delta: float) -> void:
func showMenu() -> void:
debugMenu.show()
self.get_parent().move_child(self, self.get_parent().get_child_count() - 1)
print("Debug menu shown")
func hideMenu() -> void:
debugMenu.hide()
self.get_parent().move_child(self, 0)

View File

@@ -1,7 +1 @@
class_name QuestSystem extends Node
static var QUEST_EXAMPLE = preload("res://scripts/Quest/QuestExample.gd").new();
static var ALL_QUESTS = [
QUEST_EXAMPLE
]
class_name QuestSystem extends Node

View File

@@ -1,4 +1,4 @@
extends Node
class_name SceneManager extends Node
const MainMenu = preload("res://scenes/MainMenu.tscn");
const OverworldScene = preload("res://scenes/Overworld.tscn");

25
scripts/Singletons/UI.gd Normal file
View File

@@ -0,0 +1,25 @@
class_name UISystem extends Control
enum Layer {
Game,
VN,
Test,
Debug
}
func addSubscene(subscene:Control, layer:Layer) -> void:
subscene.originalParent.remove_child.call_deferred(subscene)
match layer:
Layer.Game:
$LayerGame.add_child.call_deferred(subscene)
Layer.Debug:
$LayerDebug.add_child.call_deferred(subscene)
Layer.VN:
$LayerVN.add_child.call_deferred(subscene)
_:
push_error("Invalid layer: " + str(layer))
return
func removeSubscene(subscene:Control) -> void:
subscene.get_parent().remove_child(subscene)

View File

@@ -0,0 +1 @@
uid://dahhuhiu8u88b

View File

@@ -1,5 +1,10 @@
class_name VNSystem extends Node
const VNTextbox = preload("res://scripts/UI/VNTextbox.gd")
var vnTextbox:VNTextbox = null
func _ready() -> void:
vnTextbox = $SubsceneUI/VNTextbox
func getTextbox() -> VNTextbox:
return $UI/VNTextbox;
return vnTextbox

15
scripts/UI/SubsceneUI.gd Normal file
View File

@@ -0,0 +1,15 @@
class_name SubsceneUI extends Control
@export var layer:UISystem.Layer = UISystem.Layer.Game;
var originalParent:Node = null
func _ready() -> void:
originalParent = self.get_parent()
originalParent.tree_exiting.connect(onParentExiting)
UI.addSubscene(self, layer)
func onParentExiting() -> void:
if originalParent:
originalParent.tree_exiting.disconnect(onParentExiting)
UI.removeSubscene(self)
originalParent = null

View File

@@ -0,0 +1 @@
uid://x3cc7wsnn0xd