Pass canvas path as arg

This commit is contained in:
luboslenco 2018-07-02 10:29:16 +02:00
parent 1829261f1b
commit 6914d2d302
2 changed files with 5 additions and 11 deletions

View file

@ -323,13 +323,14 @@ class ArmEditCanvasButton(bpy.types.Operator):
project_path = arm.utils.get_fp()
item = obj.arm_traitlist[obj.arm_traitlist_index]
canvas_path = project_path + '/Bundled/canvas/' + item.canvas_name_prop + '.json'
write_data.write_canvasprefs(canvas_path)
sdk_path = arm.utils.get_sdk_path()
armory2d_path = sdk_path + '/lib/armory_tools/armory2d/krom'
krom_location, krom_path = arm.utils.krom_paths()
os.chdir(krom_location)
subprocess.Popen([krom_path, armory2d_path, armory2d_path, '--nosound'])
cpath = canvas_path.replace('\\', '/')
uiscale = str(arm.utils.get_ui_scale())
subprocess.Popen([krom_path, armory2d_path, armory2d_path, '--nosound', cpath, uiscale])
return{'FINISHED'}
class ArmNewScriptDialog(bpy.types.Operator):

View file

@ -631,11 +631,4 @@ def write_canvasjson(canvas_name):
os.makedirs(canvas_path)
with open(canvas_path + '/' + canvas_name + '.json', 'w') as f:
f.write(
"""{ "name": "untitled", "x": 0.0, "y": 0.0, "width": 960, "height": 540, "elements": [], "assets": [] }""")
def write_canvasprefs(canvas_path):
sdk_path = arm.utils.get_sdk_path()
prefs_path = sdk_path + 'lib/armory_tools/armory2d/krom/prefs.json'
with open(prefs_path, 'w') as f:
f.write(
'{ "path": "' + canvas_path.replace('\\', '/') + '", "scaleFactor": ' + str(arm.utils.get_ui_scale()) + ' }')
"""{ "name": "untitled", "x": 0.0, "y": 0.0, "width": 1280, "height": 720, "elements": [], "assets": [] }""")