YCD form improvement

This commit is contained in:
dexyfex 2017-10-04 14:35:39 +11:00
parent 2e60ed5dc9
commit 2062f1e7f7
4 changed files with 135 additions and 11 deletions

View File

@ -28,36 +28,100 @@
/// </summary>
private void InitializeComponent()
{
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));
this.MainPropertyGrid = new CodeWalker.WinForms.PropertyGridFix();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.MainListView = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.MainPropertyGrid = new CodeWalker.WinForms.ReadOnlyPropertyGrid();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.MainListView);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.MainPropertyGrid);
this.splitContainer1.Size = new System.Drawing.Size(763, 474);
this.splitContainer1.SplitterDistance = 254;
this.splitContainer1.TabIndex = 1;
//
// MainListView
//
this.MainListView.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.MainListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.MainListView.FullRowSelect = true;
listViewGroup1.Header = "Clips";
listViewGroup1.Name = "Clips";
listViewGroup2.Header = "Animations";
listViewGroup2.Name = "Anims";
this.MainListView.Groups.AddRange(new System.Windows.Forms.ListViewGroup[] {
listViewGroup1,
listViewGroup2});
this.MainListView.HideSelection = false;
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.TabIndex = 0;
this.MainListView.UseCompatibleStateImageBehavior = false;
this.MainListView.View = System.Windows.Forms.View.Details;
this.MainListView.SelectedIndexChanged += new System.EventHandler(this.MainListView_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Text = "Name";
this.columnHeader1.Width = 221;
//
// MainPropertyGrid
//
this.MainPropertyGrid.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.MainPropertyGrid.HelpVisible = false;
this.MainPropertyGrid.Location = new System.Drawing.Point(12, 12);
this.MainPropertyGrid.Location = new System.Drawing.Point(3, 3);
this.MainPropertyGrid.Name = "MainPropertyGrid";
this.MainPropertyGrid.Size = new System.Drawing.Size(631, 403);
this.MainPropertyGrid.ReadOnly = false;
this.MainPropertyGrid.Size = new System.Drawing.Size(499, 468);
this.MainPropertyGrid.TabIndex = 0;
//
// YcdForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(655, 427);
this.Controls.Add(this.MainPropertyGrid);
this.ClientSize = new System.Drawing.Size(763, 474);
this.Controls.Add(this.splitContainer1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "YcdForm";
this.Text = "Clip Dictionary Inspector - CodeWalker by dexyfex";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private WinForms.PropertyGridFix MainPropertyGrid;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.ListView MainListView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private WinForms.ReadOnlyPropertyGrid MainPropertyGrid;
}
}

View File

@ -14,6 +14,8 @@ namespace CodeWalker.Forms
public partial class YcdForm : Form
{
YcdFile Ycd;
private string fileName;
public string FileName
{
@ -43,6 +45,8 @@ namespace CodeWalker.Forms
public void LoadYcd(YcdFile ycd)
{
Ycd = ycd;
fileName = ycd?.Name;
if (string.IsNullOrEmpty(fileName))
{
@ -51,11 +55,51 @@ namespace CodeWalker.Forms
UpdateFormTitle();
//MainPropertyGrid.SelectedObject = ycd;
MainListView.Items.Clear();
if (ycd?.ClipMapEntries != null)
{
foreach (var cme in ycd.ClipMapEntries)
{
if (cme != null)
{
var lvi = MainListView.Items.Add(cme.Clip?.ShortName ?? cme.Hash.ToString());
lvi.Tag = cme.Clip;
lvi.Group = MainListView.Groups["Clips"];
}
}
}
if (ycd?.AnimMapEntries != null)
{
foreach (var ame in ycd.AnimMapEntries)
{
if (ame != null)
{
var lvi = MainListView.Items.Add(ame.Hash.ToString());
lvi.Tag = ame.Animation;
lvi.Group = MainListView.Groups["Anims"];
}
}
}
MainPropertyGrid.SelectedObject = ycd;
}
private void MainListView_SelectedIndexChanged(object sender, EventArgs e)
{
if (MainListView.SelectedItems.Count == 1)
{
MainPropertyGrid.SelectedObject = MainListView.SelectedItems[0].Tag;
}
else
{
//MainPropertyGrid.SelectedObject = null;
}
}
}
}

View File

@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CodeWalker.GameFiles
{
[TypeConverter(typeof(ExpandableObjectConverter))]
public class YcdFile : GameFile, PackedFile
{
public ClipDictionary ClipDictionary { get; set; }
@ -81,11 +83,11 @@ namespace CodeWalker.GameFiles
}
}
foreach (var cme in ClipMap.Values)
{
var clip = cme.Clip;
if (clip == null) continue;
clip.Ycd = this;
if (string.IsNullOrEmpty(clip.Name)) continue;
string name = clip.Name.Replace('\\', '/');
var slidx = name.LastIndexOf('/');
@ -98,9 +100,11 @@ namespace CodeWalker.GameFiles
{
name = name.Substring(0, didx);
}
clip.ShortName = name;
name = name.ToLowerInvariant();
JenkIndex.Ensure(name);
//if (name.EndsWith("_uv_0")) //hash for these entries match string with this removed, +1
//{
//}
@ -109,6 +113,12 @@ namespace CodeWalker.GameFiles
//}
}
foreach (var ame in AnimMap.Values)
{
var anim = ame.Animation;
if (anim == null) continue;
anim.Ycd = this;
}
ClipMapEntries = ClipMap.Values.ToArray();

View File

@ -295,6 +295,9 @@ namespace CodeWalker.GameFiles
public ResourceSimpleList64Ptr BoneIdsPtr { get; set; }
public AnimationBoneId[] BoneIds { get; set; }
public YcdFile Ycd { get; set; }
public override void Read(ResourceDataReader reader, params object[] parameters)
{
// read structure data
@ -652,6 +655,9 @@ namespace CodeWalker.GameFiles
public ClipTagList Tags { get; set; }
public ClipPropertyMap Properties { get; set; }
public YcdFile Ycd { get; set; }
public string ShortName { get; set; }
public override void Read(ResourceDataReader reader, params object[] parameters)
{
// read structure data
@ -1001,7 +1007,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
return "Count: " + AllProperties?.Length.ToString() ?? "0";
return "Count: " + (AllProperties?.Length ?? 0).ToString();
}
}
[TypeConverter(typeof(ExpandableObjectConverter))] public class ClipPropertyMapEntry : ResourceSystemBlock
@ -1604,7 +1610,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
return "Count: " + AllTags?.Length.ToString() ?? "0";
return "Count: " + (AllTags?.Length ?? 0).ToString();
}
}
[TypeConverter(typeof(ExpandableObjectConverter))] public class ClipTag : ClipProperty