mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Remove unused UI classes.
This commit is contained in:
parent
eedb5c26a9
commit
d788b286aa
@ -1,87 +0,0 @@
|
||||
from PySide2.QtGui import QStandardItem, QStandardItemModel
|
||||
|
||||
from game import Game
|
||||
from game.data.radar_db import UNITS_WITH_RADAR
|
||||
from gen import db
|
||||
from qt_ui.widgets.combos.QFilteredComboBox import QFilteredComboBox
|
||||
|
||||
|
||||
class SEADTargetInfo:
|
||||
def __init__(self):
|
||||
self.name = ""
|
||||
self.location = None
|
||||
self.radars = []
|
||||
self.threat_range = 0
|
||||
self.detection_range = 0
|
||||
|
||||
|
||||
class QSEADTargetSelectionComboBox(QFilteredComboBox):
|
||||
def __init__(self, game: Game, parent=None):
|
||||
super(QSEADTargetSelectionComboBox, self).__init__(parent)
|
||||
self.game = game
|
||||
self.find_possible_sead_targets()
|
||||
|
||||
def get_selected_target(self) -> SEADTargetInfo:
|
||||
n = self.currentText()
|
||||
for target in self.targets:
|
||||
if target.name == n:
|
||||
return target
|
||||
|
||||
def find_possible_sead_targets(self):
|
||||
|
||||
self.targets = []
|
||||
i = 0
|
||||
model = QStandardItemModel()
|
||||
|
||||
def add_model_item(i, model, target):
|
||||
item = QStandardItem(target.name)
|
||||
model.setItem(i, 0, item)
|
||||
self.targets.append(target)
|
||||
return i + 1
|
||||
|
||||
for cp in self.game.theater.controlpoints:
|
||||
if cp.captured:
|
||||
continue
|
||||
for g in cp.ground_objects:
|
||||
|
||||
radars = []
|
||||
detection_range = 0
|
||||
threat_range = 0
|
||||
if g.dcs_identifier == "AA":
|
||||
for group in g.groups:
|
||||
for u in group.units:
|
||||
utype = db.unit_type_from_name(u.type)
|
||||
|
||||
if utype in UNITS_WITH_RADAR:
|
||||
if (
|
||||
hasattr(utype, "detection_range")
|
||||
and utype.detection_range > 1000
|
||||
):
|
||||
if utype.detection_range > detection_range:
|
||||
detection_range = utype.detection_range
|
||||
radars.append(u)
|
||||
|
||||
if hasattr(utype, "threat_range"):
|
||||
if utype.threat_range > threat_range:
|
||||
threat_range = utype.threat_range
|
||||
if len(radars) > 0:
|
||||
tgt_info = SEADTargetInfo()
|
||||
tgt_info.name = (
|
||||
g.obj_name
|
||||
+ " ["
|
||||
+ ",".join(
|
||||
[db.unit_type_from_name(u.type).id for u in radars]
|
||||
)
|
||||
+ " ]"
|
||||
)
|
||||
if len(tgt_info.name) > 25:
|
||||
tgt_info.name = (
|
||||
g.obj_name + " [" + str(len(radars)) + " units]"
|
||||
)
|
||||
tgt_info.radars = radars
|
||||
tgt_info.location = g
|
||||
tgt_info.threat_range = threat_range
|
||||
tgt_info.detection_range = detection_range
|
||||
i = add_model_item(i, model, tgt_info)
|
||||
|
||||
self.setModel(model)
|
||||
@ -1,33 +0,0 @@
|
||||
from PySide2.QtGui import QStandardItemModel, QStandardItem
|
||||
from PySide2.QtWidgets import QGroupBox, QVBoxLayout, QListView, QAbstractItemView
|
||||
|
||||
from qt_ui.widgets.combos.QSEADTargetSelectionComboBox import SEADTargetInfo
|
||||
|
||||
|
||||
class QSeadTargetInfoView(QGroupBox):
|
||||
"""
|
||||
UI Component to display info about a sead target
|
||||
"""
|
||||
|
||||
def __init__(self, sead_target_infos: SEADTargetInfo):
|
||||
if sead_target_infos is None:
|
||||
sead_target_infos = SEADTargetInfo()
|
||||
super(QSeadTargetInfoView, self).__init__("Target : " + sead_target_infos.name)
|
||||
self.sead_target_infos = sead_target_infos
|
||||
self.radar_list = QListView()
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setSpacing(0)
|
||||
layout.addWidget(self.radar_list)
|
||||
self.setLayout(layout)
|
||||
|
||||
def setTarget(self, target: SEADTargetInfo):
|
||||
self.setTitle(target.name)
|
||||
self.sead_target_infos = target
|
||||
radar_list_model = QStandardItemModel()
|
||||
self.radar_list.setSelectionMode(QAbstractItemView.NoSelection)
|
||||
for r in self.sead_target_infos.radars:
|
||||
radar_list_model.appendRow(QStandardItem(r.type))
|
||||
self.radar_list.setModel(radar_list_model)
|
||||
Loading…
x
Reference in New Issue
Block a user