def set_nclass_dirty_flag(is_dirty): if is_dirty: if not get_nclass_dirty_flag(): pynebula.new('nroot', '/editor/nclass_dirty') else: if get_nclass_dirty_flag(): pynebula.delete('/editor/nclass_dirty')
def on_start( self, evt ): if self.network is None: if self.multiplayer: self.network = pynebula.new( "nnetworkmanagermulti", "/sys/servers/network" ) else: self.network = pynebula.new( "nnetworkmanager", "/sys/servers/network" ) if self.network is not None: if self.server: self.network.setserverport( self.gameport ) self.network.startserver() self.searching = False state = app.get_state( "load" ) state.setnextstate( "game" ) state = app.get_state( "game" ) state.setnextstate( "editor" ) servers.get_conjurer().setstate( "load" ) self.parent.Close()
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 __init__(self, needs_render_window ): """Constructor. Initializes the application main window and restores the previous run. """ wx.MDIParentFrame.__init__( self, None, -1, "Conjurer GUI", size = (1024, 768) ) # window icon file_server = servers.get_file_server() icon_path = file_server.manglepath("outgui:images/conjurer.ico") self.SetIcon( wx.Icon(icon_path, wx.BITMAP_TYPE_ICO) ) # Let the InGUI know that the OutGUI is open pynebula.new('nroot', '/editor/outguiisopened') self.quit_without_saving = False self.quit_requested = False # create a render window if required if needs_render_window: self.render_window = renderwindow.CreateWindow(self) parent_hwnd_env = pynebula.new('nenv','/sys/env/hwnd') parent_hwnd_env.seti(self.render_window.GetPanelHandle()) else: self.render_window = None # preparing repository nebulaguisettings.Repository # toggable window manager self.togwinmgr = togwin.ToggableWindowMgr(self) # menu bar self.__menubar = menubar.MenuBar(self) self.__menubar.create() self.SetMenuBar(self.__menubar) # status bar self.__statusbar = statusbar.StatusBar(self) self.__statusbar.create() self.SetStatusBar(self.__statusbar) # tool bar self.__toolbar = toolbar.ToolBar(self) self.__toolbar.create() self.SetToolBar(self.__toolbar) self.__toolbar.Realize() # events self.Bind(wx.EVT_CLOSE, self.on_close_window) self.Bind(nh.EVT_CONJURER_HELP, self.on_conjurer_help) # TODO: Delete when found a direct way to know the mouse position self.__mouse_position = wx.Point(0, 0) self.__toolbar.Bind(wx.EVT_LEFT_UP, self.__on_left_click)
def __init__(self, needs_render_window): """Constructor. Initializes the application main window and restores the previous run. """ wx.MDIParentFrame.__init__(self, None, -1, "Conjurer GUI", size=(1024, 768)) # window icon file_server = servers.get_file_server() icon_path = file_server.manglepath("outgui:images/conjurer.ico") self.SetIcon(wx.Icon(icon_path, wx.BITMAP_TYPE_ICO)) # Let the InGUI know that the OutGUI is open pynebula.new('nroot', '/editor/outguiisopened') self.quit_without_saving = False self.quit_requested = False # create a render window if required if needs_render_window: self.render_window = renderwindow.CreateWindow(self) parent_hwnd_env = pynebula.new('nenv', '/sys/env/hwnd') parent_hwnd_env.seti(self.render_window.GetPanelHandle()) else: self.render_window = None # preparing repository nebulaguisettings.Repository # toggable window manager self.togwinmgr = togwin.ToggableWindowMgr(self) # menu bar self.__menubar = menubar.MenuBar(self) self.__menubar.create() self.SetMenuBar(self.__menubar) # status bar self.__statusbar = statusbar.StatusBar(self) self.__statusbar.create() self.SetStatusBar(self.__statusbar) # tool bar self.__toolbar = toolbar.ToolBar(self) self.__toolbar.create() self.SetToolBar(self.__toolbar) self.__toolbar.Realize() # events self.Bind(wx.EVT_CLOSE, self.on_close_window) self.Bind(nh.EVT_CONJURER_HELP, self.on_conjurer_help) # TODO: Delete when found a direct way to know the mouse position self.__mouse_position = wx.Point(0, 0) self.__toolbar.Bind(wx.EVT_LEFT_UP, self.__on_left_click)
def __init__(self): wx.Frame.__init__(self, None, -1, "Nebula WX Viewer", wx.DefaultPosition, wx.Size(1024, 768)) self.myApplication = None self.tree = NOHTree(self, -1, nebula.sel('/')) self.tree.SetSelectionChangedCallback(self.OnNOHSelectionChanged) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self.nebulaRenderPanel = wx.Panel(self, -1, wx.Point(0, 0), wx.Size(640, 480), wx.SUNKEN_BORDER, "NebulaRender") self.nebulaRenderPanel.SetMinSize(wx.Size(640, 480)) parentHwndEnv = nebula.new('nenv', '/sys/env/parent_hwnd') parentHwndEnv.seti(self.nebulaRenderPanel.GetHandle()) self.propertyPanel = wx.Notebook(self, -1, wx.DefaultPosition, wx.Size(640, 288), wx.SUNKEN_BORDER, "Properties") # Set up layout hSizer = wx.BoxSizer(wx.HORIZONTAL) hSizer.Add(self.tree, 1, wx.EXPAND) rSizer = wx.BoxSizer(wx.VERTICAL) rSizer.Add(self.nebulaRenderPanel, 0, wx.EXPAND) rSizer.Add(self.propertyPanel, 1, wx.EXPAND) hSizer.Add(rSizer, 0, wx.EXPAND) self.SetSizer(hSizer) # Select the root node by default self.tree.SelectItem(self.tree.root)
def add_emitter( particle_system, emitter_name, texture_name = 'home:export/textures/materials/rauch.dds' ): particle_system_name = particle_system.getname() root_node = particle_system.getrootnode() # check there isn't already one with the same name for each_child in root_node.getchildren(): if each_child.getname() == emitter_name: cjr.show_error_message( "There is already an emitter "\ "called '%s'." % emitter_name ) return False particle_NOH = root_node.getfullname() + '/' + emitter_name # force particle instances to release resources before # adding new emiiter particle_system.refresh() particle_node = pynebula.new( 'nparticleshapenode2', particle_NOH ) if particle_node is None: return False else: set_default_options( particle_node, texture_name ) particle_node.binddirtydependence(root_node) particle_node.setobjectdirty(True) return True
def on_ok_button_clicked(self, event): result_list = self.get_selected_entities() if result_list: if self.has_valid_path_name(): #we need to save the entity id counter to avoid conflicts servers.get_entity_object_server().saveconfig() object_instancer = pynebula.new('nobjectinstancer') object_instancer.init( len(result_list), len(result_list) ) object_instancer.setentityobjecttype( CJR_NORMAL_ENTITY_TYPE ) for each_entity in result_list: entity_id_as_string = str( each_entity.getid() ) object_instancer.appendwithname( each_entity, entity_id_as_string ) object_instancer.saveas( self.get_path_name() ) pynebula.delete(object_instancer) self.Close() else: cjr.show_error_message( "Please enter a valid path name" ) else: cjr.show_error_message( "Please select at least one entity to export" )
def add_emitter(particle_system, emitter_name, texture_name='home:export/textures/materials/rauch.dds'): particle_system_name = particle_system.getname() root_node = particle_system.getrootnode() # check there isn't already one with the same name for each_child in root_node.getchildren(): if each_child.getname() == emitter_name: cjr.show_error_message( "There is already an emitter "\ "called '%s'." % emitter_name ) return False particle_NOH = root_node.getfullname() + '/' + emitter_name # force particle instances to release resources before # adding new emiiter particle_system.refresh() particle_node = pynebula.new('nparticleshapenode2', particle_NOH) if particle_node is None: return False else: set_default_options(particle_node, texture_name) particle_node.binddirtydependence(root_node) particle_node.setobjectdirty(True) return True
def __safe_new(path, type='nroot'): """Create an object if it doesn't exist yet""" try: return pynebula.lookup(path) except: obj = pynebula.new(type, path) return obj
def create_default_state(path, type='nleafstate'): """Create a state with default parameters""" state = pynebula.new(type, path) if type == 'nleafstate': action_path = fsm.get_behaction_of_state(path) action = fsmaction.create_default_action(action_path) if action != None: state.setbehaviouralaction(action) else: state = None pynebula.delete(path) cjr.show_error_message( "There isn't any action available.\n" \ "Couldn't create a default leaf state." ) elif type == 'nnodestate': selector_list = fsm.get_fsm_selectors() if len(selector_list) > 0: state.setfsmselectorbyname(str(selector_list[0])) else: state = None pynebula.delete(path) cjr.show_error_message( "There isn't any FSM selection script available.\n" \ "Couldn't create a default node state." ) return state
def create_default_action( path ): action = pynebula.new( 'nactiondesc', path ) action_classes = fsm.get_action_classes() if len(action_classes) == 0: return None action.setactionclass( str(action_classes[0]) ) ## action.setintarg(1) ## action.setactiontype(8) ## action.appendintarg(1) return action
def __on_update_condition(self, event): # Remove transition from state transition = self.__get_transition() state_path = fsm.get_state_of_transition(self.transition_path) state = pynebula.lookup(state_path) state.removetransition(transition) # Get old event and filter old_cond_obj = transition.getcondition() old_event_id = old_cond_obj.getevent() old_filter_obj = old_cond_obj.getfiltercondition() # Get new event and filter # new_event_name = self.choice_event.GetStringSelection() # new_event_id = servers.get_fsm_server().geteventcondition( str(new_event_name) ).getevent() new_event_id = self.event_ids[self.choice_event.GetSelection()] new_filter_name = self.choice_filter.GetStringSelection() new_filter_obj = None if new_filter_name != "<none>": new_filter_obj = servers.get_fsm_server().getscriptcondition( str(new_filter_name)) # Act depending on filter condition existance and selection local_cond_path = fsm.get_filteredcondition_of_transition( self.transition_path) if old_filter_obj == None: if new_filter_obj == None: # Neither the old or the new conditions have a filter # Just select a shared condition new_cond_obj = get_event_condition( new_event_id ) #servers.get_fsm_server().geteventcondition( str(new_event_name) ) else: # The old condition doesn't have a filter, but the new one does # Create a local condition, with the same event and new filter new_cond_obj = pynebula.new('neventcondition', local_cond_path) new_cond_obj.setevent(new_event_id) new_cond_obj.setfiltercondition(new_filter_obj) else: if new_filter_obj == None: # The old condition has a filter, but the new one doesn't # Remove the local condition and select a shared condition old_cond_obj = None pynebula.delete(str(local_cond_path)) new_cond_obj = get_event_condition( new_event_id ) #servers.get_fsm_server().geteventcondition( str(new_event_name) ) else: # Both the old and the new conditions have a filter # Update the local condition with the new event new_cond_obj = old_cond_obj new_cond_obj.setevent(new_event_id) # Reinsert the transition into the state transition.setcondition(new_cond_obj) state.addtransition(transition) # Signal the change fsmevents.signal_fsm_change(self, self.transition_path)
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 on_search( self, evt ): self.singlecheck.Disable() self.servercheck.Disable() self.button_search.Disable() self.button_cancel.Enable() self.network = pynebula.new( "nnetworkmanagermulti", "/sys/servers/network" ) self.network.startsearching( self.gameport ) self.searching = True
def CreateAsset( name , textureName ): fileServer = servers.get_file_server() assetPath = 'wc:export/assets/' + name transformNOH = '/lib/scene/' + name particleNOH = transformNOH + '/pemiter_0_0' rootNode = pynebula.new( 'ntransformnode' , transformNOH ) particleNode = pynebula.new( 'nparticleshapenode' , particleNOH ) setDefualtOptions( particleNode , textureName ) #save shapeNode if ( not fileServer.makepath( assetPath ) ): return None, "" if ( not fileServer.makepath( assetPath + '/scene' ) ): return None , "" if ( not fileServer.makepath( assetPath + '/materials' ) ): return None, "" if ( not rootNode.saveas( assetPath +'/scene/' + name + '.n2' ) ): return None,"" #pynebula.delete(rootNode.getfullname()) #rootNode = 0 return particleNode , assetPath
def CreateAsset(name, textureName): fileServer = servers.get_file_server() assetPath = 'wc:export/assets/' + name transformNOH = '/lib/scene/' + name particleNOH = transformNOH + '/pemiter_0_0' rootNode = pynebula.new('ntransformnode', transformNOH) particleNode = pynebula.new('nparticleshapenode', particleNOH) setDefualtOptions(particleNode, textureName) #save shapeNode if (not fileServer.makepath(assetPath)): return None, "" if (not fileServer.makepath(assetPath + '/scene')): return None, "" if (not fileServer.makepath(assetPath + '/materials')): return None, "" if (not rootNode.saveas(assetPath + '/scene/' + name + '.n2')): return None, "" #pynebula.delete(rootNode.getfullname()) #rootNode = 0 return particleNode, assetPath
def __on_update_condition(self, event): # Remove transition from state transition = self.__get_transition() state_path = fsm.get_state_of_transition( self.transition_path ) state = pynebula.lookup( state_path ) state.removetransition( transition ) # Get old event and filter old_cond_obj = transition.getcondition() old_event_id = old_cond_obj.getevent() old_filter_obj = old_cond_obj.getfiltercondition() # Get new event and filter # new_event_name = self.choice_event.GetStringSelection() # new_event_id = servers.get_fsm_server().geteventcondition( str(new_event_name) ).getevent() new_event_id = self.event_ids[ self.choice_event.GetSelection() ] new_filter_name = self.choice_filter.GetStringSelection() new_filter_obj = None if new_filter_name != "<none>": new_filter_obj = servers.get_fsm_server().getscriptcondition( str(new_filter_name) ) # Act depending on filter condition existance and selection local_cond_path = fsm.get_filteredcondition_of_transition( self.transition_path ) if old_filter_obj == None: if new_filter_obj == None: # Neither the old or the new conditions have a filter # Just select a shared condition new_cond_obj = get_event_condition( new_event_id ) #servers.get_fsm_server().geteventcondition( str(new_event_name) ) else: # The old condition doesn't have a filter, but the new one does # Create a local condition, with the same event and new filter new_cond_obj = pynebula.new( 'neventcondition', local_cond_path ) new_cond_obj.setevent( new_event_id ) new_cond_obj.setfiltercondition( new_filter_obj ) else: if new_filter_obj == None: # The old condition has a filter, but the new one doesn't # Remove the local condition and select a shared condition old_cond_obj = None pynebula.delete( str(local_cond_path) ) new_cond_obj = get_event_condition( new_event_id ) #servers.get_fsm_server().geteventcondition( str(new_event_name) ) else: # Both the old and the new conditions have a filter # Update the local condition with the new event new_cond_obj = old_cond_obj new_cond_obj.setevent( new_event_id ) # Reinsert the transition into the state transition.setcondition( new_cond_obj ) state.addtransition( transition ) # Signal the change fsmevents.signal_fsm_change( self, self.transition_path )
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 on_new(self, event): """Ask for a name and create a new object it if it's a non existing name""" dlg = wx.TextEntryDialog( None, "Enter the " + self.caption + "'s name:", "New " + self.caption ) if dlg.ShowModal() == wx.ID_OK: # Add the object only if there isn't another object with the same name yet obj_path = format.append_to_path( self.lib_path, dlg.GetValue() ) try: # Lookup will fail if it's a new name (name not found) pynebula.lookup( obj_path ) msg = "Another " + self.caption + " named '" + dlg.GetValue() + "' already exists." cjr.show_error_message(msg) except: # Create object, save it to disk and add it to list obj = pynebula.new( str(self.class_name), str(obj_path) ) self.save_object( obj ) self.list.Append( dlg.GetValue() ) dlg.Destroy()
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 __get_inputs_formats(self): # create a temporary object so the model can know about its init command action = self.__get_action() class_name = action.getactionclass() model_obj = pynebula.new( str(class_name) ) model = scriptingmodelsingleobject.new_scripting_model_for_object( model_obj ) # get the init command inputs' format try: inputs = model.get_command('init')['input'] except: inputs = [] # destroy the temporary model object pynebula.delete( model_obj ) model_obj = None # return the inputs' format, discarding the first one, which is # reserved for internal usage (the entity owning the action) return inputs[1:]
def on_class_select(self, evt): try: wx.BeginBusyCursor() class_name = evt.GetString() # Clear GUI self.cmds.Clear() self.cmds_pg.Clear() # Temporary object to get the commands, must be deleted!! inspector = pynebula.new( "nobjinspector", "/editor/inspector" ) # I can call the init function several times to get the # signals for all the classes I want if class_name == "All": for name in self.object.getclasses(): inspector.initsignalsclass( str(name) ) else: inspector.initsignalsclass( str(class_name) ) # Add the commands to the combox list num_cmds = inspector.getcmdscount() self.cmds_protos = list() self.get_dict = dict() for index in xrange(num_cmds): self.cmds.Append( inspector.getcmdname(index) ) if re.compile("get.*").match( inspector.getcmdname(index) ): self.get_dict[inspector.getcmdname(index)] = \ inspector.getcmdprotoname(index) # Delete the inspector pynebula.delete("/editor/inspector") self.cmds.SetValue("Choose command") self.btn_send.Disable() finally: wx.EndBusyCursor()
def on_ok_button_clicked(self, event): result_list = self.get_selected_entities() if result_list: if self.has_valid_path_name(): #we need to save the entity id counter to avoid conflicts servers.get_entity_object_server().saveconfig() object_instancer = pynebula.new('nobjectinstancer') object_instancer.init(len(result_list), len(result_list)) object_instancer.setentityobjecttype(CJR_NORMAL_ENTITY_TYPE) for each_entity in result_list: entity_id_as_string = str(each_entity.getid()) object_instancer.appendwithname(each_entity, entity_id_as_string) object_instancer.saveas(self.get_path_name()) pynebula.delete(object_instancer) self.Close() else: cjr.show_error_message("Please enter a valid path name") else: cjr.show_error_message( "Please select at least one entity to export")
def class_select(inspector_win, class_name): try: wx.BeginBusyCursor() # Temporary object for get the commands, must be deleted!! inspector = pynebula.new( "nobjinspector", "/editor/inspector" ) # I can call the init function multipletimes to get the # commands for all classes I want if class_name == "All": for name in inspector_win.object.getclasses(): inspector.initcmdsclass( str(name) ) else: inspector.initcmdsclass( str(class_name) ) doc_string = "Class %s not found in xml database.\n"\ "Doc and custom controls deactivated" % class_name inspector_win.doc_text.SetLabel(doc_string) inspector_win.Layout() # Add the commands to the combox list num_cmds = inspector.getcmdscount() inspector_win.cmds_protos = list() inspector_win.get_dict = dict() for index in xrange(num_cmds): inspector_win.cmds.Append( inspector.getcmdname(index) ) if re.compile("get.*").match( inspector.getcmdname(index) ): inspector_win.get_dict[inspector.getcmdname(index)] = \ inspector.getcmdprotoname(index) # Delete the inspector pynebula.delete("/editor/inspector") inspector_win.cmds.SetValue("Choose command") inspector_win.btn_exec.Disable() finally: wx.EndBusyCursor()
def on_connectto( self, evt ): if self.network is None: self.network = pynebula.new( "nnetworkmanagermulti", "/sys/servers/network" ) if self.network is not None: self.network.connecthost( str( self.hostedit.GetValue() ), self.gameport ) self.searching = False state = app.get_state( "load" ) state.setnextstate( "game" ) state = app.get_state( "game" ) state.setnextstate( "editor" ) servers.get_conjurer().setstate( "load" ) self.parent.Close()
def __on_new_transition(self, event): """Create a new transition with default values""" # Get the first free condition by default cond_paths = fsmtransitiontype.get_free_event_conditions( self.state_path ) if len(cond_paths) == 0: cond_paths = fsmtransitiontype.get_free_script_conditions( self.state_path ) if len(cond_paths) == 0: cjr.show_information_message( "This state already has transitions for all " \ "the available conditions." ) return condition = pynebula.lookup( cond_paths[0] ) # Create the transition with a free name transition_path = fsm.get_free_name( self.__get_transitions_path(), 'transition' ) transition = pynebula.new( "ntransition", transition_path ) transition.setcondition( condition ) self.__get_state().addtransition( transition ) self.list_transitions.Append( get_transition_gui_name( transition.getfullname() ) ) self.__update_new_button() fsmevents.signal_fsm_change(self, fsmevents.ID_NewTransition)
def create_default_state(path, type="nleafstate"): """Create a state with default parameters""" state = pynebula.new(type, path) if type == "nleafstate": action_path = fsm.get_behaction_of_state(path) action = fsmaction.create_default_action(action_path) if action != None: state.setbehaviouralaction(action) else: state = None pynebula.delete(path) cjr.show_error_message("There isn't any action available.\n" "Couldn't create a default leaf state.") elif type == "nnodestate": selector_list = fsm.get_fsm_selectors() if len(selector_list) > 0: state.setfsmselectorbyname(str(selector_list[0])) else: state = None pynebula.delete(path) cjr.show_error_message( "There isn't any FSM selection script available.\n" "Couldn't create a default node state." ) return state
def on_signal_select(self, evt): cmd_name = self.cmds.GetStringSelection() self.cmds_pg.Clear() class_name = self.classes.GetStringSelection() # Temporary object to get the commands: must be deleted after use!! inspector = pynebula.new( "nobjinspector", "/editor/inspector" ) if class_name == "All": for name in self.object.getclasses(): inspector.initsignalsclass( str(name) ) else: inspector.initsignalsclass( str(class_name) ) # Build a dictionary with the cmd name and its # position in the array: this way I can list the cmds # alphabetically self.cmd_dict = dict() for index in xrange( inspector.getcmdscount() ): self.cmd_dict[inspector.getcmdname(index)] = index num_cmd = self.cmd_dict[cmd_name] num_args = inspector.getinargscount(num_cmd) # Build the properties depending of the argument type self.cmd_proto_name = inspector.getcmdprotoname(num_cmd) arg = self.cmd_proto_name.rsplit('_') # Draw In properties self.in_elements = list() if num_args > 0: self.cmds_pg.Append( pg.wxPropertyCategory( "In Args", "InValues" ) ) self.__draw_input_fields( arg[2], self.in_elements, "in" ) # Draw Out properties self.out_elements = list() if inspector.getoutargscount(num_cmd) > 0: self.cmds_pg.Append( pg.wxPropertyCategory( "Out Args", "OutValues" ) ) self.__draw_input_fields( arg[0], self.out_elements, "out" ) # Delete the inspector pynebula.delete("/editor/inspector") self.btn_send.Enable()
def OnGuiServerOpen(): # initialize the default tooltip guiServer = nebula.lookup('/sys/servers/gui') guiRoot = guiServer.getrootpath() oldCwd = nebula.psel() nebula.sel(guiRoot) toolTip = nebula.new("nguitooltip", "Tooltip") toolTip.setdefaultbrush("tooltip") toolTip.setfont("GuiSmall") toolTip.setcolor(0, 0, 0, 1) toolTip.setalignment("left") toolTip.setborder(0.005, 0.005) # define the system skin skin = guiServer.newskin('system') # set texture path pre- and postfix (NOTE: don't change path to textures:system!!!) skin.settextureprefix("home:export/textures/system/") skin.settexturepostfix(".dds") # active and inactive window modulation color skin.setactivewindowcolor(1.0, 1.0, 1.0, 1.0) skin.setinactivewindowcolor(0.6, 0.6, 0.6, 0.6) skin.setbuttontextcolor(0.0, 0.0, 0.0, 1.0) skin.settitletextcolor(0.0, 0.0, 0.0, 1.0) skin.setlabeltextcolor(0.0, 0.0, 0.0, 1.0) skin.setentrytextcolor(0.0, 0.0, 0.0, 1.0) skin.settextcolor(0.0, 0.0, 0.0, 1.0) skin.setmenutextcolor(0.0, 0.0, 0.0, 1.0) # define brushes skin.beginbrushes() # window title bar, window background, tooltip background skin.addbrush('titlebar','skin',66,152,10,20,1.0,1.0,1.0,1.0) skin.addbrush('window','skin',8,154,4,4,1.0,1.0,1.0,1.0) skin.addbrush('tooltip','skin',8,154,4,4,1.0,1.0,0.878,0.8) skin.addbrush('pink','skin',8,154,4,4,1.0,1.0,1.0,1.0) skin.addbrush('dragbox','skin',8,154,4,4,1.0,0.8,0.8,0.5) # text entry field skin.addbrush('textentry_n','skin',446,124,8,8,0.7,0.7,0.7,1.0) skin.addbrush('textentry_p','skin',446,124,8,8,0.8,0.8,0.8,1.0) skin.addbrush('textentry_h','skin',446,124,8,8,0.9,0.9,0.9,1.0) skin.addbrush('textcursor','skin',446,124,8,8,1.0,0.8,0.8,0.5) # the window close button skin.addbrush('close_n','skin',388,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('close_h','skin',388,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('close_p','skin',388,40,16,16,1.0,1.0,1.0,1.0) # the window size button skin.addbrush('size_n','skin',372,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('size_h','skin',372,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('size_p','skin',372,40,16,16,1.0,1.0,1.0,1.0) # arrows skin.addbrush('arrowleft_n','skin',68,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowleft_h','skin',84,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowleft_p','skin',100,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowright_n','skin',116,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowright_h','skin',132,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowright_p','skin',148,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowup_n','skin',164,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowup_h','skin',180,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowup_p','skin',196,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowdown_n','skin',20,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowdown_h','skin',36,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('arrowdown_p','skin',52,40,16,16,1.0,1.0,1.0,1.0) # sliders skin.addbrush('sliderhori_bg','skin', 228, 40, 16, 16, 0.5, 0.5, 0.5, 1.0) skin.addbrush('slidervert_bg','skin', 228, 40, 16, 16, 0.5, 0.5, 0.5, 1.0) skin.addbrush('sliderknobhori_n','skin',276,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('sliderknobhori_p','skin',292,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('sliderknobhori_h','skin',308,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('sliderknobvert_n','skin',324,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('sliderknobvert_p','skin',340,40,16,16,1.0,1.0,1.0,1.0) skin.addbrush('sliderknobvert_h','skin',356,40,16,16,1.0,1.0,1.0,1.0) # standard buttons skin.addbrush('button_n','skin',192,152,96,20,1.0,1.0,1.0,1.0) skin.addbrush('button_h','skin',288,152,96,20,1.0,1.0,1.0,1.0) skin.addbrush('button_p','skin',384,152,96,20,1.0,1.0,1.0,1.0) skin.addbrush('menu_n','skin',192,172,96,16,1.0,1.0,1.0,1.0) skin.addbrush('menu_h','skin',288,172,96,16,1.0,1.0,1.0,1.0) skin.addbrush('menu_p','skin',384,172,96,16,1.0,1.0,1.0,1.0) skin.addbrush('button_64x16_n', 'skin', 0, 0, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_64x16_h', 'skin', 64, 0, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_64x16_p', 'skin', 128, 0, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_96x16_n', 'skin', 192, 0, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_96x16_h', 'skin', 288, 0, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_96x16_p', 'skin', 384, 0, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_64x24_n', 'skin', 0, 16, 64, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_64x24_h', 'skin', 64, 16, 64, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_64x24_p', 'skin', 128, 16, 64, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_96x24_n', 'skin', 192, 16, 96, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_96x24_h', 'skin', 288, 16, 96, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_96x24_p', 'skin', 384, 16, 96, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_64x20_n', 'skin', 192, 152, 96, 20, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_64x20_h', 'skin', 288, 152, 96, 20, 1.0, 1.0, 1.0, 1.0) skin.addbrush('button_64x20_p', 'skin', 384, 152, 96, 20, 1.0, 1.0, 1.0, 1.0) skin.addbrush('menu_64x16_n', 'skin', 0, 172, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('menu_64x16_h', 'skin', 64, 172, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('menu_64x16_p', 'skin', 128, 172, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('menu_128x16_n', 'skin', 192, 172, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('menu_128x16_h', 'skin', 288, 172, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush('menu_128x16_p', 'skin', 384, 172, 96, 16, 1.0, 1.0, 1.0, 1.0) # list views skin.addbrush('list_background', 'skin', 446, 72, 8, 8, 1.0, 1.0, 1.0, 1.0) skin.addbrush('list_selection' , 'skin', 64, 172, 64, 16, 1.0, 1.0, 1.0, 1.0) # icons skin.addbrush('console_n', 'skin', 0, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('console_p', 'skin', 0, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush('console_h', 'skin', 0, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('texbrowser_n', 'skin', 48, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('texbrowser_p', 'skin', 48, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush('texbrowser_h', 'skin', 48, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('gfxbrowser_n', 'skin', 96, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('gfxbrowser_p', 'skin', 96, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush('gfxbrowser_h', 'skin', 96, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('dbgwindow_n', 'skin', 144, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('dbgwindow_p', 'skin', 144, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush('dbgwindow_h', 'skin', 144, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('syswindow_n', 'skin', 192, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('syswindow_p', 'skin', 192, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush('syswindow_h', 'skin', 192, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('contrwindow_n', 'skin', 336, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('contrwindow_p', 'skin', 336, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush('contrwindow_h', 'skin', 336, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('hidegui_n', 'skin', 240, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('hidegui_p', 'skin', 240, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush('hidegui_h', 'skin', 240, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('quit_n', 'skin', 288, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('quit_p', 'skin', 288, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush('quit_h', 'skin', 288, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('hardpoint_n', 'skin', 0, 188, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('hardpoint_p', 'skin', 0, 188, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush('hardpoint_h', 'skin', 48, 188, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('disp_n', 'skin', 384, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush('disp_p', 'skin', 384, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush('disp_h', 'skin', 384, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) # the left and right logos skin.addbrush('n2logo', 'n2logo', 0, 0, 64, 64, 1.0, 1.0, 1.0, 0.5) # the color hexagon for the colorpicker skin.addbrush('colorhex', 'colorhexagon', 0, 0, 170, 141, 1.0, 1.0, 1.0, 1.0) skin.endbrushes() guiServer.setsystemskin(skin) guiServer.setskin(skin) # create the Nebula dock window guiServer.newwindow('nguidockwindow', True) nebula.sel(oldCwd)
def OnGuiServerOpen(): # initialize the default tooltip guiServer = nebula.lookup("/sys/servers/gui") guiRoot = guiServer.getrootpath() oldCwd = nebula.psel() nebula.sel(guiRoot) toolTip = nebula.new("nguitooltip", "Tooltip") toolTip.setdefaultbrush("tooltip") toolTip.setfont("GuiSmall") toolTip.setcolor(0, 0, 0, 1) toolTip.setalignment("left") toolTip.setborder(0.005, 0.005) # define the system skin skin = guiServer.newskin("system") # set texture path pre- and postfix (NOTE: don't change path to textures:system!!!) skin.settextureprefix("home:export/textures/system/") skin.settexturepostfix(".dds") # active and inactive window modulation color skin.setactivewindowcolor(1.0, 1.0, 1.0, 1.0) skin.setinactivewindowcolor(0.6, 0.6, 0.6, 0.6) skin.setbuttontextcolor(0.0, 0.0, 0.0, 1.0) skin.settitletextcolor(0.0, 0.0, 0.0, 1.0) skin.setlabeltextcolor(0.0, 0.0, 0.0, 1.0) skin.setentrytextcolor(0.0, 0.0, 0.0, 1.0) skin.settextcolor(0.0, 0.0, 0.0, 1.0) skin.setmenutextcolor(0.0, 0.0, 0.0, 1.0) # define brushes skin.beginbrushes() # window title bar, window background, tooltip background skin.addbrush("titlebar", "skin", 66, 152, 10, 20, 1.0, 1.0, 1.0, 1.0) skin.addbrush("window", "skin", 8, 154, 4, 4, 1.0, 1.0, 1.0, 1.0) skin.addbrush("tooltip", "skin", 8, 154, 4, 4, 1.0, 1.0, 0.878, 0.8) skin.addbrush("pink", "skin", 8, 154, 4, 4, 1.0, 1.0, 1.0, 1.0) skin.addbrush("dragbox", "skin", 8, 154, 4, 4, 1.0, 0.8, 0.8, 0.5) # text entry field skin.addbrush("textentry_n", "skin", 446, 124, 8, 8, 0.7, 0.7, 0.7, 1.0) skin.addbrush("textentry_p", "skin", 446, 124, 8, 8, 0.8, 0.8, 0.8, 1.0) skin.addbrush("textentry_h", "skin", 446, 124, 8, 8, 0.9, 0.9, 0.9, 1.0) skin.addbrush("textcursor", "skin", 446, 124, 8, 8, 1.0, 0.8, 0.8, 0.5) # the window close button skin.addbrush("close_n", "skin", 388, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("close_h", "skin", 388, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("close_p", "skin", 388, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) # the window size button skin.addbrush("size_n", "skin", 372, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("size_h", "skin", 372, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("size_p", "skin", 372, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) # arrows skin.addbrush("arrowleft_n", "skin", 68, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowleft_h", "skin", 84, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowleft_p", "skin", 100, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowright_n", "skin", 116, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowright_h", "skin", 132, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowright_p", "skin", 148, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowup_n", "skin", 164, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowup_h", "skin", 180, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowup_p", "skin", 196, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowdown_n", "skin", 20, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowdown_h", "skin", 36, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("arrowdown_p", "skin", 52, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) # sliders skin.addbrush("sliderhori_bg", "skin", 228, 40, 16, 16, 0.5, 0.5, 0.5, 1.0) skin.addbrush("slidervert_bg", "skin", 228, 40, 16, 16, 0.5, 0.5, 0.5, 1.0) skin.addbrush("sliderknobhori_n", "skin", 276, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("sliderknobhori_p", "skin", 292, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("sliderknobhori_h", "skin", 308, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("sliderknobvert_n", "skin", 324, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("sliderknobvert_p", "skin", 340, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("sliderknobvert_h", "skin", 356, 40, 16, 16, 1.0, 1.0, 1.0, 1.0) # standard buttons skin.addbrush("button_n", "skin", 192, 152, 96, 20, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_h", "skin", 288, 152, 96, 20, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_p", "skin", 384, 152, 96, 20, 1.0, 1.0, 1.0, 1.0) skin.addbrush("menu_n", "skin", 192, 172, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("menu_h", "skin", 288, 172, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("menu_p", "skin", 384, 172, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_64x16_n", "skin", 0, 0, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_64x16_h", "skin", 64, 0, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_64x16_p", "skin", 128, 0, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_96x16_n", "skin", 192, 0, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_96x16_h", "skin", 288, 0, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_96x16_p", "skin", 384, 0, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_64x24_n", "skin", 0, 16, 64, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_64x24_h", "skin", 64, 16, 64, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_64x24_p", "skin", 128, 16, 64, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_96x24_n", "skin", 192, 16, 96, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_96x24_h", "skin", 288, 16, 96, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_96x24_p", "skin", 384, 16, 96, 24, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_64x20_n", "skin", 192, 152, 96, 20, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_64x20_h", "skin", 288, 152, 96, 20, 1.0, 1.0, 1.0, 1.0) skin.addbrush("button_64x20_p", "skin", 384, 152, 96, 20, 1.0, 1.0, 1.0, 1.0) skin.addbrush("menu_64x16_n", "skin", 0, 172, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("menu_64x16_h", "skin", 64, 172, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("menu_64x16_p", "skin", 128, 172, 64, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("menu_128x16_n", "skin", 192, 172, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("menu_128x16_h", "skin", 288, 172, 96, 16, 1.0, 1.0, 1.0, 1.0) skin.addbrush("menu_128x16_p", "skin", 384, 172, 96, 16, 1.0, 1.0, 1.0, 1.0) # list views skin.addbrush("list_background", "skin", 446, 72, 8, 8, 1.0, 1.0, 1.0, 1.0) skin.addbrush("list_selection", "skin", 64, 172, 64, 16, 1.0, 1.0, 1.0, 1.0) # icons skin.addbrush("console_n", "skin", 0, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("console_p", "skin", 0, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush("console_h", "skin", 0, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("texbrowser_n", "skin", 48, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("texbrowser_p", "skin", 48, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush("texbrowser_h", "skin", 48, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("gfxbrowser_n", "skin", 96, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("gfxbrowser_p", "skin", 96, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush("gfxbrowser_h", "skin", 96, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("dbgwindow_n", "skin", 144, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("dbgwindow_p", "skin", 144, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush("dbgwindow_h", "skin", 144, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("syswindow_n", "skin", 192, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("syswindow_p", "skin", 192, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush("syswindow_h", "skin", 192, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("contrwindow_n", "skin", 336, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("contrwindow_p", "skin", 336, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush("contrwindow_h", "skin", 336, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("hidegui_n", "skin", 240, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("hidegui_p", "skin", 240, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush("hidegui_h", "skin", 240, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("quit_n", "skin", 288, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("quit_p", "skin", 288, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush("quit_h", "skin", 288, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("hardpoint_n", "skin", 0, 188, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("hardpoint_p", "skin", 0, 188, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush("hardpoint_h", "skin", 48, 188, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("disp_n", "skin", 384, 56, 48, 48, 1.0, 1.0, 1.0, 1.0) skin.addbrush("disp_p", "skin", 384, 56, 48, 48, 0.5, 0.5, 0.5, 1.0) skin.addbrush("disp_h", "skin", 384, 104, 48, 48, 1.0, 1.0, 1.0, 1.0) # the left and right logos skin.addbrush("n2logo", "n2logo", 0, 0, 64, 64, 1.0, 1.0, 1.0, 0.5) # the color hexagon for the colorpicker skin.addbrush("colorhex", "colorhexagon", 0, 0, 170, 141, 1.0, 1.0, 1.0, 1.0) skin.endbrushes() guiServer.setsystemskin(skin) guiServer.setskin(skin) # create the Nebula dock window guiServer.newwindow("nguidockwindow", True) nebula.sel(oldCwd)
def __get_transitions_obj(self): try: return pynebula.lookup( self.__get_transitions_path() ) except: return pynebula.new( 'nroot', self.__get_transitions_path() )
def draw_state_commands(self, obj): self.cmds_pg.Clear() if obj is None: self.Disable() return else: self.Enable() # Get the commands inspector = pynebula.new( "nobjinspector", "/editor/inspector" ) inspector.initcmdsstate(obj) # Navigate over the commands and build the interface. We need # the command definition to put it in the category. So first create # the grid properties but do not append them until the category # is placed with the full description. cmds_count = inspector.getcmdscount() self.cmd_list = list() # Command list self.cmd_name_list = list() # Store the categories self.undo_list = list() if cmds_count == 0: self.cmds_pg.Append( pg.wxPropertyCategory( str("State is EMPTY"), str("nostate") ) ) self.prev_state = list() # Storage state when the inspector is call for num_cmd in xrange(cmds_count): cmds_name_desc = inspector.getcmdname(num_cmd) + str(" (") undo_cmd = inspector.getcmdname(num_cmd) + str("(") args_count = inspector.getinargscount(num_cmd) self.element = list() # Start argument list for num_arg in xrange(args_count): label = "label_in" + str(num_cmd) + "-" + str(num_arg+1) arg_type = inspector.gettype(num_cmd, num_arg+1) # Type is Int if arg_type == 1: value = inspector.geti(num_cmd, num_arg+1) self.element.append( pg.wxIntProperty( 'Integer', label ) ) value_as_string = str(value) self.element[num_arg].SetValueFromString( value_as_string, 0 ) self.prev_state.append(value_as_string) cmds_name_desc = cmds_name_desc + value_as_string + ", " undo_cmd = undo_cmd + value_as_string + "," # Type is Float elif arg_type == 2: value = inspector.getf(num_cmd, num_arg+1) self.element.append( pg.wxFloatProperty( 'Float', label ) ) value_as_string = str(value) self.element[num_arg].SetValueFromString( value_as_string, 0 ) self.prev_state.append(value_as_string) undo_cmd = undo_cmd + value_as_string + "," temp = value_as_string.rsplit('.') value = temp[0] + '.' + temp[1][:2] cmds_name_desc = cmds_name_desc + value_as_string + ", " # Type if String elif arg_type == 3: value = inspector.gets(num_cmd, num_arg+1) self.element.append( pg.wxStringProperty( 'String', label, '' ) ) value_as_string = str(value) self.element[num_arg].SetValueFromString( value_as_string, 0 ) self.prev_state.append(value_as_string) cmds_name_desc = cmds_name_desc +\ '"' + value_as_string + '"' + ", " undo_cmd = undo_cmd + '"' + value_as_string + '"' + "," # Type is Boolean elif arg_type == 4: value = inspector.getb(num_cmd, num_arg+1) self.element.append( pg.wxEnumProperty( 'Boolean', label, ['True','False'], [1,0], 2 ) ) if value == 1: self.element[num_arg].SetValueFromString( str("True"), 0 ) cmds_name_desc = cmds_name_desc + str('True') + ", " self.prev_state.append('True') else: self.element[num_arg].SetValueFromString( str("False"), 0 ) cmds_name_desc = cmds_name_desc + str('False') + ", " self.prev_state.append('False') undo_cmd = undo_cmd + str(value) + "," # Type is Object elif arg_type == 5: value = inspector.geto(num_cmd, num_arg+1) self.element.append( pg.wxStringProperty( 'Object', label, '' ) ) full_name_as_string = str( value.getfullname() ) self.element[num_arg].SetValueFromString( full_name_as_string, 0 ) self.prev_state.append(full_name_as_string) cmds_name_desc = cmds_name_desc +\ str(value.getname()) + ", " undo_cmd = undo_cmd + "lookup(" + \ full_name_as_string + ")," # Type not implemented else: cjr.show_error_message("Unknown type!!!") # Write the command definition into the category and attach it if args_count > 0: cmds_name_desc = cmds_name_desc[:-2] + ")" undo_cmd = undo_cmd[:-1] + ")" else: cmds_name_desc = cmds_name_desc + ")" undo_cmd = undo_cmd + ")" category = pg.wxPropertyCategory( cmds_name_desc, "cmdLabel%d" % num_cmd ) self.cmds_pg.Append(category) self.cmd_name_list.append( inspector.getcmdprotoname(num_cmd) ) # Show the arguments (append to grid) recently created # and append them to a command list for num_arg in xrange(args_count): self.cmds_pg.Append(self.element[num_arg]) self.cmd_list.append(self.element) self.undo_list.append(undo_cmd) pynebula.delete("/editor/inspector") # Make de object the current nebulagui.nebula_object = obj self.object = obj # Refresh control self.cmds_pg.Refresh()
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 cmds_select(inspector_win): cmd_name = inspector_win.cmds.GetStringSelection() inspector_win.cmds_pg.Clear() class_name = str( inspector_win.classes.GetStringSelection() ) # Temporary object to get the commands: must be deleted after use!! inspector = pynebula.new( "nobjinspector", "/editor/inspector" ) if class_name == "All": for name in inspector_win.object.getclasses(): inspector.initcmdsclass( str(name) ) else: inspector.initcmdsclass(class_name) # Build a dictionary with the cmd name and its # position in the array: this way I can list the cmds # alphabetically inspector_win.cmd_dict = dict() for index in xrange( inspector.getcmdscount() ): inspector_win.cmd_dict[inspector.getcmdname(index)] = index num_cmd = inspector_win.cmd_dict[cmd_name] num_args = inspector.getinargscount(num_cmd) # Enable the get button if the command has a get counterpart if re.compile("set.*").match(cmd_name): name = cmd_name[3:] try: num_getcmd = inspector_win.cmd_dict[str("get"+name)] num_get_out_args = inspector.getoutargscount(num_getcmd) if num_args != num_get_out_args: inspector_win.btn_get.Disable() else: inspector_win.btn_get.Enable() except: inspector_win.btn_get.Disable() else: inspector_win.btn_get.Disable() # Build the properties depending on the argument type inspector_win.cmd_proto_name = inspector.getcmdprotoname(num_cmd) arg = inspector_win.cmd_proto_name.rsplit('_') # Draw In properties inspector_win.in_elements = list() if num_args > 0: inspector_win.cmds_pg.Append( pg.wxPropertyCategory( "In Args", "InValues" ) ) draw_input_fields( inspector_win, arg[2], inspector_win.in_elements, "in" ) # Draw Out properties inspector_win.out_elements = list() if inspector.getoutargscount(num_cmd) > 0: inspector_win.cmds_pg.Append( pg.wxPropertyCategory( "Out Args", "OutValues" ) ) draw_input_fields( inspector_win, arg[0], inspector_win.out_elements, "out" ) # Delete the inspector pynebula.delete("/editor/inspector") inspector_win.btn_exec.Enable() inspector_win.cmds_pg.Refresh()
def draw_state_commands(self, obj): self.cmds_pg.Clear() if obj is None: self.Disable() return else: self.Enable() # Get the commands inspector = pynebula.new("nobjinspector", "/editor/inspector") inspector.initcmdsstate(obj) # Navigate over the commands and build the interface. We need # the command definition to put it in the category. So first create # the grid properties but do not append them until the category # is placed with the full description. cmds_count = inspector.getcmdscount() self.cmd_list = list() # Command list self.cmd_name_list = list() # Store the categories self.undo_list = list() if cmds_count == 0: self.cmds_pg.Append( pg.wxPropertyCategory(str("State is EMPTY"), str("nostate"))) self.prev_state = list() # Storage state when the inspector is call for num_cmd in xrange(cmds_count): cmds_name_desc = inspector.getcmdname(num_cmd) + str(" (") undo_cmd = inspector.getcmdname(num_cmd) + str("(") args_count = inspector.getinargscount(num_cmd) self.element = list() # Start argument list for num_arg in xrange(args_count): label = "label_in" + str(num_cmd) + "-" + str(num_arg + 1) arg_type = inspector.gettype(num_cmd, num_arg + 1) # Type is Int if arg_type == 1: value = inspector.geti(num_cmd, num_arg + 1) self.element.append(pg.wxIntProperty('Integer', label)) value_as_string = str(value) self.element[num_arg].SetValueFromString( value_as_string, 0) self.prev_state.append(value_as_string) cmds_name_desc = cmds_name_desc + value_as_string + ", " undo_cmd = undo_cmd + value_as_string + "," # Type is Float elif arg_type == 2: value = inspector.getf(num_cmd, num_arg + 1) self.element.append(pg.wxFloatProperty('Float', label)) value_as_string = str(value) self.element[num_arg].SetValueFromString( value_as_string, 0) self.prev_state.append(value_as_string) undo_cmd = undo_cmd + value_as_string + "," temp = value_as_string.rsplit('.') value = temp[0] + '.' + temp[1][:2] cmds_name_desc = cmds_name_desc + value_as_string + ", " # Type if String elif arg_type == 3: value = inspector.gets(num_cmd, num_arg + 1) self.element.append( pg.wxStringProperty('String', label, '')) value_as_string = str(value) self.element[num_arg].SetValueFromString( value_as_string, 0) self.prev_state.append(value_as_string) cmds_name_desc = cmds_name_desc +\ '"' + value_as_string + '"' + ", " undo_cmd = undo_cmd + '"' + value_as_string + '"' + "," # Type is Boolean elif arg_type == 4: value = inspector.getb(num_cmd, num_arg + 1) self.element.append( pg.wxEnumProperty('Boolean', label, ['True', 'False'], [1, 0], 2)) if value == 1: self.element[num_arg].SetValueFromString( str("True"), 0) cmds_name_desc = cmds_name_desc + str('True') + ", " self.prev_state.append('True') else: self.element[num_arg].SetValueFromString( str("False"), 0) cmds_name_desc = cmds_name_desc + str('False') + ", " self.prev_state.append('False') undo_cmd = undo_cmd + str(value) + "," # Type is Object elif arg_type == 5: value = inspector.geto(num_cmd, num_arg + 1) self.element.append( pg.wxStringProperty('Object', label, '')) full_name_as_string = str(value.getfullname()) self.element[num_arg].SetValueFromString( full_name_as_string, 0) self.prev_state.append(full_name_as_string) cmds_name_desc = cmds_name_desc +\ str(value.getname()) + ", " undo_cmd = undo_cmd + "lookup(" + \ full_name_as_string + ")," # Type not implemented else: cjr.show_error_message("Unknown type!!!") # Write the command definition into the category and attach it if args_count > 0: cmds_name_desc = cmds_name_desc[:-2] + ")" undo_cmd = undo_cmd[:-1] + ")" else: cmds_name_desc = cmds_name_desc + ")" undo_cmd = undo_cmd + ")" category = pg.wxPropertyCategory(cmds_name_desc, "cmdLabel%d" % num_cmd) self.cmds_pg.Append(category) self.cmd_name_list.append(inspector.getcmdprotoname(num_cmd)) # Show the arguments (append to grid) recently created # and append them to a command list for num_arg in xrange(args_count): self.cmds_pg.Append(self.element[num_arg]) self.cmd_list.append(self.element) self.undo_list.append(undo_cmd) pynebula.delete("/editor/inspector") # Make de object the current nebulagui.nebula_object = obj self.object = obj # Refresh control self.cmds_pg.Refresh()