mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Migrate air icons to milsymbol.
All NATO icons are now generated by the milsymbol library based on their SIDC.
This commit is contained in:
parent
02383763ec
commit
e3adcada52
@ -11,6 +11,14 @@ from game.savecompat import has_save_compat_for
|
||||
from .flightroster import FlightRoster
|
||||
from .flightstate import FlightState, Uninitialized
|
||||
from .loadouts import Loadout
|
||||
from ..sidc import (
|
||||
AirEntity,
|
||||
Entity,
|
||||
SidcDescribable,
|
||||
StandardIdentity,
|
||||
Status,
|
||||
SymbolSet,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game.dcs.aircrafttype import AircraftType
|
||||
@ -25,7 +33,7 @@ if TYPE_CHECKING:
|
||||
from .starttype import StartType
|
||||
|
||||
|
||||
class Flight:
|
||||
class Flight(SidcDescribable):
|
||||
def __init__(
|
||||
self,
|
||||
package: Package,
|
||||
@ -103,6 +111,18 @@ class Flight:
|
||||
def blue(self) -> bool:
|
||||
return self.squadron.player
|
||||
|
||||
@property
|
||||
def standard_identity(self) -> StandardIdentity:
|
||||
return StandardIdentity.FRIEND if self.blue else StandardIdentity.HOSTILE_FAKER
|
||||
|
||||
@property
|
||||
def sidc_status(self) -> Status:
|
||||
return Status.PRESENT
|
||||
|
||||
@property
|
||||
def symbol_set_and_entity(self) -> tuple[SymbolSet, Entity]:
|
||||
return SymbolSet.AIR, AirEntity.UNSPECIFIED
|
||||
|
||||
@property
|
||||
def departure(self) -> ControlPoint:
|
||||
return self.squadron.location
|
||||
|
||||
@ -13,6 +13,7 @@ class FlightJs(BaseModel):
|
||||
id: UUID
|
||||
blue: bool
|
||||
position: LeafletPoint | None
|
||||
sidc: str
|
||||
|
||||
@staticmethod
|
||||
def for_flight(flight: Flight) -> FlightJs:
|
||||
@ -23,4 +24,6 @@ class FlightJs(BaseModel):
|
||||
position = None
|
||||
if isinstance(flight.state, InFlight):
|
||||
position = flight.position().latlng()
|
||||
return FlightJs(id=flight.id, blue=flight.blue, position=position)
|
||||
return FlightJs(
|
||||
id=flight.id, blue=flight.blue, position=position, sidc=str(flight.sidc())
|
||||
)
|
||||
|
||||
@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="118" height="128" viewBox="41 26 118 128"><path d="M 155,150 C 155,50 115,30 100,30 85,30 45,50 45,150" stroke-width="4" stroke="black" fill="rgb(128,224,255)" fill-opacity="1" ></path></svg>
|
||||
|
Before Width: | Height: | Size: 271 B |
@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="118" height="138" viewBox="41 16 118 138"><path d="M 45,150 L45,70 100,20 155,70 155,150" stroke-width="4" stroke="black" fill="rgb(255,128,128)" fill-opacity="1" ></path></svg>
|
||||
|
Before Width: | Height: | Size: 257 B |
@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="118" height="128" viewBox="41 26 118 128"><path d="M 155,150 C 155,50 115,30 100,30 85,30 45,50 45,150" stroke-width="4" stroke="black" fill="rgb(255,255,255)" fill-opacity="1" ></path></svg>
|
||||
|
Before Width: | Height: | Size: 271 B |
@ -34,66 +34,6 @@ const Colors = Object.freeze({
|
||||
Highlight: "#ffff00",
|
||||
});
|
||||
|
||||
const Categories = Object.freeze([
|
||||
"aa",
|
||||
"allycamp",
|
||||
"ammo",
|
||||
"armor",
|
||||
"coastal",
|
||||
"comms",
|
||||
"derrick",
|
||||
"ewr",
|
||||
"factory",
|
||||
"farp",
|
||||
"fuel",
|
||||
"missile",
|
||||
"oil",
|
||||
"power",
|
||||
"ship",
|
||||
"village",
|
||||
"ware",
|
||||
"ww2bunker",
|
||||
]);
|
||||
|
||||
const UnitState = Object.freeze({
|
||||
Alive: "alive",
|
||||
Damaged: "damaged",
|
||||
Destroyed: "destroyed",
|
||||
});
|
||||
|
||||
class AirIcons {
|
||||
constructor() {
|
||||
this.icons = {};
|
||||
for (const player of [true, false]) {
|
||||
this.icons[player] = {};
|
||||
for (const selected of [true, false]) {
|
||||
this.icons[player][selected] = this.loadIcon(
|
||||
"unspecified",
|
||||
player,
|
||||
selected
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
icon(_category, player, selected) {
|
||||
return this.icons[player][selected];
|
||||
}
|
||||
|
||||
loadIcon(category, player, selected) {
|
||||
var color;
|
||||
if (selected) {
|
||||
color = "selected";
|
||||
} else {
|
||||
color = player ? "blue" : "red";
|
||||
}
|
||||
return new L.Icon({
|
||||
iconUrl: `../air_assets/${category}_${color}.svg`,
|
||||
iconSize: [24, 24],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function milSymbolIcon(sidc, options = {}) {
|
||||
const symbol = new ms.Symbol(sidc, options);
|
||||
return L.icon({
|
||||
@ -102,10 +42,6 @@ function milSymbolIcon(sidc, options = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
const Icons = Object.freeze({
|
||||
AirIcons: new AirIcons(),
|
||||
});
|
||||
|
||||
function metersToNauticalMiles(meters) {
|
||||
return meters * 0.000539957;
|
||||
}
|
||||
@ -923,7 +859,7 @@ class Flight {
|
||||
this.clearAircraftLocation();
|
||||
if (this.position != null) {
|
||||
this.aircraft = L.marker(this.position, {
|
||||
icon: Icons.AirIcons.icon("fighter", this.flight.blue, this.selected),
|
||||
icon: milSymbolIcon(this.flight.sidc, { size: 16 }),
|
||||
}).addTo(aircraftLayer);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user