mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Move FlightJs out of MapModel.
This commit is contained in:
@@ -17,28 +17,12 @@ class GameUpdateSignal(QObject):
|
||||
|
||||
game_loaded = Signal(Game)
|
||||
|
||||
flight_paths_changed = Signal()
|
||||
package_selection_changed = Signal(int) # -1 indicates no selection.
|
||||
flight_selection_changed = Signal(int) # -1 indicates no selection.
|
||||
|
||||
def __init__(self):
|
||||
super(GameUpdateSignal, self).__init__()
|
||||
GameUpdateSignal.instance = self
|
||||
|
||||
self.game_loaded.connect(self.updateGame)
|
||||
|
||||
def select_package(self, index: Optional[int]) -> None:
|
||||
# noinspection PyUnresolvedReferences
|
||||
self.package_selection_changed.emit(-1 if index is None else index)
|
||||
|
||||
def select_flight(self, index: Optional[int]) -> None:
|
||||
# noinspection PyUnresolvedReferences
|
||||
self.flight_selection_changed.emit(-1 if index is None else index)
|
||||
|
||||
def redraw_flight_paths(self) -> None:
|
||||
# noinspection PyUnresolvedReferences
|
||||
self.flight_paths_changed.emit()
|
||||
|
||||
def updateGame(self, game: Optional[Game]):
|
||||
# noinspection PyUnresolvedReferences
|
||||
self.gameupdated.emit(game)
|
||||
|
||||
@@ -5,9 +5,10 @@ from PySide2.QtWidgets import (
|
||||
)
|
||||
|
||||
from game.ato.flight import Flight
|
||||
from game.server import EventStream
|
||||
from game.sim import GameUpdateEvents
|
||||
from qt_ui.models import GameModel, PackageModel
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
from qt_ui.windows.mission.flight.QFlightPlanner import QFlightPlanner
|
||||
|
||||
|
||||
@@ -24,6 +25,7 @@ class QEditFlightDialog(QDialog):
|
||||
super().__init__(parent=parent)
|
||||
|
||||
self.game_model = game_model
|
||||
self.flight = flight
|
||||
|
||||
self.setWindowTitle("Edit flight")
|
||||
self.setWindowIcon(EVENT_ICONS["strike"])
|
||||
@@ -37,5 +39,5 @@ class QEditFlightDialog(QDialog):
|
||||
self.finished.connect(self.on_close)
|
||||
|
||||
def on_close(self, _result) -> None:
|
||||
GameUpdateSignal.get_instance().redraw_flight_paths()
|
||||
EventStream.put_nowait(GameUpdateEvents().update_flight(self.flight))
|
||||
self.game_model.ato_model.client_slots_changed.emit()
|
||||
|
||||
@@ -16,14 +16,15 @@ from PySide2.QtWidgets import (
|
||||
)
|
||||
|
||||
from game.ato.flight import Flight
|
||||
from game.ato.flightplan import FlightPlanBuilder, PlanningError
|
||||
from game.ato.package import Package
|
||||
from game.game import Game
|
||||
from game.server import EventStream
|
||||
from game.sim import GameUpdateEvents
|
||||
from game.theater.missiontarget import MissionTarget
|
||||
from game.ato.flightplan import FlightPlanBuilder, PlanningError
|
||||
from qt_ui.models import AtoModel, GameModel, PackageModel
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
from qt_ui.widgets.ato import QFlightList
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
from qt_ui.windows.mission.flight.QFlightCreator import QFlightCreator
|
||||
|
||||
|
||||
@@ -141,9 +142,10 @@ class QPackageDialog(QDialog):
|
||||
def on_cancel(self) -> None:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def on_close(_result) -> None:
|
||||
GameUpdateSignal.get_instance().redraw_flight_paths()
|
||||
def on_close(self, _result) -> None:
|
||||
EventStream.put_nowait(
|
||||
GameUpdateEvents().update_flights_in_package(self.package_model.package)
|
||||
)
|
||||
|
||||
def on_save(self) -> None:
|
||||
self.save_tot()
|
||||
@@ -183,13 +185,14 @@ class QPackageDialog(QDialog):
|
||||
)
|
||||
try:
|
||||
planner.populate_flight_plan(flight)
|
||||
self.package_model.update_tot()
|
||||
EventStream.put_nowait(GameUpdateEvents().new_flight(flight))
|
||||
except PlanningError as ex:
|
||||
self.package_model.delete_flight(flight)
|
||||
logging.exception("Could not create flight")
|
||||
QMessageBox.critical(
|
||||
self, "Could not create flight", str(ex), QMessageBox.Ok
|
||||
)
|
||||
self.package_model.update_tot()
|
||||
# noinspection PyUnresolvedReferences
|
||||
self.package_changed.emit()
|
||||
|
||||
@@ -252,7 +255,7 @@ class QNewPackageDialog(QPackageDialog):
|
||||
def on_cancel(self) -> None:
|
||||
super().on_cancel()
|
||||
for flight in self.package_model.package.flights:
|
||||
flight.return_pilots_and_aircraft()
|
||||
self.package_model.delete_flight(flight)
|
||||
|
||||
|
||||
class QEditPackageDialog(QPackageDialog):
|
||||
|
||||
Reference in New Issue
Block a user