mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Move the base intel menu off find_unittype.
This commit is contained in:
parent
6966c16dd2
commit
ae2a818d8c
@ -1,3 +1,6 @@
|
|||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
from PySide2.QtCore import Qt
|
||||||
from PySide2.QtWidgets import (
|
from PySide2.QtWidgets import (
|
||||||
QFrame,
|
QFrame,
|
||||||
QGridLayout,
|
QGridLayout,
|
||||||
@ -7,8 +10,6 @@ from PySide2.QtWidgets import (
|
|||||||
QScrollArea,
|
QScrollArea,
|
||||||
QWidget,
|
QWidget,
|
||||||
)
|
)
|
||||||
from PySide2.QtCore import Qt
|
|
||||||
from dcs.task import CAP, CAS, Embarking, PinpointStrike
|
|
||||||
|
|
||||||
from game import Game, db
|
from game import Game, db
|
||||||
from game.theater import ControlPoint
|
from game.theater import ControlPoint
|
||||||
@ -19,51 +20,44 @@ class QIntelInfo(QFrame):
|
|||||||
super(QIntelInfo, self).__init__()
|
super(QIntelInfo, self).__init__()
|
||||||
self.cp = cp
|
self.cp = cp
|
||||||
self.game = game
|
self.game = game
|
||||||
self.init_ui()
|
|
||||||
|
|
||||||
def init_ui(self):
|
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
scroll_content = QWidget()
|
scroll_content = QWidget()
|
||||||
intelLayout = QVBoxLayout()
|
intel_layout = QVBoxLayout()
|
||||||
|
|
||||||
units = {
|
units_by_task: dict[str, dict[str, int]] = defaultdict(lambda: defaultdict(int))
|
||||||
CAP: db.find_unittype(CAP, self.game.enemy_name),
|
for unit_type, count in self.cp.base.aircraft.items():
|
||||||
Embarking: db.find_unittype(Embarking, self.game.enemy_name),
|
if count:
|
||||||
CAS: db.find_unittype(CAS, self.game.enemy_name),
|
name = db.unit_get_expanded_info(
|
||||||
PinpointStrike: db.find_unittype(PinpointStrike, self.game.enemy_name),
|
self.game.enemy_country, unit_type, "name"
|
||||||
|
)
|
||||||
|
units_by_task[unit_type.task_default.name][name] += count
|
||||||
|
|
||||||
|
units_by_task = {
|
||||||
|
task: units_by_task[task] for task in sorted(units_by_task.keys())
|
||||||
}
|
}
|
||||||
|
|
||||||
for task_type in units.keys():
|
front_line_units = defaultdict(int)
|
||||||
units_column = list(set(units[task_type]))
|
for unit_type, count in self.cp.base.armor.items():
|
||||||
|
if count:
|
||||||
|
name = db.unit_get_expanded_info(
|
||||||
|
self.game.enemy_country, unit_type, "name"
|
||||||
|
)
|
||||||
|
front_line_units[name] += count
|
||||||
|
|
||||||
if sum([self.cp.base.total_units_of_type(u) for u in units_column]) > 0:
|
units_by_task["Front line units"] = front_line_units
|
||||||
|
for task, unit_types in units_by_task.items():
|
||||||
|
task_group = QGroupBox(task)
|
||||||
|
task_layout = QGridLayout()
|
||||||
|
task_group.setLayout(task_layout)
|
||||||
|
|
||||||
group = QGroupBox(db.task_name(task_type))
|
for row, (name, count) in enumerate(unit_types.items()):
|
||||||
groupLayout = QGridLayout()
|
task_layout.addWidget(QLabel(f"<b>{name}</b>"), row, 0)
|
||||||
group.setLayout(groupLayout)
|
task_layout.addWidget(QLabel(str(count)), row, 1)
|
||||||
|
|
||||||
row = 0
|
intel_layout.addWidget(task_group)
|
||||||
for unit_type in units_column:
|
|
||||||
existing_units = self.cp.base.total_units_of_type(unit_type)
|
|
||||||
if existing_units == 0:
|
|
||||||
continue
|
|
||||||
groupLayout.addWidget(
|
|
||||||
QLabel(
|
|
||||||
"<b>"
|
|
||||||
+ db.unit_get_expanded_info(
|
|
||||||
self.game.enemy_country, unit_type, "name"
|
|
||||||
)
|
|
||||||
+ "</b>"
|
|
||||||
),
|
|
||||||
row,
|
|
||||||
0,
|
|
||||||
)
|
|
||||||
groupLayout.addWidget(QLabel(str(existing_units)), row, 1)
|
|
||||||
row += 1
|
|
||||||
|
|
||||||
intelLayout.addWidget(group)
|
scroll_content.setLayout(intel_layout)
|
||||||
|
|
||||||
scroll_content.setLayout(intelLayout)
|
|
||||||
scroll = QScrollArea()
|
scroll = QScrollArea()
|
||||||
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||||
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user