mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Polished mission generator, fixed sam bug on map view.
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
from PySide2.QtCore import QSortFilterProxyModel, Qt, QModelIndex
|
||||
from PySide2.QtGui import QStandardItem, QStandardItemModel
|
||||
from PySide2.QtWidgets import QComboBox, QCompleter
|
||||
|
||||
from game import Game
|
||||
from gen import Conflict, FlightWaypointType, db
|
||||
from gen.flights.flight import FlightWaypoint, PredefinedWaypointCategory
|
||||
from game.data.radar_db import UNITS_WITH_RADAR
|
||||
from gen import db
|
||||
from qt_ui.widgets.combos.QFilteredComboBox import QFilteredComboBox
|
||||
from theater import ControlPointType
|
||||
|
||||
|
||||
class SEADTargetInfo:
|
||||
@@ -24,7 +22,7 @@ class QSEADTargetSelectionComboBox(QFilteredComboBox):
|
||||
self.game = game
|
||||
self.find_possible_sead_targets()
|
||||
|
||||
def get_selected_target(self):
|
||||
def get_selected_target(self) -> SEADTargetInfo:
|
||||
n = self.currentText()
|
||||
for target in self.targets:
|
||||
if target.name == n:
|
||||
@@ -53,10 +51,13 @@ class QSEADTargetSelectionComboBox(QFilteredComboBox):
|
||||
for group in g.groups:
|
||||
for u in group.units:
|
||||
utype = db.unit_type_from_name(u.type)
|
||||
if hasattr(utype, "detection_range") and utype.detection_range > 1000:
|
||||
if utype.detection_range > detection_range:
|
||||
detection_range = utype.detection_range
|
||||
|
||||
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
|
||||
|
||||
@@ -20,7 +20,12 @@ class QStrikeTargetSelectionComboBox(QFilteredComboBox):
|
||||
self.game = game
|
||||
self.find_possible_strike_targets()
|
||||
|
||||
def get_selected_target(self):
|
||||
|
||||
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:
|
||||
|
||||
@@ -9,6 +9,7 @@ from dcs.mapping import point_from_heading
|
||||
|
||||
import qt_ui.uiconstants as CONST
|
||||
from game import Game, db
|
||||
from game.data.radar_db import UNITS_WITH_RADAR
|
||||
from game.event import UnitsDeliveryEvent, Event, ControlPointType
|
||||
from gen import Conflict
|
||||
from qt_ui.widgets.map.QLiberationScene import QLiberationScene
|
||||
@@ -96,13 +97,16 @@ class QLiberationMap(QGraphicsView):
|
||||
|
||||
if ground_object.category == "aa" and self.get_display_rule("sam"):
|
||||
max_range = 0
|
||||
has_radar = False
|
||||
if ground_object.groups:
|
||||
for g in ground_object.groups:
|
||||
for u in g.units:
|
||||
unit = db.unit_type_from_name(u.type)
|
||||
if unit in UNITS_WITH_RADAR:
|
||||
has_radar = True
|
||||
if unit.threat_range > max_range:
|
||||
max_range = unit.threat_range
|
||||
if max_range >= 6000:
|
||||
if has_radar:
|
||||
scene.addEllipse(go_pos[0] - max_range/300.0 + 8, go_pos[1] - max_range/300.0 + 8, max_range/150.0, max_range/150.0, pen, brush)
|
||||
added_objects.append(ground_object.obj_name)
|
||||
|
||||
|
||||
42
qt_ui/widgets/views/QSeadTargetInfoView.py
Normal file
42
qt_ui/widgets/views/QSeadTargetInfoView.py
Normal file
@@ -0,0 +1,42 @@
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
75
qt_ui/widgets/views/QStrikeTargetInfoView.py
Normal file
75
qt_ui/widgets/views/QStrikeTargetInfoView.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import random
|
||||
|
||||
from PySide2.QtGui import QStandardItemModel, QStandardItem
|
||||
from PySide2.QtWidgets import QGroupBox, QLabel, QWidget, QVBoxLayout, QListView, QAbstractItemView
|
||||
|
||||
from qt_ui.widgets.combos.QStrikeTargetSelectionComboBox import StrikeTargetInfo
|
||||
|
||||
|
||||
class QStrikeTargetInfoView(QGroupBox):
|
||||
"""
|
||||
UI Component to display info about a strike target
|
||||
"""
|
||||
|
||||
def __init__(self, strike_target_infos: StrikeTargetInfo):
|
||||
|
||||
if strike_target_infos is None:
|
||||
strike_target_infos = StrikeTargetInfo()
|
||||
|
||||
super(QStrikeTargetInfoView, self).__init__("Target : " + strike_target_infos.name)
|
||||
|
||||
self.strike_target_infos = strike_target_infos
|
||||
|
||||
self.listView = QListView()
|
||||
|
||||
self.init_ui()
|
||||
|
||||
|
||||
def init_ui(self):
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setSpacing(0)
|
||||
layout.addWidget(self.listView)
|
||||
self.setLayout(layout)
|
||||
|
||||
|
||||
def setTarget(self, target):
|
||||
|
||||
self.setTitle(target.name)
|
||||
self.strike_target_infos = target
|
||||
model = QStandardItemModel()
|
||||
self.listView.setSelectionMode(QAbstractItemView.NoSelection)
|
||||
|
||||
if len(self.strike_target_infos.units) > 0:
|
||||
dic = {}
|
||||
for u in self.strike_target_infos.units:
|
||||
if u.type in dic.keys():
|
||||
dic[u.type] = dic[u.type] + 1
|
||||
else:
|
||||
dic[u.type] = 1
|
||||
for k,v in dic.items():
|
||||
model.appendRow(QStandardItem(k + " x " + str(v)))
|
||||
print(k + " x " + str(v))
|
||||
else:
|
||||
dic = {}
|
||||
for b in self.strike_target_infos.buildings:
|
||||
id = b.dcs_identifier
|
||||
if b.is_dead:
|
||||
id = id + "[Destroyed]"
|
||||
if id in dic.keys():
|
||||
dic[id] = dic[id] + 1
|
||||
else:
|
||||
dic[id] = 1
|
||||
for k, v in dic.items():
|
||||
model.appendRow(QStandardItem(k + " x " + str(v)))
|
||||
print(k + " x " + str(v))
|
||||
|
||||
self.listView.setModel(model)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user