mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
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.
136 lines
4.7 KiB
Python
136 lines
4.7 KiB
Python
from PySide2.QtWidgets import (
|
|
QGroupBox,
|
|
QHBoxLayout,
|
|
QLabel,
|
|
QPushButton,
|
|
QSizePolicy,
|
|
QSpacerItem,
|
|
)
|
|
from dcs.unittype import UnitType
|
|
|
|
from theater import db
|
|
|
|
|
|
class QRecruitBehaviour:
|
|
BUDGET_FORMAT = "Available Budget: <b>${}M</b>"
|
|
|
|
def __init__(self) -> None:
|
|
self.deliveryEvent = None
|
|
self.bought_amount_labels = {}
|
|
self.existing_units_labels = {}
|
|
self.update_available_budget()
|
|
|
|
@property
|
|
def budget(self) -> int:
|
|
return self.game_model.game.budget
|
|
|
|
@budget.setter
|
|
def budget(self, value: int) -> None:
|
|
self.game_model.game.budget = value
|
|
|
|
def add_purchase_row(self, unit_type, layout, row):
|
|
exist = QGroupBox()
|
|
exist.setProperty("style", "buy-box")
|
|
exist.setMaximumHeight(36)
|
|
exist.setMinimumHeight(36)
|
|
existLayout = QHBoxLayout()
|
|
exist.setLayout(existLayout)
|
|
|
|
existing_units = self.cp.base.total_units_of_type(unit_type)
|
|
scheduled_units = self.deliveryEvent.units.get(unit_type, 0)
|
|
|
|
unitName = QLabel("<b>" + db.unit_type_name_2(unit_type) + "</b>")
|
|
unitName.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
|
|
|
|
existing_units = QLabel(str(existing_units))
|
|
existing_units.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
|
|
|
|
amount_bought = QLabel("<b>{}</b>".format(str(scheduled_units)))
|
|
amount_bought.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
|
|
|
|
self.existing_units_labels[unit_type] = existing_units
|
|
self.bought_amount_labels[unit_type] = amount_bought
|
|
|
|
price = QLabel("<b>$ {:02d}</b> m".format(db.PRICES[unit_type]))
|
|
price.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
|
|
|
|
buysell = QGroupBox()
|
|
buysell.setProperty("style", "buy-box")
|
|
buysell.setMaximumHeight(36)
|
|
buysell.setMinimumHeight(36)
|
|
buysellayout = QHBoxLayout()
|
|
buysell.setLayout(buysellayout)
|
|
|
|
buy = QPushButton("+")
|
|
buy.setProperty("style", "btn-buy")
|
|
buy.setMinimumSize(16, 16)
|
|
buy.setMaximumSize(16, 16)
|
|
buy.clicked.connect(lambda: self.buy(unit_type))
|
|
buy.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
|
|
|
|
sell = QPushButton("-")
|
|
sell.setProperty("style", "btn-sell")
|
|
sell.setMinimumSize(16, 16)
|
|
sell.setMaximumSize(16, 16)
|
|
sell.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
|
|
sell.clicked.connect(lambda: self.sell(unit_type))
|
|
|
|
|
|
existLayout.addWidget(unitName)
|
|
existLayout.addItem(QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Minimum))
|
|
existLayout.addWidget(existing_units)
|
|
existLayout.addItem(QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Minimum))
|
|
existLayout.addWidget(price)
|
|
|
|
buysellayout.addWidget(sell)
|
|
buysellayout.addWidget(amount_bought)
|
|
buysellayout.addWidget(buy)
|
|
|
|
layout.addWidget(exist, row, 1)
|
|
layout.addWidget(buysell, row, 2)
|
|
|
|
return row + 1
|
|
|
|
def _update_count_label(self, unit_type: UnitType):
|
|
|
|
self.bought_amount_labels[unit_type].setText("<b>{}</b>".format(
|
|
unit_type in self.deliveryEvent.units and "{}".format(self.deliveryEvent.units[unit_type]) or "0"
|
|
))
|
|
|
|
self.existing_units_labels[unit_type].setText("<b>{}</b>".format(
|
|
self.cp.base.total_units_of_type(unit_type)
|
|
))
|
|
|
|
def update_available_budget(self):
|
|
parent = self.parent()
|
|
while parent.objectName != "menuDialogue":
|
|
parent = parent.parent()
|
|
for child in parent.children():
|
|
if child.objectName() == "budgetField":
|
|
child.setText(
|
|
QRecruitBehaviour.BUDGET_FORMAT.format(self.budget))
|
|
|
|
def buy(self, unit_type):
|
|
|
|
price = db.PRICES[unit_type]
|
|
if self.budget >= price:
|
|
self.deliveryEvent.deliver({unit_type: 1})
|
|
self.budget -= price
|
|
self._update_count_label(unit_type)
|
|
self.update_available_budget()
|
|
|
|
def sell(self, unit_type):
|
|
if self.deliveryEvent.units.get(unit_type, 0) > 0:
|
|
price = db.PRICES[unit_type]
|
|
self.budget += price
|
|
self.deliveryEvent.units[unit_type] = self.deliveryEvent.units[unit_type] - 1
|
|
if self.deliveryEvent.units[unit_type] == 0:
|
|
del self.deliveryEvent.units[unit_type]
|
|
elif self.cp.base.total_units_of_type(unit_type) > 0:
|
|
price = db.PRICES[unit_type]
|
|
self.budget += price
|
|
self.cp.base.commit_losses({unit_type: 1})
|
|
|
|
self._update_count_label(unit_type)
|
|
self.update_available_budget()
|