From c203ded1cdc43997aa4f3c78fd51c13d64de8fec Mon Sep 17 00:00:00 2001 From: Khopa Date: Mon, 1 Jun 2020 12:36:10 +0200 Subject: [PATCH] Improved Mission Planning flight selection behaviour. --- changelog.md | 19 ++++++++++++++++ game/db.py | 10 ++++++++- gen/briefinggen.py | 2 +- gen/flights/ai_flight_planner.py | 6 ++--- qt_ui/windows/mission/QMissionPlanning.py | 22 ++++++++++++++----- qt_ui/windows/mission/QPlannedFlightsView.py | 21 +++++++++++++----- .../windows/mission/flight/QFlightCreator.py | 2 +- .../windows/mission/flight/QFlightPlanner.py | 9 +++++++- 8 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 changelog.md diff --git a/changelog.md b/changelog.md new file mode 100644 index 00000000..9585f432 --- /dev/null +++ b/changelog.md @@ -0,0 +1,19 @@ +2.0 RC 6 +-------- + +Features/Improvements : +* Supercarrier support (You have to go to settings to enable it, if you have the supercarrier module) +* Carrier ICLS channel will now be configured (check your briefing) +* When a base is captured, refill the "base defenses" group with units for the new owner. +* SAM units will spawn on RED Alarm state +* AI Flight planner now creates its own STRIKE flights +* Added performance settings to allow disabling : smoke, artillery strike, moving units, infantry, SAM alert mode. +* Added support for newest WW2 Units + +Fixes : + +* Fixed : CAS waypoints created from the "Predefined waypoint selector" would not be at the exact location of the frontline +* Fixed : Game generation does not work when "no night mission" settings was selected and the current time was "day" +* Fixed : Game generation does not work when the player selected faction has no AWACS +* Fixed : Base defenses would not be generated on normandy map +* Fixed : CAP mission flown from airbase are not named BARCAP anymore (CAP from carrier is still named BARCAP) diff --git a/game/db.py b/game/db.py index ec75f934..66118d51 100644 --- a/game/db.py +++ b/game/db.py @@ -681,7 +681,15 @@ PLANE_PAYLOAD_OVERRIDES = { AntishipStrike: "ANTISHIP", GroundAttack: "STRIKE" }, - + F_A_18C: { + CAP: "CAP HEAVY", + Intercept: "CAP HEAVY", + CAS: "CAS MAVERICK F", + PinpointStrike: "STRIKE", + SEAD: "SEAD", + AntishipStrike: "ANTISHIP", + GroundAttack: "STRIKE" + }, A_10A: COMMON_OVERRIDE, A_10C: COMMON_OVERRIDE, AV8BNA: COMMON_OVERRIDE, diff --git a/gen/briefinggen.py b/gen/briefinggen.py index d8fd32a8..e367996d 100644 --- a/gen/briefinggen.py +++ b/gen/briefinggen.py @@ -65,7 +65,7 @@ class BriefingGenerator: self.description += "-" * 50 + "\n" for name, freq in self.freqs: self.description += "\n{}: {}".format(name, freq) - self.description += "\n-" * 50 + "\n" + self.description += "\n" + ("-" * 50) + "\n" for cp in self.game.theater.controlpoints: if cp.captured and cp.cptype in [ControlPointType.LHA_GROUP, ControlPointType.AIRCRAFT_CARRIER_GROUP]: self.description += cp.name + " TACAN : " diff --git a/gen/flights/ai_flight_planner.py b/gen/flights/ai_flight_planner.py index b43e1d55..05b53267 100644 --- a/gen/flights/ai_flight_planner.py +++ b/gen/flights/ai_flight_planner.py @@ -59,7 +59,7 @@ class FlightPlanner: #self.commision_interceptors() # Then some CAP patrol for the next 2 hours - self.commision_barcap() + self.commision_cap() # Then setup cas self.commision_cas() @@ -115,7 +115,7 @@ class FlightPlanner: for k, v in inventory.items(): self.aircraft_inventory[k] = v - def commision_barcap(self): + def commision_cap(self): """ Pick some aircraft to assign them to defensive CAP roles (BARCAP) """ @@ -153,7 +153,7 @@ class FlightPlanner: if len(flight.points) == 0: for i in range(3): - pos = self.from_cp.position.point_from_heading(random.randint(0,360), random.randint(30000, 80000)) + pos = self.from_cp.position.point_from_heading(random.randint(0, 360), random.randint(30000, 80000)) point = FlightWaypoint(pos.x, pos.y, patrol_alt) point.name = "Patrol point" point.description = "Patrol #" + str(len(flight.points)) diff --git a/qt_ui/windows/mission/QMissionPlanning.py b/qt_ui/windows/mission/QMissionPlanning.py index 0d036e45..96a467ec 100644 --- a/qt_ui/windows/mission/QMissionPlanning.py +++ b/qt_ui/windows/mission/QMissionPlanning.py @@ -38,7 +38,7 @@ class QMissionPlanning(QDialog): self.planned_flight_view.set_flight_planner(self.planner) self.selected_cp = self.captured_cp[0] - self.planned_flight_view.selectionModel().setCurrentIndex(self.planned_flight_view.indexAt(QPoint(1, 1)), QItemSelectionModel.Select) + self.planned_flight_view.selectionModel().setCurrentIndex(self.planned_flight_view.indexAt(QPoint(1, 1)), QItemSelectionModel.Rows) self.planned_flight_view.selectionModel().selectionChanged.connect(self.on_flight_selection_change) if len(self.planned_flight_view.flight_planner.flights) > 0: @@ -83,15 +83,24 @@ class QMissionPlanning(QDialog): else: self.planned_flight_view.set_flight_planner(None) - print(self.selected_cp.id) - def on_flight_selection_change(self): - index = self.planned_flight_view.selectionModel().currentIndex().row() - flight = self.planner.flights[index] + print("On flight selection change") + + index = self.planned_flight_view.selectionModel().currentIndex().row() + self.planned_flight_view.repaint(); + + if self.flight_planner is not None: + self.flight_planner.clearTabs() + + try: + flight = self.planner.flights[index] + except IndexError: + flight = None self.flight_planner = QFlightPlanner(flight, self.game, self.planner) self.layout.addWidget(self.flight_planner, 0, 1) + def on_add_flight(self): possible_aircraft_type = list(self.selected_cp.base.aircraft.keys()) @@ -110,7 +119,8 @@ class QMissionPlanning(QDialog): def on_delete_flight(self): index = self.planned_flight_view.selectionModel().currentIndex().row() self.planner.remove_flight(index) - self.planned_flight_view.set_flight_planner(self.planner) + self.planned_flight_view.set_flight_planner(self.planner, index) + def on_start(self): diff --git a/qt_ui/windows/mission/QPlannedFlightsView.py b/qt_ui/windows/mission/QPlannedFlightsView.py index 3d6c0ff2..38e280df 100644 --- a/qt_ui/windows/mission/QPlannedFlightsView.py +++ b/qt_ui/windows/mission/QPlannedFlightsView.py @@ -1,6 +1,6 @@ -from PySide2.QtCore import QSize +from PySide2.QtCore import QSize, QItemSelectionModel, QPoint from PySide2.QtGui import QStandardItemModel -from PySide2.QtWidgets import QListView +from PySide2.QtWidgets import QListView, QAbstractItemView from gen.flights.ai_flight_planner import FlightPlanner from qt_ui.windows.mission.QFlightItem import QFlightItem @@ -13,18 +13,29 @@ class QPlannedFlightsView(QListView): self.model = QStandardItemModel(self) self.setModel(self.model) self.setIconSize(QSize(91, 24)) + self.setSelectionBehavior(QAbstractItemView.SelectItems) if flight_planner: self.set_flight_planner(flight_planner) - def update_content(self): + def update_content(self, row=0): for i, f in enumerate(self.flight_planner.flights): self.model.appendRow(QFlightItem(f)) + self.setSelectedFlight(row) + self.repaint() + + def setSelectedFlight(self, row): + self.selectionModel().clearSelection() + index = self.model.index(row, 0) + if not index.isValid(): + index = self.model.index(0, 0) + self.selectionModel().setCurrentIndex(index, QItemSelectionModel.Select) + self.repaint() def clear_layout(self): self.model.removeRows(0, self.model.rowCount()) - def set_flight_planner(self, flight_planner: FlightPlanner): + def set_flight_planner(self, flight_planner: FlightPlanner, row=0): self.clear_layout() self.flight_planner = flight_planner if self.flight_planner: - self.update_content() + self.update_content(row) diff --git a/qt_ui/windows/mission/flight/QFlightCreator.py b/qt_ui/windows/mission/flight/QFlightCreator.py index 94bdf1bf..2ee1c9d7 100644 --- a/qt_ui/windows/mission/flight/QFlightCreator.py +++ b/qt_ui/windows/mission/flight/QFlightCreator.py @@ -111,6 +111,6 @@ class QFlightCreator(QDialog): self.planner.flights.append(flight) self.planner.custom_flights.append(flight) if self.flight_view is not None: - self.flight_view.set_flight_planner(self.planner) + self.flight_view.set_flight_planner(self.planner, len(self.planner.flights)-1) self.close() diff --git a/qt_ui/windows/mission/flight/QFlightPlanner.py b/qt_ui/windows/mission/flight/QFlightPlanner.py index c8f34751..47ffe10f 100644 --- a/qt_ui/windows/mission/flight/QFlightPlanner.py +++ b/qt_ui/windows/mission/flight/QFlightPlanner.py @@ -11,6 +11,7 @@ class QFlightPlanner(QTabWidget): def __init__(self, flight: Flight, game: Game, planner): super(QFlightPlanner, self).__init__() + self.tabCount = 0 if flight: self.general_settings_tab = QGeneralFlightSettingsTab(flight, game, planner) self.payload_tab = QFlightPayloadTab(flight, game) @@ -18,9 +19,15 @@ class QFlightPlanner(QTabWidget): self.addTab(self.general_settings_tab, "General Flight settings") self.addTab(self.payload_tab, "Payload") self.addTab(self.waypoint_tab, "Waypoints") + self.tabCount = 3 else: tabError = QFrame() l = QGridLayout() l.addWidget(QLabel("No flight selected")) tabError.setLayout(l) - self.addTab(tabError, "No flight") \ No newline at end of file + self.addTab(tabError, "No flight") + self.tabCount = 1 + + def clearTabs(self): + for i in range(self.tabCount): + self.removeTab(i) \ No newline at end of file