Ejemplo n.º 1
0
    def on_remove_stream(self, event):
        """Remove geometry stream"""
        if not pynebula.exists( str("/usr/streams") ):
            app.get_state("geometrystream").loadstreamlibrary()

        dlg = nodelibdlg.NodeLibDialog(
                    self.get_frame(), 
                    nodelibdlg.OPEN,
                    'stream', 
                    'Stream', 
                    "/usr/streams"
                    )
        if dlg.ShowModal() == wx.ID_OK:
            # Check that's an existing stream
            if not dlg.node_exists():
                msg = "There is no stream called '%s'" % dlg.get_guiname()
                cjr.show_error_message(msg)
            else:
                # remove the stream
                dlg2 = waitdlg.WaitDialog(
                            self.get_frame(),
                            "Removing stream '%s' ..." % dlg.get_guiname()
                            )
                dlg.get_node().removestream()
                dlg2.Destroy()
        dlg.Destroy()
Ejemplo n.º 2
0
    def on_open_stream(self, event):
        """Open geometry stream"""
        # Ask for the stream name
        if not pynebula.exists( str("/usr/streams") ):
            app.get_state("geometrystream").loadstreamlibrary()

        dlg = nodelibdlg.NodeLibDialog(
                    self.get_frame(), 
                    nodelibdlg.OPEN,
                    'stream', 
                    'Stream', 
                    "/usr/streams"
                    )
        if dlg.ShowModal() == wx.ID_OK:
            # Check that's an existing stream
            if not dlg.node_exists():
                msg = "There is no stream called '%s'"  % dlg.get_guiname()
                cjr.show_error_message(msg)
            else:
                # open the stream for editing
                win = objdlg.create_window(
                            wx.GetApp().GetTopWindow(), 
                            dlg.get_node().getfullname() 
                            )
                win.display()
        dlg.Destroy()
Ejemplo n.º 3
0
    def on_create_stream(self, event):
        """Create geometry stream"""
        # Ask for the new stream name
        if not pynebula.exists( str("/usr/streams") ):
            app.get_state("geometrystream").loadstreamlibrary()

        dlg = nodelibdlg.NodeLibDialog(
                    self.get_frame(), 
                    nodelibdlg.NEW,
                    'stream', 
                    'Stream', 
                    "/usr/streams"
                    )
        if dlg.ShowModal() == wx.ID_OK:
            # Check that's a new stream name
            if dlg.node_exists():
                msg = "There's already a stream named"
                msg = msg + " '" + dlg.get_guiname() + "'.\n"
                msg = msg + "You should enter a new stream name."
                cjr.show_error_message(msg)
            else:
                # create the new stream
                obj = app.get_state("geometrystream").createstream(
                            str( dlg.get_guiname() ) 
                            )
                win = objdlg.create_window(
                            wx.GetApp().GetTopWindow(), 
                            obj.getfullname() 
                            )
                win.display()
        dlg.Destroy()
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
 def on_build_streams(self, event):
     """Build all streams"""
     # Build all dirty streams
     if not pynebula.exists(str("/usr/streams")):
         app.get_state("geometrystream").loadstreamlibrary()
     dlg2 = waitdlg.WaitDialog(self.get_frame(), "Building streams ...")
     app.get_state("geometrystream").buildallstreams()
     dlg2.Destroy()
Ejemplo n.º 6
0
 def on_build_streams(self, event):
     """Build all streams"""
     # Build all dirty streams
     if not pynebula.exists( str("/usr/streams") ):
         app.get_state("geometrystream").loadstreamlibrary()
     dlg2 = waitdlg.WaitDialog( self.get_frame(), "Building streams ..." )
     app.get_state("geometrystream").buildallstreams()
     dlg2.Destroy()
 def test_get_state(self):
     expected = 'What is the state? '
     with patch('builtins.input') as mocked_input:
         with patch('builtins.print') as mocked_print:
             mocked_input.side_effect = ('bad input', 'WI', 'MN')
             state = app.get_state()
             mocked_input.assert_called_with(expected)
             mocked_print.assert_called_with('A valid input is required')
             self.assertEqual(state, 'WI')
             state = app.get_state()
             self.assertEqual(state, 'MN')
Ejemplo n.º 8
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))
Ejemplo n.º 9
0
    def on_delete_stream(self, event):
        """Delete geometry stream"""
        # Ask for the stream name
        if not pynebula.exists(str("/usr/streams")):
            app.get_state("geometrystream").loadstreamlibrary()

        dlg = nodelibdlg.NodeLibDialog(self.get_frame(), nodelibdlg.DELETE,
                                       'stream', 'Stream', "/usr/streams")
        ok_to_continue = dlg.ShowModal() == wx.ID_OK
        if ok_to_continue:
            msg = "Delete stream '%s'?" % dlg.get_guiname()
            delete = cjr.warn_yes_no(self.get_frame(), msg)
            if delete == wx.ID_YES:
                # Delete the stream
                app.get_state("geometrystream").deletestream(
                    str(dlg.get_guiname()))
        dlg.Destroy()
Ejemplo n.º 10
0
    def on_open_stream(self, event):
        """Open geometry stream"""
        # Ask for the stream name
        if not pynebula.exists(str("/usr/streams")):
            app.get_state("geometrystream").loadstreamlibrary()

        dlg = nodelibdlg.NodeLibDialog(self.get_frame(), nodelibdlg.OPEN,
                                       'stream', 'Stream', "/usr/streams")
        if dlg.ShowModal() == wx.ID_OK:
            # Check that's an existing stream
            if not dlg.node_exists():
                msg = "There is no stream called '%s'" % dlg.get_guiname()
                cjr.show_error_message(msg)
            else:
                # open the stream for editing
                win = objdlg.create_window(wx.GetApp().GetTopWindow(),
                                           dlg.get_node().getfullname())
                win.display()
        dlg.Destroy()
Ejemplo n.º 11
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()
Ejemplo n.º 12
0
    def on_remove_stream(self, event):
        """Remove geometry stream"""
        if not pynebula.exists(str("/usr/streams")):
            app.get_state("geometrystream").loadstreamlibrary()

        dlg = nodelibdlg.NodeLibDialog(self.get_frame(), nodelibdlg.OPEN,
                                       'stream', 'Stream', "/usr/streams")
        if dlg.ShowModal() == wx.ID_OK:
            # Check that's an existing stream
            if not dlg.node_exists():
                msg = "There is no stream called '%s'" % dlg.get_guiname()
                cjr.show_error_message(msg)
            else:
                # remove the stream
                dlg2 = waitdlg.WaitDialog(
                    self.get_frame(),
                    "Removing stream '%s' ..." % dlg.get_guiname())
                dlg.get_node().removestream()
                dlg2.Destroy()
        dlg.Destroy()
    def test_get_state(self):

        expected_state = 'Wisconsin'
        expected_input = 'What state do you live in? '
        with patch('builtins.input') as mocked_input:
            with patch('builtins.print') as mocked_print:
                mocked_input.side_effect = ('', 'Wisconsin')
                state = app.get_state()
                mocked_print.assert_called_with('A valid input is required')
                mocked_input.assert_called_with(expected_input)

                self.assertEqual(state, expected_state)
Ejemplo n.º 14
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()
Ejemplo n.º 15
0
    def on_create_stream(self, event):
        """Create geometry stream"""
        # Ask for the new stream name
        if not pynebula.exists(str("/usr/streams")):
            app.get_state("geometrystream").loadstreamlibrary()

        dlg = nodelibdlg.NodeLibDialog(self.get_frame(), nodelibdlg.NEW,
                                       'stream', 'Stream', "/usr/streams")
        if dlg.ShowModal() == wx.ID_OK:
            # Check that's a new stream name
            if dlg.node_exists():
                msg = "There's already a stream named"
                msg = msg + " '" + dlg.get_guiname() + "'.\n"
                msg = msg + "You should enter a new stream name."
                cjr.show_error_message(msg)
            else:
                # create the new stream
                obj = app.get_state("geometrystream").createstream(
                    str(dlg.get_guiname()))
                win = objdlg.create_window(wx.GetApp().GetTopWindow(),
                                           obj.getfullname())
                win.display()
        dlg.Destroy()
Ejemplo n.º 16
0
    def on_delete_stream(self, event):
        """Delete geometry stream"""
        # Ask for the stream name
        if not pynebula.exists( str("/usr/streams") ):
            app.get_state("geometrystream").loadstreamlibrary()

        dlg = nodelibdlg.NodeLibDialog(
                    self.get_frame(), 
                    nodelibdlg.DELETE,
                    'stream', 
                    'Stream', 
                    "/usr/streams"
                    )
        ok_to_continue = dlg.ShowModal() == wx.ID_OK
        if ok_to_continue:
            msg = "Delete stream '%s'?" % dlg.get_guiname()
            delete = cjr.warn_yes_no( self.get_frame(), msg )
            if delete == wx.ID_YES:
                # Delete the stream
                app.get_state("geometrystream").deletestream(
                    str( dlg.get_guiname() ) 
                    )
        dlg.Destroy()
Ejemplo n.º 17
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) )
Ejemplo n.º 18
0
 def on_save_library(self, event):
     """Save all streams"""
     # Save all streams to file
     if pynebula.exists(str("/usr/streams")):
         app.get_state("geometrystream").savestreamlibrary()
Ejemplo n.º 19
0
 def on_crossmode( self, evt ):
     state = app.get_state( "game" )
     state.setcrossmode( self.crossmodelist.GetSelection() )
Ejemplo n.º 20
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))
Ejemplo n.º 21
0
 def on_mouseyslider( self, evt ):
     state = app.get_state( "game" )
     state.setmouseyfactor( evt.get_value() )
Ejemplo n.º 22
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)
        
        self.gameport = "Orochimaru"
        self.number_connections = 3
        
        self.multiplayer = False
        self.server = False
        self.searching = False
        self.network = None
        
        self.singlecheck = wx.RadioButton(
                                    self, 
                                    -1, 
                                    "Singleplayer",
                                    style = wx.RB_GROUP 
                                    )
        self.servercheck = wx.RadioButton( 
                                    self,
                                    -1, 
                                    "Multiplayer Server" 
                                    )
        self.clientcheck = wx.RadioButton( 
                                    self, 
                                    -1, 
                                    "Multiplayer Client" 
                                    )
        
        self.button_search = wx.Button( self, -1, "Start Search" )
        self.button_search.Disable()
        self.button_connect_to = wx.Button(
                                        self, 
                                        -1, 
                                        "Connect to -> ", 
                                        style = wx.BU_RIGHT
                                        )
        self.button_connect_to.Disable()
        self.hostedit = wx.TextCtrl( self, -1, "Host" )
        self.hostedit.SetValue( "127.0.0.1" )
        self.hostedit.Disable()

        self.connectbtn = []
        for i in range( self.number_connections ):
            self.connectbtn.append(
                wx.Button(
                    self,
                    -1, 
                    "Connect to < empty >"  
                    )
                )
            self.connectbtn[ i ].Disable()
            
        self.button_cancel = wx.Button( self, -1, "Cancel Search" )
        self.button_cancel.Disable()
        self.button_start = wx.Button( self, -1, "Start" )
        
        self.serverbox = wx.StaticBox( self, -1, "Normal Options" )
        self.clientbox = wx.StaticBox( self, -1, "Client options" )
        
        self.mousebox = wx.StaticBox( self, -1, "Mouse options" )
        state = app.get_state( "game" )

        self.invertbtn = wx.CheckBox( self, -1, "Invert mouse vertical" )
        
        self.invertbtn.SetValue( state.getmouseyinvert() )
        
        self.mousexslider = floatslider.FloatSlider(
            self, -1, "Sensitivity X", 1.0, 0.0, 5.0, precision=10.0
            )
        self.mousexslider.set_value( state.getmousexfactor() )
        self.mouseyslider = floatslider.FloatSlider(
            self, -1, "Sensitivity Y", 1.0, 0.0, 5.0, precision=10.0
            )
        self.mouseyslider.set_value( state.getmouseyfactor() )
        
        self.fullreloadslider = floatslider.FloatSlider(
            self, -1, "Full Reload Time", 1.0, 0.0, 5.0, precision=10.0
            )
        self.fullreloadslider.set_value( state.getfullreloadtime() )
        
        self.crossmodelabel = wx.StaticText( self, -1, "Cross Mode" )
        self.crossmodelist = wx.ComboBox( 
                                        self,
                                        -1, 
                                        "Cross Mode", 
                                        style=wx.CB_READONLY, 
                                        choices=["Never","Normal","Always"]
                                        )
        
        self.crossmodelist.Select( state.getcrossmode() )

        self.timer = wx.Timer(self)
        self.timer.Start( 1000 )

        self.__do_layout()
        self.__do_binding()
        
        self.parent = parent
        
        if pynebula.exists( "/sys/servers/network" ):
            self.singlecheck.Disable()
            self.servercheck.Disable()
            self.clientcheck.Disable()
            self.button_start.Disable()
Ejemplo n.º 23
0
 def on_mouseinvert( self, evt ):
     state = app.get_state( "game" )
     state.setmouseyinvert( self.invertbtn.GetValue() )
Ejemplo n.º 24
0
 def on_fullreloadslider( self, evt ):
     state = app.get_state( "game" )
     state.setfullreloadtime( evt.get_value() )
Ejemplo n.º 25
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) )
Ejemplo n.º 26
0
 def on_save_library(self, event):
     """Save all streams"""
     # Save all streams to file
     if pynebula.exists( str("/usr/streams") ):
         app.get_state("geometrystream").savestreamlibrary()