Animations XML conversion

This commit is contained in:
dexy
2019-11-14 18:58:20 +11:00
Unverified
parent 918ed7fccf
commit 7e43271a67
15 changed files with 2996 additions and 737 deletions
+14
View File
@@ -108,6 +108,7 @@
this.label4 = new System.Windows.Forms.Label();
this.ToolsTabControl = new System.Windows.Forms.TabControl();
this.ToolsPanel = new System.Windows.Forms.Panel();
this.EnableRootMotionCheckBox = new System.Windows.Forms.CheckBox();
this.ConsolePanel.SuspendLayout();
this.ToolsOptionsTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).BeginInit();
@@ -656,6 +657,7 @@
//
// ToolsPedTabPage
//
this.ToolsPedTabPage.Controls.Add(this.EnableRootMotionCheckBox);
this.ToolsPedTabPage.Controls.Add(this.label23);
this.ToolsPedTabPage.Controls.Add(this.label22);
this.ToolsPedTabPage.Controls.Add(this.ClipComboBox);
@@ -1064,6 +1066,17 @@
this.ToolsPanel.TabIndex = 7;
this.ToolsPanel.Visible = false;
//
// EnableRootMotionCheckBox
//
this.EnableRootMotionCheckBox.AutoSize = true;
this.EnableRootMotionCheckBox.Location = new System.Drawing.Point(54, 503);
this.EnableRootMotionCheckBox.Name = "EnableRootMotionCheckBox";
this.EnableRootMotionCheckBox.Size = new System.Drawing.Size(114, 17);
this.EnableRootMotionCheckBox.TabIndex = 32;
this.EnableRootMotionCheckBox.Text = "Enable root motion";
this.EnableRootMotionCheckBox.UseVisualStyleBackColor = true;
this.EnableRootMotionCheckBox.CheckedChanged += new System.EventHandler(this.EnableRootMotionCheckBox_CheckedChanged);
//
// PedsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -1184,5 +1197,6 @@
private System.Windows.Forms.Label label21;
private System.Windows.Forms.ComboBox ClipDictComboBox;
private System.Windows.Forms.Label label23;
private System.Windows.Forms.CheckBox EnableRootMotionCheckBox;
}
}
+87 -55
View File
@@ -92,6 +92,7 @@ namespace CodeWalker.Peds
public ClipMapEntry AnimClip { get; set; } = null;
public Drawable[] Drawables { get; set; } = new Drawable[12];
public Texture[] Textures { get; set; } = new Texture[12];
public bool EnableRootMotion { get; set; } = false; //used to toggle whether or not to include root motion when playing animations
}
PedSelection SelectedPed = new PedSelection();
@@ -971,6 +972,80 @@ namespace CodeWalker.Peds
private void LoadClipDict(string name)
{
var ycdhash = JenkHash.GenHash(name.ToLowerInvariant());
var ycd = GameFileCache.GetYcd(ycdhash);
while ((ycd != null) && (!ycd.Loaded))
{
Thread.Sleep(20);//kinda hacky
ycd = GameFileCache.GetYcd(ycdhash);
}
//if (ycd != null)
//{
// ////// TESTING XML CONVERSIONS
// var xml = YcdXml.GetXml(ycd);
// var ycd2 = XmlYcd.GetYcd(xml);
// var data = ycd2.Save();
// var ycd3 = new YcdFile();
// RpfFile.LoadResourceFile(ycd3, data, 46);
// //var xml2 = YcdXml.GetXml(ycd3);
// //if (xml != xml2)
// //{ }
// ycd = ycd3;
//}
SelectedPed.Ycd = ycd;
ClipComboBox.Items.Clear();
ClipComboBox.Items.Add("");
if (ycd?.ClipMapEntries == null)
{
ClipComboBox.SelectedIndex = 0;
SelectedPed.AnimClip = null;
return;
}
List<string> items = new List<string>();
foreach (var cme in ycd.ClipMapEntries)
{
var animclip = cme.Clip as ClipAnimation;
if (animclip != null)
{
items.Add(animclip.ShortName);
continue;
}
var animcliplist = cme.Clip as ClipAnimationList;
if (animcliplist?.Animations?.Data != null)
{
items.Add(animcliplist.ShortName);
continue;
}
}
items.Sort();
foreach (var item in items)
{
ClipComboBox.Items.Add(item);
}
}
private void SelectClip(string name)
{
MetaHash cliphash = JenkHash.GenHash(name);
ClipMapEntry cme = null;
SelectedPed.Ycd?.ClipMap?.TryGetValue(cliphash, out cme);
SelectedPed.AnimClip = cme;
}
@@ -1193,6 +1268,10 @@ namespace CodeWalker.Peds
var td = SelectedPed.Ytd?.TextureDict;
var ac = SelectedPed.AnimClip;
if (ac != null)
{
ac.EnableRootMotion = SelectedPed.EnableRootMotion;
}
var skel = SelectedPed.Yft?.Fragment?.Drawable?.Skeleton;
if (skel != null)
@@ -1788,69 +1867,22 @@ namespace CodeWalker.Peds
private void ClipDictComboBox_TextChanged(object sender, EventArgs e)
{
var ycdhash = JenkHash.GenHash(ClipDictComboBox.Text.ToLowerInvariant());
var ycd = GameFileCache.GetYcd(ycdhash);
while ((ycd != null) && (!ycd.Loaded))
{
Thread.Sleep(20);//kinda hacky
ycd = GameFileCache.GetYcd(ycdhash);
}
SelectedPed.Ycd = ycd;
ClipComboBox.Items.Clear();
ClipComboBox.Items.Add("");
if (ycd?.ClipMapEntries == null)
{
ClipComboBox.SelectedIndex = 0;
SelectedPed.AnimClip = null;
return;
}
List<string> items = new List<string>();
foreach (var cme in ycd.ClipMapEntries)
{
var animclip = cme.Clip as ClipAnimation;
if (animclip != null)
{
items.Add(animclip.ShortName);
continue;
}
var animcliplist = cme.Clip as ClipAnimationList;
if (animcliplist?.Animations?.Data != null)
{
items.Add(animcliplist.ShortName);
continue;
}
}
items.Sort();
foreach (var item in items)
{
ClipComboBox.Items.Add(item);
}
LoadClipDict(ClipDictComboBox.Text);
}
private void ClipComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
var name = ClipComboBox.Text;
MetaHash cliphash = JenkHash.GenHash(name);
ClipMapEntry cme = null;
SelectedPed.Ycd?.ClipMap?.TryGetValue(cliphash, out cme);
SelectedPed.AnimClip = cme;
SelectClip(ClipComboBox.Text);
}
private void ClipComboBox_TextChanged(object sender, EventArgs e)
{
ClipComboBox_SelectedIndexChanged(sender, e);
SelectClip(ClipComboBox.Text);
}
private void EnableRootMotionCheckBox_CheckedChanged(object sender, EventArgs e)
{
SelectedPed.EnableRootMotion = EnableRootMotionCheckBox.Checked;
}
}
}