def reset ( self ): if not self.AKUReady: return self.cleanLuaReferences () self.initContext () self.setWorkingDirectory ( self.getProject ().getPath () ) signals.emitNow ( 'moai.reset' ) signals.emitNow ( 'moai.ready' )
def openScene(self, node, protoNode=None): if self.activeSceneNode == node: if self.getModule('scene_view'): self.getModule('scene_view').setFocus() if protoNode: self.delegate.safeCallMethod('editor', 'locateProto', protoNode.getPath()) if self.getModule('scene_view'): self.getModule('scene_view').focusSelection() else: if not self.closeScene(): return if self.getModule('scene_view'): self.getModule('scene_view').makeCanvasCurrent() self.activeSceneNode = node signals.emitNow('scene.pre_open', node) scene = self.delegate.safeCallMethod('editor', 'openScene', node.getPath()) if not scene: #todo: raise something alertMessage( 'error', '%s\n\nfailed to open scene, see console for detailed information.' % node.getPath()) return False signals.emitNow('scene.open', self.activeSceneNode, scene) self.setFocus() self.editingProtoNode = protoNode self.loadWorkspaceState(False) self.delegate.safeCallMethod('editor', 'postOpenScene')
def saveScene(self): if not self.activeSceneNode: return self.markSceneDirty(False) signals.emitNow('scene.save') self.delegate.safeCallMethod('editor', 'saveScene', self.activeSceneNode.getAbsFilePath()) signals.emitNow('scene.saved') self.saveWorkspaceState()
def cleanLuaReferences ( self ): logging.info ( 'clean lua reference' ) # clear lua module # for m in self.luaModules: # unregisterModule(m) # bridge.clearSignalConnections() # bridge.clearLuaRegisteredSignals() # clear lua object inside introspector introspector = self.getModule ( 'introspector' ) if introspector: instances = introspector.getInstances () for ins in instances: if isinstance ( ins.target, (_LuaTable, _LuaObject, _LuaThread, _LuaFunction) ): ins.clear () signals.emitNow ( 'moai.clean' )
def closeScene(self): if not self.activeSceneNode: return True if self.sceneDirty: res = requestConfirm('scene modified!', 'save scene before close?') if res == True: #save self.saveScene() elif res == None: #cancel return elif res == False: #no save pass self.markSceneDirty(False) self.tree.clear() self.getApp().clearCommandStack('scene_editor') self.getSelectionManager().removeSelection(self.getActiveScene()) signals.emitNow('scene.close', self.activeSceneNode) self.delegate.safeCallMethod('editor', 'closeScene') self.activeSceneNode = None return True