add readme to custom layout user dir

This commit is contained in:
Teatov 2025-08-01 19:52:04 +10:00
parent 64ba8b4f80
commit 7c58d2994c
3 changed files with 22 additions and 4 deletions

View File

@ -7,7 +7,7 @@ advanced_options=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
include_filter="resources/kle/README.txt"
exclude_filter=""
export_path="build/windows/keebie.exe"
patches=PackedStringArray()

11
resources/kle/README.txt Normal file
View File

@ -0,0 +1,11 @@
Here you can add custom physical layouts.
Layouts can be created and edited in Keyboard Layout Editor:
https://www.keyboard-layout-editor.com
Once you've created the layout, export it in JSON format (Download > Download JSON)
and put the JSON file in this directory.
Keep in mind that key labels should adhere to the standard US QWERTY layout,
so that the game could correctly infer their keycodes.
You can configure your keyboard's actual labels in the game itself.

View File

@ -4,6 +4,7 @@ signal layout_swapped(new_layout: AbstractLayout)
const CONFIG_PATH := "user://layout.cfg"
const CUSTOM_LAYOUTS_PATH := "user://custom_layouts"
const CUSTOM_LAYOUTS_README := "res://resources/kle/README.txt"
const SECTION_INFO := "info"
const SECTION_KEYS := "keys"
const PARAM_NAME := "name"
@ -145,9 +146,15 @@ func _save_config() -> Error:
func _load_custom_layouts(path: String) -> void:
if not DirAccess.dir_exists_absolute(path):
var err := DirAccess.make_dir_absolute(path)
if err != OK:
printerr("error creating directory '%s': %s" % [path, err])
var dir_err := DirAccess.make_dir_absolute(path)
if dir_err != OK:
printerr("error creating directory '%s': %s" % [path, dir_err])
return
var file_err := DirAccess.copy_absolute(
CUSTOM_LAYOUTS_README, path.path_join(CUSTOM_LAYOUTS_README.get_file())
)
if file_err != OK:
printerr("error copying file '%s': %s" % [CUSTOM_LAYOUTS_README, file_err])
var dir := DirAccess.open(path)
if not dir: