store config keys as keycode strings instead of keycode enum values
This commit is contained in:
parent
d791ec24b3
commit
fcb5ba372f
@ -55,9 +55,6 @@ _center_label = NodePath("Labels/CenterLabel")
|
||||
_press_light = NodePath("Effects/PressLight")
|
||||
_adjacency_light = NodePath("Effects/AdjacencyLight")
|
||||
_sfx_player = NodePath("SFXPlayer")
|
||||
_light_fade_duration = null
|
||||
_starting_pop_offset = null
|
||||
_rotation_damping = null
|
||||
_press_sfx = SubResource("AudioStreamRandomizer_agrko")
|
||||
_release_sfx = SubResource("AudioStreamRandomizer_ch32x")
|
||||
|
||||
|
||||
@ -38,10 +38,10 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
|
||||
|
||||
func get_key_config_dict(keycode: Key) -> Dictionary:
|
||||
var param_key := str(keycode)
|
||||
if not _config.has_section_key(SECTION_KEYS, param_key):
|
||||
var config_key := OS.get_keycode_string(keycode)
|
||||
if not _config.has_section_key(SECTION_KEYS, config_key):
|
||||
return {}
|
||||
return _config.get_value(SECTION_KEYS, param_key, {}) as Dictionary
|
||||
return _config.get_value(SECTION_KEYS, config_key, {}) as Dictionary
|
||||
|
||||
|
||||
func change_layout(layout_name: String) -> void:
|
||||
@ -88,17 +88,17 @@ func _load_config() -> Error:
|
||||
|
||||
for key_props_row: Array[KeyProps] in layout_key_props_rows:
|
||||
for key_props in key_props_row:
|
||||
var keycode := str(key_props.keycode)
|
||||
var config_key := OS.get_keycode_string(key_props.keycode)
|
||||
if (
|
||||
not key_props.is_unicode()
|
||||
or not _config.has_section_key(SECTION_KEYS, keycode)
|
||||
or not _config.has_section_key(SECTION_KEYS, config_key)
|
||||
):
|
||||
continue
|
||||
|
||||
var chars_dict: Variant = _config.get_value(SECTION_KEYS, keycode)
|
||||
if chars_dict is not Dictionary[String,String]:
|
||||
var chars_dict: Variant = _config.get_value(SECTION_KEYS, config_key)
|
||||
if chars_dict is not Dictionary:
|
||||
continue
|
||||
key_props.chars_from_dict(chars_dict as Dictionary[String,String])
|
||||
key_props.chars_from_dict(chars_dict as Dictionary)
|
||||
|
||||
print("layout config loaded!\n")
|
||||
|
||||
@ -114,7 +114,9 @@ func _save_config() -> Error:
|
||||
continue
|
||||
|
||||
_config.set_value(
|
||||
SECTION_KEYS, str(key_props.keycode), key_props.chars_to_dict()
|
||||
SECTION_KEYS,
|
||||
OS.get_keycode_string(key_props.keycode),
|
||||
key_props.chars_to_dict()
|
||||
)
|
||||
|
||||
var err := _config.save(CONFIG_PATH)
|
||||
|
||||
@ -127,8 +127,8 @@ func chars_from_dict(dict: Dictionary, override: bool = true) -> KeyProps:
|
||||
return self
|
||||
|
||||
|
||||
func chars_to_dict() -> Dictionary[String, String]:
|
||||
var dict: Dictionary[String, String] = {}
|
||||
func chars_to_dict() -> Dictionary:
|
||||
var dict: Dictionary = {}
|
||||
if main_char:
|
||||
dict[CHAR_MAIN] = main_char
|
||||
if shift_char:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user