#!/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"""
Asset Gallery - Static Offline Version