Beispiel #1
0
 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()
Beispiel #2
0
 def on_new_level(self, event):
     """Create a new level replacing the old one, if user confirms"""
     # Ask for the level's name
     dlg = filedlg.FileDialog(
                 self.get_frame(), 
                 filedlg.NEW,
                 'level', 
                 'Level', 
                 "wc:levels", 
                 ["n2"]
                 )
     if dlg.ShowModal() == wx.ID_OK:
         # Check that's a new filename
         if dlg.file_exists():
             msg = "There is already a level called '%s'.\n\n" \
                         "Please enter a new level name." % dlg.get_guiname()
             cjr.show_error_message(msg)
         else:
             # Ask for final confirmation
             msg = "Any previous unsaved level data will be lost.\n\n" \
                     "Are you sure you want to create the new level '%s'?"\
                     % dlg.get_guiname()
             result = cjr.warn_yes_no(
                             self.get_frame(), 
                             msg
                             )
             if result == wx.ID_YES:
                 # Finally create the new level
                 if prelevel_process(True):
                     servers.get_conjurer().newlevel(
                         dlg.get_path_as_string()
                         )
                     postlevel_process(True)
     dlg.Destroy()
Beispiel #3
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))
Beispiel #4
0
    def on_delete_level(self, event):
        """Show a file browser and delete the selected level"""
        # Ask for the level's name
        current_level_name = get_name_of_current_level()
        dlg = filedlg.FileDialog(
                    self.get_frame(), 
                    filedlg.DELETE,
                    'level', 
                    'Level', 
                    "wc:levels", 
                    ["n2"],
                    excluded_files=['default.n2', '%s.n2' % current_level_name]
                    )
        result_ok = dlg.ShowModal() == wx.ID_OK
        level_name = dlg.get_guiname()
        level_path = dlg.get_path_as_string()
        dlg.Destroy()
        if not result_ok:
            return

        # Ask for confirmation
        msg = "All your hard work is going to be removed, deleted, " \
            "cleared, lost forever (ok, you can still revert\n" \
            "your working copy, but your local level is going to be " \
            "erased for sure).\n\nSo, are you sure that you want to " \
            "delete the '%s' level?" % level_name
        result = cjr.warn_yes_no(
                    self.get_frame(), 
                    msg
                    )
        if result != wx.ID_YES:
            return

        # Ask for final confirmation
        msg = "If you have clicked OK because of a tick in your finger, this " \
            "is your last chance to avoid throwing away the whole level.\n\n" \
            "Again, and for last time, are you ABSOLUTELY sure that you " \
            "want to delete the '%s' level?" % level_name
        result = cjr.warn_yes_no(
                        self.get_frame(), 
                        msg
                        )
        if result != wx.ID_YES:
            return

        # Finally delete the level (and the presets configuration)
        try:
            try:
                dlg = waitdlg.WaitDialog(
                            self.get_frame(),
                            "Deleting level %s..." % level_name
                            )
                unassign_preset( level_name )
                servers.get_conjurer().deletelevel(level_path)
            finally:
                dlg.Destroy()
        except:
            # make sure any errors are not hidden
            raise
Beispiel #5
0
    def on_delete_level(self, event):
        """Show a file browser and delete the selected level"""
        # Ask for the level's name
        current_level_name = get_name_of_current_level()
        dlg = filedlg.FileDialog(
            self.get_frame(),
            filedlg.DELETE,
            'level',
            'Level',
            "wc:levels", ["n2"],
            excluded_files=['default.n2',
                            '%s.n2' % current_level_name])
        result_ok = dlg.ShowModal() == wx.ID_OK
        level_name = dlg.get_guiname()
        level_path = dlg.get_path_as_string()
        dlg.Destroy()
        if not result_ok:
            return

        # Ask for confirmation
        msg = "All your hard work is going to be removed, deleted, " \
            "cleared, lost forever (ok, you can still revert\n" \
            "your working copy, but your local level is going to be " \
            "erased for sure).\n\nSo, are you sure that you want to " \
            "delete the '%s' level?" % level_name
        result = cjr.warn_yes_no(self.get_frame(), msg)
        if result != wx.ID_YES:
            return

        # Ask for final confirmation
        msg = "If you have clicked OK because of a tick in your finger, this " \
            "is your last chance to avoid throwing away the whole level.\n\n" \
            "Again, and for last time, are you ABSOLUTELY sure that you " \
            "want to delete the '%s' level?" % level_name
        result = cjr.warn_yes_no(self.get_frame(), msg)
        if result != wx.ID_YES:
            return

        # Finally delete the level (and the presets configuration)
        try:
            try:
                dlg = waitdlg.WaitDialog(self.get_frame(),
                                         "Deleting level %s..." % level_name)
                unassign_preset(level_name)
                servers.get_conjurer().deletelevel(level_path)
            finally:
                dlg.Destroy()
        except:
            # make sure any errors are not hidden
            raise
Beispiel #6
0
 def on_save_level_as(self, event):
     """ Save the current level under a new name. """
     # Ask for a name for the new level
     dlg = filedlg.FileDialog(self.get_frame(), filedlg.SAVE, 'level',
                              'Level', "wc:levels", ["n2"])
     if dlg.ShowModal() == wx.ID_OK:
         new_level_name = dlg.get_guiname()
         # Check the name hasn't already been taken
         if dlg.file_exists():
             msg = "There is already a level called '%s'.\n\n" \
                         "Please enter a new level name." % new_level_name
             cjr.show_error_message(msg)
         else:
             try:
                 try:
                     new_level_path = dlg.get_path_as_string()
                     dlg2 = waitdlg.WaitDialog(
                         self.get_frame(),
                         "Saving level as '%s'..." % new_level_name)
                     save_ok = servers.get_conjurer().savecurrentlevelas(
                         new_level_path)
                     if save_ok:
                         self.refresh()
                     else:
                         cjr.show_error_message(
                             "Unable to save level as '%s'." %
                             new_level_name)
                 finally:
                     dlg2.Destroy()
             except:
                 raise  # make sure any errors are not hidden
     dlg.Destroy()
Beispiel #7
0
def postlevel_process(is_new_level):
    if not is_new_level:
        return
    # What follows should be done only for new and open level commands

    # Load the level preset
    apply_level_preset()

    # Set the new outdoor to the terrain state
    if servers.get_conjurer().getcurrentstate() == 'terrain':
        trn.get_terrain_module().setoutdoor(
            app.get_outdoor_obj() 
            )

    # End the persist-restore process (continue from prelevel_process)
    # Close guiDialog windows
    frame = app.get_top_window()
    for child in frame.get_child_dialogs():
        child.Close()
    # Refresh other GUI features
    frame.refresh_all()
    # Restore persisted guiDialog windows
    for data in prelevel_process.child_data:
        restore_window(data)
    prelevel_process.child_data = []
Beispiel #8
0
    def refresh(self):
        # Disable Save  and Save As options if the current level is
        # the default, otherwise enable them
        level_name = get_name_of_current_level()
        should_enable = "default" != level_name
        self.Enable(ID_Save, should_enable)
        self.Enable(ID_SaveAs, should_enable)

        # Version number
        info = servers.get_conjurer().getreleasesubversioninfo()
        version = info[1]

        # Update both InGUI and OutGUI titles to show current level
        title_name = " - Level %s.n2" % level_name
        self.get_frame().SetTitle("Conjurer%s" % title_name)
        servers.get_conjurer().setwindowtitle(
            str("Summoner%s - %s" % (title_name, version)))
Beispiel #9
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) )
Beispiel #10
0
 def on_save_level(self, event):
     """Save the current level, overwritting the old file"""
     level_name = get_name_of_current_level()
     if level_name == "default":
         cjr.show_error_message("The default level cannot be saved.")
     else:
         try:
             try:
                 dlg = waitdlg.WaitDialog(
                     self.get_frame(), "Saving '%s' level..." % level_name)
                 if prelevel_process(False):
                     servers.get_conjurer().savelevel()
                     postlevel_process(False)
             finally:
                 dlg.Destroy()
         except:
             raise  # make sure any errors are not hidden
Beispiel #11
0
 def on_open_level(self, event):
     """Show a file browser and open the selected level"""
     # Ask for the level's name
     dlg = filedlg.FileDialog(
                 self.get_frame(), 
                 filedlg.OPEN,
                 'level', 
                 'Level', 
                 "wc:levels", 
                 ["n2"], 
                 import_button=False
                 )
     if dlg.ShowModal() == wx.ID_OK:
         # Check that the filename exists
         level_name = dlg.get_guiname()
         if not dlg.file_exists():
             msg = "So you want to open the '%s' level that doesn't exist?" \
                         "\n<sigh> How curious these humans are..." \
                         % level_name
             cjr.show_error_message(msg)
         else:
             # Ask for final confirmation
             msg = "Any previous unsaved level data will be lost.\n\n" \
                         "Are you sure that you want to load the "\
                         "'%s' level?" % level_name
             result = cjr.warn_yes_no( self.get_frame(), msg )
             if result == wx.ID_YES:
                 # Finally load the level
                 try:
                     try:
                         dlg3 = waitdlg.WaitDialog(
                                     self.get_frame(),
                                     "Loading level %s..." % level_name
                                     )
                         if prelevel_process(True):
                             servers.get_conjurer().loadlevel(
                                                 dlg.get_path_as_string()
                                             )
                             postlevel_process(True)
                     finally:
                         dlg3.Destroy()
                 except:
                     # make sure any errors are not hidden
                     raise
     dlg.Destroy()
Beispiel #12
0
    def __set_properties(self):
        self.SetTitle("About Conjurer")
        self.label_conjurer.SetFont(
            wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.label_number.SetFont(
            wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.list_info.InsertColumn(0, "Label")
        self.list_info.InsertColumn(1, "Value")

        # Relase build info
        # get release info: int version, int major, int minor, int patch,
        # char * versionstr, char * date, char * time, char * id
        info = servers.get_conjurer().getreleasebuildinfo()
        #self.label_number.SetLabel( get_version_number(info[0]) )

        # Build info
        self.list_info.InsertStringItem(0, "Release version")
        self.list_info.SetStringItem(0, 1, info[4])
        self.list_info.InsertStringItem(1, "Build date")
        self.list_info.SetStringItem(1, 1, info[5])
        self.list_info.InsertStringItem(2, "Build time")
        self.list_info.SetStringItem(2, 1, info[6])
        self.list_info.InsertStringItem(3, "Build id")
        self.list_info.SetStringItem(3, 1, info[7].strip('$BuildId: '))

        # Subversion info
        # int revision, char * revstr, char* range, char* url,
        # char* date, bool & mixed, bool & localmod
        info = servers.get_conjurer().getreleasesubversioninfo()
        self.list_info.InsertStringItem(4, "SVN revision")
        self.list_info.SetStringItem(4, 1, str(info[0]))
        self.label_number.SetLabel(info[1])
        self.list_info.InsertStringItem(5, "SVN revision range")
        self.list_info.SetStringItem(5, 1, info[2].strip('$Revision: '))
        self.list_info.InsertStringItem(6, "SVN head URL")
        self.list_info.SetStringItem(6, 1, info[3].strip('$HeadURL: '))
        self.list_info.InsertStringItem(7, "SVN date")
        self.list_info.SetStringItem(7, 1, info[4].strip('$Date: '))
        self.list_info.InsertStringItem(8, "SVN mixed WC")
        self.list_info.SetStringItem(8, 1, str(info[5]))
        self.list_info.InsertStringItem(9, "SVN locally modfified WC")
        self.list_info.SetStringItem(9, 1, str(info[6]))

        self.list_info.SetColumnWidth(0, wx.LIST_AUTOSIZE)
        self.list_info.SetColumnWidth(1, wx.LIST_AUTOSIZE)
Beispiel #13
0
def make_selected_viewport_first(viewport_list):
    """
    Move the selected viewport to the beginning of the list, or replace the
    first element with the selected viewport if it isn't already in the list.
    """
    current_vp = servers.get_conjurer().getcurrentviewport()
    if current_vp in viewport_list:
        viewport_list[ viewport_list.index(current_vp) ] = viewport_list[0]
    viewport_list[0] = current_vp
Beispiel #14
0
def make_selected_viewport_first(viewport_list):
    """
    Move the selected viewport to the beginning of the list, or replace the
    first element with the selected viewport if it isn't already in the list.
    """
    current_vp = servers.get_conjurer().getcurrentviewport()
    if current_vp in viewport_list:
        viewport_list[viewport_list.index(current_vp)] = viewport_list[0]
    viewport_list[0] = current_vp
Beispiel #15
0
 def on_toggle_ai(self, event):
     enable = event.Checked() or app.is_in_gameplay_mode()
     self.Check(ID_ToggleAI, enable)
     self.get_frame().get_toolbar().ToggleTool(ID_ToggleAI, enable)
     if enable:
         try:
             try:
                 wx.BeginBusyCursor()
                 servers.get_command_server().clean()
                 servers.get_conjurer().saveeditorstate()
                 app.get_ai_tester().enablegameplayupdating()
             finally:
                 wx.EndBusyCursor()
         except:
             # make sure any errors are not hidden
             raise
     else:
         app.get_ai_tester().disablegameplayupdating()
         servers.get_conjurer().restoreeditorstate()
Beispiel #16
0
    def on_connect( self, evt ):
        if self.network is not None:
            number = -1
            for index in range( self.number_connections ):
                if self.connectbtn[index] == evt.GetEventObject():
                    number = index
                    break

            if number >= 0 and self.network.getnumservers() > number:
                self.network.connect( number )
                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()
Beispiel #17
0
 def on_open_level(self, event):
     """Show a file browser and open the selected level"""
     # Ask for the level's name
     dlg = filedlg.FileDialog(self.get_frame(),
                              filedlg.OPEN,
                              'level',
                              'Level',
                              "wc:levels", ["n2"],
                              import_button=False)
     if dlg.ShowModal() == wx.ID_OK:
         # Check that the filename exists
         level_name = dlg.get_guiname()
         if not dlg.file_exists():
             msg = "So you want to open the '%s' level that doesn't exist?" \
                         "\n<sigh> How curious these humans are..." \
                         % level_name
             cjr.show_error_message(msg)
         else:
             # Ask for final confirmation
             msg = "Any previous unsaved level data will be lost.\n\n" \
                         "Are you sure that you want to load the "\
                         "'%s' level?" % level_name
             result = cjr.warn_yes_no(self.get_frame(), msg)
             if result == wx.ID_YES:
                 # Finally load the level
                 try:
                     try:
                         dlg3 = waitdlg.WaitDialog(
                             self.get_frame(),
                             "Loading level %s..." % level_name)
                         if prelevel_process(True):
                             servers.get_conjurer().loadlevel(
                                 dlg.get_path_as_string())
                             postlevel_process(True)
                     finally:
                         dlg3.Destroy()
                 except:
                     # make sure any errors are not hidden
                     raise
     dlg.Destroy()
Beispiel #18
0
 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()
Beispiel #19
0
 def on_save_level(self, event):
     """Save the current level, overwritting the old file"""
     level_name = get_name_of_current_level()
     if level_name == "default":
         cjr.show_error_message(
             "The default level cannot be saved."
             )
     else:
         try:
             try:
                 dlg = waitdlg.WaitDialog(
                             self.get_frame(),
                             "Saving '%s' level..." 
                                 % level_name
                             )
                 if prelevel_process(False):
                     servers.get_conjurer().savelevel()
                     postlevel_process(False)
             finally:
                 dlg.Destroy()
         except:
             raise # make sure any errors are not hidden
Beispiel #20
0
    def refresh(self):
        # Disable Save  and Save As options if the current level is 
        # the default, otherwise enable them
        level_name = get_name_of_current_level()
        should_enable = "default" != level_name
        self.Enable(ID_Save, should_enable)
        self.Enable(ID_SaveAs, should_enable)

        # Version number        
        info = servers.get_conjurer().getreleasesubversioninfo()
        version = info[1]

        # Update both InGUI and OutGUI titles to show current level
        title_name = " - Level %s.n2" % level_name 
        self.get_frame().SetTitle(
            "Conjurer%s" % title_name 
            )
        servers.get_conjurer().setwindowtitle(
            str(
                "Summoner%s - %s" % ( title_name, version )
                )
            )
Beispiel #21
0
 def on_new_level(self, event):
     """Create a new level replacing the old one, if user confirms"""
     # Ask for the level's name
     dlg = filedlg.FileDialog(self.get_frame(), filedlg.NEW, 'level',
                              'Level', "wc:levels", ["n2"])
     if dlg.ShowModal() == wx.ID_OK:
         # Check that's a new filename
         if dlg.file_exists():
             msg = "There is already a level called '%s'.\n\n" \
                         "Please enter a new level name." % dlg.get_guiname()
             cjr.show_error_message(msg)
         else:
             # Ask for final confirmation
             msg = "Any previous unsaved level data will be lost.\n\n" \
                     "Are you sure you want to create the new level '%s'?"\
                     % dlg.get_guiname()
             result = cjr.warn_yes_no(self.get_frame(), msg)
             if result == wx.ID_YES:
                 # Finally create the new level
                 if prelevel_process(True):
                     servers.get_conjurer().newlevel(
                         dlg.get_path_as_string())
                     postlevel_process(True)
     dlg.Destroy()
Beispiel #22
0
 def on_save_level_as(self, event):
     """ Save the current level under a new name. """
     # Ask for a name for the new level
     dlg = filedlg.FileDialog(
                 self.get_frame(), 
                 filedlg.SAVE,
                 'level', 
                 'Level',
                 "wc:levels", 
                 ["n2"]
                 )
     if dlg.ShowModal() == wx.ID_OK:
         new_level_name = dlg.get_guiname()
         # Check the name hasn't already been taken
         if dlg.file_exists():
             msg = "There is already a level called '%s'.\n\n" \
                         "Please enter a new level name." % new_level_name
             cjr.show_error_message(msg)
         else:
             try:
                 try:
                     new_level_path = dlg.get_path_as_string()
                     dlg2 = waitdlg.WaitDialog(
                                 self.get_frame(),
                                 "Saving level as '%s'..." 
                                     % new_level_name
                                 )
                     save_ok = servers.get_conjurer().savecurrentlevelas(
                                         new_level_path
                                         )
                     if save_ok:
                         self.refresh()
                     else:
                         cjr.show_error_message(
                             "Unable to save level as '%s'." 
                                 % new_level_name
                             )
                 finally:
                     dlg2.Destroy()
             except:
                 raise # make sure any errors are not hidden
     dlg.Destroy()
Beispiel #23
0
def prelevel_process(is_new_level):
    # Forbid any level operation while in game mode
    if app.is_in_gameplay_mode():
        cjr.show_error_message(
            "Operation not allowed while in game mode"
            )
        return False

    # Exit from any test mode
    app.get_ai_tester().disablegameplayupdating()
    app.get_ai_tester().disablesoundsources()

    # Clear undo buffer
    servers.get_command_server().clean()

    if not is_new_level:
        return True
    # Discard deleted entities
    servers.get_entity_object_server().discarddeletedobjects()
    servers.get_entity_class_server().discarddeletedclasses()

    # What follows should be done only for new and open level commands

    # Clear selection
    app.get_object_state().resetselection()

    # Make terrain state release some buffers
    if servers.get_conjurer().getcurrentstate() == 'terrain':
        trn.get_terrain_module().setoutdoor(None)

    # Begin a persist-restore process to close those invalid windows for
    # the new level and refresh the valid ones (continue in postlevel_process)
    # Persist guiDialog windows
    frame = app.get_top_window()
    prelevel_process.child_data = []
    for child in frame.get_child_dialogs():
        data = persist_window(child)
        if data is not None:
            prelevel_process.child_data.insert(0, data)
    return True
Beispiel #24
0
def prelevel_process(is_new_level):
    # Forbid any level operation while in game mode
    if app.is_in_gameplay_mode():
        cjr.show_error_message("Operation not allowed while in game mode")
        return False

    # Exit from any test mode
    app.get_ai_tester().disablegameplayupdating()
    app.get_ai_tester().disablesoundsources()

    # Clear undo buffer
    servers.get_command_server().clean()

    if not is_new_level:
        return True
    # Discard deleted entities
    servers.get_entity_object_server().discarddeletedobjects()
    servers.get_entity_class_server().discarddeletedclasses()

    # What follows should be done only for new and open level commands

    # Clear selection
    app.get_object_state().resetselection()

    # Make terrain state release some buffers
    if servers.get_conjurer().getcurrentstate() == 'terrain':
        trn.get_terrain_module().setoutdoor(None)

    # Begin a persist-restore process to close those invalid windows for
    # the new level and refresh the valid ones (continue in postlevel_process)
    # Persist guiDialog windows
    frame = app.get_top_window()
    prelevel_process.child_data = []
    for child in frame.get_child_dialogs():
        data = persist_window(child)
        if data is not None:
            prelevel_process.child_data.insert(0, data)
    return True
Beispiel #25
0
def postlevel_process(is_new_level):
    if not is_new_level:
        return
    # What follows should be done only for new and open level commands

    # Load the level preset
    apply_level_preset()

    # Set the new outdoor to the terrain state
    if servers.get_conjurer().getcurrentstate() == 'terrain':
        trn.get_terrain_module().setoutdoor(app.get_outdoor_obj())

    # End the persist-restore process (continue from prelevel_process)
    # Close guiDialog windows
    frame = app.get_top_window()
    for child in frame.get_child_dialogs():
        child.Close()
    # Refresh other GUI features
    frame.refresh_all()
    # Restore persisted guiDialog windows
    for data in prelevel_process.child_data:
        restore_window(data)
    prelevel_process.child_data = []
Beispiel #26
0
 def __set_conjurer_state(self, state_string):
     servers.get_conjurer().setstate(state_string)
Beispiel #27
0
def apply_preset(preset_name, preset_path):
    """Load and apply the specified preset"""
    # Validate preset path
    if not os.path.exists(preset_path):
        if preset_name != "default":
            level_name = get_name_of_current_level()
            msg = "Unable to find the '%s' preset attached to " \
                        "the '%s' level" % (preset_name, level_name)
            cjr.show_error_message(msg)
        return

    # Load stdlight
    stdlight_path = format.append_to_path(preset_path, "stdlight.n2")
    if not os.path.exists(stdlight_path):
        cjr.show_error_message(
            "Unable to find the Stdlight state for the '%s' preset"\
            % preset_name
            )
    else:
        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.loadstate(str(stdlight_path))

    # Viewport UI
    viewport_ui_path = format.append_to_path(preset_path, "viewportui.n2")
    if not os.path.exists(viewport_ui_path):
        cjr.show_error_message(
            "Unable to find the Viewport UI state for the '%s' preset"\
            % preset_name
            )
    else:
        viewport_ui = app.get_viewports_dir()
        viewport_ui.loadstate(str(viewport_ui_path))

    # Viewports
    for index in range(4):
        viewport_name = "viewport%s.n2" % index
        viewport_path = format.append_to_path(preset_path, viewport_name)
        if not os.path.exists(viewport_path):
            cjr.show_error_message(
                "Unable to find the Viewport %s state for the '%s' preset" \
                % ( index, preset_name )
                )
        else:
            viewport = pynebula.lookup(
                format.append_to_path(app.get_viewports_dir().getfullname(),
                                      viewport_name[:-3]))
            viewport.loadstate(str(viewport_path))
    # Special viewport rnsview
    viewport_path = format.append_to_path(preset_path, "rnsview.n2")
    if os.path.exists(viewport_path):
        viewport = pynebula.lookup('/usr/rnsview')
        viewport.loadstate(str(viewport_path))

    # Camera bookmarks
    bookmark_path = format.append_to_path(preset_path, "bookmarks.n2")
    if os.path.exists(bookmark_path):
        servers.get_conjurer().loadbookmarks(bookmark_path)

    # Mouse settings (sensitivity, invert y-axis, etc)
    mouse_setting_path = format.append_to_path(preset_path, "mousesettings.n2")
    if os.path.exists(mouse_setting_path):
        game_state = app.get_state("game")
        game_state.loadmousesettings(str(mouse_setting_path))
Beispiel #28
0
def get_current_state():
    return servers.get_conjurer().getcurrentstate()
Beispiel #29
0
def get_current_state():
    return servers.get_conjurer().getcurrentstate()
Beispiel #30
0
 def move_camera (self):
     conjurer = servers.get_conjurer()
     conjurer.movecameratoselection()
Beispiel #31
0
    def __set_properties(self):
        self.SetTitle("About Conjurer")
        self.label_conjurer.SetFont(
            wx.Font(
                8, 
                wx.DEFAULT, 
                wx.NORMAL, 
                wx.BOLD, 
                0, 
                ""
                )
            )
        self.label_number.SetFont(
            wx.Font(
                8,
                wx.DEFAULT, 
                wx.NORMAL, 
                wx.BOLD, 
                0,
                ""
                )
            )
        self.list_info.InsertColumn(0, "Label")
        self.list_info.InsertColumn(1, "Value")

        # Relase build info        
        # get release info: int version, int major, int minor, int patch, 
        # char * versionstr, char * date, char * time, char * id 
        info = servers.get_conjurer().getreleasebuildinfo()
        #self.label_number.SetLabel( get_version_number(info[0]) )
        
        # Build info
        self.list_info.InsertStringItem( 0, "Release version" )
        self.list_info.SetStringItem( 0, 1, info[4] )
        self.list_info.InsertStringItem( 1, "Build date" )
        self.list_info.SetStringItem( 1, 1, info[5] )
        self.list_info.InsertStringItem( 2, "Build time" )
        self.list_info.SetStringItem( 2, 1, info[6] )
        self.list_info.InsertStringItem( 3, "Build id" )
        self.list_info.SetStringItem( 3, 1, info[7].strip('$BuildId: ') )
        
        # Subversion info
        # int revision, char * revstr, char* range, char* url, 
        # char* date, bool & mixed, bool & localmod
        info = servers.get_conjurer().getreleasesubversioninfo()
        self.list_info.InsertStringItem( 4, "SVN revision" )
        self.list_info.SetStringItem( 4, 1, str(info[0]) )
        self.label_number.SetLabel( info[1] )
        self.list_info.InsertStringItem( 5, "SVN revision range" )
        self.list_info.SetStringItem( 5, 1, info[2].strip('$Revision: ') )
        self.list_info.InsertStringItem( 6, "SVN head URL" )
        self.list_info.SetStringItem( 6, 1, info[3].strip('$HeadURL: ') )
        self.list_info.InsertStringItem( 7, "SVN date" )
        self.list_info.SetStringItem( 7, 1, info[4].strip('$Date: ') )
        self.list_info.InsertStringItem( 8, "SVN mixed WC" )
        self.list_info.SetStringItem( 8, 1, str(info[5]) )
        self.list_info.InsertStringItem( 9, "SVN locally modfified WC" )
        self.list_info.SetStringItem( 9, 1, str(info[6]) )
        
        self.list_info.SetColumnWidth(0, wx.LIST_AUTOSIZE)
        self.list_info.SetColumnWidth(1, wx.LIST_AUTOSIZE)
Beispiel #32
0
def apply_preset(preset_name, preset_path):
    """Load and apply the specified preset"""
    # Validate preset path
    if not os.path.exists(preset_path):
        if preset_name != "default":
            level_name = get_name_of_current_level()
            msg = "Unable to find the '%s' preset attached to " \
                        "the '%s' level" % (preset_name, level_name) 
            cjr.show_error_message(msg)
        return

    # Load stdlight
    stdlight_path = format.append_to_path(preset_path, "stdlight.n2") 
    if not os.path.exists(stdlight_path):
        cjr.show_error_message(
            "Unable to find the Stdlight state for the '%s' preset"\
            % preset_name
            )
    else:
        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.loadstate( str(stdlight_path) )

    # Viewport UI
    viewport_ui_path = format.append_to_path( preset_path, "viewportui.n2" )
    if not os.path.exists( viewport_ui_path ):
        cjr.show_error_message(
            "Unable to find the Viewport UI state for the '%s' preset"\
            % preset_name
            )
    else:
        viewport_ui = app.get_viewports_dir()
        viewport_ui.loadstate( str(viewport_ui_path) )

    # Viewports
    for index in range(4):
        viewport_name = "viewport%s.n2" % index
        viewport_path = format.append_to_path( preset_path, viewport_name )
        if not os.path.exists( viewport_path ):
            cjr.show_error_message(
                "Unable to find the Viewport %s state for the '%s' preset" \
                % ( index, preset_name )
                )
        else:
            viewport = pynebula.lookup(
                                format.append_to_path(
                                    app.get_viewports_dir().getfullname(), 
                                    viewport_name[:-3]
                                    )
                                )
            viewport.loadstate( str(viewport_path) )
    # Special viewport rnsview
    viewport_path = format.append_to_path(preset_path, "rnsview.n2")
    if os.path.exists( viewport_path ):
        viewport = pynebula.lookup( '/usr/rnsview' )
        viewport.loadstate( str(viewport_path) )

    # Camera bookmarks
    bookmark_path = format.append_to_path(preset_path, "bookmarks.n2")
    if os.path.exists( bookmark_path ):
        servers.get_conjurer().loadbookmarks(bookmark_path)

    # Mouse settings (sensitivity, invert y-axis, etc)
    mouse_setting_path = format.append_to_path(preset_path, "mousesettings.n2")
    if os.path.exists( mouse_setting_path ):
        game_state = app.get_state("game")
        game_state.loadmousesettings( str(mouse_setting_path) )
Beispiel #33
0
 def __set_conjurer_state(self, state_string):
     servers.get_conjurer().setstate(state_string)