From 494b8ddae1d9f4b09d8d67243f63d4cd04808c29 Mon Sep 17 00:00:00 2001 From: Lucas7yoshi Date: Thu, 21 Oct 2021 23:45:11 -0400 Subject: [PATCH] World selection save image as --- CodeWalker/World/WorldInfoForm.Designer.cs | 19 +++++++++++++++++-- CodeWalker/World/WorldInfoForm.cs | 15 +++++++++++++++ CodeWalker/World/WorldInfoForm.resx | 3 +++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/CodeWalker/World/WorldInfoForm.Designer.cs b/CodeWalker/World/WorldInfoForm.Designer.cs index cf5f7b6..82a5afd 100644 --- a/CodeWalker/World/WorldInfoForm.Designer.cs +++ b/CodeWalker/World/WorldInfoForm.Designer.cs @@ -49,6 +49,7 @@ namespace CodeWalker.World this.SelDrawableTexturesTreeView = new CodeWalker.WinForms.TreeViewFix(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage3 = new System.Windows.Forms.TabPage(); + this.SaveTextureButton = new System.Windows.Forms.Button(); this.SelTextureDimensionsLabel = new System.Windows.Forms.Label(); this.SelTextureMipTrackBar = new System.Windows.Forms.TrackBar(); this.SelTextureMipLabel = new System.Windows.Forms.Label(); @@ -68,6 +69,7 @@ namespace CodeWalker.World this.label1 = new System.Windows.Forms.Label(); this.label25 = new System.Windows.Forms.Label(); this.SelectionModeComboBox = new System.Windows.Forms.ComboBox(); + this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.SelectionTabControl.SuspendLayout(); this.SelectionEntityTabPage.SuspendLayout(); this.SelectionArchetypeTabPage.SuspendLayout(); @@ -313,6 +315,7 @@ namespace CodeWalker.World // // tabPage3 // + this.tabPage3.Controls.Add(this.SaveTextureButton); this.tabPage3.Controls.Add(this.SelTextureDimensionsLabel); this.tabPage3.Controls.Add(this.SelTextureMipTrackBar); this.tabPage3.Controls.Add(this.SelTextureMipLabel); @@ -329,11 +332,21 @@ namespace CodeWalker.World this.tabPage3.Text = "Texture"; this.tabPage3.UseVisualStyleBackColor = true; // + // SaveTextureButton + // + this.SaveTextureButton.Location = new System.Drawing.Point(346, 396); + this.SaveTextureButton.Name = "SaveTextureButton"; + this.SaveTextureButton.Size = new System.Drawing.Size(54, 23); + this.SaveTextureButton.TabIndex = 38; + this.SaveTextureButton.Text = "Save..."; + this.SaveTextureButton.UseVisualStyleBackColor = true; + this.SaveTextureButton.Click += new System.EventHandler(this.SaveTextureButton_Click); + // // SelTextureDimensionsLabel // this.SelTextureDimensionsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.SelTextureDimensionsLabel.AutoSize = true; - this.SelTextureDimensionsLabel.Location = new System.Drawing.Point(334, 400); + this.SelTextureDimensionsLabel.Location = new System.Drawing.Point(262, 400); this.SelTextureDimensionsLabel.Name = "SelTextureDimensionsLabel"; this.SelTextureDimensionsLabel.Size = new System.Drawing.Size(10, 13); this.SelTextureDimensionsLabel.TabIndex = 37; @@ -348,7 +361,7 @@ namespace CodeWalker.World this.SelTextureMipTrackBar.Location = new System.Drawing.Point(59, 394); this.SelTextureMipTrackBar.Maximum = 0; this.SelTextureMipTrackBar.Name = "SelTextureMipTrackBar"; - this.SelTextureMipTrackBar.Size = new System.Drawing.Size(265, 31); + this.SelTextureMipTrackBar.Size = new System.Drawing.Size(187, 31); this.SelTextureMipTrackBar.TabIndex = 36; this.SelTextureMipTrackBar.Scroll += new System.EventHandler(this.SelTextureMipTrackBar_Scroll); // @@ -639,5 +652,7 @@ namespace CodeWalker.World private System.Windows.Forms.SplitContainer splitContainer3; private System.Windows.Forms.TreeView HierarchyTreeView; private PropertyGridFix HierarchyPropertyGrid; + private System.Windows.Forms.Button SaveTextureButton; + private System.Windows.Forms.SaveFileDialog SaveFileDialog; } } \ No newline at end of file diff --git a/CodeWalker/World/WorldInfoForm.cs b/CodeWalker/World/WorldInfoForm.cs index 78fdb5f..6d9c22a 100644 --- a/CodeWalker/World/WorldInfoForm.cs +++ b/CodeWalker/World/WorldInfoForm.cs @@ -10,6 +10,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Imaging; +using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; @@ -24,6 +25,7 @@ namespace CodeWalker.World MapSelection Selection; string SelectionMode = ""; bool MouseSelectEnable = false; + Texture currentTex; // Used by save button public WorldInfoForm(WorldForm worldForm) { @@ -389,6 +391,7 @@ namespace CodeWalker.World } if (tex != null) { + currentTex = tex; int mip = 0; if (mipchange) { @@ -423,6 +426,7 @@ namespace CodeWalker.World SelTextureMipTrackBar.Value = 0; SelTextureMipTrackBar.Maximum = 0; SelTextureDimensionsLabel.Text = "-"; + currentTex = null; } } @@ -523,5 +527,16 @@ namespace CodeWalker.World var sele = HierarchyTreeView.SelectedNode?.Tag as YmapEntityDef; HierarchyPropertyGrid.SelectedObject = sele; } + + private void SaveTextureButton_Click(object sender, EventArgs e) + { + if (currentTex == null) return; + string fname = currentTex.Name + ".dds"; + SaveFileDialog.FileName = fname; + if (SaveFileDialog.ShowDialog() != DialogResult.OK) return; + string fpath = SaveFileDialog.FileName; + byte[] dds = DDSIO.GetDDSFile(currentTex); + File.WriteAllBytes(fpath, dds); + } } } diff --git a/CodeWalker/World/WorldInfoForm.resx b/CodeWalker/World/WorldInfoForm.resx index 1431f6b..c7e1c95 100644 --- a/CodeWalker/World/WorldInfoForm.resx +++ b/CodeWalker/World/WorldInfoForm.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 +