Ejemplo n.º 1
0
 def __check_ai_not_active(self):
     if app.get_ai_tester().isgameplayupdatingenabled():
         cjr.show_error_message(
             "Please switch off AI before closing Conjurer.")
         return False
     else:
         return True
Ejemplo n.º 2
0
 def on_toggle_sound(self, event):
     enable = event.Checked()
     self.Check(ID_ToggleSound, enable)
     self.get_frame().get_toolbar().ToggleTool(ID_ToggleSound, enable)
     if enable:
         app.get_ai_tester().enablesoundsources()
     else:
         app.get_ai_tester().disablesoundsources()
         e_server = servers.get_entity_object_server()
         entity = e_server.getfirstentityobject()
         while entity is not None:
             if entity.hascomponent('ncAreaTrigger'):
                 entity.resets()
             if entity.hascomponent('ncSound'):
                 entity.disablesoundtrigger()
             entity = e_server.getnextentityobject()
Ejemplo n.º 3
0
 def __bind_events(self):
     self.Bind(events.EVT_CHANGING, self.on_change_speed, self.slider_speed)
     self.Bind(events.EVT_CHANGED, self.on_change_speed, self.slider_speed)
     self.Bind(wx.EVT_TOGGLEBUTTON, self.on_toggle_pause, self.button_debug)
     self.Bind(wx.EVT_BUTTON, self.on_apply_event, self.button_apply)
     self.Bind(wx.EVT_BUTTON, self.on_discard_event, self.button_discard)
     pynebula.pyBindSignal( app.get_ai_tester(), 'pendingeventchanged',
         self, 'onpendingeventchanged', 0 )
Ejemplo n.º 4
0
 def __check_ai_not_active(self):
     if app.get_ai_tester().isgameplayupdatingenabled():
         cjr.show_error_message(
             "Please switch off AI before closing Conjurer."
             )
         return False
     else:
         return True
Ejemplo n.º 5
0
 def __set_properties(self):
     data = {
         'speed': -app.get_ai_tester().getupdatefrequency()
         }
     self.restore([data])
     
     self.text_event.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE) )
     self.text_entity.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE) )
     self.__update_pending_event()
Ejemplo n.º 6
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()
Ejemplo n.º 7
0
 def refresh(self):
     self.menu_options.refresh()
     if self.first_refresh:
         # Do the binding here because the object state doesn't exist yet
         # when this menu is created
         pynebula.pyBindSignal(
             app.get_ai_tester(),
             'gameplayupdatingenabled',
             self,
             'ongameplayupdatingenabled',
             0,
         )
         pynebula.pyBindSignal(app.get_ai_tester(),
                               'gameplayupdatingdisabled', self,
                               'ongameplayupdatingdisabled', 0)
         pynebula.pyBindSignal(app.get_ai_tester(), 'soundsourcesenabled',
                               self, 'onsoundsourcesenabled', 0)
         pynebula.pyBindSignal(app.get_ai_tester(), 'soundsourcesdisabled',
                               self, 'onsoundsourcesdisabled', 0)
         self.first_refresh = False
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
0
 def __update_pending_event(self):
     tester = app.get_ai_tester()
     entity, event = tester.getpendingevent()
     debug = tester.isgameplaydebuggingenabled()
     pending = debug and entity != 0
     self.button_debug.SetValue( debug )
     self.button_apply.Enable( pending )
     self.button_discard.Enable( pending )
     if pending:
         self.text_event.SetValue( event )
         self.text_entity.SetValue( str(entity) )
     else:
         self.text_event.SetValue( "" )
         self.text_entity.SetValue( "" )
Ejemplo n.º 11
0
 def __del__(self):
     pynebula.pyUnbindTargetObject( app.get_ai_tester(),
         'pendingeventchanged', self)
Ejemplo n.º 12
0
    def restore(self, data_list):
        data = data_list[0]

        app.get_ai_tester().setupdatefrequency( -data['speed'] )
        self.slider_speed.set_value( data['speed'] )
Ejemplo n.º 13
0
 def on_discard_event(self, event):
     app.get_ai_tester().discardpendingevent()
Ejemplo n.º 14
0
 def on_apply_event(self, event):
     app.get_ai_tester().applypendingevent()
Ejemplo n.º 15
0
 def on_toggle_pause(self, event):
     if self.button_debug.GetValue():
         app.get_ai_tester().enablegameplaydebugging()
     else:
         app.get_ai_tester().disablegameplaydebugging()
     self.__update_pending_event()
Ejemplo n.º 16
0
 def on_change_speed(self, event):
     app.get_ai_tester().setupdatefrequency( -self.slider_speed.get_value() )