start implementing scenery-ui
This commit is contained in:
parent
b67ca9e328
commit
0035f97307
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=29 format=3 uid="uid://b3b0gyvklqn50"]
|
||||
[gd_scene load_steps=34 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"]
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
[ext_resource type="AudioStream" uid="uid://cl74a68tjwinh" path="res://base-environments/youth_room/audio/Youth Loop.wav" id="9_i8mqk"]
|
||||
[ext_resource type="AudioStream" uid="uid://ceoqo46r0kgfv" path="res://base-environments/youth_room/audio/jui-jutsu.mp3" id="10_5rpba"]
|
||||
[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://logic-scenes/collectable/click_passtrough.gd" id="11_674qe"]
|
||||
[ext_resource type="PackedScene" uid="uid://cceyp2yd6o3sq" path="res://logic-scenes/collectable/collectable_ui.tscn" id="11_jxai0"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_kcdrx"]
|
||||
sky_top_color = Color(0, 0, 1, 1)
|
||||
|
|
@ -228,6 +230,62 @@ tracks/4/keys = {
|
|||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_as75l"]
|
||||
resource_name = "childhood_intro"
|
||||
length = 10.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AudioPlayer/Moving:volume_db")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 9),
|
||||
"transitions": PackedFloat32Array(1.93187, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, -80.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AudioPlayer/Childhood:volume_db")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 9),
|
||||
"transitions": PackedFloat32Array(0.176777, 1),
|
||||
"update": 0,
|
||||
"values": [-80.0, 0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_60him"]
|
||||
resource_name = "childhood_outro"
|
||||
length = 10.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AudioPlayer/Moving:volume_db")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 9),
|
||||
"transitions": PackedFloat32Array(0.307786, 1),
|
||||
"update": 0,
|
||||
"values": [-80.0, 0.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AudioPlayer/Childhood:volume_db")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 9),
|
||||
"transitions": PackedFloat32Array(2.54912, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, -80.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_1pmhi"]
|
||||
resource_name = "intro"
|
||||
length = 20.0
|
||||
|
|
@ -356,62 +414,6 @@ tracks/4/keys = {
|
|||
}
|
||||
tracks/4/use_blend = true
|
||||
|
||||
[sub_resource type="Animation" id="Animation_as75l"]
|
||||
resource_name = "childhood_intro"
|
||||
length = 10.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AudioPlayer/Moving:volume_db")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 9),
|
||||
"transitions": PackedFloat32Array(1.93187, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, -80.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AudioPlayer/Childhood:volume_db")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 9),
|
||||
"transitions": PackedFloat32Array(0.176777, 1),
|
||||
"update": 0,
|
||||
"values": [-80.0, 0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_60him"]
|
||||
resource_name = "childhood_outro"
|
||||
length = 10.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("AudioPlayer/Moving:volume_db")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 9),
|
||||
"transitions": PackedFloat32Array(0.307786, 1),
|
||||
"update": 0,
|
||||
"values": [-80.0, 0.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("AudioPlayer/Childhood:volume_db")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 9),
|
||||
"transitions": PackedFloat32Array(2.54912, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, -80.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_8gaqi"]
|
||||
resource_name = "voice_intro"
|
||||
length = 10.0
|
||||
|
|
@ -460,6 +462,16 @@ func start_soundtrack():
|
|||
$VoiceTraining.play(70)
|
||||
"
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_72g2i"]
|
||||
radius = 0.342951
|
||||
height = 1.08154
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_n5aq1"]
|
||||
viewport_path = NodePath("Collectable/Sprite3D/SubViewport")
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_em4i8"]
|
||||
size = Vector3(0.29785, 0.380599, 0.0183088)
|
||||
|
||||
[node name="youth room" type="Node3D"]
|
||||
script = ExtResource("1_aitp0")
|
||||
|
||||
|
|
@ -579,3 +591,47 @@ bus = &"music"
|
|||
|
||||
[node name="Jui Jutsu" type="AudioStreamPlayer" parent="AudioPlayer"]
|
||||
bus = &"music"
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
visible = false
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="Label" type="Label" parent="Control"]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 23.0
|
||||
text = "n out of 3 Memories collected"
|
||||
|
||||
[node name="Collectable" type="Area3D" parent="."]
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -0.940637, 1.34703, 0.817837)
|
||||
collision_layer = 16
|
||||
|
||||
[node name="DisplayMenu" type="CollisionShape3D" parent="Collectable"]
|
||||
shape = SubResource("CapsuleShape3D_72g2i")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="Collectable"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.213171)
|
||||
visible = false
|
||||
pixel_size = 0.001
|
||||
billboard = 1
|
||||
texture = SubResource("ViewportTexture_n5aq1")
|
||||
script = ExtResource("11_674qe")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Collectable/Sprite3D"]
|
||||
transparent_bg = true
|
||||
size = Vector2i(256, 384)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Collectable_ui" parent="Collectable/Sprite3D/SubViewport" instance=ExtResource("11_jxai0")]
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="Collectable/Sprite3D"]
|
||||
collision_layer = 32
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Collectable/Sprite3D/Area3D"]
|
||||
shape = SubResource("BoxShape3D_em4i8")
|
||||
|
||||
[connection signal="mouse_entered" from="Collectable" to="Collectable/Sprite3D" method="show"]
|
||||
[connection signal="mouse_entered" from="Collectable" to="Collectable/DisplayMenu" method="set_disabled" binds= [true]]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,166 @@
|
|||
extends Sprite3D
|
||||
|
||||
# The size of the quad mesh itself.
|
||||
var render_size: Vector2
|
||||
# Used for checking if the mouse is inside the Area
|
||||
var is_mouse_inside = false
|
||||
# Used for checking if the mouse was pressed inside the Area
|
||||
var is_mouse_held = false
|
||||
# The last non-empty mouse position. Used when dragging outside of the box.
|
||||
var last_mouse_pos3D = null
|
||||
# The last processed input touch/mouse event. To calculate relative movement.
|
||||
var last_mouse_pos2D = null
|
||||
|
||||
@onready var node_viewport:SubViewport = $SubViewport
|
||||
@onready var node_area:Area3D = $Area3D
|
||||
|
||||
|
||||
func _ready():
|
||||
node_area.connect("mouse_entered", Callable(self, "_mouse_entered_area"))
|
||||
|
||||
# If the material is NOT set to use billboard settings, then avoid running billboard specific code
|
||||
if billboard == 0:
|
||||
set_process(false)
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
# NOTE: Remove this function if you don't plan on using billboard settings.
|
||||
rotate_area_to_billboard()
|
||||
|
||||
|
||||
func _mouse_entered_area():
|
||||
is_mouse_inside = true
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
# Check if the event is a non-mouse/non-touch event
|
||||
var is_mouse_event = false
|
||||
for mouse_event in [InputEventMouseButton, InputEventMouseMotion, InputEventScreenDrag, InputEventScreenTouch]:
|
||||
if event is InputEventMouse:
|
||||
is_mouse_event = true
|
||||
break
|
||||
|
||||
# If the event is a mouse/touch event and/or the mouse is either held or inside the area, then
|
||||
# we need to do some additional processing in the handle_mouse function before passing the event to the viewport.
|
||||
# If the event is not a mouse/touch event, then we can just pass the event directly to the viewport.
|
||||
if is_mouse_event and (is_mouse_inside or is_mouse_held):
|
||||
handle_mouse(event)
|
||||
elif not is_mouse_event:
|
||||
node_viewport.push_input(event)
|
||||
|
||||
|
||||
# Handle mouse events inside Area. (Area.input_event had many issues with dragging)
|
||||
func handle_mouse(event):
|
||||
# Get mesh size to detect edges and make conversions. This code only support PlaneMesh and QuadMesh.
|
||||
render_size = pixel_size * node_viewport.size
|
||||
|
||||
# Detect mouse being held to mantain event while outside of bounds. Avoid orphan clicks
|
||||
if event is InputEventMouseButton or event is InputEventScreenTouch:
|
||||
is_mouse_held = event.pressed
|
||||
|
||||
# Find mouse position in Area
|
||||
var mouse_pos3D = find_mouse(event.global_position)
|
||||
|
||||
# Check if the mouse is outside of bounds, use last position to avoid errors
|
||||
# NOTE: mouse_exited signal was unrealiable in this situation
|
||||
is_mouse_inside = mouse_pos3D != null
|
||||
if is_mouse_inside:
|
||||
# Convert click_pos from world coordinate space to a coordinate space relative to the Area node.
|
||||
# NOTE: affine_inverse accounts for the Area node's scale, rotation, and translation in the scene!
|
||||
mouse_pos3D = node_area.global_transform.affine_inverse() * mouse_pos3D
|
||||
last_mouse_pos3D = mouse_pos3D
|
||||
else:
|
||||
mouse_pos3D = last_mouse_pos3D
|
||||
if mouse_pos3D == null:
|
||||
mouse_pos3D = Vector3.ZERO
|
||||
|
||||
# TODO: adapt to bilboard mode or avoid completely
|
||||
|
||||
# convert the relative event position from 3D to 2D
|
||||
var mouse_pos2D = Vector2(mouse_pos3D.x, -mouse_pos3D.y)
|
||||
|
||||
# Right now the event position's range is the following: (-quad_size/2) -> (quad_size/2)
|
||||
# We need to convert it into the following range: 0 -> quad_size
|
||||
mouse_pos2D += render_size / 2
|
||||
# Then we need to convert it into the following range: 0 -> 1
|
||||
mouse_pos2D = mouse_pos2D / render_size.x
|
||||
|
||||
# Finally, we convert the position to the following range: 0 -> viewport.size
|
||||
mouse_pos2D.x = mouse_pos2D.x * node_viewport.size.x
|
||||
mouse_pos2D.y = mouse_pos2D.y * node_viewport.size.y
|
||||
# We need to do these conversions so the event's position is in the viewport's coordinate system.
|
||||
|
||||
# Set the event's position and global position.
|
||||
event.position = mouse_pos2D
|
||||
event.global_position = mouse_pos2D
|
||||
|
||||
# If the event is a mouse motion event...
|
||||
if event is InputEventMouseMotion:
|
||||
# If there is not a stored previous position, then we'll assume there is no relative motion.
|
||||
if last_mouse_pos2D == null:
|
||||
event.relative = Vector2(0, 0)
|
||||
# If there is a stored previous position, then we'll calculate the relative position by subtracting
|
||||
# the previous position from the new position. This will give us the distance the event traveled from prev_pos
|
||||
else:
|
||||
event.relative = mouse_pos2D - last_mouse_pos2D
|
||||
# Update last_mouse_pos2D with the position we just calculated.
|
||||
last_mouse_pos2D = mouse_pos2D
|
||||
|
||||
# Finally, send the processed input event to the viewport.
|
||||
node_viewport.push_input(event)
|
||||
|
||||
|
||||
func find_mouse(global_position):
|
||||
var camera = get_viewport().get_camera_3d()
|
||||
|
||||
# From camera center to the mouse position in the Area
|
||||
var from = camera.project_ray_origin(global_position)
|
||||
var dist = find_further_distance_to(camera.transform.origin)
|
||||
var to = from + camera.project_ray_normal(global_position) * dist
|
||||
|
||||
|
||||
# Manually raycasts the are to find the mouse position
|
||||
var result = get_world_3d().direct_space_state.intersect_ray(PhysicsRayQueryParameters3D.create(from, to, node_area.collision_layer)) #for 3.1 changes
|
||||
|
||||
if result.size() > 0:
|
||||
return result.position
|
||||
else:
|
||||
return null
|
||||
|
||||
|
||||
func find_further_distance_to(origin):
|
||||
# Find edges of collision and change to global positions
|
||||
var edges = []
|
||||
edges.append(node_area.to_global(Vector3(render_size.x / 2, render_size.y / 2, 0)))
|
||||
edges.append(node_area.to_global(Vector3(render_size.x / 2, -render_size.y / 2, 0)))
|
||||
edges.append(node_area.to_global(Vector3(-render_size.x / 2, render_size.y / 2, 0)))
|
||||
edges.append(node_area.to_global(Vector3(-render_size.x / 2, -render_size.y / 2, 0)))
|
||||
|
||||
# Get the furthest distance between the camera and collision to avoid raycasting too far or too short
|
||||
var far_dist = 0
|
||||
var temp_dist
|
||||
for edge in edges:
|
||||
temp_dist = origin.distance_to(edge)
|
||||
if temp_dist > far_dist:
|
||||
far_dist = temp_dist
|
||||
|
||||
return far_dist
|
||||
|
||||
|
||||
func rotate_area_to_billboard():
|
||||
# Try to match the area with the material's billboard setting, if enabled
|
||||
if billboard > 0:
|
||||
# Get the camera
|
||||
var camera = get_viewport().get_camera_3d()
|
||||
# Look in the same direction as the camera
|
||||
var look = camera.to_global(Vector3(0, 0, -100)) - camera.global_transform.origin
|
||||
look = node_area.position + look
|
||||
|
||||
# Y-Billboard: Lock Y rotation, but gives bad results if the camera is tilted.
|
||||
if billboard == 2:
|
||||
look = Vector3(look.x, 0, look.z)
|
||||
|
||||
node_area.look_at(look, Vector3.UP)
|
||||
|
||||
# Rotate in the Z axis to compensate camera tilt
|
||||
node_area.rotate_object_local(Vector3.BACK, camera.rotation.z)
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
[gd_scene format=3 uid="uid://cceyp2yd6o3sq"]
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer"]
|
||||
offset_right = 256.0
|
||||
offset_bottom = 255.0
|
||||
|
||||
[node name="Name" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
theme_type_variation = &"HeaderLarge"
|
||||
text = "old Mask"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Content Notes" type="RichTextLabel" parent="."]
|
||||
custom_minimum_size = Vector2(256, 0)
|
||||
layout_mode = 2
|
||||
bbcode_enabled = true
|
||||
text = "[center] Content Notes:
|
||||
Food, Blood, Gore, Whatever, I need a second line.
|
||||
[/center]"
|
||||
fit_content = true
|
||||
|
||||
[node name="collect_or_listen" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Take this with you, and listen to it's story."
|
||||
text = "Collect"
|
||||
|
||||
[node name="Summary" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Take this with you, but get a neutral description of it's story."
|
||||
text = "get neutral summary"
|
||||
|
||||
[node name="skip" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Choose this to entirely skip this Item without being unable to progress in the story. Skipped Segments can still be interacted with via the Pause Screen, if you decide to change your mind."
|
||||
text = "skip"
|
||||
|
||||
[node name="put_back" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
text = "put back"
|
||||
|
|
@ -36,14 +36,19 @@ func set_active(activate):
|
|||
if activate:
|
||||
camera.make_current()
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
sleeping = active
|
||||
|
||||
func _ready():
|
||||
|
||||
if active:
|
||||
set_active(active)
|
||||
|
||||
|
||||
|
||||
func _process(delta):
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
set_active(!active)
|
||||
|
||||
func _physics_process(delta:float):
|
||||
_handle_movement(delta)
|
||||
_handle_rotation(delta)
|
||||
|
|
@ -114,7 +119,6 @@ func _unhandled_input(event:InputEvent):
|
|||
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
_handle_mouse_input(event)
|
||||
|
||||
|
||||
func _on_bed_enter(body):
|
||||
if not crouched:
|
||||
$PlayerAnimationPlayer.queue("crouch")
|
||||
|
|
|
|||
|
|
@ -309,12 +309,10 @@ follow_focus = true
|
|||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="Content Notes" type="VBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Content Notes/ScrollContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Content Notes/ScrollContainer/Content Notes"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Button" type="Button" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Content Notes/ScrollContainer/Content Notes/VBoxContainer2"]
|
||||
|
|
@ -325,6 +323,7 @@ text = "Is this game for or about me?"
|
|||
script = SubResource("GDScript_rhtho")
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Content Notes/ScrollContainer/Content Notes/VBoxContainer2"]
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(512, 0)
|
||||
layout_mode = 2
|
||||
bbcode_enabled = true
|
||||
|
|
|
|||
|
|
@ -50,6 +50,12 @@ player_backwards={
|
|||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
3d_physics/layer_1="Scene Geometry"
|
||||
3d_physics/layer_5="UI_reveal"
|
||||
3d_physics/layer_6="UI_handle"
|
||||
|
||||
[rendering]
|
||||
|
||||
anti_aliasing/quality/screen_space_aa=1
|
||||
|
|
|
|||
Loading…
Reference in New Issue