Exemplo n.º 1
0
        private void btnSelectGameDir_Click(Object sender, EventArgs e)
        {
            string path = "";

            var browser = new FolderBrowserDialog();
            var result  = browser.ShowDialog();

            if (result == DialogResult.OK)
            {
                path = browser.SelectedPath;
                if (!File.Exists(path + "/bin/Client.exe"))
                {
                    BstManager.DisplayErrorMessageBox(
                        this._i18N.LoadI18NValue("GuiUtil", "boxTitle"),
                        this._i18N.LoadI18NValue("GuiUtil", "boxMessage")
                        );
                }
                else
                {
                    this.textBoxGameDir.Text = path;
                    BstManager.Instance.SystemSettings["path"]["game"] = path;
                    BstManager.WriteJsonFile(BstManager.PathJsonSettings, BstManager.Instance.SystemSettings);
                }
            }
        }
Exemplo n.º 2
0
        private void CheckNewVersion()
        {
            var currentVer = (string)BstManager.Instance.SystemSettings["version"];

            new Thread(() =>
            {
                var releasedVer = BstManager.GetStringFromWeb(BstManager.GithubVersionTxt);
                // releasedVer是从网络下载的,在网络无法访问或下载失败的情况下,可能为null,需要做验证
                if (!String.IsNullOrEmpty(releasedVer) && currentVer != releasedVer)
                {
                    var result = BstManager.DisplayConfirmMessageBox(
                        this._i18N.LoadI18NValue("App", "newVerTitle"),
                        string.Format(
                            this._i18N.LoadI18NValue("App", "newVerContent"),
                            currentVer,
                            releasedVer,
                            BstI18NLoader.Instance.LoadI18NValue("App", "releaseSiteUrl"))
                        );
                    if (result == DialogResult.OK)
                    {
                        Process.Start(BstI18NLoader.Instance.LoadI18NValue("App", "releaseSiteUrl"));
                    }
                }
            }).Start();
        }
Exemplo n.º 3
0
        private void LoadOriginAndTargetIconPic(PictureBox picture, JObject elementData, bool async = false)
        {
            var cachePath = BstManager.GetIconPicTmpPath(elementData);

            if (async)
            {
                MethodInvoker picUpdate = delegate
                {
                    if (File.Exists(cachePath))
                    {
                        picture.ImageLocation = cachePath;
                    }
                    else
                    {
                        picture.ImageLocation = BstManager.GetIconPicUrl(elementData);
                    }
                    picture.Load();
                };
                picture.BeginInvoke(picUpdate);
            }
            else
            {
                if (File.Exists(cachePath))
                {
                    picture.ImageLocation = cachePath;
                }
                else
                {
                    picture.ImageLocation = BstManager.GetIconPicUrl(elementData);
                }
                picture.Load();
            }
        }
Exemplo n.º 4
0
 private void btnTopRestoreAll_Click(Object sender, EventArgs e)
 {
     // 恢复全部模型
     if (BstManager.DisplayConfirmMessageBox(
             this._i18N.LoadI18NValue("GuiItems", "actionConfirmTitle"),
             this._i18N.LoadI18NValue("GuiItems", "actionRestoreMsg")) == DialogResult.OK)
     {
         BstManager.Instance.RunGrunt(this.textBoxOut, "restore");
     }
 }
Exemplo n.º 5
0
 private void btnReplace_Click(Object sender, EventArgs e)
 {
     // 替换模型
     if (this._originElementId == null)
     {
         BstManager.DisplayErrorMessageBox(
             this._i18N.LoadI18NValue("GuiItems", "actionReplaceErrorTitle"),
             this._i18N.LoadI18NValue("GuiItems", "actionOriginEmptyErrorMsg")
             );
         return;
     }
     if (this._targetElementId == null)
     {
         BstManager.DisplayErrorMessageBox(
             this._i18N.LoadI18NValue("GuiItems", "actionReplaceErrorTitle"),
             this._i18N.LoadI18NValue("GuiItems", "actionTargetEmptyErrorMsg")
             );
         return;
     }
     if (this._originElementId == this._targetElementId)
     {
         BstManager.DisplayErrorMessageBox(
             this._i18N.LoadI18NValue("GuiItems", "actionReplaceErrorTitle"),
             this._i18N.LoadI18NValue("GuiItems", "actionTargetSameErrorMsg")
             );
         return;
     }
     if (this._formType == BstManager.TypeWeapon) // 只有武器不可替换
     {
         // FIXME 后续制作功能,并开发这个限制
         BstManager.DisplayErrorMessageBox(
             this._i18N.LoadI18NValue("GuiItems", "actionFuncNotDoneTitle"),
             this._i18N.LoadI18NValue("GuiItems", "actionWaitForFuncMsg")
             );
         return;
     }
     if (BstManager.DisplayConfirmMessageBox(
             this._i18N.LoadI18NValue("GuiItems", "actionConfirmTitle"),
             this._i18N.LoadI18NValue("GuiItems", "actionReplaceMsg")) == DialogResult.OK)
     {
         string race = null;
         if (this._formType == BstManager.TypeAttach ||
             this._formType == BstManager.TypeCostume)
         {
             race = BstManager.Instance.RaceTypes[this.comboBoxRace.SelectedIndex];
         }
         BstManager.Instance.RunGrunt(this.textBoxOut, "replace", new string[]
         {
             "--part=" + BstManager.GetTypeName(this._formType),
             "--model=" + this._targetElementId,
             "--race=" + race
         });
     }
 }
Exemplo n.º 6
0
 private void btnView2DTarget_Click(Object sender, EventArgs e)
 {
     // 预览目标模型2D截图
     if (this._targetElementId == null)
     {
         BstManager.DisplayErrorMessageBox(
             this._i18N.LoadI18NValue("GuiItems", "actionSelectErrorTitle"),
             this._i18N.LoadI18NValue("GuiItems", "actionSelectTargetErrorMsg")
             );
         return;
     }
     this.CreatePictureForm(this._targetElementId);
 }
Exemplo n.º 7
0
        private void comboBoxSelectLang_SelectedIndexChanged(Object sender, EventArgs e)
        {
            // 重新记录语言信息,并写入配置文件
            var lang = BstManager.Instance.LanguageTypes[this.comboBoxSelectLang.SelectedIndex];

            BstManager.Instance.SystemSettings["lang"] = lang;
            BstManager.WriteJsonFile(BstManager.PathJsonSettings, BstManager.Instance.SystemSettings);

            // 显示重启程序提示信息
            // 这一段因为关系到语言的设定,使用双语显示,不作为配置设定
            BstManager.DisplayInfoMessageBox(
                "重启以生效改动 / Restart to activate the setting change",
                "你需要手动重启应用程序,来应用当前改动的语言配置!\r\n" +
                "You have to restart the application manually, to activate the language setting change!"
                );
        }
Exemplo n.º 8
0
 private void btnStopDownload_Click(Object sender, EventArgs e)
 {
     if (this._loadingThread != null && this._loadingThread.IsAlive)
     {
         try
         {
             this._loadingThread.Abort();
         }
         catch (Exception ex)
         {
             BstLogger.Instance.Log(ex.ToString());
         }
         this._loadingThread = null;
         BstManager.ShowMsgInTextBox(this.textBoxOut, this._i18N.LoadI18NValue("GuiUtil", "downloadStopped"));
     }
     this.UpdateDownloadProgressBar(0); // 更新进度条为0
 }
Exemplo n.º 9
0
 private void CheckBnsGamePath()
 {
     new Thread(() =>
     {
         var gamePath = (string)BstManager.Instance.SystemSettings["path"]["game"];
         if (!Directory.Exists(gamePath) || !File.Exists(gamePath + "/bin/Client.exe"))
         {
             // 游戏地址配置不存在或不正确,更新为null
             BstManager.Instance.SystemSettings["path"]["game"] = null;
             BstManager.WriteJsonFile(BstManager.PathJsonSettings, BstManager.Instance.SystemSettings);
             BstManager.DisplayErrorMessageBox(
                 BstI18NLoader.Instance.LoadI18NValue("App", "gamePathErrTitle"),
                 BstI18NLoader.Instance.LoadI18NValue("App", "gamePathErrContent")
                 );
         }
     }).Start();
 }
Exemplo n.º 10
0
 private void btnView3DInfo_Click(Object sender, EventArgs e)
 {
     // 预览选中的对象的3D模型
     if (this._selectedElementId == null)
     {
         BstManager.DisplayErrorMessageBox(
             this._i18N.LoadI18NValue("GuiItems", "actionSelectErrorTitle"),
             this._i18N.LoadI18NValue("GuiItems", "actionSelectTargetErrorMsg")
             );
         return;
     }
     BstManager.Instance.RunGrunt(this.textBoxOut, "upk_viewer", new string[]
     {
         "--part=" + BstManager.GetTypeName(this._formType),
         "--model=" + this._selectedElementId
     });
 }
Exemplo n.º 11
0
        private void btnSelectTarget_Click(Object sender, EventArgs e)
        {
            // 将当前选中的物件设为目标模型
            if (this._selectedElementId == null)
            {
                BstManager.DisplayErrorMessageBox(
                    this._i18N.LoadI18NValue("GuiItems", "actionSelectErrorTitle"),
                    this._i18N.LoadI18NValue("GuiItems", "actionSelectTargetErrorMsg")
                    );
                return; // 没有选中的元素,直接退出
            }
            this._targetElementId = this._selectedElementId;
            var element = (JObject)this._data[this._selectedElementId];

            // 展示icon,该icon应该已经有本地缓存,直接读取本地缓存
            this.LoadOriginAndTargetIconPic(this.pictureBoxTarget, element);
            // 显示模型数据
            this.textBoxTarget.Text = element.ToString();
        }
Exemplo n.º 12
0
        private void btnSelectOrigin_Click(Object sender, EventArgs e)
        {
            // 将当前选中的物件设为原始模型
            if (this._selectedElementId == null)
            {
                BstManager.DisplayErrorMessageBox(
                    this._i18N.LoadI18NValue("GuiItems", "actionSelectErrorTitle"),
                    this._i18N.LoadI18NValue("GuiItems", "actionSelectTargetErrorMsg")
                    );
                return; // 没有选中的元素,直接退出
            }
            var element = (JObject)this._data[this._selectedElementId];

            this._originElementId = this._selectedElementId;
            // 展示icon,该icon应该已经有本地缓存,直接读取本地缓存
            this.LoadOriginAndTargetIconPic(this.pictureBoxOrigin, element);
            // 显示模型数据
            this.textBoxOrigin.Text = element.ToString();
            // 存储原始模型数据
            var originData = new JObject();

            originData["id"]   = this._originElementId;
            originData["data"] = element;
            if (this._formType == BstManager.TypeAttach ||
                this._formType == BstManager.TypeCostume)
            {
                var originRace = (string)element["race"];
                if (Regex.IsMatch(originRace, BstManager.Instance.RaceTypes[BstManager.RaceIdLyn], RegexOptions.IgnoreCase))
                {
                    originRace = BstManager.Instance.RaceTypes[BstManager.RaceIdLyn];
                }
                this._originSettings[originRace] = originData;
            }
            else
            {
                this._originSettings = originData;
            }
            BstManager.WriteJsonFile(BstManager.GetItemOriginJsonPath(this._formType), this._originSettings);
        }
Exemplo n.º 13
0
        private void DownloadAllImageResources()
        {
            var finishedCount = 0;
            var types         = BstManager.Instance.Types;

            foreach (var type in types)
            {
                JObject data = null;
                switch (Array.IndexOf(types, type))
                {
                case BstManager.TypeAttach:
                    data = BstManager.Instance.DataAttach;
                    break;

                case BstManager.TypeCostume:
                    data = BstManager.Instance.DataCostume;
                    break;

                case BstManager.TypeWeapon:
                    data = BstManager.Instance.DataWeapon;
                    break;
                }

                foreach (var element in data.Properties())
                {
                    var elementData    = (JObject)element.Value;
                    var iconUrl        = BstManager.GetIconPicUrl(elementData);
                    var iconTmpPath    = BstManager.GetIconPicTmpPath(elementData);
                    var itemPicUrl     = BstManager.GetItemPicUrl(Array.IndexOf(types, type), elementData);
                    var itemPicTmpPath = BstManager.GetItemPicTmpPath(Array.IndexOf(types, type), elementData);

                    if (File.Exists(iconTmpPath))
                    {
                        // 无需下载
                        BstManager.ShowMsgInTextBox(this.textBoxOut, string.Format(this._i18N.LoadI18NValue("BstIconLoader", "iconDownloadSucceed"), iconUrl));
                    }
                    else
                    {
                        var icon = BstManager.DownloadImageFile(iconUrl, iconTmpPath);
                        if (icon == null)
                        {
                            // 下载失败
                            BstManager.ShowMsgInTextBox(this.textBoxOut, string.Format(this._i18N.LoadI18NValue("BstIconLoader", "iconDownloadFailed"), iconUrl));
                        }
                        else
                        {
                            // 下载成功
                            BstManager.ShowMsgInTextBox(this.textBoxOut, string.Format(this._i18N.LoadI18NValue("BstIconLoader", "iconDownloadSucceed"), iconUrl));
                        }
                    }

                    if (File.Exists(itemPicTmpPath))
                    {
                        // 无需下载
                        BstManager.ShowMsgInTextBox(this.textBoxOut, string.Format(this._i18N.LoadI18NValue("BstPicLoader", "picDownloadSucceed"), itemPicUrl));
                    }
                    else
                    {
                        var pic = BstManager.DownloadImageFile(itemPicUrl, itemPicTmpPath);
                        if (pic == null)
                        {
                            // 下载失败
                            BstManager.ShowMsgInTextBox(this.textBoxOut, string.Format(this._i18N.LoadI18NValue("BstPicLoader", "picDownloadFailed"), itemPicUrl));
                        }
                        else
                        {
                            // 下载成功
                            BstManager.ShowMsgInTextBox(this.textBoxOut, string.Format(this._i18N.LoadI18NValue("BstPicLoader", "picDownloadSucceed"), itemPicUrl));
                        }
                    }

                    finishedCount += 2;
                    if (finishedCount >= this.progBarDownloadAll.Maximum)
                    {
                        this.UpdateDownloadProgressBar(0);
                        BstManager.ShowMsgInTextBox(this.textBoxOut, this._i18N.LoadI18NValue("GuiUtil", "downloadAllDone"));
                    }
                    else
                    {
                        this.UpdateDownloadProgressBar(finishedCount);
                    }
                }
            }
        }
Exemplo n.º 14
0
        private void Init(int formType)
        {
            this._formType       = formType;
            this._originSettings = BstManager.ReadJsonFile(BstManager.GetItemOriginJsonPath(this._formType));
            // 数据列表
            this._dataTable = new DataTable();
            // icon列
            var columnIcon = new DataColumn("Icon")
            {
                DataType    = Type.GetType("System.Byte[]"),
                AllowDBNull = true,
                ColumnName  = this._i18N.LoadI18NValue("GuiItems", "tableColIcon")
            };

            //columnIcon.ReadOnly = true;
            this._dataTable.Columns.Add(columnIcon);
            // code列
            var columnCode = new DataColumn("Code")
            {
                ColumnName = this._i18N.LoadI18NValue("GuiItems", "tableColCode"),
                ReadOnly   = true
            };

            this._dataTable.Columns.Add(columnCode);

            // 数据展示列表
            this.gridItems.DataSource         = this._dataTable;
            this.gridItems.RowTemplate.Height = 64;
            // icon列
            var gridColumnIcon = this.gridItems.Columns[0];

            gridColumnIcon.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            gridColumnIcon.Width        = 64;
            // 展示列表点击事件
            this.gridItems.CellClick += new DataGridViewCellEventHandler(this.gridItems_CellClick);
            // 展示列表鼠标滚轴事件
            this.gridItems.MouseWheel += new MouseEventHandler(this.gridItems_MouseWheel);

            // 种族选择控件
            // ReSharper disable once CoVariantArrayConversion
            this.comboBoxRace.Items.AddRange(BstManager.Instance.RaceNames.ToArray());
            this.comboBoxRace.SelectedIndex         = 0;
            this.comboBoxRace.SelectedIndexChanged += new EventHandler(this.comboBoxRace_SelectedIndexChanged);

            // 查找模型控件
            this.btnFilter.Click += new EventHandler(this.btnFilter_Click);

            // 全部恢复按钮
            this.btnTopRestoreAll.Click += new EventHandler(this.btnTopRestoreAll_Click);
            // 预览原始模型2D截图
            this.btnView2DOrigin.Click += new EventHandler(this.btnView2DOrigin_Click);
            // 预览原始模型3D模型
            this.btnView3DOrigin.Click += new EventHandler(this.btnView3DOrigin_Click);
            // 预览目标模型2D截图
            this.btnView2DTarget.Click += new EventHandler(this.btnView2DTarget_Click);
            // 预览目标模型3D模型
            this.btnView3DTarget.Click += new EventHandler(this.btnView3DTarget_Click);
            // 替换按钮
            this.btnReplace.Click += new EventHandler(this.btnReplace_Click);

            // 展示选中物件的3D模型按钮
            this.btnView3DInfo.Click += new EventHandler(this.btnView3DInfo_Click);
            // 选为原始模型按钮
            this.btnSelectOrigin.Click += new EventHandler(this.btnSelectOrigin_Click);
            // 选为目标模型按钮
            this.btnSelectTarget.Click += new EventHandler(this.btnSelectTarget_Click);
            // 报告bug按钮
            this.btnReportIssue.Click += new EventHandler(this.btnReportIssue_Click);
        }
Exemplo n.º 15
0
        private void btnReportIssue_Click(Object sender, EventArgs e)
        {
            // 获得数据
            var originInfo  = this.textBoxOrigin.Text;
            var targetInfo  = this.textBoxTarget.Text;
            var consoleInfo = this.textBoxOut.Text;

            // 检查数据
            if (string.IsNullOrEmpty(originInfo))
            {
                BstManager.DisplayErrorMessageBox(
                    this._i18N.LoadI18NValue("GuiItems", "actionReportErrorTitle"),
                    this._i18N.LoadI18NValue("GuiItems", "actionSelectOriginErrorMsg")
                    );
                return;
            }
            if (string.IsNullOrEmpty(targetInfo))
            {
                BstManager.DisplayErrorMessageBox(
                    this._i18N.LoadI18NValue("GuiItems", "actionReportErrorTitle"),
                    this._i18N.LoadI18NValue("GuiItems", "actionSelectTargetErrorMsg")
                    );
                return;
            }
            var hasGruntRunSign = false;

            for (var lineNo = 0; lineNo < this.textBoxOut.Lines.Length; lineNo++)
            {
                var lineText = this.textBoxOut.Lines[lineNo];
                if (lineText.Contains(BstManager.GruntRunSign))
                {
                    hasGruntRunSign = true;
                    break;
                }
            }
            if (!hasGruntRunSign)
            {
                BstManager.DisplayErrorMessageBox(
                    this._i18N.LoadI18NValue("GuiItems", "actionReportErrorTitle"),
                    this._i18N.LoadI18NValue("GuiItems", "actionReportErrorMsg")
                    );
                return;
            }

            // 发送报告
            using (var wb = new WebClient())
            {
                var data = new NameValueCollection();
                data["origin"]  = originInfo;
                data["target"]  = targetInfo;
                data["console"] = consoleInfo;

                var response    = wb.UploadValues(BstManager.BstReportServerUrl, "POST", data);
                var responseStr = System.Text.Encoding.ASCII.GetString(response, 0, response.Length);

                if (Regex.IsMatch(responseStr, BstManager.BstReportAlreadyExists))
                {
                    responseStr = responseStr.Substring(3); // remove prefix "-3|"
                    BstManager.DisplayInfoMessageBox(
                        this._i18N.LoadI18NValue("GuiItems", "reportErrorTitle"),
                        string.Format(this._i18N.LoadI18NValue("GuiItems", "reportAlreadyExists"), responseStr)
                        );
                }
                else
                {
                    switch (responseStr)
                    {
                    case BstManager.BstReportMissingInfo:
                        BstManager.DisplayErrorMessageBox(
                            this._i18N.LoadI18NValue("GuiItems", "reportErrorTitle"),
                            this._i18N.LoadI18NValue("GuiItems", "reportMissingInfo")
                            );
                        break;

                    case BstManager.BstReportInvalidJson:
                        BstManager.DisplayErrorMessageBox(
                            this._i18N.LoadI18NValue("GuiItems", "reportErrorTitle"),
                            this._i18N.LoadI18NValue("GuiItems", "reportInvalidJson")
                            );
                        break;

                    default:
                        BstManager.DisplayInfoMessageBox(
                            this._i18N.LoadI18NValue("GuiItems", "reportSucceedTitle"),
                            string.Format(this._i18N.LoadI18NValue("GuiItems", "reportSucceedMsg"), responseStr)
                            );
                        break;
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void LoadItemList(int raceType = BstManager.RaceIdKunn)
        {
            if (this._loadingThread != null && this._loadingThread.IsAlive)
            {
                // 之前启动的加载线程还活着,需要先停止
                try
                {
                    this._loadingThread.Abort();
                }
                catch (Exception ex)
                {
                    BstLogger.Instance.Log(ex.ToString());
                }
                this._loadingThread = null;
            }

            this.ClearFormStatus(); // 清理旧的数据

            // 启动新的线程来处理数据加载内容
            this._loadingThread = new Thread(() =>
            {
                BstManager.ShowMsgInTextBox(this.textBoxOut, this._i18N.LoadI18NValue("GuiItems", "logStartToLoadDataList"));

                BstManager.HideDataGridViewVerticalScrollBar(this.gridItems); // 隐藏滚动条

                // 更新原始模型区块数据
                JObject originData = null;
                if (this._formType == BstManager.TypeAttach ||
                    this._formType == BstManager.TypeCostume)
                {
                    var race = BstManager.Instance.RaceTypes[raceType];
                    var data = (JObject)this._originSettings[race];
                    if (data != null)
                    {
                        this._originElementId = (string)data["id"];
                        originData            = (JObject)data["data"];
                    }
                }
                else
                {
                    if (this._originSettings["id"] != null)
                    {
                        this._originElementId = (string)this._originSettings["id"];
                        originData            = (JObject)this._originSettings["data"];
                    }
                }
                if (originData != null)
                {
                    this.LoadOriginAndTargetIconPic(this.pictureBoxOrigin, originData, true);
                    BstManager.ShowMsgInTextBox(this.textBoxOrigin, originData.ToString(), false);
                }

                // 初始化list数据
                switch (this._formType)
                {
                case BstManager.TypeCostume:
                    this._data = BstManager.Instance.GetCostumeDataByRace(raceType);
                    break;

                case BstManager.TypeAttach:
                    this._data = BstManager.Instance.GetAttachDataByRace(raceType);
                    break;

                case BstManager.TypeWeapon:
                    this._data = BstManager.Instance.DataWeapon;
                    break;
                }
                // 加载list界面
                foreach (var element in this._data.Properties())
                {
                    // 读取数据
                    var elementId   = element.Name;
                    var elementData = (JObject)element.Value;
                    // 填充数据
                    // 这里暂时不考虑做成动态的gif动画,考虑到列表里的项可能比较多,那么多timer更新gif动态图可能造成性能问题
                    this._dataTable.Rows.Add(new object[] { BstManager.Instance.LoadingGifBytes, elementId });
                    var rowId = this._dataTable.Rows.Count - 1;
                    BstIconLoader.Instance.RegisterTask(new BstIconLoadTask(
                                                            elementData, this.gridItems, this._dataTable, rowId, this.textBoxOut
                                                            ));
                }

                BstManager.ShowMsgInTextBox(this.textBoxOut, this._i18N.LoadI18NValue("GuiItems", "logEndLoadDataList"));
                BstIconLoader.Instance.Start(); // 启动图片加载器
            });
            this._loadingThread.Start();
        }