mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-12-08 08:38:23 +08:00
Update Activity Translates
This commit is contained in:
13
Source/GrasscutterTools/Pages/PageTools.Designer.cs
generated
13
Source/GrasscutterTools/Pages/PageTools.Designer.cs
generated
@@ -35,6 +35,7 @@
|
||||
this.LblGcResRoot = new System.Windows.Forms.Label();
|
||||
this.TxtGcResRoot = new System.Windows.Forms.TextBox();
|
||||
this.BtnUpdateDungeon = new System.Windows.Forms.Button();
|
||||
this.BtnUpdateActivity = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// BtnUpdateResources
|
||||
@@ -99,6 +100,16 @@
|
||||
this.BtnUpdateDungeon.UseVisualStyleBackColor = true;
|
||||
this.BtnUpdateDungeon.Click += new System.EventHandler(this.BtnUpdateDungeon_Click);
|
||||
//
|
||||
// BtnUpdateActivity
|
||||
//
|
||||
this.BtnUpdateActivity.Location = new System.Drawing.Point(197, 100);
|
||||
this.BtnUpdateActivity.Name = "BtnUpdateActivity";
|
||||
this.BtnUpdateActivity.Size = new System.Drawing.Size(150, 30);
|
||||
this.BtnUpdateActivity.TabIndex = 0;
|
||||
this.BtnUpdateActivity.Text = "Update Activity";
|
||||
this.BtnUpdateActivity.UseVisualStyleBackColor = true;
|
||||
this.BtnUpdateActivity.Click += new System.EventHandler(this.BtnUpdateActivity_Click);
|
||||
//
|
||||
// PageTools
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
|
||||
@@ -107,6 +118,7 @@
|
||||
this.Controls.Add(this.LblGcResRoot);
|
||||
this.Controls.Add(this.TxtProjectResRoot);
|
||||
this.Controls.Add(this.LblProjectResRoot);
|
||||
this.Controls.Add(this.BtnUpdateActivity);
|
||||
this.Controls.Add(this.BtnUpdateDungeon);
|
||||
this.Controls.Add(this.BtnConvertCutScene);
|
||||
this.Controls.Add(this.BtnUpdateResources);
|
||||
@@ -125,5 +137,6 @@
|
||||
private System.Windows.Forms.Label LblGcResRoot;
|
||||
private System.Windows.Forms.TextBox TxtGcResRoot;
|
||||
private System.Windows.Forms.Button BtnUpdateDungeon;
|
||||
private System.Windows.Forms.Button BtnUpdateActivity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using GrasscutterTools.Game;
|
||||
using GrasscutterTools.Game.Activity;
|
||||
using GrasscutterTools.Game.CutScene;
|
||||
using GrasscutterTools.Game.Dungeon;
|
||||
using GrasscutterTools.Properties;
|
||||
@@ -159,5 +160,58 @@ namespace GrasscutterTools.Pages
|
||||
dungeons.Select(it => $"{it.Id}:{TextMapData.GetText(it.NameTextMapHash)}"),
|
||||
Encoding.UTF8);
|
||||
}
|
||||
|
||||
private void BtnUpdateActivity_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!CheckInputPaths()) return;
|
||||
|
||||
var json = File.ReadAllText(
|
||||
Path.Combine(TxtGcResRoot.Text, "ExcelBinOutput", "NewActivityExcelConfigData.json"),
|
||||
Encoding.UTF8);
|
||||
var activityItems = JsonConvert.DeserializeObject<List<NewActivityItem>>(json);
|
||||
|
||||
if (TextMapData == null)
|
||||
TextMapData = new TextMapData(TxtGcResRoot.Text);
|
||||
|
||||
UpdateActivityForLanguage(activityItems, "TextMapCHT", "zh-tw");
|
||||
UpdateActivityForLanguage(activityItems, "TextMapEN", "en-us");
|
||||
UpdateActivityForLanguage(activityItems, "TextMapRU", "ru-ru");
|
||||
MessageBox.Show("OK", Resources.Tips, MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateActivityForLanguage(IReadOnlyCollection<NewActivityItem> activityItems, string textMap, string language)
|
||||
{
|
||||
var i = Array.IndexOf(TextMapData.TextMapFiles, textMap);
|
||||
TextMapData.LoadTextMap(TextMapData.TextMapFilePaths[i]);
|
||||
|
||||
var activityMap = new Dictionary<int, string>(activityItems.Count);
|
||||
foreach (var item in activityItems)
|
||||
activityMap[item.ActivityId] = TextMapData.GetText(item.NameTextMapHash);
|
||||
|
||||
var buffer = new StringBuilder();
|
||||
foreach (var item in GameData.Activity)
|
||||
{
|
||||
buffer.Append("// ").AppendLine(item.Key);
|
||||
foreach (var id in item.Value.Ids)
|
||||
{
|
||||
buffer.Append(id).Append(':');
|
||||
buffer.AppendLine(activityMap.TryGetValue(id, out var title) ? title : item.Value[id]);
|
||||
}
|
||||
}
|
||||
var activityFilePath = Path.Combine(TxtProjectResRoot.Text, language, "Activity.txt");
|
||||
File.WriteAllText(activityFilePath, buffer.ToString(), Encoding.UTF8);
|
||||
|
||||
//File.WriteAllLines(
|
||||
// activityFilePath,
|
||||
// activityItems.Select(it => $"{it.ActivityId}:{TextMapData.GetText(it.NameTextMapHash)}"),
|
||||
// Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user