Update pydcs, adapt to new Point APIs.

This is briefly moving us over to my fork of pydcs while we wait for
https://github.com/pydcs/dcs/pull/206 to be merged. The adaptation is
invasive enough that I don't want it lingering for long.
This commit is contained in:
Dan Albert
2022-02-21 18:14:49 -08:00
parent ff12b37431
commit 9e2e4ffa74
29 changed files with 155 additions and 186 deletions

View File

@@ -1,14 +1,14 @@
from PySide2.QtGui import QStandardItem, QStandardItemModel
from game import Game
from game.theater.controlpoint import ControlPointType
from game.theater.theatergroundobject import IadsGroundObject, BuildingGroundObject
from game.utils import Distance
from game.ato.flightwaypoint import FlightWaypoint
from game.ato.flightwaypointtype import FlightWaypointType
from game.missiongenerator.frontlineconflictdescription import (
FrontLineConflictDescription,
)
from game.ato.flightwaypointtype import FlightWaypointType
from game.ato.flightwaypoint import FlightWaypoint
from game.theater.controlpoint import ControlPointType
from game.theater.theatergroundobject import BuildingGroundObject, IadsGroundObject
from game.utils import Distance
from qt_ui.widgets.combos.QFilteredComboBox import QFilteredComboBox
@@ -72,10 +72,7 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
front_line, self.game.theater
)[0]
wpt = FlightWaypoint(
FlightWaypointType.CUSTOM,
pos.x,
pos.y,
Distance.from_meters(800),
FlightWaypointType.CUSTOM, pos, Distance.from_meters(800)
)
wpt.name = f"Frontline {front_line.name} [CAS]"
wpt.alt_type = "RADIO"
@@ -94,8 +91,7 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
):
wpt = FlightWaypoint(
FlightWaypointType.CUSTOM,
ground_object.position.x,
ground_object.position.y,
ground_object.position,
Distance.from_meters(0),
)
wpt.alt_type = "RADIO"
@@ -122,8 +118,7 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
for j, u in enumerate(g.units):
wpt = FlightWaypoint(
FlightWaypointType.CUSTOM,
u.position.x,
u.position.y,
u.position,
Distance.from_meters(0),
)
wpt.alt_type = "RADIO"
@@ -151,10 +146,7 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
self.include_friendly and cp.captured
):
wpt = FlightWaypoint(
FlightWaypointType.CUSTOM,
cp.position.x,
cp.position.y,
Distance.from_meters(0),
FlightWaypointType.CUSTOM, cp.position, Distance.from_meters(0)
)
wpt.alt_type = "RADIO"
wpt.name = cp.name

View File

@@ -4,9 +4,10 @@ from typing import Optional
from PySide2.QtCore import Property, QObject, Signal, Slot
from dcs import Point
from dcs.mapping import LatLng
from game.server.leaflet import LeafletLatLon
from game.theater import ConflictTheater, ControlPoint, ControlPointStatus, LatLon
from game.theater import ConflictTheater, ControlPoint, ControlPointStatus
from game.utils import meters, nautical_miles
from qt_ui.dialogs import Dialog
from qt_ui.models import GameModel
@@ -83,7 +84,7 @@ class ControlPointJs(QObject):
@Slot(list, result=bool)
def destinationInRange(self, destination: LeafletLatLon) -> bool:
return self.destination_in_range(self.theater.ll_to_point(LatLon(*destination)))
return self.destination_in_range(self.theater.ll_to_point(LatLng(*destination)))
@Slot(list, result=str)
def setDestination(self, destination: LeafletLatLon) -> str:
@@ -92,7 +93,7 @@ class ControlPointJs(QObject):
if not self.control_point.captured:
return f"{self.control_point} is not owned by player"
point = self.theater.ll_to_point(LatLon(*destination))
point = self.theater.ll_to_point(LatLng(*destination))
if not self.destination_in_range(point):
return (
f"Cannot move {self.control_point} more than "