mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Minor optimizations
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M45.7733 41.3423L25.9481 7.63951C25.5228 6.91648 24.4772 6.91646 24.0519 7.63951L4.22671 41.3423C3.79536 42.0756 4.32409 43 5.17484 43H44.8252C45.6759 43 46.2046 42.0756 45.7733 41.3423Z" fill="#3BB9FF" stroke="white" stroke-width="2"/>
|
<path d="M45.7733 41.3423L25.9481 7.63951C25.5228 6.91648 24.4772 6.91646 24.0519 7.63951L4.22671 41.3423C3.79536 42.0756 4.32409 43 5.17484 43H44.8252C45.6759 43 46.2046 42.0756 45.7733 41.3423Z" fill="#3BB9FF" stroke="none" stroke-width="2"/>
|
||||||
<path d="M6.74842 41L25 9.97231L43.2516 41H6.74842Z" fill="none" stroke="#082E44" stroke-width="2"/>
|
<path d="M6.74842 41L25 9.97231L43.2516 41H6.74842Z" fill="none" stroke="#082E44" stroke-width="2"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 451 B After Width: | Height: | Size: 450 B |
@@ -98,6 +98,8 @@ function readConfig(config: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupEvents() {
|
function setupEvents() {
|
||||||
|
window.onanimationiteration = console.log;
|
||||||
|
|
||||||
/* Generic clicks */
|
/* Generic clicks */
|
||||||
document.addEventListener("click", (ev) => {
|
document.addEventListener("click", (ev) => {
|
||||||
if (ev instanceof MouseEvent && ev.target instanceof HTMLElement) {
|
if (ev instanceof MouseEvent && ev.target instanceof HTMLElement) {
|
||||||
|
|||||||
@@ -111,8 +111,9 @@ export class Map extends L.Map {
|
|||||||
|
|
||||||
/* Pan interval */
|
/* Pan interval */
|
||||||
this.#panInterval = window.setInterval(() => {
|
this.#panInterval = window.setInterval(() => {
|
||||||
this.panBy(new L.Point(((this.#panLeft ? -1 : 0) + (this.#panRight ? 1 : 0)) * this.#deafultPanDelta,
|
if (this.#panLeft || this.#panDown || this.#panRight || this.#panLeft)
|
||||||
((this.#panUp ? -1 : 0) + (this.#panDown ? 1 : 0)) * this.#deafultPanDelta));
|
this.panBy(new L.Point(((this.#panLeft? -1 : 0) + (this.#panRight ? 1 : 0)) * this.#deafultPanDelta,
|
||||||
|
((this.#panUp ? -1 : 0) + (this.#panDown ? 1 : 0)) * this.#deafultPanDelta));
|
||||||
}, 20);
|
}, 20);
|
||||||
|
|
||||||
/* Option buttons */
|
/* Option buttons */
|
||||||
|
|||||||
@@ -120,8 +120,9 @@ export class UnitControlPanel extends Panel {
|
|||||||
|
|
||||||
var button = document.createElement("button");
|
var button = document.createElement("button");
|
||||||
var callsign = unit.getBaseData().unitName || "";
|
var callsign = unit.getBaseData().unitName || "";
|
||||||
|
var label = unit.getDatabase()?.getByName(unit.getBaseData().name)?.label || unit.getBaseData().name;
|
||||||
|
|
||||||
button.setAttribute("data-label", unit.getBaseData().name);
|
button.setAttribute("data-label", label);
|
||||||
button.setAttribute("data-callsign", callsign);
|
button.setAttribute("data-callsign", callsign);
|
||||||
|
|
||||||
button.setAttribute("data-coalition", unit.getMissionData().coalition);
|
button.setAttribute("data-coalition", unit.getMissionData().coalition);
|
||||||
|
|||||||
@@ -29,15 +29,22 @@ export function setCredentials(newUsername: string, newCredentials: string) {
|
|||||||
credentials = newCredentials;
|
credentials = newCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GET(callback: CallableFunction, uri: string, options?: string) {
|
export function GET(callback: CallableFunction, uri: string, options?: {time?: number}) {
|
||||||
var xmlHttp = new XMLHttpRequest();
|
var xmlHttp = new XMLHttpRequest();
|
||||||
xmlHttp.open("GET", `${demoEnabled? DEMO_ADDRESS: REST_ADDRESS}/${uri}${options? options: ''}`, true);
|
|
||||||
|
/* Assemble the request options string */
|
||||||
|
var optionsString = '';
|
||||||
|
if (options?.time != undefined)
|
||||||
|
optionsString = `time=${options.time}`;
|
||||||
|
|
||||||
|
|
||||||
|
xmlHttp.open("GET", `${demoEnabled? DEMO_ADDRESS: REST_ADDRESS}/${uri}${optionsString? `?${optionsString}`: ''}`, true);
|
||||||
if (credentials)
|
if (credentials)
|
||||||
xmlHttp.setRequestHeader("Authorization", "Basic " + credentials);
|
xmlHttp.setRequestHeader("Authorization", "Basic " + credentials);
|
||||||
xmlHttp.onload = function (e) {
|
xmlHttp.onload = function (e) {
|
||||||
if (xmlHttp.status == 200) {
|
if (xmlHttp.status == 200) {
|
||||||
var data = JSON.parse(xmlHttp.responseText);
|
var data = JSON.parse(xmlHttp.responseText);
|
||||||
if (uri !== UNITS_URI || parseInt(data.time) > lastUpdateTime)
|
if (uri !== UNITS_URI || (options?.time == 0) || parseInt(data.time) > lastUpdateTime)
|
||||||
{
|
{
|
||||||
callback(data);
|
callback(data);
|
||||||
lastUpdateTime = parseInt(data.time);
|
lastUpdateTime = parseInt(data.time);
|
||||||
@@ -106,7 +113,7 @@ export function getMission(callback: CallableFunction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getUnits(callback: CallableFunction, refresh: boolean = false) {
|
export function getUnits(callback: CallableFunction, refresh: boolean = false) {
|
||||||
GET(callback, `${UNITS_URI}`, `?time=${refresh? 0: lastUpdateTime}`);
|
GET(callback, `${UNITS_URI}`, {time: refresh? 0: lastUpdateTime});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addDestination(ID: number, path: any) {
|
export function addDestination(ID: number, path: any) {
|
||||||
|
|||||||
@@ -772,23 +772,25 @@ export class Unit extends CustomMarker {
|
|||||||
#drawTargets() {
|
#drawTargets() {
|
||||||
for (let index in this.getMissionData().targets) {
|
for (let index in this.getMissionData().targets) {
|
||||||
var targetData = this.getMissionData().targets[index];
|
var targetData = this.getMissionData().targets[index];
|
||||||
var target = getUnitsManager().getUnitByID(targetData.object["id_"])
|
if (targetData.object != undefined){
|
||||||
if (target != null) {
|
var target = getUnitsManager().getUnitByID(targetData.object["id_"])
|
||||||
var startLatLng = new LatLng(this.getFlightData().latitude, this.getFlightData().longitude)
|
if (target != null) {
|
||||||
var endLatLng = new LatLng(target.getFlightData().latitude, target.getFlightData().longitude)
|
var startLatLng = new LatLng(this.getFlightData().latitude, this.getFlightData().longitude)
|
||||||
|
var endLatLng = new LatLng(target.getFlightData().latitude, target.getFlightData().longitude)
|
||||||
|
|
||||||
var color;
|
var color;
|
||||||
if (targetData.detectionMethod === "RADAR")
|
if (targetData.detectionMethod === "RADAR")
|
||||||
color = "#FFFF00";
|
color = "#FFFF00";
|
||||||
else if (targetData.detectionMethod === "VISUAL")
|
else if (targetData.detectionMethod === "VISUAL")
|
||||||
color = "#FF00FF";
|
color = "#FF00FF";
|
||||||
else if (targetData.detectionMethod === "RWR")
|
else if (targetData.detectionMethod === "RWR")
|
||||||
color = "#00FF00";
|
color = "#00FF00";
|
||||||
else
|
else
|
||||||
color = "#FFFFFF";
|
color = "#FFFFFF";
|
||||||
var targetPolyline = new Polyline([startLatLng, endLatLng], { color: color, weight: 3, opacity: 0.4, smoothFactor: 1 });
|
var targetPolyline = new Polyline([startLatLng, endLatLng], { color: color, weight: 3, opacity: 0.4, smoothFactor: 1 });
|
||||||
targetPolyline.addTo(getMap());
|
targetPolyline.addTo(getMap());
|
||||||
this.#targetsPolylines.push(targetPolyline)
|
this.#targetsPolylines.push(targetPolyline)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -851,7 +853,7 @@ export class GroundUnit extends Unit {
|
|||||||
showVvi: false,
|
showVvi: false,
|
||||||
showHotgroup: true,
|
showHotgroup: true,
|
||||||
showUnitIcon: true,
|
showUnitIcon: true,
|
||||||
showShortLabel: true,
|
showShortLabel: false,
|
||||||
showFuel: false,
|
showFuel: false,
|
||||||
showAmmo: false,
|
showAmmo: false,
|
||||||
showSummary: false,
|
showSummary: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user