mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Connect TGO dialogs.
This commit is contained in:
parent
1ab205cb46
commit
dd75078019
@ -21,6 +21,7 @@ from gen.flights.flightplan import FlightPlan
|
|||||||
from qt_ui.models import GameModel
|
from qt_ui.models import GameModel
|
||||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||||
from qt_ui.windows.basemenu.QBaseMenu2 import QBaseMenu2
|
from qt_ui.windows.basemenu.QBaseMenu2 import QBaseMenu2
|
||||||
|
from qt_ui.windows.groundobject.QGroundObjectMenu import QGroundObjectMenu
|
||||||
|
|
||||||
LeafletLatLon = List[float]
|
LeafletLatLon = List[float]
|
||||||
|
|
||||||
@ -57,13 +58,31 @@ class ControlPointJs(QObject):
|
|||||||
|
|
||||||
|
|
||||||
class GroundObjectJs(QObject):
|
class GroundObjectJs(QObject):
|
||||||
def __init__(
|
def __init__(self, tgo: TheaterGroundObject, game: Game) -> None:
|
||||||
self, tgo: TheaterGroundObject, theater: ConflictTheater, country: str
|
|
||||||
) -> None:
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.tgo = tgo
|
self.tgo = tgo
|
||||||
self.theater = theater
|
self.game = game
|
||||||
self.country = country
|
self.theater = game.theater
|
||||||
|
self.buildings = self.theater.find_ground_objects_by_obj_name(self.tgo.obj_name)
|
||||||
|
|
||||||
|
if self.tgo.is_friendly(to_player=True):
|
||||||
|
self.country = game.player_country
|
||||||
|
else:
|
||||||
|
self.country = game.enemy_country
|
||||||
|
|
||||||
|
self.dialog: Optional[QGroundObjectMenu] = None
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def open_dialog(self) -> None:
|
||||||
|
if self.dialog is None:
|
||||||
|
self.dialog = QGroundObjectMenu(
|
||||||
|
None,
|
||||||
|
self.tgo,
|
||||||
|
self.buildings,
|
||||||
|
self.tgo.control_point,
|
||||||
|
self.game,
|
||||||
|
)
|
||||||
|
self.dialog.show()
|
||||||
|
|
||||||
@Property(str)
|
@Property(str)
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
@ -82,16 +101,15 @@ class GroundObjectJs(QObject):
|
|||||||
@Property(list)
|
@Property(list)
|
||||||
def units(self) -> List[str]:
|
def units(self) -> List[str]:
|
||||||
units = []
|
units = []
|
||||||
if self.tgo.groups:
|
if self.buildings:
|
||||||
|
for building in self.buildings:
|
||||||
|
dead = " [DEAD]" if building.is_dead else ""
|
||||||
|
units.append(f"{building.dcs_identifier}{dead}")
|
||||||
|
else:
|
||||||
for unit in self.tgo.units:
|
for unit in self.tgo.units:
|
||||||
units.append(self.make_unit_name(unit, dead=False))
|
units.append(self.make_unit_name(unit, dead=False))
|
||||||
for unit in self.tgo.dead_units:
|
for unit in self.tgo.dead_units:
|
||||||
units.append(self.make_unit_name(unit, dead=True))
|
units.append(self.make_unit_name(unit, dead=True))
|
||||||
else:
|
|
||||||
buildings = self.theater.find_ground_objects_by_obj_name(self.tgo.obj_name)
|
|
||||||
for building in buildings:
|
|
||||||
dead = " [DEAD]" if building.is_dead else ""
|
|
||||||
units.append(f"{building.dcs_identifier}{dead}")
|
|
||||||
return units
|
return units
|
||||||
|
|
||||||
@Property(bool)
|
@Property(bool)
|
||||||
@ -349,19 +367,12 @@ class MapModel(QObject):
|
|||||||
seen = set()
|
seen = set()
|
||||||
self._ground_objects = []
|
self._ground_objects = []
|
||||||
for cp in self.game.theater.controlpoints:
|
for cp in self.game.theater.controlpoints:
|
||||||
if cp.captured:
|
|
||||||
country = self.game.player_country
|
|
||||||
else:
|
|
||||||
country = self.game.enemy_country
|
|
||||||
|
|
||||||
for tgo in cp.ground_objects:
|
for tgo in cp.ground_objects:
|
||||||
if tgo.name in seen:
|
if tgo.name in seen:
|
||||||
continue
|
continue
|
||||||
seen.add(tgo.name)
|
seen.add(tgo.name)
|
||||||
|
|
||||||
self._ground_objects.append(
|
self._ground_objects.append(GroundObjectJs(tgo, self.game))
|
||||||
GroundObjectJs(tgo, self.game.theater, country)
|
|
||||||
)
|
|
||||||
self.groundObjectsChanged.emit()
|
self.groundObjectsChanged.emit()
|
||||||
|
|
||||||
@Property(list, notify=groundObjectsChanged)
|
@Property(list, notify=groundObjectsChanged)
|
||||||
|
|||||||
@ -168,6 +168,9 @@ function drawGroundObjects() {
|
|||||||
game.groundObjects.forEach((tgo) => {
|
game.groundObjects.forEach((tgo) => {
|
||||||
L.marker(tgo.position, { icon: iconFor(tgo.blue) })
|
L.marker(tgo.position, { icon: iconFor(tgo.blue) })
|
||||||
.bindTooltip(`${tgo.name}<br />${tgo.units.join("<br />")}`)
|
.bindTooltip(`${tgo.name}<br />${tgo.units.join("<br />")}`)
|
||||||
|
.on("click", function () {
|
||||||
|
tgo.open_dialog();
|
||||||
|
})
|
||||||
.addTo(groundObjectsLayer);
|
.addTo(groundObjectsLayer);
|
||||||
drawSamThreatsAt(tgo);
|
drawSamThreatsAt(tgo);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user