Add balloon, glider, and UAV sprites with admin sprite management
New dedicated pixel art sprites for ADS-B emitter categories B2 (lighter-than-air → balloon), B1 (glider/sailplane → glider), and B6 (UAV → uav), replacing the previous fallback to smallProp. Adds an admin Sprites tab for previewing and uploading replacement PNGs for all 9 aircraft sprite types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -348,6 +348,101 @@ textarea {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Sprite Management */
|
||||
.sprite-info {
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
border: 2px solid #5c94fc;
|
||||
border-radius: 8px;
|
||||
padding: 14px 18px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.sprite-info h3 {
|
||||
font-family: 'Press Start 2P', monospace;
|
||||
font-size: 10px;
|
||||
color: #fcd444;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.sprite-info p {
|
||||
font-size: 12px;
|
||||
color: #b4d4ec;
|
||||
margin-bottom: 4px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.sprite-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.sprite-card {
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
border: 2px solid #5c94fc;
|
||||
border-radius: 8px;
|
||||
padding: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sprite-card h4 {
|
||||
font-family: 'Press Start 2P', monospace;
|
||||
font-size: 10px;
|
||||
color: #fcfcfc;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.sprite-card .sprite-categories {
|
||||
font-size: 10px;
|
||||
color: #888;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.sprite-preview {
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
border: 1px solid #444;
|
||||
border-radius: 4px;
|
||||
padding: 6px;
|
||||
margin-bottom: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 80px;
|
||||
}
|
||||
|
||||
.sprite-preview img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
max-height: 80px;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
|
||||
.sprite-preview .no-sprite {
|
||||
color: #666;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.sprite-upload-label {
|
||||
display: inline-block;
|
||||
font-family: 'Press Start 2P', monospace;
|
||||
font-size: 8px;
|
||||
padding: 6px 12px;
|
||||
border: 2px solid #5c94fc;
|
||||
border-radius: 6px;
|
||||
background: rgba(92, 148, 252, 0.2);
|
||||
color: #fcfcfc;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.sprite-upload-label:hover {
|
||||
background: rgba(92, 148, 252, 0.4);
|
||||
}
|
||||
|
||||
.sprite-upload-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Mobile */
|
||||
@media (max-width: 768px) {
|
||||
.admin-header {
|
||||
@@ -389,4 +484,8 @@ textarea {
|
||||
.button-row .btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sprite-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
<button class="tab" data-tab="location">LOCATION</button>
|
||||
<button class="tab" data-tab="display">DISPLAY</button>
|
||||
<button class="tab" data-tab="tuning">TUNING</button>
|
||||
<button class="tab" data-tab="sprites">SPRITES</button>
|
||||
<button class="tab" data-tab="security">SECURITY</button>
|
||||
</nav>
|
||||
|
||||
@@ -201,6 +202,20 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Sprites Tab -->
|
||||
<section id="tab-sprites" class="tab-pane hidden">
|
||||
<h2>Aircraft Sprites</h2>
|
||||
<div class="sprite-info">
|
||||
<h3>Sprite Specifications</h3>
|
||||
<p><strong>Size:</strong> 500 x 333 px <strong>Format:</strong> PNG 8-bit RGBA (transparent background)</p>
|
||||
<p><strong>Orientation:</strong> Facing right (auto-flipped for westbound aircraft)</p>
|
||||
<p><strong>Style:</strong> Retro SNES pixel art, white/blue/red color scheme</p>
|
||||
</div>
|
||||
<div id="sprite-grid" class="sprite-grid">
|
||||
<!-- Populated by JS -->
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Security Tab -->
|
||||
<section id="tab-security" class="tab-pane hidden">
|
||||
<h2>Change Admin Password</h2>
|
||||
|
||||
@@ -67,6 +67,11 @@
|
||||
document.querySelectorAll('.tab-pane').forEach(p => p.classList.add('hidden'));
|
||||
tab.classList.add('active');
|
||||
document.getElementById('tab-' + tab.dataset.tab).classList.remove('hidden');
|
||||
// Lazy-load sprites on first visit
|
||||
if (tab.dataset.tab === 'sprites' && !spritesLoaded) {
|
||||
spritesLoaded = true;
|
||||
loadSprites();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -307,6 +312,76 @@
|
||||
}
|
||||
});
|
||||
|
||||
// ------- Sprites -------
|
||||
let spritesLoaded = false;
|
||||
|
||||
async function loadSprites() {
|
||||
try {
|
||||
const res = await fetch('/api/admin/sprites');
|
||||
if (!res.ok) return;
|
||||
const data = await res.json();
|
||||
const grid = document.getElementById('sprite-grid');
|
||||
if (!grid) return;
|
||||
|
||||
grid.innerHTML = '';
|
||||
(data.sprites || []).forEach(sprite => {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'sprite-card';
|
||||
|
||||
const cacheBust = Date.now();
|
||||
const imgHtml = sprite.exists
|
||||
? `<img src="${sprite.url}?v=${cacheBust}" alt="${sprite.type}">`
|
||||
: `<span class="no-sprite">No sprite</span>`;
|
||||
|
||||
card.innerHTML = `
|
||||
<h4>${sprite.type}</h4>
|
||||
<div class="sprite-categories">${sprite.categories || ''}</div>
|
||||
<div class="sprite-preview">${imgHtml}</div>
|
||||
<label class="sprite-upload-label">
|
||||
UPLOAD
|
||||
<input type="file" class="sprite-upload-input" accept=".png,image/png" data-type="${sprite.type}">
|
||||
</label>
|
||||
`;
|
||||
|
||||
const fileInput = card.querySelector('.sprite-upload-input');
|
||||
fileInput.addEventListener('change', async (e) => {
|
||||
const file = e.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
if (!file.type.includes('png')) {
|
||||
toast('Only PNG files are allowed', true);
|
||||
e.target.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
try {
|
||||
const uploadRes = await fetch(`/api/admin/sprites/${sprite.type}`, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
if (uploadRes.ok) {
|
||||
toast(`${sprite.type} sprite updated`);
|
||||
loadSprites(); // Refresh previews
|
||||
} else {
|
||||
const err = await uploadRes.json();
|
||||
toast(err.error || 'Upload failed', true);
|
||||
}
|
||||
} catch (err) {
|
||||
toast('Upload error', true);
|
||||
}
|
||||
e.target.value = '';
|
||||
});
|
||||
|
||||
grid.appendChild(card);
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Failed to load sprites', e);
|
||||
}
|
||||
}
|
||||
|
||||
// ------- Helpers -------
|
||||
async function saveConfig(body) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user