-
-
+
+
+
Categories
+
+
+
+
+
+
+
-
diff --git a/assets/map/js/controllers/MapController.js b/assets/map/js/controllers/MapController.js
index 2af789b..f6e7aca 100644
--- a/assets/map/js/controllers/MapController.js
+++ b/assets/map/js/controllers/MapController.js
@@ -364,6 +364,9 @@ class MapController {
this.view.isDragging = false;
});
+ this.setupTouch();
+ this.setupPanelToggles();
+
// Keyboard shortcuts
window.addEventListener('keydown', (e) => {
if (e.key === '+' || e.key === '=') {
@@ -377,6 +380,130 @@ class MapController {
});
}
+ /**
+ * Fenster ausblenden: der Augen-Knopf (oder Taste H) blendet alles ausser der
+ * Zoom-Leiste aus. Die Kategorien lassen sich ausserdem einzeln einklappen. Auf
+ * schmalen Bildschirmen starten Kategorien und Taktiken eingeklappt, sonst
+ * verdecken sie fast die ganze Karte.
+ */
+ setupPanelToggles() {
+ const overlay = document.getElementById('ui-overlay');
+ const toggleBtn = document.getElementById('btn-toggle-ui');
+ const setUiHidden = hidden => {
+ overlay.classList.toggle('ui-hidden', hidden);
+ toggleBtn.setAttribute('aria-pressed', String(hidden));
+ this.tooltip.classList.add('hidden');
+ };
+ toggleBtn.addEventListener('click', () => setUiHidden(!overlay.classList.contains('ui-hidden')));
+ window.addEventListener('keydown', (e) => {
+ const tag = e.target && e.target.tagName;
+ if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return;
+ if (e.key === 'h' || e.key === 'H') setUiHidden(!overlay.classList.contains('ui-hidden'));
+ });
+
+ const panel = document.getElementById('category-panel');
+ const collapseBtn = document.getElementById('cp-collapse');
+ collapseBtn.addEventListener('click', () => {
+ const collapsed = panel.classList.toggle('collapsed');
+ collapseBtn.textContent = collapsed ? '▸' : '▾';
+ collapseBtn.setAttribute('aria-expanded', String(!collapsed));
+ });
+
+ if (window.matchMedia('(max-width: 700px)').matches) {
+ collapseBtn.click();
+ const tacticCollapse = document.getElementById('tp-collapse');
+ if (tacticCollapse && tacticCollapse.getAttribute('aria-expanded') === 'true') tacticCollapse.click();
+ }
+ }
+
+ /**
+ * Touch: ein Finger verschiebt die Karte, zwei Finger zoomen (Pinch) und verschieben.
+ * Die Kacheln gibt es nur in ganzen Zoomstufen - deshalb wird eine Stufe gewechselt,
+ * sobald die Finger sich um einen festen Faktor auseinander- bzw. zusammenbewegt haben.
+ * Doppeltippen zoomt eine Stufe hinein.
+ */
+ setupTouch() {
+ const PINCH_STEP = 1.5;
+ let lastX = 0;
+ let lastY = 0;
+ let pinchBase = 0; // Fingerabstand bei der letzten Zoomstufe
+ let lastTap = 0;
+ let moved = false;
+
+ const midpoint = touches => {
+ const rect = this.canvas.getBoundingClientRect();
+ let x = 0;
+ let y = 0;
+ for (const t of touches) {
+ x += t.clientX;
+ y += t.clientY;
+ }
+ return { x: x / touches.length - rect.left, y: y / touches.length - rect.top };
+ };
+ const distance = touches => Math.hypot(
+ touches[0].clientX - touches[1].clientX,
+ touches[0].clientY - touches[1].clientY
+ );
+ const resetTracking = touches => {
+ const mid = midpoint(touches);
+ lastX = mid.x;
+ lastY = mid.y;
+ pinchBase = touches.length >= 2 ? distance(touches) : 0;
+ };
+
+ this.canvas.addEventListener('touchstart', (e) => {
+ e.preventDefault();
+ this.tooltip.classList.add('hidden');
+ if (e.touches.length === 1) moved = false;
+ resetTracking(e.touches);
+ }, { passive: false });
+
+ this.canvas.addEventListener('touchmove', (e) => {
+ e.preventDefault();
+ const mid = midpoint(e.touches);
+ const dx = mid.x - lastX;
+ const dy = mid.y - lastY;
+ if (Math.abs(dx) + Math.abs(dy) > 2) moved = true;
+ this.view.panBy(dx, dy);
+ lastX = mid.x;
+ lastY = mid.y;
+
+ if (e.touches.length >= 2 && pinchBase > 0) {
+ moved = true;
+ const ratio = distance(e.touches) / pinchBase;
+ if (ratio >= PINCH_STEP || ratio <= 1 / PINCH_STEP) {
+ this.view.zoomAt(ratio > 1 ? 1 : -1, mid.x, mid.y);
+ pinchBase = distance(e.touches);
+ this.render();
+ return;
+ }
+ }
+ this.view.requestRender(this.tileService, this.mapData);
+ }, { passive: false });
+
+ this.canvas.addEventListener('touchend', (e) => {
+ e.preventDefault();
+ if (e.touches.length > 0) {
+ // Ein Finger bleibt liegen: von dort aus ohne Sprung weiterschieben.
+ resetTracking(e.touches);
+ return;
+ }
+ if (moved || e.changedTouches.length !== 1) return;
+
+ const touch = e.changedTouches[0];
+ const now = Date.now();
+ if (now - lastTap < 300) {
+ const rect = this.canvas.getBoundingClientRect();
+ if (this.view.zoomAt(1, touch.clientX - rect.left, touch.clientY - rect.top)) this.render();
+ lastTap = 0;
+ } else {
+ lastTap = now;
+ // Antippen zeigt den Namen eines Markers (statt Mauszeiger-Hover).
+ this.checkHover(touch);
+ }
+ }, { passive: false });
+ }
+
/**
* Check for marker hover and show tooltip
*/
diff --git a/assets/map/js/views/MapView.js b/assets/map/js/views/MapView.js
index 4714d6d..50f71e2 100644
--- a/assets/map/js/views/MapView.js
+++ b/assets/map/js/views/MapView.js
@@ -260,6 +260,20 @@ class MapView {
return false;
}
+ /**
+ * Eine Stufe rein (+1) oder raus (-1) zoomen, wobei der Weltpunkt unter
+ * screenX/screenY an seiner Stelle bleibt (z.B. zwischen zwei Fingern).
+ */
+ zoomAt(step, screenX, screenY) {
+ const before = this.screenToWorld(screenX, screenY);
+ const changed = step > 0 ? this.zoomIn() : this.zoomOut();
+ if (!changed) return false;
+ const after = this.screenToWorld(screenX, screenY);
+ const scale = this.worldToScreen(1, 0).x - this.worldToScreen(0, 0).x;
+ this.panBy((after.x - before.x) * scale, (after.y - before.y) * scale);
+ return true;
+ }
+
/**
* Reset view to default
*/
diff --git a/assets/map/styles.css b/assets/map/styles.css
index 92c80ac..d18a2b0 100644
--- a/assets/map/styles.css
+++ b/assets/map/styles.css
@@ -34,6 +34,8 @@ body {
canvas {
display: block;
cursor: grab;
+ /* Wischen und Pinch-Zoom steuert die Karte selbst (MapController.setupTouch). */
+ touch-action: none;
}
canvas:active {
@@ -152,14 +154,42 @@ button:hover {
width: 300px;
}
-#category-panel h3 {
- font-size: 14px;
- color: var(--accent-gold);
+#category-panel .tp-head {
margin-bottom: 8px;
border-bottom: 1px solid rgba(255, 215, 0, 0.3);
padding-bottom: 4px;
}
+#category-panel h3 {
+ flex: 1;
+ font-size: 14px;
+ color: var(--accent-gold);
+}
+
+#category-panel.collapsed {
+ width: auto;
+}
+
+#category-panel.collapsed .tp-head {
+ margin-bottom: 0;
+ padding-bottom: 0;
+ border-bottom: none;
+}
+
+#category-panel.collapsed .cp-body {
+ display: none;
+}
+
+/* Fenster ausgeblendet: nur die Zoom-Leiste (mit dem Augen-Knopf) bleibt stehen. */
+#ui-overlay.ui-hidden > :not(#zoom-controls) {
+ display: none !important;
+}
+
+#btn-toggle-ui[aria-pressed="true"] {
+ border-color: var(--accent-gold);
+ background: rgba(255, 215, 0, 0.2);
+}
+
.category-group {
margin-bottom: 12px;
}
@@ -735,3 +765,82 @@ button.tp-item.active {
min-width: 180px;
}
}
+
+/* Handy: Fenster schmal und kompakt, damit von der Karte etwas uebrig bleibt. */
+@media (max-width: 700px) {
+ #title-bar {
+ top: 8px;
+ left: 8px;
+ right: 64px;
+ padding: 6px 8px;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ #title-bar h1 {
+ font-size: 15px;
+ margin-bottom: 0;
+ }
+
+ .map-selector-container {
+ flex: 1;
+ min-width: 0;
+ }
+
+ .map-selector-container select {
+ width: 100%;
+ min-width: 0;
+ padding: 6px 8px;
+ }
+
+ #zoom-controls {
+ top: 8px;
+ right: 8px;
+ padding: 4px;
+ }
+
+ #zoom-controls button {
+ padding: 6px 10px;
+ }
+
+ #tactic-panel {
+ top: 60px;
+ left: 8px;
+ right: 64px;
+ width: auto;
+ max-height: 45%;
+ padding: 6px 8px;
+ }
+
+ #category-panel {
+ left: 8px;
+ bottom: 8px;
+ width: calc(100% - 16px);
+ max-height: 45%;
+ padding: 8px 10px;
+ }
+
+ #category-panel.collapsed {
+ width: auto;
+ }
+
+ #zoom-indicator {
+ display: none;
+ }
+
+ #step-bar {
+ left: 8px;
+ right: 8px;
+ bottom: 56px;
+ width: auto;
+ min-width: 0;
+ max-width: none;
+ }
+
+ #toast {
+ left: 8px;
+ right: 8px;
+ bottom: 120px;
+ }
+}