mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Decrease redraw load
This commit is contained in:
parent
30a9d4e730
commit
21b49ac79d
@ -68,10 +68,10 @@ function setup() {
|
||||
airspeedSlider = new Slider("airspeed-slider", 0, 100, "kts", (value: number) => getUnitsManager().selectedUnitsSetSpeed(value / 1.94384));
|
||||
|
||||
/* Visibility buttons */
|
||||
userVisibilityButton = new Button("user-visibility-button", ["images/buttons/user-full.svg", "images/buttons/user-partial.svg", "images/buttons/user-none.svg", "images/buttons/user-hidden.svg"], () => { });
|
||||
aiVisibilityButton = new Button("ai-visibility-button", ["images/buttons/ai-full.svg", "images/buttons/ai-partial.svg", "images/buttons/ai-none.svg", "images/buttons/ai-hidden.svg"], () => { });
|
||||
weaponVisibilityButton = new Button("weapon-visibility-button", ["images/buttons/weapon-partial.svg", "images/buttons/weapon-none.svg", "images/buttons/weapon-hidden.svg"], () => { });
|
||||
deadVisibilityButton = new Button("dead-visibility-button", ["images/buttons/dead.svg", "images/buttons/dead-hidden.svg"], () => { });
|
||||
userVisibilityButton = new Button("user-visibility-button", ["images/buttons/user-full.svg", "images/buttons/user-partial.svg", "images/buttons/user-none.svg", "images/buttons/user-hidden.svg"], () => { getUnitsManager().forceUpdate() });
|
||||
aiVisibilityButton = new Button("ai-visibility-button", ["images/buttons/ai-full.svg", "images/buttons/ai-partial.svg", "images/buttons/ai-none.svg", "images/buttons/ai-hidden.svg"], () => { getUnitsManager().forceUpdate() });
|
||||
weaponVisibilityButton = new Button("weapon-visibility-button", ["images/buttons/weapon-partial.svg", "images/buttons/weapon-none.svg", "images/buttons/weapon-hidden.svg"], () => { getUnitsManager().forceUpdate() });
|
||||
deadVisibilityButton = new Button("dead-visibility-button", ["images/buttons/dead.svg", "images/buttons/dead-hidden.svg"], () => { getUnitsManager().forceUpdate() });
|
||||
|
||||
aiVisibilityButton.setState(1);
|
||||
weaponVisibilityButton.setState(1);
|
||||
|
||||
@ -49,6 +49,7 @@ export class Unit {
|
||||
#targetsPolylines: Polyline[];
|
||||
#marker: UnitMarker;
|
||||
#timer: number = 0;
|
||||
#forceUpdate: boolean = false;
|
||||
|
||||
static getConstructor(name: string) {
|
||||
if (name === "GroundUnit") return GroundUnit;
|
||||
@ -76,6 +77,10 @@ export class Unit {
|
||||
}
|
||||
|
||||
update(response: any) {
|
||||
var updateMarker = false;
|
||||
if (this.latitude != response['latitude'] || this.longitude != response['longitude'] || this.alive != response['alive'] || this.#forceUpdate)
|
||||
updateMarker = true;
|
||||
|
||||
for (let entry in response) {
|
||||
// @ts-ignore TODO handle better
|
||||
this[entry] = response[entry];
|
||||
@ -88,7 +93,8 @@ export class Unit {
|
||||
/* Dead units can't be selected */
|
||||
this.setSelected(this.getSelected() && this.alive)
|
||||
|
||||
this.#updateMarker();
|
||||
if (updateMarker)
|
||||
this.#updateMarker();
|
||||
|
||||
this.#clearTargets();
|
||||
if (this.getSelected() && this.activePath != null)
|
||||
@ -164,6 +170,11 @@ export class Unit {
|
||||
return wingmen;
|
||||
}
|
||||
|
||||
forceUpdate()
|
||||
{
|
||||
this.#forceUpdate = true;
|
||||
}
|
||||
|
||||
#onClick(e: any) {
|
||||
this.#timer = setTimeout(() => {
|
||||
if (!this.#preventClick) {
|
||||
@ -218,6 +229,8 @@ export class Unit {
|
||||
alive: this.alive
|
||||
});
|
||||
}
|
||||
|
||||
this.#forceUpdate = false;
|
||||
}
|
||||
|
||||
#drawPath() {
|
||||
|
||||
@ -91,7 +91,7 @@ export class UnitMarker extends L.Marker {
|
||||
altitudeDiv.style.display = 'none';
|
||||
speedDiv.style.display = 'none';
|
||||
}
|
||||
if (this.getVisibility() === "none")
|
||||
if (this.getVisibility() === "none" && nameDiv.style.display != 'none')
|
||||
nameDiv.style.display = 'none';
|
||||
|
||||
nameDiv.style.left = (-(nameDiv.offsetWidth - container.offsetWidth) / 2) + "px";
|
||||
|
||||
@ -88,6 +88,12 @@ export class UnitsManager {
|
||||
}
|
||||
}
|
||||
|
||||
forceUpdate() {
|
||||
for (let ID in this.#units) {
|
||||
this.#units[ID].forceUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
onUnitSelection() {
|
||||
if (this.getSelectedUnits().length > 0) {
|
||||
getMap().setState("MOVE_UNIT");
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<%- include('selectionwheel.ejs') %>
|
||||
<%- include('selectionscroll.ejs') %>
|
||||
<div class="olympus-dropdown" id="map-source-dropdown"></div>
|
||||
<div class="olympus-dropdown" id="scenario-dropdown"></div>
|
||||
<!-- <div class="olympus-dropdown" id="scenario-dropdown"></div> -->
|
||||
<%- include('unitinfopanel.ejs') %>
|
||||
<%- include('unitcontrolpanel.ejs') %>
|
||||
<%- include('visibilitycontrolpanel.ejs') %>
|
||||
|
||||
@ -2,7 +2,7 @@ Olympus.unitCounter = 1
|
||||
Olympus.payloadRegistry = {}
|
||||
|
||||
function Olympus.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor)
|
||||
-- trigger.action.outText(message, displayFor)
|
||||
end
|
||||
|
||||
-- Gets a unit class reference from a given ObjectID (the ID used by Olympus for unit referencing)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user