mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 23:12:59 +08:00
Added Save All textures button to selection info form
This commit is contained in:
parent
7aef6a1ec6
commit
a036d1673a
30
CodeWalker/World/WorldInfoForm.Designer.cs
generated
30
CodeWalker/World/WorldInfoForm.Designer.cs
generated
@ -70,6 +70,8 @@ namespace CodeWalker.World
|
|||||||
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.SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||||
|
this.SaveAllTexturesButton = new System.Windows.Forms.Button();
|
||||||
|
this.FolderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||||
this.SelectionTabControl.SuspendLayout();
|
this.SelectionTabControl.SuspendLayout();
|
||||||
this.SelectionEntityTabPage.SuspendLayout();
|
this.SelectionEntityTabPage.SuspendLayout();
|
||||||
this.SelectionArchetypeTabPage.SuspendLayout();
|
this.SelectionArchetypeTabPage.SuspendLayout();
|
||||||
@ -279,6 +281,8 @@ namespace CodeWalker.World
|
|||||||
//
|
//
|
||||||
// splitContainer2.Panel1
|
// splitContainer2.Panel1
|
||||||
//
|
//
|
||||||
|
this.splitContainer2.Panel1.Controls.Add(this.SaveAllTexturesButton);
|
||||||
|
this.splitContainer2.Panel1.Controls.Add(this.SaveTextureButton);
|
||||||
this.splitContainer2.Panel1.Controls.Add(this.SelDrawableTexturesTreeView);
|
this.splitContainer2.Panel1.Controls.Add(this.SelDrawableTexturesTreeView);
|
||||||
//
|
//
|
||||||
// splitContainer2.Panel2
|
// splitContainer2.Panel2
|
||||||
@ -296,7 +300,7 @@ namespace CodeWalker.World
|
|||||||
this.SelDrawableTexturesTreeView.HideSelection = false;
|
this.SelDrawableTexturesTreeView.HideSelection = false;
|
||||||
this.SelDrawableTexturesTreeView.Location = new System.Drawing.Point(0, 0);
|
this.SelDrawableTexturesTreeView.Location = new System.Drawing.Point(0, 0);
|
||||||
this.SelDrawableTexturesTreeView.Name = "SelDrawableTexturesTreeView";
|
this.SelDrawableTexturesTreeView.Name = "SelDrawableTexturesTreeView";
|
||||||
this.SelDrawableTexturesTreeView.Size = new System.Drawing.Size(300, 454);
|
this.SelDrawableTexturesTreeView.Size = new System.Drawing.Size(300, 412);
|
||||||
this.SelDrawableTexturesTreeView.TabIndex = 2;
|
this.SelDrawableTexturesTreeView.TabIndex = 2;
|
||||||
this.SelDrawableTexturesTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.SelDrawableTexturesTreeView_AfterSelect);
|
this.SelDrawableTexturesTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.SelDrawableTexturesTreeView_AfterSelect);
|
||||||
//
|
//
|
||||||
@ -315,7 +319,6 @@ 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);
|
||||||
@ -334,11 +337,13 @@ namespace CodeWalker.World
|
|||||||
//
|
//
|
||||||
// SaveTextureButton
|
// SaveTextureButton
|
||||||
//
|
//
|
||||||
this.SaveTextureButton.Location = new System.Drawing.Point(346, 396);
|
this.SaveTextureButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.SaveTextureButton.Enabled = false;
|
||||||
|
this.SaveTextureButton.Location = new System.Drawing.Point(124, 419);
|
||||||
this.SaveTextureButton.Name = "SaveTextureButton";
|
this.SaveTextureButton.Name = "SaveTextureButton";
|
||||||
this.SaveTextureButton.Size = new System.Drawing.Size(54, 23);
|
this.SaveTextureButton.Size = new System.Drawing.Size(100, 23);
|
||||||
this.SaveTextureButton.TabIndex = 38;
|
this.SaveTextureButton.TabIndex = 4;
|
||||||
this.SaveTextureButton.Text = "Save...";
|
this.SaveTextureButton.Text = "Save Selected...";
|
||||||
this.SaveTextureButton.UseVisualStyleBackColor = true;
|
this.SaveTextureButton.UseVisualStyleBackColor = true;
|
||||||
this.SaveTextureButton.Click += new System.EventHandler(this.SaveTextureButton_Click);
|
this.SaveTextureButton.Click += new System.EventHandler(this.SaveTextureButton_Click);
|
||||||
//
|
//
|
||||||
@ -566,6 +571,17 @@ namespace CodeWalker.World
|
|||||||
this.SelectionModeComboBox.TabIndex = 31;
|
this.SelectionModeComboBox.TabIndex = 31;
|
||||||
this.SelectionModeComboBox.SelectedIndexChanged += new System.EventHandler(this.SelectionModeComboBox_SelectedIndexChanged);
|
this.SelectionModeComboBox.SelectedIndexChanged += new System.EventHandler(this.SelectionModeComboBox_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
|
// SaveAllTexturesButton
|
||||||
|
//
|
||||||
|
this.SaveAllTexturesButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.SaveAllTexturesButton.Location = new System.Drawing.Point(3, 419);
|
||||||
|
this.SaveAllTexturesButton.Name = "SaveAllTexturesButton";
|
||||||
|
this.SaveAllTexturesButton.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.SaveAllTexturesButton.TabIndex = 3;
|
||||||
|
this.SaveAllTexturesButton.Text = "Save All...";
|
||||||
|
this.SaveAllTexturesButton.UseVisualStyleBackColor = true;
|
||||||
|
this.SaveAllTexturesButton.Click += new System.EventHandler(this.SaveAllTexturesButton_Click);
|
||||||
|
//
|
||||||
// WorldInfoForm
|
// WorldInfoForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
@ -654,5 +670,7 @@ namespace CodeWalker.World
|
|||||||
private PropertyGridFix HierarchyPropertyGrid;
|
private PropertyGridFix HierarchyPropertyGrid;
|
||||||
private System.Windows.Forms.Button SaveTextureButton;
|
private System.Windows.Forms.Button SaveTextureButton;
|
||||||
private System.Windows.Forms.SaveFileDialog SaveFileDialog;
|
private System.Windows.Forms.SaveFileDialog SaveFileDialog;
|
||||||
|
private System.Windows.Forms.Button SaveAllTexturesButton;
|
||||||
|
private System.Windows.Forms.FolderBrowserDialog FolderBrowserDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -345,13 +345,60 @@ namespace CodeWalker.World
|
|||||||
Texture tex = texbase as Texture;
|
Texture tex = texbase as Texture;
|
||||||
YtdFile ytd = null;
|
YtdFile ytd = null;
|
||||||
string errstr = string.Empty;
|
string errstr = string.Empty;
|
||||||
if ((tex == null)&&(texbase!=null))
|
if ((tex == null) && (texbase != null))
|
||||||
|
{
|
||||||
|
tex = TryGetTexture(texbase, out ytd, ref errstr);
|
||||||
|
}
|
||||||
|
if (tex != null)
|
||||||
|
{
|
||||||
|
currentTex = tex;
|
||||||
|
int mip = 0;
|
||||||
|
if (mipchange)
|
||||||
|
{
|
||||||
|
mip = SelTextureMipTrackBar.Value;
|
||||||
|
if (mip >= tex.Levels) mip = tex.Levels - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelTextureMipTrackBar.Maximum = tex.Levels - 1;
|
||||||
|
}
|
||||||
|
DisplayTexture(tex, mip);
|
||||||
|
|
||||||
|
|
||||||
|
//try get owner drawable to get the name for the dictionary textbox...
|
||||||
|
object owner = null;
|
||||||
|
if (Selection.Drawable != null)
|
||||||
|
{
|
||||||
|
owner = Selection.Drawable.Owner;
|
||||||
|
}
|
||||||
|
YdrFile ydr = owner as YdrFile;
|
||||||
|
YddFile ydd = owner as YddFile;
|
||||||
|
YftFile yft = owner as YftFile;
|
||||||
|
|
||||||
|
SelTextureNameTextBox.Text = tex.Name;
|
||||||
|
SelTextureDictionaryTextBox.Text = (ytd != null) ? ytd.Name : (ydr != null) ? ydr.Name : (ydd != null) ? ydd.Name : (yft != null) ? yft.Name : string.Empty;
|
||||||
|
SaveTextureButton.Enabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelDrawableTexturePictureBox.Image = null;
|
||||||
|
SelTextureNameTextBox.Text = errstr;
|
||||||
|
SelTextureDictionaryTextBox.Text = string.Empty;
|
||||||
|
SelTextureMipTrackBar.Value = 0;
|
||||||
|
SelTextureMipTrackBar.Maximum = 0;
|
||||||
|
SelTextureDimensionsLabel.Text = "-";
|
||||||
|
SaveTextureButton.Enabled = false;
|
||||||
|
currentTex = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Texture TryGetTexture(TextureBase texbase, out YtdFile ytd, ref string errstr)
|
||||||
{
|
{
|
||||||
//need to load from txd.
|
//need to load from txd.
|
||||||
var arch = Selection.Archetype;
|
var arch = Selection.Archetype;
|
||||||
uint texhash = texbase.NameHash;
|
uint texhash = texbase.NameHash;
|
||||||
uint txdHash = (arch != null) ? arch.TextureDict.Hash : 0;
|
uint txdHash = (arch != null) ? arch.TextureDict.Hash : 0;
|
||||||
tex = TryGetTextureFromYtd(texhash, txdHash, out ytd);
|
var tex = TryGetTextureFromYtd(texhash, txdHash, out ytd);
|
||||||
if (tex == null)
|
if (tex == null)
|
||||||
{ //search parent ytds...
|
{ //search parent ytds...
|
||||||
uint ptxdhash = WorldForm.GameFileCache.TryGetParentYtdHash(txdHash);
|
uint ptxdhash = WorldForm.GameFileCache.TryGetParentYtdHash(txdHash);
|
||||||
@ -388,46 +435,7 @@ namespace CodeWalker.World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return tex;
|
||||||
if (tex != null)
|
|
||||||
{
|
|
||||||
currentTex = tex;
|
|
||||||
int mip = 0;
|
|
||||||
if (mipchange)
|
|
||||||
{
|
|
||||||
mip = SelTextureMipTrackBar.Value;
|
|
||||||
if (mip >= tex.Levels) mip = tex.Levels - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SelTextureMipTrackBar.Maximum = tex.Levels - 1;
|
|
||||||
}
|
|
||||||
DisplayTexture(tex, mip);
|
|
||||||
|
|
||||||
|
|
||||||
//try get owner drawable to get the name for the dictionary textbox...
|
|
||||||
object owner = null;
|
|
||||||
if (Selection.Drawable != null)
|
|
||||||
{
|
|
||||||
owner = Selection.Drawable.Owner;
|
|
||||||
}
|
|
||||||
YdrFile ydr = owner as YdrFile;
|
|
||||||
YddFile ydd = owner as YddFile;
|
|
||||||
YftFile yft = owner as YftFile;
|
|
||||||
|
|
||||||
SelTextureNameTextBox.Text = tex.Name;
|
|
||||||
SelTextureDictionaryTextBox.Text = (ytd != null) ? ytd.Name : (ydr != null) ? ydr.Name : (ydd != null) ? ydd.Name : (yft != null) ? yft.Name : string.Empty;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SelDrawableTexturePictureBox.Image = null;
|
|
||||||
SelTextureNameTextBox.Text = errstr;
|
|
||||||
SelTextureDictionaryTextBox.Text = string.Empty;
|
|
||||||
SelTextureMipTrackBar.Value = 0;
|
|
||||||
SelTextureMipTrackBar.Maximum = 0;
|
|
||||||
SelTextureDimensionsLabel.Text = "-";
|
|
||||||
currentTex = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Texture TryGetTextureFromYtd(uint texHash, uint txdHash, out YtdFile ytd)
|
private Texture TryGetTextureFromYtd(uint texHash, uint txdHash, out YtdFile ytd)
|
||||||
@ -528,6 +536,46 @@ namespace CodeWalker.World
|
|||||||
HierarchyPropertyGrid.SelectedObject = sele;
|
HierarchyPropertyGrid.SelectedObject = sele;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SaveAllTexturesButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (FolderBrowserDialog.ShowDialog() != DialogResult.OK) return;
|
||||||
|
string folderpath = FolderBrowserDialog.SelectedPath;
|
||||||
|
if (!folderpath.EndsWith("\\")) folderpath += "\\";
|
||||||
|
|
||||||
|
var texs = new List<Texture>();
|
||||||
|
foreach (TreeNode modelnode in SelDrawableTexturesTreeView.Nodes)
|
||||||
|
{
|
||||||
|
foreach (TreeNode geomnode in modelnode.Nodes)
|
||||||
|
{
|
||||||
|
foreach (TreeNode texnode in geomnode.Nodes)
|
||||||
|
{
|
||||||
|
var texbase = texnode.Tag as TextureBase;
|
||||||
|
var tex = texbase as Texture;
|
||||||
|
string errstr = "";
|
||||||
|
if ((tex == null) && (texbase != null))
|
||||||
|
{
|
||||||
|
tex = TryGetTexture(texbase, out _, ref errstr);
|
||||||
|
}
|
||||||
|
if (tex != null)
|
||||||
|
{
|
||||||
|
if (!texs.Contains(tex))
|
||||||
|
{
|
||||||
|
texs.Add(tex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var tex in texs)
|
||||||
|
{
|
||||||
|
string fpath = folderpath + tex.Name + ".dds";
|
||||||
|
byte[] dds = DDSIO.GetDDSFile(tex);
|
||||||
|
File.WriteAllBytes(fpath, dds);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void SaveTextureButton_Click(object sender, EventArgs e)
|
private void SaveTextureButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (currentTex == null) return;
|
if (currentTex == null) return;
|
||||||
|
@ -120,6 +120,9 @@
|
|||||||
<metadata name="SaveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="SaveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="FolderBrowserDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>148, 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>
|
||||||
|
Loading…
Reference in New Issue
Block a user