This commit is contained in:
tobspr 2020-08-28 20:56:04 +02:00
commit bfe2795677
3 changed files with 33 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

View File

@ -22,12 +22,18 @@
@include S(margin-left, 1px); @include S(margin-left, 1px);
&.displayIcons, &.displayIcons,
&.displayDetailed { &.displayDetailed,
&.displaySorted {
background: uiResource("icons/display_list.png") center center / #{D(15px)} no-repeat; background: uiResource("icons/display_list.png") center center / #{D(15px)} no-repeat;
&.displayIcons { &.displayIcons {
background-image: uiResource("icons/display_icons.png"); background-image: uiResource("icons/display_icons.png");
background-size: #{D(11.5px)}; background-size: #{D(11.5px)};
} }
&.displaySorted {
background-image: uiResource("icons/display_sorted.png");
background-size: #{D(11.5px)};
margin-right: 20px;
}
} }
background-color: #44484a !important; background-color: #44484a !important;
@ -109,6 +115,7 @@
.dialogInner { .dialogInner {
&[data-displaymode="detailed"] .displayDetailed, &[data-displaymode="detailed"] .displayDetailed,
&[data-displaymode="icons"] .displayIcons, &[data-displaymode="icons"] .displayIcons,
&[data-sorted="true"] .displaySorted,
&[data-datasource="produced"] .modeProduced, &[data-datasource="produced"] .modeProduced,
&[data-datasource="delivered"] .modeDelivered, &[data-datasource="delivered"] .modeDelivered,
&[data-datasource="stored"] .modeStored { &[data-datasource="stored"] .modeStored {

View File

@ -47,9 +47,11 @@ export class HUDStatistics extends BaseHUDPart {
this.trackClicks(button, () => this.setDataSource(dataSource)); this.trackClicks(button, () => this.setDataSource(dataSource));
} }
const buttonDisplaySorted = makeButton(this.filtersDisplayMode, ["displaySorted"]);
const buttonDisplayDetailed = makeButton(this.filtersDisplayMode, ["displayDetailed"]); const buttonDisplayDetailed = makeButton(this.filtersDisplayMode, ["displayDetailed"]);
const buttonDisplayIcons = makeButton(this.filtersDisplayMode, ["displayIcons"]); const buttonDisplayIcons = makeButton(this.filtersDisplayMode, ["displayIcons"]);
this.trackClicks(buttonDisplaySorted, () => this.toggleSorted());
this.trackClicks(buttonDisplayIcons, () => this.setDisplayMode(enumDisplayMode.icons)); this.trackClicks(buttonDisplayIcons, () => this.setDisplayMode(enumDisplayMode.icons));
this.trackClicks(buttonDisplayDetailed, () => this.setDisplayMode(enumDisplayMode.detailed)); this.trackClicks(buttonDisplayDetailed, () => this.setDisplayMode(enumDisplayMode.detailed));
@ -80,6 +82,21 @@ export class HUDStatistics extends BaseHUDPart {
} }
} }
/**
* @param {boolean} sorted
*/
setSorted(sorted) {
this.sorted = sorted;
this.dialogInner.setAttribute("data-sorted", sorted);
if (this.visible) {
this.rerenderFull();
}
}
toggleSorted() {
this.setSorted(!this.sorted);
}
initialize() { initialize() {
this.domAttach = new DynamicDomAttach(this.root, this.background, { this.domAttach = new DynamicDomAttach(this.root, this.background, {
attachClass: "visible", attachClass: "visible",
@ -95,6 +112,7 @@ export class HUDStatistics extends BaseHUDPart {
/** @type {Object.<string, HUDShapeStatisticsHandle>} */ /** @type {Object.<string, HUDShapeStatisticsHandle>} */
this.activeHandles = {}; this.activeHandles = {};
this.setSorted(true);
this.setDataSource(enumAnalyticsDataSource.produced); this.setDataSource(enumAnalyticsDataSource.produced);
this.setDisplayMode(enumDisplayMode.detailed); this.setDisplayMode(enumDisplayMode.detailed);
@ -183,7 +201,13 @@ export class HUDStatistics extends BaseHUDPart {
} }
} }
entries.sort((a, b) => b[1] - a[1]); entries.sort((a, b) => {
// Sort by shape key for some consistency
if (!this.sorted || b[1] == a[1]) {
return b[0].localeCompare(a[0]);
}
return b[1] - a[1];
});
let rendered = new Set(); let rendered = new Set();