Files
MatchMaster_level/scripts/windows/StartEditor.mjs
T

20 lines
1.1 KiB
JavaScript

import {fileURLToPath,pathToFileURL} from 'node:url';
import path from 'node:path';
import {startEditor} from './colorBlock-level-editor/src/server.js';
const root=path.dirname(fileURLToPath(import.meta.url));
export async function startPortableEditor({port=4488,open=true}={}) {
const draftsDir=path.join(root,'colorBlock-level-editor','drafts');
return startEditor({port,open,draftsDir,sources:{
matchmaster:{name:'MatchMaster · 随包关卡快照',dir:path.join(root,'game-data','assets','custom','Json')},
archive:{name:'参考关卡库 · 只读',dir:path.join(root,'levels')},
drafts:{name:'我的编辑草稿',dir:draftsDir}
}});
}
if(process.argv[1]&&pathToFileURL(path.resolve(process.argv[1])).href===import.meta.url){
startPortableEditor().then(app=>{
console.log('ColorBlock Editor 0.19.0 - Windows portable');
console.log('Open this address if the browser did not open: '+app.url);
console.log('Keep this window open while editing. Close it to stop the editor.');
}).catch(error=>{console.error(error.message);process.exitCode=1;});
}