mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
This appears to be incompatible with pyinstaller. I get the following when trying to run the executable generated with pyside6: ``` Traceback (most recent call last): File "qt_ui\main.py", line 29, in <module> File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module File "qt_ui\windows\QLiberationWindow.py", line 28, in <module> File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module File "qt_ui\widgets\map\QLiberationMap.py", line 11, in <module> ImportError: could not import module 'PySide6.QtPrintSupport' ```
71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
from PySide2.QtGui import QStandardItem, QStandardItemModel
|
|
|
|
from game import Game
|
|
from qt_ui.widgets.combos.QFilteredComboBox import QFilteredComboBox
|
|
|
|
|
|
class StrikeTargetInfo:
|
|
def __init__(self):
|
|
self.name = ""
|
|
self.location = None
|
|
self.units = []
|
|
self.buildings = []
|
|
|
|
|
|
class QStrikeTargetSelectionComboBox(QFilteredComboBox):
|
|
def __init__(self, game: Game, parent=None):
|
|
super(QStrikeTargetSelectionComboBox, self).__init__(parent)
|
|
self.game = game
|
|
self.find_possible_strike_targets()
|
|
|
|
for t in self.targets:
|
|
print(t.name + " - " + str(len(t.units)) + " " + str(len(t.buildings)))
|
|
|
|
def get_selected_target(self) -> StrikeTargetInfo:
|
|
n = self.currentText()
|
|
for target in self.targets:
|
|
if target.name == n:
|
|
return target
|
|
|
|
def find_possible_strike_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
|
|
|
|
added_obj_names = []
|
|
|
|
for g in cp.ground_objects:
|
|
if g.obj_name in added_obj_names:
|
|
continue
|
|
|
|
target = StrikeTargetInfo()
|
|
target.location = g
|
|
target.name = g.obj_name
|
|
|
|
if g.dcs_identifier == "AA":
|
|
target.name = g.obj_name + " [units]"
|
|
for group in g.groups:
|
|
for u in group.units:
|
|
target.units.append(u)
|
|
else:
|
|
target.name = g.obj_name + " [" + g.category + "]"
|
|
for g2 in cp.ground_objects:
|
|
if g2 is not g and g2.obj_name == g.obj_name:
|
|
target.buildings.append(g2)
|
|
|
|
i = add_model_item(i, model, target)
|
|
added_obj_names.append(g.obj_name)
|
|
|
|
self.setModel(model)
|