mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
More sorting, changed keybind to U
This commit is contained in:
@@ -68,7 +68,7 @@ export class UnitListPanel extends Panel {
|
||||
"callback": () => {
|
||||
this.toggle()
|
||||
},
|
||||
"code": "Quote"
|
||||
"code": "KeyU"
|
||||
});
|
||||
|
||||
this.startUpdates();
|
||||
@@ -86,14 +86,18 @@ export class UnitListPanel extends Panel {
|
||||
this.#units = Object.values( this.#olympusApp.getUnitsManager().getUnits() );
|
||||
|
||||
|
||||
if ( this.#currentSortAlgorithm === "unitName" ) {
|
||||
this.#sortUnitsByUnitName();
|
||||
if ( this.#currentSortAlgorithm === "coalition" ) {
|
||||
this.#sortUnitsByCoalition();
|
||||
}
|
||||
|
||||
if ( this.#currentSortAlgorithm === "name" ) {
|
||||
this.#sortUnitsByName();
|
||||
}
|
||||
|
||||
if ( this.#currentSortAlgorithm === "unitName" ) {
|
||||
this.#sortUnitsByUnitName();
|
||||
}
|
||||
|
||||
|
||||
Object.values( this.#units ).forEach( ( unit:Unit ) => {
|
||||
|
||||
@@ -142,6 +146,28 @@ export class UnitListPanel extends Panel {
|
||||
|
||||
}
|
||||
|
||||
#sortUnitsByCoalition() {
|
||||
|
||||
this.#units.sort( ( unit1:Unit, unit2:Unit ) => {
|
||||
|
||||
let str1 = unit1.getCoalition();
|
||||
let str2 = unit2.getCoalition();
|
||||
|
||||
let cmp = this.#sortStringsCompare( str1, str2 );
|
||||
|
||||
if ( cmp !== 0 ) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
str1 = unit1.getUnitName().toLowerCase();
|
||||
str2 = unit2.getUnitName().toLowerCase();
|
||||
|
||||
return this.#sortStringsCompare( str1, str2 );
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
#sortUnitsByName() {
|
||||
|
||||
this.#units.sort( ( unit1:Unit, unit2:Unit ) => {
|
||||
|
||||
Reference in New Issue
Block a user