Play convertible roof animations in VehicleForm

This commit is contained in:
dexy 2019-11-21 20:26:46 +11:00
parent 7da61d36c1
commit b307cd5d47
2 changed files with 184 additions and 45 deletions

View File

@ -38,6 +38,11 @@
this.ToolsPanel = new System.Windows.Forms.Panel(); this.ToolsPanel = new System.Windows.Forms.Panel();
this.ToolsTabControl = new System.Windows.Forms.TabControl(); this.ToolsTabControl = new System.Windows.Forms.TabControl();
this.ToolsVehicleTabPage = new System.Windows.Forms.TabPage(); this.ToolsVehicleTabPage = new System.Windows.Forms.TabPage();
this.VehicleHighDetailCheckBox = new System.Windows.Forms.CheckBox();
this.VehicleNameLabel = new System.Windows.Forms.Label();
this.VehicleMakeLabel = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.VehicleModelComboBox = new System.Windows.Forms.ComboBox(); this.VehicleModelComboBox = new System.Windows.Forms.ComboBox();
this.ToolsModelsTabPage = new System.Windows.Forms.TabPage(); this.ToolsModelsTabPage = new System.Windows.Forms.TabPage();
@ -78,11 +83,13 @@
this.ToolsPanelShowButton = new System.Windows.Forms.Button(); this.ToolsPanelShowButton = new System.Windows.Forms.Button();
this.ConsolePanel = new System.Windows.Forms.Panel(); this.ConsolePanel = new System.Windows.Forms.Panel();
this.ConsoleTextBox = new CodeWalker.WinForms.TextBoxFix(); this.ConsoleTextBox = new CodeWalker.WinForms.TextBoxFix();
this.label4 = new System.Windows.Forms.Label(); this.ConvRoofPanel = new System.Windows.Forms.Panel();
this.label5 = new System.Windows.Forms.Label(); this.ConvRoofButton = new System.Windows.Forms.Button();
this.VehicleMakeLabel = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label();
this.VehicleNameLabel = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label();
this.VehicleHighDetailCheckBox = new System.Windows.Forms.CheckBox(); this.ConvRoofDictNameLabel = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.ConvRoofNameLabel = new System.Windows.Forms.Label();
this.StatusStrip.SuspendLayout(); this.StatusStrip.SuspendLayout();
this.ToolsPanel.SuspendLayout(); this.ToolsPanel.SuspendLayout();
this.ToolsTabControl.SuspendLayout(); this.ToolsTabControl.SuspendLayout();
@ -93,6 +100,7 @@
this.ToolsOptionsTabPage.SuspendLayout(); this.ToolsOptionsTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).BeginInit();
this.ConsolePanel.SuspendLayout(); this.ConsolePanel.SuspendLayout();
this.ConvRoofPanel.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// StatusStrip // StatusStrip
@ -169,6 +177,7 @@
// //
// ToolsVehicleTabPage // ToolsVehicleTabPage
// //
this.ToolsVehicleTabPage.Controls.Add(this.ConvRoofPanel);
this.ToolsVehicleTabPage.Controls.Add(this.VehicleHighDetailCheckBox); this.ToolsVehicleTabPage.Controls.Add(this.VehicleHighDetailCheckBox);
this.ToolsVehicleTabPage.Controls.Add(this.VehicleNameLabel); this.ToolsVehicleTabPage.Controls.Add(this.VehicleNameLabel);
this.ToolsVehicleTabPage.Controls.Add(this.VehicleMakeLabel); this.ToolsVehicleTabPage.Controls.Add(this.VehicleMakeLabel);
@ -183,6 +192,55 @@
this.ToolsVehicleTabPage.Text = "Vehicle"; this.ToolsVehicleTabPage.Text = "Vehicle";
this.ToolsVehicleTabPage.UseVisualStyleBackColor = true; this.ToolsVehicleTabPage.UseVisualStyleBackColor = true;
// //
// VehicleHighDetailCheckBox
//
this.VehicleHighDetailCheckBox.AutoSize = true;
this.VehicleHighDetailCheckBox.Checked = true;
this.VehicleHighDetailCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.VehicleHighDetailCheckBox.Location = new System.Drawing.Point(54, 90);
this.VehicleHighDetailCheckBox.Name = "VehicleHighDetailCheckBox";
this.VehicleHighDetailCheckBox.Size = new System.Drawing.Size(120, 17);
this.VehicleHighDetailCheckBox.TabIndex = 6;
this.VehicleHighDetailCheckBox.Text = "High detail fragment";
this.VehicleHighDetailCheckBox.UseVisualStyleBackColor = true;
this.VehicleHighDetailCheckBox.CheckedChanged += new System.EventHandler(this.VehicleHighDetailCheckBox_CheckedChanged);
//
// VehicleNameLabel
//
this.VehicleNameLabel.AutoSize = true;
this.VehicleNameLabel.Location = new System.Drawing.Point(51, 63);
this.VehicleNameLabel.Name = "VehicleNameLabel";
this.VehicleNameLabel.Size = new System.Drawing.Size(10, 13);
this.VehicleNameLabel.TabIndex = 5;
this.VehicleNameLabel.Text = "-";
//
// VehicleMakeLabel
//
this.VehicleMakeLabel.AutoSize = true;
this.VehicleMakeLabel.Location = new System.Drawing.Point(51, 41);
this.VehicleMakeLabel.Name = "VehicleMakeLabel";
this.VehicleMakeLabel.Size = new System.Drawing.Size(10, 13);
this.VehicleMakeLabel.TabIndex = 4;
this.VehicleMakeLabel.Text = "-";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(3, 63);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(38, 13);
this.label5.TabIndex = 3;
this.label5.Text = "Name:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(3, 41);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(37, 13);
this.label4.TabIndex = 2;
this.label4.Text = "Make:";
//
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
@ -675,54 +733,74 @@
this.ConsoleTextBox.Size = new System.Drawing.Size(695, 95); this.ConsoleTextBox.Size = new System.Drawing.Size(695, 95);
this.ConsoleTextBox.TabIndex = 0; this.ConsoleTextBox.TabIndex = 0;
// //
// label4 // ConvRoofPanel
// //
this.label4.AutoSize = true; this.ConvRoofPanel.Controls.Add(this.ConvRoofNameLabel);
this.label4.Location = new System.Drawing.Point(3, 41); this.ConvRoofPanel.Controls.Add(this.label8);
this.label4.Name = "label4"; this.ConvRoofPanel.Controls.Add(this.ConvRoofDictNameLabel);
this.label4.Size = new System.Drawing.Size(37, 13); this.ConvRoofPanel.Controls.Add(this.label7);
this.label4.TabIndex = 2; this.ConvRoofPanel.Controls.Add(this.label6);
this.label4.Text = "Make:"; this.ConvRoofPanel.Controls.Add(this.ConvRoofButton);
this.ConvRoofPanel.Location = new System.Drawing.Point(3, 164);
this.ConvRoofPanel.Name = "ConvRoofPanel";
this.ConvRoofPanel.Size = new System.Drawing.Size(233, 89);
this.ConvRoofPanel.TabIndex = 7;
this.ConvRoofPanel.Visible = false;
// //
// label5 // ConvRoofButton
// //
this.label5.AutoSize = true; this.ConvRoofButton.Location = new System.Drawing.Point(13, 63);
this.label5.Location = new System.Drawing.Point(3, 63); this.ConvRoofButton.Name = "ConvRoofButton";
this.label5.Name = "label5"; this.ConvRoofButton.Size = new System.Drawing.Size(75, 23);
this.label5.Size = new System.Drawing.Size(38, 13); this.ConvRoofButton.TabIndex = 0;
this.label5.TabIndex = 3; this.ConvRoofButton.Text = "Play";
this.label5.Text = "Name:"; this.ConvRoofButton.UseVisualStyleBackColor = true;
this.ConvRoofButton.Click += new System.EventHandler(this.ConvRoofButton_Click);
// //
// VehicleMakeLabel // label6
// //
this.VehicleMakeLabel.AutoSize = true; this.label6.AutoSize = true;
this.VehicleMakeLabel.Location = new System.Drawing.Point(51, 41); this.label6.Location = new System.Drawing.Point(4, 4);
this.VehicleMakeLabel.Name = "VehicleMakeLabel"; this.label6.Name = "label6";
this.VehicleMakeLabel.Size = new System.Drawing.Size(10, 13); this.label6.Size = new System.Drawing.Size(86, 13);
this.VehicleMakeLabel.TabIndex = 4; this.label6.TabIndex = 1;
this.VehicleMakeLabel.Text = "-"; this.label6.Text = "Convertible Roof";
// //
// VehicleNameLabel // label7
// //
this.VehicleNameLabel.AutoSize = true; this.label7.AutoSize = true;
this.VehicleNameLabel.Location = new System.Drawing.Point(51, 63); this.label7.Location = new System.Drawing.Point(10, 21);
this.VehicleNameLabel.Name = "VehicleNameLabel"; this.label7.Name = "label7";
this.VehicleNameLabel.Size = new System.Drawing.Size(10, 13); this.label7.Size = new System.Drawing.Size(47, 13);
this.VehicleNameLabel.TabIndex = 5; this.label7.TabIndex = 2;
this.VehicleNameLabel.Text = "-"; this.label7.Text = "Clip dict:";
// //
// VehicleHighDetailCheckBox // ConvRoofDictNameLabel
// //
this.VehicleHighDetailCheckBox.AutoSize = true; this.ConvRoofDictNameLabel.AutoSize = true;
this.VehicleHighDetailCheckBox.Checked = true; this.ConvRoofDictNameLabel.Location = new System.Drawing.Point(60, 21);
this.VehicleHighDetailCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; this.ConvRoofDictNameLabel.Name = "ConvRoofDictNameLabel";
this.VehicleHighDetailCheckBox.Location = new System.Drawing.Point(54, 90); this.ConvRoofDictNameLabel.Size = new System.Drawing.Size(124, 13);
this.VehicleHighDetailCheckBox.Name = "VehicleHighDetailCheckBox"; this.ConvRoofDictNameLabel.TabIndex = 3;
this.VehicleHighDetailCheckBox.Size = new System.Drawing.Size(120, 17); this.ConvRoofDictNameLabel.Text = "animConvRoofDictName";
this.VehicleHighDetailCheckBox.TabIndex = 6; //
this.VehicleHighDetailCheckBox.Text = "High detail fragment"; // label8
this.VehicleHighDetailCheckBox.UseVisualStyleBackColor = true; //
this.VehicleHighDetailCheckBox.CheckedChanged += new System.EventHandler(this.VehicleHighDetailCheckBox_CheckedChanged); this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(10, 41);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(27, 13);
this.label8.TabIndex = 4;
this.label8.Text = "Clip:";
//
// ConvRoofNameLabel
//
this.ConvRoofNameLabel.AutoSize = true;
this.ConvRoofNameLabel.Location = new System.Drawing.Point(40, 41);
this.ConvRoofNameLabel.Name = "ConvRoofNameLabel";
this.ConvRoofNameLabel.Size = new System.Drawing.Size(105, 13);
this.ConvRoofNameLabel.TabIndex = 5;
this.ConvRoofNameLabel.Text = "animConvRoofName";
// //
// VehicleForm // VehicleForm
// //
@ -759,6 +837,8 @@
((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).EndInit();
this.ConsolePanel.ResumeLayout(false); this.ConsolePanel.ResumeLayout(false);
this.ConsolePanel.PerformLayout(); this.ConsolePanel.PerformLayout();
this.ConvRoofPanel.ResumeLayout(false);
this.ConvRoofPanel.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -819,5 +899,12 @@
private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
private System.Windows.Forms.CheckBox VehicleHighDetailCheckBox; private System.Windows.Forms.CheckBox VehicleHighDetailCheckBox;
private System.Windows.Forms.Panel ConvRoofPanel;
private System.Windows.Forms.Label ConvRoofDictNameLabel;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button ConvRoofButton;
private System.Windows.Forms.Label ConvRoofNameLabel;
private System.Windows.Forms.Label label8;
} }
} }

View File

@ -80,6 +80,9 @@ namespace CodeWalker.Vehicles
VehicleInitData SelectedVehicleInit = null; VehicleInitData SelectedVehicleInit = null;
YftFile SelectedVehicleYft = null; YftFile SelectedVehicleYft = null;
YcdFile ConvRoofDict = null;
ClipMapEntry ConvRoofClip = null;
bool PlayConvRoofAnim = false;
@ -676,6 +679,8 @@ namespace CodeWalker.Vehicles
if (GameFileCache.VehiclesInitDict.TryGetValue(modelhash, out vid)) if (GameFileCache.VehiclesInitDict.TryGetValue(modelhash, out vid))
{ {
bool vehiclechange = SelectedVehicleHash != modelhash; bool vehiclechange = SelectedVehicleHash != modelhash;
ConvRoofDict = null;
ConvRoofClip = null;
SelectedModelHash = yfthash; SelectedModelHash = yfthash;
SelectedVehicleHash = modelhash; SelectedVehicleHash = modelhash;
SelectedVehicleInit = vid; SelectedVehicleInit = vid;
@ -688,6 +693,30 @@ namespace CodeWalker.Vehicles
LoadModel(SelectedVehicleYft, vehiclechange); LoadModel(SelectedVehicleYft, vehiclechange);
VehicleMakeLabel.Text = GlobalText.TryGetString(JenkHash.GenHash(vid.vehicleMakeName.ToLower())); VehicleMakeLabel.Text = GlobalText.TryGetString(JenkHash.GenHash(vid.vehicleMakeName.ToLower()));
VehicleNameLabel.Text = GlobalText.TryGetString(JenkHash.GenHash(vid.gameName.ToLower())); VehicleNameLabel.Text = GlobalText.TryGetString(JenkHash.GenHash(vid.gameName.ToLower()));
if (!string.IsNullOrEmpty(vid.animConvRoofDictName) && (vid.animConvRoofDictName.ToLowerInvariant() != "null"))
{
ConvRoofDictNameLabel.Text = vid.animConvRoofDictName;
ConvRoofNameLabel.Text = vid.animConvRoofName;
var ycdhash = JenkHash.GenHash(vid.animConvRoofDictName.ToLowerInvariant());
var cliphash = JenkHash.GenHash(vid.animConvRoofName?.ToLowerInvariant());
ConvRoofDict = GameFileCache.GetYcd(ycdhash);
while ((ConvRoofDict != null) && (!ConvRoofDict.Loaded))
{
Thread.Sleep(20);//kinda hacky
ConvRoofDict = GameFileCache.GetYcd(ycdhash);
}
ClipMapEntry cme = null;
ConvRoofDict?.ClipMap?.TryGetValue(cliphash, out cme);
ConvRoofClip = cme;
ConvRoofPanel.Visible = true;
}
else
{
ConvRoofPanel.Visible = false;
}
} }
else else
{ {
@ -697,6 +726,9 @@ namespace CodeWalker.Vehicles
SelectedVehicleYft = null; SelectedVehicleYft = null;
VehicleMakeLabel.Text = "-"; VehicleMakeLabel.Text = "-";
VehicleNameLabel.Text = "-"; VehicleNameLabel.Text = "-";
ConvRoofPanel.Visible = false;
ConvRoofDict = null;
ConvRoofClip = null;
} }
} }
@ -914,7 +946,13 @@ namespace CodeWalker.Vehicles
Archetype arch = null;// TryGetArchetype(hash); Archetype arch = null;// TryGetArchetype(hash);
Renderer.RenderFragment(arch, null, f, txdhash); ClipMapEntry clip = null;
if (PlayConvRoofAnim)
{
clip = ConvRoofClip;
}
Renderer.RenderFragment(arch, null, f, txdhash, clip);
//seldrwbl = f.Drawable; //seldrwbl = f.Drawable;
} }
@ -1429,5 +1467,19 @@ namespace CodeWalker.Vehicles
LoadVehicle(); LoadVehicle();
} }
private void ConvRoofButton_Click(object sender, EventArgs e)
{
if (PlayConvRoofAnim)
{
ConvRoofButton.Text = "Play";
PlayConvRoofAnim = false;
}
else
{
ConvRoofButton.Text = "Stop";
PlayConvRoofAnim = true;
}
}
} }
} }