merge remote changes
This commit is contained in:
1 parent
9fcaf9d762
commit
6161f36ea4
7 files changed
+736
-354
No files matched your search
+6
-3
@@ -58,6 +58,7 @@ DEFAULTS = {
|
|||||||
'enabled': True,
|
'enabled': True,
|
||||||
'username': None, # Must be set via setup
|
'username': None, # Must be set via setup
|
||||||
'password_hash': None, # Argon2 hash, never plaintext
|
'password_hash': None, # Argon2 hash, never plaintext
|
||||||
|
'shell_enabled': True,
|
||||||
},
|
},
|
||||||
'logging': {
|
'logging': {
|
||||||
'level': 'INFO',
|
'level': 'INFO',
|
||||||
@@ -73,6 +74,7 @@ DEFAULTS = {
|
|||||||
'default_map': 'DeepDesert',
|
'default_map': 'DeepDesert',
|
||||||
'DeepDesert': {
|
'DeepDesert': {
|
||||||
'image': 'maps/Deep_Desert_Map1.jpg',
|
'image': 'maps/Deep_Desert_Map1.jpg',
|
||||||
|
'label': 'The Deep Desert',
|
||||||
'bounds': {
|
'bounds': {
|
||||||
'min_x': 466906,
|
'min_x': 466906,
|
||||||
'max_x': 466907,
|
'max_x': 466907,
|
||||||
@@ -80,10 +82,11 @@ DEFAULTS = {
|
|||||||
'max_y': -620340
|
'max_y': -620340
|
||||||
},
|
},
|
||||||
'flip_y': False,
|
'flip_y': False,
|
||||||
'image_size': {'width': 1200, 'height': 800}
|
'image_size': {'width': 683, 'height': 683}
|
||||||
},
|
},
|
||||||
'HaggaBasin': {
|
'HaggaBasin': {
|
||||||
'image': None,
|
'image': 'maps/T_WorldMap_Survival_1_D.png',
|
||||||
|
'label': 'Hagga Basin',
|
||||||
'bounds': {
|
'bounds': {
|
||||||
'min_x': 21352,
|
'min_x': 21352,
|
||||||
'max_x': 23166,
|
'max_x': 23166,
|
||||||
@@ -91,7 +94,7 @@ DEFAULTS = {
|
|||||||
'max_y': 237943
|
'max_y': 237943
|
||||||
},
|
},
|
||||||
'flip_y': False,
|
'flip_y': False,
|
||||||
'image_size': {'width': 800, 'height': 600}
|
'image_size': {'width': 1228, 'height': 1228}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ def create_app(settings_path=None):
|
|||||||
# Content Security Policy
|
# Content Security Policy
|
||||||
response.headers['Content-Security-Policy'] = (
|
response.headers['Content-Security-Policy'] = (
|
||||||
"default-src 'self'; "
|
"default-src 'self'; "
|
||||||
"script-src 'self'; "
|
"script-src 'self' 'unsafe-inline'; "
|
||||||
"style-src 'self' 'unsafe-inline'; "
|
"style-src 'self' 'unsafe-inline'; "
|
||||||
"img-src 'self' data:; "
|
"img-src 'self' data:; "
|
||||||
"connect-src 'self' ws: wss:; "
|
"connect-src 'self' ws: wss:; "
|
||||||
|
|||||||
+101
-27
@@ -456,7 +456,61 @@ def register_routes(app, services, settings):
|
|||||||
@app.route('/map')
|
@app.route('/map')
|
||||||
@login_required
|
@login_required
|
||||||
def map_page():
|
def map_page():
|
||||||
|
def get_map_context():
|
||||||
|
map_config = settings.get('maps', {})
|
||||||
|
try:
|
||||||
|
from app.config import DEFAULTS
|
||||||
|
default_map_config = DEFAULTS.get('maps', {})
|
||||||
|
merged_map_config = {}
|
||||||
|
for name, default_cfg in default_map_config.items():
|
||||||
|
if not isinstance(default_cfg, dict):
|
||||||
|
continue
|
||||||
|
cfg = dict(default_cfg)
|
||||||
|
cfg.update(map_config.get(name, {}) if isinstance(map_config.get(name), dict) else {})
|
||||||
|
for fallback_key in ('image', 'label', 'image_size'):
|
||||||
|
if not cfg.get(fallback_key) and default_cfg.get(fallback_key):
|
||||||
|
cfg[fallback_key] = default_cfg[fallback_key]
|
||||||
|
merged_map_config[name] = cfg
|
||||||
|
for name, cfg in map_config.items():
|
||||||
|
if isinstance(cfg, dict) and name not in merged_map_config:
|
||||||
|
merged_map_config[name] = cfg
|
||||||
|
map_config = merged_map_config
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
configured_maps = {
|
||||||
|
name: cfg for name, cfg in map_config.items()
|
||||||
|
if isinstance(cfg, dict) and cfg.get('image') and cfg.get('bounds')
|
||||||
|
}
|
||||||
|
default_map = map_config.get('default_map', 'DeepDesert')
|
||||||
|
|
||||||
|
return map_config, configured_maps, default_map
|
||||||
|
|
||||||
|
def build_map_options(configured_maps, player_locations=None, vehicle_locations=None, building_locations=None):
|
||||||
|
player_locations = player_locations or []
|
||||||
|
vehicle_locations = vehicle_locations or []
|
||||||
|
building_locations = building_locations or []
|
||||||
|
map_options = []
|
||||||
|
for key, cfg in configured_maps.items():
|
||||||
|
image_size = cfg.get('image_size', {})
|
||||||
|
map_options.append({
|
||||||
|
'key': key,
|
||||||
|
'label': cfg.get('label') or key,
|
||||||
|
'image': cfg.get('image'),
|
||||||
|
'width': image_size.get('width', 1000),
|
||||||
|
'height': image_size.get('height', 1000),
|
||||||
|
'counts': {
|
||||||
|
'players': sum(1 for p in player_locations if p.get('map') == key and p.get('in_bounds')),
|
||||||
|
'vehicles': sum(1 for v in vehicle_locations if v.get('map') == key and v.get('in_bounds')),
|
||||||
|
'bases': sum(1 for b in building_locations if b.get('map') == key and b.get('in_bounds')),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return map_options
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
map_config, configured_maps, default_map = get_map_context()
|
||||||
|
selected_map_keys = list(configured_maps.keys()) or ['DeepDesert', 'HaggaBasin']
|
||||||
|
|
||||||
# Get players with coordinates
|
# Get players with coordinates
|
||||||
players = db.query("""
|
players = db.query("""
|
||||||
SELECT
|
SELECT
|
||||||
@@ -466,28 +520,33 @@ def register_routes(app, services, settings):
|
|||||||
a.transform
|
a.transform
|
||||||
FROM dune.actors a
|
FROM dune.actors a
|
||||||
JOIN dune.player_state ps ON a.id = ps.player_pawn_id
|
JOIN dune.player_state ps ON a.id = ps.player_pawn_id
|
||||||
WHERE a.transform IS NOT NULL
|
WHERE a.transform IS NOT NULL AND a.map = ANY(%s)
|
||||||
ORDER BY a.map, ps.character_name
|
ORDER BY a.map, ps.character_name
|
||||||
""") or []
|
""", [selected_map_keys]) or []
|
||||||
|
|
||||||
# Get vehicles with coordinates (only DeepDesert and HaggaBasin)
|
# Get vehicles with coordinates for configured map assets
|
||||||
vehicles = db.query("""
|
vehicles = db.query("""
|
||||||
SELECT v.id, a.map, a.transform, a.class
|
SELECT v.id, a.map, a.transform, a.class
|
||||||
FROM dune.vehicles v
|
FROM dune.vehicles v
|
||||||
JOIN dune.actors a ON v.id = a.id
|
JOIN dune.actors a ON v.id = a.id
|
||||||
WHERE a.transform IS NOT NULL AND a.map IN ('DeepDesert', 'HaggaBasin')
|
WHERE a.transform IS NOT NULL AND a.map = ANY(%s)
|
||||||
ORDER BY a.map, a.class
|
ORDER BY a.map, a.class
|
||||||
""") or []
|
""", [selected_map_keys]) or []
|
||||||
|
|
||||||
# Get buildings with coordinates (only DeepDesert and HaggaBasin)
|
# Get bases/buildings with coordinates for configured map assets
|
||||||
buildings = db.query("""
|
buildings = db.query("""
|
||||||
SELECT b.id, a.map, a.transform, a.class
|
SELECT b.id, a.map, a.transform, a.class,
|
||||||
|
COALESCE(NULLIF(ps.character_name, ''), NULLIF(ea.platform_name, ''), 'Base ' || b.id::text) as owner_name
|
||||||
FROM dune.buildings b
|
FROM dune.buildings b
|
||||||
JOIN dune.actors a ON b.id = a.id
|
JOIN dune.actors a ON b.id = a.id
|
||||||
WHERE a.transform IS NOT NULL AND a.map IN ('DeepDesert', 'HaggaBasin')
|
LEFT JOIN dune.player_state ps ON b.owner_id = ps.player_pawn_id
|
||||||
|
LEFT JOIN dune.encrypted_accounts ea ON ea.id = (
|
||||||
|
SELECT ps2.account_id FROM dune.player_state ps2 WHERE ps2.player_pawn_id = b.owner_id LIMIT 1
|
||||||
|
)
|
||||||
|
WHERE a.transform IS NOT NULL AND a.map = ANY(%s)
|
||||||
ORDER BY a.map
|
ORDER BY a.map
|
||||||
LIMIT 200
|
LIMIT 500
|
||||||
""") or []
|
""", [selected_map_keys]) or []
|
||||||
|
|
||||||
# Parse coordinates from transform field
|
# Parse coordinates from transform field
|
||||||
def parse_transform(t):
|
def parse_transform(t):
|
||||||
@@ -518,7 +577,8 @@ def register_routes(app, services, settings):
|
|||||||
'map': p['map'],
|
'map': p['map'],
|
||||||
'x': coords['x'],
|
'x': coords['x'],
|
||||||
'y': coords['y'],
|
'y': coords['y'],
|
||||||
'z': coords['z']
|
'z': coords['z'],
|
||||||
|
'type': 'player',
|
||||||
})
|
})
|
||||||
|
|
||||||
# Process vehicles
|
# Process vehicles
|
||||||
@@ -533,7 +593,8 @@ def register_routes(app, services, settings):
|
|||||||
'class': v.get('class', '').split('/')[-1] if v.get('class') else '',
|
'class': v.get('class', '').split('/')[-1] if v.get('class') else '',
|
||||||
'x': coords['x'],
|
'x': coords['x'],
|
||||||
'y': coords['y'],
|
'y': coords['y'],
|
||||||
'z': coords['z']
|
'z': coords['z'],
|
||||||
|
'type': 'vehicle',
|
||||||
})
|
})
|
||||||
|
|
||||||
# Process buildings
|
# Process buildings
|
||||||
@@ -544,23 +605,14 @@ def register_routes(app, services, settings):
|
|||||||
building_locations.append({
|
building_locations.append({
|
||||||
'id': b['id'],
|
'id': b['id'],
|
||||||
'map': b['map'],
|
'map': b['map'],
|
||||||
|
'name': b.get('owner_name') or f"Base {b['id']}",
|
||||||
'class': b.get('class', '').split('/')[-1] if b.get('class') else '',
|
'class': b.get('class', '').split('/')[-1] if b.get('class') else '',
|
||||||
'x': coords['x'],
|
'x': coords['x'],
|
||||||
'y': coords['y'],
|
'y': coords['y'],
|
||||||
'z': coords['z']
|
'z': coords['z'],
|
||||||
|
'type': 'base',
|
||||||
})
|
})
|
||||||
|
|
||||||
# Get unique maps
|
|
||||||
all_maps = set()
|
|
||||||
for loc in player_locations + vehicle_locations + building_locations:
|
|
||||||
if loc.get('map'):
|
|
||||||
all_maps.add(loc['map'])
|
|
||||||
maps = sorted(all_maps)
|
|
||||||
|
|
||||||
# Get map configuration from settings
|
|
||||||
map_config = settings.get('maps', {})
|
|
||||||
default_map = map_config.get('default_map', 'DeepDesert')
|
|
||||||
|
|
||||||
# Calculate pixel positions for markers
|
# Calculate pixel positions for markers
|
||||||
def to_pixel_coords(x, y, map_name):
|
def to_pixel_coords(x, y, map_name):
|
||||||
cfg = map_config.get(map_name, {})
|
cfg = map_config.get(map_name, {})
|
||||||
@@ -585,23 +637,45 @@ def register_routes(app, services, settings):
|
|||||||
|
|
||||||
return int(px), int(py)
|
return int(px), int(py)
|
||||||
|
|
||||||
# Add pixel positions
|
def is_in_bounds(loc):
|
||||||
|
img_size = map_config.get(loc.get('map'), {}).get('image_size', {})
|
||||||
|
width = img_size.get('width', 0)
|
||||||
|
height = img_size.get('height', 0)
|
||||||
|
return (
|
||||||
|
loc.get('px') is not None
|
||||||
|
and loc.get('py') is not None
|
||||||
|
and 0 <= loc['px'] <= width
|
||||||
|
and 0 <= loc['py'] <= height
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add pixel positions and hide out-of-bounds markers until bounds are calibrated.
|
||||||
for p in player_locations:
|
for p in player_locations:
|
||||||
p['px'], p['py'] = to_pixel_coords(p['x'], p['y'], p.get('map', ''))
|
p['px'], p['py'] = to_pixel_coords(p['x'], p['y'], p.get('map', ''))
|
||||||
|
p['in_bounds'] = is_in_bounds(p)
|
||||||
|
|
||||||
for v in vehicle_locations:
|
for v in vehicle_locations:
|
||||||
v['px'], v['py'] = to_pixel_coords(v['x'], v['y'], v.get('map', ''))
|
v['px'], v['py'] = to_pixel_coords(v['x'], v['y'], v.get('map', ''))
|
||||||
|
v['in_bounds'] = is_in_bounds(v)
|
||||||
|
|
||||||
for b in building_locations:
|
for b in building_locations:
|
||||||
b['px'], b['py'] = to_pixel_coords(b['x'], b['y'], b.get('map', ''))
|
b['px'], b['py'] = to_pixel_coords(b['x'], b['y'], b.get('map', ''))
|
||||||
|
b['in_bounds'] = is_in_bounds(b)
|
||||||
|
|
||||||
|
map_options = build_map_options(configured_maps, player_locations, vehicle_locations, building_locations)
|
||||||
|
|
||||||
return render_template('map.html',
|
return render_template('map.html',
|
||||||
players=player_locations,
|
players=player_locations,
|
||||||
vehicles=vehicle_locations,
|
vehicles=vehicle_locations,
|
||||||
buildings=building_locations,
|
buildings=building_locations,
|
||||||
maps=maps,
|
map_options=map_options,
|
||||||
map_config=map_config,
|
map_config=map_config,
|
||||||
default_map=default_map)
|
default_map=default_map)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("Error in map route")
|
logger.exception("Error in map route")
|
||||||
return render_template('map.html', db_error=f"{type(e).__name__}: {e}")
|
map_config, configured_maps, default_map = get_map_context()
|
||||||
|
return render_template('map.html',
|
||||||
|
players=[], vehicles=[], buildings=[],
|
||||||
|
map_options=build_map_options(configured_maps),
|
||||||
|
map_config=map_config,
|
||||||
|
default_map=default_map,
|
||||||
|
db_error=f"{type(e).__name__}: {e}")
|
||||||
+29
-5
@@ -11,19 +11,43 @@ class SSHService:
|
|||||||
def __init__(self, host, user, ssh_key=None):
|
def __init__(self, host, user, ssh_key=None):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.user = user
|
self.user = user
|
||||||
self.ssh_key = ssh_key
|
self.ssh_key = self._resolve_ssh_key(ssh_key)
|
||||||
logger.info(f"SSHService initialized: {user}@{host}")
|
key_status = self.ssh_key if self.ssh_key else 'default ssh identity/agent'
|
||||||
|
logger.info(f"SSHService initialized: {user}@{host} using {key_status}")
|
||||||
|
|
||||||
|
def _resolve_ssh_key(self, ssh_key):
|
||||||
|
if ssh_key:
|
||||||
|
key = str(ssh_key).strip("'\"")
|
||||||
|
if os.path.exists(key):
|
||||||
|
return key
|
||||||
|
|
||||||
|
base_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||||
|
temp_dir = os.environ.get('TEMP') or os.environ.get('TMPDIR') or ('/tmp' if os.name != 'nt' else 'C:\\Temp')
|
||||||
|
local_appdata = os.environ.get('LOCALAPPDATA', '')
|
||||||
|
potential_paths = [
|
||||||
|
os.path.join(temp_dir, 'dune-tunnel-key'),
|
||||||
|
os.path.join(temp_dir, 'dune-awakening-server-sshKey'),
|
||||||
|
os.path.join(base_dir, 'internal-scripts', 'ssh', 'sshKey'),
|
||||||
|
os.path.join(os.path.dirname(base_dir), 'internal-scripts', 'ssh', 'sshKey'),
|
||||||
|
]
|
||||||
|
if local_appdata:
|
||||||
|
potential_paths.insert(2, os.path.join(local_appdata, 'DuneAwakeningServer', 'sshKey'))
|
||||||
|
|
||||||
|
for path in potential_paths:
|
||||||
|
if os.path.exists(path):
|
||||||
|
return path
|
||||||
|
return None
|
||||||
|
|
||||||
def run(self, command, timeout=30):
|
def run(self, command, timeout=30):
|
||||||
args = [
|
args = [
|
||||||
'ssh',
|
'ssh',
|
||||||
'-i', self.ssh_key,
|
|
||||||
'-o', 'StrictHostKeyChecking=accept-new',
|
'-o', 'StrictHostKeyChecking=accept-new',
|
||||||
'-o', 'ConnectTimeout=10',
|
'-o', 'ConnectTimeout=10',
|
||||||
'-o', 'BatchMode=yes',
|
'-o', 'BatchMode=yes',
|
||||||
f'{self.user}@{self.host}',
|
|
||||||
command
|
|
||||||
]
|
]
|
||||||
|
if self.ssh_key:
|
||||||
|
args.extend(['-i', self.ssh_key])
|
||||||
|
args.extend([f'{self.user}@{self.host}', command])
|
||||||
logger.debug(f"SSH command: {command[:100]}...")
|
logger.debug(f"SSH command: {command[:100]}...")
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ def register_websocket_handlers(socketio, settings):
|
|||||||
@socketio.on('shell_create')
|
@socketio.on('shell_create')
|
||||||
def handle_shell_create(data):
|
def handle_shell_create(data):
|
||||||
# Check if shell access is enabled
|
# Check if shell access is enabled
|
||||||
shell_enabled = settings.get('auth', {}).get('shell_enabled', False)
|
shell_enabled = settings.get('auth', {}).get('shell_enabled', True)
|
||||||
if not shell_enabled:
|
if not shell_enabled:
|
||||||
logger.warning(f"WebSocket shell rejected: shell disabled (sid={request.sid})")
|
logger.warning(f"WebSocket shell rejected: shell disabled (sid={request.sid})")
|
||||||
return emit('shell_created', {'success': False, 'error': 'Shell access is disabled'})
|
return emit('shell_created', {'success': False, 'error': 'Shell access is disabled'})
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 99 MiB |
+598
-317
@@ -4,398 +4,679 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<style>
|
<style>
|
||||||
.map-container {
|
.map-page {
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 300px 1fr;
|
|
||||||
gap: 20px;
|
|
||||||
height: calc(100vh - 120px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-sidebar {
|
|
||||||
background: var(--card-bg);
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 16px;
|
|
||||||
overflow-y: auto;
|
|
||||||
box-shadow: var(--shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-sidebar h3 {
|
|
||||||
font-size: 14px;
|
|
||||||
color: var(--text-light);
|
|
||||||
margin: 16px 0 8px;
|
|
||||||
padding-bottom: 8px;
|
|
||||||
border-bottom: 1px solid var(--border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-sidebar h3:first-child {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-checkbox {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 6px 0;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-checkbox input {
|
|
||||||
accent-color: var(--primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.location-list {
|
|
||||||
max-height: 200px;
|
|
||||||
overflow-y: auto;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.location-item {
|
|
||||||
padding: 4px 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
margin: 2px 0;
|
|
||||||
cursor: pointer;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.location-item:hover {
|
|
||||||
background: var(--hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.location-item.player { border-left: 3px solid var(--primary); }
|
|
||||||
.location-item.vehicle { border-left: 3px solid #3498db; }
|
|
||||||
.location-item.building { border-left: 3px solid var(--success); }
|
|
||||||
|
|
||||||
.map-view {
|
|
||||||
background: var(--card-bg);
|
|
||||||
border-radius: 8px;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
box-shadow: var(--shadow);
|
|
||||||
min-height: 400px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-placeholder {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
gap: 14px;
|
||||||
justify-content: center;
|
height: calc(100vh - 104px);
|
||||||
height: 100%;
|
min-height: 620px;
|
||||||
color: var(--text-muted);
|
|
||||||
padding: 40px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.map-placeholder-icon {
|
.map-header {
|
||||||
font-size: 48px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-stats {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
margin-bottom: 16px;
|
}
|
||||||
|
|
||||||
|
.map-header h2 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-summary {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stat-card {
|
.map-summary-item {
|
||||||
background: var(--bg);
|
min-width: 92px;
|
||||||
padding: 12px 16px;
|
padding: 8px 10px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
min-width: 100px;
|
background: var(--card-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.stat-card .count {
|
.map-summary-item strong {
|
||||||
font-size: 24px;
|
display: block;
|
||||||
font-weight: 700;
|
font-size: 18px;
|
||||||
|
line-height: 1.1;
|
||||||
color: var(--primary);
|
color: var(--primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.stat-card .label {
|
.map-summary-item span {
|
||||||
|
display: block;
|
||||||
|
margin-top: 3px;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
.map-select {
|
.map-layout {
|
||||||
padding: 8px;
|
display: grid;
|
||||||
border: 1px solid var(--border);
|
grid-template-columns: minmax(0, 1fr) 320px;
|
||||||
border-radius: 4px;
|
gap: 16px;
|
||||||
background: var(--card-bg);
|
min-height: 0;
|
||||||
color: var(--text);
|
flex: 1;
|
||||||
font-size: 13px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.coord-display {
|
.map-view {
|
||||||
background: var(--code-bg);
|
|
||||||
padding: 8px 12px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-family: monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-light);
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.no-map-note {
|
|
||||||
background: var(--hover);
|
|
||||||
border: 1px dashed var(--border);
|
|
||||||
padding: 16px;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin-top: 16px;
|
|
||||||
font-size: 13px;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-display {
|
|
||||||
position: relative;
|
position: relative;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #101312;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-scroll {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
background: #1a1a1a;
|
cursor: grab;
|
||||||
}
|
}
|
||||||
|
|
||||||
.map-image-container {
|
.map-scroll.dragging {
|
||||||
|
cursor: grabbing;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-canvas {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
margin: 24px;
|
||||||
min-width: 1200px;
|
background: #0d0f0f;
|
||||||
min-height: 800px;
|
box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
|
||||||
}
|
}
|
||||||
|
|
||||||
.map-image {
|
.map-image {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 100%;
|
height: 100%;
|
||||||
height: auto;
|
object-fit: contain;
|
||||||
display: block;
|
user-select: none;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.map-marker {
|
.map-marker {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 12px;
|
width: 14px;
|
||||||
height: 12px;
|
height: 14px;
|
||||||
border-radius: 50%;
|
border-radius: 999px;
|
||||||
cursor: pointer;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
border: 2px solid #fff;
|
border: 2px solid #fff;
|
||||||
box-shadow: 0 2px 4px rgba(0,0,0,0.5);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
|
||||||
transition: transform 0.15s;
|
transform: translate(-50%, -50%);
|
||||||
|
cursor: pointer;
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-marker:hover,
|
||||||
|
.map-marker.active {
|
||||||
|
transform: translate(-50%, -50%) scale(1.45);
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
.map-marker:hover {
|
.map-marker.player { background: #e7c65b; }
|
||||||
transform: translate(-50%, -50%) scale(1.5);
|
.map-marker.vehicle { background: #45a3ff; }
|
||||||
z-index: 100;
|
.map-marker.base { background: #54c878; }
|
||||||
}
|
|
||||||
|
|
||||||
.map-marker.player {
|
.map-tooltip {
|
||||||
background: var(--primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-marker.vehicle {
|
|
||||||
background: #3498db;
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-marker.building {
|
|
||||||
background: var(--success);
|
|
||||||
}
|
|
||||||
|
|
||||||
.map-marker-tooltip {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 100%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
background: rgba(0,0,0,0.85);
|
|
||||||
color: #fff;
|
|
||||||
padding: 4px 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-size: 11px;
|
|
||||||
white-space: nowrap;
|
|
||||||
display: none;
|
display: none;
|
||||||
margin-bottom: 4px;
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
bottom: calc(100% + 8px);
|
||||||
|
transform: translateX(-50%);
|
||||||
|
min-width: 150px;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border-radius: 5px;
|
||||||
|
background: rgba(0, 0, 0, 0.86);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.4;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.map-marker:hover .map-marker-tooltip {
|
.map-marker:hover .map-tooltip {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.map-empty {
|
.map-empty {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
height: 100%;
|
gap: 8px;
|
||||||
color: var(--text-muted);
|
padding: 28px;
|
||||||
padding: 40px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-panel {
|
||||||
|
min-height: 0;
|
||||||
|
overflow: auto;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--card-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-section {
|
||||||
|
padding: 14px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-section:last-child {
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-title {
|
||||||
|
margin: 0 0 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-choice {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr auto;
|
||||||
|
gap: 6px 10px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-choice.active {
|
||||||
|
border-color: var(--primary);
|
||||||
|
box-shadow: inset 3px 0 0 var(--primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-choice strong {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-choice span {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-controls {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 36px 1fr 36px;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-controls button,
|
||||||
|
.map-icon-button {
|
||||||
|
height: 34px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-controls input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.zoom-readout {
|
||||||
|
margin-top: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 7px 0;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-toggle input {
|
||||||
|
accent-color: var(--primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-dot {
|
||||||
|
display: inline-block;
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
margin-right: 7px;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: 1px solid #fff;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-dot.player { background: #e7c65b; }
|
||||||
|
.legend-dot.vehicle { background: #45a3ff; }
|
||||||
|
.legend-dot.base { background: #54c878; }
|
||||||
|
|
||||||
|
.location-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
max-height: 310px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-item {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr auto;
|
||||||
|
gap: 4px 8px;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-item:hover,
|
||||||
|
.location-item.active {
|
||||||
|
border-color: var(--primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-item strong {
|
||||||
|
font-size: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-item span {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.coord-card {
|
||||||
|
display: none;
|
||||||
|
margin-top: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--bg);
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-light);
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 980px) {
|
||||||
|
.map-page {
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-layout {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-view {
|
||||||
|
height: 64vh;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<h2>World Map</h2>
|
<div class="map-page">
|
||||||
|
<div class="map-header">
|
||||||
{% if db_error %}
|
<div>
|
||||||
<div class="error-banner danger">{{ db_error }}</div>
|
<h2>World Map</h2>
|
||||||
{% endif %}
|
{% if db_error %}
|
||||||
|
<div class="error-banner danger">{{ db_error }}</div>
|
||||||
<div class="map-stats">
|
|
||||||
<div class="stat-card">
|
|
||||||
<div class="count">{{ players|length }}</div>
|
|
||||||
<div class="label">Players</div>
|
|
||||||
</div>
|
|
||||||
<div class="stat-card">
|
|
||||||
<div class="count">{{ vehicles|length }}</div>
|
|
||||||
<div class="label">Vehicles</div>
|
|
||||||
</div>
|
|
||||||
<div class="stat-card">
|
|
||||||
<div class="count">{{ buildings|length }}</div>
|
|
||||||
<div class="label">Buildings</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="map-container">
|
|
||||||
<div class="map-sidebar">
|
|
||||||
<h3>Filter by Type</h3>
|
|
||||||
<label class="map-checkbox">
|
|
||||||
<input type="checkbox" id="show-players" checked onchange="updateMap()">
|
|
||||||
Players ({{ players|length }})
|
|
||||||
</label>
|
|
||||||
<label class="map-checkbox">
|
|
||||||
<input type="checkbox" id="show-vehicles" checked onchange="updateMap()">
|
|
||||||
Vehicles ({{ vehicles|length }})
|
|
||||||
</label>
|
|
||||||
<label class="map-checkbox">
|
|
||||||
<input type="checkbox" id="show-buildings" checked onchange="updateMap()">
|
|
||||||
Buildings ({{ buildings|length }})
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<h3>Players</h3>
|
|
||||||
<div class="location-list" id="player-list">
|
|
||||||
{% for p in players %}
|
|
||||||
<div class="location-item player" data-type="player" data-map="{{ p.map }}" data-x="{{ p.x }}" data-y="{{ p.y }}" data-z="{{ p.z }}" data-name="{{ p.name }}" onclick="showCoords(this)">
|
|
||||||
<span>{{ p.name }}</span>
|
|
||||||
<span style="color:var(--text-muted)">{{ p.map }}</span>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% if not players %}
|
|
||||||
<div style="color:var(--text-muted);font-size:12px;padding:8px;">No player locations</div>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="map-summary">
|
||||||
<h3>Vehicles</h3>
|
<div class="map-summary-item">
|
||||||
<div class="location-list" id="vehicle-list">
|
<strong id="summary-players">0</strong>
|
||||||
{% for v in vehicles %}
|
<span>Players</span>
|
||||||
{% set vehicle_name = v.class.split('/')[-1].split('.')[0] if v.class else 'Unknown' %}
|
|
||||||
<div class="location-item vehicle" data-type="vehicle" data-map="{{ v.map }}" data-x="{{ v.x }}" data-y="{{ v.y }}" data-z="{{ v.z }}" data-name="{{ vehicle_name }}" onclick="showCoords(this)">
|
|
||||||
<span>{{ vehicle_name|truncate(15) }}</span>
|
|
||||||
<span style="color:var(--text-muted)">{{ v.map }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
<div class="map-summary-item">
|
||||||
{% if not vehicles %}
|
<strong id="summary-vehicles">0</strong>
|
||||||
<div style="color:var(--text-muted);font-size:12px;padding:8px;">No vehicle locations</div>
|
<span>Vehicles</span>
|
||||||
{% endif %}
|
</div>
|
||||||
</div>
|
<div class="map-summary-item">
|
||||||
|
<strong id="summary-bases">0</strong>
|
||||||
<h3>Buildings</h3>
|
<span>Bases</span>
|
||||||
<div class="location-list" id="building-list">
|
|
||||||
{% for b in buildings[:50] %}
|
|
||||||
<div class="location-item building" data-type="building" data-map="{{ b.map }}" data-x="{{ b.x }}" data-y="{{ b.y }}" data-z="{{ b.z }}" data-name="{{ b.class }}" onclick="showCoords(this)">
|
|
||||||
<span>{{ b.class|truncate(20) }}</span>
|
|
||||||
<span style="color:var(--text-muted)">{{ b.map }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
{% if not buildings %}
|
|
||||||
<div style="color:var(--text-muted);font-size:12px;padding:8px;">No building locations</div>
|
|
||||||
{% endif %}
|
|
||||||
{% if buildings|length > 50 %}
|
|
||||||
<div style="color:var(--text-muted);font-size:11px;padding:8px;">+{{ buildings|length - 50 }} more</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="map-view">
|
<div class="map-layout">
|
||||||
{% set current_map = map_config.get(default_map, {}) %}
|
<div class="map-view">
|
||||||
{% set map_image = current_map.get('image') %}
|
<div class="map-scroll" id="map-scroll">
|
||||||
{% if map_image %}
|
<div class="map-canvas" id="map-canvas">
|
||||||
<div class="map-display">
|
<img class="map-image" id="map-image" alt="Selected map">
|
||||||
<div class="map-image-container">
|
<div id="map-markers"></div>
|
||||||
<img src="{{ url_for('static', filename=map_image) }}" class="map-image" alt="Map">
|
|
||||||
|
|
||||||
{# Players - only show if they have pixel coords #}
|
|
||||||
{% for p in players %}
|
|
||||||
{% if p.px is not none and p.py is not none %}
|
|
||||||
<div class="map-marker player" style="left:{{ p.px }}px;top:{{ p.py }}px;" title="{{ p.name }}">
|
|
||||||
<span class="map-marker-tooltip">{{ p.name }} (Player)</span>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
</div>
|
||||||
{% endfor %}
|
<div class="map-empty" id="map-empty" style="display:none;">
|
||||||
|
<strong>No markers on this map</strong>
|
||||||
{# Vehicles #}
|
<span>The selected map has no in-bounds players, vehicles, or bases yet.</span>
|
||||||
{% for v in vehicles %}
|
|
||||||
{% if v.px is not none and v.py is not none %}
|
|
||||||
<div class="map-marker vehicle" style="left:{{ v.px }}px;top:{{ v.py }}px;" title="{{ v.class }}">
|
|
||||||
<span class="map-marker-tooltip">{{ v.class.split('/')[-1].split('.')[0] }} (Vehicle)</span>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{# Buildings #}
|
|
||||||
{% for b in buildings[:30] %}
|
|
||||||
{% if b.px is not none and b.py is not none %}
|
|
||||||
<div class="map-marker building" style="left:{{ b.px }}px;top:{{ b.py }}px;" title="{{ b.class }}">
|
|
||||||
<span class="map-marker-tooltip">{{ b.class.split('/')[-1].split('.')[0] }} (Building)</span>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
|
||||||
<div class="map-placeholder">
|
<aside class="map-panel">
|
||||||
<div class="map-placeholder-icon">🗺️</div>
|
<section class="panel-section">
|
||||||
<h3>No Map Available</h3>
|
<h3 class="panel-title">Map</h3>
|
||||||
<p>Map image not configured. Showing coordinate data in list view.</p>
|
<div id="map-choices"></div>
|
||||||
<div class="no-map-note">
|
</section>
|
||||||
<strong>Available Data:</strong><br>
|
|
||||||
DeepDesert & HaggaBasin locations:<br>
|
<section class="panel-section">
|
||||||
Players: {{ players|length }}<br>
|
<h3 class="panel-title">Zoom</h3>
|
||||||
Vehicles: {{ vehicles|length }}<br>
|
<div class="map-controls">
|
||||||
Buildings: {{ buildings|length }}
|
<button type="button" id="zoom-out" title="Zoom out">-</button>
|
||||||
</div>
|
<input type="range" id="zoom-slider" min="50" max="350" value="100" step="10">
|
||||||
</div>
|
<button type="button" id="zoom-in" title="Zoom in">+</button>
|
||||||
{% endif %}
|
</div>
|
||||||
|
<div class="zoom-readout" id="zoom-readout">100%</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="panel-section">
|
||||||
|
<h3 class="panel-title">Assets</h3>
|
||||||
|
<label class="map-toggle">
|
||||||
|
<span><i class="legend-dot player"></i>Players</span>
|
||||||
|
<input type="checkbox" data-filter="player" checked>
|
||||||
|
</label>
|
||||||
|
<label class="map-toggle">
|
||||||
|
<span><i class="legend-dot vehicle"></i>Vehicles</span>
|
||||||
|
<input type="checkbox" data-filter="vehicle" checked>
|
||||||
|
</label>
|
||||||
|
<label class="map-toggle">
|
||||||
|
<span><i class="legend-dot base"></i>Bases</span>
|
||||||
|
<input type="checkbox" data-filter="base" checked>
|
||||||
|
</label>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="panel-section">
|
||||||
|
<h3 class="panel-title">Visible Assets</h3>
|
||||||
|
<div class="location-list" id="location-list"></div>
|
||||||
|
<div class="coord-card" id="coord-card"></div>
|
||||||
|
</section>
|
||||||
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function showCoords(el) {
|
const mapOptions = {{ map_options|tojson }};
|
||||||
const name = el.dataset.name;
|
const markers = [
|
||||||
const map = el.dataset.map;
|
...{{ players|tojson }},
|
||||||
const x = parseFloat(el.dataset.x);
|
...{{ vehicles|tojson }},
|
||||||
const y = parseFloat(el.dataset.y);
|
...{{ buildings|tojson }}
|
||||||
const z = parseFloat(el.dataset.z);
|
];
|
||||||
|
const mapImageUrls = {
|
||||||
|
{% for map in map_options %}
|
||||||
|
"{{ map.key }}": "{{ url_for('static', filename=map.image) }}"{% if not loop.last %},{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
};
|
||||||
|
|
||||||
document.getElementById('selected-coords').style.display = 'block';
|
let currentMap = "{{ default_map }}";
|
||||||
document.getElementById('coord-display').innerHTML =
|
let currentZoom = 1;
|
||||||
`<strong>${name}</strong><br>` +
|
let activeMarkerId = null;
|
||||||
`Map: ${map}<br>` +
|
const enabledTypes = { player: true, vehicle: true, base: true };
|
||||||
`X: ${x.toFixed(2)} | Y: ${y.toFixed(2)} | Z: ${z.toFixed(2)}`;
|
|
||||||
|
if (!mapOptions.some(map => map.key === currentMap) && mapOptions.length) {
|
||||||
|
currentMap = mapOptions[0].key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateMap() {
|
const els = {
|
||||||
const showPlayers = document.getElementById('show-players').checked;
|
choices: document.getElementById('map-choices'),
|
||||||
const showVehicles = document.getElementById('show-vehicles').checked;
|
scroll: document.getElementById('map-scroll'),
|
||||||
const showBuildings = document.getElementById('show-buildings').checked;
|
canvas: document.getElementById('map-canvas'),
|
||||||
|
image: document.getElementById('map-image'),
|
||||||
|
markers: document.getElementById('map-markers'),
|
||||||
|
empty: document.getElementById('map-empty'),
|
||||||
|
list: document.getElementById('location-list'),
|
||||||
|
coord: document.getElementById('coord-card'),
|
||||||
|
zoomSlider: document.getElementById('zoom-slider'),
|
||||||
|
zoomReadout: document.getElementById('zoom-readout'),
|
||||||
|
summaryPlayers: document.getElementById('summary-players'),
|
||||||
|
summaryVehicles: document.getElementById('summary-vehicles'),
|
||||||
|
summaryBases: document.getElementById('summary-bases'),
|
||||||
|
};
|
||||||
|
|
||||||
// Filter lists
|
function markerKey(marker) {
|
||||||
document.querySelectorAll('#player-list .location-item').forEach(el => {
|
return `${marker.type}-${marker.id}`;
|
||||||
el.style.display = showPlayers ? 'flex' : 'none';
|
}
|
||||||
});
|
|
||||||
document.querySelectorAll('#vehicle-list .location-item').forEach(el => {
|
function escapeHtml(value) {
|
||||||
el.style.display = showVehicles ? 'flex' : 'none';
|
return String(value ?? '').replace(/[&<>"']/g, char => ({
|
||||||
});
|
'&': '&',
|
||||||
document.querySelectorAll('#building-list .location-item').forEach(el => {
|
'<': '<',
|
||||||
el.style.display = showBuildings ? 'flex' : 'none';
|
'>': '>',
|
||||||
|
'"': '"',
|
||||||
|
"'": '''
|
||||||
|
}[char]));
|
||||||
|
}
|
||||||
|
|
||||||
|
function markerLabel(marker) {
|
||||||
|
if (marker.type === 'player') return marker.name || `Player ${marker.id}`;
|
||||||
|
if (marker.type === 'vehicle') return marker.class || `Vehicle ${marker.id}`;
|
||||||
|
return marker.name || marker.class || `Base ${marker.id}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectedMapConfig() {
|
||||||
|
return mapOptions.find(map => map.key === currentMap) || mapOptions[0] || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function visibleMarkers() {
|
||||||
|
return markers.filter(marker =>
|
||||||
|
marker.map === currentMap &&
|
||||||
|
marker.in_bounds &&
|
||||||
|
enabledTypes[marker.type]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setZoom(nextZoom, keepCenter = true) {
|
||||||
|
const map = selectedMapConfig();
|
||||||
|
if (!map) return;
|
||||||
|
|
||||||
|
const oldZoom = currentZoom;
|
||||||
|
const viewportCenterX = els.scroll.scrollLeft + els.scroll.clientWidth / 2;
|
||||||
|
const viewportCenterY = els.scroll.scrollTop + els.scroll.clientHeight / 2;
|
||||||
|
const relativeX = oldZoom ? viewportCenterX / oldZoom : 0;
|
||||||
|
const relativeY = oldZoom ? viewportCenterY / oldZoom : 0;
|
||||||
|
|
||||||
|
currentZoom = Math.min(3.5, Math.max(0.5, nextZoom));
|
||||||
|
els.canvas.style.width = `${map.width * currentZoom}px`;
|
||||||
|
els.canvas.style.height = `${map.height * currentZoom}px`;
|
||||||
|
els.zoomSlider.value = Math.round(currentZoom * 100);
|
||||||
|
els.zoomReadout.textContent = `${Math.round(currentZoom * 100)}%`;
|
||||||
|
|
||||||
|
if (keepCenter) {
|
||||||
|
els.scroll.scrollLeft = relativeX * currentZoom - els.scroll.clientWidth / 2;
|
||||||
|
els.scroll.scrollTop = relativeY * currentZoom - els.scroll.clientHeight / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderChoices() {
|
||||||
|
els.choices.innerHTML = '';
|
||||||
|
mapOptions.forEach(map => {
|
||||||
|
const button = document.createElement('button');
|
||||||
|
button.type = 'button';
|
||||||
|
button.className = `map-choice${map.key === currentMap ? ' active' : ''}`;
|
||||||
|
button.innerHTML = `
|
||||||
|
<strong>${escapeHtml(map.label)}</strong>
|
||||||
|
<span>${map.counts.players} P / ${map.counts.vehicles} V / ${map.counts.bases} B</span>
|
||||||
|
<span>${escapeHtml(map.key)}</span>
|
||||||
|
<span>${map.width} x ${map.height}</span>
|
||||||
|
`;
|
||||||
|
button.addEventListener('click', () => {
|
||||||
|
currentMap = map.key;
|
||||||
|
activeMarkerId = null;
|
||||||
|
renderAll(true);
|
||||||
|
});
|
||||||
|
els.choices.appendChild(button);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderMarkers() {
|
||||||
|
const map = selectedMapConfig();
|
||||||
|
const current = visibleMarkers();
|
||||||
|
els.markers.innerHTML = '';
|
||||||
|
|
||||||
|
current.forEach(marker => {
|
||||||
|
const key = markerKey(marker);
|
||||||
|
const label = escapeHtml(markerLabel(marker));
|
||||||
|
const node = document.createElement('button');
|
||||||
|
node.type = 'button';
|
||||||
|
node.className = `map-marker ${marker.type}${activeMarkerId === key ? ' active' : ''}`;
|
||||||
|
node.style.left = `${(marker.px / map.width) * 100}%`;
|
||||||
|
node.style.top = `${(marker.py / map.height) * 100}%`;
|
||||||
|
node.title = markerLabel(marker);
|
||||||
|
node.innerHTML = `
|
||||||
|
<span class="map-tooltip">
|
||||||
|
${label}<br>
|
||||||
|
${escapeHtml(marker.type.toUpperCase())} | X ${Number(marker.x).toFixed(0)} Y ${Number(marker.y).toFixed(0)}
|
||||||
|
</span>
|
||||||
|
`;
|
||||||
|
node.addEventListener('click', () => selectMarker(key, true));
|
||||||
|
els.markers.appendChild(node);
|
||||||
|
});
|
||||||
|
|
||||||
|
els.empty.style.display = current.length ? 'none' : 'flex';
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderList() {
|
||||||
|
const current = visibleMarkers();
|
||||||
|
els.list.innerHTML = '';
|
||||||
|
|
||||||
|
if (!current.length) {
|
||||||
|
const empty = document.createElement('div');
|
||||||
|
empty.className = 'location-item';
|
||||||
|
empty.innerHTML = '<strong>No visible assets</strong><span>Adjust map or filters</span>';
|
||||||
|
els.list.appendChild(empty);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
current
|
||||||
|
.sort((a, b) => a.type.localeCompare(b.type) || markerLabel(a).localeCompare(markerLabel(b)))
|
||||||
|
.forEach(marker => {
|
||||||
|
const key = markerKey(marker);
|
||||||
|
const label = escapeHtml(markerLabel(marker));
|
||||||
|
const item = document.createElement('button');
|
||||||
|
item.type = 'button';
|
||||||
|
item.className = `location-item${activeMarkerId === key ? ' active' : ''}`;
|
||||||
|
item.dataset.markerKey = key;
|
||||||
|
item.innerHTML = `
|
||||||
|
<strong><i class="legend-dot ${marker.type}"></i>${label}</strong>
|
||||||
|
<span>${escapeHtml(marker.type)}</span>
|
||||||
|
<span>X ${Number(marker.x).toFixed(0)} | Y ${Number(marker.y).toFixed(0)}</span>
|
||||||
|
<span>Z ${Number(marker.z).toFixed(0)}</span>
|
||||||
|
`;
|
||||||
|
item.addEventListener('click', () => selectMarker(key, true));
|
||||||
|
els.list.appendChild(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderSummary() {
|
||||||
|
const scoped = markers.filter(marker => marker.map === currentMap && marker.in_bounds);
|
||||||
|
els.summaryPlayers.textContent = scoped.filter(marker => marker.type === 'player').length;
|
||||||
|
els.summaryVehicles.textContent = scoped.filter(marker => marker.type === 'vehicle').length;
|
||||||
|
els.summaryBases.textContent = scoped.filter(marker => marker.type === 'base').length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectMarker(key, centerMap = false) {
|
||||||
|
activeMarkerId = key;
|
||||||
|
const marker = markers.find(candidate => markerKey(candidate) === key);
|
||||||
|
if (!marker) return;
|
||||||
|
|
||||||
|
els.coord.style.display = 'block';
|
||||||
|
els.coord.innerHTML = `
|
||||||
|
<strong>${escapeHtml(markerLabel(marker))}</strong><br>
|
||||||
|
Type: ${escapeHtml(marker.type)}<br>
|
||||||
|
Map: ${escapeHtml(marker.map)}<br>
|
||||||
|
X: ${Number(marker.x).toFixed(2)} | Y: ${Number(marker.y).toFixed(2)} | Z: ${Number(marker.z).toFixed(2)}
|
||||||
|
`;
|
||||||
|
|
||||||
|
if (centerMap) {
|
||||||
|
els.scroll.scrollLeft = marker.px * currentZoom - els.scroll.clientWidth / 2;
|
||||||
|
els.scroll.scrollTop = marker.py * currentZoom - els.scroll.clientHeight / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderMarkers();
|
||||||
|
renderList();
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderAll(resetView = false) {
|
||||||
|
const map = selectedMapConfig();
|
||||||
|
renderChoices();
|
||||||
|
|
||||||
|
if (!map) {
|
||||||
|
els.empty.style.display = 'flex';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
els.image.src = mapImageUrls[map.key] || '';
|
||||||
|
els.image.alt = map.label;
|
||||||
|
setZoom(resetView ? 1 : currentZoom, !resetView);
|
||||||
|
|
||||||
|
if (resetView) {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
els.scroll.scrollLeft = Math.max(0, (els.canvas.offsetWidth - els.scroll.clientWidth) / 2);
|
||||||
|
els.scroll.scrollTop = Math.max(0, (els.canvas.offsetHeight - els.scroll.clientHeight) / 2);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
renderSummary();
|
||||||
|
renderMarkers();
|
||||||
|
renderList();
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll('[data-filter]').forEach(input => {
|
||||||
|
input.addEventListener('change', () => {
|
||||||
|
enabledTypes[input.dataset.filter] = input.checked;
|
||||||
|
activeMarkerId = null;
|
||||||
|
els.coord.style.display = 'none';
|
||||||
|
renderMarkers();
|
||||||
|
renderList();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('zoom-in').addEventListener('click', () => setZoom(currentZoom + 0.1));
|
||||||
|
document.getElementById('zoom-out').addEventListener('click', () => setZoom(currentZoom - 0.1));
|
||||||
|
els.zoomSlider.addEventListener('input', event => setZoom(Number(event.target.value) / 100));
|
||||||
|
|
||||||
|
els.scroll.addEventListener('wheel', event => {
|
||||||
|
if (!event.ctrlKey && !event.metaKey) return;
|
||||||
|
event.preventDefault();
|
||||||
|
setZoom(currentZoom + (event.deltaY < 0 ? 0.1 : -0.1));
|
||||||
|
}, { passive: false });
|
||||||
|
|
||||||
|
let dragStart = null;
|
||||||
|
els.scroll.addEventListener('mousedown', event => {
|
||||||
|
if (event.button !== 0) return;
|
||||||
|
dragStart = {
|
||||||
|
x: event.clientX,
|
||||||
|
y: event.clientY,
|
||||||
|
left: els.scroll.scrollLeft,
|
||||||
|
top: els.scroll.scrollTop,
|
||||||
|
};
|
||||||
|
els.scroll.classList.add('dragging');
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('mousemove', event => {
|
||||||
|
if (!dragStart) return;
|
||||||
|
els.scroll.scrollLeft = dragStart.left - (event.clientX - dragStart.x);
|
||||||
|
els.scroll.scrollTop = dragStart.top - (event.clientY - dragStart.y);
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('mouseup', () => {
|
||||||
|
dragStart = null;
|
||||||
|
els.scroll.classList.remove('dragging');
|
||||||
|
});
|
||||||
|
|
||||||
|
renderAll(true);
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in new issue
Block a user