mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Blacken.
This commit is contained in:
@@ -22,8 +22,7 @@ from game.data.building_data import FORTIFICATION_BUILDINGS
|
||||
from game.db import PRICES, PinpointStrike, REWARDS, unit_type_of
|
||||
from game.theater import ControlPoint, TheaterGroundObject
|
||||
from game.theater.theatergroundobject import NavalGroundObject
|
||||
from gen.defenses.armor_group_generator import \
|
||||
generate_armor_group_of_type_and_size
|
||||
from gen.defenses.armor_group_generator import generate_armor_group_of_type_and_size
|
||||
from gen.sam.sam_group_generator import get_faction_possible_sams_generator
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
from qt_ui.widgets.QBudgetBox import QBudgetBox
|
||||
@@ -36,9 +35,14 @@ class QGroundObjectMenu(QDialog):
|
||||
|
||||
changed = QtCore.Signal()
|
||||
|
||||
def __init__(self, parent, ground_object: TheaterGroundObject,
|
||||
buildings: Optional[List[TheaterGroundObject]],
|
||||
cp: ControlPoint, game: Game):
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
ground_object: TheaterGroundObject,
|
||||
buildings: Optional[List[TheaterGroundObject]],
|
||||
cp: ControlPoint,
|
||||
game: Game,
|
||||
):
|
||||
super().__init__(parent)
|
||||
self.setMinimumWidth(350)
|
||||
self.ground_object = ground_object
|
||||
@@ -105,8 +109,20 @@ class QGroundObjectMenu(QDialog):
|
||||
unit_display_name = u.type
|
||||
unit_type = vehicles.vehicle_map.get(u.type)
|
||||
if unit_type is not None:
|
||||
unit_display_name = db.unit_get_expanded_info(self.game.enemy_country, unit_type, 'name')
|
||||
self.intelLayout.addWidget(QLabel("<b>Unit #" + str(u.id) + " - " + str(unit_display_name) + "</b>"), i, 0)
|
||||
unit_display_name = db.unit_get_expanded_info(
|
||||
self.game.enemy_country, unit_type, "name"
|
||||
)
|
||||
self.intelLayout.addWidget(
|
||||
QLabel(
|
||||
"<b>Unit #"
|
||||
+ str(u.id)
|
||||
+ " - "
|
||||
+ str(unit_display_name)
|
||||
+ "</b>"
|
||||
),
|
||||
i,
|
||||
0,
|
||||
)
|
||||
i = i + 1
|
||||
|
||||
for u in g.units_losts:
|
||||
@@ -117,11 +133,19 @@ class QGroundObjectMenu(QDialog):
|
||||
else:
|
||||
price = 6
|
||||
|
||||
self.intelLayout.addWidget(QLabel("<b>Unit #" + str(u.id) + " - " + str(u.type) + "</b> [DEAD]"), i, 0)
|
||||
self.intelLayout.addWidget(
|
||||
QLabel(
|
||||
"<b>Unit #" + str(u.id) + " - " + str(u.type) + "</b> [DEAD]"
|
||||
),
|
||||
i,
|
||||
0,
|
||||
)
|
||||
if self.cp.captured:
|
||||
repair = QPushButton("Repair [" + str(price) + "M]")
|
||||
repair.setProperty("style", "btn-success")
|
||||
repair.clicked.connect(lambda u=u, g=g, p=price: self.repair_unit(g, u, p))
|
||||
repair.clicked.connect(
|
||||
lambda u=u, g=g, p=price: self.repair_unit(g, u, p)
|
||||
)
|
||||
self.intelLayout.addWidget(repair, i, 1)
|
||||
i = i + 1
|
||||
stretch = QVBoxLayout()
|
||||
@@ -136,7 +160,9 @@ class QGroundObjectMenu(QDialog):
|
||||
received_income = 0
|
||||
for i, building in enumerate(self.buildings):
|
||||
if building.dcs_identifier not in FORTIFICATION_BUILDINGS:
|
||||
self.buildingsLayout.addWidget(QBuildingInfo(building, self.ground_object), j/3, j%3)
|
||||
self.buildingsLayout.addWidget(
|
||||
QBuildingInfo(building, self.ground_object), j / 3, j % 3
|
||||
)
|
||||
j = j + 1
|
||||
|
||||
if building.category in REWARDS.keys():
|
||||
@@ -148,8 +174,12 @@ class QGroundObjectMenu(QDialog):
|
||||
|
||||
self.financesBox = QGroupBox("Finances: ")
|
||||
self.financesBoxLayout = QGridLayout()
|
||||
self.financesBoxLayout.addWidget(QLabel("Available: " + str(total_income) + "M"), 2, 1)
|
||||
self.financesBoxLayout.addWidget(QLabel("Receiving: " + str(received_income) + "M"), 2, 2)
|
||||
self.financesBoxLayout.addWidget(
|
||||
QLabel("Available: " + str(total_income) + "M"), 2, 1
|
||||
)
|
||||
self.financesBoxLayout.addWidget(
|
||||
QLabel("Receiving: " + str(received_income) + "M"), 2, 2
|
||||
)
|
||||
|
||||
self.financesBox.setLayout(self.financesBoxLayout)
|
||||
self.buildingBox.setLayout(self.buildingsLayout)
|
||||
@@ -224,17 +254,25 @@ class QGroundObjectMenu(QDialog):
|
||||
GameUpdateSignal.get_instance().updateBudget(self.game)
|
||||
|
||||
def buy_group(self):
|
||||
self.subwindow = QBuyGroupForGroundObjectDialog(self, self.ground_object, self.cp, self.game, self.total_value)
|
||||
self.subwindow = QBuyGroupForGroundObjectDialog(
|
||||
self, self.ground_object, self.cp, self.game, self.total_value
|
||||
)
|
||||
self.subwindow.changed.connect(self.do_refresh_layout)
|
||||
self.subwindow.show()
|
||||
|
||||
|
||||
|
||||
class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
|
||||
changed = QtCore.Signal()
|
||||
|
||||
def __init__(self, parent, ground_object: TheaterGroundObject, cp: ControlPoint, game: Game, current_group_value: int):
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
ground_object: TheaterGroundObject,
|
||||
cp: ControlPoint,
|
||||
game: Game,
|
||||
current_group_value: int,
|
||||
):
|
||||
super(QBuyGroupForGroundObjectDialog, self).__init__(parent)
|
||||
|
||||
self.setMinimumWidth(350)
|
||||
@@ -256,8 +294,6 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
self.buySamBox = QGroupBox("Buy SAM site :")
|
||||
self.buyArmorBox = QGroupBox("Buy defensive position :")
|
||||
|
||||
|
||||
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
@@ -267,7 +303,9 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
|
||||
possible_sams = get_faction_possible_sams_generator(faction)
|
||||
for sam in possible_sams:
|
||||
self.samCombo.addItem(sam.name + " [$" + str(sam.price) + "M]", userData=sam)
|
||||
self.samCombo.addItem(
|
||||
sam.name + " [$" + str(sam.price) + "M]", userData=sam
|
||||
)
|
||||
self.samCombo.currentIndexChanged.connect(self.samComboChanged)
|
||||
|
||||
self.buySamLayout.addWidget(QLabel("Site Type :"), 0, 0, Qt.AlignLeft)
|
||||
@@ -281,9 +319,14 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
|
||||
# Armored units
|
||||
|
||||
armored_units = db.find_unittype(PinpointStrike, faction.name) # Todo : refactor this legacy nonsense
|
||||
armored_units = db.find_unittype(
|
||||
PinpointStrike, faction.name
|
||||
) # Todo : refactor this legacy nonsense
|
||||
for unit in set(armored_units):
|
||||
self.buyArmorCombo.addItem(db.unit_type_name_2(unit) + " [$" + str(db.PRICES[unit]) + "M]", userData=unit)
|
||||
self.buyArmorCombo.addItem(
|
||||
db.unit_type_name_2(unit) + " [$" + str(db.PRICES[unit]) + "M]",
|
||||
userData=unit,
|
||||
)
|
||||
self.buyArmorCombo.currentIndexChanged.connect(self.armorComboChanged)
|
||||
|
||||
self.amount.setMinimum(2)
|
||||
@@ -293,9 +336,13 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
|
||||
self.buyArmorLayout.addWidget(QLabel("Unit type :"), 0, 0, Qt.AlignLeft)
|
||||
self.buyArmorLayout.addWidget(self.buyArmorCombo, 0, 1, alignment=Qt.AlignRight)
|
||||
self.buyArmorLayout.addWidget(QLabel("Group size :"), 1, 0, alignment=Qt.AlignLeft)
|
||||
self.buyArmorLayout.addWidget(
|
||||
QLabel("Group size :"), 1, 0, alignment=Qt.AlignLeft
|
||||
)
|
||||
self.buyArmorLayout.addWidget(self.amount, 1, 1, alignment=Qt.AlignRight)
|
||||
self.buyArmorLayout.addWidget(self.buyArmorButton, 2, 1, alignment=Qt.AlignRight)
|
||||
self.buyArmorLayout.addWidget(
|
||||
self.buyArmorButton, 2, 1, alignment=Qt.AlignRight
|
||||
)
|
||||
stretch2 = QVBoxLayout()
|
||||
stretch2.addStretch()
|
||||
self.buyArmorLayout.addLayout(stretch2, 3, 0)
|
||||
@@ -321,13 +368,36 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
pass
|
||||
|
||||
def samComboChanged(self, index):
|
||||
self.buySamButton.setText("Buy [$" + str(self.samCombo.itemData(index).price) + "M] [-$" + str(self.current_group_value) + "M]")
|
||||
self.buySamButton.setText(
|
||||
"Buy [$"
|
||||
+ str(self.samCombo.itemData(index).price)
|
||||
+ "M] [-$"
|
||||
+ str(self.current_group_value)
|
||||
+ "M]"
|
||||
)
|
||||
|
||||
def armorComboChanged(self, index):
|
||||
self.buyArmorButton.setText("Buy [$" + str(db.PRICES[self.buyArmorCombo.itemData(index)] * self.amount.value()) + "M][-$" + str(self.current_group_value) + "M]")
|
||||
self.buyArmorButton.setText(
|
||||
"Buy [$"
|
||||
+ str(db.PRICES[self.buyArmorCombo.itemData(index)] * self.amount.value())
|
||||
+ "M][-$"
|
||||
+ str(self.current_group_value)
|
||||
+ "M]"
|
||||
)
|
||||
|
||||
def amountComboChanged(self):
|
||||
self.buyArmorButton.setText("Buy [$" + str(db.PRICES[self.buyArmorCombo.itemData(self.buyArmorCombo.currentIndex())] * self.amount.value()) + "M][-$" + str(self.current_group_value) + "M]")
|
||||
self.buyArmorButton.setText(
|
||||
"Buy [$"
|
||||
+ str(
|
||||
db.PRICES[
|
||||
self.buyArmorCombo.itemData(self.buyArmorCombo.currentIndex())
|
||||
]
|
||||
* self.amount.value()
|
||||
)
|
||||
+ "M][-$"
|
||||
+ str(self.current_group_value)
|
||||
+ "M]"
|
||||
)
|
||||
|
||||
def buyArmor(self):
|
||||
logging.info("Buying Armor ")
|
||||
@@ -342,7 +412,9 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
self.game.budget -= price
|
||||
|
||||
# Generate Armor
|
||||
group = generate_armor_group_of_type_and_size(self.game, self.ground_object, utype, int(self.amount.value()))
|
||||
group = generate_armor_group_of_type_and_size(
|
||||
self.game, self.ground_object, utype, int(self.amount.value())
|
||||
)
|
||||
self.ground_object.groups = [group]
|
||||
|
||||
GameUpdateSignal.get_instance().updateBudget(self.game)
|
||||
@@ -377,4 +449,4 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
msg.setStandardButtons(QMessageBox.Ok)
|
||||
msg.setWindowFlags(Qt.WindowStaysOnTopHint)
|
||||
msg.exec_()
|
||||
self.close()
|
||||
self.close()
|
||||
|
||||
Reference in New Issue
Block a user