const os = require('os'); import Path from './Path'; import FairyManager from './reader/FairyManager'; export enum ExportVer { ts_layabox2 = "ts_layabox2", ts_layabox2merge = "ts_layabox2merge", ts_layabox2mergejs = "ts_layabox2mergejs", } export default class Options { /** 设置导出代码类型和版本 */ codeExportVer = ExportVer.ts_layabox2merge; // 代码--组件类名前缀 codeClassNamePrefix: string = "UI_"; // 代码--成员变量名前缀 codeMemberNamePrefix: string = "m_"; // 代码--忽略自动生成的成员变量名 codeIgnoreNoname: boolean = true; // 代码--忽略非法组件名称 codeIgnorIllegalClassName: boolean = true; // 代码--忽略没设置导出的组件 codeIgnorNoExported: boolean = true; // 代码--忽略~NCode结尾的目录下的组件 codeIgnorNCode: boolean = true; // 代码--忽略~NCode结尾的目录下的组件 codeIgnorNCodeFlag: string = "~NCode"; // 代码--导出依赖的组件 codeExportDepend: boolean = false; // 代码--命名空间 codeNamespace: string = "fgui"; // 代码--是否使用其他包的组件类型 codeUseOtherPkgType: boolean = false; // 声音--包名 soundPackageName: string = "Sound"; // Fairygui项目路径 fairyProjectPath: string = "../../fgui/"; // fgui资源路径 resPath: string = "../../client/bin/res/fgui"; // 生成代码到制定路径 genCodePath: string = "../../_gen/fguicode"; // 导出代码到制定路径 outCodePath: string = "../../client/src/FGUI"; // 模板目录 templatePath: string = "./template"; /** 包的图集分隔符 */ fguires_atlasSeparator = "_atlas"; /** 忽略文件后缀 */ fguires_ignoreExts = [".meta", ".json"]; /** 声音文件后缀 */ fguires_soundExts = [".ogg", ".mp3", ".wav"]; // fgui 资源文件 后缀 fguires_fguiFileExtension: string = ".bin"; // fgui 资源依赖关系配置 get fguiExportJsonPath(): string { return this.resPath + "fgui.json"; } get genCodeMainPath(): string { return this.genCodePath + "/" + FairyManager.current.projectDescription.id + "/"; } constructor() { let dir = __dirname.replace(/\\/g, "/"); dir = dir.substring(0, dir.lastIndexOf('/bundle')); this.templatePath = `${dir}/template/`; this.genCodePath = os.homedir() + "/.fguicode/"; Path.CheckPath(this.genCodePath, false) } Check(): boolean { var result = true; if (!this.fairyProjectPath) { console.error("[Error]: -f, --fgui-project-path , [必填] Fairygui工程根目录"); result = false; } if(!this.fairyProjectPath.endsWith('/')) { this.fairyProjectPath += '/'; } // if(!this.resPath.endsWith('/')) // { // this.resPath += '/'; // } // if(!this.genCodePath.endsWith('/')) // { // this.genCodePath += '/'; // } if(!this.outCodePath.endsWith('/')) { this.outCodePath += '/'; } return result; } }