import * as fs from 'fs' ; import * as path from 'path' ; import { URL } from 'url' ; import { ServerProxy } from './Proxy' ; import { Builder } from './Builder' ; import URI from 'vscode-uri' ; /**
 * 插件配置，定义于package.json文件中
 */ interface Settings { root : string ; } interface MySettings { quickxdev : Settings ; } class Config0 { private _settings : Settings ; private _root : string ; private _workspaceRoot : string ; private _quickRoot : string ; private _isQuickX : boolean = false ; private _initSettinged : boolean = false ; constructor ( ) { } /**
     * 初始化
     */ public initWorkspace ( workspaceRoot ) { this . _workspaceRoot = workspaceRoot ; this . _isQuickX = true ; let root = path . join ( __dirname , "../../../" ) ; root = path . resolve ( root ) ; this . _root = URI . file ( root ) . toString ( ) ; } /**
     * 初始化配置
     */ public changeSettings ( settings ) { let s = < MySettings > settings ; this . _settings = s . quickxdev ; if ( ! this . _settings . root ) { this . _settings . root = process . env . QUICK_V3_ROOT ; } this . _quickRoot = null ; if ( this . _settings . root ) { this . _quickRoot = URI . file ( this . _settings . root ) . toString ( ) ; } console . log ( "QuickX root:" , this . _quickRoot ) ; ServerProxy . sendRequest ( "quickRoot" , this . quickRoot ) ; if ( this . _isQuickX && ! this . quickRoot ) { ServerProxy . showMessageWarning ( "还没有设置Quick引擎目录!" ) ; } if ( ! this . _initSettinged ) { Builder . initWorkspace ( ) ; this . _initSettinged = true ; } } /**
     * 配置选项
     */ public get settings ( ) : Settings { return this . _settings ; } /**
     * Quick-Cocos2dx 根目录
     */ public get quickRoot ( ) : string { return this . _quickRoot ; } /**
     * 项目目录
     */ public get workspaceRoot ( ) : string { return this . _workspaceRoot ; } /**
     * 插件目录
     */ public get root ( ) : string { return this . _root ; } /**
     * 是否是quick-cocos2dx项目
     */ public get isQuickX ( ) : boolean { return this . _isQuickX ; } } /**
 * 配置文件管理
 */ export const Config = new Config0 ( ) ;