diff --git a/.gitattributes b/.gitattributes index a98e7af..707e703 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,6 @@ -# Unreal assets (binary, lockable) -*.uasset filter=lfs diff=lfs merge=lfs -text lockable -*.umap filter=lfs diff=lfs merge=lfs -text lockable +# Unreal assets (binary) +*.uasset filter=lfs diff=lfs merge=lfs -text +*.umap filter=lfs diff=lfs merge=lfs -text # Source art / audio / video *.fbx filter=lfs diff=lfs merge=lfs -text diff --git a/Content/Input/IMC_Default.uasset b/Content/Input/IMC_Default.uasset index b63309a..ae96efc 100644 --- a/Content/Input/IMC_Default.uasset +++ b/Content/Input/IMC_Default.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:133bda6567aaeea1aae05c03597345e4b1d9ef24d868a0275203b3203a7aae98 -size 7787 +oid sha256:5ab2f8e915fff603ae6e379ee1b0a399e1690dc415ce489bc33d7aa450e09c1e +size 8719 diff --git a/Content/Variant_Combat/Input/IMC_Combat.uasset b/Content/Variant_Combat/Input/IMC_Combat.uasset index 3d6e570..274c0ec 100644 --- a/Content/Variant_Combat/Input/IMC_Combat.uasset +++ b/Content/Variant_Combat/Input/IMC_Combat.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:70a0550dafdf7c6a61935610eefcd83c1fa7475bd229ace5de6e695f315aa783 -size 9665 +oid sha256:de13dd4d1e2443c18018c36ef280a1a1794cfee089994a097f93f345c502bc39 +size 10538 diff --git a/Content/Variant_Platforming/Input/IMC_Platforming.uasset b/Content/Variant_Platforming/Input/IMC_Platforming.uasset index fa622cc..c8d8afa 100644 --- a/Content/Variant_Platforming/Input/IMC_Platforming.uasset +++ b/Content/Variant_Platforming/Input/IMC_Platforming.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e94f067f538d5fa01cb69b030159537812dbd14e13ff6c4e31c570b834580414 -size 8779 +oid sha256:ca8b0e158d5007569a104e8f409b3c0c827d40e9ef52a92cefd41963fdc7d1b7 +size 9695 diff --git a/Content/Variant_SideScrolling/Input/IMC_SideScroller.uasset b/Content/Variant_SideScrolling/Input/IMC_SideScroller.uasset index 2ea6a48..50c6c31 100644 --- a/Content/Variant_SideScrolling/Input/IMC_SideScroller.uasset +++ b/Content/Variant_SideScrolling/Input/IMC_SideScroller.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2ac23fc0b6ffc89b09210fc2774db51d54de23e07018b86b8c32cd6f10eee549 -size 7181 +oid sha256:3fda6a608b6fdbff350334b5c677071b9a65613685e42d5580f9631404954972 +size 7779 diff --git a/Scripts/azerty_mappings.py b/Scripts/azerty_mappings.py new file mode 100644 index 0000000..01199b6 --- /dev/null +++ b/Scripts/azerty_mappings.py @@ -0,0 +1,70 @@ +"""Add AZERTY key mappings next to the QWERTY ones in every Input Mapping Context. + +W -> also Z (forward), A -> also Q (left). Idempotent: skips keys already mapped. +Run headless (editor closed): + UnrealEditor pogo.uproject -run=pythonscript -script=Scripts/azerty_mappings.py -nullrhi -unattended -FullStdOutLogOutput +""" +import unreal + +CONTEXTS = [ + "/Game/Input/IMC_Default", + "/Game/Variant_Platforming/Input/IMC_Platforming", + "/Game/Variant_Combat/Input/IMC_Combat", + "/Game/Variant_SideScrolling/Input/IMC_SideScroller", +] +EXTRA_KEYS = {"W": "Z", "A": "Q"} + +# Properties copied when cloning instanced modifiers/triggers. +COPY_PROPS = ["order", "x", "y", "z", "lower_threshold", "upper_threshold", "type", + "scalar", "actuation_threshold"] + + +def clone_instanced(obj, outer): + new = unreal.new_object(type(obj), outer=outer) + for prop in COPY_PROPS: + try: + new.set_editor_property(prop, obj.get_editor_property(prop)) + except Exception: + pass + return new + + +def log(msg): + unreal.log(f"POGO_AZERTY {msg}") + + +for path in CONTEXTS: + imc = unreal.load_asset(path) + if imc is None: + log(f"MISSING {path}") + continue + data = imc.get_editor_property("default_key_mappings") + mappings = list(data.get_editor_property("mappings")) + existing = {(m.get_editor_property("action").get_name(), + str(m.get_editor_property("key").get_editor_property("key_name"))) + for m in mappings} + added = 0 + for m in list(mappings): + action = m.get_editor_property("action") + src_key = str(m.get_editor_property("key").get_editor_property("key_name")) + dst_key = EXTRA_KEYS.get(src_key) + if not dst_key or (action.get_name(), dst_key) in existing: + continue + new = unreal.EnhancedActionKeyMapping() + new.set_editor_property("action", action) + key = unreal.Key() + key.set_editor_property("key_name", dst_key) + new.set_editor_property("key", key) + new.set_editor_property("modifiers", [clone_instanced(x, imc) for x in m.get_editor_property("modifiers")]) + new.set_editor_property("triggers", [clone_instanced(x, imc) for x in m.get_editor_property("triggers")]) + mappings.append(new) + existing.add((action.get_name(), dst_key)) + added += 1 + log(f"{path}: {action.get_name()} {src_key} -> +{dst_key}") + if added: + data.set_editor_property("mappings", mappings) + imc.set_editor_property("default_key_mappings", data) + ok = unreal.EditorAssetLibrary.save_loaded_asset(imc, only_if_is_dirty=False) + log(f"SAVED {path} added={added} ok={ok}") + else: + log(f"UNCHANGED {path}") diff --git a/pogo.uproject b/pogo.uproject index 4d689f8..d8ad476 100644 --- a/pogo.uproject +++ b/pogo.uproject @@ -30,6 +30,13 @@ { "Name": "GameplayStateTree", "Enabled": true + }, + { + "Name": "PythonScriptPlugin", + "Enabled": true, + "TargetAllowList": [ + "Editor" + ] } ] } \ No newline at end of file