updates
This commit is contained in:
41
src/menu/aquonSamples.js
Normal file
41
src/menu/aquonSamples.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
class AquonSamplesMenu {
|
||||
constructor(relPath = '../../datasets/assetData') {
|
||||
this.baseDir = path.resolve(__dirname, relPath);
|
||||
this.samplePath = path.resolve(this.baseDir, 'monsterSamples.json');
|
||||
this.specPath = path.resolve(this.baseDir, 'specs/monster/index.json');
|
||||
this.cache = new Map();
|
||||
}
|
||||
|
||||
_loadJSON(filePath, cacheKey) {
|
||||
if (this.cache.has(cacheKey)) {
|
||||
return this.cache.get(cacheKey);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
throw new Error(`Aquon dataset not found: ${filePath}`);
|
||||
}
|
||||
|
||||
const raw = fs.readFileSync(filePath, 'utf8');
|
||||
const parsed = JSON.parse(raw);
|
||||
this.cache.set(cacheKey, parsed);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
getAllMenuData() {
|
||||
const samples = this._loadJSON(this.samplePath, 'samples');
|
||||
const specs = this._loadJSON(this.specPath, 'specs');
|
||||
|
||||
return {
|
||||
samples: samples.samples || [],
|
||||
specs: {
|
||||
defaults: specs.defaults || {},
|
||||
bySample: specs.bySample || {}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AquonSamplesMenu;
|
||||
@@ -2,6 +2,7 @@ const AssetMenu = require('./asset.js');
|
||||
const { TagcodeApp, DynamicAssetMenu } = require('./tagcodeApp.js');
|
||||
const LoggerMenu = require('./logger.js');
|
||||
const PhysicalPositionMenu = require('./physicalPosition.js');
|
||||
const AquonSamplesMenu = require('./aquonSamples.js');
|
||||
const ConfigManager = require('../configs');
|
||||
|
||||
class MenuManager {
|
||||
@@ -16,6 +17,7 @@ class MenuManager {
|
||||
//this.registerMenu('asset', (nodeName) => new DynamicAssetMenu(nodeName, new TagcodeApp()));
|
||||
this.registerMenu('logger', () => new LoggerMenu());
|
||||
this.registerMenu('position', () => new PhysicalPositionMenu());
|
||||
this.registerMenu('aquon', () => new AquonSamplesMenu());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user