Ejemplo n.º 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))
Ejemplo n.º 2
0
async def ensure_logged_in(parent: Optional[QtWidgets.QWidget], network_client: QtNetworkClient):
    if network_client.connection_state == ConnectionState.Connected:
        return True

    if network_client.connection_state.is_disconnected:
        try:
            await wait_dialog.cancellable_wait(
                parent,
                network_client.connect_to_server(),
                "Connecting",
                "Connecting to server...",
            )
        except asyncio.CancelledError:
            return False

    if network_client.current_user is None:
        await async_dialog.execute_dialog(LoginPromptDialog(network_client))

    return network_client.current_user is not None
Ejemplo n.º 3
0
async def qt_main(app: QtWidgets.QApplication, data_dir: Path, args):
    app.setQuitOnLastWindowClosed(False)
    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.")

    if args.login_as_guest:
        logging.info("Logging as %s", args.login_as_guest)
        await app.network_client.login_as_guest(args.login_as_guest)

    options = await _load_options()
    if options is None:
        app.exit(1)
        return

    executor = create_memory_executor(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(executor)

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

    @qasync.asyncClose
    async def _on_last_window_closed():
        if app.quitOnLastWindowClosed():
            await app.network_client.disconnect_from_server()
            await app.game_connection.stop()
            logger.info("Last QT window closed")
        else:
            logger.warning(
                "Last Qt window closed, but currently not doing anything")

    app.setQuitOnLastWindowClosed(True)
    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))
Ejemplo n.º 4
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))
Ejemplo n.º 5
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))