mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
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.
This commit is contained in:
@@ -17,6 +17,7 @@ from game import Game, db
|
||||
from game.data.radar_db import UNITS_WITH_RADAR
|
||||
from gen import Conflict
|
||||
from gen.flights.flight import Flight
|
||||
from qt_ui.models import GameModel
|
||||
from qt_ui.widgets.map.QLiberationScene import QLiberationScene
|
||||
from qt_ui.widgets.map.QMapControlPoint import QMapControlPoint
|
||||
from qt_ui.widgets.map.QMapGroundObject import QMapGroundObject
|
||||
@@ -37,9 +38,10 @@ class QLiberationMap(QGraphicsView):
|
||||
"flight_paths": False
|
||||
}
|
||||
|
||||
def __init__(self, game: Game):
|
||||
def __init__(self, game_model: GameModel):
|
||||
super(QLiberationMap, self).__init__()
|
||||
QLiberationMap.instance = self
|
||||
self.game_model = game_model
|
||||
|
||||
self.frontline_vector_cache = {}
|
||||
|
||||
@@ -50,7 +52,7 @@ class QLiberationMap(QGraphicsView):
|
||||
self.factorized = 1
|
||||
self.init_scene()
|
||||
self.connectSignals()
|
||||
self.setGame(game)
|
||||
self.setGame(game_model.game)
|
||||
|
||||
def init_scene(self):
|
||||
scene = QLiberationScene(self)
|
||||
@@ -129,8 +131,10 @@ class QLiberationMap(QGraphicsView):
|
||||
|
||||
pos = self._transform_point(cp.position)
|
||||
|
||||
scene.addItem(QMapControlPoint(self, pos[0] - CONST.CP_SIZE / 2, pos[1] - CONST.CP_SIZE / 2, CONST.CP_SIZE,
|
||||
CONST.CP_SIZE, cp, self.game))
|
||||
scene.addItem(QMapControlPoint(self, pos[0] - CONST.CP_SIZE / 2,
|
||||
pos[1] - CONST.CP_SIZE / 2,
|
||||
CONST.CP_SIZE,
|
||||
CONST.CP_SIZE, cp, self.game_model))
|
||||
|
||||
if cp.captured:
|
||||
pen = QPen(brush=CONST.COLORS[playerColor])
|
||||
@@ -185,11 +189,9 @@ class QLiberationMap(QGraphicsView):
|
||||
text.setPos(pos[0] + CONST.CP_SIZE + 1, pos[1] - CONST.CP_SIZE / 2 + 1)
|
||||
|
||||
def draw_flight_plans(self, scene) -> None:
|
||||
for cp in self.game.theater.controlpoints:
|
||||
if cp.id in self.game.planners:
|
||||
planner = self.game.planners[cp.id]
|
||||
for flight in planner.flights:
|
||||
self.draw_flight_plan(scene, flight)
|
||||
for package in self.game_model.ato_model.packages:
|
||||
for flight in package.flights:
|
||||
self.draw_flight_plan(scene, flight)
|
||||
|
||||
def draw_flight_plan(self, scene: QGraphicsScene, flight: Flight) -> None:
|
||||
is_player = flight.from_cp.captured
|
||||
|
||||
@@ -1,29 +1,23 @@
|
||||
from typing import Optional
|
||||
|
||||
from PySide2.QtGui import QColor, QPainter
|
||||
from PySide2.QtWidgets import (
|
||||
QAction,
|
||||
QGraphicsSceneContextMenuEvent,
|
||||
QMenu,
|
||||
)
|
||||
|
||||
import qt_ui.uiconstants as const
|
||||
from game import Game
|
||||
from qt_ui.models import GameModel
|
||||
from qt_ui.windows.basemenu.QBaseMenu2 import QBaseMenu2
|
||||
from theater import ControlPoint
|
||||
from .QMapObject import QMapObject
|
||||
|
||||
|
||||
class QMapControlPoint(QMapObject):
|
||||
|
||||
def __init__(self, parent, x: float, y: float, w: float, h: float,
|
||||
model: ControlPoint, game: Game) -> None:
|
||||
super().__init__(x, y, w, h)
|
||||
self.model = model
|
||||
self.game = game
|
||||
control_point: ControlPoint, game_model: GameModel) -> None:
|
||||
super().__init__(x, y, w, h, mission_target=control_point)
|
||||
self.game_model = game_model
|
||||
self.control_point = control_point
|
||||
self.parent = parent
|
||||
self.setZValue(1)
|
||||
self.setToolTip(self.model.name)
|
||||
self.setToolTip(self.control_point.name)
|
||||
self.base_details_dialog: Optional[QBaseMenu2] = None
|
||||
|
||||
def paint(self, painter, option, widget=None) -> None:
|
||||
@@ -33,7 +27,7 @@ class QMapControlPoint(QMapObject):
|
||||
painter.setBrush(self.brush_color)
|
||||
painter.setPen(self.pen_color)
|
||||
|
||||
if self.model.has_runway():
|
||||
if self.control_point.has_runway():
|
||||
if self.isUnderMouse():
|
||||
painter.setBrush(const.COLORS["white"])
|
||||
painter.setPen(self.pen_color)
|
||||
@@ -44,22 +38,9 @@ class QMapControlPoint(QMapObject):
|
||||
# Either don't draw them at all, or perhaps use a sunk ship icon.
|
||||
painter.restore()
|
||||
|
||||
def contextMenuEvent(self, event: QGraphicsSceneContextMenuEvent) -> None:
|
||||
if self.model.captured:
|
||||
text = "Open base menu"
|
||||
else:
|
||||
text = "Open intel menu"
|
||||
|
||||
open_menu = QAction(text)
|
||||
open_menu.triggered.connect(self.on_click)
|
||||
|
||||
menu = QMenu("Menu", self.parent)
|
||||
menu.addAction(open_menu)
|
||||
menu.exec_(event.screenPos())
|
||||
|
||||
@property
|
||||
def brush_color(self) -> QColor:
|
||||
if self.model.captured:
|
||||
if self.control_point.captured:
|
||||
return const.COLORS["blue"]
|
||||
else:
|
||||
return const.COLORS["super_red"]
|
||||
@@ -68,10 +49,17 @@ class QMapControlPoint(QMapObject):
|
||||
def pen_color(self) -> QColor:
|
||||
return const.COLORS["white"]
|
||||
|
||||
@property
|
||||
def object_dialog_text(self) -> str:
|
||||
if self.control_point.captured:
|
||||
return "Open base menu"
|
||||
else:
|
||||
return "Open intel menu"
|
||||
|
||||
def on_click(self) -> None:
|
||||
self.base_details_dialog = QBaseMenu2(
|
||||
self.window(),
|
||||
self.model,
|
||||
self.game
|
||||
self.control_point,
|
||||
self.game_model
|
||||
)
|
||||
self.base_details_dialog.show()
|
||||
|
||||
@@ -14,11 +14,12 @@ from .QMapObject import QMapObject
|
||||
|
||||
class QMapGroundObject(QMapObject):
|
||||
def __init__(self, parent, x: float, y: float, w: float, h: float,
|
||||
cp: ControlPoint, model: TheaterGroundObject, game: Game,
|
||||
control_point: ControlPoint,
|
||||
ground_object: TheaterGroundObject, game: Game,
|
||||
buildings: Optional[List[TheaterGroundObject]] = None) -> None:
|
||||
super().__init__(x, y, w, h)
|
||||
self.model = model
|
||||
self.cp = cp
|
||||
super().__init__(x, y, w, h, mission_target=ground_object)
|
||||
self.ground_object = ground_object
|
||||
self.control_point = control_point
|
||||
self.parent = parent
|
||||
self.game = game
|
||||
self.setZValue(2)
|
||||
@@ -26,21 +27,20 @@ class QMapGroundObject(QMapObject):
|
||||
self.setFlag(QGraphicsItem.ItemIgnoresTransformations, False)
|
||||
self.ground_object_dialog: Optional[QGroundObjectMenu] = None
|
||||
|
||||
if len(self.model.groups) > 0:
|
||||
if self.ground_object.groups:
|
||||
units = {}
|
||||
for g in self.model.groups:
|
||||
print(g)
|
||||
for g in self.ground_object.groups:
|
||||
for u in g.units:
|
||||
if u.type in units:
|
||||
units[u.type] = units[u.type]+1
|
||||
else:
|
||||
units[u.type] = 1
|
||||
tooltip = "[" + self.model.obj_name + "]" + "\n"
|
||||
tooltip = "[" + self.ground_object.obj_name + "]" + "\n"
|
||||
for unit in units.keys():
|
||||
tooltip = tooltip + str(unit) + "x" + str(units[unit]) + "\n"
|
||||
self.setToolTip(tooltip[:-1])
|
||||
else:
|
||||
tooltip = "[" + self.model.obj_name + "]" + "\n"
|
||||
tooltip = "[" + self.ground_object.obj_name + "]" + "\n"
|
||||
for building in buildings:
|
||||
if not building.is_dead:
|
||||
tooltip = tooltip + str(building.dcs_identifier) + "\n"
|
||||
@@ -53,20 +53,20 @@ class QMapGroundObject(QMapObject):
|
||||
if self.parent.get_display_rule("go"):
|
||||
painter.save()
|
||||
|
||||
cat = self.model.category
|
||||
if cat == "aa" and self.model.sea_object:
|
||||
cat = self.ground_object.category
|
||||
if cat == "aa" and self.ground_object.sea_object:
|
||||
cat = "ship"
|
||||
|
||||
rect = QRect(option.rect.x() + 2, option.rect.y(),
|
||||
option.rect.width() - 2, option.rect.height())
|
||||
|
||||
is_dead = self.model.is_dead
|
||||
is_dead = self.ground_object.is_dead
|
||||
for building in self.buildings:
|
||||
if not building.is_dead:
|
||||
is_dead = False
|
||||
break
|
||||
|
||||
if not is_dead and not self.cp.captured:
|
||||
if not is_dead and not self.control_point.captured:
|
||||
painter.drawPixmap(rect, const.ICONS[cat + enemy_icons])
|
||||
elif not is_dead:
|
||||
painter.drawPixmap(rect, const.ICONS[cat + player_icons])
|
||||
@@ -80,7 +80,7 @@ class QMapGroundObject(QMapObject):
|
||||
units_alive = 0
|
||||
units_dead = 0
|
||||
|
||||
if len(self.model.groups) == 0:
|
||||
if len(self.ground_object.groups) == 0:
|
||||
for building in self.buildings:
|
||||
if building.dcs_identifier in FORTIFICATION_BUILDINGS:
|
||||
continue
|
||||
@@ -89,7 +89,7 @@ class QMapGroundObject(QMapObject):
|
||||
else:
|
||||
units_alive += 1
|
||||
|
||||
for g in self.model.groups:
|
||||
for g in self.ground_object.groups:
|
||||
units_alive += len(g.units)
|
||||
if hasattr(g, "units_losts"):
|
||||
units_dead += len(g.units_losts)
|
||||
@@ -106,9 +106,9 @@ class QMapGroundObject(QMapObject):
|
||||
def on_click(self) -> None:
|
||||
self.ground_object_dialog = QGroundObjectMenu(
|
||||
self.window(),
|
||||
self.model,
|
||||
self.ground_object,
|
||||
self.buildings,
|
||||
self.cp,
|
||||
self.control_point,
|
||||
self.game
|
||||
)
|
||||
self.ground_object_dialog.show()
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
"""Common base for objects drawn on the game map."""
|
||||
from typing import Optional
|
||||
|
||||
from PySide2.QtCore import Qt
|
||||
from PySide2.QtWidgets import (
|
||||
QAction,
|
||||
QGraphicsRectItem,
|
||||
QGraphicsSceneContextMenuEvent,
|
||||
QGraphicsSceneHoverEvent,
|
||||
QGraphicsSceneMouseEvent,
|
||||
QMenu,
|
||||
)
|
||||
|
||||
from qt_ui.dialogs import Dialog
|
||||
from qt_ui.windows.mission.QPackageDialog import QNewPackageDialog
|
||||
from theater.missiontarget import MissionTarget
|
||||
|
||||
|
||||
class QMapObject(QGraphicsRectItem):
|
||||
"""Base class for objects drawn on the game map.
|
||||
@@ -13,8 +22,12 @@ class QMapObject(QGraphicsRectItem):
|
||||
Game map objects have an on_click behavior that triggers on left click, and
|
||||
change the mouse cursor on hover.
|
||||
"""
|
||||
def __init__(self, x: float, y: float, w: float, h: float):
|
||||
|
||||
def __init__(self, x: float, y: float, w: float, h: float,
|
||||
mission_target: MissionTarget) -> None:
|
||||
super().__init__(x, y, w, h)
|
||||
self.mission_target = mission_target
|
||||
self.new_package_dialog: Optional[QNewPackageDialog] = None
|
||||
self.setAcceptHoverEvents(True)
|
||||
|
||||
def hoverEnterEvent(self, event: QGraphicsSceneHoverEvent):
|
||||
@@ -24,5 +37,39 @@ class QMapObject(QGraphicsRectItem):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.on_click()
|
||||
|
||||
def contextMenuEvent(self, event: QGraphicsSceneContextMenuEvent) -> None:
|
||||
menu = QMenu("Menu", self.parent)
|
||||
|
||||
object_details_action = QAction(self.object_dialog_text)
|
||||
object_details_action.triggered.connect(self.on_click)
|
||||
menu.addAction(object_details_action)
|
||||
|
||||
new_package_action = QAction(f"New package")
|
||||
new_package_action.triggered.connect(self.open_new_package_dialog)
|
||||
menu.addAction(new_package_action)
|
||||
|
||||
menu.exec_(event.screenPos())
|
||||
|
||||
@property
|
||||
def object_dialog_text(self) -> str:
|
||||
"""Text to for the object's dialog in the context menu.
|
||||
|
||||
Right clicking a map object will open a context menu and the first item
|
||||
will open the details dialog for this object. This menu action has the
|
||||
same behavior as the on_click event.
|
||||
|
||||
Return:
|
||||
The text that should be displayed for the menu item.
|
||||
"""
|
||||
return "Details"
|
||||
|
||||
def on_click(self) -> None:
|
||||
"""The action to take when this map object is left-clicked.
|
||||
|
||||
Typically this should open a details view of the object.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def open_new_package_dialog(self) -> None:
|
||||
"""Opens the dialog for planning a new mission package."""
|
||||
Dialog.open_new_package_dialog(self.mission_target)
|
||||
|
||||
Reference in New Issue
Block a user