mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Draw frozen combat in the new UI.
https://github.com/dcs-liberation/dcs_liberation/issues/2039
This commit is contained in:
52
client/src/components/combat/Combat.tsx
Normal file
52
client/src/components/combat/Combat.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import CombatModel from "../../api/combat";
|
||||
import { LatLng } from "leaflet";
|
||||
import { Polygon, Polyline } from "react-leaflet";
|
||||
|
||||
interface CombatProps {
|
||||
combat: CombatModel;
|
||||
}
|
||||
|
||||
function CombatFootprint(props: CombatProps) {
|
||||
if (!props.combat.footprint) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
return (
|
||||
<Polygon
|
||||
positions={props.combat.footprint}
|
||||
color="#c85050"
|
||||
interactive={false}
|
||||
fillOpacity={0.2}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CombatLines(props: CombatProps) {
|
||||
if (!props.combat.flight_position || !props.combat.target_positions) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
const flightPosition: LatLng = props.combat.flight_position;
|
||||
return (
|
||||
<>
|
||||
{props.combat.target_positions.map((position) => {
|
||||
return (
|
||||
<Polyline
|
||||
positions={[flightPosition, position]}
|
||||
color="#c85050"
|
||||
interactive={false}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Combat(props: CombatProps) {
|
||||
return (
|
||||
<>
|
||||
<CombatFootprint {...props} />
|
||||
<CombatLines {...props} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
1
client/src/components/combat/index.ts
Normal file
1
client/src/components/combat/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from "./Combat";
|
||||
Reference in New Issue
Block a user