make existing keys consider swapping with the closest replacement key when regenerating
This commit is contained in:
parent
b0d577701e
commit
38f94c4f0f
@ -259,9 +259,17 @@ func _regenerate_row(
|
||||
var dict_key := Vector2i(key_props.physical_keycode, key_props.location)
|
||||
|
||||
if current_keys.has(dict_key):
|
||||
var game_key := current_keys[dict_key].pop_front() as GameKey
|
||||
game_key.load_props(key_props, key_default_pos)
|
||||
if current_keys[dict_key].size() == 0:
|
||||
var game_keys := current_keys[dict_key] as Array[GameKey]
|
||||
var game_key_idx: int
|
||||
var min_dist: float = 0
|
||||
for i in range(game_keys.size()):
|
||||
var dist := game_keys[i].position.distance_to(key_default_pos)
|
||||
if min_dist == 0 or dist <= min_dist:
|
||||
min_dist = dist
|
||||
game_key_idx = i
|
||||
game_keys[game_key_idx].load_props(key_props, key_default_pos)
|
||||
game_keys.remove_at(game_key_idx)
|
||||
if game_keys.size() == 0:
|
||||
current_keys.erase(dict_key)
|
||||
else:
|
||||
var props_dict := LayoutConfig.get_key_config_dict(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user