Improve Android controller and chat support
This commit is contained in:
parent
3dc8ced5d2
commit
ceef03eba5
24 changed files with 2485 additions and 128 deletions
|
|
@ -13,6 +13,9 @@ const SECTOR_COUNT: int = 8
|
|||
const RING_RADIUS: float = 172.0
|
||||
const BUBBLE_SIZE: Vector2 = Vector2(92.0, 88.0)
|
||||
const CONTROLLER_SELECTION_DEADZONE: float = 0.35
|
||||
const ControllerMappingManagerType = preload(
|
||||
"res://settings/controller_mapping_manager.gd"
|
||||
)
|
||||
const ACTIONS: Array[StringName] = [
|
||||
&"stuff",
|
||||
&"logbook",
|
||||
|
|
@ -38,6 +41,13 @@ var _buttons: Array[BubbleButton] = []
|
|||
var _is_open: bool = false
|
||||
var _selected_sector: int = 0
|
||||
var _controller_selection_mode: bool = false
|
||||
var _controller_mapping_manager: ControllerMappingManagerType
|
||||
|
||||
|
||||
func setup_controller_mapping(
|
||||
mapping_manager: ControllerMappingManagerType,
|
||||
) -> void:
|
||||
_controller_mapping_manager = mapping_manager
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -114,10 +124,7 @@ func _layout_bubbles() -> void:
|
|||
|
||||
|
||||
func _update_selection() -> void:
|
||||
var stick: Vector2 = Vector2(
|
||||
Input.get_joy_axis(0, JOY_AXIS_RIGHT_X),
|
||||
Input.get_joy_axis(0, JOY_AXIS_RIGHT_Y),
|
||||
)
|
||||
var stick: Vector2 = _get_selection_stick()
|
||||
if stick.length() >= CONTROLLER_SELECTION_DEADZONE:
|
||||
_select_sector_from_offset(stick)
|
||||
return
|
||||
|
|
@ -126,6 +133,25 @@ func _update_selection() -> void:
|
|||
_update_mouse_selection()
|
||||
|
||||
|
||||
func _get_selection_stick() -> Vector2:
|
||||
if (
|
||||
_controller_mapping_manager != null
|
||||
and _controller_mapping_manager.has_custom_mapping()
|
||||
):
|
||||
return Vector2(
|
||||
_controller_mapping_manager.get_role_axis(
|
||||
ControllerMappingManagerType.ROLE_RIGHT_STICK_X
|
||||
),
|
||||
_controller_mapping_manager.get_role_axis(
|
||||
ControllerMappingManagerType.ROLE_RIGHT_STICK_Y
|
||||
),
|
||||
)
|
||||
return Vector2(
|
||||
Input.get_joy_axis(0, JOY_AXIS_RIGHT_X),
|
||||
Input.get_joy_axis(0, JOY_AXIS_RIGHT_Y),
|
||||
)
|
||||
|
||||
|
||||
func _update_mouse_selection() -> void:
|
||||
var offset: Vector2 = get_local_mouse_position() - size * 0.5
|
||||
if offset.length() < 24.0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue