mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Improved base menu to show planned AI flights and base defence. (WIP)
This commit is contained in:
parent
827138fc6a
commit
48748bbc39
@ -773,7 +773,7 @@ def task_name(task) -> str:
|
||||
elif task == Embarking:
|
||||
return "Transportation"
|
||||
elif task == PinpointStrike:
|
||||
return "Ground units"
|
||||
return "Frontline units"
|
||||
else:
|
||||
return task.name
|
||||
|
||||
|
||||
33
qt_ui/widgets/QBaseInformation.py
Normal file
33
qt_ui/widgets/QBaseInformation.py
Normal file
@ -0,0 +1,33 @@
|
||||
from PySide2.QtWidgets import QGridLayout, QLabel, QGroupBox
|
||||
|
||||
from game import db
|
||||
from theater import ControlPoint, Airport
|
||||
|
||||
|
||||
class QBaseInformation(QGroupBox):
|
||||
|
||||
def __init__(self, cp:ControlPoint, airport:Airport):
|
||||
super(QBaseInformation, self).__init__("Base defenses")
|
||||
self.cp = cp
|
||||
self.airport = airport
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
self.layout = QGridLayout()
|
||||
|
||||
unit_dict = {}
|
||||
for g in self.cp.ground_objects:
|
||||
if g.airbase_group:
|
||||
for group in g.groups:
|
||||
for u in group.units:
|
||||
if u.type in unit_dict.keys():
|
||||
unit_dict[u.type] = unit_dict[u.type] + 1
|
||||
else:
|
||||
unit_dict[u.type] = 1
|
||||
|
||||
i = 0
|
||||
for k,v in unit_dict.items():
|
||||
self.layout.addWidget(QLabel(str(v) + " x " + k), i, 0)
|
||||
i = i + 1
|
||||
|
||||
self.setLayout(self.layout)
|
||||
27
qt_ui/widgets/QPlannedFlightView.py
Normal file
27
qt_ui/widgets/QPlannedFlightView.py
Normal file
@ -0,0 +1,27 @@
|
||||
from PySide2.QtWidgets import QGridLayout, QLabel, QGroupBox
|
||||
|
||||
from game import db
|
||||
from gen.flights.ai_flight_planner import FlightPlanner
|
||||
|
||||
|
||||
class QPlannedFlightView(QGroupBox):
|
||||
|
||||
def __init__(self, flight_planner:FlightPlanner):
|
||||
super(QPlannedFlightView, self).__init__("Planned flights")
|
||||
self.flight_planner = flight_planner
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
self.layout = QGridLayout()
|
||||
|
||||
for i,f in enumerate(self.flight_planner.flights):
|
||||
ftype = QLabel("<b>" + f.flight_type.name + "</b>")
|
||||
count = QLabel(str(f.count) + "x" + db.unit_type_name(f.unit_type))
|
||||
sched = QLabel(" in " + str(f.scheduled_in) + " minutes")
|
||||
|
||||
self.layout.addWidget(ftype, i, 0)
|
||||
self.layout.addWidget(count, i, 1)
|
||||
self.layout.addWidget(sched, i, 2)
|
||||
|
||||
|
||||
self.setLayout(self.layout)
|
||||
@ -5,6 +5,8 @@ from PySide2.QtWidgets import QHBoxLayout, QLabel, QWidget, QFrame, QDialog, QVB
|
||||
from dcs.unittype import UnitType
|
||||
|
||||
from game.event import UnitsDeliveryEvent
|
||||
from qt_ui.widgets.QBaseInformation import QBaseInformation
|
||||
from qt_ui.widgets.QPlannedFlightView import QPlannedFlightView
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
from theater import ControlPoint, CAP, Embarking, AirDefence, CAS, PinpointStrike, db
|
||||
from game import Game
|
||||
@ -14,9 +16,15 @@ class QBaseMenu(QDialog):
|
||||
|
||||
def __init__(self, parent, controlPoint: ControlPoint, game: Game):
|
||||
super(QBaseMenu, self).__init__(parent)
|
||||
|
||||
self.cp = controlPoint
|
||||
self.game = game
|
||||
|
||||
try:
|
||||
self.airport = game.theater.terrain.airport_by_id(self.cp.id)
|
||||
except:
|
||||
self.airport = None
|
||||
|
||||
|
||||
if self.cp.captured:
|
||||
self.deliveryEvent = None
|
||||
@ -68,8 +76,10 @@ class QBaseMenu(QDialog):
|
||||
PinpointStrike: db.find_unittype(PinpointStrike, self.game.enemy_name),
|
||||
}
|
||||
|
||||
self.mainLayout = QVBoxLayout()
|
||||
self.mainLayout.addWidget(self.topLayoutWidget)
|
||||
self.mainLayout = QGridLayout()
|
||||
|
||||
self.leftLayout = QVBoxLayout()
|
||||
self.leftLayout.addWidget(self.topLayoutWidget)
|
||||
|
||||
tasks = list(units.keys())
|
||||
tasks_per_column = 3
|
||||
@ -123,7 +133,7 @@ class QBaseMenu(QDialog):
|
||||
add_purchase_row(unit_type, taskBoxLayout)
|
||||
|
||||
self.unitLayout.addWidget(taskBox)
|
||||
self.mainLayout.addLayout(self.unitLayout)
|
||||
self.leftLayout.addLayout(self.unitLayout)
|
||||
else:
|
||||
intel = QGroupBox("Intel")
|
||||
intelLayout = QVBoxLayout()
|
||||
@ -148,7 +158,15 @@ class QBaseMenu(QDialog):
|
||||
row += 1
|
||||
|
||||
intelLayout.addWidget(group)
|
||||
self.mainLayout.addLayout(intelLayout)
|
||||
self.leftLayout.addLayout(intelLayout)
|
||||
|
||||
self.mainLayout.addLayout(self.leftLayout, 0, 0)
|
||||
|
||||
try:
|
||||
self.mainLayout.addWidget(QPlannedFlightView(self.game.planners[self.cp.id]), 0, 1)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.mainLayout.addWidget(QBaseInformation(self.cp, self.airport), 0, 3)
|
||||
|
||||
self.setLayout(self.mainLayout)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user