Completed aircraft spawn contextmenu
BIN
client/public/images/units/a-10.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
client/public/images/units/a-20.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
client/public/images/units/a-29.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
client/public/images/units/a-4.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
client/public/images/units/a-400.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
BIN
client/public/images/units/a-50.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
client/public/images/units/a-6.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
client/public/images/units/ah-1.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
client/public/images/units/ah-64.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
client/public/images/units/airUnit.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
client/public/images/units/airliner2engine.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
client/public/images/units/an-26.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
client/public/images/units/av8bna.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
client/public/images/units/b-1.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
client/public/images/units/b-17.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
client/public/images/units/b-2.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
client/public/images/units/b-52.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
client/public/images/units/b707.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
client/public/images/units/bf109.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
client/public/images/units/c-101.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
client/public/images/units/c-130.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
client/public/images/units/c-17.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
client/public/images/units/c-5.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
client/public/images/units/ch-47.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
client/public/images/units/ch-53.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
client/public/images/units/e-2.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
client/public/images/units/e-3.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
client/public/images/units/eurofighter.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
client/public/images/units/f-111.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
client/public/images/units/f-117.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
client/public/images/units/f-14.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
client/public/images/units/f-15.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
client/public/images/units/f-16c.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
client/public/images/units/f-22.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
client/public/images/units/f-35.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
client/public/images/units/f-4.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
client/public/images/units/f-5.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
client/public/images/units/f-86.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
client/public/images/units/fa-18c.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
client/public/images/units/fw190.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
client/public/images/units/general1.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
client/public/images/units/gripen.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
client/public/images/units/h-6.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
client/public/images/units/hawk.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
client/public/images/units/helicopter1.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
client/public/images/units/i-16.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
client/public/images/units/il-76.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
client/public/images/units/j-10.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
client/public/images/units/j-20.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
client/public/images/units/j-7.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
client/public/images/units/jf-17.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
client/public/images/units/ju-88.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
client/public/images/units/ka-27.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
client/public/images/units/ka-50.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
client/public/images/units/kc-10.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
client/public/images/units/kc-135.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
client/public/images/units/l-159.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
client/public/images/units/l-39.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
client/public/images/units/m2000.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
client/public/images/units/mi-24.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
client/public/images/units/mi-26.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
client/public/images/units/mi-28.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
client/public/images/units/mi-8.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
client/public/images/units/mig-15.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
client/public/images/units/mig-19.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
client/public/images/units/mig-21.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
client/public/images/units/mig-23.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
client/public/images/units/mig-25.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
client/public/images/units/mig-29.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
client/public/images/units/mosquito.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
client/public/images/units/oh-58.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
client/public/images/units/p-47.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
client/public/images/units/p-51.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
client/public/images/units/rafale.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
client/public/images/units/rq-1.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
client/public/images/units/rq-4.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
client/public/images/units/s-3.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
client/public/images/units/sa-342.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
client/public/images/units/spitfire.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
client/public/images/units/su-17.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
client/public/images/units/su-24.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
client/public/images/units/su-25.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
client/public/images/units/su-27.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
client/public/images/units/su-34.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
client/public/images/units/su-57.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
client/public/images/units/tornado.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
client/public/images/units/tu-160.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
client/public/images/units/tu-22.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
client/public/images/units/tu-95.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
client/public/images/units/u-28.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
client/public/images/units/uh-1.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
client/public/images/units/uh-60.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
client/public/images/units/viggen.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
client/public/images/units/yak-40.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
client/public/images/units/yak-52.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
@ -2,8 +2,17 @@
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#contextmenu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 5px;
|
||||
width: 230px;
|
||||
height: fit-content;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#aircraft-spawn-menu {
|
||||
height: 191px;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
#active-coalition-label {
|
||||
@ -25,16 +34,7 @@
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.ol-contextmenu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 5px;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.ol-contextmenu>div:nth-child(2){
|
||||
#contextmenu>div:nth-child(2){
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
@ -42,27 +42,27 @@
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
.ol-contextmenu>ul{
|
||||
#contextmenu>ul{
|
||||
max-height: 200px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.ol-contextmenu .ol-panel {
|
||||
#contextmenu .ol-panel {
|
||||
width: 100%;
|
||||
border-radius: var(--border-radius-sm);
|
||||
}
|
||||
|
||||
.ol-contextmenu ul {
|
||||
#contextmenu ul {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.ol-contextmenu>div:nth-child(3)>button {
|
||||
#contextmenu>div:nth-child(3)>button {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.ol-contextmenu>div:nth-child(3){
|
||||
#contextmenu>div:nth-child(3){
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@ -71,13 +71,13 @@
|
||||
row-gap: 5px;
|
||||
}
|
||||
|
||||
.ol-contextmenu .ol-select-container{
|
||||
#contextmenu .ol-select-container{
|
||||
width: 100%;
|
||||
flex:0 0 auto;
|
||||
align-self: stretch;
|
||||
}
|
||||
|
||||
#deploy-unit-button {
|
||||
#contextmenu>div:nth-child(3)>button:last-of-type {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
@ -145,4 +145,27 @@
|
||||
}
|
||||
[data-active-coalition=red]#active-coalition-label::after {
|
||||
content: "Create red unit";
|
||||
}
|
||||
|
||||
#loadout-preview {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
column-gap: 20px;
|
||||
}
|
||||
|
||||
#loadout-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-content: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#unit-image {
|
||||
width: 100px;
|
||||
filter: invert(100%);
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
1
client/src/@types/unitdatabase.d.ts
vendored
@ -16,4 +16,5 @@ interface UnitBlueprint {
|
||||
label: string;
|
||||
shortLabel: string;
|
||||
loadouts: LoadoutBlueprint[];
|
||||
filename: string;
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ export class ContextMenu {
|
||||
this.#container = document.getElementById(id);
|
||||
this.#container?.querySelector("#context-menu-switch")?.addEventListener('change', (e) => this.#onSwitch(e));
|
||||
|
||||
this.#aircraftRoleDropdown = new Dropdown("role-options", (role: string) => this.#setAircraftRole(role), aircraftDatabase.getRoles());
|
||||
this.#aircraftRoleDropdown = new Dropdown("role-options", (role: string) => this.#setAircraftRole(role));
|
||||
this.#aircraftTypeDropdown = new Dropdown("aircraft-options", (type: string) => this.#setAircraftType(type));
|
||||
this.#aircraftLoadoutDropdown = new Dropdown("loadout-options", (loadout: string) => this.#setAircraftLoadout(loadout));
|
||||
//this.#unitsNumberDropdown = new Dropdown("#units-options", this.#setAircraftType, [""]);
|
||||
@ -36,6 +36,9 @@ export class ContextMenu {
|
||||
document.addEventListener("contextMenuShow", (e: any) => {
|
||||
this.#container?.querySelector("#aircraft-spawn-menu")?.classList.toggle("hide", e.detail.type !== "aircraft");
|
||||
this.#container?.querySelector("#unit-spawn-aircraft")?.classList.toggle("is-open", e.detail.type === "aircraft");
|
||||
|
||||
this.#resetAircraftRole();
|
||||
this.#resetAircraftType();
|
||||
})
|
||||
|
||||
document.addEventListener("contextMenuDeployAircraft", () => {
|
||||
@ -77,24 +80,50 @@ export class ContextMenu {
|
||||
}
|
||||
}
|
||||
|
||||
/********* Aircraft spawn menu *********/
|
||||
#setAircraftRole(role: string)
|
||||
{
|
||||
if (this.#spawnOptions != null)
|
||||
{
|
||||
this.#spawnOptions.role = role;
|
||||
this.#resetAircraftRole();
|
||||
this.#aircraftTypeDropdown.setOptions(aircraftDatabase.getLabelsByRole(role));
|
||||
this.#aircraftTypeDropdown.selectValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
#setAircraftType(type: string)
|
||||
#resetAircraftRole() {
|
||||
(<HTMLButtonElement>this.#container?.querySelector("#deploy-unit-button")).disabled = true;
|
||||
(<HTMLButtonElement>this.#container?.querySelector("#loadout-list")).replaceChildren();
|
||||
this.#aircraftTypeDropdown.reset();
|
||||
this.#aircraftRoleDropdown.setOptions(aircraftDatabase.getRoles());
|
||||
}
|
||||
|
||||
#setAircraftType(label: string)
|
||||
{
|
||||
if (this.#spawnOptions != null)
|
||||
{
|
||||
this.#spawnOptions.type = type;
|
||||
this.#aircraftLoadoutDropdown.setOptions(aircraftDatabase.getLoadoutNamesByRole(type, this.#spawnOptions.role));
|
||||
this.#resetAircraftType();
|
||||
var type = aircraftDatabase.getNameByLabel(label);
|
||||
if (type != null)
|
||||
{
|
||||
this.#spawnOptions.type = type;
|
||||
this.#aircraftLoadoutDropdown.setOptions(aircraftDatabase.getLoadoutNamesByRole(type, this.#spawnOptions.role));
|
||||
this.#aircraftLoadoutDropdown.selectValue(0);
|
||||
var image = (<HTMLImageElement>this.#container?.querySelector("#unit-image"));
|
||||
image.src = `images/units/${aircraftDatabase.getByLabel(label)?.filename}`;
|
||||
image.classList.toggle("hide", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#resetAircraftType() {
|
||||
(<HTMLButtonElement>this.#container?.querySelector("#deploy-unit-button")).disabled = true;
|
||||
(<HTMLButtonElement>this.#container?.querySelector("#loadout-list")).replaceChildren();
|
||||
this.#aircraftLoadoutDropdown.reset();
|
||||
(<HTMLImageElement>this.#container?.querySelector("#unit-image")).classList.toggle("hide", true);
|
||||
}
|
||||
|
||||
#setAircraftLoadout(loadoutName: string)
|
||||
{
|
||||
if (this.#spawnOptions != null)
|
||||
@ -104,12 +133,16 @@ export class ContextMenu {
|
||||
{
|
||||
this.#spawnOptions.loadout = loadout.code;
|
||||
(<HTMLButtonElement>this.#container?.querySelector("#deploy-unit-button")).disabled = false;
|
||||
var items = loadout.items.map((item: any) => {return `${item.quantity}x ${item.name}`;});
|
||||
items.length == 0? items.push("Empty loadout"): "";
|
||||
(<HTMLButtonElement>this.#container?.querySelector("#loadout-list")).replaceChildren(
|
||||
...items.map((item: any) => {
|
||||
var div = document.createElement('div');
|
||||
div.innerText = item;
|
||||
return div;
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#setUnitsNumber(unitsNumber: string)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -3,21 +3,24 @@ export class Dropdown {
|
||||
#options: HTMLElement;
|
||||
#value: HTMLElement;
|
||||
#callback: CallableFunction;
|
||||
#defaultValue: string;
|
||||
#optionsList: string[] = [];
|
||||
|
||||
constructor(ID: string, callback: CallableFunction, options: string[] | null = null)
|
||||
{
|
||||
this.#element = <HTMLElement>document.getElementById(ID);
|
||||
var element = this.#element;
|
||||
this.#options = <HTMLElement>this.#element.querySelector(".ol-select-options");
|
||||
this.#value = <HTMLElement>this.#element.querySelector(".ol-select-value");
|
||||
this.#defaultValue = this.#value.innerText;
|
||||
this.#callback = callback;
|
||||
if (options != null)
|
||||
this.setOptions(options);
|
||||
}
|
||||
|
||||
setOptions(options: string[])
|
||||
setOptions(optionsList: string[])
|
||||
{
|
||||
this.#options.replaceChildren(...options.map((option: string) => {
|
||||
this.#optionsList = optionsList;
|
||||
this.#options.replaceChildren(...optionsList.map((option: string) => {
|
||||
var div = document.createElement("div");
|
||||
var button = document.createElement("button");
|
||||
button.textContent = option;
|
||||
@ -29,4 +32,19 @@ export class Dropdown {
|
||||
return div;
|
||||
}));
|
||||
}
|
||||
|
||||
selectValue(idx: number)
|
||||
{
|
||||
if (idx < this.#optionsList.length)
|
||||
{
|
||||
var option = this.#optionsList[idx];
|
||||
this.#value.innerText = option;
|
||||
this.#callback(option);
|
||||
}
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.#options.replaceChildren();
|
||||
this.#value.innerText = this.#defaultValue;
|
||||
}
|
||||
}
|
||||
@ -54,12 +54,12 @@ export function rad2deg(rad: number) {
|
||||
}
|
||||
|
||||
|
||||
export function reciprocalHeading( heading:number ): number {
|
||||
|
||||
if ( heading > 180 ) {
|
||||
export function reciprocalHeading(heading: number): number {
|
||||
|
||||
if (heading > 180) {
|
||||
return heading - 180;
|
||||
}
|
||||
|
||||
|
||||
return heading + 180;
|
||||
|
||||
}
|
||||
@ -80,4 +80,46 @@ export const zeroPad = function (num: number, places: number) {
|
||||
string += "0";
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
export function similarity(s1: string, s2: string) {
|
||||
var longer = s1;
|
||||
var shorter = s2;
|
||||
if (s1.length < s2.length) {
|
||||
longer = s2;
|
||||
shorter = s1;
|
||||
}
|
||||
var longerLength = longer.length;
|
||||
if (longerLength == 0) {
|
||||
return 1.0;
|
||||
}
|
||||
return (longerLength - editDistance(longer, shorter)) / longerLength;
|
||||
}
|
||||
|
||||
export function editDistance(s1: string, s2: string) {
|
||||
s1 = s1.toLowerCase();
|
||||
s2 = s2.toLowerCase();
|
||||
|
||||
var costs = new Array();
|
||||
for (var i = 0; i <= s1.length; i++) {
|
||||
var lastValue = i;
|
||||
for (var j = 0; j <= s2.length; j++) {
|
||||
if (i == 0)
|
||||
costs[j] = j;
|
||||
else {
|
||||
if (j > 0) {
|
||||
var newValue = costs[j - 1];
|
||||
if (s1.charAt(i - 1) != s2.charAt(j - 1))
|
||||
newValue = Math.min(Math.min(newValue, lastValue),
|
||||
costs[j]) + 1;
|
||||
costs[j - 1] = lastValue;
|
||||
lastValue = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
costs[s2.length] = lastValue;
|
||||
}
|
||||
return costs[s2.length];
|
||||
}
|
||||