mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Remove our old lat/lon support code.
pydcs provides this now.
This commit is contained in:
@@ -62,8 +62,7 @@ class ControlPointJs(QObject):
|
||||
|
||||
@Property(list, notify=positionChanged)
|
||||
def position(self) -> LeafletLatLon:
|
||||
ll = self.theater.point_to_ll(self.control_point.position)
|
||||
return [ll.lat, ll.lng]
|
||||
return self.control_point.position.latlng().as_list()
|
||||
|
||||
@Property(bool, notify=mobileChanged)
|
||||
def mobile(self) -> bool:
|
||||
@@ -74,7 +73,7 @@ class ControlPointJs(QObject):
|
||||
if self.control_point.target_position is None:
|
||||
# Qt seems to convert None to [] for list Properties :(
|
||||
return []
|
||||
return self.theater.point_to_ll(self.control_point.target_position).as_list()
|
||||
return self.control_point.target_position.latlng().as_list()
|
||||
|
||||
def destination_in_range(self, destination: Point) -> bool:
|
||||
move_distance = meters(
|
||||
@@ -84,7 +83,9 @@ class ControlPointJs(QObject):
|
||||
|
||||
@Slot(list, result=bool)
|
||||
def destinationInRange(self, destination: LeafletLatLon) -> bool:
|
||||
return self.destination_in_range(self.theater.ll_to_point(LatLng(*destination)))
|
||||
return self.destination_in_range(
|
||||
Point.from_latlng(LatLng(*destination), self.theater.terrain)
|
||||
)
|
||||
|
||||
@Slot(list, result=str)
|
||||
def setDestination(self, destination: LeafletLatLon) -> str:
|
||||
@@ -93,7 +94,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(LatLng(*destination))
|
||||
point = Point.from_latlng(LatLng(*destination), self.theater.terrain)
|
||||
if not self.destination_in_range(point):
|
||||
return (
|
||||
f"Cannot move {self.control_point} more than "
|
||||
|
||||
@@ -5,7 +5,6 @@ from PySide2.QtCore import Property, QObject, Signal, Slot
|
||||
from game.ato import Flight
|
||||
from game.ato.flightstate import InFlight
|
||||
from game.server.leaflet import LeafletLatLon
|
||||
from game.theater import ConflictTheater
|
||||
from qt_ui.models import AtoModel
|
||||
|
||||
|
||||
@@ -15,17 +14,10 @@ class FlightJs(QObject):
|
||||
blueChanged = Signal()
|
||||
selectedChanged = Signal()
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
flight: Flight,
|
||||
selected: bool,
|
||||
theater: ConflictTheater,
|
||||
ato_model: AtoModel,
|
||||
) -> None:
|
||||
def __init__(self, flight: Flight, selected: bool, ato_model: AtoModel) -> None:
|
||||
super().__init__()
|
||||
self.flight = flight
|
||||
self._selected = selected
|
||||
self.theater = theater
|
||||
self.ato_model = ato_model
|
||||
|
||||
@Property(str, notify=idChanged)
|
||||
@@ -35,8 +27,7 @@ class FlightJs(QObject):
|
||||
@Property(list, notify=positionChanged)
|
||||
def position(self) -> LeafletLatLon:
|
||||
if isinstance(self.flight.state, InFlight):
|
||||
ll = self.theater.point_to_ll(self.flight.state.estimate_position())
|
||||
return [ll.lat, ll.lng]
|
||||
return self.flight.state.estimate_position().latlng().as_list()
|
||||
return []
|
||||
|
||||
@Property(bool, notify=blueChanged)
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing import List
|
||||
from PySide2.QtCore import Property, QObject, Signal, Slot
|
||||
|
||||
from game.server.leaflet import LeafletLatLon
|
||||
from game.theater import ConflictTheater, FrontLine
|
||||
from game.theater import FrontLine
|
||||
from game.utils import nautical_miles
|
||||
from qt_ui.dialogs import Dialog
|
||||
|
||||
@@ -13,24 +13,19 @@ from qt_ui.dialogs import Dialog
|
||||
class FrontLineJs(QObject):
|
||||
extentsChanged = Signal()
|
||||
|
||||
def __init__(self, front_line: FrontLine, theater: ConflictTheater) -> None:
|
||||
def __init__(self, front_line: FrontLine) -> None:
|
||||
super().__init__()
|
||||
self.front_line = front_line
|
||||
self.theater = theater
|
||||
|
||||
@Property(list, notify=extentsChanged)
|
||||
def extents(self) -> List[LeafletLatLon]:
|
||||
a = self.theater.point_to_ll(
|
||||
self.front_line.position.point_from_heading(
|
||||
self.front_line.attack_heading.right.degrees, nautical_miles(2).meters
|
||||
)
|
||||
)
|
||||
b = self.theater.point_to_ll(
|
||||
self.front_line.position.point_from_heading(
|
||||
self.front_line.attack_heading.left.degrees, nautical_miles(2).meters
|
||||
)
|
||||
)
|
||||
return [[a.lat, a.lng], [b.lat, b.lng]]
|
||||
a = self.front_line.position.point_from_heading(
|
||||
self.front_line.attack_heading.right.degrees, nautical_miles(2).meters
|
||||
).latlng()
|
||||
b = self.front_line.position.point_from_heading(
|
||||
self.front_line.attack_heading.left.degrees, nautical_miles(2).meters
|
||||
).latlng()
|
||||
return [a.as_list(), b.as_list()]
|
||||
|
||||
@Slot()
|
||||
def showPackageDialog(self) -> None:
|
||||
|
||||
@@ -66,8 +66,7 @@ class GroundObjectJs(QObject):
|
||||
|
||||
@Property(list, notify=positionChanged)
|
||||
def position(self) -> LeafletLatLon:
|
||||
ll = self.theater.point_to_ll(self.tgo.position)
|
||||
return [ll.lat, ll.lng]
|
||||
return self.tgo.position.latlng().as_list()
|
||||
|
||||
@Property(bool, notify=deadChanged)
|
||||
def dead(self) -> bool:
|
||||
|
||||
@@ -16,7 +16,6 @@ class IpCombatJs(QObject):
|
||||
self._flight = FlightJs(
|
||||
combat.flight,
|
||||
selected=False,
|
||||
theater=game_model.game.theater,
|
||||
ato_model=game_model.ato_model_for(combat.flight.squadron.player),
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import logging
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from PySide2.QtCore import Property, QObject, Signal
|
||||
from dcs import Point
|
||||
from dcs.mapping import LatLng
|
||||
|
||||
from game import Game
|
||||
from game.ato.airtaaskingorder import AirTaskingOrder
|
||||
@@ -63,7 +63,7 @@ class MapModel(QObject):
|
||||
def __init__(self, game_model: GameModel) -> None:
|
||||
super().__init__()
|
||||
self.game_model = game_model
|
||||
self._map_center = [0, 0]
|
||||
self._map_center = LatLng(0, 0)
|
||||
self._control_points = []
|
||||
self._ground_objects = []
|
||||
self._supply_routes = []
|
||||
@@ -157,11 +157,6 @@ class MapModel(QObject):
|
||||
flight.set_selected(True)
|
||||
self.selectedFlightChanged.emit(str(flight.flight.id))
|
||||
|
||||
@staticmethod
|
||||
def leaflet_coord_for(point: Point, theater: ConflictTheater) -> LeafletLatLon:
|
||||
ll = theater.point_to_ll(point)
|
||||
return [ll.lat, ll.lng]
|
||||
|
||||
def reset(self) -> None:
|
||||
if self.game_model.game is None:
|
||||
self.clear()
|
||||
@@ -182,9 +177,8 @@ class MapModel(QObject):
|
||||
self.reset_map_center(game.theater)
|
||||
|
||||
def reset_map_center(self, theater: ConflictTheater) -> None:
|
||||
ll = theater.point_to_ll(theater.terrain.map_view_default.position)
|
||||
self._map_center = [ll.lat, ll.lng]
|
||||
self.mapCenterChanged.emit(self._map_center)
|
||||
self._map_center = theater.terrain.map_view_default.position.latlng()
|
||||
self.mapCenterChanged.emit(self._map_center.as_list())
|
||||
|
||||
@Property(str, notify=apiKeyChanged)
|
||||
def apiKey(self) -> str:
|
||||
@@ -192,7 +186,7 @@ class MapModel(QObject):
|
||||
|
||||
@Property(list, notify=mapCenterChanged)
|
||||
def mapCenter(self) -> LeafletLatLon:
|
||||
return self._map_center
|
||||
return self._map_center.as_list()
|
||||
|
||||
def _flights_in_ato(
|
||||
self, ato: AirTaskingOrder, blue: bool
|
||||
@@ -203,7 +197,6 @@ class MapModel(QObject):
|
||||
flights[blue, p_idx, f_idx] = FlightJs(
|
||||
flight,
|
||||
selected=blue and (p_idx, f_idx) == self._selected_flight_index,
|
||||
theater=self.game.theater,
|
||||
ato_model=self.game_model.ato_model_for(blue),
|
||||
)
|
||||
return flights
|
||||
@@ -262,10 +255,7 @@ class MapModel(QObject):
|
||||
SupplyRouteJs(
|
||||
control_point,
|
||||
destination,
|
||||
[
|
||||
self.leaflet_coord_for(p, self.game.theater)
|
||||
for p in convoy_route
|
||||
],
|
||||
[p.latlng().as_list() for p in convoy_route],
|
||||
sea_route=False,
|
||||
game=self.game,
|
||||
)
|
||||
@@ -278,10 +268,7 @@ class MapModel(QObject):
|
||||
SupplyRouteJs(
|
||||
control_point,
|
||||
destination,
|
||||
[
|
||||
self.leaflet_coord_for(p, self.game.theater)
|
||||
for p in shipping_lane
|
||||
],
|
||||
[p.latlng().as_list() for p in shipping_lane],
|
||||
sea_route=True,
|
||||
game=self.game,
|
||||
)
|
||||
@@ -293,9 +280,7 @@ class MapModel(QObject):
|
||||
return self._supply_routes
|
||||
|
||||
def reset_front_lines(self) -> None:
|
||||
self._front_lines = [
|
||||
FrontLineJs(f, self.game.theater) for f in self.game.theater.conflicts()
|
||||
]
|
||||
self._front_lines = [FrontLineJs(f) for f in self.game.theater.conflicts()]
|
||||
self.frontLinesChanged.emit()
|
||||
|
||||
@Property(list, notify=frontLinesChanged)
|
||||
|
||||
@@ -14,11 +14,9 @@ class SamCombatJs(QObject):
|
||||
super().__init__()
|
||||
assert game_model.game is not None
|
||||
self.combat = combat
|
||||
self.theater = game_model.game.theater
|
||||
self._flight = FlightJs(
|
||||
combat.flight,
|
||||
selected=False,
|
||||
theater=game_model.game.theater,
|
||||
ato_model=game_model.ato_model_for(combat.flight.squadron.player),
|
||||
)
|
||||
self._air_defenses = [
|
||||
|
||||
@@ -28,7 +28,6 @@ class UnculledZone(QObject):
|
||||
@classmethod
|
||||
def each_from_game(cls, game: Game) -> Iterator[UnculledZone]:
|
||||
for zone in game.get_culling_zones():
|
||||
ll = game.theater.point_to_ll(zone)
|
||||
yield UnculledZone(
|
||||
[ll.lat, ll.lng], game.settings.perf_culling_distance * 1000
|
||||
zone.latlng().as_list(), game.settings.perf_culling_distance * 1000
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user