def __init__(self, parent=None): if Weld.__instance is None: Weld.__instance = self else: raise Exception('can\'t declare new Weld instance. Weld is a singleton.') Savable.__init__(self, savepath=os.path.join(user.home, '.weld', 'weld.cache')) self.savelist += ['current_project_path'] # this is used to reload last opened project self.current_project_path = None Ui(self) # setup internal resource handlers self.project = None # list of resources we can ask steel to load self.resMan = ResourceManager(os.path.join(Config.instance().weld_data_path, 'resources')) self.resMan.attach_to_Ui(Ui.instance().res_browser['library']) # entity responsible for behavior trees manipulations self.BTMan = BTManager() # ready Ui.instance().show_status('ready', 1000) self.load() if Config.instance().on_weld_start_reopen_last_project: if self.current_project_path is not None: print 'auto reopening project \'%s\'.' % self.current_project_path p, f = os.path.split(self.current_project_path) self.open_project(self.current_project_path, f) else: print 'no project to reopen.' else: print 'skipping project reopening.'
def __init__(self, parent=None): if Weld.__instance is None: Weld.__instance = self else: raise Exception( 'can\'t declare new Weld instance. Weld is a singleton.') Savable.__init__(self, savepath=os.path.join(user.home, '.weld', 'weld.cache')) self.savelist += ['current_project_path'] # this is used to reload last opened project self.current_project_path = None Ui(self) # setup internal resource handlers self.project = None # list of resources we can ask steel to load self.resMan = ResourceManager( os.path.join(Config.instance().weld_data_path, 'resources')) self.resMan.attach_to_Ui(Ui.instance().res_browser['library']) # entity responsible for behavior trees manipulations self.BTMan = BTManager() # ready Ui.instance().show_status('ready', 1000) self.load() if Config.instance().on_weld_start_reopen_last_project: if self.current_project_path is not None: print 'auto reopening project \'%s\'.' % self.current_project_path p, f = os.path.split(self.current_project_path) self.open_project(self.current_project_path, f) else: print 'no project to reopen.' else: print 'skipping project reopening.'
class Weld(Savable): """ Main class of the editor. """ """application version""" version = '0.1.0' #singleton __instance = None def __init__(self, parent=None): if Weld.__instance is None: Weld.__instance = self else: raise Exception( 'can\'t declare new Weld instance. Weld is a singleton.') Savable.__init__(self, savepath=os.path.join(user.home, '.weld', 'weld.cache')) self.savelist += ['current_project_path'] # this is used to reload last opened project self.current_project_path = None Ui(self) # setup internal resource handlers self.project = None # list of resources we can ask steel to load self.resMan = ResourceManager( os.path.join(Config.instance().weld_data_path, 'resources')) self.resMan.attach_to_Ui(Ui.instance().res_browser['library']) # entity responsible for behavior trees manipulations self.BTMan = BTManager() # ready Ui.instance().show_status('ready', 1000) self.load() if Config.instance().on_weld_start_reopen_last_project: if self.current_project_path is not None: print 'auto reopening project \'%s\'.' % self.current_project_path p, f = os.path.split(self.current_project_path) self.open_project(self.current_project_path, f) else: print 'no project to reopen.' else: print 'skipping project reopening.' def BT_export(self): """ Called by the Ui. Exports filesystem BTrees as json files. """ src = os.path.join(self.resMan.base_path, Config.instance().weld_BT_root_folder) srcs = self.BTMan.get_subdirs(src) dst = os.path.join(self.project.rootdir, Config.instance().weld_BT_root_folder) #this operation has lots of exceptions to output... try: for src in srcs: self.BTMan.export(src, dst) except Exception, e: print >> sys.__stderr, 'ERROR in Weld.BT_export():' print >> sys.__stderr, e.args[0] print >> sys.__stderr, 'export cancelled (some cleanup might be needed in %s)' % dst
class Weld(Savable): """ Main class of the editor. """ """application version""" version = '0.1.0' #singleton __instance = None def __init__(self, parent=None): if Weld.__instance is None: Weld.__instance = self else: raise Exception('can\'t declare new Weld instance. Weld is a singleton.') Savable.__init__(self, savepath=os.path.join(user.home, '.weld', 'weld.cache')) self.savelist += ['current_project_path'] # this is used to reload last opened project self.current_project_path = None Ui(self) # setup internal resource handlers self.project = None # list of resources we can ask steel to load self.resMan = ResourceManager(os.path.join(Config.instance().weld_data_path, 'resources')) self.resMan.attach_to_Ui(Ui.instance().res_browser['library']) # entity responsible for behavior trees manipulations self.BTMan = BTManager() # ready Ui.instance().show_status('ready', 1000) self.load() if Config.instance().on_weld_start_reopen_last_project: if self.current_project_path is not None: print 'auto reopening project \'%s\'.' % self.current_project_path p, f = os.path.split(self.current_project_path) self.open_project(self.current_project_path, f) else: print 'no project to reopen.' else: print 'skipping project reopening.' def BT_export(self): """ Called by the Ui. Exports filesystem BTrees as json files. """ src = os.path.join(self.resMan.base_path, Config.instance().weld_BT_root_folder) srcs=self.BTMan.get_subdirs(src) dst = os.path.join(self.project.rootdir, Config.instance().weld_BT_root_folder) #this operation has lots of exceptions to output... try: for src in srcs: self.BTMan.export(src, dst) except Exception, e: print >> sys.__stderr, 'ERROR in Weld.BT_export():' print >> sys.__stderr, e.args[0] print >> sys.__stderr, 'export cancelled (some cleanup might be needed in %s)' % dst