diff --git a/BlueMapAPI b/BlueMapAPI index 1d0d63f0..2a3cc1c2 160000 --- a/BlueMapAPI +++ b/BlueMapAPI @@ -1 +1 @@ -Subproject commit 1d0d63f08853581a447f818fbacc7e5c14aa514e +Subproject commit 2a3cc1c2709bb13021db9c8064715d569db40ca3 diff --git a/BlueMapCommon/webapp/public/lang/de.conf b/BlueMapCommon/webapp/public/lang/de.conf index 2a5007fa..c1cea628 100644 --- a/BlueMapCommon/webapp/public/lang/de.conf +++ b/BlueMapCommon/webapp/public/lang/de.conf @@ -17,6 +17,14 @@ markerSet: "Markerset | Markersets" searchPlaceholder: "Suche..." followPlayerTitle: "Spieler folgen" + sort { + title: "Sortieren nach" + by { + default: "Standard" + label: "Name" + distance: "Distanz" + } + } } settings: { title: "Einstellungen" diff --git a/BlueMapCommon/webapp/public/lang/en.conf b/BlueMapCommon/webapp/public/lang/en.conf index e44a6c3d..bbde4758 100644 --- a/BlueMapCommon/webapp/public/lang/en.conf +++ b/BlueMapCommon/webapp/public/lang/en.conf @@ -17,6 +17,14 @@ markerSet: "marker-set | marker-sets" searchPlaceholder: "Search..." followPlayerTitle: "Follow Player" + sort { + title: "Sort by" + by { + default: "default" + label: "name" + distance: "distance" + } + } } settings: { title: "Settings" diff --git a/BlueMapCommon/webapp/src/components/Menu/ChoiceBox.vue b/BlueMapCommon/webapp/src/components/Menu/ChoiceBox.vue new file mode 100644 index 00000000..bd40d988 --- /dev/null +++ b/BlueMapCommon/webapp/src/components/Menu/ChoiceBox.vue @@ -0,0 +1,70 @@ + + + + + \ No newline at end of file diff --git a/BlueMapCommon/webapp/src/components/Menu/MarkerSetMenu.vue b/BlueMapCommon/webapp/src/components/Menu/MarkerSetMenu.vue index 32a99d9b..5b6a1b36 100644 --- a/BlueMapCommon/webapp/src/components/Menu/MarkerSetMenu.vue +++ b/BlueMapCommon/webapp/src/components/Menu/MarkerSetMenu.vue @@ -6,6 +6,16 @@
+
@@ -15,17 +25,23 @@ import MarkerItem from "./MarkerItem.vue"; import TextInput from "./TextInput.vue"; import MarkerSet from "./MarkerSet.vue"; +import Group from "./Group.vue"; +import SimpleButton from "./SimpleButton.vue"; import {MainMenu} from "../../js/MainMenu"; +import ChoiceBox from "./ChoiceBox.vue"; + export default { name: "MarkerSetMenu", - components: {MarkerSet, TextInput, MarkerItem}, + components: {ChoiceBox, SimpleButton, MarkerSet, TextInput, MarkerItem, Group}, props: { menu: MainMenu }, data() { return { + controls: this.$bluemap.mapViewer.controlsManager.data, filter: { search: "", + order: "default" } } }, @@ -34,20 +50,28 @@ export default { return this.menu.currentPage().markerSet; }, filteredMarkers() { - return [...this.thisMarkerSet.markers].sort((a, b) => { - if (a.id < b.id) return -1; - if (a.id > b.id) return 1; - return 0; - }).filter(marker => { + return [...this.thisMarkerSet.markers].filter(marker => { if (!this.filter.search) return true; if (marker.id.includesCI(this.filter.search)) return true; if (marker.label && marker.label.includesCI(this.filter.search)) return true; return marker.type === "player" && (marker.name.includesCI(this.filter.search) || marker.playerUuid.includesCI(this.filter.search)); + }).sort((a, b) => { + if (this.filter.order === "label") { + if (a.label < b.label) return -1; + if (a.label > b.label) return 1; + return 0; + } + if (this.filter.order === "distance") { + return a.position.distanceToSquared(this.controls.position) - b.position.distanceToSquared(this.controls.position); + } + return (a.sorting || 0) - (b.sorting || 0); }); }, filteredMarkerSets() { return this.thisMarkerSet.markerSets.filter(markerSet => { return (markerSet.id !== "bm-popup-set"); + }).sort((a, b) => { + return (a.sorting || 0) - (b.sorting || 0); }); } }, diff --git a/BlueMapCommon/webapp/src/js/markers/HtmlMarker.js b/BlueMapCommon/webapp/src/js/markers/HtmlMarker.js index 31f39397..68fa289c 100644 --- a/BlueMapCommon/webapp/src/js/markers/HtmlMarker.js +++ b/BlueMapCommon/webapp/src/js/markers/HtmlMarker.js @@ -93,6 +93,7 @@ export class HtmlMarker extends Marker { * @param markerData {{ * position: {x: number, y: number, z: number}, * label: string, + * sorting: number, * anchor: {x: number, y: number}, * html: string, * classes: string[], @@ -109,7 +110,14 @@ export class HtmlMarker extends Marker { this.position.setZ(pos.z || 0); // update label - this.data.label = markerData.label || null; + if (this.data.label !== markerData.label) { + this.data.label = markerData.label || null; + } + + //update sorting + if (this.data.sorting !== markerData.sorting) { + this.data.sorting = markerData.sorting || 0; + } // update anchor let anch = markerData.anchor || {}; diff --git a/BlueMapCommon/webapp/src/js/markers/Marker.js b/BlueMapCommon/webapp/src/js/markers/Marker.js index 557d8b5a..b6c47c67 100644 --- a/BlueMapCommon/webapp/src/js/markers/Marker.js +++ b/BlueMapCommon/webapp/src/js/markers/Marker.js @@ -37,6 +37,7 @@ export class Marker extends Object3D { this.data = reactive({ id: markerId, type: "marker", + sorting: 0, position: this.position, visible: this.visible }); @@ -67,7 +68,7 @@ export class Marker extends Object3D { /** * @param position {Vector3} - * @param camera {THREE.Camera} + * @param camera {Camera} * @param fadeDistanceMax {number} * @param fadeDistanceMin {number} * @returns {number} - opacity between 0 and 1 @@ -84,7 +85,7 @@ export class Marker extends Object3D { /** * @param position {Vector3} - * @param camera {THREE.Camera} + * @param camera {Camera} * @returns {number} */ static calculateDistanceToCameraPlane (position, camera) { diff --git a/BlueMapCommon/webapp/src/js/markers/MarkerSet.js b/BlueMapCommon/webapp/src/js/markers/MarkerSet.js index f885a029..53fd829a 100644 --- a/BlueMapCommon/webapp/src/js/markers/MarkerSet.js +++ b/BlueMapCommon/webapp/src/js/markers/MarkerSet.js @@ -50,6 +50,7 @@ export class MarkerSet extends Scene { label: id, toggleable: true, defaultHide: false, + sorting: 0, markerSets: [], markers: [], visible: this.visible, @@ -66,6 +67,7 @@ export class MarkerSet extends Scene { this.data.label = data.label || this.data.id; this.data.toggleable = !!data.toggleable; this.data.defaultHide = !!data.defaultHidden; + this.data.sorting = data.sorting || this.data.sorting; // update markerSets this.updateMarkerSetsFromData(data.markerSets); diff --git a/BlueMapCommon/webapp/src/js/markers/ObjectMarker.js b/BlueMapCommon/webapp/src/js/markers/ObjectMarker.js index 04f64916..858340bc 100644 --- a/BlueMapCommon/webapp/src/js/markers/ObjectMarker.js +++ b/BlueMapCommon/webapp/src/js/markers/ObjectMarker.js @@ -73,6 +73,7 @@ export class ObjectMarker extends Marker { * position: {x: number, y: number, z: number}, * label: string, * detail: string, + * sorting: number, * link: string, * newTab: boolean * }} @@ -91,6 +92,9 @@ export class ObjectMarker extends Marker { //update detail this.data.detail = markerData.detail || null; + //update sorting + this.data.sorting = markerData.sorting || 0; + // update link this.data.link = markerData.link || null; this.data.newTab = !!markerData.newTab; diff --git a/BlueMapCommon/webapp/src/js/markers/PoiMarker.js b/BlueMapCommon/webapp/src/js/markers/PoiMarker.js index 986d9143..a73fca07 100644 --- a/BlueMapCommon/webapp/src/js/markers/PoiMarker.js +++ b/BlueMapCommon/webapp/src/js/markers/PoiMarker.js @@ -90,6 +90,7 @@ export class PoiMarker extends HtmlMarker { * iconAnchor: {x: number, y: number}, * label: string, * detail: string, + * sorting: number, * icon: string, * classes: string[], * minDistance: number, @@ -116,6 +117,11 @@ export class PoiMarker extends HtmlMarker { this.data.label = markerData.label || ""; } + //update sorting + if (this.data.sorting !== markerData.sorting) { + this.data.sorting = markerData.sorting || 0; + } + // update detail if (this.data.detail !== markerData.detail){ this.data.detail = markerData.detail || this.data.label; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/math/Color.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/math/Color.java index d8f02807..211fb45f 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/math/Color.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/math/Color.java @@ -166,7 +166,7 @@ public Color straight() { /** * Parses the color from a string and sets it to this Color instance. * The value can be an integer in String-Format or a string in hexadecimal format prefixed with # (css-style: e.g. #f16 becomes #ff1166). - * @param val The String to parse + * @param value The String to parse * @return The parsed Integer * @throws NumberFormatException If the value is not formatted correctly or if there is no value present. */