Add Cutscene command to Scene page

This commit is contained in:
2023-06-08 21:19:26 +08:00
parent 6da7e1d4d0
commit 1ccb3656c2
12 changed files with 411 additions and 56 deletions

View File

@@ -147,8 +147,17 @@ namespace GrasscutterTools.Pages
return;
}
Common.OC = new OpenCommandAPI(TxtHost.Text);
if (await Common.OC.Ping())
var isOcEnabled = false;
try
{
Common.OC = new OpenCommandAPI(TxtHost.Text);
isOcEnabled = await Common.OC.Ping();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (isOcEnabled)
{
LblOpenCommandSupport.Text = "√";
LblOpenCommandSupport.ForeColor = Color.Green;

View File

@@ -45,6 +45,7 @@
this.LblSceneDescription = new System.Windows.Forms.Label();
this.ListScenes = new System.Windows.Forms.ListBox();
this.LblTp = new System.Windows.Forms.Label();
this.RbListCutScene = new System.Windows.Forms.RadioButton();
((System.ComponentModel.ISupportInitialize)(this.NUDTpZ)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUDTpY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUDTpX)).BeginInit();
@@ -195,10 +196,18 @@
resources.ApplyResources(this.LblTp, "LblTp");
this.LblTp.Name = "LblTp";
//
// RbListCutScene
//
resources.ApplyResources(this.RbListCutScene, "RbListCutScene");
this.RbListCutScene.Name = "RbListCutScene";
this.RbListCutScene.UseVisualStyleBackColor = true;
this.RbListCutScene.CheckedChanged += new System.EventHandler(this.RbListCutScene_CheckedChanged);
//
// PageScene
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.RbListCutScene);
this.Controls.Add(this.RbListDungeons);
this.Controls.Add(this.RbListScene);
this.Controls.Add(this.TxtSceneFilter);
@@ -242,5 +251,6 @@
private System.Windows.Forms.Label LblSceneDescription;
private System.Windows.Forms.ListBox ListScenes;
private System.Windows.Forms.Label LblTp;
private System.Windows.Forms.RadioButton RbListCutScene;
}
}

View File

@@ -75,6 +75,16 @@ namespace GrasscutterTools.Pages
Scenes = GameData.Dungeons.Lines;
}
/// <summary>
/// 选中过场时触发
/// </summary>
private void RbListCutScene_CheckedChanged(object sender, EventArgs e)
{
if (RbListCutScene.Checked)
Scenes = GameData.CutScenes.Lines;
}
/// <summary>
/// 场景列表过滤器输入项改变时触发
/// </summary>
@@ -113,6 +123,10 @@ namespace GrasscutterTools.Pages
{
SetCommand("/dungeon", id.ToString());
}
else if (RbListCutScene.Checked)
{
SetCommand("/cutscene", id.ToString());
}
}
/// <summary>

View File

@@ -148,7 +148,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;RbListDungeons.ZOrder" xml:space="preserve">
<value>0</value>
<value>1</value>
</data>
<data name="RbListScene.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -178,7 +178,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;RbListScene.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="TxtSceneFilter.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
@@ -202,7 +202,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;TxtSceneFilter.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="ChkIncludeSceneId.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
@@ -238,7 +238,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;ChkIncludeSceneId.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="LblTpZ.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
@@ -271,7 +271,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;LblTpZ.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="LblTpY.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
@@ -304,7 +304,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;LblTpY.ZOrder" xml:space="preserve">
<value>5</value>
<value>6</value>
</data>
<data name="BtnTeleport.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
@@ -334,7 +334,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;BtnTeleport.ZOrder" xml:space="preserve">
<value>6</value>
<value>7</value>
</data>
<data name="LblTpX.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
@@ -367,7 +367,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;LblTpX.ZOrder" xml:space="preserve">
<value>7</value>
<value>8</value>
</data>
<data name="NUDTpZ.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
@@ -391,7 +391,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;NUDTpZ.ZOrder" xml:space="preserve">
<value>8</value>
<value>9</value>
</data>
<data name="NUDTpY.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
@@ -415,7 +415,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;NUDTpY.ZOrder" xml:space="preserve">
<value>9</value>
<value>10</value>
</data>
<data name="NUDTpX.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
@@ -439,7 +439,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;NUDTpX.ZOrder" xml:space="preserve">
<value>10</value>
<value>11</value>
</data>
<data name="CmbClimateType.Location" type="System.Drawing.Point, System.Drawing">
<value>65, 29</value>
@@ -460,7 +460,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;CmbClimateType.ZOrder" xml:space="preserve">
<value>11</value>
<value>12</value>
</data>
<data name="LblClimateType.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -490,7 +490,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;LblClimateType.ZOrder" xml:space="preserve">
<value>12</value>
<value>13</value>
</data>
<data name="LblSceneDescription.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -520,7 +520,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;LblSceneDescription.ZOrder" xml:space="preserve">
<value>13</value>
<value>14</value>
</data>
<data name="ListScenes.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
@@ -547,7 +547,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;ListScenes.ZOrder" xml:space="preserve">
<value>14</value>
<value>15</value>
</data>
<data name="LblTp.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
@@ -583,7 +583,37 @@
<value>$this</value>
</data>
<data name="&gt;&gt;LblTp.ZOrder" xml:space="preserve">
<value>15</value>
<value>16</value>
</data>
<data name="RbListCutScene.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="RbListCutScene.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="RbListCutScene.Location" type="System.Drawing.Point, System.Drawing">
<value>287, 57</value>
</data>
<data name="RbListCutScene.Size" type="System.Drawing.Size, System.Drawing">
<value>50, 21</value>
</data>
<data name="RbListCutScene.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="RbListCutScene.Text" xml:space="preserve">
<value>过场</value>
</data>
<data name="&gt;&gt;RbListCutScene.Name" xml:space="preserve">
<value>RbListCutScene</value>
</data>
<data name="&gt;&gt;RbListCutScene.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;RbListCutScene.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;RbListCutScene.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
@@ -595,6 +625,6 @@
<value>PageScene</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>GrasscutterTools.Pages.BasePage, GrasscutterTools, Version=1.7.4.0, Culture=neutral, PublicKeyToken=de2b1c089621e923</value>
<value>GrasscutterTools.Pages.BasePage, GrasscutterTools, Version=1.9.1.0, Culture=neutral, PublicKeyToken=de2b1c089621e923</value>
</data>
</root>

View File

@@ -29,6 +29,7 @@
private void InitializeComponent()
{
this.BtnUpdateResources = new System.Windows.Forms.Button();
this.BtnConvertCutScene = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// BtnUpdateResources
@@ -41,10 +42,21 @@
this.BtnUpdateResources.UseVisualStyleBackColor = true;
this.BtnUpdateResources.Click += new System.EventHandler(this.BtnUpdateResources_Click);
//
// BtnConvertCutScene
//
this.BtnConvertCutScene.Location = new System.Drawing.Point(109, 3);
this.BtnConvertCutScene.Name = "BtnConvertCutScene";
this.BtnConvertCutScene.Size = new System.Drawing.Size(150, 30);
this.BtnConvertCutScene.TabIndex = 0;
this.BtnConvertCutScene.Text = "Convert Cutscene";
this.BtnConvertCutScene.UseVisualStyleBackColor = true;
this.BtnConvertCutScene.Click += new System.EventHandler(this.BtnConvertCutScene_Click);
//
// PageTools
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.BtnConvertCutScene);
this.Controls.Add(this.BtnUpdateResources);
this.Name = "PageTools";
this.ResumeLayout(false);
@@ -54,5 +66,6 @@
#endregion
private System.Windows.Forms.Button BtnUpdateResources;
private System.Windows.Forms.Button BtnConvertCutScene;
}
}

View File

@@ -1,7 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using GrasscutterTools.Game.CutScene;
using GrasscutterTools.Properties;
using Newtonsoft.Json;
namespace GrasscutterTools.Pages
{
@@ -62,5 +66,28 @@ namespace GrasscutterTools.Pages
}
}
}
private void BtnConvertCutScene_Click(object sender, EventArgs e)
{
var src = new OpenFileDialog
{
Title = "请选择 Json 格式的 Cutscene.txt",
Multiselect = false,
};
if (src.ShowDialog() != DialogResult.OK)
return;
try
{
var cutScenes = JsonConvert.DeserializeObject<List<CutSceneItem>>(File.ReadAllText(src.FileName));
File.WriteAllLines(src.FileName, cutScenes.Select(it => $"{it.Id}:{it.Path.Substring(it.Path.IndexOf('/') + 1)}"));
MessageBox.Show("OK", Resources.Tips, MessageBoxButtons.OK);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}