mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Handle inventory when selling aircraft.
This still leaves a bit to be desired, namely that selling aircraft happens immediately but buying aircraft takes a turn. However, that's how this behaved before, so this restores the 2.1 behavior. Worth investigating further in the future.
This commit is contained in:
parent
a81254cd18
commit
75769df8e2
@ -6,6 +6,7 @@ from PySide2.QtWidgets import (
|
|||||||
QGridLayout,
|
QGridLayout,
|
||||||
QHBoxLayout,
|
QHBoxLayout,
|
||||||
QLabel,
|
QLabel,
|
||||||
|
QMessageBox,
|
||||||
QScrollArea,
|
QScrollArea,
|
||||||
QVBoxLayout,
|
QVBoxLayout,
|
||||||
QWidget,
|
QWidget,
|
||||||
@ -88,7 +89,21 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour):
|
|||||||
super().buy(unit_type)
|
super().buy(unit_type)
|
||||||
self.hangar_status.update_label(self.total_units, self.cp.available_aircraft_slots)
|
self.hangar_status.update_label(self.total_units, self.cp.available_aircraft_slots)
|
||||||
|
|
||||||
def sell(self, unit_type):
|
def sell(self, unit_type: UnitType):
|
||||||
|
# Don't need to remove aircraft from the inventory if we're canceling
|
||||||
|
# orders.
|
||||||
|
if self.deliveryEvent.units.get(unit_type, 0) <= 0:
|
||||||
|
global_inventory = self.game_model.game.aircraft_inventory
|
||||||
|
inventory = global_inventory.for_control_point(self.cp)
|
||||||
|
try:
|
||||||
|
inventory.remove_aircraft(unit_type, 1)
|
||||||
|
except ValueError:
|
||||||
|
QMessageBox.critical(
|
||||||
|
self, "Could not sell aircraft",
|
||||||
|
f"Attempted to sell one {unit_type.id} at {self.cp.name} "
|
||||||
|
"but none are available. Are all aircraft currently "
|
||||||
|
"assigned to a mission?", QMessageBox.Ok)
|
||||||
|
return
|
||||||
super().sell(unit_type)
|
super().sell(unit_type)
|
||||||
self.hangar_status.update_label(self.total_units, self.cp.available_aircraft_slots)
|
self.hangar_status.update_label(self.total_units, self.cp.available_aircraft_slots)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user