mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-12-08 08:38:23 +08:00
Add Resources update tool
This commit is contained in:
22
Source/GrasscutterTools/Pages/PageTools.Designer.cs
generated
22
Source/GrasscutterTools/Pages/PageTools.Designer.cs
generated
@@ -34,7 +34,7 @@
|
||||
this.TxtProjectResRoot = new System.Windows.Forms.TextBox();
|
||||
this.LblGcResRoot = new System.Windows.Forms.Label();
|
||||
this.TxtGcResRoot = new System.Windows.Forms.TextBox();
|
||||
this.BtnUpdateDungeon = new System.Windows.Forms.Button();
|
||||
this.BtnUpdateAllResources = new System.Windows.Forms.Button();
|
||||
this.BtnUpdateActivity = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -90,15 +90,15 @@
|
||||
this.TxtGcResRoot.Size = new System.Drawing.Size(413, 23);
|
||||
this.TxtGcResRoot.TabIndex = 4;
|
||||
//
|
||||
// BtnUpdateDungeon
|
||||
// BtnUpdateAllResources
|
||||
//
|
||||
this.BtnUpdateDungeon.Location = new System.Drawing.Point(41, 100);
|
||||
this.BtnUpdateDungeon.Name = "BtnUpdateDungeon";
|
||||
this.BtnUpdateDungeon.Size = new System.Drawing.Size(150, 30);
|
||||
this.BtnUpdateDungeon.TabIndex = 0;
|
||||
this.BtnUpdateDungeon.Text = "Update Dungeon";
|
||||
this.BtnUpdateDungeon.UseVisualStyleBackColor = true;
|
||||
this.BtnUpdateDungeon.Click += new System.EventHandler(this.BtnUpdateDungeon_Click);
|
||||
this.BtnUpdateAllResources.Location = new System.Drawing.Point(41, 100);
|
||||
this.BtnUpdateAllResources.Name = "BtnUpdateAllResources";
|
||||
this.BtnUpdateAllResources.Size = new System.Drawing.Size(150, 30);
|
||||
this.BtnUpdateAllResources.TabIndex = 0;
|
||||
this.BtnUpdateAllResources.Text = "Update All Resources";
|
||||
this.BtnUpdateAllResources.UseVisualStyleBackColor = true;
|
||||
this.BtnUpdateAllResources.Click += new System.EventHandler(this.BtnUpdateAllResources_Click);
|
||||
//
|
||||
// BtnUpdateActivity
|
||||
//
|
||||
@@ -119,7 +119,7 @@
|
||||
this.Controls.Add(this.TxtProjectResRoot);
|
||||
this.Controls.Add(this.LblProjectResRoot);
|
||||
this.Controls.Add(this.BtnUpdateActivity);
|
||||
this.Controls.Add(this.BtnUpdateDungeon);
|
||||
this.Controls.Add(this.BtnUpdateAllResources);
|
||||
this.Controls.Add(this.BtnConvertCutScene);
|
||||
this.Controls.Add(this.BtnUpdateResources);
|
||||
this.Name = "PageTools";
|
||||
@@ -136,7 +136,7 @@
|
||||
private System.Windows.Forms.TextBox TxtProjectResRoot;
|
||||
private System.Windows.Forms.Label LblGcResRoot;
|
||||
private System.Windows.Forms.TextBox TxtGcResRoot;
|
||||
private System.Windows.Forms.Button BtnUpdateDungeon;
|
||||
private System.Windows.Forms.Button BtnUpdateAllResources;
|
||||
private System.Windows.Forms.Button BtnUpdateActivity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Windows.Forms;
|
||||
using GrasscutterTools.Game;
|
||||
using GrasscutterTools.Game.Activity;
|
||||
using GrasscutterTools.Game.CutScene;
|
||||
using GrasscutterTools.Game.Data;
|
||||
using GrasscutterTools.Game.Dungeon;
|
||||
using GrasscutterTools.Properties;
|
||||
|
||||
@@ -121,26 +122,25 @@ namespace GrasscutterTools.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private TextMapData TextMapData;
|
||||
|
||||
private void BtnUpdateDungeon_Click(object sender, EventArgs e)
|
||||
|
||||
|
||||
|
||||
private TextMapData TextMapData;
|
||||
private GameResources GameResources;
|
||||
|
||||
private void BtnUpdateAllResources_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!CheckInputPaths()) return;
|
||||
|
||||
var json = File.ReadAllText(
|
||||
Path.Combine(TxtGcResRoot.Text, "ExcelBinOutput", "DungeonExcelConfigData.json"),
|
||||
Encoding.UTF8);
|
||||
var dungeons = JsonConvert.DeserializeObject<List<DungeonItem>>(json);
|
||||
|
||||
|
||||
if (TextMapData == null)
|
||||
TextMapData = new TextMapData(TxtGcResRoot.Text);
|
||||
if (GameResources == null)
|
||||
GameResources = new GameResources(TxtGcResRoot.Text, TextMapData);
|
||||
|
||||
UpdateDungeonsForLanguage(dungeons, "TextMapCHS", "zh-cn");
|
||||
UpdateDungeonsForLanguage(dungeons, "TextMapCHT", "zh-tw");
|
||||
UpdateDungeonsForLanguage(dungeons, "TextMapEN", "en-us");
|
||||
UpdateDungeonsForLanguage(dungeons, "TextMapRU", "ru-ru");
|
||||
GameResources.ConvertResources(TxtProjectResRoot.Text);
|
||||
MessageBox.Show("OK", Resources.Tips, MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -149,17 +149,12 @@ namespace GrasscutterTools.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDungeonsForLanguage(IEnumerable<DungeonItem> dungeons, string textMap, string language)
|
||||
{
|
||||
var i = Array.IndexOf(TextMapData.TextMapFiles, textMap);
|
||||
TextMapData.LoadTextMap(TextMapData.TextMapFilePaths[i]);
|
||||
|
||||
var dungeonFilePath = Path.Combine(TxtProjectResRoot.Text, language, "Dungeon.txt");
|
||||
File.WriteAllLines(
|
||||
dungeonFilePath,
|
||||
dungeons.Select(it => $"{it.Id}:{TextMapData.GetText(it.NameTextMapHash)}"),
|
||||
Encoding.UTF8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void BtnUpdateActivity_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -213,5 +208,6 @@ namespace GrasscutterTools.Pages
|
||||
// activityItems.Select(it => $"{it.ActivityId}:{TextMapData.GetText(it.NameTextMapHash)}"),
|
||||
// Encoding.UTF8);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user