World selection save image as

This commit is contained in:
Lucas7yoshi 2021-10-21 23:45:11 -04:00
parent 458e9d365e
commit 494b8ddae1
3 changed files with 35 additions and 2 deletions

View File

@ -49,6 +49,7 @@ namespace CodeWalker.World
this.SelDrawableTexturesTreeView = new CodeWalker.WinForms.TreeViewFix(); this.SelDrawableTexturesTreeView = new CodeWalker.WinForms.TreeViewFix();
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage3 = new System.Windows.Forms.TabPage(); this.tabPage3 = new System.Windows.Forms.TabPage();
this.SaveTextureButton = new System.Windows.Forms.Button();
this.SelTextureDimensionsLabel = new System.Windows.Forms.Label(); this.SelTextureDimensionsLabel = new System.Windows.Forms.Label();
this.SelTextureMipTrackBar = new System.Windows.Forms.TrackBar(); this.SelTextureMipTrackBar = new System.Windows.Forms.TrackBar();
this.SelTextureMipLabel = new System.Windows.Forms.Label(); this.SelTextureMipLabel = new System.Windows.Forms.Label();
@ -68,6 +69,7 @@ namespace CodeWalker.World
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label25 = new System.Windows.Forms.Label(); this.label25 = new System.Windows.Forms.Label();
this.SelectionModeComboBox = new System.Windows.Forms.ComboBox(); this.SelectionModeComboBox = new System.Windows.Forms.ComboBox();
this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.SelectionTabControl.SuspendLayout(); this.SelectionTabControl.SuspendLayout();
this.SelectionEntityTabPage.SuspendLayout(); this.SelectionEntityTabPage.SuspendLayout();
this.SelectionArchetypeTabPage.SuspendLayout(); this.SelectionArchetypeTabPage.SuspendLayout();
@ -313,6 +315,7 @@ namespace CodeWalker.World
// //
// tabPage3 // tabPage3
// //
this.tabPage3.Controls.Add(this.SaveTextureButton);
this.tabPage3.Controls.Add(this.SelTextureDimensionsLabel); this.tabPage3.Controls.Add(this.SelTextureDimensionsLabel);
this.tabPage3.Controls.Add(this.SelTextureMipTrackBar); this.tabPage3.Controls.Add(this.SelTextureMipTrackBar);
this.tabPage3.Controls.Add(this.SelTextureMipLabel); this.tabPage3.Controls.Add(this.SelTextureMipLabel);
@ -329,11 +332,21 @@ namespace CodeWalker.World
this.tabPage3.Text = "Texture"; this.tabPage3.Text = "Texture";
this.tabPage3.UseVisualStyleBackColor = true; 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 // SelTextureDimensionsLabel
// //
this.SelTextureDimensionsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.SelTextureDimensionsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.SelTextureDimensionsLabel.AutoSize = true; 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.Name = "SelTextureDimensionsLabel";
this.SelTextureDimensionsLabel.Size = new System.Drawing.Size(10, 13); this.SelTextureDimensionsLabel.Size = new System.Drawing.Size(10, 13);
this.SelTextureDimensionsLabel.TabIndex = 37; this.SelTextureDimensionsLabel.TabIndex = 37;
@ -348,7 +361,7 @@ namespace CodeWalker.World
this.SelTextureMipTrackBar.Location = new System.Drawing.Point(59, 394); this.SelTextureMipTrackBar.Location = new System.Drawing.Point(59, 394);
this.SelTextureMipTrackBar.Maximum = 0; this.SelTextureMipTrackBar.Maximum = 0;
this.SelTextureMipTrackBar.Name = "SelTextureMipTrackBar"; 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.TabIndex = 36;
this.SelTextureMipTrackBar.Scroll += new System.EventHandler(this.SelTextureMipTrackBar_Scroll); 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.SplitContainer splitContainer3;
private System.Windows.Forms.TreeView HierarchyTreeView; private System.Windows.Forms.TreeView HierarchyTreeView;
private PropertyGridFix HierarchyPropertyGrid; private PropertyGridFix HierarchyPropertyGrid;
private System.Windows.Forms.Button SaveTextureButton;
private System.Windows.Forms.SaveFileDialog SaveFileDialog;
} }
} }

View File

@ -10,6 +10,7 @@ using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
@ -24,6 +25,7 @@ namespace CodeWalker.World
MapSelection Selection; MapSelection Selection;
string SelectionMode = ""; string SelectionMode = "";
bool MouseSelectEnable = false; bool MouseSelectEnable = false;
Texture currentTex; // Used by save button
public WorldInfoForm(WorldForm worldForm) public WorldInfoForm(WorldForm worldForm)
{ {
@ -389,6 +391,7 @@ namespace CodeWalker.World
} }
if (tex != null) if (tex != null)
{ {
currentTex = tex;
int mip = 0; int mip = 0;
if (mipchange) if (mipchange)
{ {
@ -423,6 +426,7 @@ namespace CodeWalker.World
SelTextureMipTrackBar.Value = 0; SelTextureMipTrackBar.Value = 0;
SelTextureMipTrackBar.Maximum = 0; SelTextureMipTrackBar.Maximum = 0;
SelTextureDimensionsLabel.Text = "-"; SelTextureDimensionsLabel.Text = "-";
currentTex = null;
} }
} }
@ -523,5 +527,16 @@ namespace CodeWalker.World
var sele = HierarchyTreeView.SelectedNode?.Tag as YmapEntityDef; var sele = HierarchyTreeView.SelectedNode?.Tag as YmapEntityDef;
HierarchyPropertyGrid.SelectedObject = sele; 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);
}
} }
} }

View File

@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="SaveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>