Пример #1
0
        bool OnStep2()
        {
            if (_curConfig.IsModifyProject)
            {
                ProjectProperty info = _curConfig.ProjectInfo;

                txtResolution.Text = "项目原始分辨率:";

                // 第二步的说明窗口,目前也只有这么一个属性可以显示
                txtResolution.Text += string.Format("{0}{0}【{3}】 {1}x{2}",
                                                    Environment.NewLine, info.width, info.height, _curConfig.ProjectName);

                // 显示项目所有文件
                ShowFiles(_curConfig.ProjectFolder);
            }
            else
            {
                ProjectProperty info = _curConfig.ThemeInfo;

                txtResolution.Text = "主题原始分辨率:";

                // 第二步的说明窗口,目前也只有这么一个属性可以显示
                string name = _curConfig.IsDefaultTheme ? WizardConfig.NAME_DEFAULT_THEME : _curConfig.ThemeName;
                txtResolution.Text += string.Format("{0}{0}【{3}】 {1}x{2}",
                                                    Environment.NewLine, info.width, info.height, name);

                // 是否选择了默认主题,没选则附加默认主题属性
                if (!_curConfig.IsDefaultTheme)
                {
                    ProjectProperty baseInfo = _curConfig.ReadBaseTemplateInfo();
                    txtResolution.Text += string.Format("{0}{0}【{3}】 {1}x{2}",
                                                        Environment.NewLine, baseInfo.width, baseInfo.height, WizardConfig.NAME_DEFAULT_THEME);

                    txtResolution.Text += string.Format("{0}{0}注意:【{2}】将覆盖【{1}】中的同名文件。",
                                                        Environment.NewLine, WizardConfig.NAME_DEFAULT_THEME, name);
                }

                // 这里本来应该根据缩放策略配置来显示每个文件如何缩放
                // 先简单列一下文件和目录吧……
                ShowFiles(_curConfig.ThemeFolder);
            }

            // 调用下测试用的函数
            test();

            return(true);
        }
Пример #2
0
        // 根据配置的内容生成报告
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            if (this.IsModifyProject)
            {
                sb.AppendFormat("【修改项目配置清单】"); sb.Append(Environment.NewLine);

                sb.Append(Environment.NewLine);
                ProjectProperty info = this.ProjectInfo;
                sb.AppendFormat("原始分辨率:{0}x{1}", info.width, info.height); sb.Append(Environment.NewLine);
                sb.AppendFormat("目标分辨率:{0}x{1}", this._width, this._height);
                if (info.width != _width || info.height != this._height)
                {
                    sb.AppendFormat(" (分辨率已修改)");
                }
                sb.Append(Environment.NewLine);
            }
            else
            {
                sb.AppendFormat("【创建项目配置清单】"); sb.Append(Environment.NewLine);

                sb.Append(Environment.NewLine);
                string theme = (this.IsDefaultTheme) ? NAME_DEFAULT_THEME : this.ThemeName;
                sb.AppendFormat("所选主题:{0}", theme); sb.Append(Environment.NewLine);
                sb.AppendFormat("分辨率设定:{0}x{1}", this._width, this._height);
                ProjectProperty info = this.ThemeInfo;
                if (info.width != _width || info.height != this._height)
                {
                    sb.AppendFormat(" (非原始分辨率)");
                }
                sb.Append(Environment.NewLine);
            }

            sb.Append(Environment.NewLine);
            sb.AppendFormat("项目名称:{0}", this._projectName); sb.Append(Environment.NewLine);
            sb.AppendFormat("项目位置:{0}", this.ProjectFolder); sb.Append(Environment.NewLine);

            sb.Append(Environment.NewLine);
            sb.AppendFormat("缩放策略:{0}", this._scaler); sb.Append(Environment.NewLine);
            sb.AppendFormat("缩放质量:{0}", this._quality); sb.Append(Environment.NewLine);
            sb.AppendFormat("NVLMaker目录:{0}", this.BaseFolder); sb.Append(Environment.NewLine);
            return(sb.ToString());
        }
Пример #3
0
        // 在界面上显示读取的属性内容
        private void ShowProperty(ProjectProperty info)
        {
            // 读取项目说明
            txtReadme.Text      = info.readme;
            txtProjectName.Text = info.title;

            // 选定分辨率
            int w = info.width, h = info.height;

            for (int i = 0; i < cbResolution.Items.Count; i++)
            {
                Resolution r = cbResolution.Items[i] as Resolution;
                if (r != null && r._w == w && r._h == h)
                {
                    cbResolution.SelectedIndex = i;
                    break;
                }
            }
        }
Пример #4
0
        // 读取基础模板的配置
        public ProjectProperty ReadBaseTemplateInfo()
        {
            // 如果选的是默认的主题,则返回主题属性
            if (this.IsDefaultTheme)
            {
                return(this.ThemeInfo);
            }

            // 这里就不读readme了,也不做保存,每次调用都从文件读一次
            string          file = Path.Combine(this.BaseTemplateFolder + DATA_FOLDER, UI_SETTING);
            ProjectProperty info = new ProjectProperty();

            try
            {
                info.LoadSetting(file);
            }
            catch (System.Exception e)
            {
                info.readme = e.Message;
            }
            return(info);
        }
Пример #5
0
        // 根据配置创建目标项目
        public void Start()
        {
            if (_config.IsModifyProject)
            {
                // 从配置中读取目标大小
                int dw = _config._width, dh = _config._height;

                // 从项目自身的文件夹转换
                string project = _config.ProjectFolder;

                // 读取项目原始配置
                ProjectProperty projInfo = _config.ProjectInfo;
                int             sw = projInfo.width, sh = projInfo.height;

                ConvertFiles(project, sw, sh, project, dw, dh);

                // 修正所有坐标
                AdjustSettings(sw, sh);
            }
            else
            {
                // 从配置中读取目标大小
                int dw = _config._width, dh = _config._height;

                // 先从基础模板目录拷贝文件到项目目录
                string template = _config.BaseTemplateFolder;
                string project  = _config.ProjectFolder;

                // 读取基础模板的配置
                ProjectProperty baseInfo = _config.ReadBaseTemplateInfo();

                int sw = baseInfo.width;
                if (sw <= 0)
                {
                    sw = WizardConfig.DEFAULT_WIDTH;
                }
                int sh = baseInfo.height;
                if (sh <= 0)
                {
                    sh = WizardConfig.DEFAULT_HEIGHT;
                }

                ConvertFiles(template, sw, sh, project, dw, dh);

                // 修正所有坐标,写入项目名称
                AdjustSettings(sw, sh);

                // 如果选择了非默认主题,再从主题目录拷贝文件到项目资料文件夹
                if (_config.ThemeFolder != template)
                {
                    // 读取所选主题配置
                    ProjectProperty themeInfo = _config.ThemeInfo;

                    sw = themeInfo.width;
                    if (sw <= 0)
                    {
                        sw = WizardConfig.DEFAULT_WIDTH;
                    }
                    sh = themeInfo.height;
                    if (sh <= 0)
                    {
                        sh = WizardConfig.DEFAULT_HEIGHT;
                    }

                    // 主题的文件直接拷入数据目录
                    ConvertFiles(_config.ThemeFolder, sw, sh, _config.ProjectDataFolder, dw, dh);

                    // 修正所有坐标,写入项目名称
                    AdjustSettings(sw, sh);
                }
            }
        }
Пример #6
0
        // 检查这个配置是否已经完备,把出错信息写入output
        public bool IsReady(TextWriter output)
        {
            try
            {
                string path = this.BaseFolder;
                if (string.IsNullOrEmpty(_baseFolder) || !Directory.Exists(path))
                {
                    if (output != null)
                    {
                        output.WriteLine("错误:软件根目录不存在。");
                    }
                    return(false);
                }

                if (_height <= 0 || _width <= 0)
                {
                    if (output != null)
                    {
                        output.WriteLine("错误:无效的分辨率设置。");
                    }
                    return(false);
                }

                path = this.ProjectFolder;
                if (string.IsNullOrEmpty(_projectName))
                {
                    if (output != null)
                    {
                        output.WriteLine("错误:无效的项目名称。");
                    }
                    return(false);
                }
                else if (!this.IsModifyProject && Directory.Exists(path))
                {
                    if (output != null)
                    {
                        output.WriteLine("错误:项目文件夹已存在,请更换项目名或设置其他路径。");
                    }
                    return(false);
                }

                if (this.IsModifyProject)
                {
                    ProjectProperty info = ProjectInfo;
                    if (info == null || (info.width == this._width && info.height == this._height))
                    {
                        if (output != null)
                        {
                            output.WriteLine("错误:项目分辨率未改动,不需要进行转换");
                        }
                        return(false);
                    }
                }
                else
                {
                    path = this.ThemeFolder;
                    if (!string.IsNullOrEmpty(path))
                    {
                        if (!Directory.Exists(path))
                        {
                            if (output != null)
                            {
                                output.WriteLine("错误:主题目录不存在。");
                            }
                            return(false);
                        }

                        path = this.ThemeSetting;
                        if (string.IsNullOrEmpty(path) || !File.Exists(path))
                        {
                            if (output != null)
                            {
                                output.WriteLine("警告:主题缺少配置文件");
                            }
                        }
                    }

                    ProjectProperty info = ThemeInfo;
                    if (info == null || info.height <= 0 || info.width <= 0)
                    {
                        if (output != null)
                        {
                            output.WriteLine("警告:主题分辨率错误。");
                        }
                    }

                    ProjectProperty baseInfo = ReadBaseTemplateInfo();
                    if (baseInfo != info && (baseInfo == null || baseInfo.height <= 0 || baseInfo.width <= 0))
                    {
                        if (output != null)
                        {
                            output.WriteLine("警告:默认主题分辨率错误。");
                        }
                    }
                }

                // 生成配置报告
                if (output != null)
                {
                    output.WriteLine(this.ToString());
                }
            }
            catch (System.Exception e)
            {
                if (output != null)
                {
                    output.WriteLine("无效的项目配置:" + e.Message);
                }
                return(false);
            }

            return(true);
        }