mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Fixed unit payloads, spread update load from mission update
This commit is contained in:
@@ -34,6 +34,7 @@ var climbButton: Button;
|
||||
var descendButton: Button;
|
||||
var userVisibilityButton: Button;
|
||||
var aiVisibilityButton: Button;
|
||||
var uncontrolledVisibilityButton: Button;
|
||||
var weaponVisibilityButton: Button;
|
||||
var deadVisibilityButton: Button;
|
||||
|
||||
@@ -70,10 +71,12 @@ function setup() {
|
||||
/* 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"], () => { 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() });
|
||||
uncontrolledVisibilityButton = new Button("uncontrolled-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);
|
||||
uncontrolledVisibilityButton.setState(3);
|
||||
weaponVisibilityButton.setState(1);
|
||||
deadVisibilityButton.setState(1);
|
||||
|
||||
@@ -148,6 +151,7 @@ export function getVisibilitySettings() {
|
||||
var visibility = {
|
||||
user: "",
|
||||
ai: "",
|
||||
uncontrolled: "",
|
||||
weapon: "",
|
||||
dead: ""
|
||||
};
|
||||
@@ -174,6 +178,17 @@ export function getVisibilitySettings() {
|
||||
visibility.ai = "hidden"; break;
|
||||
}
|
||||
|
||||
switch (uncontrolledVisibilityButton.getState()) {
|
||||
case 0:
|
||||
visibility.uncontrolled = "full"; break;
|
||||
case 1:
|
||||
visibility.uncontrolled = "partial"; break;
|
||||
case 2:
|
||||
visibility.uncontrolled = "none"; break;
|
||||
case 3:
|
||||
visibility.uncontrolled = "hidden"; break;
|
||||
}
|
||||
|
||||
switch (weaponVisibilityButton.getState()) {
|
||||
case 0:
|
||||
visibility.weapon = "partial"; break;
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as L from "leaflet"
|
||||
import { getSelectionWheel, getSelectionScroll, getUnitsManager, getActiveCoalition, getMouseInfoPanel } from "..";
|
||||
import { spawnAircraft, spawnGroundUnit, spawnSmoke } from "../dcs/dcs";
|
||||
import { bearing, distance, zeroAppend } from "../other/utils";
|
||||
import { payloadNames } from "../units/payloadNames";
|
||||
import { aircraftDatabase, getAircraftLabelsByRole, getLoadoutsByName, getLoadoutNamesByRole } from "../units/aircraftDatabase";
|
||||
import { unitTypes } from "../units/unitTypes";
|
||||
import { BoxSelect } from "./boxselect";
|
||||
|
||||
@@ -278,6 +278,23 @@ export class Map extends L.Map {
|
||||
}
|
||||
|
||||
/* Spawning menus */
|
||||
#aircraftSpawnMenu(e: SpawnEvent) {
|
||||
var options = [
|
||||
{ 'coalition': true, 'tooltip': 'CAP', 'src': 'spawnCAP.png', 'callback': () => this.#selectAircraft(e, "cap") },
|
||||
{ 'coalition': true, 'tooltip': 'CAS', 'src': 'spawnCAS.png', 'callback': () => this.#selectAircraft(e, "cas") },
|
||||
{ 'coalition': true, 'tooltip': 'Strike', 'src': 'spawnStrike.png', 'callback': () => this.#selectAircraft(e, "strike") },
|
||||
{ 'coalition': true, 'tooltip': 'Recce', 'src': 'spawnStrike.png', 'callback': () => this.#selectAircraft(e, "reconnaissance") },
|
||||
{ 'coalition': true, 'tooltip': 'Tanker', 'src': 'spawnTanker.png', 'callback': () => this.#selectAircraft(e, "tanker") },
|
||||
{ 'coalition': true, 'tooltip': 'AWACS', 'src': 'spawnAWACS.png', 'callback': () => this.#selectAircraft(e, "awacs") },
|
||||
{ 'coalition': true, 'tooltip': 'Drone', 'src': 'spawnDrone.png', 'callback': () => this.#selectAircraft(e, "drone") },
|
||||
{ 'coalition': true, 'tooltip': 'Transport', 'src': 'spawnTransport.png', 'callback': () => this.#selectAircraft(e, "transport") },
|
||||
]
|
||||
if (e.airbaseName != null)
|
||||
this.showSelectionScroll(e, "Spawn at " + e.airbaseName, options, () => {}, true);
|
||||
else
|
||||
this.showSelectionScroll(e, "Spawn air unit", options, () => {}, true);
|
||||
}
|
||||
|
||||
#groundUnitSpawnMenu(e: SpawnEvent) {
|
||||
var options = [
|
||||
{'coalition': true, 'tooltip': 'Howitzer', 'src': 'spawnHowitzer.png', 'callback': () => this.#selectGroundUnit(e, "Howitzers")},
|
||||
@@ -308,50 +325,31 @@ export class Map extends L.Map {
|
||||
|
||||
}
|
||||
|
||||
#aircraftSpawnMenu(e: SpawnEvent) {
|
||||
var options = [
|
||||
{ 'coalition': true, 'tooltip': 'CAP', 'src': 'spawnCAP.png', 'callback': () => this.#selectAircraft(e, "CAP") },
|
||||
{ 'coalition': true, 'tooltip': 'CAS', 'src': 'spawnCAS.png', 'callback': () => this.#selectAircraft(e, "CAS") },
|
||||
{ 'coalition': true, 'tooltip': 'Tanker', 'src': 'spawnTanker.png', 'callback': () => this.#selectAircraft(e, "tanker") },
|
||||
{ 'coalition': true, 'tooltip': 'AWACS', 'src': 'spawnAWACS.png', 'callback': () => this.#selectAircraft(e, "awacs") },
|
||||
{ 'coalition': true, 'tooltip': 'Strike', 'src': 'spawnStrike.png', 'callback': () => this.#selectAircraft(e, "strike") },
|
||||
{ 'coalition': true, 'tooltip': 'Drone', 'src': 'spawnDrone.png', 'callback': () => this.#selectAircraft(e, "drone") },
|
||||
{ 'coalition': true, 'tooltip': 'Transport', 'src': 'spawnTransport.png', 'callback': () => this.#selectAircraft(e, "transport") },
|
||||
]
|
||||
if (e.airbaseName != null)
|
||||
this.showSelectionScroll(e, "Spawn at " + e.airbaseName, options, () => {}, true);
|
||||
else
|
||||
this.showSelectionScroll(e, "Spawn air unit", options, () => {}, true);
|
||||
}
|
||||
|
||||
/* Show unit selection for air units */
|
||||
#selectAircraft(e: SpawnEvent, group: string) {
|
||||
#selectAircraft(e: SpawnEvent, role: string) {
|
||||
this.hideSelectionWheel();
|
||||
this.hideSelectionScroll();
|
||||
var options = unitTypes.air[group];
|
||||
if (options != undefined)
|
||||
options.sort();
|
||||
else
|
||||
options = [];
|
||||
var options = getAircraftLabelsByRole(role);
|
||||
this.showSelectionScroll(e, "Select aircraft", options, (unitType: string) => {
|
||||
this.hideSelectionWheel();
|
||||
this.hideSelectionScroll();
|
||||
this.#unitSelectPayload(e, unitType);
|
||||
this.#unitSelectPayload(e, unitType, role);
|
||||
}, true);
|
||||
}
|
||||
|
||||
/* Show weapon selection for air units */
|
||||
#unitSelectPayload(e: SpawnEvent, unitType: string) {
|
||||
#unitSelectPayload(e: SpawnEvent, unitType: string, role: string) {
|
||||
this.hideSelectionWheel();
|
||||
this.hideSelectionScroll();
|
||||
var options = [];
|
||||
options = payloadNames[unitType]
|
||||
var options = getLoadoutNamesByRole(unitType, role);
|
||||
//options = payloadNames[unitType]
|
||||
if (options != undefined && options.length > 0) {
|
||||
options.sort();
|
||||
this.showSelectionScroll({x: e.x, y: e.y, latlng: e.latlng}, "Select loadout", options, (payloadName: string) => {
|
||||
this.showSelectionScroll({x: e.x, y: e.y, latlng: e.latlng}, "Select loadout", options, (loadoutName: string) => {
|
||||
this.hideSelectionWheel();
|
||||
this.hideSelectionScroll();
|
||||
spawnAircraft(unitType, e.latlng, getActiveCoalition(), payloadName, e.airbaseName);
|
||||
var loadout = getLoadoutsByName(unitType, loadoutName);
|
||||
spawnAircraft(unitType, e.latlng, getActiveCoalition(), loadout.code, e.airbaseName);
|
||||
}, true);
|
||||
}
|
||||
else {
|
||||
|
||||
1236
client/src/units/aircraftDatabase.ts
Normal file
1236
client/src/units/aircraftDatabase.ts
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -12,6 +12,7 @@ var pathIcon = new Icon({
|
||||
|
||||
export class Unit {
|
||||
ID: number = -1;
|
||||
AI: boolean = false;
|
||||
formation: string = "";
|
||||
name: string = "";
|
||||
unitName: string = "";
|
||||
@@ -387,6 +388,9 @@ export class Unit {
|
||||
|
||||
export class AirUnit extends Unit {
|
||||
getHidden() {
|
||||
if (this.AI == false && getVisibilitySettings().uncontrolled === "hidden")
|
||||
return true
|
||||
|
||||
if (this.alive)
|
||||
{
|
||||
if (this.flags.user && getVisibilitySettings().user === "hidden")
|
||||
@@ -421,6 +425,9 @@ export class GroundUnit extends Unit {
|
||||
}
|
||||
|
||||
getHidden() {
|
||||
if (this.AI == false && getVisibilitySettings().uncontrolled === "hidden")
|
||||
return true
|
||||
|
||||
if (this.alive)
|
||||
{
|
||||
if (this.flags.user && getVisibilitySettings().user === "hidden")
|
||||
@@ -441,6 +448,9 @@ export class NavyUnit extends Unit {
|
||||
}
|
||||
|
||||
getHidden() {
|
||||
if (this.AI == false && getVisibilitySettings().uncontrolled === "hidden")
|
||||
return true
|
||||
|
||||
if (this.alive)
|
||||
{
|
||||
if (this.flags.user && getVisibilitySettings().user === "hidden")
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface MarkerOptions {
|
||||
human: boolean
|
||||
coalitionID: number
|
||||
type: any
|
||||
AI: boolean
|
||||
}
|
||||
|
||||
export interface MarkerData {
|
||||
@@ -21,6 +22,7 @@ export class UnitMarker extends L.Marker {
|
||||
#unitName: string
|
||||
#name: string
|
||||
#human: boolean
|
||||
#AI: boolean
|
||||
#alive: boolean = true
|
||||
#selected: boolean = false
|
||||
|
||||
@@ -29,6 +31,7 @@ export class UnitMarker extends L.Marker {
|
||||
this.#unitName = options.unitName;
|
||||
this.#name = options.name;
|
||||
this.#human = options.human;
|
||||
this.#AI = options.AI;
|
||||
|
||||
var symbol = new Symbol(this.#computeMarkerCode(options), { size: 25 });
|
||||
var img = symbol.asCanvas().toDataURL('image/png');
|
||||
@@ -127,6 +130,10 @@ export class UnitMarker extends L.Marker {
|
||||
return this.#human;
|
||||
}
|
||||
|
||||
getAI() {
|
||||
return this.#AI;
|
||||
}
|
||||
|
||||
getAlive() {
|
||||
return this.#alive;
|
||||
}
|
||||
@@ -226,7 +233,7 @@ export class AirUnitMarker extends UnitMarker {
|
||||
else if (!this.getAlive())
|
||||
return "none";
|
||||
else
|
||||
return getVisibilitySettings().ai;
|
||||
return this.getAI()? getVisibilitySettings().ai: getVisibilitySettings().uncontrolled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +254,7 @@ export class GroundUnitMarker extends UnitMarker {
|
||||
else if (!this.getAlive())
|
||||
return "none";
|
||||
else
|
||||
return getVisibilitySettings().ai;
|
||||
return this.getAI()? getVisibilitySettings().ai: getVisibilitySettings().uncontrolled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +266,7 @@ export class NavyUnitMarker extends UnitMarker {
|
||||
if (!this.getAlive())
|
||||
return "none";
|
||||
else
|
||||
return getVisibilitySettings().ai;
|
||||
return this.getAI()? getVisibilitySettings().ai: getVisibilitySettings().uncontrolled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ export class UnitsManager {
|
||||
name: data.name,
|
||||
human: data.human,
|
||||
coalitionID: data.coalitionID,
|
||||
type: data.type
|
||||
type: data.type,
|
||||
AI: data.AI
|
||||
}
|
||||
this.#units[ID] = new constructor(ID, options);
|
||||
}
|
||||
@@ -112,10 +113,13 @@ export class UnitsManager {
|
||||
this.deselectAllUnits();
|
||||
for (let ID in this.#units)
|
||||
{
|
||||
var latlng = new LatLng(this.#units[ID].latitude, this.#units[ID].longitude);
|
||||
if (bounds.contains(latlng))
|
||||
if (this.#units[ID].getHidden() == false)
|
||||
{
|
||||
this.#units[ID].setSelected(true);
|
||||
var latlng = new LatLng(this.#units[ID].latitude, this.#units[ID].longitude);
|
||||
if (bounds.contains(latlng))
|
||||
{
|
||||
this.#units[ID].setSelected(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user