def create_new_dir(self, parent, position): if parent != self.GetRootItem(): # get library name library = self.get_root_library(parent) library_name = self.GetItemText(library) if self.files.has_key(library_name): # create new sublibrary parent = self.GetPyData(parent) dlg = wx.TextEntryDialog(self, 'Enter new name for sublibrary', 'New library', '') dlg.SetPosition(position) if dlg.ShowModal() == wx.ID_OK: new_lib_name = dlg.GetValue() # create object new_library_path = parent.getfullname( ) + '/' + new_lib_name pynebula.new('nstringlist', new_library_path) self.files[library_name][1] = True self.expand_tree(new_library_path.replace('/editor/', '')) dlg.Destroy() else: cjr.show_warning_message("This library is read-only")
def create_new_dir (self, parent, position): if parent != self.GetRootItem(): # get library name library = self.get_root_library(parent) library_name = self.GetItemText(library) if self.files.has_key(library_name): # create new sublibrary parent = self.GetPyData(parent) dlg = wx.TextEntryDialog( self, 'Enter new name for sublibrary', 'New library', '' ) dlg.SetPosition(position) if dlg.ShowModal() == wx.ID_OK: new_lib_name = dlg.GetValue() # create object new_library_path = parent.getfullname() + '/' + new_lib_name pynebula.new( 'nstringlist', new_library_path ) self.files[library_name][1] = True self.expand_tree( new_library_path.replace('/editor/','') ) dlg.Destroy() else: cjr.show_warning_message( "This library is read-only" )
def on_save(self, event): library = self.GetPyData(self.get_root_library(self.current)) lib_name = library.getname() if self.files.has_key(lib_name): self.save(self.files[lib_name]) else: cjr.show_warning_message("Element is read-only")
def on_save (self, event): library = self.GetPyData(self.get_root_library(self.current)) lib_name = library.getname() if self.files.has_key(lib_name): self.save(self.files[lib_name]) else: cjr.show_warning_message( "Element is read-only" )
def __set_properties(self): self.SetSize((400, 300)) self.scroll_materials.SetScrollRate(10, 10) if app.get_outdoor() is None: cjr.show_warning_message("The current level has no terrain") return self.__build_material_list()
def __set_properties(self): self.SetSize( (400, 300) ) self.scroll_materials.SetScrollRate(10, 10) if app.get_outdoor() is None: cjr.show_warning_message( "The current level has no terrain" ) return self.__build_material_list()
def __fill_operation(self, obj): # Check that the object has at least one command to execute cmds = obj.getcmds() if len(cmds) == 0: cjr.show_warning_message("The object has no commands to execute.") return False # Select the first command as the default one cmd = cmds[0].split('_')[1] # Set the object and command self.operation.setobjectcommand(obj, str(cmd)) return True
def __fill_operation(self, obj): # Check that the object has at least one command to execute cmds = obj.getcmds() if len( cmds ) == 0: cjr.show_warning_message("The object has no commands to execute.") return False # Select the first command as the default one cmd = cmds[0].split('_')[1] # Set the object and command self.operation.setobjectcommand( obj, str(cmd) ) return True
def __get_prop_values(self): source_id = self.props_event.get_property_value(self.pids['source']) if source_id == 0: source_id = self.entity.getid() source = servers.get_entity_object_server().getentityobject(source_id) if source is None: cjr.show_warning_message( "There's no valid source entity for the specified entity id") source = self.entity self.props_event.set_property_value(self.pids['source'], 0) self.props_event.Refresh() duration = self.props_event.get_property_value(self.pids['duration']) priority = self.props_event.get_property_value(self.pids['priority']) return {'source': source, 'duration': duration, 'priority': priority}
def __get_prop_values(self): source_id = self.props_event.get_property_value( self.pids['source'] ) if source_id == 0: source_id = self.entity.getid() source = servers.get_entity_object_server().getentityobject( source_id ) if source is None: cjr.show_warning_message( "There's no valid source entity for the specified entity id" ) source = self.entity self.props_event.set_property_value( self.pids['source'], 0 ) self.props_event.Refresh() duration = self.props_event.get_property_value( self.pids['duration'] ) priority = self.props_event.get_property_value( self.pids['priority'] ) return {'source': source, 'duration': duration, 'priority': priority}
def on_end_drag (self, event): self.SetCursor(wx.STANDARD_CURSOR) # restore cursor test_object = self.HitTest( event.GetPoint() ) if test_object[1] != wx.TREE_HITTEST_TORIGHT: # get nebula objects dest_object = self.GetPyData(test_object[0]) orig_object = self.GetPyData(self.drag_object) # check if we are trying to move a parent to a child dest = test_object[0] is_parent = False while dest != self.GetRootItem() and not is_parent: if dest == self.drag_object: is_parent = True dest = self.GetItemParent(dest) # destination must be valid if self.is_valid(test_object[0]) and dest_object != orig_object \ and not is_parent and dest_object != orig_object.getparent(): new_obj = '/'.join( ( dest_object.getfullname(), orig_object.getname() ) ) orig_object.clone( str(new_obj) ) # delete item if is a move operation if self.drag_type == 'move': if not self.is_library(self.drag_object): self.dirt_file(self.drag_object) else: self.files.pop(self.GetItemText(self.drag_object)) pynebula.delete(orig_object.getfullname()) self.dirt_file(test_object[0]) # expand tree to the target library self.expand_tree( new_obj.replace('/editor/','') ) else: wx.Bell() cjr.show_warning_message( "Operation not allowed" ) else: wx.Bell()
def on_end_drag(self, event): self.SetCursor(wx.STANDARD_CURSOR) # restore cursor test_object = self.HitTest(event.GetPoint()) if test_object[1] != wx.TREE_HITTEST_TORIGHT: # get nebula objects dest_object = self.GetPyData(test_object[0]) orig_object = self.GetPyData(self.drag_object) # check if we are trying to move a parent to a child dest = test_object[0] is_parent = False while dest != self.GetRootItem() and not is_parent: if dest == self.drag_object: is_parent = True dest = self.GetItemParent(dest) # destination must be valid if self.is_valid(test_object[0]) and dest_object != orig_object \ and not is_parent and dest_object != orig_object.getparent(): new_obj = '/'.join( (dest_object.getfullname(), orig_object.getname())) orig_object.clone(str(new_obj)) # delete item if is a move operation if self.drag_type == 'move': if not self.is_library(self.drag_object): self.dirt_file(self.drag_object) else: self.files.pop(self.GetItemText(self.drag_object)) pynebula.delete(orig_object.getfullname()) self.dirt_file(test_object[0]) # expand tree to the target library self.expand_tree(new_obj.replace('/editor/', '')) else: wx.Bell() cjr.show_warning_message("Operation not allowed") else: wx.Bell()
def on_delete_from_disk(self, event): obj = self.GetPyData(self.current) lib_name = obj.getname() # delete only files avilable in the file list, files that are not # in this list are supossed read-only root_lib_name = self.GetItemText(self.get_root_library(self.current)) if self.files.has_key(root_lib_name): position = self.__get_cursor_position() dlg_result = cjr.confirm_yes_no_at_position( self, "Are you sure?", position) if dlg_result == wx.ID_YES: parent = obj.getparent() dir_to_expand = parent.getfullname() os.remove(self.files[lib_name][0]) # delete file from disk! self.files.pop(lib_name) pynebula.delete(obj.getfullname()) self.expand_tree(dir_to_expand.replace('/editor/', '')) else: cjr.show_warning_message("Element is read-only")
def delete (self, library, type='dir'): element_name = self.GetItemText(library) if self.is_valid(library): if 'lib' == type: msg1 = "This will unload the %s library from memory.\n\n"\ "Are you sure?" % (element_name) elif 'dir' == type: msg1 = "This will delete the %s directory.\n\n"\ "Are you sure?" % (element_name) position = self.__get_cursor_position() dlg_result = cjr.confirm_yes_no_at_position( self, msg1, position ) if dlg_result == wx.ID_YES: # get full nebula path library_data = self.GetPyData(library) full_path = library_data.getfullname() # the same with the parent for expand the tree after delete parent = library_data.getparent() parent_name = parent.getfullname() pynebula.delete(full_path) # delete nebula object self.Delete(self.current) # delete object from tree # update state if 'lib' == type: self.files.pop(element_name) elif 'dir' == type: self.dirt_file(self.get_root_library(self.current)) # expand the parent self.expand_tree(parent_name.replace('/editor/', '')) else: cjr.show_warning_message("Element is read-only")
def on_delete_from_disk (self, event): obj = self.GetPyData(self.current) lib_name = obj.getname() # delete only files avilable in the file list, files that are not # in this list are supossed read-only root_lib_name = self.GetItemText(self.get_root_library(self.current)) if self.files.has_key(root_lib_name): position = self.__get_cursor_position() dlg_result = cjr.confirm_yes_no_at_position( self, "Are you sure?", position ) if dlg_result == wx.ID_YES: parent = obj.getparent() dir_to_expand = parent.getfullname() os.remove(self.files[lib_name][0]) # delete file from disk! self.files.pop(lib_name) pynebula.delete(obj.getfullname()) self.expand_tree(dir_to_expand.replace('/editor/', '') ) else: cjr.show_warning_message("Element is read-only")
def delete(self, library, type='dir'): element_name = self.GetItemText(library) if self.is_valid(library): if 'lib' == type: msg1 = "This will unload the %s library from memory.\n\n"\ "Are you sure?" % (element_name) elif 'dir' == type: msg1 = "This will delete the %s directory.\n\n"\ "Are you sure?" % (element_name) position = self.__get_cursor_position() dlg_result = cjr.confirm_yes_no_at_position(self, msg1, position) if dlg_result == wx.ID_YES: # get full nebula path library_data = self.GetPyData(library) full_path = library_data.getfullname() # the same with the parent for expand the tree after delete parent = library_data.getparent() parent_name = parent.getfullname() pynebula.delete(full_path) # delete nebula object self.Delete(self.current) # delete object from tree # update state if 'lib' == type: self.files.pop(element_name) elif 'dir' == type: self.dirt_file(self.get_root_library(self.current)) # expand the parent self.expand_tree(parent_name.replace('/editor/', '')) else: cjr.show_warning_message("Element is read-only")