feat: complete Style 32 overhaul & Tiled integration fix
- Enforced 'Style 32 - Dark Chibi Vector' for all ground assets. - Fixed critical Prologue-to-Game crash (function renaming). - Implemented Tiled JSON/TMX auto-conversion. - Updated Asset Manager to visualize 1800+ assets. - Cleaned up project structure (new assets/grounds folder). - Auto-Ground logic added to GameScene.js.
This commit is contained in:
85
tools/generate_manifest.js
Normal file
85
tools/generate_manifest.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const ASSETS_DIR = path.join(__dirname, '../assets');
|
||||
const OUTPUT_FILE = path.join(__dirname, '../src/AssetManifest.js');
|
||||
|
||||
const CATEGORY_MAP = {
|
||||
'buildings': 'farm',
|
||||
'crops': 'farm',
|
||||
'grounds': 'farm',
|
||||
'props': 'farm',
|
||||
'terrain': 'farm',
|
||||
'characters': 'common',
|
||||
'ui': 'common',
|
||||
'vfx': 'common',
|
||||
'images': 'common',
|
||||
'intro_assets': 'common',
|
||||
'sprites': 'common', // Treat as regular images for now unless frame config known
|
||||
'slike 🟢': 'common'
|
||||
};
|
||||
|
||||
const manifest = {
|
||||
phases: {
|
||||
farm: [],
|
||||
basement_mine: [],
|
||||
common: []
|
||||
},
|
||||
spritesheets: []
|
||||
};
|
||||
|
||||
function scanDir(dir, category) {
|
||||
if (!fs.existsSync(dir)) return;
|
||||
|
||||
const files = fs.readdirSync(dir);
|
||||
|
||||
files.forEach(file => {
|
||||
const fullPath = path.join(dir, file);
|
||||
const stat = fs.statSync(fullPath);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
// Recursive scan
|
||||
// Special handling: if dir is 'sprites', maybe subdirs are categories?
|
||||
// For now, simple recursion
|
||||
scanDir(fullPath, category);
|
||||
} else if (file.match(/\.(png|jpg|jpeg)$/i)) {
|
||||
const relativePath = 'assets/' + path.relative(ASSETS_DIR, fullPath);
|
||||
const key = path.parse(file).name; // Use filename without ext as key
|
||||
|
||||
// Avoid duplicates?
|
||||
// Just push for now
|
||||
|
||||
if (category === 'spritesheets') {
|
||||
// Try to guess definition or generic
|
||||
manifest.spritesheets.push({
|
||||
key: key,
|
||||
path: relativePath,
|
||||
frameConfig: { frameWidth: 32, frameHeight: 32 } // Default guess
|
||||
});
|
||||
} else {
|
||||
if (!manifest.phases[category]) manifest.phases[category] = [];
|
||||
manifest.phases[category].push({
|
||||
key: key,
|
||||
path: relativePath
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// MAIN SCAN LOOP
|
||||
Object.keys(CATEGORY_MAP).forEach(dirName => {
|
||||
const fullDir = path.join(ASSETS_DIR, dirName);
|
||||
const cat = CATEGORY_MAP[dirName];
|
||||
scanDir(fullDir, cat);
|
||||
});
|
||||
|
||||
// Generate File Content
|
||||
const fileContent = `window.AssetManifest = ${JSON.stringify(manifest, null, 4)};`;
|
||||
|
||||
fs.writeFileSync(OUTPUT_FILE, fileContent);
|
||||
|
||||
console.log('✅ AssetManifest.js regenerated!');
|
||||
console.log(`Farm: ${manifest.phases.farm.length}`);
|
||||
console.log(`Common: ${manifest.phases.common.length}`);
|
||||
console.log(`Mine: ${manifest.phases.basement_mine.length}`);
|
||||
Reference in New Issue
Block a user