mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-14 19:44:47 +08:00
Animations XML conversion
This commit is contained in:
Generated
+98
-4
@@ -28,6 +28,7 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.ListViewGroup listViewGroup1 = new System.Windows.Forms.ListViewGroup("Clips", System.Windows.Forms.HorizontalAlignment.Left);
|
||||
System.Windows.Forms.ListViewGroup listViewGroup2 = new System.Windows.Forms.ListViewGroup("Animations", System.Windows.Forms.HorizontalAlignment.Left);
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(YcdForm));
|
||||
@@ -35,10 +36,18 @@
|
||||
this.MainListView = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.MainPropertyGrid = new CodeWalker.WinForms.ReadOnlyPropertyGrid();
|
||||
this.MainTabControl = new System.Windows.Forms.TabControl();
|
||||
this.DetailsTabPage = new System.Windows.Forms.TabPage();
|
||||
this.XmlTabPage = new System.Windows.Forms.TabPage();
|
||||
this.XmlTextBox = new FastColoredTextBoxNS.FastColoredTextBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
this.MainTabControl.SuspendLayout();
|
||||
this.DetailsTabPage.SuspendLayout();
|
||||
this.XmlTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.XmlTextBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// splitContainer1
|
||||
@@ -55,7 +64,7 @@
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.MainPropertyGrid);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(763, 474);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(751, 442);
|
||||
this.splitContainer1.SplitterDistance = 254;
|
||||
this.splitContainer1.TabIndex = 1;
|
||||
//
|
||||
@@ -78,7 +87,7 @@
|
||||
this.MainListView.Location = new System.Drawing.Point(3, 3);
|
||||
this.MainListView.MultiSelect = false;
|
||||
this.MainListView.Name = "MainListView";
|
||||
this.MainListView.Size = new System.Drawing.Size(248, 468);
|
||||
this.MainListView.Size = new System.Drawing.Size(248, 436);
|
||||
this.MainListView.TabIndex = 0;
|
||||
this.MainListView.UseCompatibleStateImageBehavior = false;
|
||||
this.MainListView.View = System.Windows.Forms.View.Details;
|
||||
@@ -98,15 +107,92 @@
|
||||
this.MainPropertyGrid.Location = new System.Drawing.Point(3, 3);
|
||||
this.MainPropertyGrid.Name = "MainPropertyGrid";
|
||||
this.MainPropertyGrid.ReadOnly = false;
|
||||
this.MainPropertyGrid.Size = new System.Drawing.Size(499, 468);
|
||||
this.MainPropertyGrid.Size = new System.Drawing.Size(487, 436);
|
||||
this.MainPropertyGrid.TabIndex = 0;
|
||||
//
|
||||
// MainTabControl
|
||||
//
|
||||
this.MainTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.MainTabControl.Controls.Add(this.DetailsTabPage);
|
||||
this.MainTabControl.Controls.Add(this.XmlTabPage);
|
||||
this.MainTabControl.Location = new System.Drawing.Point(2, 3);
|
||||
this.MainTabControl.Name = "MainTabControl";
|
||||
this.MainTabControl.SelectedIndex = 0;
|
||||
this.MainTabControl.Size = new System.Drawing.Size(759, 468);
|
||||
this.MainTabControl.TabIndex = 2;
|
||||
this.MainTabControl.SelectedIndexChanged += new System.EventHandler(this.MainTabControl_SelectedIndexChanged);
|
||||
//
|
||||
// DetailsTabPage
|
||||
//
|
||||
this.DetailsTabPage.Controls.Add(this.splitContainer1);
|
||||
this.DetailsTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.DetailsTabPage.Name = "DetailsTabPage";
|
||||
this.DetailsTabPage.Size = new System.Drawing.Size(751, 442);
|
||||
this.DetailsTabPage.TabIndex = 0;
|
||||
this.DetailsTabPage.Text = "Details";
|
||||
this.DetailsTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// XmlTabPage
|
||||
//
|
||||
this.XmlTabPage.Controls.Add(this.XmlTextBox);
|
||||
this.XmlTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.XmlTabPage.Name = "XmlTabPage";
|
||||
this.XmlTabPage.Size = new System.Drawing.Size(751, 442);
|
||||
this.XmlTabPage.TabIndex = 1;
|
||||
this.XmlTabPage.Text = "XML";
|
||||
this.XmlTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// XmlTextBox
|
||||
//
|
||||
this.XmlTextBox.AutoCompleteBracketsList = new char[] {
|
||||
'(',
|
||||
')',
|
||||
'{',
|
||||
'}',
|
||||
'[',
|
||||
']',
|
||||
'\"',
|
||||
'\"',
|
||||
'\'',
|
||||
'\''};
|
||||
this.XmlTextBox.AutoIndentChars = false;
|
||||
this.XmlTextBox.AutoIndentCharsPatterns = "";
|
||||
this.XmlTextBox.AutoIndentExistingLines = false;
|
||||
this.XmlTextBox.AutoScrollMinSize = new System.Drawing.Size(27, 14);
|
||||
this.XmlTextBox.BackBrush = null;
|
||||
this.XmlTextBox.CharHeight = 14;
|
||||
this.XmlTextBox.CharWidth = 8;
|
||||
this.XmlTextBox.CommentPrefix = null;
|
||||
this.XmlTextBox.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.XmlTextBox.DelayedEventsInterval = 1;
|
||||
this.XmlTextBox.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))));
|
||||
this.XmlTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.XmlTextBox.Font = new System.Drawing.Font("Courier New", 9.75F);
|
||||
this.XmlTextBox.IsReplaceMode = false;
|
||||
this.XmlTextBox.Language = FastColoredTextBoxNS.Language.XML;
|
||||
this.XmlTextBox.LeftBracket = '<';
|
||||
this.XmlTextBox.LeftBracket2 = '(';
|
||||
this.XmlTextBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.XmlTextBox.Name = "XmlTextBox";
|
||||
this.XmlTextBox.Paddings = new System.Windows.Forms.Padding(0);
|
||||
this.XmlTextBox.RightBracket = '>';
|
||||
this.XmlTextBox.RightBracket2 = ')';
|
||||
this.XmlTextBox.SelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));
|
||||
this.XmlTextBox.ServiceColors = ((FastColoredTextBoxNS.ServiceColors)(resources.GetObject("XmlTextBox.ServiceColors")));
|
||||
this.XmlTextBox.Size = new System.Drawing.Size(751, 442);
|
||||
this.XmlTextBox.TabIndex = 1;
|
||||
this.XmlTextBox.Zoom = 100;
|
||||
this.XmlTextBox.TextChanged += new System.EventHandler<FastColoredTextBoxNS.TextChangedEventArgs>(this.XmlTextBox_TextChanged);
|
||||
this.XmlTextBox.VisibleRangeChangedDelayed += new System.EventHandler(this.XmlTextBox_VisibleRangeChangedDelayed);
|
||||
//
|
||||
// YcdForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(763, 474);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Controls.Add(this.MainTabControl);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "YcdForm";
|
||||
this.Text = "Clip Dictionary Inspector - CodeWalker by dexyfex";
|
||||
@@ -114,6 +200,10 @@
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
this.MainTabControl.ResumeLayout(false);
|
||||
this.DetailsTabPage.ResumeLayout(false);
|
||||
this.XmlTabPage.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.XmlTextBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@@ -123,5 +213,9 @@
|
||||
private System.Windows.Forms.ListView MainListView;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private WinForms.ReadOnlyPropertyGrid MainPropertyGrid;
|
||||
private System.Windows.Forms.TabControl MainTabControl;
|
||||
private System.Windows.Forms.TabPage DetailsTabPage;
|
||||
private System.Windows.Forms.TabPage XmlTabPage;
|
||||
private FastColoredTextBoxNS.FastColoredTextBox XmlTextBox;
|
||||
}
|
||||
}
|
||||
+109
-23
@@ -1,4 +1,5 @@
|
||||
using CodeWalker.GameFiles;
|
||||
using FastColoredTextBoxNS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -29,6 +30,8 @@ namespace CodeWalker.Forms
|
||||
}
|
||||
public string FilePath { get; set; }
|
||||
|
||||
private bool LoadingXml = false;
|
||||
private bool DelayHighlight = false;
|
||||
|
||||
|
||||
public YcdForm()
|
||||
@@ -43,30 +46,7 @@ namespace CodeWalker.Forms
|
||||
|
||||
private void ExportOnim_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MainListView.SelectedItems[0].Tag is Animation anim)
|
||||
{
|
||||
var saveFileDialog = new SaveFileDialog();
|
||||
|
||||
string newfn = $"{Path.GetFileNameWithoutExtension(Ycd.Name)}_{MainListView.SelectedItems[0].Text}.onim";
|
||||
|
||||
saveFileDialog.FileName = newfn;
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string path = saveFileDialog.FileName;
|
||||
|
||||
try
|
||||
{
|
||||
using (var file = File.OpenWrite(path))
|
||||
{
|
||||
Ycd.SaveOpenFormatsAnimation(anim, file);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error saving file " + path + ":\n" + ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFormTitle()
|
||||
@@ -74,6 +54,49 @@ namespace CodeWalker.Forms
|
||||
Text = fileName + " - Clip Dictionary Inspector - CodeWalker by dexyfex";
|
||||
}
|
||||
|
||||
private void UpdateXmlTextBox(string xml)
|
||||
{
|
||||
LoadingXml = true;
|
||||
XmlTextBox.Text = "";
|
||||
XmlTextBox.Language = Language.XML;
|
||||
DelayHighlight = false;
|
||||
|
||||
if (string.IsNullOrEmpty(xml))
|
||||
{
|
||||
LoadingXml = false;
|
||||
return;
|
||||
}
|
||||
//if (xml.Length > (1048576 * 5))
|
||||
//{
|
||||
// XmlTextBox.Language = Language.Custom;
|
||||
// XmlTextBox.Text = "[XML size > 10MB - Not shown due to performance limitations - Please use an external viewer for this file.]";
|
||||
// return;
|
||||
//}
|
||||
//else
|
||||
if (xml.Length > (1024 * 512))
|
||||
{
|
||||
XmlTextBox.Language = Language.Custom;
|
||||
DelayHighlight = true;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// XmlTextBox.Language = Language.XML;
|
||||
//}
|
||||
|
||||
|
||||
Cursor = Cursors.WaitCursor;
|
||||
|
||||
|
||||
|
||||
XmlTextBox.Text = xml;
|
||||
//XmlTextBox.IsChanged = false;
|
||||
XmlTextBox.ClearUndo();
|
||||
|
||||
Cursor = Cursors.Default;
|
||||
LoadingXml = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void LoadYcd(YcdFile ycd)
|
||||
{
|
||||
@@ -120,8 +143,60 @@ namespace CodeWalker.Forms
|
||||
|
||||
}
|
||||
|
||||
public void LoadXml()
|
||||
{
|
||||
if (Ycd != null)
|
||||
{
|
||||
var xml = YcdXml.GetXml(Ycd);
|
||||
UpdateXmlTextBox(xml);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void HTMLSyntaxHighlight(Range range)
|
||||
{
|
||||
try
|
||||
{
|
||||
Style BlueStyle = new TextStyle(Brushes.Blue, null, FontStyle.Regular);
|
||||
Style RedStyle = new TextStyle(Brushes.Red, null, FontStyle.Regular);
|
||||
Style MaroonStyle = new TextStyle(Brushes.Maroon, null, FontStyle.Regular);
|
||||
|
||||
//clear style of changed range
|
||||
range.ClearStyle(BlueStyle, MaroonStyle, RedStyle);
|
||||
//tag brackets highlighting
|
||||
range.SetStyle(BlueStyle, @"<|/>|</|>");
|
||||
//tag name
|
||||
range.SetStyle(MaroonStyle, @"<(?<range>[!\w]+)");
|
||||
//end of tag
|
||||
range.SetStyle(MaroonStyle, @"</(?<range>\w+)>");
|
||||
//attributes
|
||||
range.SetStyle(RedStyle, @"(?<range>\S+?)='[^']*'|(?<range>\S+)=""[^""]*""|(?<range>\S+)=\S+");
|
||||
//attribute values
|
||||
range.SetStyle(BlueStyle, @"\S+?=(?<range>'[^']*')|\S+=(?<range>""[^""]*"")|\S+=(?<range>\S+)");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
private void XmlTextBox_VisibleRangeChangedDelayed(object sender, EventArgs e)
|
||||
{
|
||||
//this approach is much faster to load, but no outlining is available
|
||||
|
||||
//highlight only visible area of text
|
||||
if (DelayHighlight)
|
||||
{
|
||||
HTMLSyntaxHighlight(XmlTextBox.VisibleRange);
|
||||
}
|
||||
}
|
||||
|
||||
private void XmlTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (!LoadingXml)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void MainListView_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (MainListView.SelectedItems.Count == 1)
|
||||
@@ -143,5 +218,16 @@ namespace CodeWalker.Forms
|
||||
//MainPropertyGrid.SelectedObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void MainTabControl_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (MainTabControl.SelectedTab == XmlTabPage)
|
||||
{
|
||||
if (string.IsNullOrEmpty(XmlTextBox.Text))
|
||||
{
|
||||
LoadXml();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,6 +117,24 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="XmlTextBox.ServiceColors" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdGYXN0Q29sb3JlZFRleHRCb3gsIFZlcnNpb249Mi4xNi4yNC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWZiOGFhMTJiOTk0ZWY2MWIMAwAAAFFTeXN0
|
||||
ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2Vu
|
||||
PWIwM2Y1ZjdmMTFkNTBhM2EFAQAAACJGYXN0Q29sb3JlZFRleHRCb3hOUy5TZXJ2aWNlQ29sb3JzBgAA
|
||||
ACg8Q29sbGFwc2VNYXJrZXJGb3JlQ29sb3I+a19fQmFja2luZ0ZpZWxkKDxDb2xsYXBzZU1hcmtlckJh
|
||||
Y2tDb2xvcj5rX19CYWNraW5nRmllbGQqPENvbGxhcHNlTWFya2VyQm9yZGVyQ29sb3I+a19fQmFja2lu
|
||||
Z0ZpZWxkJjxFeHBhbmRNYXJrZXJGb3JlQ29sb3I+a19fQmFja2luZ0ZpZWxkJjxFeHBhbmRNYXJrZXJC
|
||||
YWNrQ29sb3I+a19fQmFja2luZ0ZpZWxkKDxFeHBhbmRNYXJrZXJCb3JkZXJDb2xvcj5rX19CYWNraW5n
|
||||
RmllbGQEBAQEBAQUU3lzdGVtLkRyYXdpbmcuQ29sb3IDAAAAFFN5c3RlbS5EcmF3aW5nLkNvbG9yAwAA
|
||||
ABRTeXN0ZW0uRHJhd2luZy5Db2xvcgMAAAAUU3lzdGVtLkRyYXdpbmcuQ29sb3IDAAAAFFN5c3RlbS5E
|
||||
cmF3aW5nLkNvbG9yAwAAABRTeXN0ZW0uRHJhd2luZy5Db2xvcgMAAAACAAAABfz///8UU3lzdGVtLkRy
|
||||
YXdpbmcuQ29sb3IEAAAABG5hbWUFdmFsdWUKa25vd25Db2xvcgVzdGF0ZQEAAAAJBwcDAAAACgAAAAAA
|
||||
AAAAlgABAAH7/////P///woAAAAAAAAAAKQAAQAB+v////z///8KAAAAAAAAAACWAAEAAfn////8////
|
||||
CgAAAAAAAAAATgABAAH4/////P///woAAAAAAAAAAKQAAQAB9/////z///8KAAAAAAAAAACWAAEACw==
|
||||
</value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
||||
Reference in New Issue
Block a user