318 lines
9.3 KiB
Python
318 lines
9.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Fast Static Asset Gallery Generator
|
|
Scans assets and generates HTML - NO file copying!
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
from collections import defaultdict
|
|
|
|
# Skip these folders (backups, etc.)
|
|
SKIP_FOLDERS = {'BACKUP', 'node_modules', '.git', 'out', '__pycache__'}
|
|
|
|
# Categories with keywords
|
|
CATEGORIES = {
|
|
"🌱 Ground & Terrain": ["ground", "grass", "dirt", "soil", "water", "teren", "tla"],
|
|
"🌾 Crops & Farming": ["crop", "wheat", "potato", "corn", "tomato", "seed", "harvest", "pridelek", "sadik"],
|
|
"🌳 Trees & Nature": ["tree", "apple", "cherry", "dead", "bush", "drevo", "narava", "gozd"],
|
|
"🏗️ Props & Objects": ["fence", "chest", "barrel", "crate", "prop", "objekt", "ograja"],
|
|
"🏠 Buildings": ["house", "barn", "building", "zgradba", "hisa", "gothic"],
|
|
"👤 Characters & NPCs": ["character", "npc", "kai", "ana", "gronk", "zombie", "lik", "igralec"],
|
|
"💥 Effects & VFX": ["blood", "fog", "rain", "vfx", "effect", "kri", "megla"],
|
|
"🎨 UI & Icons": ["icon", "ui", "button", "menu", "ikona"],
|
|
"🔧 Tools & Items": ["tool", "hoe", "axe", "pickaxe", "sword", "orodi", "item"],
|
|
"📦 Other": []
|
|
}
|
|
|
|
def should_skip(path_str):
|
|
"""Check if we should skip this path."""
|
|
for skip in SKIP_FOLDERS:
|
|
if skip in path_str:
|
|
return True
|
|
return False
|
|
|
|
def categorize(filepath):
|
|
"""Determine category from path."""
|
|
path_lower = str(filepath).lower()
|
|
|
|
for category, keywords in CATEGORIES.items():
|
|
if category == "📦 Other":
|
|
continue
|
|
for kw in keywords:
|
|
if kw in path_lower:
|
|
return category
|
|
|
|
return "📦 Other"
|
|
|
|
def scan_fast():
|
|
"""Fast scan - limit depth and skip backups."""
|
|
categorized = defaultdict(list)
|
|
count = 0
|
|
max_files = 500 # Limit for speed
|
|
|
|
print("🔍 Scanning assets...")
|
|
|
|
for root, dirs, files in os.walk("assets"):
|
|
# Remove skip folders from search
|
|
dirs[:] = [d for d in dirs if not should_skip(os.path.join(root, d))]
|
|
|
|
for file in files:
|
|
if not file.endswith('.png'):
|
|
continue
|
|
|
|
if count >= max_files:
|
|
break
|
|
|
|
full_path = os.path.join(root, file)
|
|
category = categorize(full_path)
|
|
|
|
categorized[category].append({
|
|
"path": full_path,
|
|
"name": file
|
|
})
|
|
count += 1
|
|
|
|
if count % 50 == 0:
|
|
print(f" Found {count} assets...")
|
|
|
|
if count >= max_files:
|
|
break
|
|
|
|
print(f"✅ Scanned {count} assets")
|
|
return categorized
|
|
|
|
def generate_html(categorized):
|
|
"""Generate beautiful HTML gallery."""
|
|
|
|
total = sum(len(assets) for assets in categorized.values())
|
|
|
|
html = f"""<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Mrtva Dolina - Full Asset Gallery</title>
|
|
<style>
|
|
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
|
|
|
|
body {{
|
|
font-family: 'Segoe UI', Tahoma, sans-serif;
|
|
background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
|
|
color: #e0e0e0;
|
|
padding: 20px;
|
|
}}
|
|
|
|
.header {{
|
|
text-align: center;
|
|
padding: 40px 20px;
|
|
background: rgba(0,0,0,0.4);
|
|
border-radius: 10px;
|
|
margin-bottom: 30px;
|
|
border: 2px solid #ff4444;
|
|
}}
|
|
|
|
.header h1 {{
|
|
font-size: 3.5em;
|
|
color: #ff4444;
|
|
text-shadow: 3px 3px 6px rgba(0,0,0,0.9);
|
|
margin-bottom: 10px;
|
|
}}
|
|
|
|
.header p {{
|
|
font-size: 1.3em;
|
|
color: #aaa;
|
|
}}
|
|
|
|
.stats {{
|
|
text-align: center;
|
|
margin: 20px 0;
|
|
font-size: 1.2em;
|
|
color: #888;
|
|
padding: 15px;
|
|
background: rgba(0,0,0,0.3);
|
|
border-radius: 8px;
|
|
}}
|
|
|
|
.category {{
|
|
margin: 50px 0;
|
|
background: rgba(0,0,0,0.3);
|
|
border-radius: 12px;
|
|
padding: 25px;
|
|
border: 1px solid #333;
|
|
}}
|
|
|
|
.category-header {{
|
|
font-size: 2.2em;
|
|
color: #ff6666;
|
|
margin-bottom: 25px;
|
|
padding-bottom: 15px;
|
|
border-bottom: 3px solid #444;
|
|
}}
|
|
|
|
.category-header .count {{
|
|
font-size: 0.6em;
|
|
color: #888;
|
|
margin-left: 15px;
|
|
}}
|
|
|
|
.grid {{
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
|
gap: 20px;
|
|
margin-top: 25px;
|
|
}}
|
|
|
|
.card {{
|
|
background: rgba(255,255,255,0.05);
|
|
border: 1px solid #444;
|
|
border-radius: 10px;
|
|
padding: 15px;
|
|
text-align: center;
|
|
transition: all 0.3s ease;
|
|
}}
|
|
|
|
.card:hover {{
|
|
transform: translateY(-8px) scale(1.02);
|
|
box-shadow: 0 10px 25px rgba(255,68,68,0.4);
|
|
border-color: #ff4444;
|
|
background: rgba(255,68,68,0.1);
|
|
}}
|
|
|
|
.card img {{
|
|
width: 180px;
|
|
height: 180px;
|
|
object-fit: contain;
|
|
background: rgba(0,0,0,0.5);
|
|
border-radius: 6px;
|
|
margin-bottom: 12px;
|
|
image-rendering: pixelated;
|
|
border: 1px solid #222;
|
|
}}
|
|
|
|
.asset-name {{
|
|
font-size: 0.85em;
|
|
color: #ccc;
|
|
margin: 10px 0;
|
|
word-break: break-all;
|
|
font-family: 'Courier New', monospace;
|
|
min-height: 40px;
|
|
}}
|
|
|
|
.copy-btn {{
|
|
background: linear-gradient(135deg, #ff4444, #cc3333);
|
|
color: white;
|
|
border: none;
|
|
padding: 10px 18px;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
font-size: 0.95em;
|
|
font-weight: bold;
|
|
transition: all 0.2s;
|
|
box-shadow: 0 2px 5px rgba(0,0,0,0.3);
|
|
}}
|
|
|
|
.copy-btn:hover {{
|
|
background: linear-gradient(135deg, #ff6666, #ff4444);
|
|
transform: scale(1.05);
|
|
box-shadow: 0 4px 10px rgba(255,68,68,0.4);
|
|
}}
|
|
|
|
.copy-btn:active {{
|
|
background: #cc3333;
|
|
transform: scale(0.98);
|
|
}}
|
|
|
|
.copied {{
|
|
background: linear-gradient(135deg, #44ff44, #33cc33) !important;
|
|
}}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h1>💀 MRTVA DOLINA 💀</h1>
|
|
<p>Complete Asset Gallery - Static Offline Version</p>
|
|
</div>
|
|
|
|
<div class="stats">
|
|
<strong>📊 Total Assets:</strong> {total} |
|
|
<strong>📁 Categories:</strong> {len([c for c in categorized if categorized[c]])}
|
|
</div>
|
|
"""
|
|
|
|
for category in sorted(categorized.keys()):
|
|
assets = categorized[category]
|
|
if not assets:
|
|
continue
|
|
|
|
# Sort by name
|
|
assets.sort(key=lambda x: x['name'])
|
|
|
|
html += f"""
|
|
<div class="category">
|
|
<div class="category-header">
|
|
{category}
|
|
<span class="count">({len(assets)} assets)</span>
|
|
</div>
|
|
<div class="grid">
|
|
"""
|
|
|
|
for asset in assets:
|
|
html += f"""
|
|
<div class="card">
|
|
<img src="{asset['path']}" alt="{asset['name']}"
|
|
onerror="this.style.border='2px solid red'">
|
|
<div class="asset-name">{asset['name']}</div>
|
|
<button class="copy-btn" onclick="copyName('{asset['name']}', this)">
|
|
📋 Copy Name
|
|
</button>
|
|
</div>
|
|
"""
|
|
|
|
html += """
|
|
</div>
|
|
</div>
|
|
"""
|
|
|
|
html += """
|
|
<script>
|
|
function copyName(name, btn) {
|
|
navigator.clipboard.writeText(name).then(() => {
|
|
const orig = btn.innerHTML;
|
|
btn.innerHTML = '✅ Copied!';
|
|
btn.classList.add('copied');
|
|
|
|
setTimeout(() => {
|
|
btn.innerHTML = orig;
|
|
btn.classList.remove('copied');
|
|
}, 1800);
|
|
}).catch(() => {
|
|
// Fallback
|
|
const ta = document.createElement('textarea');
|
|
ta.value = name;
|
|
document.body.appendChild(ta);
|
|
ta.select();
|
|
document.execCommand('copy');
|
|
document.body.removeChild(ta);
|
|
|
|
btn.innerHTML = '✅ Copied!';
|
|
btn.classList.add('copied');
|
|
setTimeout(() => btn.innerHTML = '📋 Copy Name', 1800);
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
"""
|
|
|
|
with open('asset_gallery_full.html', 'w', encoding='utf-8') as f:
|
|
f.write(html)
|
|
|
|
print(f"\n✅ Gallery created: asset_gallery_full.html")
|
|
print(f" {total} assets in {len([c for c in categorized if categorized[c]])} categories")
|
|
print(f"\n🎯 Double-click to open (works offline!)")
|
|
|
|
if __name__ == "__main__":
|
|
categorized = scan_fast()
|
|
generate_html(categorized)
|