disable move or mouse on screen when menu is visible

This commit is contained in:
AleaJactaEst 2023-04-20 00:24:05 +02:00
parent 9a2a797ee3
commit a94095128e
8 changed files with 26 additions and 8 deletions

View file

@ -47,8 +47,10 @@ func _physics_process(_delta):
set("parameters/VelocityDirection/crouching/conditions/walking",movement_script.gait == Global.gait.walking and movement_script.input_is_moving) set("parameters/VelocityDirection/crouching/conditions/walking",movement_script.gait == Global.gait.walking and movement_script.input_is_moving)
#On Stopped #On Stopped
if !(Input.is_action_pressed("INPUT_ACTION_FORWARD") || Input.is_action_pressed("INPUT_ACTION_BACK") || Input.is_action_pressed("INPUT_ACTION_RIGHT") || Input.is_action_pressed("INPUT_ACTION_LEFT")) and (Input.is_action_just_released("INPUT_ACTION_RIGHT") || Input.is_action_just_released("INPUT_ACTION_BACK") || Input.is_action_just_released("INPUT_ACTION_LEFT") || Input.is_action_just_released("INPUT_ACTION_FORWARD")): if Common.is_menu_visible():
var seek_time = get_node(anim_player).get_animation(tree_root.get_node("VelocityDirection").get_node("standing").get_node("Stopping").get_node("StopAnim").animation).length - movement_script.pose_warping_instance.CalculateStopTime((movement_script.actual_velocity * Vector3(1.0,0.0,1.0)),movement_script.deacceleration * movement_script.direction)
set("parameters/VelocityDirection/standing/Stopping/StopSeek/seek_position",seek_time)
elif !(Input.is_action_pressed("INPUT_ACTION_FORWARD") || Input.is_action_pressed("INPUT_ACTION_BACK") || Input.is_action_pressed("INPUT_ACTION_RIGHT") || Input.is_action_pressed("INPUT_ACTION_LEFT")) and (Input.is_action_just_released("INPUT_ACTION_RIGHT") || Input.is_action_just_released("INPUT_ACTION_BACK") || Input.is_action_just_released("INPUT_ACTION_LEFT") || Input.is_action_just_released("INPUT_ACTION_FORWARD")):
var seek_time = get_node(anim_player).get_animation(tree_root.get_node("VelocityDirection").get_node("standing").get_node("Stopping").get_node("StopAnim").animation).length - movement_script.pose_warping_instance.CalculateStopTime((movement_script.actual_velocity * Vector3(1.0,0.0,1.0)),movement_script.deacceleration * movement_script.direction) var seek_time = get_node(anim_player).get_animation(tree_root.get_node("VelocityDirection").get_node("standing").get_node("Stopping").get_node("StopAnim").animation).length - movement_script.pose_warping_instance.CalculateStopTime((movement_script.actual_velocity * Vector3(1.0,0.0,1.0)),movement_script.deacceleration * movement_script.direction)
set("parameters/VelocityDirection/standing/Stopping/StopSeek/seek_position",seek_time) set("parameters/VelocityDirection/standing/Stopping/StopSeek/seek_position",seek_time)
set("parameters/VelocityDirection/standing/conditions/stop",!movement_script.input_is_moving) set("parameters/VelocityDirection/standing/conditions/stop",!movement_script.input_is_moving)

View file

@ -68,6 +68,8 @@ func _ready():
func _input(event): func _input(event):
if Common.is_menu_visible():
return
if event is InputEventMouseMotion: if event is InputEventMouseMotion:
camera_h += -event.relative.x * mouse_sensitvity camera_h += -event.relative.x * mouse_sensitvity
camera_v += -event.relative.y * mouse_sensitvity camera_v += -event.relative.y * mouse_sensitvity

View file

@ -375,8 +375,6 @@ func _ready():
update_character_movement() update_character_movement()
var pose_warping_instance = pose_warping.new() var pose_warping_instance = pose_warping.new()
func _process(delta): func _process(delta):
calc_animation_data() calc_animation_data()
var orientation_warping_condition = rotation_mode != Global.rotation_mode.velocity_direction and movement_state == Global.movement_state.grounded and movement_action == Global.movement_action.none and gait != Global.gait.sprinting and input_is_moving var orientation_warping_condition = rotation_mode != Global.rotation_mode.velocity_direction and movement_state == Global.movement_state.grounded and movement_action == Global.movement_action.none and gait != Global.gait.sprinting and input_is_moving
pose_warping_instance.orientation_warping( orientation_warping_condition,camera_root.HObject,animation_velocity,skeleton_ref,"Hips",["Spine","Spine1","Spine2"],0.0,delta) pose_warping_instance.orientation_warping( orientation_warping_condition,camera_root.HObject,animation_velocity,skeleton_ref,"Hips",["Spine","Spine1","Spine2"],0.0,delta)

View file

@ -36,6 +36,9 @@ func _physics_process(delta):
h_rotation = camera_root.HObject.transform.basis.get_euler().y h_rotation = camera_root.HObject.transform.basis.get_euler().y
# v_rotation = camera_root.VObject.transform.basis.get_euler().x # v_rotation = camera_root.VObject.transform.basis.get_euler().x
if Common.is_menu_visible():
add_movement_input(direction,0,deacceleration)
return
if Input.is_action_pressed("INPUT_ACTION_FORWARD") || Input.is_action_pressed("INPUT_ACTION_BACK") || Input.is_action_pressed("INPUT_ACTION_RIGHT") || Input.is_action_pressed("INPUT_ACTION_LEFT") : if Input.is_action_pressed("INPUT_ACTION_FORWARD") || Input.is_action_pressed("INPUT_ACTION_BACK") || Input.is_action_pressed("INPUT_ACTION_RIGHT") || Input.is_action_pressed("INPUT_ACTION_LEFT") :
direction = Vector3(Input.get_action_strength("INPUT_ACTION_RIGHT") - Input.get_action_strength("INPUT_ACTION_LEFT"), direction = Vector3(Input.get_action_strength("INPUT_ACTION_RIGHT") - Input.get_action_strength("INPUT_ACTION_LEFT"),
0.0 if is_flying == true else 0.0, 0.0 if is_flying == true else 0.0,
@ -123,6 +126,8 @@ func _physics_process(delta):
var view_changed_recently = false var view_changed_recently = false
func _input(event): func _input(event):
if Common.is_menu_visible():
return
#------------------ Motion Warping test------------------# #------------------ Motion Warping test------------------#
if event.is_action_pressed("INPUT_ACTION_FIRE"): if event.is_action_pressed("INPUT_ACTION_FIRE"):
anim_ref.active = false anim_ref.active = false

File diff suppressed because one or more lines are too long

View file

@ -41,6 +41,9 @@ func _input(_event:InputEvent):
if $Menu.visible: if $Menu.visible:
# Force focus on Keys # Force focus on Keys
$Menu/About.grab_focus() $Menu/About.grab_focus()
Common.set_menu_visible(true)
else:
Common.set_menu_visible(false)
# elif $Menu.visible: # elif $Menu.visible:
# if _event.is_action_pressed("INPUT_ACTION_RIGHT"): # if _event.is_action_pressed("INPUT_ACTION_RIGHT"):
# print("INPUT_ACTION_RIGHT 2") # print("INPUT_ACTION_RIGHT 2")

View file

@ -99,8 +99,6 @@ visible = false
[node name="MenuControl" parent="." instance=ExtResource("3_08xl7")] [node name="MenuControl" parent="." instance=ExtResource("3_08xl7")]
layout_mode = 1 layout_mode = 1
grow_horizontal = 2
grow_vertical = 2
[node name="MenuTheme" parent="." instance=ExtResource("4_1poje")] [node name="MenuTheme" parent="." instance=ExtResource("4_1poje")]
visible = false visible = false

View file

@ -15,11 +15,21 @@ var factor_camera_verticale_joypad:float = 2.0
var factor_player_horizontale_joypad:float = 2.0 var factor_player_horizontale_joypad:float = 2.0
var factor_player_verticale_joypad:float = 2.0 var factor_player_verticale_joypad:float = 2.0
var menu_visible:bool = false
func _ready(): func _ready():
randomize() randomize()
func is_menu_visible() -> bool:
return menu_visible
func set_menu_visible(state:bool):
menu_visible = state
func get_time_text() -> String: func get_time_text() -> String:
var time = Time.get_datetime_dict_from_system() var time = Time.get_datetime_dict_from_system()
return "%s/%02d/%02d %02d:%02d:%02d" % [ return "%s/%02d/%02d %02d:%02d:%02d" % [