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:
parent
72c6e4e94e
commit
85b1404321
@ -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 ) => {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<div id="unit-list-panel" class="ol-panel">
|
||||
<div id="unit-list-panel" class="ol-panel hide">
|
||||
<h3>Unit List</h3>
|
||||
<div class="unit-list-unit headers">
|
||||
<div data-sort-field="unitName">Name</div>
|
||||
<div data-sort-field="name">Vehicle</div>
|
||||
<div data-sort-field="coalition">Coalition</div>
|
||||
<div data-sort-field="human">Human/AI</div>
|
||||
<div>Human/AI</div>
|
||||
</div>
|
||||
<div id="unit-list-panel-content" class="ol-scrollable"></div>
|
||||
</div>
|
||||
Loading…
x
Reference in New Issue
Block a user