#!/usr/bin/env python3 """ Static Asset Gallery Generator Generates self-contained HTML galleries for all game assets. Works offline (file://) - just double-click to open! """ import os import json from pathlib import Path from collections import defaultdict # Categories with their detection patterns CATEGORIES = { "Ground & Terrain": ["ground", "grass", "dirt", "soil", "water", "teren"], "Crops & Farming": ["crop", "wheat", "potato", "corn", "seed", "harvest", "pridelek"], "Trees & Nature": ["tree", "apple", "cherry", "dead", "bush", "drevo", "narava"], "Props & Objects": ["fence", "chest", "barrel", "scooter", "prop", "objekt"], "Buildings": ["house", "barn", "building", "zgradba", "hisa"], "Characters & NPCs": ["character", "npc", "kai", "ana", "gronk", "zombie", "lik"], "Effects & VFX": ["blood", "fog", "rain", "vfx", "effect", "kri"], "UI & Icons": ["icon", "ui", "button", "ikona"], "Tools & Items": ["tool", "hoe", "axe", "pickaxe", "orodi", "item"], "Other": [] } def categorize_file(filepath): """Determine category based on file path and name.""" path_lower = str(filepath).lower() filename_lower = filepath.name.lower() for category, patterns in CATEGORIES.items(): if category == "Other": continue for pattern in patterns: if pattern in path_lower or pattern in filename_lower: return category return "Other" def scan_assets(base_dir="assets"): """Scan all PNG files and categorize them.""" categorized = defaultdict(list) base_path = Path(base_dir) for png_file in base_path.rglob("*.png"): # Skip backup folders if "BACKUP" in str(png_file): continue category = categorize_file(png_file) relative_path = png_file.relative_to(Path.cwd()) categorized[category].append({ "path": str(relative_path), "name": png_file.name, "size": png_file.stat().st_size if png_file.exists() else 0 }) # Sort each category by name for category in categorized: categorized[category].sort(key=lambda x: x["name"]) return dict(categorized) def generate_html(categorized_assets, output_file="asset_gallery.html"): """Generate self-contained HTML gallery.""" html = f""" Mrtva Dolina - Asset Gallery

šŸ’€ MRTVA DOLINA šŸ’€

Asset Gallery - Static Offline Version

Total Assets: {sum(len(assets) for assets in categorized_assets.values())} | Categories: {len([c for c in categorized_assets if categorized_assets[c]])}
""" for category, assets in sorted(categorized_assets.items()): if not assets: continue html += f"""
{category} ({len(assets)} assets)
""" for asset in assets: size_kb = asset['size'] / 1024 html += f"""
{asset['name']}
{asset['name']}
{size_kb:.1f} KB
""" html += """
""" html += """ """ with open(output_file, 'w', encoding='utf-8') as f: f.write(html) print(f"āœ… Gallery generated: {output_file}") print(f" Total assets: {sum(len(assets) for assets in categorized_assets.values())}") print(f" Categories: {len([c for c in categorized_assets if categorized_assets[c]])}") print(f"\nšŸŽÆ Just double-click the HTML file to open it!") if __name__ == "__main__": print("šŸŽØ Scanning assets...") categorized = scan_assets() print("šŸ“ Generating HTML gallery...") generate_html(categorized) print("\n✨ Done! Open 'asset_gallery.html' in your browser.")