From 3655a8658d74e3bcff7dba50444ed607a84ca93b Mon Sep 17 00:00:00 2001 From: Ella Jameson Date: Fri, 6 Dec 2019 22:41:46 -0700 Subject: [PATCH] @LOAD_LAYOUT done... I think... --- VERSION | 2 +- files.py | 5 +- scripts.py | 5 +- user_layouts/examples/all_delays_all_day.lpl | 6 +- user_layouts/examples/all_delays_all_gay.lpl | 6 +- user_layouts/examples/bar.lpl | 671 ------------------- user_layouts/examples/foo.lpl | 671 ------------------- 7 files changed, 14 insertions(+), 1352 deletions(-) delete mode 100644 user_layouts/examples/bar.lpl delete mode 100644 user_layouts/examples/foo.lpl diff --git a/VERSION b/VERSION index 08456a4..d81f1c3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.8 \ No newline at end of file +0.2.9 \ No newline at end of file diff --git a/files.py b/files.py index a56abcb..d00ab1d 100644 --- a/files.py +++ b/files.py @@ -31,10 +31,11 @@ def init(user_path_in): LAYOUT_PATH = os.path.join(USER_PATH, LAYOUT_DIR) SCRIPT_PATH = os.path.join(USER_PATH, SCRIPT_DIR) -def save_layout(layout, name): +def save_layout(layout, name, printing=True): with open(name, "w") as f: json.dump(layout, f, indent=2, sort_keys=True) - print("[files] Saved layout as " + name) + if printing: + print("[files] Saved layout as " + name) def load_layout_json(name, printing=True): with open(name, "r") as f: diff --git a/scripts.py b/scripts.py index 6c63f39..6c2942d 100644 --- a/scripts.py +++ b/scripts.py @@ -447,6 +447,8 @@ def main_logic(idx): except files.json.decoder.JSONDecodeError: print("[scripts] " + coords + " ERROR: Layout is malformated.") return -1 + if files.layout_changed_since_load: + files.save_lp_to_layout(files.curr_layout) files.load_layout_to_lp(layout_path, popups=False, save_converted=False, preload=layout) elif split_line[0] == "OPEN": path_name = " ".join(split_line[1:]) @@ -604,7 +606,8 @@ def validate_script(script_str): for line in script_lines[1:]: if line != "" and line[0] != "-": return ("When @LOAD_LAYOUT is used, scripts can only contain comments.", line) - + if len(first_line_split) < 2: + return ("No layout filename provided.", first_line) layout_path = os.path.join(files.LAYOUT_PATH, " ".join(first_line_split[1:])) if not os.path.isfile(layout_path): return ("'" + layout_path + "' does not exist!", first_line) diff --git a/user_layouts/examples/all_delays_all_day.lpl b/user_layouts/examples/all_delays_all_day.lpl index b7bbdb7..1b8d45f 100644 --- a/user_layouts/examples/all_delays_all_day.lpl +++ b/user_layouts/examples/all_delays_all_day.lpl @@ -4,10 +4,10 @@ { "color": [ 0, - 0, - 255 + 255, + 0 ], - "text": "DELAY 2" + "text": "@LOAD_LAYOUT examples/all_delays_all_gay.lpl" }, { "color": [ diff --git a/user_layouts/examples/all_delays_all_gay.lpl b/user_layouts/examples/all_delays_all_gay.lpl index 61cefdc..f670694 100644 --- a/user_layouts/examples/all_delays_all_gay.lpl +++ b/user_layouts/examples/all_delays_all_gay.lpl @@ -3,11 +3,11 @@ [ { "color": [ + 0, 255, - 255, - 255 + 0 ], - "text": "DELAY 1" + "text": "@LOAD_LAYOUT examples/all_delays_all_day.lpl" }, { "color": [ diff --git a/user_layouts/examples/bar.lpl b/user_layouts/examples/bar.lpl deleted file mode 100644 index 5886dc7..0000000 --- a/user_layouts/examples/bar.lpl +++ /dev/null @@ -1,671 +0,0 @@ -{ - "buttons": [ - [ - { - "color": [ - 255, - 0, - 0 - ], - "text": "@LOAD_LAYOUT foo.lpl" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 255, - 0 - ], - "text": "-" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ] - ], - "version": "0.1.1" -} \ No newline at end of file diff --git a/user_layouts/examples/foo.lpl b/user_layouts/examples/foo.lpl deleted file mode 100644 index 7ed7a62..0000000 --- a/user_layouts/examples/foo.lpl +++ /dev/null @@ -1,671 +0,0 @@ -{ - "buttons": [ - [ - { - "color": [ - 0, - 255, - 0 - ], - "text": "@LOAD_LAYOUT bar.lpl" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 255, - 0 - ], - "text": "-" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ], - [ - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - }, - { - "color": [ - 0, - 0, - 0 - ], - "text": "" - } - ] - ], - "version": "0.1.1" -} \ No newline at end of file