def SoftCryDelayedStartupEvent_OnEvent(in_ctxt): add_to_path() import crycore config = crycore.load_settings(xsi) try: check = config['check_version_on_startup'] except KeyError: crycore.default_settings(xsi) check = crycore.load_settings(xsi)['check_version_on_startup'] if check: check_version(True) return False
def check_version(quiet=False): add_to_path() import requests as req import webbrowser import crycore config = crycore.load_settings(xsi) try: timeout = config['check_version_timeout'] except KeyError: crycore.default_settings(xsi) config = crycore.load_settings(xsi) timeout = config['check_version_timeout'] pb = uitk.ProgressBar pb.Caption = 'Checking SoftCry Version...' pb.Visible = True pb.Maximum = 1 origin = get_origin() verdir = os.path.abspath(os.path.join(origin, 'softcry.ver')) with open(verdir, 'r') as fh: local_major, local_minor, local_build = fh.readline().split('.') try: latest = req.get('http://raw.github.com/Schlechtwetterfront/softcry/master/softcry.ver', timeout=timeout) except (req.ConnectionError, req.Timeout): if quiet: pb.Visible = False return uitk.MsgBox(CHECK_VERSION_ERROR_MSG) pb.Visible = False return major, minor, build = latest.text.split('.') pb.Value = 1 if build > local_build: if uitk.MsgBox(OLD_VERSION_MSG.format(local_major, local_minor, local_build, major, minor, build), 4) == 6: webbrowser.open('http://github.com/Schlechtwetterfront/softcry') else: if quiet: pb.Visible = False return uitk.MsgBox(UP_TO_DATE_MSG.format(local_major, local_minor, local_build, major, minor, build)) pb.Visible = False
def SoftCrySettings_Execute(): add_to_path() import crycore reload(crycore) config = crycore.load_settings(xsi) for prop in xsi.ActiveSceneRoot.Properties: if prop.Name == 'SoftCrySettings': xsi.DeleteObj('SoftCrySettings') try: pS = xsi.ActiveSceneRoot.AddProperty('CustomProperty', False, 'SoftCrySettings') pS.AddParameter3('rcpath', const.siString, config['rcpath']) pS.AddParameter3('gamefolder_name', const.siString, config['gamefolder_name'], '', '', 0, 0) pS.AddParameter3('check_version_on_startup', const.siBool, config['check_version_on_startup'], 0, 1, 0, 0) pS.AddParameter3('check_version_timeout', const.siDouble, config['check_version_timeout'], 0, 10, 0, 0) except KeyError: crycore.default_settings(xsi) xsi.SoftCryExport() return mLay = pS.PPGLayout mLay.SetAttribute(const.siUILogicFile, get_origin() + '\\Application\\Logic\\settings.py') mLay.Language = 'pythonscript' btn = mLay.AddButton item = mLay.AddItem r = mLay.AddRow er = mLay.EndRow enum = mLay.AddEnumControl text = mLay.AddStaticText g = mLay.AddGroup eg = mLay.EndGroup tab = mLay.AddTab spacer = mLay.AddSpacer g('Settings') path_ctrl = item('rcpath', 'RC Path', const.siControlFolder) path_ctrl.SetAttribute(const.siUILabelPercentage, 70) r() folder_ctrl = item('gamefolder_name', 'Game Folder Name') folder_ctrl.SetAttribute(const.siUILabelPercentage, 80) help_btn = btn('helpgamefolder', '?') help_btn.SetAttribute(const.siUICX, 40) er() spacer(100, 5) r() item('check_version_on_startup', 'Check Version on Startup') item('check_version_timeout', 'Timeout') er() r() spacer(190, 5) reload_btn = btn('reload', 'Reload') reload_btn.SetAttribute(const.siUICX, 60) reload_btn.SetAttribute(const.siUICY, 22) def_btn = btn('default', 'Default') def_btn.SetAttribute(const.siUICX, 60) def_btn.SetAttribute(const.siUICY, 22) save_btn = btn('save', 'Save') save_btn.SetAttribute(const.siUICX, 60) save_btn.SetAttribute(const.siUICY, 22) er() eg() desk = xsi.Desktop.ActiveLayout view = desk.CreateView('Property Panel', 'SoftCrySettings') view.BeginEdit() view.Resize(400, 150) view.SetAttributeValue('targetcontent', pS.FullName) view.EndEdit() return True
def SoftCryExport_Execute(): add_to_path() import crycore reload(crycore) config = crycore.load_settings(xsi) for prop in xsi.ActiveSceneRoot.Properties: if prop.Name == 'SoftCryExport': xsi.DeleteObj('SoftCryExport') try: pS = xsi.ActiveSceneRoot.AddProperty('CustomProperty', False, 'SoftCryExport') pS.AddParameter3('path', const.siString, config['path']) pS.AddParameter3('customnormals', const.siBool, config['customnormals'], '', 0, 0) pS.AddParameter3('donotmerge', const.siBool, config['donotmerge'], '', 0, 0) pS.AddParameter3('filetype', const.siString, config['filetype'], '', 0, 0) file_types = ('CGF', 'cgf', 'CGA ANM', 'cgaanm', 'CHR CAF', 'chrcaf', 'SKIN', 'skin', 'Material', 'matlib') pS.AddParameter3('unit', const.siString, config['unit'], '', 0, 0) units = 'Meter', 'meter', 'Centimeter', 'centimeter' pS.AddParameter3('deluncompiled', const.siBool, config['deluncompiled'], '', '', 0) pS.AddParameter3('debugdump', const.siBool, config['debugdump'], '', '', 0) pS.AddParameter3('batch', const.siBool, config['batch'], '', '', 0) pS.AddParameter3('verbose', const.siInt4, config['verbose'], 0, 2, 0) pS.AddParameter3('usespaces', const.siBool, config['usespaces'], '', '', 0) pS.AddParameter3('keyforspace', const.siString, config['keyforspace'], '', '', 0, 1) pS.AddParameter3('f32', const.siBool, False, '', '', 0, 0) except KeyError: crycore.default_settings(xsi) xsi.SoftCryExport() return mLay = pS.PPGLayout mLay.SetAttribute(const.siUILogicFile, get_origin() + '\\Application\\Logic\\exporter.py') mLay.Language = 'pythonscript' btn = mLay.AddButton item = mLay.AddItem row = mLay.AddRow erow = mLay.EndRow enum = mLay.AddEnumControl text = mLay.AddStaticText grp = mLay.AddGroup egrp = mLay.EndGroup tab = mLay.AddTab spacer = mLay.AddSpacer tab('Export') path_ctrl = item('path', 'File', const.siControlFilePath) path_ctrl.SetAttribute(const.siUINoLabel, 1) path_ctrl.SetAttribute(const.siUIFileFilter, 'CRYENGINE Files (*.cgf, *.cga, *.chr)|*.cgf:*.cga:*.chr') path_ctrl.SetAttribute(const.siUIOpenFile, False) path_ctrl.SetAttribute(const.siUIFileMustExist, False) '''texPathI = mLay.AddItem('rcpath', 'Resource Compiler', const.siControlFolder) texPathI.SetAttribute(const.siUINoLabel, 1) texPathI.SetAttribute(const.siUIWidthPercentage, 55)''' exgrp = grp('Export', 1) row() item('deluncompiled', 'Delete Uncompiled') item('donotmerge', 'Do Not Merge') bf32 = item('f32', 'F32') bf32.SetAttribute(const.siUIWidthPercentage, 15.5) erow() row() item('batch', 'Batch Export') item('customnormals', 'Custom Normals') b = btn('help', 'Help') b.SetAttribute(const.siUICX, 80) erow() row() unit = enum('unit', units, 'Unit', const.siControlCombo) unit.SetAttribute('NoLabel', True) filetype = enum('filetype', file_types, 'File Type', const.siControlCombo) filetype.SetAttribute('NoLabel', True) b = btn('Export', 'Export') b.SetAttribute(const.siUICX, 80) erow() egrp() tab('Special Settings') grp('Debug', 1) row() bdebugdump = item('debugdump', 'Debug Dump CGF') bdebugdump.SetAttribute(const.siUIWidthPercentage, 20) iverbose = item('verbose', 'Verbose Level') iverbose.SetAttribute(const.siUILabelPercentage, 90) erow() egrp() grp('Spaces', 1) row() bspaces = item('usespaces', 'Enable Spaces') bspaces.SetAttribute(const.siUIWidthPercentage, 20) skeyforspace = item('keyforspace', 'Replace With Space') skeyforspace.SetAttribute(const.siUILabelPercentage, 90) erow() egrp() desk = xsi.Desktop.ActiveLayout view = desk.CreateView('Property Panel', 'SoftCryExport') view.BeginEdit() view.Resize(400, 165) view.SetAttributeValue('targetcontent', pS.FullName) view.EndEdit() return True