activate button control

This commit is contained in:
AleaJactaEst 2022-04-15 15:54:35 +02:00
parent eab25005a1
commit 692aac7930
7 changed files with 256 additions and 46 deletions

View file

@ -176,6 +176,9 @@ var save_camera_rotate_y:float
var save_camera_position_y:float
var save_zoom:float
var input_view_camera_move_player_follow_mouse = false
var input_view_camera_move_only_mouse = false
var input_action_camera_move_player_mouse = false
func save_position_camera():
#Common.msg_debug("Save pos camera")
@ -401,12 +404,49 @@ func get_distance_vector(obj1: Vector3, obj2: Vector3) -> float:
return obj1.distance_to(obj2)
func is_mouse_button_pressed(action):
var pressed:bool = true
var ext = String(action) + "_PLUS"
Common.msg_debug("action:" + action)
if InputMap.has_action(ext):
if InputMap.action_get_events(ext).size() > 0:
for a in InputMap.action_get_events(ext):
Common.msg_debug(str(a))
Common.msg_debug("Size:" + str(InputMap.action_get_events(ext).size()))
pressed = Input.is_action_pressed(ext)
var res = Input.is_action_pressed(action) and pressed
Common.msg_debug("action:" + action + " -> " + str(res) + " / " + str(Input.is_action_pressed(action)) + " / " +str(pressed))
return res
func _input(event):
if Input.is_action_just_pressed("INPUT_VIEW_BACK_ONLY_PRESSED", true):
save_position_camera()
switch_camera_tps_back()
elif Input.is_action_just_released("INPUT_VIEW_BACK_ONLY_PRESSED", true):
restore_position_camera()
if event is InputEventMouseButton:
Common.msg_debug("----------")
if is_mouse_button_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW_MOUSE"):
input_view_camera_move_player_follow_mouse = true
Common.msg_debug("input_view_camera_move_player_follow_mouse")
else:
input_view_camera_move_player_follow_mouse = false
if is_mouse_button_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY_MOUSE"):
input_view_camera_move_only_mouse = true
Common.msg_debug("input_view_camera_move_only_mouse")
else:
input_view_camera_move_only_mouse = false
if is_mouse_button_pressed("INPUT_ACTION_CAMERA_MOVE_PLAYER_MOUSE"):
input_action_camera_move_player_mouse = true
Common.msg_debug("input_action_camera_move_player_mouse")
else:
input_action_camera_move_player_mouse = false
if tps:
if Input.is_action_pressed("INPUT_VIEW_FRONT", true) and tps:
# Move camera position on front
@ -420,29 +460,17 @@ func _input(event):
camera_zoom_out()
if Input.is_action_just_pressed("INPUT_VIEW_CAMERA_FPS_TPS", true):
switch_camera_fps()
if Input.is_action_just_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"):
# Mouse Button Right (start)
pass
elif Input.is_action_just_released("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"):
# Mouse Button Right (stop)
pass
elif Input.is_action_just_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY"):
# Mouse Button Left (start)
pass
elif Input.is_action_just_released("INPUT_VIEW_CAMERA_MOVE_ONLY"):
# Mouse Button Left (stop)
pass
elif Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW") or Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY"):
if input_view_camera_move_player_follow_mouse or input_view_camera_move_only_mouse or input_action_camera_move_player_mouse:
if event is InputEventMouseMotion:
move_camera(event.relative.y * 0.01 , - event.relative.x *0.01)
if Input.is_action_just_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"):
if input_view_camera_move_player_follow_mouse or input_action_camera_move_player_mouse:
reconciliate_rotate_camera_player = true
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
elif Input.is_action_just_released("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"):
else: #elif Input.is_action_just_released("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"):
# reconciliate_rotate_camera_player = false # continue move camera, and stop when it's arrive in final position
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
if Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW") or Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY"):
if input_view_camera_move_player_follow_mouse or input_view_camera_move_only_mouse or input_action_camera_move_player_mouse:
if event is InputEventMouseMotion:
camera_rotate_y = player_rotate_y
player_rotate_y += event.relative.x *0.01
@ -923,7 +951,7 @@ func _process( delta ):
offset_camera_current += offset_diff
if reconciliate_rotate_player_back:
var diff = camera_rotate_y - player_rotate_y
if not Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"):
if not input_view_camera_move_player_follow_mouse and not input_action_camera_move_player_mouse:
if diff <= 0.01 and diff >= -0.01:
reconciliate_rotate_player_back = false
return
@ -944,7 +972,7 @@ func _process( delta ):
rotate_camera_y(diff)
elif reconciliate_rotate_camera_player:
var diff = camera_rotate_y - player_rotate_y
if not Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"):
if not input_view_camera_move_player_follow_mouse and not input_action_camera_move_player_mouse:
if diff <= 0.01 and diff >= -0.01:
reconciliate_rotate_camera_player = false
return
@ -1028,7 +1056,7 @@ func _process( delta ):
camera_rotate_y = player_rotate_y
rotate_y( angle_y )
#detect_camera_collision_y( angle_y) # Ignore detection, will try to reposition after
if Input.is_action_pressed("INPUT_ACTION_UP") or (Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW") and Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY")):
if Input.is_action_pressed("INPUT_ACTION_UP") or input_action_camera_move_player_mouse:
input_y = 1.0
input_z = 1.0
move_up = true

View file

@ -12,8 +12,8 @@ radius = 0.781675
height = 1.69837
[sub_resource type="CylinderShape3D" id="CylinderShape3D_lc75a"]
radius = 0.4
height = 2.75615
radius = 0.4
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_645as"]
radius = 0.608862

View file

@ -287,6 +287,18 @@ INPUT_ACTION_CAMERA_MOVE_PLAYER_MOUSE_PLUS={
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"button_mask":2,"position":Vector2(217, 135),"global_position":Vector2(217, 135),"factor":1.0,"button_index":2,"pressed":true,"double_click":false,"script":null)
]
}
INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW_JOYPAD={
"deadzone": 0.5,
"events": []
}
INPUT_VIEW_CAMERA_MOVE_ONLY_JOYPAD={
"deadzone": 0.5,
"events": []
}
INPUT_ACTION_CAMERA_MOVE_PLAYER_JOYPAD={
"deadzone": 0.5,
"events": []
}
[internationalization]

View file

@ -138,6 +138,9 @@ func update_mouse_button_move_camera():
$Window/v/Tab/MOUSE/v/CameraPlayer/h1/SelectButton.set_text(Common.get_input_plus("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW_MOUSE"))
$Window/v/Tab/MOUSE/v/CameraOnly/h1/SelectButton.set_text(Common.get_input_plus("INPUT_VIEW_CAMERA_MOVE_ONLY_MOUSE"))
$Window/v/Tab/MOUSE/v/CameraPlayerWalk/h1/SelectButton.set_text(Common.get_input_plus("INPUT_ACTION_CAMERA_MOVE_PLAYER_MOUSE"))
$Window/v/Tab/JOYPAD/v/CameraPlayer/h1/SelectButton.set_text(Common.get_input_plus("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW_JOYPAD"))
$Window/v/Tab/JOYPAD/v/CameraOnly/h1/SelectButton.set_text(Common.get_input_plus("INPUT_VIEW_CAMERA_MOVE_ONLY_JOYPAD"))
$Window/v/Tab/JOYPAD/v/CameraPlayerWalk/h1/SelectButton.set_text(Common.get_input_plus("INPUT_ACTION_CAMERA_MOVE_PLAYER_JOYPAD"))
func configure_control():
@ -382,22 +385,43 @@ func define_mouse_camera_move():
show_windows()
func _on_select_button_pressed():
func _on_select_mouse_button_camera_player_pressed():
$Window.visible = false
$DefineInput.set_param(2, "INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW_MOUSE")
$DefineInput/Window.popup_centered()
$DefineInput/Window.visible = true
func _on_camear_only_button_pressed():
func _on_select_mouse_button_camera_only_pressed():
$Window.visible = false
$DefineInput.set_param(2, "INPUT_VIEW_CAMERA_MOVE_ONLY_MOUSE")
$DefineInput/Window.popup_centered()
$DefineInput/Window.visible = true
func _on_camera_player_walk_button_pressed():
func _on_select_mouse_button_camera_player_walk_pressed():
$Window.visible = false
$DefineInput.set_param(2, "INPUT_VIEW_CAMERA_PLAYER_WALK_MOUSE")
$DefineInput/Window.popup_centered()
$DefineInput/Window.visible = true
func _on_select_joypad_button_camera_player_pressed():
$Window.visible = false
$DefineInput.set_param(4, "INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW_JOYPAD")
$DefineInput/Window.popup_centered()
$DefineInput/Window.visible = true
func _on_select_joypad_button_camera_only_pressed():
$Window.visible = false
$DefineInput.set_param(4, "INPUT_VIEW_CAMERA_MOVE_ONLY_JOYPAD")
$DefineInput/Window.popup_centered()
$DefineInput/Window.visible = true
func _on_joypad_camera_player_walk_button_pressed():
$Window.visible = false
$DefineInput.set_param(4, "INPUT_VIEW_CAMERA_PLAYER_WALK_JOYPAD")
$DefineInput/Window.popup_centered()
$DefineInput/Window.visible = true

View file

@ -238,6 +238,151 @@ offset_right = 24.0
offset_bottom = 31.0
text = "EDIT_CONTROL/MOVE_CAMERA_REVERSE_VERTICAL"
[node name="JOYPAD" type="ScrollContainer" parent="Window/v/Tab"]
visible = false
offset_right = 40.0
offset_bottom = 40.0
[node name="v" type="VBoxContainer" parent="Window/v/Tab/JOYPAD"]
offset_right = 934.0
offset_bottom = 312.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="CameraPlayer" type="VBoxContainer" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="Window/v/Tab/JOYPAD/v/CameraPlayer"]
offset_right = 40.0
offset_bottom = 23.0
text = "INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"
[node name="h1" type="HBoxContainer" parent="Window/v/Tab/JOYPAD/v/CameraPlayer"]
offset_right = 40.0
offset_bottom = 40.0
[node name="space" type="Label" parent="Window/v/Tab/JOYPAD/v/CameraPlayer/h1"]
minimum_size = Vector2(50, 0)
offset_right = 40.0
offset_bottom = 23.0
[node name="SelectButton" type="Button" parent="Window/v/Tab/JOYPAD/v/CameraPlayer/h1"]
offset_right = 8.0
offset_bottom = 31.0
text = "SELECT"
[node name="h2" type="HBoxContainer" parent="Window/v/Tab/JOYPAD/v/CameraPlayer"]
offset_right = 40.0
offset_bottom = 40.0
[node name="space" type="Label" parent="Window/v/Tab/JOYPAD/v/CameraPlayer/h2"]
minimum_size = Vector2(50, 0)
offset_right = 40.0
offset_bottom = 23.0
[node name="ReverseHorizontal" type="CheckBox" parent="Window/v/Tab/JOYPAD/v/CameraPlayer/h2"]
offset_right = 24.0
offset_bottom = 31.0
text = "EDIT_CONTROL/MOVE_CAMERA_REVERSE_HORIZONTAL"
[node name="ReverseVertical" type="CheckBox" parent="Window/v/Tab/JOYPAD/v/CameraPlayer/h2"]
offset_right = 24.0
offset_bottom = 31.0
text = "EDIT_CONTROL/MOVE_CAMERA_REVERSE_VERTICAL"
[node name="HSeparator1" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
[node name="CameraOnly" type="VBoxContainer" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="Window/v/Tab/JOYPAD/v/CameraOnly"]
offset_right = 40.0
offset_bottom = 23.0
text = "INPUT_VIEW_CAMERA_MOVE_ONLY"
[node name="h1" type="HBoxContainer" parent="Window/v/Tab/JOYPAD/v/CameraOnly"]
offset_right = 40.0
offset_bottom = 40.0
[node name="space" type="Label" parent="Window/v/Tab/JOYPAD/v/CameraOnly/h1"]
minimum_size = Vector2(50, 0)
offset_right = 40.0
offset_bottom = 23.0
[node name="SelectButton" type="Button" parent="Window/v/Tab/JOYPAD/v/CameraOnly/h1"]
offset_right = 8.0
offset_bottom = 31.0
text = "SELECT"
[node name="h2" type="HBoxContainer" parent="Window/v/Tab/JOYPAD/v/CameraOnly"]
offset_right = 40.0
offset_bottom = 40.0
[node name="space" type="Label" parent="Window/v/Tab/JOYPAD/v/CameraOnly/h2"]
minimum_size = Vector2(50, 0)
offset_right = 40.0
offset_bottom = 23.0
[node name="ReverseHorizontal" type="CheckBox" parent="Window/v/Tab/JOYPAD/v/CameraOnly/h2"]
offset_right = 24.0
offset_bottom = 31.0
text = "EDIT_CONTROL/MOVE_CAMERA_REVERSE_HORIZONTAL"
[node name="ReverseVertical" type="CheckBox" parent="Window/v/Tab/JOYPAD/v/CameraOnly/h2"]
offset_right = 24.0
offset_bottom = 31.0
text = "EDIT_CONTROL/MOVE_CAMERA_REVERSE_VERTICAL"
[node name="HSeparator2" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
[node name="CameraPlayerWalk" type="VBoxContainer" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="Window/v/Tab/JOYPAD/v/CameraPlayerWalk"]
offset_right = 40.0
offset_bottom = 23.0
text = "INPUT_ACTION_CAMERA_MOVE_PLAYER"
[node name="h1" type="HBoxContainer" parent="Window/v/Tab/JOYPAD/v/CameraPlayerWalk"]
offset_right = 40.0
offset_bottom = 40.0
[node name="space" type="Label" parent="Window/v/Tab/JOYPAD/v/CameraPlayerWalk/h1"]
minimum_size = Vector2(50, 0)
offset_right = 40.0
offset_bottom = 23.0
[node name="SelectButton" type="Button" parent="Window/v/Tab/JOYPAD/v/CameraPlayerWalk/h1"]
offset_right = 8.0
offset_bottom = 31.0
text = "SELECT"
[node name="h2" type="HBoxContainer" parent="Window/v/Tab/JOYPAD/v/CameraPlayerWalk"]
offset_right = 40.0
offset_bottom = 40.0
[node name="space" type="Label" parent="Window/v/Tab/JOYPAD/v/CameraPlayerWalk/h2"]
minimum_size = Vector2(50, 0)
offset_right = 40.0
offset_bottom = 23.0
[node name="ReverseHorizontal" type="CheckBox" parent="Window/v/Tab/JOYPAD/v/CameraPlayerWalk/h2"]
offset_right = 24.0
offset_bottom = 31.0
text = "EDIT_CONTROL/MOVE_CAMERA_REVERSE_HORIZONTAL"
[node name="ReverseVertical" type="CheckBox" parent="Window/v/Tab/JOYPAD/v/CameraPlayerWalk/h2"]
offset_right = 24.0
offset_bottom = 31.0
text = "EDIT_CONTROL/MOVE_CAMERA_REVERSE_VERTICAL"
[node name="Quit" type="Button" parent="Window/v"]
anchor_left = 0.5
anchor_top = 1.0
@ -263,7 +408,10 @@ metadata/_edit_use_custom_anchors = false
[connection signal="pressed" from="Window/v/Tab/CONTROL/Menu/SortByInput" to="." method="_on_sort_by_input_pressed"]
[connection signal="pressed" from="Window/v/Tab/CONTROL/Menu/Reload" to="." method="reload_control_system"]
[connection signal="button_pressed" from="Window/v/Tab/CONTROL/Tree" to="." method="_on_tree_button_pressed"]
[connection signal="pressed" from="Window/v/Tab/MOUSE/v/CameraPlayer/h1/SelectButton" to="." method="_on_select_button_pressed"]
[connection signal="pressed" from="Window/v/Tab/MOUSE/v/CameraOnly/h1/SelectButton" to="." method="_on_select_button_pressed"]
[connection signal="pressed" from="Window/v/Tab/MOUSE/v/CameraPlayerWalk/h1/SelectButton" to="." method="_on_select_button_pressed"]
[connection signal="pressed" from="Window/v/Tab/MOUSE/v/CameraPlayer/h1/SelectButton" to="." method="_on_select_mouse_button_camera_player_pressed"]
[connection signal="pressed" from="Window/v/Tab/MOUSE/v/CameraOnly/h1/SelectButton" to="." method="_on_select_mouse_button_camera_only_pressed"]
[connection signal="pressed" from="Window/v/Tab/MOUSE/v/CameraPlayerWalk/h1/SelectButton" to="." method="_on_select_mouse_button_camera_player_walk_pressed"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/CameraPlayer/h1/SelectButton" to="." method="_on_select_joypad_button_camera_player_pressed"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/CameraOnly/h1/SelectButton" to="." method="_on_select_joypad_button_camera_only_pressed"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/CameraPlayerWalk/h1/SelectButton" to="." method="_on_joypad_camera_player_walk_button_pressed"]
[connection signal="pressed" from="Window/v/Quit" to="." method="_on_quit_pressed"]

View file

@ -32,8 +32,12 @@ func set_param(typeevent:int, _action):
comment = "OPTION_DEFINE_INPUT/MESSAGE_KEY"
elif typeevent == 2:
comment = "OPTION_DEFINE_INPUT/MESSAGE_MOUSE"
else:
elif typeevent == 3:
comment = "OPTION_DEFINE_INPUT/MESSAGE_JOYPAD"
elif typeevent == 4:
comment = "OPTION_DEFINE_INPUT/MESSAGE_JOYPAD"
else:
comment = "OPTION_DEFINE_INPUT/DISABLED"
type_event = typeevent
action = _action
last_event = null
@ -88,7 +92,19 @@ func _on_window_window_input(event):
#last_last_event = last_event
last_event = event
$Window/v/result.set_text( Common.get_string_input(event) )
elif event is InputEventJoypadMotion and self.type_event == 4:
#last_last_event = last_event
if not last_event:
last_event = event
elif last_event.get_axis() != event.get_axis():
last_last_event = last_event
last_event = event
if last_last_event != null:
$Window/v/result.set_text( "Axe:" + str(event.get_axis()) + " & " + str(last_last_event.get_axis()))
else:
$Window/v/result.set_text( "move all axes" )
if last_event != null:
if self.type_event != 4 or last_last_event != null:
set_disabled(false)

View file

@ -3,24 +3,6 @@ extends Node3D
var oldobject:Node3D = null
@onready var player_ptr = $player
#func _init():
# var content = "N/A"
# var file = File.new()
# if file.file_exists("res://.git/HEAD"):
# file.open("res://.git/HEAD", File.READ)
# content = file.get_as_text().strip_escapes()
# file.close()
# var head:String = content.split(' ')[1]
#
# file.open("res://.git/" + head, File.READ)
# content = file.get_as_text().strip_escapes()
# file.close()
# elif file.file_exists("res://commit.txt"):
# file.open("res://commit.txt", File.READ)
# content = file.get_as_text().strip_escapes()
# file.close()
# Common.msg_debug("Commit: " + content)
# Called when the node enters the scene tree for the first time.
func _ready():