def openFile(self): file = QFileDialog.getOpenFileName( self, "Select game file to open", dir=persistency._dcs_saved_game_folder, filter="*.liberation") if file is not None: game = persistency.load_game(file[0]) GameUpdateSignal.get_instance().updateGame(game)
def openFile(self): if self.game is not None and self.game.savepath: save_dir = self.game.savepath else: save_dir = str(persistency.save_dir()) file = QFileDialog.getOpenFileName( self, "Select game file to open", dir=save_dir, filter="*.liberation", ) if file is not None and file[0] != "": game = persistency.load_game(file[0]) GameUpdateSignal.get_instance().game_loaded.emit(game) self.updateWindowTitle(file[0])
def __init__(self, game: Optional[Game]) -> None: super(QLiberationWindow, self).__init__() self.game = game self.game_model = GameModel(game) 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, 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() screen = QDesktopWidget().screenGeometry() self.setGeometry(0, 0, screen.width(), screen.height()) self.setWindowState(Qt.WindowMaximized) 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)
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)