コード例 #1
0
 def on_duplicate(self, event):
     """Ask for a name and clone the selected object it if it's a non existing name"""
     source_name = self.list.GetStringSelection()
     if source_name != "":
         dlg = wx.TextEntryDialog(
             None,
             "Enter the " + self.caption + "'s name:",
             "Duplicate " + self.caption,
             source_name
             )
         if dlg.ShowModal() == wx.ID_OK:
             # Clone the object only if there isn't another object with the same name yet
             target_name = dlg.GetValue()
             target_path = format.append_to_path( self.lib_path, target_name )
             try:
                 # Lookup will fail if it's a new name (name not found)
                 pynebula.lookup( target_path )
                 msg = "Another " + self.caption + " named '" + dlg.GetValue() + "' already exists."
                 cjr.show_error_message(msg)
             except:
                 # Clone object, save it to disk and add it to list
                 source_path = format.append_to_path( self.lib_path, source_name )
                 source_obj = pynebula.lookup( source_path )
                 target_obj = source_obj.clone( str(target_path) ) 
                 self.save_object( target_obj )
                 self.list.Append( target_name )
         dlg.Destroy()
コード例 #2
0
def save_preset(preset_path):
    # Create preset path if it doesn't exist
    if not os.path.exists(preset_path):
        os.makedirs(preset_path)
    # Save stdlight
    entity_id = app.get_level().findentity('stdlight')
    if entity_id == 0:
        cjr.show_error_message("'stdlight' not found")
    else:
        entity = servers.get_entity_object_server().getentityobject(entity_id)
        entity.savestateas(
            str(format.append_to_path(preset_path, "stdlight.n2")))
    # Save viewport ui
    viewport_ui = app.get_viewports_dir()
    viewport_ui.savestateas(
        str(format.append_to_path(preset_path, "viewportui.n2")))
    # Save viewports
    for index in range(4):
        viewport_name = "viewport%s.n2" % index
        viewport_path = format.append_to_path(preset_path, viewport_name)
        viewport = pynebula.lookup(
            format.append_to_path(app.get_viewports_dir().getfullname(),
                                  viewport_name[:-3]))
        viewport.savestateas(str(viewport_path))
    # Save special viewport rnsview
    viewport_path = format.append_to_path(preset_path, "rnsview.n2")
    viewport = pynebula.lookup('/usr/rnsview')
    viewport.savestateas(str(viewport_path))
    # Save camera bookmarks
    bookmark_path = format.append_to_path(preset_path, "bookmarks.n2")
    servers.get_conjurer().savebookmarks(bookmark_path)
    # Save mouse settings (sensitivity, invert y-axis, etc)
    mouse_setting_path = format.append_to_path(preset_path, "mousesettings.n2")
    game_state = app.get_state("game")
    game_state.savemousesettings(str(mouse_setting_path))
コード例 #3
0
def get_free_event_conditions(state, allowed_condition=None):
    """
    Return a paths list of those event conditions which the given state doesn't
    already have a transition for.
    
    \param state State (path) to gather the free event conditions for
    \param allowed_condition Condition (path) allowed as a free condition, even if it's already taken
    \return List of event conditions paths not found in any transition of the given state
    """
    allowed_event = None
    if allowed_condition != None:
        cond = pynebula.lookup( allowed_condition )
        if cond.isa('neventcondition'):
            allowed_event = cond.getevent()
    conds_paths = fsm.get_event_conditions()
##    conds_paths = []
##    cond = pynebula.lookup( fsm.get_event_conditions_lib() ).gethead()
##    while cond is not None:
##        if cond.getname().startswith( "event" ):
##            conds_paths.append( cond.getfullname() )
##        cond = cond.getsucc()
    trans_paths = fsm.get_transitions( state )
    for trans_path in trans_paths:
        trans_obj = pynebula.lookup( trans_path )
        cond_obj = trans_obj.getcondition()
        if cond_obj.isa('neventcondition'):
            if cond_obj.getevent() != allowed_event:
                cond_path = get_event_condition( cond_obj.getevent() )
##                if cond_path == fsm.get_filteredcondition_of_transition( trans_path ):
##                    conds_paths.remove( get_event_condition( cond_obj.getevent() ) )
##                else:
                conds_paths.remove( cond_path )
    return conds_paths
コード例 #4
0
 def __on_change_type(self, event):
     if self.transition_path != None and not self.skip_change_type_event:
         # Remove transition from state
         transition = self.__get_transition()
         state = self.__get_state()
         state.removetransition( transition )
         # Get free conditions for the selected transition type
         state_path = fsm.get_state_of_transition( self.transition_path )
         conds_paths = get_free_conditions( event.GetSelection(), state_path )
         # Delete condition if it's an event condition with filter
         cond_path = fsm.get_filteredcondition_of_transition( self.transition_path )
         try:
             pynebula.lookup( cond_path )
             pynebula.delete( cond_path )
         except:
             pass
         # Set first free condition for the selected transition type
         transition.setcondition( pynebula.lookup(conds_paths[0]) )
         # Add transition to state
         state.addtransition( transition )
         # Refresh condition parameters panel
         if self.GetSelection() == 0:
             self.panel_event.set_transition( self.transition_path )
         else:
             self.panel_script.set_transition( self.transition_path )
         # Signal change
         fsmevents.signal_fsm_change( self, self.transition_path )
コード例 #5
0
 def __on_change_type(self, event):
     if self.transition_path != None and not self.skip_change_type_event:
         # Remove transition from state
         transition = self.__get_transition()
         state = self.__get_state()
         state.removetransition(transition)
         # Get free conditions for the selected transition type
         state_path = fsm.get_state_of_transition(self.transition_path)
         conds_paths = get_free_conditions(event.GetSelection(), state_path)
         # Delete condition if it's an event condition with filter
         cond_path = fsm.get_filteredcondition_of_transition(
             self.transition_path)
         try:
             pynebula.lookup(cond_path)
             pynebula.delete(cond_path)
         except:
             pass
         # Set first free condition for the selected transition type
         transition.setcondition(pynebula.lookup(conds_paths[0]))
         # Add transition to state
         state.addtransition(transition)
         # Refresh condition parameters panel
         if self.GetSelection() == 0:
             self.panel_event.set_transition(self.transition_path)
         else:
             self.panel_script.set_transition(self.transition_path)
         # Signal change
         fsmevents.signal_fsm_change(self, self.transition_path)
コード例 #6
0
def get_free_event_conditions(state, allowed_condition=None):
    """
    Return a paths list of those event conditions which the given state doesn't
    already have a transition for.
    
    \param state State (path) to gather the free event conditions for
    \param allowed_condition Condition (path) allowed as a free condition, even if it's already taken
    \return List of event conditions paths not found in any transition of the given state
    """
    allowed_event = None
    if allowed_condition != None:
        cond = pynebula.lookup(allowed_condition)
        if cond.isa('neventcondition'):
            allowed_event = cond.getevent()
    conds_paths = fsm.get_event_conditions()
    ##    conds_paths = []
    ##    cond = pynebula.lookup( fsm.get_event_conditions_lib() ).gethead()
    ##    while cond is not None:
    ##        if cond.getname().startswith( "event" ):
    ##            conds_paths.append( cond.getfullname() )
    ##        cond = cond.getsucc()
    trans_paths = fsm.get_transitions(state)
    for trans_path in trans_paths:
        trans_obj = pynebula.lookup(trans_path)
        cond_obj = trans_obj.getcondition()
        if cond_obj.isa('neventcondition'):
            if cond_obj.getevent() != allowed_event:
                cond_path = get_event_condition(cond_obj.getevent())
                ##                if cond_path == fsm.get_filteredcondition_of_transition( trans_path ):
                ##                    conds_paths.remove( get_event_condition( cond_obj.getevent() ) )
                ##                else:
                conds_paths.remove(cond_path)
    return conds_paths
コード例 #7
0
ファイル: shdctrls.py プロジェクト: Teivaz/nebula2
 def __init__(self, parent, infoPanel, shdPanel):
     wx.Panel.__init__(self, parent, size = (800, 600))
     nebula.lookup('/sys/env/parent_hwnd').seti(self.GetHandle())
     self.infoPanel = infoPanel
     self.shdPanel = shdPanel
     self.infoPopup = None
     self.waiting = False
コード例 #8
0
 def __on_delete_state(self, event):
     """Ask to confirm the state deletion and delete it if so"""
     state_name = self.list_states.GetStringSelection()
     if state_name != "":
         msg = "Deleting a state cannot be undone.\n"
         msg = msg + "Are you sure that you want to delete the "
         msg = msg + "'" + state_name + "' state?"
         result = cjr.warn_yes_no(self, msg)
         if result == wx.ID_YES:
             # Delete all transition targets pointing to the state to be deleted
             state = self.__get_current_state()
             fsm_ = fsm.get_fsm_of_state( state.getfullname() )
             states = fsm.get_states( fsm_ )
             for s in states:
                 transitions = fsm.get_transitions(s)
                 for t in transitions:
                     t_obj = pynebula.lookup(t)
                     t_obj.removetarget(state)
                     # Delete the transition if it's emmpty after deleting the target
                     if t_obj.gettargetsnumber() == 0:
                         s_obj = pynebula.lookup(s)
                         s_obj.deletetransition(t_obj)
                         t_obj = None
             
             # Delete the state
             self.__get_fsm().deletestate( state )
             state = None
             self.list_states.Delete( self.list_states.GetSelection() )
             self.__on_select_state(None)
             fsmevents.signal_fsm_change(self)
コード例 #9
0
 def __init__(self, parent, infoPanel, shdPanel):
     wx.Panel.__init__(self, parent, size=(800, 600))
     nebula.lookup('/sys/env/parent_hwnd').seti(self.GetHandle())
     self.infoPanel = infoPanel
     self.shdPanel = shdPanel
     self.infoPopup = None
     self.waiting = False
コード例 #10
0
 def __on_select_script(self, event):
     transition = pynebula.lookup(self.transition_path)
     state_path = fsm.get_state_of_transition(self.transition_path)
     state = pynebula.lookup(state_path)
     state.removetransition(transition)
     condition = servers.get_fsm_server().getscriptcondition(
         str(self.choice_script.GetStringSelection()))
     transition.setcondition(condition)
     state.addtransition(transition)
     fsmevents.signal_fsm_change(self, self.transition_path)
コード例 #11
0
 def __on_select_script(self, event):
     transition = pynebula.lookup( self.transition_path )
     state_path = fsm.get_state_of_transition( self.transition_path )
     state = pynebula.lookup( state_path )
     state.removetransition( transition )
     condition = servers.get_fsm_server().getscriptcondition(
         str(self.choice_script.GetStringSelection()) )
     transition.setcondition( condition )
     state.addtransition( transition )
     fsmevents.signal_fsm_change( self, self.transition_path )
コード例 #12
0
    def __on_change_type(self, event):
        if self.state_path != None and not self.skip_change_type_event:
            # Rename the old state to keep it while building the new one
            old_state = self.__get_state()
            old_state.setname('_tmp')

            # Create new state for the new state type
            if self.GetSelection() == self.ID_NodeStatePanel:
                new_state = create_default_state(self.state_path, 'nnodestate')
            elif self.GetSelection() == self.ID_LeafStatePanel:
                new_state = create_default_state(self.state_path, 'nleafstate')
            else:
                new_state = create_default_state(self.state_path, 'nendstate')
            if new_state == None:
                # If creating a default state fails abort and restore old state
                old_state.setname(str(format.get_name(self.state_path)))
                self.skip_change_type_event = True
                self.SetSelection(event.GetOldSelection())
                self.skip_change_type_event = False
                return
            fsm_ = self.__get_fsm()
            fsm_.addstate(new_state)

            # Copy info that's independent of the state type
            old_trans_path = fsm.get_transitions_dir_of_state(
                old_state.getfullname())
            new_trans_path = fsm.get_transitions_dir_of_state(
                new_state.getfullname(), False)
            pynebula.lookup(str(old_trans_path)).clone(str(new_trans_path))
            transitions = fsm.get_transitions(new_state.getfullname())
            for t in transitions:
                t_obj = pynebula.lookup(t)
                new_state.addtransition(t_obj)
            if fsm_.getinitialstate() == old_state:
                fsm_.setinitialstate(new_state)

            # Update all transitions to point to the new state if pointing the old one
            states = fsm.get_states(fsm_.getfullname())
            for s in states:
                transitions = fsm.get_transitions(s)
                for t in transitions:
                    t_obj = pynebula.lookup(t)
                    for i in range(t_obj.gettargetsnumber()):
                        if t_obj.gettargetstatebyindex(i) == old_state:
                            t_obj.settargetstatebyindex(i, new_state)

            # Delete old state
            fsm_.deletestate(old_state)
            old_state = None  # Python, release that #$%&/)?! reference NOW!

            # Update type specific controls
            self.__update_controls()

            # Signal change
            fsmevents.signal_fsm_change(self, self.state_path)
コード例 #13
0
    def __on_change_type(self, event):
        if self.state_path != None and not self.skip_change_type_event:
            # Rename the old state to keep it while building the new one
            old_state = self.__get_state()
            old_state.setname("_tmp")

            # Create new state for the new state type
            if self.GetSelection() == self.ID_NodeStatePanel:
                new_state = create_default_state(self.state_path, "nnodestate")
            elif self.GetSelection() == self.ID_LeafStatePanel:
                new_state = create_default_state(self.state_path, "nleafstate")
            else:
                new_state = create_default_state(self.state_path, "nendstate")
            if new_state == None:
                # If creating a default state fails abort and restore old state
                old_state.setname(str(format.get_name(self.state_path)))
                self.skip_change_type_event = True
                self.SetSelection(event.GetOldSelection())
                self.skip_change_type_event = False
                return
            fsm_ = self.__get_fsm()
            fsm_.addstate(new_state)

            # Copy info that's independent of the state type
            old_trans_path = fsm.get_transitions_dir_of_state(old_state.getfullname())
            new_trans_path = fsm.get_transitions_dir_of_state(new_state.getfullname(), False)
            pynebula.lookup(str(old_trans_path)).clone(str(new_trans_path))
            transitions = fsm.get_transitions(new_state.getfullname())
            for t in transitions:
                t_obj = pynebula.lookup(t)
                new_state.addtransition(t_obj)
            if fsm_.getinitialstate() == old_state:
                fsm_.setinitialstate(new_state)

            # Update all transitions to point to the new state if pointing the old one
            states = fsm.get_states(fsm_.getfullname())
            for s in states:
                transitions = fsm.get_transitions(s)
                for t in transitions:
                    t_obj = pynebula.lookup(t)
                    for i in range(t_obj.gettargetsnumber()):
                        if t_obj.gettargetstatebyindex(i) == old_state:
                            t_obj.settargetstatebyindex(i, new_state)

            # Delete old state
            fsm_.deletestate(old_state)
            old_state = None  # Python, release that #$%&/)?! reference NOW!

            # Update type specific controls
            self.__update_controls()

            # Signal change
            fsmevents.signal_fsm_change(self, self.state_path)
コード例 #14
0
ファイル: fsmaction.py プロジェクト: xuebai5/TheZombieEngine
    def on_change_type(self, event):
        # replace old action with a new one for the new action type
        if self.action_path != None and not self.skip_change_type_event:
            state_path = fsm.get_state_of_behaction( self.action_path )
            state = pynebula.lookup( state_path )
            action = pynebula.lookup( str(self.action_path) )
##            action_panel = self.GetPage( event.GetSelection() )
##            action.setactiontype( action_panel.action_id )
##            action_panel.update_action( action )
            action.setactionclass( str( self.choice.GetStringSelection() ) )
            self.__update_propgrid()
            fsmevents.signal_fsm_change( self )
コード例 #15
0
def validate_fsm_name(name):
    path = format.append_to_path(fsm.get_fsms_lib(), name)
    try:
        # Lookup will fail if it's a new name (name not found)
        pynebula.lookup(path)
        msg = "Another finite state machine called '%s' already exists." % name
        cjr.show_error_message(msg)
        return False
    except:
        msg = "Renaming this FSM will invalidate any references to it that " \
            "any agent has.\nAre you sure that you want to rename it?"
        result = cjr.confirm_yes_no(None, msg)
        return result == wx.ID_YES
コード例 #16
0
def validate_fsm_name(name):
    path = format.append_to_path( fsm.get_fsms_lib(), name )
    try:
        # Lookup will fail if it's a new name (name not found)
        pynebula.lookup( path )
        msg = "Another finite state machine called '%s' already exists." % name
        cjr.show_error_message(msg)
        return False
    except:
        msg = "Renaming this FSM will invalidate any references to it that " \
            "any agent has.\nAre you sure that you want to rename it?"
        result = cjr.confirm_yes_no(None, msg)
        return result == wx.ID_YES
コード例 #17
0
ファイル: fsm.py プロジェクト: xuebai5/TheZombieEngine
def get_free_name(dir_path, prefix):
    """
    Get a free name for an object to be placed in the given path and begining with the given prefix.
    
    Names are got by appending an index to the prefix.
    """
    i = 0
    while True:
        obj_path = get_path( dir_path, prefix, str(i) )
        try:
            pynebula.lookup( obj_path )
            i = i + 1
        except:
            return obj_path
コード例 #18
0
ファイル: objdlg.py プロジェクト: xuebai5/TheZombieEngine
    def __get_object(self):
        """
        Return a reference to the object for my object id.

        If no object is found None will be returned.
        For objects in NOH use absolute paths as their object id, 
        for entities use the id given by the entity server.
        """
        if self.object_id is None:
            return None
        if isinstance(self.object_id, int):
            # integer -> nEntity -> Get object from entity server
            return self.__get_entity_object_with_id(
                self.object_id 
                )
        elif self.object_id.startswith('/'):
            # NOH path -> nRoot -> Get object from NOH
            try:
                return pynebula.lookup( self.object_id )
            except:
                return None
        else:
            # name -> nEntity -> Get object from entity server
            entity_id = app.get_level().findentity( self.object_id )
            if entity_id == 0:
                return None
            else:
                return self.__get_entity_object_with_id(
                    entity_id
                    )
コード例 #19
0
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
コード例 #20
0
ファイル: trn.py プロジェクト: xuebai5/TheZombieEngine
def get_layer_manager():
    try:
        return pynebula.lookup(
            '/usr/terrain/geomipmap/layermanager'
            )
    except:
        return None
コード例 #21
0
ファイル: fsm.py プロジェクト: xuebai5/TheZombieEngine
def __copy(source_dir, target_dir):
    """Copy all objects from a directory to another directory (not recursive)"""
    obj = pynebula.lookup( source_dir ).gethead()
    while obj != None:
        path = format.append_to_path( target_dir, obj.getname() )
        obj.clone( path )
        obj = obj.getsucc()
コード例 #22
0
ファイル: particle.py プロジェクト: xuebai5/TheZombieEngine
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
コード例 #23
0
ファイル: triggerlib.py プロジェクト: xuebai5/TheZombieEngine
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
コード例 #24
0
def get_event_condition(event):
    cond = pynebula.lookup( fsm.get_event_conditions_lib() ).gethead()
    while cond is not None:
        if cond.getevent() == event:
            return cond.getfullname()
        cond = cond.getsucc()
    raise "Error: shared event " + str(event) + " not found"
コード例 #25
0
def get_event_condition(event):
    cond = pynebula.lookup(fsm.get_event_conditions_lib()).gethead()
    while cond is not None:
        if cond.getevent() == event:
            return cond.getfullname()
        cond = cond.getsucc()
    raise "Error: shared event " + str(event) + " not found"
コード例 #26
0
    def onterrainhole(self):
        # Set label names
        self.__init_labels(self.ID_TerrainHole,
                           ["Start:", "End:", "Distance:"])

        # Set new info values
        tool = pynebula.lookup(self.tool_paths[self.ID_TerrainHole])
        self.__set_common_values(tool)
コード例 #27
0
 def __bind_signal(self, tool_id, signal_name, receiver_method):
     try:
         tool = pynebula.lookup(self.tool_paths[tool_id])
     except:
         cjr.show_error_message("Tool '" + self.tool_paths[tool_id] +
                                "' not found")
     else:
         pynebula.pyBindSignal(tool, signal_name, self, receiver_method, 0)
コード例 #28
0
 def __unbind_signal(self, tool_id, signal_name):
     try:
         tool = pynebula.lookup(self.tool_paths[tool_id])
     except:
         cjr.show_error_message("Tool '" + self.tool_paths[tool_id] +
                                "' not found")
     else:
         pynebula.pyUnbindTargetObject(tool, signal_name, self)
コード例 #29
0
ファイル: fsm.py プロジェクト: xuebai5/TheZombieEngine
def get_fsms():
    """Return a sequence with all the FSM paths"""
    paths = []
    fsm = pynebula.lookup( get_fsms_lib() ).gethead()
    while fsm != None:
        paths.append( fsm.getfullname() )
        fsm = fsm.getsucc()
    return paths
コード例 #30
0
ファイル: infodlg.py プロジェクト: xuebai5/TheZombieEngine
 def onterrainhole(self):
     # Set label names
     self.__init_labels( self.ID_TerrainHole,
         ["Start:", "End:", "Distance:"] )
     
     # Set new info values
     tool = pynebula.lookup( self.tool_paths[self.ID_TerrainHole] )
     self.__set_common_values( tool )
コード例 #31
0
def get_condition_gui_name(condition_path):
    condition = pynebula.lookup(condition_path)
##    shared_event_prefix = format.append_to_path( fsm.get_event_conditions_lib(), "event" )
##    if condition_path.startswith( shared_event_prefix ):
    if condition.isa('neventcondition'):
        return servers.get_trigger_server().geteventlabel( condition.getevent() )
    else:
        return condition.getname()
コード例 #32
0
ファイル: fsm.py プロジェクト: xuebai5/TheZombieEngine
def find_path(dir_path, target_gui_name, gui_name_generator):
    """Find and return the object's path that matches the given gui name"""
    obj = pynebula.lookup( dir_path ).gethead()
    while obj != None:
        if target_gui_name == gui_name_generator( obj.getfullname() ):
            return obj.getfullname()
        obj = obj.getsucc()
    return None
コード例 #33
0
    def onscaleobject(self):
        # Set label names
        self.__init_labels(toolscmds.ID_ScaleObjTool, ["Scale:"])

        # Set new info values
        tool = pynebula.lookup(self.tool_paths[toolscmds.ID_ScaleObjTool])
        scale = tool.getcurrentscaling()
        self.label_values[0].SetLabel(str(round(scale, self.decimals)))
コード例 #34
0
    def onrotateobject(self):
        # Set label names
        self.__init_labels(toolscmds.ID_RotateObjTool, ["Angle:"])

        # Set new info values
        tool = pynebula.lookup(self.tool_paths[toolscmds.ID_RotateObjTool])
        angle = tool.getcurrentrotangle()
        self.label_values[0].SetLabel(str(round(angle, self.decimals)))
コード例 #35
0
    def ontranslateobject(self):
        # Set label names
        self.__init_labels(toolscmds.ID_TranslateObjTool,
                           ["Start:", "End:", "Distance:"])

        # Set new info values
        tool = pynebula.lookup(self.tool_paths[toolscmds.ID_TranslateObjTool])
        self.__set_common_values(tool)
コード例 #36
0
 def on_button1(self, event):
     if self.modal == True:
         self.parent.Hide()
         self.parent.EndModal(wx.ID_OK)
     else:
         obj = pynebula.lookup(self.parent.GetTitle())
         win = objdlg.create_window(self.parent.parent, obj.getfullname())
         win.display()
コード例 #37
0
ファイル: fsm.py プロジェクト: xuebai5/TheZombieEngine
def get_states(fsm_path):
    """Return a sequence with all the states paths of the given fsm"""
    paths = []
    state = pynebula.lookup( fsm_path ).gethead()
    while state != None:
        paths.append( state.getfullname() )
        state = state.getsucc()
    return paths
コード例 #38
0
ファイル: levelcmds.py プロジェクト: xuebai5/TheZombieEngine
def save_preset(preset_path):
    # Create preset path if it doesn't exist
    if not os.path.exists( preset_path ):
        os.makedirs( preset_path )
    # Save stdlight
    entity_id = app.get_level().findentity('stdlight')
    if entity_id == 0:
        cjr.show_error_message("'stdlight' not found")
    else:
        entity = servers.get_entity_object_server().getentityobject( entity_id )
        entity.savestateas(
            str( format.append_to_path(preset_path, "stdlight.n2") ) 
            )
    # Save viewport ui
    viewport_ui = app.get_viewports_dir()
    viewport_ui.savestateas(
        str( format.append_to_path(preset_path, "viewportui.n2") ) 
        )
    # Save viewports
    for index in range(4):
        viewport_name = "viewport%s.n2" % index
        viewport_path = format.append_to_path( preset_path, viewport_name )
        viewport = pynebula.lookup(
                            format.append_to_path(
                                app.get_viewports_dir().getfullname(), 
                                viewport_name[:-3]
                                )
                            )
        viewport.savestateas( str(viewport_path) )
    # Save special viewport rnsview
    viewport_path = format.append_to_path( preset_path, "rnsview.n2" )
    viewport = pynebula.lookup( '/usr/rnsview' )
    viewport.savestateas( str(viewport_path) )
    # Save camera bookmarks
    bookmark_path = format.append_to_path(
                                preset_path, 
                                "bookmarks.n2" 
                                )
    servers.get_conjurer().savebookmarks( bookmark_path )
    # Save mouse settings (sensitivity, invert y-axis, etc)
    mouse_setting_path = format.append_to_path(
                                    preset_path, 
                                    "mousesettings.n2" 
                                    )
    game_state = app.get_state( "game" )
    game_state.savemousesettings( str(mouse_setting_path) )
コード例 #39
0
 def on_button1(self, event):
     if self.modal == True:
         self.parent.Hide()
         self.parent.EndModal(wx.ID_OK)
     else:
         obj = pynebula.lookup(self.parent.GetTitle())
         win = objdlg.create_window(self.parent.parent, obj.getfullname())
         win.display()
コード例 #40
0
ファイル: infodlg.py プロジェクト: xuebai5/TheZombieEngine
 def ontranslateobject(self):
     # Set label names
     self.__init_labels( toolscmds.ID_TranslateObjTool,
         ["Start:", "End:", "Distance:"] )
     
     # Set new info values
     tool = pynebula.lookup( self.tool_paths[toolscmds.ID_TranslateObjTool] )
     self.__set_common_values(tool)
コード例 #41
0
 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()
コード例 #42
0
def get_condition_gui_name(condition_path):
    condition = pynebula.lookup(condition_path)
    ##    shared_event_prefix = format.append_to_path( fsm.get_event_conditions_lib(), "event" )
    ##    if condition_path.startswith( shared_event_prefix ):
    if condition.isa('neventcondition'):
        return servers.get_trigger_server().geteventlabel(condition.getevent())
    else:
        return condition.getname()
コード例 #43
0
ファイル: fsm.py プロジェクト: xuebai5/TheZombieEngine
def get_transitions(state_path):
    """Return a sequence with all the transition paths of the given state"""
    paths = []
    transitions_path = get_transitions_dir_of_state( state_path )
    transition = pynebula.lookup( transitions_path ).gethead()
    while transition != None:
        paths.append( transition.getfullname() )
        transition = transition.getsucc()
    return paths
コード例 #44
0
ファイル: infodlg.py プロジェクト: xuebai5/TheZombieEngine
 def __unbind_signal(self, tool_id, signal_name):
     try:
         tool = pynebula.lookup( self.tool_paths[tool_id] )
     except:
         cjr.show_error_message(
             "Tool '" + self.tool_paths[tool_id] + "' not found"
             )
     else:
         pynebula.pyUnbindTargetObject(tool, signal_name, self)
コード例 #45
0
ファイル: fsm.py プロジェクト: xuebai5/TheZombieEngine
def get_event_conditions():
    """Return a sequence with all the event conditions paths"""
    paths = []
    conds_path = get_event_conditions_lib()
    cond = pynebula.lookup( conds_path ).gethead()
    while cond != None:
        paths.append( cond.getfullname() )
        cond = cond.getsucc()
    return paths
コード例 #46
0
ファイル: infodlg.py プロジェクト: xuebai5/TheZombieEngine
 def onscaleobject(self):
     # Set label names
     self.__init_labels( toolscmds.ID_ScaleObjTool,
         ["Scale:"] )
     
     # Set new info values
     tool = pynebula.lookup( self.tool_paths[toolscmds.ID_ScaleObjTool] )
     scale = tool.getcurrentscaling()
     self.label_values[0].SetLabel( str( round(scale, self.decimals) ) )
コード例 #47
0
ファイル: infodlg.py プロジェクト: xuebai5/TheZombieEngine
 def onrotateobject(self):
     # Set label names
     self.__init_labels( toolscmds.ID_RotateObjTool,
         ["Angle:"] )
     
     # Set new info values
     tool = pynebula.lookup( self.tool_paths[toolscmds.ID_RotateObjTool] )
     angle = tool.getcurrentrotangle()
     self.label_values[0].SetLabel( str( round(angle, self.decimals) ) )
コード例 #48
0
ファイル: fsmtargets.py プロジェクト: xuebai5/TheZombieEngine
 def __on_change_state(self, event):
     state_path = fsm.find_path(
         fsm.get_fsm_of_transition(self.transition_path),
         self.choice_state.GetStringSelection(),
         fsmstates.get_state_gui_name)
     if self.__get_transition().gettargetstatebyindex(
             self.target_index).getfullname() != state_path:
         self.__get_transition().settargetstatebyindex(
             self.target_index, pynebula.lookup(state_path))
         fsmevents.signal_fsm_change(self, self.target_index)