mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Commonize sort method
This commit is contained in:
parent
1d44690482
commit
d0d8314d81
@ -272,18 +272,7 @@ export class HUDWaypoints extends BaseHUDPart {
|
|||||||
zoomLevel: Math.max(this.root.camera.zoomLevel, globalConfig.mapChunkOverviewMinZoom + 0.05),
|
zoomLevel: Math.max(this.root.camera.zoomLevel, globalConfig.mapChunkOverviewMinZoom + 0.05),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sort waypoints by name
|
this.sort();
|
||||||
this.waypoints.sort((a, b) => {
|
|
||||||
if (!a.label) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (!b.label) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return this.getWaypointLabel(a)
|
|
||||||
.padEnd(MAX_LABEL_LENGTH, "0")
|
|
||||||
.localeCompare(this.getWaypointLabel(b).padEnd(MAX_LABEL_LENGTH, "0"));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Show notification about creation
|
// Show notification about creation
|
||||||
this.root.hud.signals.notification.dispatch(
|
this.root.hud.signals.notification.dispatch(
|
||||||
@ -304,6 +293,23 @@ export class HUDWaypoints extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort waypoints by name
|
||||||
|
*/
|
||||||
|
sort() {
|
||||||
|
this.waypoints.sort((a, b) => {
|
||||||
|
if (!a.label) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!b.label) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return this.getWaypointLabel(a)
|
||||||
|
.padEnd(MAX_LABEL_LENGTH, "0")
|
||||||
|
.localeCompare(this.getWaypointLabel(b).padEnd(MAX_LABEL_LENGTH, "0"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the label for a given waypoint
|
* Returns the label for a given waypoint
|
||||||
* @param {Waypoint} waypoint
|
* @param {Waypoint} waypoint
|
||||||
|
Loading…
Reference in New Issue
Block a user