Skip to content

Commit

Permalink
@LOAD_LAYOUT done... I think...
Browse files Browse the repository at this point in the history
  • Loading branch information
nimaid committed Dec 7, 2019
1 parent 504a3a0 commit 3655a86
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 1,352 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.8
0.2.9
5 changes: 3 additions & 2 deletions files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:])
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions user_layouts/examples/all_delays_all_day.lpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{
"color": [
0,
0,
255
255,
0
],
"text": "DELAY 2"
"text": "@LOAD_LAYOUT examples/all_delays_all_gay.lpl"
},
{
"color": [
Expand Down
6 changes: 3 additions & 3 deletions user_layouts/examples/all_delays_all_gay.lpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
[
{
"color": [
0,
255,
255,
255
0
],
"text": "DELAY 1"
"text": "@LOAD_LAYOUT examples/all_delays_all_day.lpl"
},
{
"color": [
Expand Down
Loading

0 comments on commit 3655a86

Please sign in to comment.