コード例 #1
0
ファイル: AppRunner.py プロジェクト: chongzhang5097/panda3d
    def run(self):
        """ This method calls taskMgr.run(), with an optional
        exception handler.  This is generally the program's main loop
        when running in a p3d environment (except on unusual platforms
        like the iPhone, which have to hand the main loop off to the
        OS, and don't use this interface). """

        try:
            taskMgr.run()

        except SystemExit:
            # Presumably the window has already been shut down here, but shut
            # it down again for good measure.
            if hasattr(__builtin__, "base"):
                base.destroy()

            self.notify.info("Normal exit.")
            raise

        except:
            # Some unexpected Python exception; pass it to the
            # optional handler, if it is defined.
            if self.exceptionHandler and not self.interactiveConsole:
                self.exceptionHandler()
            else:
                raise
コード例 #2
0
def main():
    base = ShowBase()

    cm = CardMaker('')
    cm.set_frame(-.5, .5, -.5, .5)

    # Node which contains all the cards equally spaced apart and which is
    # animated to move the cards in front of the camera.
    cards = base.render.attach_new_node(PandaNode(''))
    cards.setPos(-2, 5, 0)
    cards.posInterval(2, Point3(-6, 5, 0)).loop()

    for i in range(5):
        card = cards.attach_new_node(cm.generate())
        card.setPos(i * 2, 0, 0)

    def on_every_frame(task):
        # Time which has elapsed since the last frame measured in units of
        # the time quota available at 60 fps (e.g. 1/60 second).
        time_quota = taskMgr.globalClock.get_dt() * 60

        # Print time use as percent of the 60-fps-quota.
        print(f'{round(time_quota * 100):4}', end='', flush=True)

        return Task.DSCont

    taskMgr.add(on_every_frame)
    taskMgr.run()
コード例 #3
0
    def run(self):
        """ This method calls taskMgr.run(), with an optional
        exception handler.  This is generally the program's main loop
        when running in a p3d environment (except on unusual platforms
        like the iPhone, which have to hand the main loop off to the
        OS, and don't use this interface). """

        try:
            taskMgr.run()

        except SystemExit:
            # Presumably the window has already been shut down here, but shut
            # it down again for good measure.
            if hasattr(__builtin__, "base"):
                base.destroy()

            self.notify.info("Normal exit.")
            raise

        except:
            # Some unexpected Python exception; pass it to the
            # optional handler, if it is defined.
            if self.exceptionHandler and not self.interactiveConsole:
                self.exceptionHandler()
            else:
                raise
コード例 #4
0
ファイル: OTPBase.py プロジェクト: NoraTheGamer/StrideMods
 def run(self):
     try:
         taskMgr.run()
     except SystemExit:
         self.notify.info('Normal exit.')
         self.destroy()
         raise
     except:
         self.notify.warning('Handling Python exception.')
         if getattr(self, 'cr', None):
             if self.cr.timeManager:
                 from otp.otpbase import OTPGlobals
                 self.cr.timeManager.setDisconnectReason(
                     OTPGlobals.DisconnectPythonError)
                 self.cr.timeManager.setExceptionInfo()
             self.cr.sendDisconnect()
         self.notify.info('Exception exit.\n')
         self.destroy()
         import traceback
         traceback.print_exc()
コード例 #5
0
def main():
    dc_loader = io.NetworkDCLoader()
    dc_loader.read_dc_files(['config/dclass/toon.dc'])

    component_manager = component.ComponentManager()
    if not args.no_messagedirector:
        if has_clibotp:
            component_manager.add_component(CMessageDirector())
        else:
            component_manager.add_component(messagedirector.MessageDirector())

    if not args.no_clientagent:
        component_manager.add_component(clientagent.ClientAgent(dc_loader))

    if not args.no_stateserver:
        component_manager.add_component(stateserver.StateServer(dc_loader))

    if not args.no_database:
        component_manager.add_component(database.DatabaseServer(dc_loader))

    task_mgr.run()
    component_manager.shutdown()
    return 0
コード例 #6
0

def runPackedApp(pathname):
    runner = AppRunner()
    runner.gotWindow = True
    try:
        runner.setP3DFilename(pathname,
                              tokens=[],
                              argv=[],
                              instanceId=0,
                              interactiveConsole=False)
    except ArgumentError, e:
        print e.args[0]
        sys.exit(1)


if __name__ == '__main__':
    runner = AppRunner()
    runner.gotWindow = True
    try:
        argv = parseSysArgs()
        runner.setP3DFilename(argv[0],
                              tokens=[],
                              argv=argv,
                              instanceId=0,
                              interactiveConsole=False)
    except ArgumentError, e:
        print e.args[0]
        sys.exit(1)
    taskMgr.run()
コード例 #7
0
    database_connect_address = config.GetString('database-connect-address',
                                                '127.0.0.1')
    database_connect_port = config.GetInt('database-connect-port',
                                          message_director_port)
    database_channel = config.GetInt('database-channel',
                                     types.DATABASE_CHANNEL)

    message_director = setup_component(messagedirector.MessageDirector,
                                       message_director_address,
                                       message_director_port)

    client_agent = setup_component(clientagent.ClientAgent, dc_loader,
                                   client_agent_address, client_agent_port,
                                   client_agent_connect_address,
                                   client_agent_connect_port,
                                   client_agent_channel)

    state_server = setup_component(stateserver.StateServer, dc_loader,
                                   state_server_connect_address,
                                   state_server_connect_port,
                                   state_server_channel)

    database_server = setup_component(database.DatabaseServer, dc_loader,
                                      database_connect_address,
                                      database_connect_port, database_channel)


if __name__ == '__main__':
    main()
    task_mgr.run()
コード例 #8
0
    arg0 = args[0]
    p3dFilename = Filename.fromOsSpecific(arg0)
    if p3dFilename.exists():
        p3dFilename.makeAbsolute()
        arg0 = p3dFilename.toOsSpecific()

    return [arg0] + args[1:]

def runPackedApp(pathname):
    runner = AppRunner()
    runner.gotWindow = True
    try:
        runner.setP3DFilename(pathname, tokens = [], argv = [],
                              instanceId = 0, interactiveConsole = False)
    except ArgumentError, e:
        print e.args[0]
        sys.exit(1)

if __name__ == '__main__':
    runner = AppRunner()
    runner.gotWindow = True
    try:
        argv = parseSysArgs()
        runner.setP3DFilename(argv[0], tokens = [], argv = argv,
                              instanceId = 0, interactiveConsole = False)
    except ArgumentError, e:
        print e.args[0]
        sys.exit(1)
    taskMgr.run()