mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-14 23:04:52 +08:00
Added ability to manually select animations in ModelForm
This commit is contained in:
Generated
+79
-6
@@ -82,6 +82,11 @@
|
||||
this.ToolsDragPanel = new System.Windows.Forms.Panel();
|
||||
this.ToolsPanelShowButton = new System.Windows.Forms.Button();
|
||||
this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.EnableRootMotionCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.label22 = new System.Windows.Forms.Label();
|
||||
this.ClipComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.label21 = new System.Windows.Forms.Label();
|
||||
this.ClipDictComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.StatusStrip.SuspendLayout();
|
||||
this.ConsolePanel.SuspendLayout();
|
||||
this.ToolsPanel.SuspendLayout();
|
||||
@@ -172,7 +177,7 @@
|
||||
this.ToolsPanel.Controls.Add(this.ToolsDragPanel);
|
||||
this.ToolsPanel.Location = new System.Drawing.Point(12, 12);
|
||||
this.ToolsPanel.Name = "ToolsPanel";
|
||||
this.ToolsPanel.Size = new System.Drawing.Size(218, 559);
|
||||
this.ToolsPanel.Size = new System.Drawing.Size(230, 559);
|
||||
this.ToolsPanel.TabIndex = 2;
|
||||
this.ToolsPanel.Visible = false;
|
||||
//
|
||||
@@ -181,7 +186,7 @@
|
||||
this.MainToolbarPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.MainToolbarPanel.BackColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.MainToolbarPanel.Controls.Add(this.MainToolbar);
|
||||
this.MainToolbarPanel.Location = new System.Drawing.Point(181, 2);
|
||||
this.MainToolbarPanel.Location = new System.Drawing.Point(193, 2);
|
||||
this.MainToolbarPanel.Name = "MainToolbarPanel";
|
||||
this.MainToolbarPanel.Size = new System.Drawing.Size(34, 24);
|
||||
this.MainToolbarPanel.TabIndex = 4;
|
||||
@@ -238,16 +243,21 @@
|
||||
this.ToolsTabControl.Location = new System.Drawing.Point(2, 30);
|
||||
this.ToolsTabControl.Name = "ToolsTabControl";
|
||||
this.ToolsTabControl.SelectedIndex = 0;
|
||||
this.ToolsTabControl.Size = new System.Drawing.Size(213, 526);
|
||||
this.ToolsTabControl.Size = new System.Drawing.Size(225, 526);
|
||||
this.ToolsTabControl.TabIndex = 1;
|
||||
//
|
||||
// ToolsModelsTabPage
|
||||
//
|
||||
this.ToolsModelsTabPage.Controls.Add(this.EnableRootMotionCheckBox);
|
||||
this.ToolsModelsTabPage.Controls.Add(this.label22);
|
||||
this.ToolsModelsTabPage.Controls.Add(this.ClipComboBox);
|
||||
this.ToolsModelsTabPage.Controls.Add(this.label21);
|
||||
this.ToolsModelsTabPage.Controls.Add(this.ClipDictComboBox);
|
||||
this.ToolsModelsTabPage.Controls.Add(this.ModelsTreeView);
|
||||
this.ToolsModelsTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.ToolsModelsTabPage.Name = "ToolsModelsTabPage";
|
||||
this.ToolsModelsTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.ToolsModelsTabPage.Size = new System.Drawing.Size(205, 500);
|
||||
this.ToolsModelsTabPage.Size = new System.Drawing.Size(217, 500);
|
||||
this.ToolsModelsTabPage.TabIndex = 0;
|
||||
this.ToolsModelsTabPage.Text = "Models";
|
||||
this.ToolsModelsTabPage.UseVisualStyleBackColor = true;
|
||||
@@ -261,7 +271,7 @@
|
||||
this.ModelsTreeView.Location = new System.Drawing.Point(0, 3);
|
||||
this.ModelsTreeView.Name = "ModelsTreeView";
|
||||
this.ModelsTreeView.ShowRootLines = false;
|
||||
this.ModelsTreeView.Size = new System.Drawing.Size(205, 497);
|
||||
this.ModelsTreeView.Size = new System.Drawing.Size(217, 422);
|
||||
this.ModelsTreeView.TabIndex = 1;
|
||||
this.ModelsTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.ModelsTreeView_AfterCheck);
|
||||
this.ModelsTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.ModelsTreeView_NodeMouseDoubleClick);
|
||||
@@ -680,7 +690,7 @@
|
||||
this.ToolsDragPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ToolsDragPanel.Cursor = System.Windows.Forms.Cursors.VSplit;
|
||||
this.ToolsDragPanel.Location = new System.Drawing.Point(215, 0);
|
||||
this.ToolsDragPanel.Location = new System.Drawing.Point(227, 0);
|
||||
this.ToolsDragPanel.Name = "ToolsDragPanel";
|
||||
this.ToolsDragPanel.Size = new System.Drawing.Size(4, 559);
|
||||
this.ToolsDragPanel.TabIndex = 17;
|
||||
@@ -702,6 +712,63 @@
|
||||
//
|
||||
this.SaveFileDialog.Filter = "All files|*.*";
|
||||
//
|
||||
// EnableRootMotionCheckBox
|
||||
//
|
||||
this.EnableRootMotionCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.EnableRootMotionCheckBox.AutoSize = true;
|
||||
this.EnableRootMotionCheckBox.Location = new System.Drawing.Point(50, 483);
|
||||
this.EnableRootMotionCheckBox.Name = "EnableRootMotionCheckBox";
|
||||
this.EnableRootMotionCheckBox.Size = new System.Drawing.Size(114, 17);
|
||||
this.EnableRootMotionCheckBox.TabIndex = 37;
|
||||
this.EnableRootMotionCheckBox.Text = "Enable root motion";
|
||||
this.EnableRootMotionCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label22
|
||||
//
|
||||
this.label22.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.label22.AutoSize = true;
|
||||
this.label22.Location = new System.Drawing.Point(23, 461);
|
||||
this.label22.Name = "label22";
|
||||
this.label22.Size = new System.Drawing.Size(27, 13);
|
||||
this.label22.TabIndex = 36;
|
||||
this.label22.Text = "Clip:";
|
||||
//
|
||||
// ClipComboBox
|
||||
//
|
||||
this.ClipComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ClipComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
|
||||
this.ClipComboBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
|
||||
this.ClipComboBox.FormattingEnabled = true;
|
||||
this.ClipComboBox.Location = new System.Drawing.Point(50, 458);
|
||||
this.ClipComboBox.Name = "ClipComboBox";
|
||||
this.ClipComboBox.Size = new System.Drawing.Size(167, 21);
|
||||
this.ClipComboBox.TabIndex = 35;
|
||||
this.ClipComboBox.TextChanged += new System.EventHandler(this.ClipComboBox_TextChanged);
|
||||
//
|
||||
// label21
|
||||
//
|
||||
this.label21.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.label21.AutoSize = true;
|
||||
this.label21.Location = new System.Drawing.Point(1, 434);
|
||||
this.label21.Name = "label21";
|
||||
this.label21.Size = new System.Drawing.Size(49, 13);
|
||||
this.label21.TabIndex = 34;
|
||||
this.label21.Text = "Clip Dict:";
|
||||
//
|
||||
// ClipDictComboBox
|
||||
//
|
||||
this.ClipDictComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ClipDictComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
|
||||
this.ClipDictComboBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
|
||||
this.ClipDictComboBox.FormattingEnabled = true;
|
||||
this.ClipDictComboBox.Location = new System.Drawing.Point(50, 431);
|
||||
this.ClipDictComboBox.Name = "ClipDictComboBox";
|
||||
this.ClipDictComboBox.Size = new System.Drawing.Size(167, 21);
|
||||
this.ClipDictComboBox.TabIndex = 33;
|
||||
this.ClipDictComboBox.TextChanged += new System.EventHandler(this.ClipDictComboBox_TextChanged);
|
||||
//
|
||||
// ModelForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -734,6 +801,7 @@
|
||||
this.MainToolbar.PerformLayout();
|
||||
this.ToolsTabControl.ResumeLayout(false);
|
||||
this.ToolsModelsTabPage.ResumeLayout(false);
|
||||
this.ToolsModelsTabPage.PerformLayout();
|
||||
this.ToolsMaterialsTabPage.ResumeLayout(false);
|
||||
this.ToolsDetailsTabPage.ResumeLayout(false);
|
||||
this.ToolsOptionsTabPage.ResumeLayout(false);
|
||||
@@ -798,5 +866,10 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem SaveMenuButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem SaveAsMenuButton;
|
||||
private System.Windows.Forms.SaveFileDialog SaveFileDialog;
|
||||
private System.Windows.Forms.CheckBox EnableRootMotionCheckBox;
|
||||
private System.Windows.Forms.Label label22;
|
||||
private System.Windows.Forms.ComboBox ClipComboBox;
|
||||
private System.Windows.Forms.Label label21;
|
||||
private System.Windows.Forms.ComboBox ClipDictComboBox;
|
||||
}
|
||||
}
|
||||
+142
-22
@@ -101,12 +101,20 @@ namespace CodeWalker.Forms
|
||||
|
||||
|
||||
ModelMatForm materialForm = null;
|
||||
private bool modelModified = false;
|
||||
bool modelModified = false;
|
||||
|
||||
ExploreForm exploreForm = null;
|
||||
RpfFileEntry rpfFileEntry = null;
|
||||
|
||||
|
||||
bool animsInited = false;
|
||||
YcdFile Ycd = null;
|
||||
ClipMapEntry AnimClip = null;
|
||||
|
||||
MetaHash ModelHash;
|
||||
Archetype ModelArchetype = null;
|
||||
|
||||
|
||||
|
||||
public ModelForm(ExploreForm ExpForm = null)
|
||||
{
|
||||
@@ -314,6 +322,11 @@ namespace CodeWalker.Forms
|
||||
timecycle.SetTime(Renderer.timeofday);
|
||||
//UpdateStatus("Timecycles loaded.");
|
||||
}
|
||||
if (!animsInited)
|
||||
{
|
||||
InitAnimation();
|
||||
animsInited = true;
|
||||
}
|
||||
if (Renderer.renderskydome)
|
||||
{
|
||||
if (!weather.Inited)
|
||||
@@ -355,6 +368,35 @@ namespace CodeWalker.Forms
|
||||
|
||||
|
||||
|
||||
private void InitAnimation()
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
BeginInvoke(new Action(() => { InitAnimation(); }));
|
||||
}
|
||||
else
|
||||
{
|
||||
ClipComboBox.Items.Clear();
|
||||
ClipDictComboBox.Items.Clear();
|
||||
var ycds = gameFileCache.YcdDict.Values.ToList();
|
||||
ycds.Sort((a, b) => { return a.Name.CompareTo(b.Name); });
|
||||
ClipDictComboBox.AutoCompleteCustomSource.Clear();
|
||||
List<string> ycdlist = new List<string>();
|
||||
foreach (var ycde in ycds)
|
||||
{
|
||||
ycdlist.Add(ycde.GetShortName());
|
||||
}
|
||||
ClipDictComboBox.AutoCompleteCustomSource.AddRange(ycdlist.ToArray());
|
||||
ClipDictComboBox.Text = "";
|
||||
|
||||
TrySelectClipDict();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
@@ -479,17 +521,13 @@ namespace CodeWalker.Forms
|
||||
private void RenderSingleItem()
|
||||
{
|
||||
|
||||
uint hash = 0;
|
||||
Archetype arch = null;
|
||||
|
||||
if (Ydr != null)
|
||||
{
|
||||
if (Ydr.Loaded)
|
||||
{
|
||||
hash = Ydr?.RpfFileEntry?.ShortNameHash ?? 0;
|
||||
arch = TryGetArchetype(hash);
|
||||
if (ModelArchetype == null) ModelArchetype = TryGetArchetype(ModelHash);
|
||||
|
||||
Renderer.RenderDrawable(Ydr.Drawable, arch, null, hash);
|
||||
Renderer.RenderDrawable(Ydr.Drawable, ModelArchetype, null, ModelHash, null, null, AnimClip);
|
||||
}
|
||||
}
|
||||
else if (Ydd != null)
|
||||
@@ -501,9 +539,9 @@ namespace CodeWalker.Forms
|
||||
{
|
||||
if (!DrawableDrawFlags.ContainsKey(kvp.Value))//only render if it's checked...
|
||||
{
|
||||
arch = TryGetArchetype(kvp.Key);
|
||||
var arch = TryGetArchetype(kvp.Key);
|
||||
|
||||
Renderer.RenderDrawable(kvp.Value, arch, null, Ydd.RpfFileEntry.ShortNameHash);
|
||||
Renderer.RenderDrawable(kvp.Value, arch, null, Ydd.RpfFileEntry.ShortNameHash, null, null, AnimClip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -516,9 +554,9 @@ namespace CodeWalker.Forms
|
||||
{
|
||||
if (!DrawableDrawFlags.ContainsKey(kvp.Value))//only render if it's checked...
|
||||
{
|
||||
arch = TryGetArchetype(kvp.Key);
|
||||
if (ModelArchetype == null) ModelArchetype = TryGetArchetype(kvp.Key);
|
||||
|
||||
Renderer.RenderDrawable(kvp.Value, arch, null, kvp.Key);
|
||||
Renderer.RenderDrawable(kvp.Value, ModelArchetype, null, kvp.Key, null, null, AnimClip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,17 +569,9 @@ namespace CodeWalker.Forms
|
||||
{
|
||||
var f = Yft.Fragment;
|
||||
|
||||
hash = Yft.RpfFileEntry?.ShortNameHash ?? 0;
|
||||
if (ModelArchetype == null) ModelArchetype = TryGetArchetype(ModelHash);
|
||||
|
||||
var namelower = Yft.RpfFileEntry?.GetShortNameLower();
|
||||
if (namelower?.EndsWith("_hi") ?? false)
|
||||
{
|
||||
hash = JenkHash.GenHash(namelower.Substring(0, namelower.Length - 3));
|
||||
}
|
||||
|
||||
arch = TryGetArchetype(hash);
|
||||
|
||||
Renderer.RenderFragment(arch, null, f, hash);
|
||||
Renderer.RenderFragment(ModelArchetype, null, f, ModelHash, AnimClip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -577,6 +607,11 @@ namespace CodeWalker.Forms
|
||||
FileName = ydr.Name;
|
||||
Ydr = ydr;
|
||||
rpfFileEntry = Ydr.RpfFileEntry;
|
||||
ModelHash = Ydr.RpfFileEntry?.ShortNameHash ?? 0;
|
||||
if (ModelHash != 0)
|
||||
{
|
||||
ModelArchetype = TryGetArchetype(ModelHash);
|
||||
}
|
||||
|
||||
if (ydr.Drawable != null)
|
||||
{
|
||||
@@ -614,6 +649,17 @@ namespace CodeWalker.Forms
|
||||
FileName = yft.Name;
|
||||
Yft = yft;
|
||||
rpfFileEntry = Yft.RpfFileEntry;
|
||||
ModelHash = Yft.RpfFileEntry?.ShortNameHash ?? 0;
|
||||
var namelower = Yft.RpfFileEntry?.GetShortNameLower();
|
||||
if (namelower?.EndsWith("_hi") ?? false)
|
||||
{
|
||||
ModelHash = JenkHash.GenHash(namelower.Substring(0, namelower.Length - 3));
|
||||
}
|
||||
if (ModelHash != 0)
|
||||
{
|
||||
ModelArchetype = TryGetArchetype(ModelHash);
|
||||
}
|
||||
|
||||
|
||||
var dr = yft.Fragment?.Drawable;
|
||||
if (dr != null)
|
||||
@@ -680,7 +726,14 @@ namespace CodeWalker.Forms
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void TrySelectClipDict()
|
||||
{
|
||||
if (ModelArchetype != null)
|
||||
{
|
||||
var str = ModelArchetype.ClipDict.ToCleanString();
|
||||
ClipDictComboBox.Text = str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -728,6 +781,63 @@ namespace CodeWalker.Forms
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void LoadClipDict(string name)
|
||||
{
|
||||
if (gameFileCache == null) return;
|
||||
if (!gameFileCache.IsInited) return;//what to do here? wait for it..?
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Ycd = ycd;
|
||||
|
||||
ClipComboBox.Items.Clear();
|
||||
ClipComboBox.Items.Add("");
|
||||
|
||||
if (ycd?.ClipMapEntries == null)
|
||||
{
|
||||
ClipComboBox.SelectedIndex = 0;
|
||||
AnimClip = null;
|
||||
return;
|
||||
}
|
||||
|
||||
List<string> items = new List<string>();
|
||||
foreach (var cme in ycd.ClipMapEntries)
|
||||
{
|
||||
if (cme.Clip != null)
|
||||
{
|
||||
items.Add(cme.Clip.ShortName);
|
||||
}
|
||||
}
|
||||
|
||||
items.Sort();
|
||||
foreach (var item in items)
|
||||
{
|
||||
ClipComboBox.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectClip(string name)
|
||||
{
|
||||
MetaHash cliphash = JenkHash.GenHash(name);
|
||||
ClipMapEntry cme = null;
|
||||
Ycd?.ClipMap?.TryGetValue(cliphash, out cme);
|
||||
AnimClip = cme;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void UpdateTimeOfDayLabel()
|
||||
{
|
||||
int v = TimeOfDayTrackBar.Value;
|
||||
@@ -1865,5 +1975,15 @@ namespace CodeWalker.Forms
|
||||
{
|
||||
Save(true);
|
||||
}
|
||||
|
||||
private void ClipDictComboBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
LoadClipDict(ClipDictComboBox.Text);
|
||||
}
|
||||
|
||||
private void ClipComboBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
SelectClip(ClipComboBox.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user