Affiche le menu du jukebox directement dans la scene 3d, lorsqu'on s'en approche.
This commit is contained in:
parent
83dc298a86
commit
a331edd6b6
7 changed files with 234 additions and 33 deletions
|
@ -31,7 +31,7 @@ func _on_SaveHUD_pressed():
|
|||
|
||||
func _on_Windows_gui_input( event ):
|
||||
if event is InputEventMouseButton \
|
||||
and event.button_index == BUTTON_LEFT \
|
||||
and event.button_index == BUTTON_RIGHT \
|
||||
and Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE \
|
||||
and not event.is_echo() \
|
||||
and not event.pressed:
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
[ext_resource path="res://scenes/GUI/HUD/trauma.gd" type="Script" id=10]
|
||||
[ext_resource path="res://scenes/GUI/HUD/douleur.gd" type="Script" id=11]
|
||||
|
||||
[node name="HUD" type="MarginContainer" index="0"]
|
||||
[node name="HUD" type="MarginContainer"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
|
@ -986,6 +986,7 @@ _sections_unfolded = [ "Rect", "Size Flags", "custom_constants" ]
|
|||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="Windows/Music/VBoxContainer/Content" index="0"]
|
||||
|
||||
visible = false
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
|
@ -1016,7 +1017,6 @@ _sections_unfolded = [ "BBCode", "Rect", "Size Flags" ]
|
|||
|
||||
[node name="Music" parent="Windows/Music/VBoxContainer/Content" index="1" instance=ExtResource( 8 )]
|
||||
|
||||
visible = false
|
||||
margin_left = 8.0
|
||||
margin_top = 8.0
|
||||
margin_right = 121.0
|
||||
|
@ -1087,14 +1087,11 @@ _sections_unfolded = [ "Mouse", "Size Flags", "Textures" ]
|
|||
|
||||
[node name="Music" parent="." index="3" instance=ExtResource( 8 )]
|
||||
|
||||
visible = false
|
||||
margin_left = 942.0
|
||||
margin_top = 0.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 66.0
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 2
|
||||
_sections_unfolded = [ "Size Flags" ]
|
||||
|
||||
[node name="Jauges" type="VBoxContainer" parent="." index="4"]
|
||||
|
||||
|
|
|
@ -11,9 +11,8 @@ anchor_left = 0.0
|
|||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 316.0
|
||||
margin_right = 256.0
|
||||
margin_bottom = 402.0
|
||||
margin_bottom = 86.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
|
@ -22,6 +21,7 @@ size_flags_horizontal = 1
|
|||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
script = ExtResource( 1 )
|
||||
_sections_unfolded = [ "Rect", "Size Flags" ]
|
||||
|
||||
[node name="Songs" type="Container" parent="." index="0"]
|
||||
|
||||
|
@ -130,6 +130,7 @@ mouse_default_cursor_shape = 0
|
|||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
_sections_unfolded = [ "Rect" ]
|
||||
|
||||
[node name="Pause" type="Button" parent="Buttons" index="0"]
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ func process_movement(delta):
|
|||
hvel = hvel.linear_interpolate(target, accel*delta)
|
||||
vel.x = hvel.x
|
||||
vel.z = hvel.z
|
||||
# vel = move_and_slide(vel,Vector3(0,1,0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE))
|
||||
|
||||
var collision_info = move_and_collide(vel * delta)
|
||||
if collision_info:
|
||||
vel = vel.bounce(collision_info.normal)
|
||||
|
@ -99,12 +99,6 @@ func process_movement(delta):
|
|||
get_node( "../../GUI/HUD/Jauges/trauma/ProgressBar" ).value += 0.25
|
||||
if get_node( "../../GUI/HUD/Jauges/trauma/ProgressBar" ).value >= 100:
|
||||
get_node( "../../GUI/HUD/Jauges/oubli/ProgressBar" ).value += 0.25
|
||||
# obj.get_node( "MeshInstance" ).get_surface_material(0).albedo_color = Color( collision_info.normal )
|
||||
# if obj.has_method( "hit" ):
|
||||
# obj.hit( collision_info.position, collision_info.collider_velocity )
|
||||
|
||||
|
||||
# print(str(collision_info.collider.get_class()))
|
||||
|
||||
|
||||
|
||||
|
@ -119,7 +113,7 @@ func _input(event):
|
|||
camera_rotation.rotation_degrees = camera_rot
|
||||
|
||||
|
||||
if event is InputEventMouseButton and Input.get_mouse_mode():
|
||||
if event is InputEventMouseButton:
|
||||
|
||||
# to prevent the cam sliding effect when clamp limit reached.
|
||||
var old_x_translation = camera.translation.x
|
||||
|
@ -137,8 +131,6 @@ func _input(event):
|
|||
camera.translation.y = old_y_translation
|
||||
camera.translation.z = clamp(camera.translation.z, 0, 5)
|
||||
|
||||
# if event.is_action_pressed( "game_flashlight" ) and not event.is_echo():
|
||||
# get_node( "Flashlight" ).visible = not get_node( "Flashlight" ).visible
|
||||
if Input.is_action_just_pressed("game_flashlight"):
|
||||
if flashlight.is_visible_in_tree():
|
||||
flashlight.hide()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=41 format=2]
|
||||
[gd_scene load_steps=46 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/Game/Character/Character.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://scenes/Game/Terrain/Terrain.tscn" type="PackedScene" id=2]
|
||||
|
@ -13,6 +13,7 @@
|
|||
[ext_resource path="res://assets/Game/textures/fire_01.png" type="Texture" id=11]
|
||||
[ext_resource path="res://assets/Game/textures/fire_02.png" type="Texture" id=12]
|
||||
[ext_resource path="res://scenes/Game/jukebox/jukebox.tscn" type="PackedScene" id=13]
|
||||
[ext_resource path="res://scenes/GUI/MusicControls/MusicControls.tscn" type="PackedScene" id=14]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
|
||||
|
@ -776,7 +777,76 @@ material = SubResource( 26 )
|
|||
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
|
||||
size = Vector2( 0.4, 0.4 )
|
||||
|
||||
[node name="Game" type="Spatial"]
|
||||
[sub_resource type="QuadMesh" id=28]
|
||||
|
||||
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
|
||||
size = Vector2( 2, 2 )
|
||||
|
||||
[sub_resource type="ViewportTexture" id=29]
|
||||
|
||||
resource_local_to_scene = true
|
||||
flags = 0
|
||||
viewport_path = NodePath("jukebox/Viewport")
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=30]
|
||||
|
||||
resource_local_to_scene = true
|
||||
render_priority = 0
|
||||
flags_transparent = true
|
||||
flags_unshaded = true
|
||||
flags_vertex_lighting = false
|
||||
flags_no_depth_test = false
|
||||
flags_use_point_size = false
|
||||
flags_world_triplanar = false
|
||||
flags_fixed_size = false
|
||||
flags_albedo_tex_force_srgb = true
|
||||
vertex_color_use_as_albedo = false
|
||||
vertex_color_is_srgb = false
|
||||
params_diffuse_mode = 0
|
||||
params_specular_mode = 0
|
||||
params_blend_mode = 0
|
||||
params_cull_mode = 2
|
||||
params_depth_draw_mode = 0
|
||||
params_line_width = 1.0
|
||||
params_point_size = 1.0
|
||||
params_billboard_mode = 0
|
||||
params_grow = false
|
||||
params_use_alpha_scissor = false
|
||||
albedo_color = Color( 1, 1, 1, 1 )
|
||||
albedo_texture = SubResource( 29 )
|
||||
metallic = 0.0
|
||||
metallic_specular = 0.5
|
||||
metallic_texture_channel = 0
|
||||
roughness = 0.0
|
||||
roughness_texture_channel = 0
|
||||
emission_enabled = false
|
||||
normal_enabled = false
|
||||
rim_enabled = false
|
||||
clearcoat_enabled = false
|
||||
anisotropy_enabled = false
|
||||
ao_enabled = false
|
||||
depth_enabled = false
|
||||
subsurf_scatter_enabled = false
|
||||
transmission_enabled = false
|
||||
refraction_enabled = false
|
||||
detail_enabled = false
|
||||
uv1_scale = Vector3( 1, 1, 1 )
|
||||
uv1_offset = Vector3( 0, 0, 0 )
|
||||
uv1_triplanar = false
|
||||
uv1_triplanar_sharpness = 1.0
|
||||
uv2_scale = Vector3( 1, 1, 1 )
|
||||
uv2_offset = Vector3( 0, 0, 0 )
|
||||
uv2_triplanar = false
|
||||
uv2_triplanar_sharpness = 1.0
|
||||
proximity_fade_enable = false
|
||||
distance_fade_enable = false
|
||||
_sections_unfolded = [ "Albedo", "Flags", "Metallic", "Parameters", "Resource" ]
|
||||
|
||||
[sub_resource type="ConvexPolygonShape" id=31]
|
||||
|
||||
points = PoolVector3Array( -0.5, -0.5, 0, -0.5, 0.5, 0, 0.5, 0.5, 0, 0.5, -0.5, 0 )
|
||||
|
||||
[node name="Game" type="Spatial" index="0"]
|
||||
|
||||
_sections_unfolded = [ "Transform" ]
|
||||
|
||||
|
@ -1138,7 +1208,88 @@ draw_pass_2 = SubResource( 27 )
|
|||
[node name="jukebox" parent="." index="2" instance=ExtResource( 13 )]
|
||||
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7.67816, 0, 0 )
|
||||
music_window = "../../GUI/HUD/Music"
|
||||
_sections_unfolded = [ "Transform" ]
|
||||
|
||||
[node name="JukeBoxArea" type="Area" parent="jukebox" index="3"]
|
||||
|
||||
transform = Transform( -4.96064e-008, -0.173067, 0.981514, 3.42613e-008, 0.981514, 0.173067, -0.996655, 4.23548e-008, -4.29033e-008, 0.5, 2.5, 0 )
|
||||
input_ray_pickable = true
|
||||
input_capture_on_drag = true
|
||||
space_override = 0
|
||||
gravity_point = false
|
||||
gravity_distance_scale = 0.0
|
||||
gravity_vec = Vector3( 0, -1, 0 )
|
||||
gravity = 9.8
|
||||
linear_damp = 0.1
|
||||
angular_damp = 1.0
|
||||
priority = 0.0
|
||||
monitoring = true
|
||||
monitorable = true
|
||||
collision_layer = 1
|
||||
collision_mask = 1
|
||||
audio_bus_override = false
|
||||
audio_bus_name = "Master"
|
||||
reverb_bus_enable = false
|
||||
reverb_bus_name = "Master"
|
||||
reverb_bus_amount = 0.0
|
||||
reverb_bus_uniformity = 0.0
|
||||
_sections_unfolded = [ "Collision", "Transform" ]
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="jukebox/JukeBoxArea" index="0"]
|
||||
|
||||
transform = Transform( 1, 0, 0, -7.10543e-015, 1, -9.55343e-016, 7.10543e-015, -9.55343e-016, 1, 0, 0, 0 )
|
||||
layers = 1
|
||||
material_override = null
|
||||
cast_shadow = 1
|
||||
extra_cull_margin = 0.0
|
||||
use_in_baked_light = false
|
||||
lod_min_distance = 0.0
|
||||
lod_min_hysteresis = 0.0
|
||||
lod_max_distance = 0.0
|
||||
lod_max_hysteresis = 0.0
|
||||
mesh = SubResource( 28 )
|
||||
skeleton = NodePath("..")
|
||||
material/0 = SubResource( 30 )
|
||||
_sections_unfolded = [ "Geometry", "Transform", "material" ]
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="jukebox/JukeBoxArea" index="1"]
|
||||
|
||||
shape = SubResource( 31 )
|
||||
disabled = false
|
||||
_sections_unfolded = [ "Transform" ]
|
||||
|
||||
[node name="Viewport" type="Viewport" parent="jukebox" index="4"]
|
||||
|
||||
arvr = false
|
||||
size = Vector2( 256, 256 )
|
||||
own_world = false
|
||||
world = null
|
||||
transparent_bg = true
|
||||
msaa = 0
|
||||
hdr = false
|
||||
disable_3d = false
|
||||
usage = 0
|
||||
debug_draw = 0
|
||||
render_target_v_flip = true
|
||||
render_target_clear_mode = 0
|
||||
render_target_update_mode = 2
|
||||
audio_listener_enable_2d = false
|
||||
audio_listener_enable_3d = false
|
||||
physics_object_picking = false
|
||||
gui_disable_input = false
|
||||
gui_snap_controls_to_pixels = true
|
||||
shadow_atlas_size = 0
|
||||
shadow_atlas_quad_0 = 2
|
||||
shadow_atlas_quad_1 = 2
|
||||
shadow_atlas_quad_2 = 3
|
||||
shadow_atlas_quad_3 = 4
|
||||
_sections_unfolded = [ "Audio Listener", "GUI", "Physics", "Render Target", "Rendering", "Shadow Atlas" ]
|
||||
|
||||
[node name="Music" parent="jukebox/Viewport" index="0" instance=ExtResource( 14 )]
|
||||
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 2
|
||||
_sections_unfolded = [ "Mouse", "Rect", "Size Flags", "custom_constants" ]
|
||||
|
||||
[connection signal="sleeping_state_changed" from="World/Box" to="World/Box" method="_on_Box_sleeping_state_changed"]
|
||||
|
||||
|
|
|
@ -1,17 +1,78 @@
|
|||
extends Spatial
|
||||
|
||||
export( String ) var music_window = ""
|
||||
# Member variables
|
||||
var prev_pos = null
|
||||
var last_click_pos = null
|
||||
var viewport = null
|
||||
|
||||
|
||||
func _ready():
|
||||
viewport = get_node("Viewport")
|
||||
get_node("JukeBoxArea").connect("input_event", self, "_on_area_input_event")
|
||||
|
||||
func _input(event):
|
||||
# Check if the event is a non-mouse event
|
||||
var is_mouse_event = false
|
||||
var mouse_events = [InputEventMouseButton, InputEventMouseMotion, InputEventScreenDrag, InputEventScreenTouch]
|
||||
for mouse_event in mouse_events:
|
||||
if (event is mouse_event):
|
||||
is_mouse_event = true
|
||||
break
|
||||
|
||||
# If it is, then pass the event to the viewport
|
||||
if (is_mouse_event == false):
|
||||
viewport.input(event)
|
||||
|
||||
|
||||
# Mouse events for Area
|
||||
func _on_area_input_event(camera, event, click_pos, click_normal, shape_idx):
|
||||
print("area")
|
||||
# Use click pos (click in 3d space, convert to area space)
|
||||
var pos = get_node("JukeBoxArea").get_global_transform().affine_inverse()
|
||||
# the click pos is not zero, then use it to convert from 3D space to area space
|
||||
if (click_pos.x != 0 or click_pos.y != 0 or click_pos.z != 0):
|
||||
pos *= click_pos
|
||||
last_click_pos = click_pos
|
||||
else:
|
||||
# Otherwise, we have a motion event and need to use our last click pos
|
||||
# and move it according to the relative position of the event.
|
||||
# NOTE: this is not an exact 1-1 conversion, but it's pretty close
|
||||
pos *= last_click_pos
|
||||
if (event is InputEventMouseMotion or event is InputEventScreenDrag):
|
||||
pos.x += event.relative.x / viewport.size.x
|
||||
pos.y += event.relative.y / viewport.size.y
|
||||
last_click_pos = pos
|
||||
|
||||
# Convert to 2D
|
||||
pos = Vector2(pos.x, pos.y)
|
||||
|
||||
# Convert to viewport coordinate system
|
||||
# Convert pos to a range from (0 - 1)
|
||||
pos.y *= -1
|
||||
pos += Vector2(1, 1)
|
||||
pos = pos / 2
|
||||
|
||||
# Convert pos to be in range of the viewport
|
||||
pos.x *= viewport.size.x
|
||||
pos.y *= viewport.size.y
|
||||
|
||||
# Set the position in event
|
||||
event.position = pos
|
||||
event.global_position = pos
|
||||
if (prev_pos == null):
|
||||
prev_pos = pos
|
||||
if (event is InputEventMouseMotion):
|
||||
event.relative = pos - prev_pos
|
||||
prev_pos = pos
|
||||
|
||||
# Send the event to the viewport
|
||||
viewport.input(event)
|
||||
|
||||
|
||||
func _on_Area_body_entered(body):
|
||||
print( "jukebox entered: " +str(body.name) )
|
||||
if not music_window == "" and get_node( music_window ) and body.name == "Character":
|
||||
get_node( music_window ).show()
|
||||
print( "test entered" )
|
||||
|
||||
if get_node( "JukeBoxArea" ) and body.name == "Character":
|
||||
get_node( "JukeBoxArea" ).show()
|
||||
|
||||
func _on_Area_body_exited(body):
|
||||
print( "jukebox exited: " +str(body.name) )
|
||||
if not music_window == "" and get_node( music_window ) and body.name == "Character":
|
||||
get_node( music_window ).hide()
|
||||
print( "test exited" )
|
||||
if get_node( "JukeBoxArea" ) and body.name == "Character":
|
||||
get_node( "JukeBoxArea" ).hide()
|
||||
|
|
|
@ -260,7 +260,6 @@ extents = Vector3( 2.62941, 1.97978, 1.99544 )
|
|||
[node name="jukebox" type="Spatial"]
|
||||
|
||||
script = ExtResource( 1 )
|
||||
music_window = ""
|
||||
|
||||
[node name="head" type="MeshInstance" parent="." index="0"]
|
||||
|
||||
|
|
Loading…
Reference in a new issue