From 263e06a944dc1db267c665d39a3d29832f055f97 Mon Sep 17 00:00:00 2001 From: teatov Date: Sat, 2 Aug 2025 13:58:44 +1000 Subject: [PATCH] replace newlines in `printerr` with empty `print`s --- scripts/globals/layout_config.gd | 16 +++++++++------- scripts/key_props.gd | 2 +- scripts/layouts/layout_custom.gd | 10 +++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/globals/layout_config.gd b/scripts/globals/layout_config.gd index 941a3db..bbdcd82 100644 --- a/scripts/globals/layout_config.gd +++ b/scripts/globals/layout_config.gd @@ -83,7 +83,8 @@ func _load_config() -> Error: return FAILED if err != OK: - printerr("failed to load layout config file: '%s'\n" % err) + printerr("failed to load layout config file: '%s'" % err) + print() return FAILED var layout_name := "" @@ -142,7 +143,8 @@ func _load_custom_layouts(path: String) -> void: if not DirAccess.dir_exists_absolute(path): var dir_err := DirAccess.make_dir_absolute(path) if dir_err != OK: - printerr("error creating directory '%s': %s\n" % [path, dir_err]) + printerr("error creating directory '%s': %s" % [path, dir_err]) + print() return var file_err := DirAccess.copy_absolute( CUSTOM_LAYOUTS_README, path.path_join(CUSTOM_LAYOUTS_README.get_file()) @@ -154,9 +156,10 @@ func _load_custom_layouts(path: String) -> void: if not dir: var err := DirAccess.get_open_error() if err == ERR_FILE_NOT_FOUND: - printerr("directory not found '%s'\n" % path) + printerr("directory not found '%s'" % path) else: - printerr("error opening directory '%s': %s\n" % [path, err]) + printerr("error opening directory '%s': %s" % [path, err]) + print() return var files := dir.get_files() @@ -168,15 +171,14 @@ func _load_custom_layouts(path: String) -> void: if file_name.get_extension().to_lower() != "json": continue var layout := LayoutCustom.new(path.path_join(file_name)) - if layout.has_errors or layout.failed: - print() if layout.failed: continue if layouts.has(layout.get_name()): printerr( ( - "layout '%s' already exists and will be replaced by the new one\n" + "layout '%s' already exists and will be replaced by the new one" % [layout.get_name()] ) ) + print() layouts[layout.get_name()] = layout diff --git a/scripts/key_props.gd b/scripts/key_props.gd index 8852671..f6979f2 100644 --- a/scripts/key_props.gd +++ b/scripts/key_props.gd @@ -24,7 +24,7 @@ enum { NUB, } -var physical_keycode: Key +var physical_keycode: Key = KEY_NONE var location: KeyLocation = KEY_LOCATION_UNSPECIFIED var width: float = 1 diff --git a/scripts/layouts/layout_custom.gd b/scripts/layouts/layout_custom.gd index 36f3b35..fea5add 100644 --- a/scripts/layouts/layout_custom.gd +++ b/scripts/layouts/layout_custom.gd @@ -1,11 +1,11 @@ class_name LayoutCustom extends AbstractLayout -var failed: bool = false -var has_errors: bool = false +var failed: bool var _name: String var _rows: Array[Array] var _file_name: String +var _has_errors: bool func _init(path: String) -> void: @@ -16,14 +16,18 @@ func _init(path: String) -> void: if not data: failed = true printerr("%s: COULD NOT PARSE CUSTOM LAYOUT JSON" % _file_name) + print() return var layout_rows := _deserialize(data, _file_name) if not layout_rows: failed = true printerr("%s: COULD NOT DESERIALIZE CUSTOM LAYOUT" % _file_name) + print() return + if _has_errors: + print() _rows = layout_rows @@ -75,5 +79,5 @@ func _deserialize(data: Variant, path: String) -> Array[Array]: return [] if parser.get_name() != "": _name = parser.get_name() - has_errors = parser.has_errors() + _has_errors = parser.has_errors() return parser.get_rows()