Connect CP/TGO package fragging dialogs.

This commit is contained in:
Dan Albert 2021-05-13 01:05:15 -07:00
parent dd75078019
commit 1a65b1affb
2 changed files with 23 additions and 6 deletions

View File

@ -18,6 +18,7 @@ from game.utils import meters
from gen.ato import AirTaskingOrder from gen.ato import AirTaskingOrder
from gen.flights.flight import Flight, FlightWaypoint, FlightWaypointType from gen.flights.flight import Flight, FlightWaypoint, FlightWaypointType
from gen.flights.flightplan import FlightPlan from gen.flights.flightplan import FlightPlan
from qt_ui.dialogs import Dialog
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
@ -37,6 +38,7 @@ class ControlPointJs(QObject):
self.control_point = control_point self.control_point = control_point
self.game_model = game_model self.game_model = game_model
self.theater = theater self.theater = theater
self.dialog: Optional[QBaseMenu2] = None
@Property(str) @Property(str)
def name(self) -> str: def name(self) -> str:
@ -52,9 +54,14 @@ class ControlPointJs(QObject):
return [ll.latitude, ll.longitude] return [ll.latitude, ll.longitude]
@Slot() @Slot()
def open_base_menu(self) -> None: def showInfoDialog(self) -> None:
self.base_details_dialog = QBaseMenu2(None, self.control_point, self.game_model) if self.dialog is None:
self.base_details_dialog.show() self.dialog = QBaseMenu2(None, self.control_point, self.game_model)
self.dialog.show()
@Slot()
def showPackageDialog(self) -> None:
Dialog.open_new_package_dialog(self.control_point)
class GroundObjectJs(QObject): class GroundObjectJs(QObject):
@ -73,7 +80,7 @@ class GroundObjectJs(QObject):
self.dialog: Optional[QGroundObjectMenu] = None self.dialog: Optional[QGroundObjectMenu] = None
@Slot() @Slot()
def open_dialog(self) -> None: def showInfoDialog(self) -> None:
if self.dialog is None: if self.dialog is None:
self.dialog = QGroundObjectMenu( self.dialog = QGroundObjectMenu(
None, None,
@ -84,6 +91,10 @@ class GroundObjectJs(QObject):
) )
self.dialog.show() self.dialog.show()
@Slot()
def showPackageDialog(self) -> None:
Dialog.open_new_package_dialog(self.tgo)
@Property(str) @Property(str)
def name(self) -> str: def name(self) -> str:
return self.tgo.name return self.tgo.name

View File

@ -128,7 +128,10 @@ function drawControlPoints() {
permanent: zoom >= SHOW_BASE_NAME_AT_ZOOM, permanent: zoom >= SHOW_BASE_NAME_AT_ZOOM,
}) })
.on("click", function () { .on("click", function () {
cp.open_base_menu(); cp.showInfoDialog();
})
.on("contextmenu", function () {
cp.showPackageDialog();
}) })
.addTo(controlPointsLayer); .addTo(controlPointsLayer);
}); });
@ -169,7 +172,10 @@ function drawGroundObjects() {
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 () { .on("click", function () {
tgo.open_dialog(); tgo.showInfoDialog();
})
.on("contextmenu", function () {
tgo.showPackageDialog();
}) })
.addTo(groundObjectsLayer); .addTo(groundObjectsLayer);
drawSamThreatsAt(tgo); drawSamThreatsAt(tgo);