move sort func to key helper

This commit is contained in:
Teatov 2025-08-03 03:52:29 +10:00
parent 532505c812
commit e9a6d5ed5c
5 changed files with 10 additions and 11 deletions

View File

@ -84,14 +84,6 @@ static func instantiate_with_props(
return node
static func sort_func(a: GameKey, b: GameKey) -> bool:
var a_pos := a.get_default_transform().origin
var b_pos := b.get_default_transform().origin
if a_pos.y == b_pos.y:
return a_pos.x < b_pos.x
return a_pos.y < b_pos.y
#endregion

View File

@ -151,7 +151,7 @@ func request_keys(filter_func: Callable, limit: int = 0) -> Array[GameKey]:
_requested_keys = []
_requested_keys_limit = 0
requested_keys.sort_custom(GameKey.sort_func)
requested_keys.sort_custom(KeyHelper.sort_func)
return requested_keys

View File

@ -59,7 +59,6 @@ func swap_layout(layout_name: String) -> void:
func _set_defaults() -> void:
print("\nsetting defaults")
_set_layout(layouts.values()[0] as AbstractLayout)
# _set_layout(layouts[LayoutANSI.name_static()])
func _set_layout(layout: AbstractLayout) -> void:

View File

@ -51,6 +51,14 @@ const ADJACENCY_MAP: Dictionary[Key, Array] = {
}
static func sort_func(a: GameKey, b: GameKey) -> bool:
var a_pos := a.get_default_transform().origin
var b_pos := b.get_default_transform().origin
if a_pos.y == b_pos.y:
return a_pos.x < b_pos.x
return a_pos.y < b_pos.y
static func get_rotated_key_pos(
key_pos: Vector3, pivot: Vector2, angle: float
) -> Vector3:

View File

@ -54,7 +54,7 @@ func is_unicode() -> bool:
return OS.is_keycode_unicode(physical_keycode)
func is_viable_player_pos_key() -> bool:
func is_player_pos_key() -> bool:
return KeyHelper.ADJACENCY_MAP.has(physical_keycode)