Initial commit and push

This commit is contained in:
2021-05-12 16:38:14 -05:00
parent d9b8ad1292
commit f2efb7c42d
104 changed files with 34330 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
'''
UI functionality for the msh2text dialog.
'''
xsi = Application
import msh2
reload(msh2)
import msh2_unpack
reload(msh2_unpack)
import os
TXTPATH = 'C:\\SWBF2_ModTools\\data_TST\\Worlds\\TST\\msh\\test\\abc.txt'
MSHPATH = 'C:\\SWBF2_ModTools\\data_TST\\Worlds\\TST\\msh\\nab2_prop_fountain.msh'
USE_HARD_PATHS = False
def get_paths():
params = PPG.Inspected(0).Parameters
if USE_HARD_PATHS or params('dev').Value:
return MSHPATH, TXTPATH
return params('mshpath').Value, params('txtpath').Value
def msh2txt_OnClicked():
mshpath, txtpath = get_paths()
if not mshpath or not txtpath:
return
unpacker = msh2_unpack.MSHUnpack(mshpath)
msh = unpacker.unpack()
if PPG.Inspected(0).Parameters('segmented').Value is True:
msh.save_segmented_json(os.path.dirname(txtpath), os.path.basename(txtpath.split('.')[0]))
else:
msh.save_json(txtpath)
def txt2msh_OnClicked():
mshpath, txtpath = get_paths()
if not mshpath or not txtpath:
return
if PPG.Inspected(0).Parameters('segmented').Value is True:
msh = msh2.Msh.load_segmented_json(os.path.dirname(txtpath), os.path.basename(txtpath.split('.')[0]))
else:
msh = msh2.Msh.load_json(txtpath)
if PPG.Inspected(0).Parameters('dev').Value:
msh.save(mshpath + '.msh')
else:
msh.save(mshpath)