keebie/scripts/key_props.gd

45 lines
952 B
GDScript

class_name KeyProps
var physical_keycode: Key
var location: KeyLocation
var main_char: String
var shift_char: String
var alt_char: String
var alt_shift_char: String
var width_ratio_init: float
var width_ratio: float
func _init(
_physical_keycode: Key,
_width_ratio: float = 1,
_location: KeyLocation = KEY_LOCATION_UNSPECIFIED
) -> void:
physical_keycode = _physical_keycode
location = _location
width_ratio_init = _width_ratio
width_ratio = width_ratio_init
func is_char() -> bool:
return physical_keycode >= KEY_EXCLAM and physical_keycode <= KEY_SECTION
func to_dictionary() -> Dictionary:
return {
"main_char": main_char,
"shift_char": shift_char,
"alt_char": alt_char,
"alt_shift_char": alt_shift_char,
}
func from_dictionary(dictionary: Dictionary) -> void:
main_char = dictionary["main_char"]
shift_char = dictionary["shift_char"]
alt_char = dictionary["alt_char"]
alt_shift_char = dictionary["alt_shift_char"]