Example #1
0
async def qt_main(app: QtWidgets.QApplication, data_dir: Path, args):
    app.network_client = None
    logging.info("Loading server client...")
    from randovania.gui.lib.qt_network_client import QtNetworkClient
    logging.info("Configuring server client...")
    app.network_client = QtNetworkClient(data_dir)
    logging.info("Server client ready.")

    options = _load_options()
    backend = create_backend(args.debug_game_backend, options)

    logging.info("Configuring game connection with the backend...")
    from randovania.game_connection.game_connection import GameConnection
    app.game_connection = GameConnection(backend)

    logging.info("Configuring qasync...")
    import qasync

    @qasync.asyncClose
    async def _on_last_window_closed():
        await app.network_client.disconnect_from_server()
        await app.game_connection.stop()
        logger.info("Last QT window closed")

    app.lastWindowClosed.connect(_on_last_window_closed,
                                 QtCore.Qt.QueuedConnection)

    await asyncio.gather(app.game_connection.start(),
                         display_window_for(app, options, args.command, args))
Example #2
0
async def qt_main(app: QApplication, data_dir: Path, args):
    from randovania.gui.lib.qt_network_client import QtNetworkClient
    from randovania.game_connection.game_connection import GameConnection

    app.network_client = QtNetworkClient(data_dir)

    backend = create_backend(args.debug_game_backend)
    app.game_connection = GameConnection(backend)

    @asyncClose
    async def _on_last_window_closed():
        await app.network_client.disconnect_from_server()
        await app.game_connection.stop()

    app.lastWindowClosed.connect(_on_last_window_closed,
                                 QtCore.Qt.QueuedConnection)

    options = _load_options()

    await asyncio.gather(app.game_connection.start(),
                         display_window_for(app, options, args.command, args))
Example #3
0
def run(args):
    QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)

    app = QApplication(sys.argv)
    preview: bool = getattr(args, "preview", False)

    os.environ['QT_API'] = "PySide2"
    import asyncqt
    loop = asyncqt.QEventLoop(app)
    asyncio.set_event_loop(loop)

    sys.excepthook = catch_exceptions

    app.game_connection = GameConnection()

    if getattr(args, "debug_game_backend", False):
        backend = DebugBackendWindow()
        backend.show()
    else:
        backend = DolphinBackend()

    app.game_connection.set_backend(backend)

    @asyncClose
    async def _on_last_window_closed():
        await app.game_connection.stop()

    app.lastWindowClosed.connect(_on_last_window_closed, Qt.QueuedConnection)

    target_window = getattr(args, "window", None)
    if target_window == "data-editor":
        show_data_editor(app)
    elif target_window == "tracker":
        show_tracker(app)
    else:
        show_main_window(app, preview)

    with loop:
        loop.create_task(app.game_connection.start())
        sys.exit(loop.run_forever())
Example #4
0
async def qt_main(app: QtWidgets.QApplication, data_dir: Path, args):
    from randovania.gui.lib.qt_network_client import QtNetworkClient
    from randovania.game_connection.game_connection import GameConnection

    app.network_client = QtNetworkClient(data_dir)
    options = _load_options()

    backend = create_backend(args.debug_game_backend, options)
    app.game_connection = GameConnection(backend)
    app.game_connection.tracking_inventory = options.tracking_inventory
    app.game_connection.displaying_messages = options.displaying_messages

    @asyncClose
    async def _on_last_window_closed():
        await app.network_client.disconnect_from_server()
        await app.game_connection.stop()
        logger.info("Last QT window closed")

    app.lastWindowClosed.connect(_on_last_window_closed,
                                 QtCore.Qt.QueuedConnection)

    await asyncio.gather(app.game_connection.start(),
                         display_window_for(app, options, args.command, args))