dcs-retribution/qt_ui/dialogs.py
Dan Albert ff083942e8 Replace mission planning UI.
Mission planning has been completely redone. Missions are now planned
by right clicking the target area and choosing "New package".

A package can include multiple flights for the same objective. Right
now the automatic flight planner is only fragging single-flight
packages in the same manner that it used to, but that can be improved
now.

The air tasking order (ATO) is now the left bar of the main UI. This
shows every fragged package, and the flights in the selected package.
The info bar that was previously on the left is now a smaller bar at
the bottom of the screen. The old "Mission Planning" button is now
just the "Take Off" button.

The flight plan display no longer shows enemy flight plans. That could
be re-added if needed, probably with a difficulty/cheat option.

Aircraft inventories have been disassociated from the Planner class.
Aircraft inventories are now stored globally in the Game object.

Save games made prior to this update will not be compatible do to the
changes in how aircraft inventories and planned flights are stored.
2020-09-27 13:44:58 -07:00

61 lines
2.1 KiB
Python

"""Application-wide dialog management."""
from typing import Optional
from gen.flights.flight import Flight
from theater.missiontarget import MissionTarget
from .models import GameModel, PackageModel
from .windows.mission.QEditFlightDialog import QEditFlightDialog
from .windows.mission.QPackageDialog import (
QEditPackageDialog,
QNewPackageDialog,
)
class Dialog:
"""Dialog management singleton.
Opens dialogs and keeps references to dialog windows so that their creators
do not need to worry about the lifetime of the dialog object, and can open
dialogs without needing to have their own reference to common data like the
game model.
"""
#: The game model. Is only None before initialization, as the game model
#: itself is responsible for handling the case where no game is loaded.
game_model: Optional[GameModel] = None
new_package_dialog: Optional[QNewPackageDialog] = None
edit_package_dialog: Optional[QEditPackageDialog] = None
edit_flight_dialog: Optional[QEditFlightDialog] = None
@classmethod
def set_game(cls, game_model: GameModel) -> None:
"""Sets the game model."""
cls.game_model = game_model
@classmethod
def open_new_package_dialog(cls, mission_target: MissionTarget):
"""Opens the dialog to create a new package with the given target."""
cls.new_package_dialog = QNewPackageDialog(
cls.game_model.game,
cls.game_model.ato_model,
mission_target
)
cls.new_package_dialog.show()
@classmethod
def open_edit_package_dialog(cls, package_model: PackageModel):
"""Opens the dialog to edit the given package."""
cls.edit_package_dialog = QEditPackageDialog(
cls.game_model.game,
cls.game_model.ato_model,
package_model
)
cls.edit_package_dialog.show()
@classmethod
def open_edit_flight_dialog(cls, flight: Flight):
"""Opens the dialog to edit the given flight."""
cls.edit_flight_dialog = QEditFlightDialog(cls.game_model.game, flight)
cls.edit_flight_dialog.show()