mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Unit spawn qty now sorted numerically.
This commit is contained in:
parent
24cd2729db
commit
4d31d9d748
@ -36,8 +36,21 @@ export class Dropdown {
|
||||
return this.#container;
|
||||
}
|
||||
|
||||
setOptions(optionsList: string[], sortAlphabetically: boolean = true) {
|
||||
this.#optionsList = optionsList.sort();
|
||||
setOptions(optionsList: string[], sort:""|"string"|"number" = "string") {
|
||||
|
||||
if ( sort === "number" ) {
|
||||
this.#optionsList = optionsList.sort( (optionA:string, optionB:string) => {
|
||||
const a = parseInt( optionA );
|
||||
const b = parseInt( optionB );
|
||||
if ( a > b )
|
||||
return 1;
|
||||
else
|
||||
return ( b > a ) ? -1 : 0;
|
||||
});
|
||||
} else if ( sort === "string" ) {
|
||||
this.#optionsList = optionsList.sort();
|
||||
}
|
||||
|
||||
if (this.#optionsList.length == 0) {
|
||||
optionsList = ["No options available"]
|
||||
this.#value.innerText = "No options available";
|
||||
|
||||
@ -346,7 +346,7 @@ export class UnitSpawnMenu {
|
||||
var countOptions: string[] = [];
|
||||
for (let i = 1; i <= maxUnitCount; i++)
|
||||
countOptions.push(i.toString());
|
||||
this.#unitCountDropdown.setOptions(countOptions);
|
||||
this.#unitCountDropdown.setOptions(countOptions, "number");
|
||||
this.#unitCountDropdown.selectValue(0);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user