diff --git a/Source/GrasscutterTools/Forms/FormMain.cs b/Source/GrasscutterTools/Forms/FormMain.cs index 8d8d480..3201c2c 100644 --- a/Source/GrasscutterTools/Forms/FormMain.cs +++ b/Source/GrasscutterTools/Forms/FormMain.cs @@ -101,6 +101,7 @@ namespace GrasscutterTools.Forms TPQuest.Controls.Add(CreatePage()); TPScene.Controls.Add(CreatePage()); TPAbout.Controls.Add(CreatePage()); + //TPAbout.Controls.Add(CreatePage()); TCMain.ResumeLayout(); Logger.I(TAG, "InitPages completed"); } diff --git a/Source/GrasscutterTools/GrasscutterTools.csproj b/Source/GrasscutterTools/GrasscutterTools.csproj index cd53fff..bb0d440 100644 --- a/Source/GrasscutterTools/GrasscutterTools.csproj +++ b/Source/GrasscutterTools/GrasscutterTools.csproj @@ -244,6 +244,12 @@ PageTasks.cs + + UserControl + + + PageTools.cs + @@ -514,6 +520,9 @@ PageTasks.cs + + PageTools.cs + ResXFileCodeGenerator Resources.zh-TW.Designer.cs diff --git a/Source/GrasscutterTools/Pages/PageTools.Designer.cs b/Source/GrasscutterTools/Pages/PageTools.Designer.cs new file mode 100644 index 0000000..dd6ae44 --- /dev/null +++ b/Source/GrasscutterTools/Pages/PageTools.Designer.cs @@ -0,0 +1,58 @@ +namespace GrasscutterTools.Pages +{ + partial class PageTools + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.BtnUpdateResources = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // BtnUpdateResources + // + this.BtnUpdateResources.Location = new System.Drawing.Point(3, 3); + this.BtnUpdateResources.Name = "BtnUpdateResources"; + this.BtnUpdateResources.Size = new System.Drawing.Size(100, 30); + this.BtnUpdateResources.TabIndex = 0; + this.BtnUpdateResources.Text = "Update res"; + this.BtnUpdateResources.UseVisualStyleBackColor = true; + this.BtnUpdateResources.Click += new System.EventHandler(this.BtnUpdateResources_Click); + // + // PageTools + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.BtnUpdateResources); + this.Name = "PageTools"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button BtnUpdateResources; + } +} diff --git a/Source/GrasscutterTools/Pages/PageTools.cs b/Source/GrasscutterTools/Pages/PageTools.cs new file mode 100644 index 0000000..3eece78 --- /dev/null +++ b/Source/GrasscutterTools/Pages/PageTools.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Windows.Forms; + +namespace GrasscutterTools.Pages +{ + internal partial class PageTools : BasePage + { + public PageTools() + { + InitializeComponent(); + } + + private void BtnUpdateResources_Click(object sender, EventArgs e) + { + var src = new OpenFileDialog + { + Title = "请选择当前原文件", + Multiselect = false, + }; + var dest = new OpenFileDialog + { + Title = "请选择包含新ID的文件", + Multiselect = false, + }; + + if (src.ShowDialog() == DialogResult.OK && dest.ShowDialog() == DialogResult.OK) + { + var srcLines = File.ReadAllLines(src.FileName); + var srcDic = new Dictionary(srcLines.Length); + foreach (var line in srcLines) + { + var sp = line.IndexOf(':'); + if (sp > 0) + { + var value = line.Substring(sp + 1).Trim(); + if (!value.StartsWith("[N/A]")) + srcDic[line.Substring(0, sp).Trim()] = line.Substring(sp + 1).Trim(); + } + } + + var destLines = File.ReadAllLines(dest.FileName); + using (var outStream = File.Create(dest.FileName)) + using (var outTxtStream = new StreamWriter(outStream)) + { + foreach (var line in destLines) + { + var sp = line.IndexOf(':'); + if (sp == -1) + { + outTxtStream.WriteLine(line); + } + else + { + var key = line.Substring(0, sp).Trim(); + if (!srcDic.TryGetValue(key, out var value)) + value = line.Substring(sp + 1).Trim(); + outTxtStream.WriteLine($"{key}:{value}"); + } + } + } + } + } + } +} diff --git a/Source/GrasscutterTools/Pages/PageTools.resx b/Source/GrasscutterTools/Pages/PageTools.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Source/GrasscutterTools/Pages/PageTools.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file