Map: map picker popup with preview images grouped by region, remembers last map
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
|
@ -19,14 +19,13 @@
|
|||
|
||||
<!-- UI Overlay -->
|
||||
<div id="ui-overlay">
|
||||
<!-- Title bar with map selector -->
|
||||
<!-- Kartenwahl: Knopf mit aktueller Karte, oeffnet die Auswahl mit Vorschaubildern -->
|
||||
<header id="title-bar" class="panel">
|
||||
<h1>Aion 2</h1>
|
||||
<div class="map-selector-container">
|
||||
<select id="map-select" aria-label="Select map">
|
||||
<option value="">Loading maps...</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" id="map-picker-btn" aria-haspopup="dialog" title="Karte wechseln">
|
||||
<span class="map-picker-label">Karte</span>
|
||||
<strong id="map-current-name">Lädt …</strong>
|
||||
<span class="map-picker-chevron" aria-hidden="true">▾</span>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<!-- Zoom controls -->
|
||||
|
|
@ -129,6 +128,17 @@
|
|||
<div class="category"></div>
|
||||
</div>
|
||||
|
||||
<!-- Kartenauswahl mit Vorschaubildern (data/previews, nur die Karte ohne Markierungen) -->
|
||||
<div id="map-picker" class="hidden" role="dialog" aria-modal="true" aria-labelledby="map-picker-title">
|
||||
<div class="map-picker-panel panel">
|
||||
<div class="map-picker-head">
|
||||
<h2 id="map-picker-title">Karte wählen</h2>
|
||||
<button type="button" id="map-picker-close" aria-label="Schließen">✕</button>
|
||||
</div>
|
||||
<div id="map-picker-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Eingabedialog fuer Namen, Beschreibungen und Beschriftungen -->
|
||||
<div id="tactic-dialog" class="hidden">
|
||||
<form class="panel" id="td-form">
|
||||
|
|
|
|||
|
|
@ -18,6 +18,18 @@ const CONFIG = {
|
|||
TILES_DIR: 'data/tiles',
|
||||
MARKERS_DIR: 'data/markers',
|
||||
ICONS_DIR: 'data/icons',
|
||||
// Vorschaubilder der Kartenauswahl - bewusst ausserhalb von data/ (das kommt per FTP),
|
||||
// damit sie mit dem Code ausgeliefert werden.
|
||||
PREVIEWS_DIR: 'previews',
|
||||
DEFAULT_MAP: 'verteron',
|
||||
|
||||
// Gebiete der Kartenauswahl in dieser Reihenfolge, Karten darin ebenfalls sortiert.
|
||||
// Karten, die hier fehlen, landen unter "Weitere".
|
||||
MAP_ZONES: [
|
||||
{ name: 'Elysea', maps: ['poeta', 'verteron', 'elthen'] },
|
||||
{ name: 'Asmodae', maps: ['ishalgen', 'altgard', 'morheim'] },
|
||||
{ name: 'Abyss', maps: ['abyss-reshanta-a', 'abyss-reshanta-b', 'chaotic-middle-reshanta', 'chaotic-upper-reshanta'] },
|
||||
],
|
||||
|
||||
// Local maps list (generated by download scripts to avoid CORS)
|
||||
MAPS_LIST: 'data/maps.json',
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ class MapController {
|
|||
|
||||
// DOM elements
|
||||
this.canvas = document.getElementById('map-canvas');
|
||||
this.mapSelect = document.getElementById('map-select');
|
||||
this.mapPicker = document.getElementById('map-picker');
|
||||
this.mapPickerList = document.getElementById('map-picker-list');
|
||||
this.mapPickerBtn = document.getElementById('map-picker-btn');
|
||||
this.mapCurrentName = document.getElementById('map-current-name');
|
||||
this.categoriesList = document.getElementById('categories-list');
|
||||
this.zoomLevelEl = document.getElementById('zoom-level');
|
||||
this.loadingOverlay = document.getElementById('loading-overlay');
|
||||
|
|
@ -36,11 +39,17 @@ class MapController {
|
|||
// Discover available maps
|
||||
await this.discoverMaps();
|
||||
|
||||
// Load first map by default
|
||||
// Zuletzt gewaehlte Karte, sonst die Standardkarte, sonst die erste
|
||||
if (this.mapData.maps.length > 0) {
|
||||
const firstMap = this.mapData.maps[0];
|
||||
this.mapSelect.value = firstMap.slug;
|
||||
await this.loadMap(firstMap.slug);
|
||||
let saved = null;
|
||||
try {
|
||||
saved = localStorage.getItem('lumina_map');
|
||||
} catch (e) {
|
||||
saved = null;
|
||||
}
|
||||
const has = slug => this.mapData.maps.some(m => m.slug === slug);
|
||||
const slug = has(saved) ? saved : (has(CONFIG.DEFAULT_MAP) ? CONFIG.DEFAULT_MAP : this.mapData.maps[0].slug);
|
||||
await this.loadMap(slug);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to initialize:', e);
|
||||
|
|
@ -80,36 +89,80 @@ class MapController {
|
|||
}
|
||||
|
||||
/**
|
||||
* Populate the map selection dropdown
|
||||
* Kartenauswahl aufbauen: pro Gebiet eine Reihe Karten mit Vorschaubild.
|
||||
*/
|
||||
populateMapSelector() {
|
||||
const maps = this.mapData.maps;
|
||||
|
||||
this.mapPickerList.textContent = '';
|
||||
|
||||
if (maps.length === 0) {
|
||||
this.mapSelect.innerHTML = '<option value="">No maps available</option>';
|
||||
this.mapCurrentName.textContent = 'Keine Karten';
|
||||
return;
|
||||
}
|
||||
|
||||
// Group by zone
|
||||
let html = '';
|
||||
// Nach den Gebieten aus CONFIG.MAP_ZONES ordnen (maps.json kennt keine Gebiete).
|
||||
const zones = {};
|
||||
|
||||
for (const map of maps) {
|
||||
if (!zones[map.zone]) {
|
||||
zones[map.zone] = [];
|
||||
}
|
||||
zones[map.zone].push(map);
|
||||
for (const zone of CONFIG.MAP_ZONES) {
|
||||
const zoneMaps = zone.maps.map(slug => maps.find(m => m.slug === slug)).filter(Boolean);
|
||||
if (zoneMaps.length) zones[zone.name] = zoneMaps;
|
||||
}
|
||||
const assigned = new Set(CONFIG.MAP_ZONES.flatMap(zone => zone.maps));
|
||||
const rest = maps.filter(m => !assigned.has(m.slug));
|
||||
if (rest.length) zones['Weitere'] = rest;
|
||||
|
||||
for (const [zoneName, zoneMaps] of Object.entries(zones)) {
|
||||
html += `<optgroup label="${zoneName}">`;
|
||||
for (const map of zoneMaps) {
|
||||
html += `<option value="${map.slug}">${map.name}</option>`;
|
||||
}
|
||||
html += '</optgroup>';
|
||||
}
|
||||
const section = document.createElement('section');
|
||||
section.className = 'map-picker-zone';
|
||||
const heading = document.createElement('h3');
|
||||
heading.textContent = zoneName;
|
||||
const grid = document.createElement('div');
|
||||
grid.className = 'map-picker-grid';
|
||||
|
||||
this.mapSelect.innerHTML = html;
|
||||
for (const map of zoneMaps) {
|
||||
const card = document.createElement('button');
|
||||
card.type = 'button';
|
||||
card.className = 'map-card';
|
||||
card.dataset.slug = map.slug;
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.src = `${CONFIG.PREVIEWS_DIR}/${map.slug}.webp`;
|
||||
img.alt = '';
|
||||
// Nicht lazy: die zehn kleinen Vorschauen (~300 KB) laden gleich mit, damit sie
|
||||
// beim Oeffnen der Auswahl sofort da sind.
|
||||
img.decoding = 'async';
|
||||
img.onerror = () => img.remove();
|
||||
|
||||
const name = document.createElement('span');
|
||||
name.className = 'map-card-name';
|
||||
name.textContent = map.name;
|
||||
|
||||
card.append(img, name);
|
||||
card.addEventListener('click', () => {
|
||||
this.closeMapPicker();
|
||||
if (map.slug !== this.mapData.currentMap?.slug) {
|
||||
this.loadMap(map.slug);
|
||||
}
|
||||
});
|
||||
grid.appendChild(card);
|
||||
}
|
||||
|
||||
section.append(heading, grid);
|
||||
this.mapPickerList.appendChild(section);
|
||||
}
|
||||
}
|
||||
|
||||
openMapPicker() {
|
||||
this.mapPickerList.querySelectorAll('.map-card').forEach(card => {
|
||||
card.classList.toggle('active', card.dataset.slug === this.mapData.currentMap?.slug);
|
||||
});
|
||||
this.mapPicker.classList.remove('hidden');
|
||||
const active = this.mapPickerList.querySelector('.map-card.active') || this.mapPickerList.querySelector('.map-card');
|
||||
if (active) active.focus();
|
||||
}
|
||||
|
||||
closeMapPicker() {
|
||||
this.mapPicker.classList.add('hidden');
|
||||
this.mapPickerBtn.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -123,6 +176,12 @@ class MapController {
|
|||
const mapInfo = this.mapData.setCurrentMap(slug);
|
||||
|
||||
if (!mapInfo) throw new Error(`Map ${slug} not found`);
|
||||
this.mapCurrentName.textContent = mapInfo.name;
|
||||
try {
|
||||
localStorage.setItem('lumina_map', slug);
|
||||
} catch (e) {
|
||||
// ohne Speicher eben jedes Mal die Standardkarte
|
||||
}
|
||||
|
||||
// Load tile manifest
|
||||
await this.tileService.loadManifest(slug);
|
||||
|
|
@ -300,13 +359,18 @@ class MapController {
|
|||
* Setup all event listeners
|
||||
*/
|
||||
setupEventListeners() {
|
||||
// Map selection change
|
||||
this.mapSelect.addEventListener('change', (e) => {
|
||||
const slug = e.target.value;
|
||||
if (slug) {
|
||||
this.loadMap(slug);
|
||||
}
|
||||
// Kartenauswahl: Knopf oeffnet das Popup, Klick daneben / X / Esc schliesst es
|
||||
this.mapPickerBtn.addEventListener('click', () => this.openMapPicker());
|
||||
document.getElementById('map-picker-close').addEventListener('click', () => this.closeMapPicker());
|
||||
this.mapPicker.addEventListener('click', (e) => {
|
||||
if (e.target === this.mapPicker) this.closeMapPicker();
|
||||
});
|
||||
window.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape' && !this.mapPicker.classList.contains('hidden')) {
|
||||
e.stopPropagation();
|
||||
this.closeMapPicker();
|
||||
}
|
||||
}, true);
|
||||
|
||||
// Alle Kategorien auf einmal ein- bzw. ausblenden
|
||||
document.getElementById('btn-show-all').addEventListener('click', () => this.setAllCategories(true));
|
||||
|
|
|
|||
BIN
assets/map/previews/abyss-reshanta-a.webp
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/map/previews/abyss-reshanta-b.webp
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
assets/map/previews/altgard.webp
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
assets/map/previews/chaotic-middle-reshanta.webp
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/map/previews/chaotic-upper-reshanta.webp
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
assets/map/previews/elthen.webp
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
assets/map/previews/ishalgen.webp
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/map/previews/morheim.webp
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
assets/map/previews/poeta.webp
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
assets/map/previews/verteron.webp
Normal file
|
After Width: | Height: | Size: 34 KiB |
|
|
@ -84,38 +84,154 @@ canvas:active {
|
|||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
/* Title bar */
|
||||
/* Kartenwahl oben mittig: Knopf mit dem Namen der aktuellen Karte */
|
||||
#title-bar {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
padding: 12px 24px;
|
||||
text-align: center;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
#title-bar h1 {
|
||||
font-size: 24px;
|
||||
#map-picker-btn {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
padding: 9px 16px;
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
#map-picker-btn:hover {
|
||||
background: rgba(255, 215, 0, 0.08);
|
||||
border-color: rgba(255, 215, 0, 0.4);
|
||||
}
|
||||
|
||||
.map-picker-label {
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
#map-current-name {
|
||||
font-size: 17px;
|
||||
color: var(--accent-gold);
|
||||
text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
|
||||
margin-bottom: 8px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.map-selector-container select {
|
||||
background: rgba(30, 30, 60, 0.9);
|
||||
border: 1px solid var(--border-color);
|
||||
color: var(--text-primary);
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
.map-picker-chevron {
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* Popup mit Vorschaubildern der Karten */
|
||||
#map-picker {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 2500;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
backdrop-filter: blur(4px);
|
||||
animation: map-picker-fade 0.2s ease;
|
||||
}
|
||||
|
||||
.map-picker-panel {
|
||||
width: min(960px, 100%);
|
||||
max-height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 18px 20px 20px;
|
||||
border-color: rgba(255, 215, 0, 0.35);
|
||||
box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
|
||||
.map-picker-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.map-picker-head h2 {
|
||||
font-size: 18px;
|
||||
color: var(--accent-gold);
|
||||
}
|
||||
|
||||
#map-picker-close {
|
||||
padding: 4px 10px;
|
||||
font-size: 14px;
|
||||
min-width: 250px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.map-selector-container select:hover {
|
||||
border-color: var(--accent-gold);
|
||||
#map-picker-list {
|
||||
overflow-y: auto;
|
||||
min-height: 0;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.map-picker-zone + .map-picker-zone { margin-top: 16px; }
|
||||
|
||||
.map-picker-zone h3 {
|
||||
margin-bottom: 8px;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.map-picker-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.map-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
background: rgba(30, 30, 50, 0.9);
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 10px;
|
||||
text-align: left;
|
||||
transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
|
||||
}
|
||||
|
||||
.map-card:hover,
|
||||
.map-card:focus-visible {
|
||||
transform: translateY(-3px);
|
||||
border-color: var(--accent-gold);
|
||||
box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.map-card.active {
|
||||
border-color: var(--accent-gold);
|
||||
box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.25);
|
||||
}
|
||||
|
||||
.map-card img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
aspect-ratio: 1;
|
||||
object-fit: cover;
|
||||
background: #e1d2bf;
|
||||
}
|
||||
|
||||
.map-card-name {
|
||||
padding: 8px 10px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.map-card.active .map-card-name { color: var(--accent-gold); }
|
||||
|
||||
@keyframes map-picker-fade { from { opacity: 0; } to { opacity: 1; } }
|
||||
|
||||
/* Zoom controls */
|
||||
#zoom-controls {
|
||||
position: absolute;
|
||||
|
|
@ -756,14 +872,6 @@ button.tp-item.active {
|
|||
transform: none;
|
||||
}
|
||||
|
||||
#title-bar h1 {
|
||||
font-size: 18px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.map-selector-container select {
|
||||
min-width: 180px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Handy: Fenster schmal und kompakt, damit von der Karte etwas uebrig bleibt. */
|
||||
|
|
@ -772,27 +880,25 @@ button.tp-item.active {
|
|||
top: 8px;
|
||||
left: 8px;
|
||||
right: 64px;
|
||||
padding: 6px 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
#title-bar h1 {
|
||||
font-size: 15px;
|
||||
margin-bottom: 0;
|
||||
#map-picker-btn {
|
||||
width: 100%;
|
||||
padding: 7px 10px;
|
||||
}
|
||||
|
||||
.map-selector-container {
|
||||
#map-current-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.map-selector-container select {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
#map-picker { padding: 10px; }
|
||||
.map-picker-panel { padding: 14px; }
|
||||
.map-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
|
||||
|
||||
#zoom-controls {
|
||||
top: 8px;
|
||||
|
|
|
|||