changes to state management, probably in need of refactoring
This commit is contained in:
parent
e1c93f7be0
commit
07cae4619d
|
|
@ -1,11 +1,7 @@
|
|||
extends Area3D
|
||||
|
||||
@onready var focus_forward = $UiWrapper/UiSprite/SubViewport/Collectable_ui
|
||||
var has_mouse: bool = false
|
||||
var has_focus: bool = false:
|
||||
set(focus):
|
||||
_on_mouse_entered()
|
||||
$UiWrapper/UiSprite/SubViewport/Collectable_ui.has_focus = focus
|
||||
has_focus = focus
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func _process(delta):
|
|||
func start():
|
||||
$light_animation.play("light_up")
|
||||
$AudioPlayer.play("intro")
|
||||
State.pass_focus_to($PlayerController)
|
||||
State.assign_focus_to($PlayerController)
|
||||
current_mode = Modes.WALKING
|
||||
|
||||
func _update_scene(new_mode) -> int:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=50 format=3 uid="uid://b8ht7h7b6rs8b"]
|
||||
[gd_scene load_steps=48 format=3 uid="uid://b3b0gyvklqn50"]
|
||||
|
||||
[ext_resource type="Script" path="res://base-environments/youth_room/room_handle.gd" id="1_aitp0"]
|
||||
[ext_resource type="PackedScene" uid="uid://c0i4ydmxtxfho" path="res://base-environments/youth_room/import/youth_room.glb" id="1_jf3oi"]
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
[ext_resource type="AudioStream" uid="uid://cho5neuxkvpyh" path="res://base-environments/youth_room/audio/Voice Loop.wav" id="10_wwwdq"]
|
||||
[ext_resource type="Script" path="res://base-environments/youth_room/Collectable.gd" id="11_6fwv8"]
|
||||
[ext_resource type="Script" path="res://dev-util/click-trough-area.gd" id="11_7uxd8"]
|
||||
[ext_resource type="PackedScene" uid="uid://cceyp2yd6o3sq" path="res://logic-scenes/collectable/collectable_ui.tscn" id="11_jxai0"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3pb25xuef2t2" path="res://logic-scenes/collectable/collectable_ui.tscn" id="11_jxai0"]
|
||||
[ext_resource type="PackedScene" uid="uid://bdnesuqroi7ss" path="res://vfx/collectable_particles.tscn" id="12_qxx2k"]
|
||||
[ext_resource type="Texture2D" uid="uid://d005qvnbnishb" path="res://import/interface-elements/cursor_grab.png" id="13_lqj71"]
|
||||
[ext_resource type="Script" path="res://base-environments/youth_room/catch_all.gd" id="16_tddlc"]
|
||||
|
|
@ -269,10 +269,10 @@ tracks/2/loop_wrap = true
|
|||
tracks/2/keys = {
|
||||
"clips": [{
|
||||
"end_offset": 200.412,
|
||||
"start_offset": 95.336,
|
||||
"start_offset": 96.656,
|
||||
"stream": ExtResource("9_dqdgk")
|
||||
}],
|
||||
"times": PackedFloat32Array(0.4)
|
||||
"times": PackedFloat32Array(1.6)
|
||||
}
|
||||
tracks/2/use_blend = true
|
||||
|
||||
|
|
@ -578,12 +578,6 @@ viewport_path = NodePath("Collectable/UiWrapper/UiSprite/SubViewport")
|
|||
radius = 0.342951
|
||||
height = 1.08154
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_2kdqs"]
|
||||
viewport_path = NodePath("Exit/Collectable_ui/Sprite3D/SubViewport")
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_60rck"]
|
||||
viewport_path = NodePath("Board/Collectable_ui/Sprite3D/SubViewport")
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_f1g8m"]
|
||||
radius = 0.156739
|
||||
|
||||
|
|
@ -634,12 +628,14 @@ stream = ExtResource("2_3haaq")
|
|||
volume_db = -15.367
|
||||
autoplay = true
|
||||
panning_strength = 0.5
|
||||
bus = &"sfx"
|
||||
emission_angle_enabled = true
|
||||
emission_angle_degrees = 57.0
|
||||
|
||||
[node name="AudioStreamPlayer3D2" type="AudioStreamPlayer3D" parent="youth_room"]
|
||||
transform = Transform3D(-0.410985, -0.460061, 0.787042, -0.904759, 0.311726, -0.290238, -0.111814, -0.831367, -0.544359, -0.248397, 4.34956, 8.85405)
|
||||
stream = ExtResource("3_wcypa")
|
||||
bus = &"sfx"
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_pllnm")
|
||||
|
|
@ -849,72 +845,12 @@ render_target_update_mode = 4
|
|||
|
||||
[node name="Collectable_ui" parent="Collectable/UiWrapper/UiSprite/SubViewport" instance=ExtResource("11_jxai0")]
|
||||
is_story = true
|
||||
item_name = "my old Mask"
|
||||
content_notes = "CN: testing testing 123"
|
||||
|
||||
[node name="HoverDetect" type="CollisionShape3D" parent="Collectable"]
|
||||
shape = SubResource("CapsuleShape3D_72g2i")
|
||||
|
||||
[node name="Exit" type="Area3D" parent="." groups=["exit"]]
|
||||
transform = Transform3D(1, 0, 1.06581e-14, 0, 1, 0, -1.06581e-14, 0, 1, 0.13754, 1.34703, -0.95778)
|
||||
collision_layer = 16
|
||||
|
||||
[node name="Collectable_ui" type="Area3D" parent="Exit"]
|
||||
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, -2.38419e-07, 0, 0.071894)
|
||||
script = ExtResource("11_7uxd8")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Exit/Collectable_ui"]
|
||||
transform = Transform3D(2.56, 0, 7.10543e-14, 0, 2.56, 0, -7.10543e-14, 0, 2.56, 0, 0, 0.238397)
|
||||
shape = SubResource("BoxShape3D_cb3g8")
|
||||
|
||||
[node name="UiSprite" type="Sprite3D" parent="Exit/Collectable_ui"]
|
||||
transform = Transform3D(1, 0, 2.4869e-14, 0, 1, 0, -2.4869e-14, 0, 1, 0, 0, 0.610758)
|
||||
pixel_size = 0.015
|
||||
no_depth_test = true
|
||||
texture = SubResource("ViewportTexture_2kdqs")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Exit/Collectable_ui/UiSprite"]
|
||||
transparent_bg = true
|
||||
size = Vector2i(300, 350)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Label" type="Label" parent="Exit/Collectable_ui/UiSprite/SubViewport"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 23.0
|
||||
text = "you may not exit now, three are still things to pack."
|
||||
|
||||
[node name="DisplayMenu" type="CollisionShape3D" parent="Exit"]
|
||||
shape = SubResource("CapsuleShape3D_72g2i")
|
||||
|
||||
[node name="Board" type="Area3D" parent="." groups=["exit"]]
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -0.995796, 1.30696, 1.71915)
|
||||
collision_layer = 16
|
||||
|
||||
[node name="Collectable_ui" type="Area3D" parent="Board"]
|
||||
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, -2.38419e-07, 0, 0.071894)
|
||||
script = ExtResource("11_7uxd8")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Board/Collectable_ui"]
|
||||
transform = Transform3D(2.56, 0, 7.10543e-14, 0, 2.56, 0, -7.10543e-14, 0, 2.56, 0, 0, 0.238397)
|
||||
shape = SubResource("BoxShape3D_cb3g8")
|
||||
|
||||
[node name="UiSprite" type="Sprite3D" parent="Board/Collectable_ui"]
|
||||
transform = Transform3D(1, 0, 2.4869e-14, 0, 1, 0, -2.4869e-14, 0, 1, 0, 0, 0.610758)
|
||||
pixel_size = 0.015
|
||||
no_depth_test = true
|
||||
texture = SubResource("ViewportTexture_60rck")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Board/Collectable_ui/UiSprite"]
|
||||
transparent_bg = true
|
||||
size = Vector2i(300, 350)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Label" type="Label" parent="Board/Collectable_ui/UiSprite/SubViewport"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 23.0
|
||||
text = "This is the Card Board."
|
||||
|
||||
[node name="DisplayMenu" type="CollisionShape3D" parent="Board"]
|
||||
shape = SubResource("CapsuleShape3D_72g2i")
|
||||
|
||||
[node name="Bed and Ladders" type="Node3D" parent="."]
|
||||
|
||||
[node name="ladder_trigger" type="Area3D" parent="Bed and Ladders"]
|
||||
|
|
@ -998,12 +934,6 @@ script = ExtResource("16_tddlc")
|
|||
[connection signal="ui_entered" from="PlayerController" to="SceneUI" method="show"]
|
||||
[connection signal="ui_exited" from="PlayerController" to="SceneUI" method="hide"]
|
||||
[connection signal="input_event" from="Collectable/UiWrapper" to="Collectable/UiWrapper" method="_on_input_event" flags=18]
|
||||
[connection signal="mouse_entered" from="Exit" to="Exit/Collectable_ui" method="show"]
|
||||
[connection signal="mouse_entered" from="Exit" to="Exit/DisplayMenu" method="set_disabled"]
|
||||
[connection signal="input_event" from="Exit/Collectable_ui" to="Exit/Collectable_ui" method="_on_input_event" flags=18]
|
||||
[connection signal="mouse_entered" from="Board" to="Board/Collectable_ui" method="show"]
|
||||
[connection signal="mouse_entered" from="Board" to="Board/DisplayMenu" method="set_disabled"]
|
||||
[connection signal="input_event" from="Board/Collectable_ui" to="Board/Collectable_ui" method="_on_input_event" flags=18]
|
||||
[connection signal="body_entered" from="Bed and Ladders/ladder_trigger" to="PlayerController" method="_on_bed_enter"]
|
||||
[connection signal="body_entered" from="Bed and Ladders/ladder_trigger" to="Bed and Ladders/ladder" method="raise"]
|
||||
[connection signal="body_exited" from="Bed and Ladders/ladder_reset" to="PlayerController" method="_on_bed_exit"]
|
||||
|
|
|
|||
|
|
@ -1,20 +1,13 @@
|
|||
[gd_resource type="AudioBusLayout" load_steps=2 format=3 uid="uid://djkwd76o033io"]
|
||||
|
||||
[sub_resource type="AudioEffectCompressor" id="AudioEffectCompressor_qkr2s"]
|
||||
resource_name = "Compressor"
|
||||
ratio = 12.2
|
||||
gain = 7.2
|
||||
[gd_resource type="AudioBusLayout" format=3 uid="uid://djkwd76o033io"]
|
||||
|
||||
[resource]
|
||||
bus/0/volume_db = 0.742748
|
||||
bus/0/mute = true
|
||||
bus/1/name = &"text"
|
||||
bus/1/solo = false
|
||||
bus/1/mute = false
|
||||
bus/1/bypass_fx = false
|
||||
bus/1/volume_db = -21.3877
|
||||
bus/1/volume_db = 0.0
|
||||
bus/1/send = &"test 2"
|
||||
bus/1/effect/0/effect = SubResource("AudioEffectCompressor_qkr2s")
|
||||
bus/1/effect/0/enabled = true
|
||||
bus/2/name = &"sfx"
|
||||
bus/2/solo = false
|
||||
bus/2/mute = false
|
||||
|
|
@ -23,7 +16,7 @@ bus/2/volume_db = 0.0
|
|||
bus/2/send = &"New Bus 3"
|
||||
bus/3/name = &"music"
|
||||
bus/3/solo = false
|
||||
bus/3/mute = true
|
||||
bus/3/mute = false
|
||||
bus/3/bypass_fx = false
|
||||
bus/3/volume_db = -9.12507
|
||||
bus/3/volume_db = -0.00384331
|
||||
bus/3/send = &"New Bus 3"
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -20,6 +20,8 @@ class_name Collectable_Ui
|
|||
@export var is_story: bool = false
|
||||
@export var has_focus: bool = false:
|
||||
set(focused):
|
||||
print("set focus of card to ", focused)
|
||||
|
||||
if has_focus == focused: return
|
||||
|
||||
if focused:
|
||||
|
|
@ -31,8 +33,8 @@ class_name Collectable_Ui
|
|||
else:
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.grab_focus()
|
||||
elif has_focus:
|
||||
has_focus = false
|
||||
State.drop_own_focus(self)
|
||||
has_focus = false # How did we get here?
|
||||
State.focus_cleared(self)
|
||||
get_viewport().gui_release_focus()
|
||||
hide()
|
||||
|
||||
|
|
@ -61,11 +63,13 @@ class_name Collectable_Ui
|
|||
@export var item_name: String = "":
|
||||
set(new_name):
|
||||
item_name = new_name
|
||||
if is_inside_tree():
|
||||
$Content/Name.text = new_name
|
||||
|
||||
@export var content_notes: String = "":
|
||||
set(new_notes):
|
||||
content_notes = new_notes
|
||||
if is_inside_tree():
|
||||
$Content/Name.text = new_notes
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://cceyp2yd6o3sq"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://d3pb25xuef2t2"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/messy.theme" id="1_2apkb"]
|
||||
[ext_resource type="Script" path="res://logic-scenes/collectable/collectable_ui.gd" id="1_tgjc2"]
|
||||
|
|
@ -99,7 +99,6 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
theme = ExtResource("1_2apkb")
|
||||
script = ExtResource("1_tgjc2")
|
||||
collapsed = null
|
||||
|
||||
[node name="Panel" type="PanelContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
extends RigidBody3D
|
||||
|
||||
@export var has_focus: bool = true :
|
||||
var has_focus: bool = false :
|
||||
set(focused):
|
||||
if has_focus != focused:
|
||||
if focused:
|
||||
|
|
@ -24,7 +24,7 @@ extends RigidBody3D
|
|||
else:
|
||||
jitter_strength = 0
|
||||
has_focus = false
|
||||
State.drop_own_focus(self)
|
||||
State.focus_cleared(self)
|
||||
|
||||
sleeping = has_focus
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ var has_entered:bool = false
|
|||
signal ui_exited
|
||||
|
||||
func _ready():
|
||||
_handle_jitter(0)
|
||||
if has_focus: _handle_jitter(0)
|
||||
|
||||
func _process(delta):
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ func _process(delta):
|
|||
emit_signal("ui_exited")
|
||||
has_entered = false
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
State.pass_focus_to(focus_ray.get_collider())
|
||||
State.assign_focus_to(focus_ray.get_collider())
|
||||
|
||||
func _physics_process(delta:float):
|
||||
if has_focus:
|
||||
|
|
@ -153,7 +153,7 @@ func _unhandled_input(event:InputEvent):
|
|||
has_focus = false
|
||||
get_viewport().set_input_as_handled()
|
||||
if event.is_action("ui_accept"):
|
||||
State.pass_focus_to(focus_ray.get_collider())
|
||||
State.assign_focus_to(focus_ray.get_collider())
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func _on_empty_click():
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://cq2s8oa1ql28l"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://df3ppd08g84f3"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://d0ucjqi8tx6vt" path="res://import/interface-elements/frame.png" id="1_8giso"]
|
||||
[ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/messy.theme" id="1_b01tw"]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://befxf8uruwnrl"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://balmcptv73l2j" path="res://dev-util/menu_background.png" id="1_0oiki"]
|
||||
[ext_resource type="PackedScene" uid="uid://cq2s8oa1ql28l" path="res://logic-scenes/startup/startup.tscn" id="1_v5rpm"]
|
||||
[ext_resource type="PackedScene" uid="uid://b8ht7h7b6rs8b" path="res://base-environments/youth_room/youth_room.tscn" id="2_23ia3"]
|
||||
[ext_resource type="PackedScene" uid="uid://df3ppd08g84f3" path="res://logic-scenes/startup/startup.tscn" id="1_v5rpm"]
|
||||
[ext_resource type="PackedScene" uid="uid://b3b0gyvklqn50" path="res://base-environments/youth_room/youth_room.tscn" id="2_23ia3"]
|
||||
[ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/messy.theme" id="3_8hrj7"]
|
||||
[ext_resource type="Texture2D" uid="uid://d3ewjumh0b0g6" path="res://logic-scenes/main menu/logo.png" id="4_kslkj"]
|
||||
[ext_resource type="Script" path="res://logic-scenes/main menu/Main Menu.gd" id="4_vj0j6"]
|
||||
|
|
|
|||
|
|
@ -28,10 +28,9 @@ gdscript/warnings/native_method_override=0
|
|||
|
||||
window/size/viewport_width=1440
|
||||
window/size/viewport_height=1080
|
||||
window/size/mode=3
|
||||
mouse_cursor/custom_image="res://import/interface-elements/cursor.png"
|
||||
window/stretch/mode="canvas_items"
|
||||
window/stretch/aspect="expand"
|
||||
mouse_cursor/custom_image="res://import/interface-elements/cursor.png"
|
||||
|
||||
[input]
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,15 @@ var focus_list:Array = []
|
|||
var lock_focus: bool = false
|
||||
|
||||
func request_focus(new_focus: Node, reclaim_focus: bool = false) -> bool:
|
||||
|
||||
assert(is_instance_valid(new_focus))
|
||||
if not focus_list.size() == 0: _pass_focus_of(focus_list[0])
|
||||
if not lock_focus or get_tree().paused:
|
||||
if lock_focus or get_tree().paused:
|
||||
push_warning(new_focus.name, " attempted to get focus while tree was paused or fokus had been locked.")
|
||||
return false
|
||||
elif reclaim_focus:
|
||||
|
||||
if not focus_list.size() == 0: _pass_focus_of(focus_list[0])
|
||||
|
||||
if reclaim_focus:
|
||||
if focus_list.has(new_focus):
|
||||
while not focus_list[0] == new_focus: focus_list.pop_front()
|
||||
return true
|
||||
|
|
@ -30,8 +33,9 @@ func request_focus(new_focus: Node, reclaim_focus: bool = false) -> bool:
|
|||
focus_list.append(new_focus)
|
||||
return true
|
||||
|
||||
|
||||
func assign_focus_to(focusable: Node) -> bool:
|
||||
if "focus_forward" in focusable:
|
||||
assign_focus_to(focusable.focus_forward)
|
||||
if "has_focus" in focusable:
|
||||
if not focus_list.size() == 0:
|
||||
_pass_focus_of(focus_list[0])
|
||||
|
|
@ -39,18 +43,26 @@ func assign_focus_to(focusable: Node) -> bool:
|
|||
return true
|
||||
else: return false
|
||||
|
||||
func pass_focus_to_unkown(from: Node):
|
||||
pass
|
||||
|
||||
func drop_own_focus(node: Node):
|
||||
if focus_list[0] == node:
|
||||
focus_list.pop_front().has_focus = false
|
||||
assert(focus_list.size() > 0)
|
||||
assert(focus_list.size() == 0)
|
||||
focus_list[0].has_focus = true
|
||||
else:
|
||||
push_warning(node.name + " attempted to drop focus while not owning it.")
|
||||
|
||||
func clear_focus_with(focus: Node):
|
||||
func clear_focus_stack_and_focus_on(focus: Node):
|
||||
assert(is_instance_valid(focus))
|
||||
if focus_list.size() > 0: focus_list[0].has_focus = false
|
||||
focus_list = [focus]
|
||||
focus.has_focus = true
|
||||
|
||||
func _pass_focus_of(previous_focus: Node):
|
||||
previous_focus.has_focus = false
|
||||
|
||||
func focus_cleared(from: Node):
|
||||
if from == focus_list[0]:
|
||||
push_warning(from.name, " cleared focus without validating!")
|
||||
|
|
|
|||
Loading…
Reference in New Issue