From cda768eb2211ea669026d5f418543a2ce494996a Mon Sep 17 00:00:00 2001 From: dexyfex Date: Sat, 17 Mar 2018 02:24:21 +1100 Subject: [PATCH] Button in model viewer to open embedded texture dict in YTD viewer --- Forms/ModelForm.Designer.cs | 17 +++++++++++++++-- Forms/ModelForm.cs | 32 ++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Forms/ModelForm.Designer.cs b/Forms/ModelForm.Designer.cs index f8ed482..40e2d81 100644 --- a/Forms/ModelForm.Designer.cs +++ b/Forms/ModelForm.Designer.cs @@ -73,6 +73,7 @@ this.ToolsPanelHideButton = new System.Windows.Forms.Button(); this.ToolsDragPanel = new System.Windows.Forms.Panel(); this.ToolsPanelShowButton = new System.Windows.Forms.Button(); + this.TextureViewerButton = new System.Windows.Forms.Button(); this.StatusStrip.SuspendLayout(); this.ConsolePanel.SuspendLayout(); this.ToolsPanel.SuspendLayout(); @@ -207,6 +208,7 @@ // // ToolsTexturesTabPage // + this.ToolsTexturesTabPage.Controls.Add(this.TextureViewerButton); this.ToolsTexturesTabPage.Controls.Add(this.TexturesTreeView); this.ToolsTexturesTabPage.Location = new System.Drawing.Point(4, 22); this.ToolsTexturesTabPage.Name = "ToolsTexturesTabPage"; @@ -221,10 +223,10 @@ this.TexturesTreeView.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.TexturesTreeView.Location = new System.Drawing.Point(0, 3); + this.TexturesTreeView.Location = new System.Drawing.Point(0, 34); this.TexturesTreeView.Name = "TexturesTreeView"; this.TexturesTreeView.ShowRootLines = false; - this.TexturesTreeView.Size = new System.Drawing.Size(205, 497); + this.TexturesTreeView.Size = new System.Drawing.Size(205, 466); this.TexturesTreeView.TabIndex = 1; // // ToolsDetailsTabPage @@ -600,6 +602,16 @@ this.ToolsPanelShowButton.UseVisualStyleBackColor = true; this.ToolsPanelShowButton.Click += new System.EventHandler(this.ToolsPanelShowButton_Click); // + // TextureViewerButton + // + this.TextureViewerButton.Location = new System.Drawing.Point(6, 6); + this.TextureViewerButton.Name = "TextureViewerButton"; + this.TextureViewerButton.Size = new System.Drawing.Size(113, 23); + this.TextureViewerButton.TabIndex = 2; + this.TextureViewerButton.Text = "Open texture viewer"; + this.TextureViewerButton.UseVisualStyleBackColor = true; + this.TextureViewerButton.Click += new System.EventHandler(this.TextureViewerButton_Click); + // // ModelForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -683,5 +695,6 @@ private System.Windows.Forms.Label label19; private System.Windows.Forms.TrackBar TimeOfDayTrackBar; private System.Windows.Forms.CheckBox SkeletonsCheckBox; + private System.Windows.Forms.Button TextureViewerButton; } } \ No newline at end of file diff --git a/Forms/ModelForm.cs b/Forms/ModelForm.cs index 15f3db5..d95e9d4 100644 --- a/Forms/ModelForm.cs +++ b/Forms/ModelForm.cs @@ -533,12 +533,6 @@ namespace CodeWalker.Forms Renderer.RenderCollisionMesh(Ybn.Bounds, null); } } - else if (Ypt != null) - { - if (Ypt.Loaded) - { - } - } else if (Ynv != null) { if (Ynv.Loaded) @@ -1512,5 +1506,31 @@ namespace CodeWalker.Forms { StatusStrip.Visible = StatusBarCheckBox.Checked; } + + private void TextureViewerButton_Click(object sender, EventArgs e) + { + TextureDictionary td = null; + + if ((Ydr != null) && (Ydr.Loaded)) + { + td = Ydr.Drawable?.ShaderGroup?.TextureDictionary; + } + else if ((Yft != null) && (Yft.Loaded)) + { + td = Yft.Fragment?.Drawable?.ShaderGroup?.TextureDictionary; + } + + if (td != null) + { + YtdForm f = new YtdForm(); + f.Show(); + f.LoadTexDict(td, fileName); + //f.LoadYtd(ytd); + } + else + { + MessageBox.Show("Couldn't find embedded texture dict."); + } + } } }