mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Completed unit nation selection and new spawn menu
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ export class Dropdown {
|
|||||||
#defaultValue: string;
|
#defaultValue: string;
|
||||||
#optionsList: string[] = [];
|
#optionsList: string[] = [];
|
||||||
#index: number = 0;
|
#index: number = 0;
|
||||||
|
#hidden: boolean = false;
|
||||||
|
|
||||||
constructor(ID: string | null, callback: CallableFunction, options: string[] | null = null, defaultText?: string) {
|
constructor(ID: string | null, callback: CallableFunction, options: string[] | null = null, defaultText?: string) {
|
||||||
if (ID === null)
|
if (ID === null)
|
||||||
@@ -139,11 +140,17 @@ export class Dropdown {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
this.#container.classList.add("show");
|
this.#container.classList.remove("hide");
|
||||||
|
this.#hidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hide() {
|
hide() {
|
||||||
this.#container.classList.add("hide");
|
this.#container.classList.add("hide");
|
||||||
|
this.#hidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
isHidden() {
|
||||||
|
return this.#hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
#toggle() {
|
#toggle() {
|
||||||
|
|||||||
@@ -63,7 +63,12 @@ export class Slider extends Control {
|
|||||||
|
|
||||||
setValue(newValue: number, ignoreExpectedValue: boolean = true) {
|
setValue(newValue: number, ignoreExpectedValue: boolean = true) {
|
||||||
if (!this.getDragged() && (ignoreExpectedValue || this.checkExpectedValue(newValue))) {
|
if (!this.getDragged() && (ignoreExpectedValue || this.checkExpectedValue(newValue))) {
|
||||||
this.#value = newValue;
|
if (this.#value !== newValue) {
|
||||||
|
this.#value = newValue;
|
||||||
|
if (this.#callback)
|
||||||
|
this.#callback(this.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
if (this.#slider != null)
|
if (this.#slider != null)
|
||||||
this.#slider.value = String((newValue - this.#minValue) / (this.#maxValue - this.#minValue) * parseFloat(this.#slider.max));
|
this.#slider.value = String((newValue - this.#minValue) / (this.#maxValue - this.#minValue) * parseFloat(this.#slider.max));
|
||||||
this.#update();
|
this.#update();
|
||||||
|
|||||||
@@ -84,7 +84,10 @@ export class UnitSpawnMenu {
|
|||||||
advancedOptionsText.innerText = "Advanced options";
|
advancedOptionsText.innerText = "Advanced options";
|
||||||
var advancedOptionsHr = document.createElement("hr");
|
var advancedOptionsHr = document.createElement("hr");
|
||||||
advancedOptionsToggle.append(advancedOptionsText, advancedOptionsHr);
|
advancedOptionsToggle.append(advancedOptionsText, advancedOptionsHr);
|
||||||
advancedOptionsToggle.addEventListener("click", () => { advancedOptionsDiv.classList.toggle("hide") });
|
advancedOptionsToggle.addEventListener("click", () => {
|
||||||
|
advancedOptionsDiv.classList.toggle("hide");
|
||||||
|
this.#container.dispatchEvent(new Event("resize"));
|
||||||
|
});
|
||||||
advancedOptionsDiv.append(this.#unitCountryDropdown.getContainer(), this.#unitLiveryDropdown.getContainer(),
|
advancedOptionsDiv.append(this.#unitCountryDropdown.getContainer(), this.#unitLiveryDropdown.getContainer(),
|
||||||
this.#unitLoadoutPreviewEl, this.#unitSpawnAltitudeSlider.getContainer() as HTMLElement);
|
this.#unitLoadoutPreviewEl, this.#unitSpawnAltitudeSlider.getContainer() as HTMLElement);
|
||||||
|
|
||||||
@@ -94,7 +97,9 @@ export class UnitSpawnMenu {
|
|||||||
this.#deployUnitButtonEl.disabled = true;
|
this.#deployUnitButtonEl.disabled = true;
|
||||||
this.#deployUnitButtonEl.innerText = "Deploy unit";
|
this.#deployUnitButtonEl.innerText = "Deploy unit";
|
||||||
this.#deployUnitButtonEl.setAttribute("data-coalition", "blue");
|
this.#deployUnitButtonEl.setAttribute("data-coalition", "blue");
|
||||||
this.#deployUnitButtonEl.addEventListener("click", () => { this.#deployUnits(); });
|
this.#deployUnitButtonEl.addEventListener("click", () => {
|
||||||
|
this.deployUnits(this.#spawnOptions, parseInt(this.#unitCountDropdown.getValue()));
|
||||||
|
});
|
||||||
|
|
||||||
/* Assemble all components */
|
/* Assemble all components */
|
||||||
this.#container.append(this.#unitRoleTypeDropdown.getContainer(), unitLabelCountContainerEl, this.#unitLoadoutDropdown.getContainer(),
|
this.#container.append(this.#unitRoleTypeDropdown.getContainer(), unitLabelCountContainerEl, this.#unitLoadoutDropdown.getContainer(),
|
||||||
@@ -115,13 +120,11 @@ export class UnitSpawnMenu {
|
|||||||
|
|
||||||
/* Event listeners */
|
/* Event listeners */
|
||||||
this.#container.addEventListener("unitRoleTypeChanged", () => {
|
this.#container.addEventListener("unitRoleTypeChanged", () => {
|
||||||
|
this.#deployUnitButtonEl.disabled = true;
|
||||||
this.#unitLabelDropdown.reset();
|
this.#unitLabelDropdown.reset();
|
||||||
if (this.#unitLoadoutListEl !== null)
|
this.#unitLoadoutListEl.replaceChildren();
|
||||||
this.#unitLoadoutListEl.replaceChildren();
|
this.#unitLoadoutDropdown.reset();
|
||||||
if (this.#unitLoadoutDropdown !== null)
|
this.#unitImageEl.classList.toggle("hide", true);
|
||||||
this.#unitLoadoutDropdown.reset();
|
|
||||||
if (this.#unitImageEl !== null)
|
|
||||||
this.#unitImageEl.classList.toggle("hide", true);
|
|
||||||
this.#unitLiveryDropdown.reset();
|
this.#unitLiveryDropdown.reset();
|
||||||
|
|
||||||
if (this.#orderByRole)
|
if (this.#orderByRole)
|
||||||
@@ -129,18 +132,24 @@ export class UnitSpawnMenu {
|
|||||||
else
|
else
|
||||||
this.#unitLabelDropdown.setOptions(this.#unitDatabase.getByType(this.#spawnOptions.roleType).map((blueprint) => { return blueprint.label }));
|
this.#unitLabelDropdown.setOptions(this.#unitDatabase.getByType(this.#spawnOptions.roleType).map((blueprint) => { return blueprint.label }));
|
||||||
this.#container.dispatchEvent(new Event("resize"));
|
this.#container.dispatchEvent(new Event("resize"));
|
||||||
|
|
||||||
|
this.#spawnOptions.name = "";
|
||||||
|
this.#spawnOptions.loadout = undefined;
|
||||||
|
this.#spawnOptions.liveryID = undefined;
|
||||||
|
|
||||||
this.#computeSpawnPoints();
|
this.#computeSpawnPoints();
|
||||||
})
|
})
|
||||||
|
|
||||||
this.#container.addEventListener("unitLabelChanged", () => {
|
this.#container.addEventListener("unitLabelChanged", () => {
|
||||||
if (this.#unitLoadoutDropdown !== null) {
|
this.#deployUnitButtonEl.disabled = false;
|
||||||
|
if (!this.#unitLoadoutDropdown.isHidden()) {
|
||||||
this.#unitLoadoutDropdown.setOptions(this.#unitDatabase.getLoadoutNamesByRole(this.#spawnOptions.name, this.#spawnOptions.roleType));
|
this.#unitLoadoutDropdown.setOptions(this.#unitDatabase.getLoadoutNamesByRole(this.#spawnOptions.name, this.#spawnOptions.roleType));
|
||||||
this.#unitLoadoutDropdown.selectValue(0);
|
this.#unitLoadoutDropdown.selectValue(0);
|
||||||
}
|
}
|
||||||
if (this.#unitImageEl !== null) {
|
|
||||||
this.#unitImageEl.src = `images/units/${this.#unitDatabase.getByName(this.#spawnOptions.name)?.filename}`;
|
this.#unitImageEl.src = `images/units/${this.#unitDatabase.getByName(this.#spawnOptions.name)?.filename}`;
|
||||||
this.#unitImageEl.classList.toggle("hide", false);
|
this.#unitImageEl.classList.toggle("hide", false);
|
||||||
}
|
|
||||||
this.#setUnitLiveryOptions();
|
this.#setUnitLiveryOptions();
|
||||||
|
|
||||||
this.#container.dispatchEvent(new Event("resize"));
|
this.#container.dispatchEvent(new Event("resize"));
|
||||||
@@ -148,9 +157,8 @@ export class UnitSpawnMenu {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.#container.addEventListener("unitLoadoutChanged", () => {
|
this.#container.addEventListener("unitLoadoutChanged", () => {
|
||||||
this.#deployUnitButtonEl.disabled = false;
|
|
||||||
var items = this.#spawnOptions.loadout?.items.map((item: any) => { return `${item.quantity}x ${item.name}`; });
|
var items = this.#spawnOptions.loadout?.items.map((item: any) => { return `${item.quantity}x ${item.name}`; });
|
||||||
if (items != undefined && this.#unitLoadoutListEl !== null) {
|
if (items != undefined) {
|
||||||
items.length == 0 ? items.push("Empty loadout") : "";
|
items.length == 0 ? items.push("Empty loadout") : "";
|
||||||
this.#unitLoadoutListEl.replaceChildren(
|
this.#unitLoadoutListEl.replaceChildren(
|
||||||
...items.map((item: any) => {
|
...items.map((item: any) => {
|
||||||
@@ -191,12 +199,9 @@ export class UnitSpawnMenu {
|
|||||||
else
|
else
|
||||||
this.#unitRoleTypeDropdown.setOptions(this.#unitDatabase.getTypes());
|
this.#unitRoleTypeDropdown.setOptions(this.#unitDatabase.getTypes());
|
||||||
|
|
||||||
if (this.#unitLoadoutListEl !== null)
|
this.#unitLoadoutListEl.replaceChildren();
|
||||||
this.#unitLoadoutListEl.replaceChildren();
|
this.#unitLoadoutDropdown.reset();
|
||||||
if (this.#unitLoadoutDropdown !== null)
|
this.#unitImageEl.classList.toggle("hide", true);
|
||||||
this.#unitLoadoutDropdown.reset();
|
|
||||||
if (this.#unitImageEl !== null)
|
|
||||||
this.#unitImageEl.classList.toggle("hide", true);
|
|
||||||
|
|
||||||
this.setCountries();
|
this.setCountries();
|
||||||
this.#container.dispatchEvent(new Event("resize"));
|
this.#container.dispatchEvent(new Event("resize"));
|
||||||
@@ -208,7 +213,7 @@ export class UnitSpawnMenu {
|
|||||||
this.#unitCountryDropdown.setOptionsElements(this.#createCountryButtons(this.#unitCountryDropdown, countries, (country: string) => { this.#setUnitCountry(country) }));
|
this.#unitCountryDropdown.setOptionsElements(this.#createCountryButtons(this.#unitCountryDropdown, countries, (country: string) => { this.#setUnitCountry(country) }));
|
||||||
|
|
||||||
if (countries.length > 0 && !countries.includes(this.#spawnOptions.country)) {
|
if (countries.length > 0 && !countries.includes(this.#spawnOptions.country)) {
|
||||||
this.#unitCountryDropdown.forceValue(countries[0]);
|
this.#unitCountryDropdown.forceValue(this.#getFormattedCountry(countries[0]));
|
||||||
this.#setUnitCountry(countries[0]);
|
this.#setUnitCountry(countries[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,10 +305,15 @@ export class UnitSpawnMenu {
|
|||||||
|
|
||||||
#setUnitLivery(liveryName: string) {
|
#setUnitLivery(liveryName: string) {
|
||||||
var liveries = this.#unitDatabase.getByName(this.#spawnOptions.name)?.liveries;
|
var liveries = this.#unitDatabase.getByName(this.#spawnOptions.name)?.liveries;
|
||||||
if (liveries !== undefined) {
|
if (liveryName === "Default") {
|
||||||
for (let liveryID in liveries)
|
this.#spawnOptions.liveryID = "";
|
||||||
if (liveries[liveryID].name === liveryName)
|
}
|
||||||
this.#spawnOptions.liveryID = liveryID;
|
else {
|
||||||
|
if (liveries !== undefined) {
|
||||||
|
for (let liveryID in liveries)
|
||||||
|
if (liveries[liveryID].name === liveryName)
|
||||||
|
this.#spawnOptions.liveryID = liveryID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.#container.dispatchEvent(new Event("unitLiveryChanged"));
|
this.#container.dispatchEvent(new Event("unitLiveryChanged"));
|
||||||
}
|
}
|
||||||
@@ -314,7 +324,7 @@ export class UnitSpawnMenu {
|
|||||||
var countryLiveries: string[] = ["Default"];
|
var countryLiveries: string[] = ["Default"];
|
||||||
liveries.forEach((livery: any) => {
|
liveries.forEach((livery: any) => {
|
||||||
var nationLiveryCodes = this.#countryCodes[this.#spawnOptions.country].liveryCodes;
|
var nationLiveryCodes = this.#countryCodes[this.#spawnOptions.country].liveryCodes;
|
||||||
if (livery.countries.some((country: string) => { return nationLiveryCodes.includes(country) }))
|
if (livery.countries === "All" || livery.countries.some((country: string) => { return nationLiveryCodes.includes(country) }))
|
||||||
countryLiveries.push(livery.name);
|
countryLiveries.push(livery.name);
|
||||||
});
|
});
|
||||||
this.#unitLiveryDropdown.setOptions(countryLiveries);
|
this.#unitLiveryDropdown.setOptions(countryLiveries);
|
||||||
@@ -322,43 +332,20 @@ export class UnitSpawnMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#deployUnits() {
|
deployUnits(spawnOptions: UnitSpawnOptions, unitsCount: number) {
|
||||||
this.#spawnOptions.coalition = getActiveCoalition();
|
/* Virtual function must be overloaded by inheriting classes */
|
||||||
if (this.#spawnOptions) {
|
|
||||||
var unitTable = {
|
|
||||||
unitType: this.#spawnOptions.name,
|
|
||||||
location: this.#spawnOptions.latlng,
|
|
||||||
altitude: this.#spawnOptions.altitude,
|
|
||||||
loadout: this.#spawnOptions.loadout,
|
|
||||||
liveryID: this.#spawnOptions.liveryID
|
|
||||||
};
|
|
||||||
var units = [];
|
|
||||||
for (let i = 1; i < parseInt(this.#unitCountDropdown.getValue()) + 1; i++) {
|
|
||||||
units.push(unitTable);
|
|
||||||
}
|
|
||||||
if (getUnitsManager().spawnUnits("Unit", units, getActiveCoalition(), false, this.#spawnOptions.airbase ? this.#spawnOptions.airbase.getName() : "", this.#spawnOptions.country)) {
|
|
||||||
getMap().addTemporaryMarker(this.#spawnOptions.latlng, this.#spawnOptions.name, getActiveCoalition());
|
|
||||||
getMap().getMapContextMenu().hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#createCountryButtons(parent: Dropdown, countries: string[], callback: CallableFunction) {
|
#createCountryButtons(parent: Dropdown, countries: string[], callback: CallableFunction) {
|
||||||
return Object.values(countries).map((country: string) => {
|
return Object.values(countries).map((country: string) => {
|
||||||
var el = document.createElement("div");
|
var el = document.createElement("div");
|
||||||
|
|
||||||
var formattedCountry = "";
|
|
||||||
if (this.#countryCodes[country] !== undefined && this.#countryCodes[country].displayName !== undefined)
|
|
||||||
formattedCountry = this.#countryCodes[country].displayName;
|
|
||||||
else
|
|
||||||
formattedCountry = country.charAt(0).toUpperCase() + country.slice(1).toLowerCase();
|
|
||||||
|
|
||||||
var button = document.createElement("button");
|
var button = document.createElement("button");
|
||||||
button.classList.add("country-dropdown-element");
|
button.classList.add("country-dropdown-element");
|
||||||
el.appendChild(button);
|
el.appendChild(button);
|
||||||
button.addEventListener("click", () => {
|
button.addEventListener("click", () => {
|
||||||
callback(country);
|
callback(country);
|
||||||
parent.forceValue(formattedCountry);
|
parent.forceValue(this.#getFormattedCountry(country));
|
||||||
parent.close();
|
parent.close();
|
||||||
});
|
});
|
||||||
if (this.#countryCodes[country] !== undefined) {
|
if (this.#countryCodes[country] !== undefined) {
|
||||||
@@ -373,12 +360,21 @@ export class UnitSpawnMenu {
|
|||||||
console.log("Unknown country " + country);
|
console.log("Unknown country " + country);
|
||||||
}
|
}
|
||||||
var text = document.createElement("div");
|
var text = document.createElement("div");
|
||||||
text.innerText = formattedCountry;
|
text.innerText = this.#getFormattedCountry(country);
|
||||||
button.appendChild(text);
|
button.appendChild(text);
|
||||||
return el;
|
return el;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#getFormattedCountry(country: string) {
|
||||||
|
var formattedCountry = "";
|
||||||
|
if (this.#countryCodes[country] !== undefined && this.#countryCodes[country].displayName !== undefined)
|
||||||
|
formattedCountry = this.#countryCodes[country].displayName;
|
||||||
|
else
|
||||||
|
formattedCountry = country.charAt(0).toUpperCase() + country.slice(1).toLowerCase();
|
||||||
|
return formattedCountry;
|
||||||
|
}
|
||||||
|
|
||||||
#computeSpawnPoints() {
|
#computeSpawnPoints() {
|
||||||
if (getMissionHandler() && getMissionHandler().getCommandModeOptions().commandMode !== GAME_MASTER) {
|
if (getMissionHandler() && getMissionHandler().getCommandModeOptions().commandMode !== GAME_MASTER) {
|
||||||
var unitCount = parseInt(this.#unitCountDropdown.getValue());
|
var unitCount = parseInt(this.#unitCountDropdown.getValue());
|
||||||
@@ -401,6 +397,27 @@ export class AircraftSpawnMenu extends UnitSpawnMenu {
|
|||||||
this.getAltitudeSlider().setIncrement(500);
|
this.getAltitudeSlider().setIncrement(500);
|
||||||
this.getAltitudeSlider().setValue(20000);
|
this.getAltitudeSlider().setValue(20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deployUnits(spawnOptions: UnitSpawnOptions, unitsCount: number) {
|
||||||
|
spawnOptions.coalition = getActiveCoalition();
|
||||||
|
if (spawnOptions) {
|
||||||
|
var unitTable = {
|
||||||
|
unitType: spawnOptions.name,
|
||||||
|
location: spawnOptions.latlng,
|
||||||
|
altitude: spawnOptions.altitude? spawnOptions.altitude: 0,
|
||||||
|
loadout: spawnOptions.loadout? spawnOptions.loadout.name: "",
|
||||||
|
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: ""
|
||||||
|
};
|
||||||
|
var units = [];
|
||||||
|
for (let i = 1; i < unitsCount + 1; i++) {
|
||||||
|
units.push(unitTable);
|
||||||
|
}
|
||||||
|
if (getUnitsManager().spawnUnits("Aircraft", units, getActiveCoalition(), false, spawnOptions.airbase ? spawnOptions.airbase.getName() : "", spawnOptions.country)) {
|
||||||
|
getMap().addTemporaryMarker(spawnOptions.latlng, spawnOptions.name, getActiveCoalition());
|
||||||
|
getMap().getMapContextMenu().hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HelicopterSpawnMenu extends UnitSpawnMenu {
|
export class HelicopterSpawnMenu extends UnitSpawnMenu {
|
||||||
@@ -415,6 +432,27 @@ export class HelicopterSpawnMenu extends UnitSpawnMenu {
|
|||||||
this.getAltitudeSlider().setIncrement(100);
|
this.getAltitudeSlider().setIncrement(100);
|
||||||
this.getAltitudeSlider().setValue(5000);
|
this.getAltitudeSlider().setValue(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deployUnits(spawnOptions: UnitSpawnOptions, unitsCount: number) {
|
||||||
|
spawnOptions.coalition = getActiveCoalition();
|
||||||
|
if (spawnOptions) {
|
||||||
|
var unitTable = {
|
||||||
|
unitType: spawnOptions.name,
|
||||||
|
location: spawnOptions.latlng,
|
||||||
|
altitude: spawnOptions.altitude? spawnOptions.altitude: 0,
|
||||||
|
loadout: spawnOptions.loadout? spawnOptions.loadout.name: "",
|
||||||
|
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: ""
|
||||||
|
};
|
||||||
|
var units = [];
|
||||||
|
for (let i = 1; i < unitsCount + 1; i++) {
|
||||||
|
units.push(unitTable);
|
||||||
|
}
|
||||||
|
if (getUnitsManager().spawnUnits("Helicopter", units, getActiveCoalition(), false, spawnOptions.airbase ? spawnOptions.airbase.getName() : "", spawnOptions.country)) {
|
||||||
|
getMap().addTemporaryMarker(spawnOptions.latlng, spawnOptions.name, getActiveCoalition());
|
||||||
|
getMap().getMapContextMenu().hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GroundUnitSpawnMenu extends UnitSpawnMenu {
|
export class GroundUnitSpawnMenu extends UnitSpawnMenu {
|
||||||
@@ -429,6 +467,26 @@ export class GroundUnitSpawnMenu extends UnitSpawnMenu {
|
|||||||
this.getLoadoutDropdown().hide();
|
this.getLoadoutDropdown().hide();
|
||||||
this.getLoadoutPreview().classList.add("hide");
|
this.getLoadoutPreview().classList.add("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deployUnits(spawnOptions: UnitSpawnOptions, unitsCount: number) {
|
||||||
|
spawnOptions.coalition = getActiveCoalition();
|
||||||
|
if (spawnOptions) {
|
||||||
|
var unitTable = {
|
||||||
|
unitType: spawnOptions.name,
|
||||||
|
location: spawnOptions.latlng,
|
||||||
|
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: ""
|
||||||
|
};
|
||||||
|
var units = [];
|
||||||
|
for (let i = 1; i < unitsCount + 1; i++) {
|
||||||
|
units.push(JSON.parse(JSON.stringify(unitTable)));
|
||||||
|
unitTable.location.lat += 0.0001;
|
||||||
|
}
|
||||||
|
if (getUnitsManager().spawnUnits("GroundUnit", units, getActiveCoalition(), false, spawnOptions.airbase ? spawnOptions.airbase.getName() : "", spawnOptions.country)) {
|
||||||
|
getMap().addTemporaryMarker(spawnOptions.latlng, spawnOptions.name, getActiveCoalition());
|
||||||
|
getMap().getMapContextMenu().hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NavyUnitSpawnMenu extends UnitSpawnMenu {
|
export class NavyUnitSpawnMenu extends UnitSpawnMenu {
|
||||||
@@ -443,4 +501,24 @@ export class NavyUnitSpawnMenu extends UnitSpawnMenu {
|
|||||||
this.getLoadoutDropdown().hide();
|
this.getLoadoutDropdown().hide();
|
||||||
this.getLoadoutPreview().classList.add("hide");
|
this.getLoadoutPreview().classList.add("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deployUnits(spawnOptions: UnitSpawnOptions, unitsCount: number) {
|
||||||
|
spawnOptions.coalition = getActiveCoalition();
|
||||||
|
if (spawnOptions) {
|
||||||
|
var unitTable = {
|
||||||
|
unitType: spawnOptions.name,
|
||||||
|
location: spawnOptions.latlng,
|
||||||
|
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: ""
|
||||||
|
};
|
||||||
|
var units = [];
|
||||||
|
for (let i = 1; i < unitsCount + 1; i++) {
|
||||||
|
units.push(JSON.parse(JSON.stringify(unitTable)));
|
||||||
|
unitTable.location.lat += 0.0001;
|
||||||
|
}
|
||||||
|
if (getUnitsManager().spawnUnits("NavyUnit", units, getActiveCoalition(), false, spawnOptions.airbase ? spawnOptions.airbase.getName() : "", spawnOptions.country)) {
|
||||||
|
getMap().addTemporaryMarker(spawnOptions.latlng, spawnOptions.name, getActiveCoalition());
|
||||||
|
getMap().getMapContextMenu().hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { LatLng } from "leaflet";
|
import { LatLng } from "leaflet";
|
||||||
import { getInfoPopup, getMap } from "..";
|
import { getInfoPopup, getMap } from "..";
|
||||||
import { Airbase, AirbaseChartData } from "./airbase";
|
import { Airbase } from "./airbase";
|
||||||
import { Bullseye } from "./bullseye";
|
import { Bullseye } from "./bullseye";
|
||||||
import { BLUE_COMMANDER, GAME_MASTER, NONE, RED_COMMANDER } from "../constants/constants";
|
import { BLUE_COMMANDER, GAME_MASTER, NONE, RED_COMMANDER } from "../constants/constants";
|
||||||
import { refreshAll, setCommandModeOptions } from "../server/server";
|
import { refreshAll, setCommandModeOptions } from "../server/server";
|
||||||
|
|||||||
@@ -170,14 +170,14 @@ export function spawnHelicopters(units: any, coalition: string, airbaseName: str
|
|||||||
POST(data, () => { });
|
POST(data, () => { });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function spawnGroundUnits(units: any, coalition: string, immediate: boolean, spawnPoints: number) {
|
export function spawnGroundUnits(units: any, coalition: string, country: string, immediate: boolean, spawnPoints: number) {
|
||||||
var command = { "units": units, "coalition": coalition, "immediate": immediate, "spawnPoints": spawnPoints };;
|
var command = { "units": units, "coalition": coalition, "country": country, "immediate": immediate, "spawnPoints": spawnPoints };;
|
||||||
var data = { "spawnGroundUnits": command }
|
var data = { "spawnGroundUnits": command }
|
||||||
POST(data, () => { });
|
POST(data, () => { });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function spawnNavyUnits(units: any, coalition: string, immediate: boolean, spawnPoints: number) {
|
export function spawnNavyUnits(units: any, coalition: string, country: string, immediate: boolean, spawnPoints: number) {
|
||||||
var command = { "units": units, "coalition": coalition, "immediate": immediate, "spawnPoints": spawnPoints };
|
var command = { "units": units, "coalition": coalition, "country": country, "immediate": immediate, "spawnPoints": spawnPoints };
|
||||||
var data = { "spawnNavyUnits": command }
|
var data = { "spawnNavyUnits": command }
|
||||||
POST(data, () => { });
|
POST(data, () => { });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -722,14 +722,14 @@ export class UnitsManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
spawnPoints = units.reduce((points: number, unit: any) => {return points + groundUnitDatabase.getSpawnPointsByName(unit.unitType)}, 0);
|
spawnPoints = units.reduce((points: number, unit: any) => {return points + groundUnitDatabase.getSpawnPointsByName(unit.unitType)}, 0);
|
||||||
spawnGroundUnits(units, coalition, immediate, spawnPoints);
|
spawnGroundUnits(units, coalition, country, immediate, spawnPoints);
|
||||||
} else if (category === "NavyUnit") {
|
} else if (category === "NavyUnit") {
|
||||||
if (getMissionHandler().getCommandModeOptions().restrictSpawns && getMissionHandler().getRemainingSetupTime() < 0 && getMissionHandler().getCommandModeOptions().commandMode !== GAME_MASTER) {
|
if (getMissionHandler().getCommandModeOptions().restrictSpawns && getMissionHandler().getRemainingSetupTime() < 0 && getMissionHandler().getCommandModeOptions().commandMode !== GAME_MASTER) {
|
||||||
getInfoPopup().setText("Navy units can be spawned during the SETUP phase only");
|
getInfoPopup().setText("Navy units can be spawned during the SETUP phase only");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
spawnPoints = units.reduce((points: number, unit: any) => {return points + navyUnitDatabase.getSpawnPointsByName(unit.unitType)}, 0);
|
spawnPoints = units.reduce((points: number, unit: any) => {return points + navyUnitDatabase.getSpawnPointsByName(unit.unitType)}, 0);
|
||||||
spawnNavyUnits(units, coalition, immediate, spawnPoints);
|
spawnNavyUnits(units, coalition, country, immediate, spawnPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spawnPoints <= getMissionHandler().getAvailableSpawnPoints()) {
|
if (spawnPoints <= getMissionHandler().getAvailableSpawnPoints()) {
|
||||||
|
|||||||
@@ -461,8 +461,6 @@ function Olympus.generateAirUnitsTable(units)
|
|||||||
["livery_id"] = unit.liveryID
|
["livery_id"] = unit.liveryID
|
||||||
}
|
}
|
||||||
|
|
||||||
Olympus.debug(unit.liveryID, 5)
|
|
||||||
|
|
||||||
-- Add the payload to the registry, used for unit cloning
|
-- Add the payload to the registry, used for unit cloning
|
||||||
Olympus.payloadRegistry[unitTable[#unitTable].name] = payload
|
Olympus.payloadRegistry[unitTable[#unitTable].name] = payload
|
||||||
end
|
end
|
||||||
|
|||||||
2
scripts/python/.vscode/launch.json
vendored
2
scripts/python/.vscode/launch.json
vendored
@@ -11,7 +11,7 @@
|
|||||||
"program": "${file}",
|
"program": "${file}",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"justMyCode": true,
|
"justMyCode": true,
|
||||||
"args": ["C:\\Users\\dpass\\Documents\\DCSOlympus\\client\\public\\databases\\units\\aircraftdatabase.json"]
|
"args": ["groundunit"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
94
scripts/python/addLiveries.py
Normal file
94
scripts/python/addLiveries.py
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import inspect
|
||||||
|
import difflib
|
||||||
|
from slpp import slpp as lua
|
||||||
|
|
||||||
|
SEARCH_FOLDER = "D:\\Eagle Dynamics\\DCS World OpenBeta"
|
||||||
|
|
||||||
|
sys.path.append("..\\..\\..\\dcs-master\\dcs-master")
|
||||||
|
|
||||||
|
from dcs.weapons_data import Weapons
|
||||||
|
from dcs.planes import *
|
||||||
|
from dcs.helicopters import *
|
||||||
|
from dcs.vehicles import *
|
||||||
|
from dcs.ships import *
|
||||||
|
from dcs.liveries.liveryscanner import LiveryScanner
|
||||||
|
|
||||||
|
livery_scanner = LiveryScanner()
|
||||||
|
livery_scanner.scan_dcs_installation(SEARCH_FOLDER)
|
||||||
|
|
||||||
|
# Known id mismatches (because reasons, ask ED)
|
||||||
|
mismatched_ids = {
|
||||||
|
"A-10CII": "A-10C_2"
|
||||||
|
}
|
||||||
|
|
||||||
|
# The database file on which to operate is the first standard argument of the call
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
if (sys.argv[1] == "aircraft"):
|
||||||
|
filename = '..\\..\\client\\public\\databases\\units\\aircraftdatabase.json'
|
||||||
|
elif (sys.argv[1] == "helicopter"):
|
||||||
|
filename = '..\\..\\client\\public\\databases\\units\\helicopterdatabase.json'
|
||||||
|
elif (sys.argv[1] == "groundunit"):
|
||||||
|
filename = '..\\..\\client\\public\\databases\\units\\groundunitdatabase.json'
|
||||||
|
elif (sys.argv[1] == "navyunit"):
|
||||||
|
filename = '..\\..\\client\\public\\databases\\units\\navyunitdatabase.json'
|
||||||
|
|
||||||
|
# Loads the database
|
||||||
|
with open(filename) as f:
|
||||||
|
database = json.load(f)
|
||||||
|
for unit_name in database:
|
||||||
|
database[unit_name]["enabled"] = True
|
||||||
|
|
||||||
|
# Loop on all the units in the database
|
||||||
|
for unit_name in database:
|
||||||
|
try:
|
||||||
|
# Get the pydcs Python class for the unit
|
||||||
|
if (sys.argv[1] == "aircraft"):
|
||||||
|
unitmap = plane_map
|
||||||
|
elif (sys.argv[1] == "helicopter"):
|
||||||
|
unitmap = helicopter_map
|
||||||
|
elif (sys.argv[1] == "groundunit"):
|
||||||
|
unitmap = vehicle_map
|
||||||
|
elif (sys.argv[1] == "navyunit"):
|
||||||
|
unitmap = ship_map
|
||||||
|
lowercase_keys = [key.lower() for key in unitmap.keys()]
|
||||||
|
res = difflib.get_close_matches(unit_name.lower(), lowercase_keys)
|
||||||
|
if len(res) > 0:
|
||||||
|
found_name = list(unitmap.keys())[lowercase_keys.index(res[0])]
|
||||||
|
cls = unitmap[found_name]
|
||||||
|
else:
|
||||||
|
print(f"Warning, could not find {unit_name} in classes list. Skipping...")
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Add the liveries
|
||||||
|
liveries = []
|
||||||
|
if unit_name in livery_scanner.map:
|
||||||
|
liveries = livery_scanner.map[unit_name]
|
||||||
|
else:
|
||||||
|
if (unit_name in mismatched_ids):
|
||||||
|
found_name = mismatched_ids[unit_name]
|
||||||
|
else:
|
||||||
|
lowercase_keys = [key.lower() for key in livery_scanner.map.keys()]
|
||||||
|
res = difflib.get_close_matches(unit_name.lower(), lowercase_keys)
|
||||||
|
found_name = list(livery_scanner.map.keys())[lowercase_keys.index(res[0])]
|
||||||
|
print(f"Warning, could not find {unit_name} in liveries list. Best match is {found_name}. Manual check required!")
|
||||||
|
liveries = livery_scanner.map[found_name]
|
||||||
|
|
||||||
|
database[unit_name]["liveries"] = {}
|
||||||
|
for livery in liveries:
|
||||||
|
database[unit_name]["liveries"][livery.id] = {
|
||||||
|
"name": livery.name,
|
||||||
|
"countries": [country for country in livery.countries] if livery.countries != None else "All"
|
||||||
|
}
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Could not find data for aircraft of type {unit_name}: {e}, skipping...")
|
||||||
|
|
||||||
|
# Dump everything in the database
|
||||||
|
with open(filename, "w") as f:
|
||||||
|
json.dump(database, f, indent=2)
|
||||||
|
|
||||||
|
# Done!
|
||||||
|
print("Done!")
|
||||||
|
|
||||||
|
|
||||||
@@ -11,10 +11,6 @@ sys.path.append("..\..\..\dcs-master\dcs-master")
|
|||||||
from dcs.weapons_data import Weapons
|
from dcs.weapons_data import Weapons
|
||||||
from dcs.planes import *
|
from dcs.planes import *
|
||||||
from dcs.helicopters import *
|
from dcs.helicopters import *
|
||||||
from dcs.liveries.liveryscanner import LiveryScanner
|
|
||||||
|
|
||||||
livery_scanner = LiveryScanner()
|
|
||||||
livery_scanner.scan_dcs_installation(SEARCH_FOLDER)
|
|
||||||
|
|
||||||
# Known id mismatches (because reasons, ask ED)
|
# Known id mismatches (because reasons, ask ED)
|
||||||
mismatched_ids = {
|
mismatched_ids = {
|
||||||
@@ -29,11 +25,20 @@ def find_weapon_name(clsid):
|
|||||||
for weapon_id in weapon_ids:
|
for weapon_id in weapon_ids:
|
||||||
if getattr(Weapons, weapon_id)["clsid"] == clsid:
|
if getattr(Weapons, weapon_id)["clsid"] == clsid:
|
||||||
return getattr(Weapons, weapon_id)["name"]
|
return getattr(Weapons, weapon_id)["name"]
|
||||||
|
|
||||||
# The database file on which to operate is the first standard argument of the call
|
# The database file on which to operate is the first standard argument of the call
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
|
if (sys.argv[1] == "aircraft"):
|
||||||
|
filename = '..\\..\\client\\public\\databases\\units\\aircraftdatabase.json'
|
||||||
|
elif (sys.argv[1] == "helicopter"):
|
||||||
|
filename = '..\\..\\client\\public\\databases\\units\\helicopterdatabase.json'
|
||||||
|
elif (sys.argv[1] == "groundunit"):
|
||||||
|
filename = '..\\..\\client\\public\\databases\\units\\groundunitdatabase.json'
|
||||||
|
elif (sys.argv[1] == "navyunit"):
|
||||||
|
filename = '..\\..\\client\\public\\databases\\units\\navyunitdatabase.json'
|
||||||
|
|
||||||
# Loads the database
|
# Loads the database
|
||||||
with open(sys.argv[1]) as f:
|
with open(filename) as f:
|
||||||
database = json.load(f)
|
database = json.load(f)
|
||||||
for unit_name in database:
|
for unit_name in database:
|
||||||
database[unit_name]["enabled"] = True
|
database[unit_name]["enabled"] = True
|
||||||
@@ -51,28 +56,22 @@ if len(sys.argv) > 1:
|
|||||||
for unit_name in database:
|
for unit_name in database:
|
||||||
try:
|
try:
|
||||||
# Get the pydcs Python class for the unit
|
# Get the pydcs Python class for the unit
|
||||||
cls = getattr(sys.modules[__name__], unit_name.replace("-", "_").replace(" ", "_"))
|
if (sys.argv[1] == "aircraft"):
|
||||||
|
unitmap = plane_map
|
||||||
# Add the liveries
|
elif (sys.argv[1] == "helicopter"):
|
||||||
liveries = []
|
unitmap = helicopter_map
|
||||||
if unit_name in livery_scanner.map:
|
elif (sys.argv[1] == "groundunit"):
|
||||||
liveries = livery_scanner.map[unit_name]
|
unitmap = vehicle_map
|
||||||
|
elif (sys.argv[1] == "navyunit"):
|
||||||
|
unitmap = ship_map
|
||||||
|
lowercase_keys = [key.lower() for key in unitmap.keys()]
|
||||||
|
res = difflib.get_close_matches(unit_name.lower(), lowercase_keys)
|
||||||
|
if len(res) > 0:
|
||||||
|
found_name = list(unitmap.keys())[lowercase_keys.index(res[0])]
|
||||||
|
cls = unitmap[found_name]
|
||||||
else:
|
else:
|
||||||
if (unit_name in mismatched_ids):
|
print(f"Warning, could not find {unit_name} in classes list. Skipping...")
|
||||||
found_name = mismatched_ids[unit_name]
|
continue
|
||||||
else:
|
|
||||||
lowercase_keys = [key.lower() for key in livery_scanner.map.keys()]
|
|
||||||
res = difflib.get_close_matches(unit_name.lower(), lowercase_keys)
|
|
||||||
found_name = list(livery_scanner.map.keys())[lowercase_keys.index(res[0])]
|
|
||||||
print(f"Warning, could not find {unit_name} in liveries list. Best match is {found_name}. Manual check required!")
|
|
||||||
liveries = livery_scanner.map[found_name]
|
|
||||||
|
|
||||||
database[unit_name]["liveries"] = {}
|
|
||||||
for livery in liveries:
|
|
||||||
database[unit_name]["liveries"][livery.id] = {
|
|
||||||
"name": livery.name,
|
|
||||||
"countries": [country for country in livery.countries]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create the loadouts table and add the empty loadout for the default task
|
# Create the loadouts table and add the empty loadout for the default task
|
||||||
database[unit_name]["loadouts"] = []
|
database[unit_name]["loadouts"] = []
|
||||||
@@ -124,7 +123,7 @@ if len(sys.argv) > 1:
|
|||||||
print(f"Could not find data for aircraft of type {unit_name}: {e}, skipping...")
|
print(f"Could not find data for aircraft of type {unit_name}: {e}, skipping...")
|
||||||
|
|
||||||
# Dump everything in the database
|
# Dump everything in the database
|
||||||
with open(sys.argv[1], "w") as f:
|
with open(filename, "w") as f:
|
||||||
json.dump(database, f, indent=2)
|
json.dump(database, f, indent=2)
|
||||||
|
|
||||||
# Done!
|
# Done!
|
||||||
@@ -155,9 +155,10 @@ private:
|
|||||||
class SpawnGroundUnits : public Command
|
class SpawnGroundUnits : public Command
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SpawnGroundUnits(string coalition, vector<SpawnOptions> spawnOptions, bool immediate) :
|
SpawnGroundUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, bool immediate) :
|
||||||
coalition(coalition),
|
coalition(coalition),
|
||||||
spawnOptions(spawnOptions),
|
spawnOptions(spawnOptions),
|
||||||
|
country(country),
|
||||||
immediate(immediate)
|
immediate(immediate)
|
||||||
{
|
{
|
||||||
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
||||||
@@ -168,6 +169,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
const string coalition;
|
const string coalition;
|
||||||
const vector<SpawnOptions> spawnOptions;
|
const vector<SpawnOptions> spawnOptions;
|
||||||
|
const string country;
|
||||||
const bool immediate;
|
const bool immediate;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -175,9 +177,10 @@ private:
|
|||||||
class SpawnNavyUnits : public Command
|
class SpawnNavyUnits : public Command
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SpawnNavyUnits(string coalition, vector<SpawnOptions> spawnOptions, bool immediate) :
|
SpawnNavyUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, bool immediate) :
|
||||||
coalition(coalition),
|
coalition(coalition),
|
||||||
spawnOptions(spawnOptions),
|
spawnOptions(spawnOptions),
|
||||||
|
country(country),
|
||||||
immediate(immediate)
|
immediate(immediate)
|
||||||
{
|
{
|
||||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||||
@@ -188,6 +191,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
const string coalition;
|
const string coalition;
|
||||||
const vector<SpawnOptions> spawnOptions;
|
const vector<SpawnOptions> spawnOptions;
|
||||||
|
const string country;
|
||||||
const bool immediate;
|
const bool immediate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ string SpawnGroundUnits::getString()
|
|||||||
commandSS << "Olympus.spawnUnits, {"
|
commandSS << "Olympus.spawnUnits, {"
|
||||||
<< "category = " << "\"" << "GroundUnit" << "\"" << ", "
|
<< "category = " << "\"" << "GroundUnit" << "\"" << ", "
|
||||||
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
||||||
|
<< "country = \"" << country << "\", "
|
||||||
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
||||||
return commandSS.str();
|
return commandSS.str();
|
||||||
}
|
}
|
||||||
@@ -78,6 +79,7 @@ string SpawnNavyUnits::getString()
|
|||||||
commandSS << "Olympus.spawnUnits, {"
|
commandSS << "Olympus.spawnUnits, {"
|
||||||
<< "category = " << "\"" << "NavyUnit" << "\"" << ", "
|
<< "category = " << "\"" << "NavyUnit" << "\"" << ", "
|
||||||
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
||||||
|
<< "country = \"" << country << "\", "
|
||||||
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
||||||
return commandSS.str();
|
return commandSS.str();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ void Scheduler::handleRequest(string key, json::value value, string username)
|
|||||||
{
|
{
|
||||||
bool immediate = value[L"immediate"].as_bool();
|
bool immediate = value[L"immediate"].as_bool();
|
||||||
string coalition = to_string(value[L"coalition"]);
|
string coalition = to_string(value[L"coalition"]);
|
||||||
|
string country = to_string(value[L"country"]);
|
||||||
|
|
||||||
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
|
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
|
||||||
if (!checkSpawnPoints(spawnPoints, coalition)) return;
|
if (!checkSpawnPoints(spawnPoints, coalition)) return;
|
||||||
@@ -242,16 +243,17 @@ void Scheduler::handleRequest(string key, json::value value, string username)
|
|||||||
Coords location; location.lat = lat; location.lng = lng;
|
Coords location; location.lat = lat; location.lng = lng;
|
||||||
string liveryID = to_string(unit[L"liveryID"]);
|
string liveryID = to_string(unit[L"liveryID"]);
|
||||||
|
|
||||||
spawnOptions.push_back({ unitType, location, "", liveryID});
|
spawnOptions.push_back({ unitType, location, "", liveryID });
|
||||||
log(username + " spawned a " + coalition + " " + unitType, true);
|
log(username + " spawned a " + coalition + " " + unitType, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, spawnOptions, immediate));
|
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, spawnOptions, country, immediate));
|
||||||
}
|
}
|
||||||
else if (key.compare("spawnNavyUnits") == 0)
|
else if (key.compare("spawnNavyUnits") == 0)
|
||||||
{
|
{
|
||||||
bool immediate = value[L"immediate"].as_bool();
|
bool immediate = value[L"immediate"].as_bool();
|
||||||
string coalition = to_string(value[L"coalition"]);
|
string coalition = to_string(value[L"coalition"]);
|
||||||
|
string country = to_string(value[L"country"]);
|
||||||
|
|
||||||
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
|
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
|
||||||
if (!checkSpawnPoints(spawnPoints, coalition)) return;
|
if (!checkSpawnPoints(spawnPoints, coalition)) return;
|
||||||
@@ -264,11 +266,11 @@ void Scheduler::handleRequest(string key, json::value value, string username)
|
|||||||
Coords location; location.lat = lat; location.lng = lng;
|
Coords location; location.lat = lat; location.lng = lng;
|
||||||
string liveryID = to_string(unit[L"liveryID"]);
|
string liveryID = to_string(unit[L"liveryID"]);
|
||||||
|
|
||||||
spawnOptions.push_back({ unitType, location, "", liveryID });
|
spawnOptions.push_back({ unitType, location, "", liveryID});
|
||||||
log(username + " spawned a " + coalition + " " + unitType, true);
|
log(username + " spawned a " + coalition + " " + unitType, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, spawnOptions, immediate));
|
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, spawnOptions, country, immediate));
|
||||||
}
|
}
|
||||||
else if (key.compare("attackUnit") == 0)
|
else if (key.compare("attackUnit") == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user