mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-10-20 19:39:47 +08:00
Update banner titles to 4.6
Fix benner editor format Add banner title update tool
This commit is contained in:
13
Source/GrasscutterTools/Pages/PageTools.Designer.cs
generated
13
Source/GrasscutterTools/Pages/PageTools.Designer.cs
generated
@@ -36,6 +36,7 @@
|
||||
this.TxtGcResRoot = new System.Windows.Forms.TextBox();
|
||||
this.BtnUpdateAllResources = new System.Windows.Forms.Button();
|
||||
this.BtnUpdateActivity = new System.Windows.Forms.Button();
|
||||
this.BtnUpdateBannerTitles = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// BtnUpdateResources
|
||||
@@ -110,6 +111,16 @@
|
||||
this.BtnUpdateActivity.UseVisualStyleBackColor = true;
|
||||
this.BtnUpdateActivity.Click += new System.EventHandler(this.BtnUpdateActivity_Click);
|
||||
//
|
||||
// BtnUpdateBannerTitles
|
||||
//
|
||||
this.BtnUpdateBannerTitles.Location = new System.Drawing.Point(353, 100);
|
||||
this.BtnUpdateBannerTitles.Name = "BtnUpdateBannerTitles";
|
||||
this.BtnUpdateBannerTitles.Size = new System.Drawing.Size(150, 30);
|
||||
this.BtnUpdateBannerTitles.TabIndex = 0;
|
||||
this.BtnUpdateBannerTitles.Text = "Update Banner Titles";
|
||||
this.BtnUpdateBannerTitles.UseVisualStyleBackColor = true;
|
||||
this.BtnUpdateBannerTitles.Click += new System.EventHandler(this.BtnUpdateBannerTitles_Click);
|
||||
//
|
||||
// PageTools
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
|
||||
@@ -118,6 +129,7 @@
|
||||
this.Controls.Add(this.LblGcResRoot);
|
||||
this.Controls.Add(this.TxtProjectResRoot);
|
||||
this.Controls.Add(this.LblProjectResRoot);
|
||||
this.Controls.Add(this.BtnUpdateBannerTitles);
|
||||
this.Controls.Add(this.BtnUpdateActivity);
|
||||
this.Controls.Add(this.BtnUpdateAllResources);
|
||||
this.Controls.Add(this.BtnConvertCutScene);
|
||||
@@ -138,5 +150,6 @@
|
||||
private System.Windows.Forms.TextBox TxtGcResRoot;
|
||||
private System.Windows.Forms.Button BtnUpdateAllResources;
|
||||
private System.Windows.Forms.Button BtnUpdateActivity;
|
||||
private System.Windows.Forms.Button BtnUpdateBannerTitles;
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using GrasscutterTools.Game;
|
||||
@@ -151,10 +152,8 @@ namespace GrasscutterTools.Pages
|
||||
{
|
||||
if (!CheckInputPaths()) return;
|
||||
|
||||
if (TextMapData == null)
|
||||
TextMapData = new TextMapData(TxtGcResRoot.Text);
|
||||
if (GameResources == null)
|
||||
GameResources = new GameResources(TxtGcResRoot.Text, TextMapData);
|
||||
TextMapData ??= new TextMapData(TxtGcResRoot.Text);
|
||||
GameResources ??= new GameResources(TxtGcResRoot.Text, TextMapData);
|
||||
|
||||
GameResources.ConvertResources(TxtProjectResRoot.Text);
|
||||
MessageBox.Show("OK", Resources.Tips, MessageBoxButtons.OK);
|
||||
@@ -176,8 +175,7 @@ namespace GrasscutterTools.Pages
|
||||
Encoding.UTF8);
|
||||
var activityItems = JsonConvert.DeserializeObject<List<NewActivityItem>>(json);
|
||||
|
||||
if (TextMapData == null)
|
||||
TextMapData = new TextMapData(TxtGcResRoot.Text);
|
||||
TextMapData ??= new TextMapData(TxtGcResRoot.Text);
|
||||
|
||||
UpdateActivityForLanguage(activityItems, "TextMapCHS", "zh-cn");
|
||||
UpdateActivityForLanguage(activityItems, "TextMapCHT", "zh-tw");
|
||||
@@ -218,5 +216,51 @@ namespace GrasscutterTools.Pages
|
||||
// activityItems.Select(it => $"{it.ActivityId}:{TextMapData.GetText(it.NameTextMapHash)}"),
|
||||
// Encoding.UTF8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void UpdateGachaResourceForLanguage(string textMap, string language)
|
||||
{
|
||||
var i = Array.IndexOf(TextMapData.TextMapFiles, textMap);
|
||||
TextMapData.LoadTextMap(TextMapData.TextMapFilePaths[i]);
|
||||
|
||||
var titleBuffer = new StringBuilder();
|
||||
const string titlePattern = "UI_GACHA_SHOW_PANEL_([^_]+?)_TITLE";
|
||||
const string markPattern = "<[^>]+>";
|
||||
|
||||
foreach (var kv in TextMapData.ManualTextMap)
|
||||
{
|
||||
var titleId = Regex.Match(kv.Value, titlePattern);
|
||||
if (!titleId.Success) continue;
|
||||
var text = TextMapData.TextMap[kv.Key];
|
||||
titleBuffer.Append(titleId.Groups[1].Captures[0].Value)
|
||||
.Append(":")
|
||||
.AppendLine(Regex.Replace(text, markPattern, ""));
|
||||
}
|
||||
|
||||
var titleFilePath = Path.Combine(TxtProjectResRoot.Text, language, "GachaBannerTitle.txt");
|
||||
File.WriteAllText(titleFilePath, titleBuffer.ToString(), Encoding.UTF8);
|
||||
|
||||
}
|
||||
|
||||
private void BtnUpdateBannerTitles_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!CheckInputPaths()) return;
|
||||
|
||||
TextMapData ??= new TextMapData(TxtGcResRoot.Text);
|
||||
|
||||
UpdateGachaResourceForLanguage("TextMapCHS", "zh-cn");
|
||||
UpdateGachaResourceForLanguage("TextMapCHT", "zh-tw");
|
||||
UpdateGachaResourceForLanguage("TextMapEN", "en-us");
|
||||
UpdateGachaResourceForLanguage("TextMapRU", "ru-ru");
|
||||
MessageBox.Show("OK", Resources.Tips, MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user