mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from PySide2.QtWidgets import QGridLayout, QLabel, QGroupBox, QVBoxLayout
|
|
|
|
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
|
|
|
|
stretch = QVBoxLayout()
|
|
stretch.addStretch()
|
|
self.layout.addLayout(stretch, len(unit_dict) + 1, 0)
|
|
self.setLayout(self.layout)
|