def CreateClass(name, libraryPath, textureName='home:export/textures/materials/rauch.dds'): name = name.capitalize() # valid name for a class entityServer = servers.get_entity_class_server() neBrushClass = entityServer.getentityclass('nebrush') if not entityServer.checkclassname(name): wx.MessageBox("\"%s\" is invalid name for a class" % (name), "Conjurer", wx.ICON_ERROR) return None if None != entityServer.getentityclass(name): wx.MessageBox("the class \"%s\" already exists" % (name), "Conjurer", wx.ICON_ERROR) return None particleNode, assetPath = CreateAsset(name, textureName) if particleNode == None: return None newClass = entityServer.newentityclass(neBrushClass, name) newClass.setasseteditable(True) newClass.setresourcefile(assetPath) newClass.setbbox(0.0, 0.5, 0.0, 0.500000, 0.5, 0.500000) library = pynebula.lookup(libraryPath) library.appendstring(name) # Mark the library as dirty app.get_libraries().setobjectdirty(True) return particleNode
def CreateClass( name, libraryPath, textureName = 'home:export/textures/materials/rauch.dds' ): name = name.capitalize() # valid name for a class entityServer = servers.get_entity_class_server() neBrushClass = entityServer.getentityclass( 'nebrush' ) if not entityServer.checkclassname(name): wx.MessageBox("\"%s\" is invalid name for a class" %(name), "Conjurer", wx.ICON_ERROR) return None if None != entityServer.getentityclass( name ): wx.MessageBox("the class \"%s\" already exists" %(name), "Conjurer", wx.ICON_ERROR) return None particleNode, assetPath = CreateAsset( name , textureName ) if particleNode == None: return None newClass = entityServer.newentityclass( neBrushClass, name ) newClass.setasseteditable(True) newClass.setresourcefile( assetPath ) newClass.setbbox( 0.0, 0.5 , 0.0, 0.500000, 0.5, 0.500000) library = pynebula.lookup( libraryPath ) library.appendstring( name ) # Mark the library as dirty app.get_libraries().setobjectdirty( True ) return particleNode
def create_class(name, parent_name, library_path): name = name.capitalize() # valid name for a class entity_server = servers.get_entity_class_server() if not entity_server.checkclassname(name): cjr.show_error_message("'%s' is not a valid name for a class" % (name)) return False if entity_server.getentityclass(name) is not None: cjr.show_error_message("A class called '%s' already exists" % (name)) return False #Get the class for the given parent class name, checking that it is valid parent_class = entity_server.getentityclass(parent_name) if parent_class is None: cjr.show_error_message( "The new class cannot derive from '%s' "\ "because it does not exist" % (parent_name) ) return False new_class = entity_server.newentityclass(parent_class, name) new_class.setclasskeyint("ParticleSystem", 1) new_class.setasseteditable(True) new_class.setbbox(0.0, 0.5, 0.0, 0.5, 0.5, 0.5) asset_path = 'wc:export/assets/%s' % name file_server = servers.get_file_server() if (not file_server.makepath(asset_path)): return False new_class.setresourcefile(asset_path) scene_path = asset_path + '/scene' if (not file_server.makepath(scene_path)): return False materials_path = asset_path + '/materials' if (not file_server.makepath(materials_path)): return False # create the root node root_node_path = scene_path + '/' + name root_node = pynebula.new('ntransformnode', root_node_path) result = root_node.saveas(root_node_path + '.n2') if not result: return False library = pynebula.lookup(library_path) library.appendstring(name) # Mark the library as dirty app.get_libraries().setobjectdirty(True) return True
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, "New particle system class", style=cfg.DEFAULT_DIALOG_STYLE) self.target_library = None valid_parent_list = self.get_valid_parent_list() self.staticbox_new_details_grp = wx.StaticBox(self, -1, "Details of new class") self.label_new_name = wx.StaticText(self, -1, "Class name", style=wx.ALIGN_RIGHT) self.text_new_name = wx.TextCtrl(self, -1, "") self.label_parent_name = wx.StaticText(self, -1, "Derive from", style=wx.ALIGN_RIGHT) self.choice_parent_name = wx.Choice(self, -1, (100, 50), choices=valid_parent_list) self.staticbox_target_library_grp = wx.StaticBox( self, -1, "Target library") self.noh = nohtree.NOHTree(self, -1, app.get_libraries(), passive=True) # do this here, so initial selection picked up self.noh.set_selection_changed_callback(self.on_select_target) self.button_ok = wx.Button(self, -1, "&OK") #giving cancel button special ID so it will close when ESC is pressed self.button_cancel = wx.Button(self, wx.ID_CANCEL, "&Cancel") self.SetDefaultItem(self.button_ok) self.__set_properties() self.__do_layout() self.__bind_events()
def __init__(self, parent): wx.Dialog.__init__( self, parent, -1, "New particle system class", style = cfg.DEFAULT_DIALOG_STYLE ) self.target_library = None valid_parent_list = self.get_valid_parent_list() self.staticbox_new_details_grp = wx.StaticBox( self, -1, "Details of new class" ) self.label_new_name = wx.StaticText( self, -1, "Class name", style=wx.ALIGN_RIGHT ) self.text_new_name = wx.TextCtrl(self, -1, "") self.label_parent_name = wx.StaticText( self, -1, "Derive from", style=wx.ALIGN_RIGHT ) self.choice_parent_name = wx.Choice( self, -1, (100, 50), choices = valid_parent_list ) self.staticbox_target_library_grp = wx.StaticBox( self, -1, "Target library" ) self.noh = nohtree.NOHTree( self, -1, app.get_libraries(), passive=True ) # do this here, so initial selection picked up self.noh.set_selection_changed_callback( self.on_select_target ) self.button_ok = wx.Button(self, -1, "&OK") #giving cancel button special ID so it will close when ESC is pressed self.button_cancel = wx.Button(self, wx.ID_CANCEL, "&Cancel") self.SetDefaultItem(self.button_ok) self.__set_properties() self.__do_layout() self.__bind_events()
def save(self): library = app.get_libraries() root_path = servers.get_file_server().manglepath("wc:libs/grimoire/") library = library.gethead() # first library # save all grimoire libraries while library is not None: if library.getname() != 'natives': save_path = root_path + '/' + library.getname() + '.n2' library.saveas(save_path) library = library.getsucc() # next library
def save(self, file): root = app.get_libraries() # get file name without extension foo, file_name = os.path.split(file[0]) file_name, ext = os.path.splitext(file_name) # save file if needed if self.is_file_dirty(file) and file[0] != '': obj_name = root.getfullname() + "/" + file_name obj = pynebula.lookup(str(obj_name)) obj.saveas(str(file[0])) self.files[file_name][1] = False
def save (self, file): root = app.get_libraries() # get file name without extension foo, file_name = os.path.split(file[0]) file_name, ext = os.path.splitext(file_name) # save file if needed if self.is_file_dirty(file) and file[0] != '': obj_name = root.getfullname() + "/" + file_name obj = pynebula.lookup(str(obj_name)) obj.saveas(str(file[0])) self.files[file_name][1] = False
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, "Select a library location", style=cfg.DEFAULT_DIALOG_STYLE) self.target_library = None self.tree_view = NOHTree(self, -1, app.get_libraries(), passive=True) self.button_ok = wx.Button(self, -1, "&OK") #giving cancel button special ID so it will close when ESC is pressed self.button_cancel = wx.Button(self, wx.ID_CANCEL, "&Cancel") self.__set_properties() self.__do_layout() self.__bind_events()
def create_new_lib (self, position): wildcard = "Library files (*.n2)|*.n2" # Show file dialog dlg = wx.FileDialog( self.GetGrandParent(), message="Create library", wildcard=wildcard, style=wx.SAVE|wx.CHANGE_DIR|wx.OVERWRITE_PROMPT, pos=position ) # get the selected file if dlg.ShowModal() == wx.ID_OK: root = app.get_libraries() new_library_path = root.getfullname() + "/" + dlg.GetFilename() new_library_path, ext = os.path.splitext(new_library_path) # test extension if ext != ".n2": cjr.show_error_message( "Bad extension: must be .n2. Try again." ) else: # create object and save to disk save = True if pynebula.exists(str(new_library_path)): dlg2_result = cjr.warn_yes_no( "You are using a library with the same name."\ "\n\n Are you sure you want to delete it?" ) if dlg2_result == wx.ID_NO: save = False else: pynebula.delete( str(new_library_path) ) if save: library = pynebula.new("nstringlist", new_library_path) path_string = str( dlg.GetPath() ) library.saveas(path_string) foo, lib_name = os.path.split(new_library_path) self.files[lib_name] = [path_string, False] self.expand_tree(new_library_path.replace('/editor/','')) dlg.Destroy()
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, "New particle system class", style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.TAB_TRAVERSAL) self.target_library = None self.label_name = wx.StaticText(self, -1, "Class name:", style=wx.ALIGN_RIGHT) self.text_name = wx.TextCtrl(self, -1, "") self.label_texture = wx.StaticText(self, -1, "Texture:", style=wx.ALIGN_RIGHT) self.button_texture = wx.Button(self, -1, "<default>") self.label_target = wx.StaticText(self, -1, "Target library:") self.noh = nohtree.NOHTree(self, -1, app.get_libraries(), passive=True) self.button_ok = wx.Button(self, -1, "OK") self.button_cancel = wx.Button(self, -1, "Cancel") self.__set_properties() self.__do_layout() self.__bind_events()
def create_new_lib(self, position): wildcard = "Library files (*.n2)|*.n2" # Show file dialog dlg = wx.FileDialog(self.GetGrandParent(), message="Create library", wildcard=wildcard, style=wx.SAVE | wx.CHANGE_DIR | wx.OVERWRITE_PROMPT, pos=position) # get the selected file if dlg.ShowModal() == wx.ID_OK: root = app.get_libraries() new_library_path = root.getfullname() + "/" + dlg.GetFilename() new_library_path, ext = os.path.splitext(new_library_path) # test extension if ext != ".n2": cjr.show_error_message( "Bad extension: must be .n2. Try again.") else: # create object and save to disk save = True if pynebula.exists(str(new_library_path)): dlg2_result = cjr.warn_yes_no( "You are using a library with the same name."\ "\n\n Are you sure you want to delete it?" ) if dlg2_result == wx.ID_NO: save = False else: pynebula.delete(str(new_library_path)) if save: library = pynebula.new("nstringlist", new_library_path) path_string = str(dlg.GetPath()) library.saveas(path_string) foo, lib_name = os.path.split(new_library_path) self.files[lib_name] = [path_string, False] self.expand_tree(new_library_path.replace('/editor/', '')) dlg.Destroy()
def load (self, file_path): if os.path.exists(file_path): root = app.get_libraries() kernel = servers.get_kernel_server() # get file name without extension foo, file_name = os.path.split(file_path) file_name, ext = os.path.splitext(file_name) # load new library into memory new_library_path = root.getfullname() + "/" + file_name if not pynebula.exists(new_library_path): kernel.loadas(str(file_path), str(new_library_path)) self.files[file_name] = [file_path, False] return new_library_path return ''
def load(self, file_path): if os.path.exists(file_path): root = app.get_libraries() kernel = servers.get_kernel_server() # get file name without extension foo, file_name = os.path.split(file_path) file_name, ext = os.path.splitext(file_name) # load new library into memory new_library_path = root.getfullname() + "/" + file_name if not pynebula.exists(new_library_path): kernel.loadas(str(file_path), str(new_library_path)) self.files[file_name] = [file_path, False] return new_library_path return ''
def __init__(self, parent): wx.Dialog.__init__( self, parent, -1, "Select a library location", style=cfg.DEFAULT_DIALOG_STYLE ) self.target_library = None self.tree_view = NOHTree( self, -1, app.get_libraries(), passive=True ) self.button_ok = wx.Button(self, -1, "&OK") #giving cancel button special ID so it will close when ESC is pressed self.button_cancel = wx.Button(self, wx.ID_CANCEL, "&Cancel") self.__set_properties() self.__do_layout() self.__bind_events()
def __is_dirty(self, obj): return app.get_libraries().isobjectdirty()
def is_save_allowed(self): return app.get_libraries().isobjectdirty()
def create_class( name, parent_name, library_path ): name = name.capitalize() # valid name for a class entity_server = servers.get_entity_class_server() if not entity_server.checkclassname( name ): cjr.show_error_message( "'%s' is not a valid name for a class" % (name) ) return False if entity_server.getentityclass( name ) is not None: cjr.show_error_message( "A class called '%s' already exists" % (name) ) return False #Get the class for the given parent class name, checking that it is valid parent_class = entity_server.getentityclass(parent_name) if parent_class is None: cjr.show_error_message( "The new class cannot derive from '%s' "\ "because it does not exist" % (parent_name) ) return False new_class = entity_server.newentityclass( parent_class, name ) new_class.setclasskeyint( "ParticleSystem", 1 ) new_class.setasseteditable( True ) new_class.setbbox( 0.0, 0.5, 0.0, 0.5, 0.5, 0.5 ) asset_path = 'wc:export/assets/%s' % name file_server = servers.get_file_server() if ( not file_server.makepath( asset_path ) ): return False new_class.setresourcefile( asset_path ) scene_path = asset_path + '/scene' if ( not file_server.makepath( scene_path ) ): return False materials_path = asset_path + '/materials' if ( not file_server.makepath( materials_path ) ): return False # create the root node root_node_path = scene_path + '/' + name root_node = pynebula.new( 'ntransformnode', root_node_path ) result = root_node.saveas( root_node_path + '.n2' ) if not result: return False library = pynebula.lookup( library_path ) library.appendstring( name ) # Mark the library as dirty app.get_libraries().setobjectdirty( True ) return True