def on_attack(self):
     # TODO: Maintain Convoy list in Game.
     # The fact that we create these here makes some of the other bookkeeping
     # complicated. We could instead generate this at the start of the turn (and
     # update whenever transfers are created or canceled) and also use that time to
     # precalculate things like the next stop and group names.
     Dialog.open_new_package_dialog(self.convoy, parent=self.window())
Esempio n. 2
0
 def new_package(self) -> None:
     Dialog.open_new_package_dialog(self.cp, parent=self.window())
    def __init__(self, game: Game | None, dev: bool) -> None:
        super().__init__()

        self._uncaught_exception_handler = UncaughtExceptionHandler(self)

        self.game = game
        self.sim_controller = SimController(self.game)
        self.sim_controller.sim_update.connect(EventStream.put_nowait)
        self.game_model = GameModel(game, self.sim_controller)
        GameContext.set_model(self.game_model)
        self.new_package_signal.connect(
            lambda target: Dialog.open_new_package_dialog(target, self))
        self.tgo_info_signal.connect(self.open_tgo_info_dialog)
        self.control_point_info_signal.connect(
            self.open_control_point_info_dialog)
        QtContext.set_callbacks(
            QtCallbacks(
                lambda target: self.new_package_signal.emit(target),
                lambda tgo: self.tgo_info_signal.emit(tgo),
                lambda cp: self.control_point_info_signal.emit(cp),
            ))
        Dialog.set_game(self.game_model)
        self.ato_panel = QAirTaskingOrderPanel(self.game_model)
        self.info_panel = QInfoPanel(self.game)
        self.liberation_map = QLiberationMap(self.game_model, dev, self)

        self.setGeometry(300, 100, 270, 100)
        self.updateWindowTitle()
        self.setWindowIcon(QIcon("./resources/icon.png"))
        self.statusBar().showMessage("Ready")

        self.initUi()
        self.initActions()
        self.initToolbar()
        self.initMenuBar()
        self.connectSignals()

        # Default to maximized on the main display if we don't have any persistent
        # configuration.
        screen = QDesktopWidget().screenGeometry()
        self.setGeometry(0, 0, screen.width(), screen.height())
        self.setWindowState(Qt.WindowMaximized)

        # But override it with the saved configuration if it exists.
        self._restore_window_geometry()

        if self.game is None:
            last_save_file = liberation_install.get_last_save_file()
            if last_save_file:
                try:
                    logging.info("Loading last saved game : " +
                                 str(last_save_file))
                    game = persistency.load_game(last_save_file)
                    self.onGameGenerated(game)
                    self.updateWindowTitle(last_save_file if game else None)
                except:
                    logging.info("Error loading latest save game")
            else:
                logging.info("No existing save game")
        else:
            self.onGameGenerated(self.game)
Esempio n. 4
0
 def open_new_package_dialog(self) -> None:
     """Opens the dialog for planning a new mission package."""
     Dialog.open_new_package_dialog(self.mission_target)
Esempio n. 5
0
 def onAttack(self):
     Dialog.open_new_package_dialog(self.ground_object,
                                    parent=self.window())
Esempio n. 6
0
 def showPackageDialog(self) -> None:
     Dialog.open_new_package_dialog(self.front_line)
Esempio n. 7
0
 def showPackageDialog(self) -> None:
     Dialog.open_new_package_dialog(self.tgo)
Esempio n. 8
0
 def showPackageDialog(self) -> None:
     Dialog.open_new_package_dialog(self.control_point)