mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-01-10 07:33:04 +08:00
YTD and embedded texture editing in YtdForm, Fixed texture sorting by hash when importing XML
This commit is contained in:
parent
a4998e36c8
commit
7f0bb17e68
@ -26,6 +26,7 @@ namespace CodeWalker.GameFiles
|
|||||||
public void Load(byte[] data, RpfFileEntry entry)
|
public void Load(byte[] data, RpfFileEntry entry)
|
||||||
{
|
{
|
||||||
Name = entry.Name;
|
Name = entry.Name;
|
||||||
|
RpfFileEntry = entry;
|
||||||
|
|
||||||
|
|
||||||
RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;
|
RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;
|
||||||
|
@ -99,7 +99,6 @@ namespace CodeWalker.GameFiles
|
|||||||
public void ReadXml(XmlNode node, string ddsfolder)
|
public void ReadXml(XmlNode node, string ddsfolder)
|
||||||
{
|
{
|
||||||
var textures = new List<Texture>();
|
var textures = new List<Texture>();
|
||||||
var texturehashes = new List<uint>();
|
|
||||||
|
|
||||||
var inodes = node.SelectNodes("Item");
|
var inodes = node.SelectNodes("Item");
|
||||||
if (inodes != null)
|
if (inodes != null)
|
||||||
@ -109,15 +108,10 @@ namespace CodeWalker.GameFiles
|
|||||||
var tex = new Texture();
|
var tex = new Texture();
|
||||||
tex.ReadXml(inode, ddsfolder);
|
tex.ReadXml(inode, ddsfolder);
|
||||||
textures.Add(tex);
|
textures.Add(tex);
|
||||||
texturehashes.Add(tex.NameHash);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureNameHashes = new ResourceSimpleList64_uint();
|
BuildFromTextureList(textures);
|
||||||
TextureNameHashes.data_items = texturehashes.ToArray();
|
|
||||||
Textures = new ResourcePointerList64<Texture>();
|
|
||||||
Textures.data_items = textures.ToArray();
|
|
||||||
BuildDict();
|
|
||||||
}
|
}
|
||||||
public static void WriteXmlNode(TextureDictionary d, StringBuilder sb, int indent, string ddsfolder, string name = "TextureDictionary")
|
public static void WriteXmlNode(TextureDictionary d, StringBuilder sb, int indent, string ddsfolder, string name = "TextureDictionary")
|
||||||
{
|
{
|
||||||
@ -175,6 +169,23 @@ namespace CodeWalker.GameFiles
|
|||||||
Dict = dict;
|
Dict = dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void BuildFromTextureList(List<Texture> textures)
|
||||||
|
{
|
||||||
|
textures.Sort((a, b) => a.NameHash.CompareTo(b.NameHash));
|
||||||
|
|
||||||
|
var texturehashes = new List<uint>();
|
||||||
|
foreach (var tex in textures)
|
||||||
|
{
|
||||||
|
texturehashes.Add(tex.NameHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextureNameHashes = new ResourceSimpleList64_uint();
|
||||||
|
TextureNameHashes.data_items = texturehashes.ToArray();
|
||||||
|
Textures = new ResourcePointerList64<Texture>();
|
||||||
|
Textures.data_items = textures.ToArray();
|
||||||
|
BuildDict();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TypeConverter(typeof(ExpandableObjectConverter))] public class TextureBase : ResourceSystemBlock
|
[TypeConverter(typeof(ExpandableObjectConverter))] public class TextureBase : ResourceSystemBlock
|
||||||
|
@ -1608,7 +1608,7 @@ namespace CodeWalker
|
|||||||
private void ViewYtd(string name, string path, byte[] data, RpfFileEntry e)
|
private void ViewYtd(string name, string path, byte[] data, RpfFileEntry e)
|
||||||
{
|
{
|
||||||
var ytd = RpfFile.GetFile<YtdFile>(e, data);
|
var ytd = RpfFile.GetFile<YtdFile>(e, data);
|
||||||
YtdForm f = new YtdForm();
|
YtdForm f = new YtdForm(this);
|
||||||
f.Show();
|
f.Show();
|
||||||
f.LoadYtd(ytd);
|
f.LoadYtd(ytd);
|
||||||
}
|
}
|
||||||
|
179
CodeWalker/Forms/YtdForm.Designer.cs
generated
179
CodeWalker/Forms/YtdForm.Designer.cs
generated
@ -31,16 +31,26 @@
|
|||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(YtdForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(YtdForm));
|
||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
this.FileMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.FileMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.FileSaveAllMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.FileSaveMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.FileSaveAsMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.FileSaveTextureAsMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.FileSaveAllTexturesMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.EditMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.EditMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.ViewMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.ViewMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
||||||
this.NewButton = new System.Windows.Forms.ToolStripSplitButton();
|
this.NewButton = new System.Windows.Forms.ToolStripSplitButton();
|
||||||
this.OpenButton = new System.Windows.Forms.ToolStripSplitButton();
|
this.OpenButton = new System.Windows.Forms.ToolStripSplitButton();
|
||||||
this.SaveButton = new System.Windows.Forms.ToolStripSplitButton();
|
this.SaveButton = new System.Windows.Forms.ToolStripSplitButton();
|
||||||
|
this.ToolbarSaveMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ToolbarSaveAsMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ToolbarSaveTextureAsMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ToolbarSaveAllTexturesMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.MainToolbar = new System.Windows.Forms.StatusStrip();
|
this.MainToolbar = new System.Windows.Forms.StatusStrip();
|
||||||
this.StatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
this.StatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.MainSplitContainer = new System.Windows.Forms.SplitContainer();
|
this.MainSplitContainer = new System.Windows.Forms.SplitContainer();
|
||||||
|
this.ReplaceTextureButton = new System.Windows.Forms.Button();
|
||||||
|
this.RemoveTextureButton = new System.Windows.Forms.Button();
|
||||||
|
this.AddTextureButton = new System.Windows.Forms.Button();
|
||||||
this.TexturesListView = new System.Windows.Forms.ListView();
|
this.TexturesListView = new System.Windows.Forms.ListView();
|
||||||
this.TextureNameColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.TextureNameColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.TextureSizeColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.TextureSizeColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
@ -58,11 +68,10 @@
|
|||||||
this.label4 = new System.Windows.Forms.Label();
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
this.DetailsTabPage = new System.Windows.Forms.TabPage();
|
this.DetailsTabPage = new System.Windows.Forms.TabPage();
|
||||||
this.DetailsPropertyGrid = new CodeWalker.WinForms.PropertyGridFix();
|
this.DetailsPropertyGrid = new CodeWalker.WinForms.PropertyGridFix();
|
||||||
this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
this.SaveDDSFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||||
this.FolderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
|
this.FolderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||||
this.FileSaveAsMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.OpenDDSFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.ToolbarSaveAsMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.SaveYTDFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||||
this.ToolbarSaveAllMenu = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.toolStrip1.SuspendLayout();
|
this.toolStrip1.SuspendLayout();
|
||||||
this.MainToolbar.SuspendLayout();
|
this.MainToolbar.SuspendLayout();
|
||||||
@ -93,21 +102,46 @@
|
|||||||
// FileMenu
|
// FileMenu
|
||||||
//
|
//
|
||||||
this.FileMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.FileMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.FileSaveMenu,
|
||||||
this.FileSaveAsMenu,
|
this.FileSaveAsMenu,
|
||||||
this.FileSaveAllMenu});
|
this.FileSaveTextureAsMenu,
|
||||||
|
this.FileSaveAllTexturesMenu});
|
||||||
this.FileMenu.Name = "FileMenu";
|
this.FileMenu.Name = "FileMenu";
|
||||||
this.FileMenu.Size = new System.Drawing.Size(37, 20);
|
this.FileMenu.Size = new System.Drawing.Size(37, 20);
|
||||||
this.FileMenu.Text = "File";
|
this.FileMenu.Text = "File";
|
||||||
//
|
//
|
||||||
// FileSaveAllMenu
|
// FileSaveMenu
|
||||||
//
|
//
|
||||||
this.FileSaveAllMenu.Image = ((System.Drawing.Image)(resources.GetObject("FileSaveAllMenu.Image")));
|
this.FileSaveMenu.Image = ((System.Drawing.Image)(resources.GetObject("FileSaveMenu.Image")));
|
||||||
this.FileSaveAllMenu.Name = "FileSaveAllMenu";
|
this.FileSaveMenu.Name = "FileSaveMenu";
|
||||||
this.FileSaveAllMenu.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
|
this.FileSaveMenu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||||
|
this.FileSaveMenu.Size = new System.Drawing.Size(242, 22);
|
||||||
|
this.FileSaveMenu.Text = "Save YTD";
|
||||||
|
this.FileSaveMenu.Click += new System.EventHandler(this.FileSaveMenu_Click);
|
||||||
|
//
|
||||||
|
// FileSaveAsMenu
|
||||||
|
//
|
||||||
|
this.FileSaveAsMenu.Name = "FileSaveAsMenu";
|
||||||
|
this.FileSaveAsMenu.Size = new System.Drawing.Size(242, 22);
|
||||||
|
this.FileSaveAsMenu.Text = "Save YTD As...";
|
||||||
|
this.FileSaveAsMenu.Click += new System.EventHandler(this.FileSaveAsMenu_Click);
|
||||||
|
//
|
||||||
|
// FileSaveTextureAsMenu
|
||||||
|
//
|
||||||
|
this.FileSaveTextureAsMenu.Name = "FileSaveTextureAsMenu";
|
||||||
|
this.FileSaveTextureAsMenu.Size = new System.Drawing.Size(242, 22);
|
||||||
|
this.FileSaveTextureAsMenu.Text = "Save Texture As...";
|
||||||
|
this.FileSaveTextureAsMenu.Click += new System.EventHandler(this.FileSaveTextureAsMenu_Click);
|
||||||
|
//
|
||||||
|
// FileSaveAllTexturesMenu
|
||||||
|
//
|
||||||
|
this.FileSaveAllTexturesMenu.Image = ((System.Drawing.Image)(resources.GetObject("FileSaveAllTexturesMenu.Image")));
|
||||||
|
this.FileSaveAllTexturesMenu.Name = "FileSaveAllTexturesMenu";
|
||||||
|
this.FileSaveAllTexturesMenu.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
|
||||||
| System.Windows.Forms.Keys.S)));
|
| System.Windows.Forms.Keys.S)));
|
||||||
this.FileSaveAllMenu.Size = new System.Drawing.Size(196, 22);
|
this.FileSaveAllTexturesMenu.Size = new System.Drawing.Size(242, 22);
|
||||||
this.FileSaveAllMenu.Text = "Save All...";
|
this.FileSaveAllTexturesMenu.Text = "Save All Textures...";
|
||||||
this.FileSaveAllMenu.Click += new System.EventHandler(this.FileSaveAllMenu_Click);
|
this.FileSaveAllTexturesMenu.Click += new System.EventHandler(this.FileSaveAllTexturesMenu_Click);
|
||||||
//
|
//
|
||||||
// EditMenu
|
// EditMenu
|
||||||
//
|
//
|
||||||
@ -159,8 +193,10 @@
|
|||||||
//
|
//
|
||||||
this.SaveButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
this.SaveButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||||
this.SaveButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.SaveButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.ToolbarSaveMenu,
|
||||||
this.ToolbarSaveAsMenu,
|
this.ToolbarSaveAsMenu,
|
||||||
this.ToolbarSaveAllMenu});
|
this.ToolbarSaveTextureAsMenu,
|
||||||
|
this.ToolbarSaveAllTexturesMenu});
|
||||||
this.SaveButton.Image = ((System.Drawing.Image)(resources.GetObject("SaveButton.Image")));
|
this.SaveButton.Image = ((System.Drawing.Image)(resources.GetObject("SaveButton.Image")));
|
||||||
this.SaveButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
this.SaveButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||||
this.SaveButton.Name = "SaveButton";
|
this.SaveButton.Name = "SaveButton";
|
||||||
@ -168,6 +204,36 @@
|
|||||||
this.SaveButton.Text = "Save YTD...";
|
this.SaveButton.Text = "Save YTD...";
|
||||||
this.SaveButton.ButtonClick += new System.EventHandler(this.SaveButton_ButtonClick);
|
this.SaveButton.ButtonClick += new System.EventHandler(this.SaveButton_ButtonClick);
|
||||||
//
|
//
|
||||||
|
// ToolbarSaveMenu
|
||||||
|
//
|
||||||
|
this.ToolbarSaveMenu.Image = ((System.Drawing.Image)(resources.GetObject("ToolbarSaveMenu.Image")));
|
||||||
|
this.ToolbarSaveMenu.Name = "ToolbarSaveMenu";
|
||||||
|
this.ToolbarSaveMenu.Size = new System.Drawing.Size(170, 22);
|
||||||
|
this.ToolbarSaveMenu.Text = "Save YTD";
|
||||||
|
this.ToolbarSaveMenu.Click += new System.EventHandler(this.ToolbarSaveMenu_Click);
|
||||||
|
//
|
||||||
|
// ToolbarSaveAsMenu
|
||||||
|
//
|
||||||
|
this.ToolbarSaveAsMenu.Name = "ToolbarSaveAsMenu";
|
||||||
|
this.ToolbarSaveAsMenu.Size = new System.Drawing.Size(170, 22);
|
||||||
|
this.ToolbarSaveAsMenu.Text = "Save YTD As...";
|
||||||
|
this.ToolbarSaveAsMenu.Click += new System.EventHandler(this.ToolbarSaveAsMenu_Click);
|
||||||
|
//
|
||||||
|
// ToolbarSaveTextureAsMenu
|
||||||
|
//
|
||||||
|
this.ToolbarSaveTextureAsMenu.Name = "ToolbarSaveTextureAsMenu";
|
||||||
|
this.ToolbarSaveTextureAsMenu.Size = new System.Drawing.Size(170, 22);
|
||||||
|
this.ToolbarSaveTextureAsMenu.Text = "Save Texture As...";
|
||||||
|
this.ToolbarSaveTextureAsMenu.Click += new System.EventHandler(this.ToolbarSaveTextureAsMenu_Click);
|
||||||
|
//
|
||||||
|
// ToolbarSaveAllTexturesMenu
|
||||||
|
//
|
||||||
|
this.ToolbarSaveAllTexturesMenu.Image = ((System.Drawing.Image)(resources.GetObject("ToolbarSaveAllTexturesMenu.Image")));
|
||||||
|
this.ToolbarSaveAllTexturesMenu.Name = "ToolbarSaveAllTexturesMenu";
|
||||||
|
this.ToolbarSaveAllTexturesMenu.Size = new System.Drawing.Size(170, 22);
|
||||||
|
this.ToolbarSaveAllTexturesMenu.Text = "Save All Textures...";
|
||||||
|
this.ToolbarSaveAllTexturesMenu.Click += new System.EventHandler(this.ToolbarSaveAllTexturesMenu_Click);
|
||||||
|
//
|
||||||
// MainToolbar
|
// MainToolbar
|
||||||
//
|
//
|
||||||
this.MainToolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.MainToolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
@ -193,6 +259,9 @@
|
|||||||
//
|
//
|
||||||
// MainSplitContainer.Panel1
|
// MainSplitContainer.Panel1
|
||||||
//
|
//
|
||||||
|
this.MainSplitContainer.Panel1.Controls.Add(this.ReplaceTextureButton);
|
||||||
|
this.MainSplitContainer.Panel1.Controls.Add(this.RemoveTextureButton);
|
||||||
|
this.MainSplitContainer.Panel1.Controls.Add(this.AddTextureButton);
|
||||||
this.MainSplitContainer.Panel1.Controls.Add(this.TexturesListView);
|
this.MainSplitContainer.Panel1.Controls.Add(this.TexturesListView);
|
||||||
//
|
//
|
||||||
// MainSplitContainer.Panel2
|
// MainSplitContainer.Panel2
|
||||||
@ -204,6 +273,41 @@
|
|||||||
this.MainSplitContainer.SplitterDistance = 257;
|
this.MainSplitContainer.SplitterDistance = 257;
|
||||||
this.MainSplitContainer.TabIndex = 3;
|
this.MainSplitContainer.TabIndex = 3;
|
||||||
//
|
//
|
||||||
|
// ReplaceTextureButton
|
||||||
|
//
|
||||||
|
this.ReplaceTextureButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.ReplaceTextureButton.Enabled = false;
|
||||||
|
this.ReplaceTextureButton.Location = new System.Drawing.Point(170, 462);
|
||||||
|
this.ReplaceTextureButton.Name = "ReplaceTextureButton";
|
||||||
|
this.ReplaceTextureButton.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.ReplaceTextureButton.TabIndex = 3;
|
||||||
|
this.ReplaceTextureButton.Text = "Replace...";
|
||||||
|
this.ReplaceTextureButton.UseVisualStyleBackColor = true;
|
||||||
|
this.ReplaceTextureButton.Click += new System.EventHandler(this.ReplaceTextureButton_Click);
|
||||||
|
//
|
||||||
|
// RemoveTextureButton
|
||||||
|
//
|
||||||
|
this.RemoveTextureButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.RemoveTextureButton.Enabled = false;
|
||||||
|
this.RemoveTextureButton.Location = new System.Drawing.Point(89, 462);
|
||||||
|
this.RemoveTextureButton.Name = "RemoveTextureButton";
|
||||||
|
this.RemoveTextureButton.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.RemoveTextureButton.TabIndex = 2;
|
||||||
|
this.RemoveTextureButton.Text = "Remove";
|
||||||
|
this.RemoveTextureButton.UseVisualStyleBackColor = true;
|
||||||
|
this.RemoveTextureButton.Click += new System.EventHandler(this.RemoveTextureButton_Click);
|
||||||
|
//
|
||||||
|
// AddTextureButton
|
||||||
|
//
|
||||||
|
this.AddTextureButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.AddTextureButton.Location = new System.Drawing.Point(8, 462);
|
||||||
|
this.AddTextureButton.Name = "AddTextureButton";
|
||||||
|
this.AddTextureButton.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.AddTextureButton.TabIndex = 1;
|
||||||
|
this.AddTextureButton.Text = "Add...";
|
||||||
|
this.AddTextureButton.UseVisualStyleBackColor = true;
|
||||||
|
this.AddTextureButton.Click += new System.EventHandler(this.AddTextureButton_Click);
|
||||||
|
//
|
||||||
// TexturesListView
|
// TexturesListView
|
||||||
//
|
//
|
||||||
this.TexturesListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.TexturesListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
@ -217,7 +321,7 @@
|
|||||||
this.TexturesListView.Location = new System.Drawing.Point(3, 3);
|
this.TexturesListView.Location = new System.Drawing.Point(3, 3);
|
||||||
this.TexturesListView.Name = "TexturesListView";
|
this.TexturesListView.Name = "TexturesListView";
|
||||||
this.TexturesListView.ShowItemToolTips = true;
|
this.TexturesListView.ShowItemToolTips = true;
|
||||||
this.TexturesListView.Size = new System.Drawing.Size(251, 483);
|
this.TexturesListView.Size = new System.Drawing.Size(251, 453);
|
||||||
this.TexturesListView.TabIndex = 0;
|
this.TexturesListView.TabIndex = 0;
|
||||||
this.TexturesListView.UseCompatibleStateImageBehavior = false;
|
this.TexturesListView.UseCompatibleStateImageBehavior = false;
|
||||||
this.TexturesListView.View = System.Windows.Forms.View.Details;
|
this.TexturesListView.View = System.Windows.Forms.View.Details;
|
||||||
@ -250,6 +354,7 @@
|
|||||||
this.SelTextureNameTextBox.Name = "SelTextureNameTextBox";
|
this.SelTextureNameTextBox.Name = "SelTextureNameTextBox";
|
||||||
this.SelTextureNameTextBox.Size = new System.Drawing.Size(271, 20);
|
this.SelTextureNameTextBox.Size = new System.Drawing.Size(271, 20);
|
||||||
this.SelTextureNameTextBox.TabIndex = 46;
|
this.SelTextureNameTextBox.TabIndex = 46;
|
||||||
|
this.SelTextureNameTextBox.TextChanged += new System.EventHandler(this.SelTextureNameTextBox_TextChanged);
|
||||||
//
|
//
|
||||||
// TextureTabControl
|
// TextureTabControl
|
||||||
//
|
//
|
||||||
@ -398,34 +503,17 @@
|
|||||||
this.DetailsPropertyGrid.Size = new System.Drawing.Size(558, 445);
|
this.DetailsPropertyGrid.Size = new System.Drawing.Size(558, 445);
|
||||||
this.DetailsPropertyGrid.TabIndex = 0;
|
this.DetailsPropertyGrid.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// SaveFileDialog
|
// SaveDDSFileDialog
|
||||||
//
|
//
|
||||||
this.SaveFileDialog.Filter = "DDS files|*.dds|All files|*.*";
|
this.SaveDDSFileDialog.Filter = "DDS files|*.dds|All files|*.*";
|
||||||
//
|
//
|
||||||
// FileSaveAsMenu
|
// OpenDDSFileDialog
|
||||||
//
|
//
|
||||||
this.FileSaveAsMenu.Image = ((System.Drawing.Image)(resources.GetObject("FileSaveAsMenu.Image")));
|
this.OpenDDSFileDialog.Filter = "DDS files|*.dds|All files|*.*";
|
||||||
this.FileSaveAsMenu.Name = "FileSaveAsMenu";
|
|
||||||
this.FileSaveAsMenu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
|
||||||
this.FileSaveAsMenu.Size = new System.Drawing.Size(196, 22);
|
|
||||||
this.FileSaveAsMenu.Text = "Save As...";
|
|
||||||
this.FileSaveAsMenu.Click += new System.EventHandler(this.FileSaveAsMenu_Click);
|
|
||||||
//
|
//
|
||||||
// ToolbarSaveAsMenu
|
// SaveYTDFileDialog
|
||||||
//
|
//
|
||||||
this.ToolbarSaveAsMenu.Image = ((System.Drawing.Image)(resources.GetObject("ToolbarSaveAsMenu.Image")));
|
this.SaveYTDFileDialog.Filter = "YTD files|*.ytd|All files|*.*";
|
||||||
this.ToolbarSaveAsMenu.Name = "ToolbarSaveAsMenu";
|
|
||||||
this.ToolbarSaveAsMenu.Size = new System.Drawing.Size(152, 22);
|
|
||||||
this.ToolbarSaveAsMenu.Text = "Save as...";
|
|
||||||
this.ToolbarSaveAsMenu.Click += new System.EventHandler(this.ToolbarSaveAsMenu_Click);
|
|
||||||
//
|
|
||||||
// ToolbarSaveAllMenu
|
|
||||||
//
|
|
||||||
this.ToolbarSaveAllMenu.Image = ((System.Drawing.Image)(resources.GetObject("ToolbarSaveAllMenu.Image")));
|
|
||||||
this.ToolbarSaveAllMenu.Name = "ToolbarSaveAllMenu";
|
|
||||||
this.ToolbarSaveAllMenu.Size = new System.Drawing.Size(152, 22);
|
|
||||||
this.ToolbarSaveAllMenu.Text = "Save All...";
|
|
||||||
this.ToolbarSaveAllMenu.Click += new System.EventHandler(this.ToolbarSaveAllMenu_Click);
|
|
||||||
//
|
//
|
||||||
// YtdForm
|
// YtdForm
|
||||||
//
|
//
|
||||||
@ -494,11 +582,20 @@
|
|||||||
private System.Windows.Forms.Panel SelTexturePanel;
|
private System.Windows.Forms.Panel SelTexturePanel;
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
private System.Windows.Forms.ComboBox SelTextureZoomCombo;
|
private System.Windows.Forms.ComboBox SelTextureZoomCombo;
|
||||||
private System.Windows.Forms.ToolStripMenuItem FileSaveAllMenu;
|
private System.Windows.Forms.ToolStripMenuItem FileSaveAllTexturesMenu;
|
||||||
private System.Windows.Forms.SaveFileDialog SaveFileDialog;
|
private System.Windows.Forms.SaveFileDialog SaveDDSFileDialog;
|
||||||
private System.Windows.Forms.FolderBrowserDialog FolderBrowserDialog;
|
private System.Windows.Forms.FolderBrowserDialog FolderBrowserDialog;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem FileSaveMenu;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ToolbarSaveMenu;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ToolbarSaveAllTexturesMenu;
|
||||||
|
private System.Windows.Forms.Button ReplaceTextureButton;
|
||||||
|
private System.Windows.Forms.Button RemoveTextureButton;
|
||||||
|
private System.Windows.Forms.Button AddTextureButton;
|
||||||
|
private System.Windows.Forms.OpenFileDialog OpenDDSFileDialog;
|
||||||
private System.Windows.Forms.ToolStripMenuItem FileSaveAsMenu;
|
private System.Windows.Forms.ToolStripMenuItem FileSaveAsMenu;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem FileSaveTextureAsMenu;
|
||||||
private System.Windows.Forms.ToolStripMenuItem ToolbarSaveAsMenu;
|
private System.Windows.Forms.ToolStripMenuItem ToolbarSaveAsMenu;
|
||||||
private System.Windows.Forms.ToolStripMenuItem ToolbarSaveAllMenu;
|
private System.Windows.Forms.ToolStripMenuItem ToolbarSaveTextureAsMenu;
|
||||||
|
private System.Windows.Forms.SaveFileDialog SaveYTDFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,15 +17,20 @@ namespace CodeWalker.Forms
|
|||||||
{
|
{
|
||||||
public partial class YtdForm : Form
|
public partial class YtdForm : Form
|
||||||
{
|
{
|
||||||
private string fileName;
|
private string FileName;
|
||||||
private YtdFile Ytd { get; set; }
|
private YtdFile Ytd { get; set; }
|
||||||
private TextureDictionary TexDict { get; set; }
|
private TextureDictionary TexDict { get; set; }
|
||||||
private Texture CurrentTexture = null;
|
private Texture CurrentTexture = null;
|
||||||
private float CurrentZoom = 0.0f; //1.0 = 100%, 0.0 = stretch
|
private float CurrentZoom = 0.0f; //1.0 = 100%, 0.0 = stretch
|
||||||
|
private bool Modified = false;
|
||||||
|
private ExploreForm ExploreForm = null;
|
||||||
|
private ModelForm ModelForm = null;
|
||||||
|
|
||||||
|
|
||||||
public YtdForm()
|
public YtdForm(ExploreForm exploreForm = null, ModelForm modelForm = null)
|
||||||
{
|
{
|
||||||
|
ExploreForm = exploreForm;
|
||||||
|
ModelForm = modelForm;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,18 +39,18 @@ namespace CodeWalker.Forms
|
|||||||
{
|
{
|
||||||
Ytd = ytd;
|
Ytd = ytd;
|
||||||
|
|
||||||
fileName = ytd?.Name;
|
FileName = ytd?.Name;
|
||||||
if (string.IsNullOrEmpty(fileName))
|
if (string.IsNullOrEmpty(FileName))
|
||||||
{
|
{
|
||||||
fileName = ytd?.RpfFileEntry?.Name;
|
FileName = ytd?.RpfFileEntry?.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadTexDict(ytd.TextureDict, fileName);
|
LoadTexDict(ytd.TextureDict, FileName);
|
||||||
}
|
}
|
||||||
public void LoadTexDict(TextureDictionary texdict, string filename)
|
public void LoadTexDict(TextureDictionary texdict, string filename)
|
||||||
{
|
{
|
||||||
TexDict = texdict;
|
TexDict = texdict;
|
||||||
fileName = filename;
|
FileName = filename;
|
||||||
|
|
||||||
TexturesListView.Items.Clear();
|
TexturesListView.Items.Clear();
|
||||||
SelTexturePictureBox.Image = null;
|
SelTexturePictureBox.Image = null;
|
||||||
@ -82,6 +87,7 @@ namespace CodeWalker.Forms
|
|||||||
|
|
||||||
|
|
||||||
UpdateFormTitle();
|
UpdateFormTitle();
|
||||||
|
UpdateSaveYTDAs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetTexCountStr()
|
private string GetTexCountStr()
|
||||||
@ -92,11 +98,24 @@ namespace CodeWalker.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void SelectTexture(Texture tex)
|
||||||
|
{
|
||||||
|
TexturesListView.SelectedItems.Clear();
|
||||||
|
if (tex == null) return;
|
||||||
|
foreach (ListViewItem lvi in TexturesListView.Items)
|
||||||
|
{
|
||||||
|
if (lvi.Tag == tex)
|
||||||
|
{
|
||||||
|
lvi.Selected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ShowTextureMip(Texture tex, int mip, bool mipchange)
|
private void ShowTextureMip(Texture tex, int mip, bool mipchange)
|
||||||
{
|
{
|
||||||
CurrentTexture = tex;
|
CurrentTexture = tex;
|
||||||
UpdateSaveAs();
|
UpdateSaveTextureAs();
|
||||||
|
|
||||||
if (tex == null)
|
if (tex == null)
|
||||||
{
|
{
|
||||||
@ -107,10 +126,15 @@ namespace CodeWalker.Forms
|
|||||||
SelTextureMipTrackBar.Value = 0;
|
SelTextureMipTrackBar.Value = 0;
|
||||||
SelTextureMipTrackBar.Maximum = 0;
|
SelTextureMipTrackBar.Maximum = 0;
|
||||||
DetailsPropertyGrid.SelectedObject = null;
|
DetailsPropertyGrid.SelectedObject = null;
|
||||||
|
RemoveTextureButton.Enabled = false;
|
||||||
|
ReplaceTextureButton.Enabled = false;
|
||||||
UpdateStatus(GetTexCountStr());
|
UpdateStatus(GetTexCountStr());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoveTextureButton.Enabled = true;
|
||||||
|
ReplaceTextureButton.Enabled = true;
|
||||||
|
|
||||||
|
|
||||||
if (mipchange)
|
if (mipchange)
|
||||||
{
|
{
|
||||||
@ -169,10 +193,156 @@ namespace CodeWalker.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void AddTexture()
|
||||||
|
{
|
||||||
|
if (TexDict.Textures?.data_items == null) return;
|
||||||
|
|
||||||
|
var tex = OpenDDSFile();
|
||||||
|
if (tex == null) return;
|
||||||
|
|
||||||
|
var textures = new List<Texture>();
|
||||||
|
textures.AddRange(TexDict.Textures.data_items);
|
||||||
|
textures.Add(tex);
|
||||||
|
|
||||||
|
TexDict.BuildFromTextureList(textures);
|
||||||
|
|
||||||
|
Modified = true;
|
||||||
|
|
||||||
|
LoadTexDict(TexDict, FileName);
|
||||||
|
|
||||||
|
SelectTexture(tex);
|
||||||
|
|
||||||
|
UpdateModelFormTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveTexture()
|
||||||
|
{
|
||||||
|
if (TexDict?.Textures?.data_items == null) return;
|
||||||
|
if (CurrentTexture == null) return;
|
||||||
|
|
||||||
|
var textures = new List<Texture>();
|
||||||
|
foreach (var tex in TexDict.Textures.data_items)
|
||||||
|
{
|
||||||
|
if (tex != CurrentTexture)
|
||||||
|
{
|
||||||
|
textures.Add(tex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TexDict.BuildFromTextureList(textures);
|
||||||
|
|
||||||
|
Modified = true;
|
||||||
|
|
||||||
|
LoadTexDict(TexDict, FileName);
|
||||||
|
|
||||||
|
SelectTexture(null);
|
||||||
|
|
||||||
|
UpdateModelFormTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReplaceTexture()
|
||||||
|
{
|
||||||
|
if (TexDict?.Textures?.data_items == null) return;
|
||||||
|
if (CurrentTexture == null) return;
|
||||||
|
|
||||||
|
var tex = OpenDDSFile();
|
||||||
|
if (tex == null) return;
|
||||||
|
|
||||||
|
tex.Name = CurrentTexture.Name;
|
||||||
|
tex.NameHash = CurrentTexture.NameHash;
|
||||||
|
|
||||||
|
var textures = new List<Texture>();
|
||||||
|
foreach (var t in TexDict.Textures.data_items)
|
||||||
|
{
|
||||||
|
if (t != CurrentTexture)
|
||||||
|
{
|
||||||
|
textures.Add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textures.Add(tex);
|
||||||
|
|
||||||
|
TexDict.BuildFromTextureList(textures);
|
||||||
|
|
||||||
|
Modified = true;
|
||||||
|
|
||||||
|
LoadTexDict(TexDict, FileName);
|
||||||
|
|
||||||
|
SelectTexture(tex);
|
||||||
|
|
||||||
|
UpdateModelFormTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RenameTexture(string name)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(name)) return;
|
||||||
|
if (TexDict?.Textures?.data_items == null) return;
|
||||||
|
if (CurrentTexture == null) return;
|
||||||
|
if (CurrentTexture.Name == name) return;
|
||||||
|
|
||||||
|
var tex = CurrentTexture;
|
||||||
|
|
||||||
|
tex.Name = name;
|
||||||
|
tex.NameHash = JenkHash.GenHash(name.ToLowerInvariant());
|
||||||
|
|
||||||
|
var textures = new List<Texture>();
|
||||||
|
textures.AddRange(TexDict.Textures.data_items);
|
||||||
|
|
||||||
|
TexDict.BuildFromTextureList(textures);
|
||||||
|
|
||||||
|
Modified = true;
|
||||||
|
|
||||||
|
foreach (ListViewItem lvi in TexturesListView.Items)
|
||||||
|
{
|
||||||
|
if (lvi.Tag == tex)
|
||||||
|
{
|
||||||
|
lvi.Text = tex.Name;
|
||||||
|
lvi.ToolTipText = tex.Name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateFormTitle();
|
||||||
|
UpdateSaveYTDAs();
|
||||||
|
UpdateModelFormTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Texture OpenDDSFile()
|
||||||
|
{
|
||||||
|
if (OpenDDSFileDialog.ShowDialog() != DialogResult.OK) return null;
|
||||||
|
|
||||||
|
var fn = OpenDDSFileDialog.FileName;
|
||||||
|
|
||||||
|
if (!File.Exists(fn)) return null; //couldn't find file?
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dds = File.ReadAllBytes(fn);
|
||||||
|
var tex = DDSIO.GetTexture(dds);
|
||||||
|
tex.Name = Path.GetFileNameWithoutExtension(fn);
|
||||||
|
tex.NameHash = JenkHash.GenHash(tex.Name?.ToLowerInvariant());
|
||||||
|
JenkIndex.Ensure(tex.Name?.ToLowerInvariant());
|
||||||
|
return tex;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("Unable to load " + fn + ".\nAre you sure it's a valid .dds file?");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void UpdateModelFormTextures()
|
||||||
|
{
|
||||||
|
if (ModelForm == null) return;
|
||||||
|
|
||||||
|
//TODO: live update of model form view when changes have been made...
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateFormTitle()
|
private void UpdateFormTitle()
|
||||||
{
|
{
|
||||||
Text = fileName + " - Texture Dictionary - CodeWalker by dexyfex";
|
Text = FileName + (Modified ? "*" : "") + " - Texture Dictionary - CodeWalker by dexyfex";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateStatus(string text)
|
private void UpdateStatus(string text)
|
||||||
@ -211,41 +381,141 @@ namespace CodeWalker.Forms
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void UpdateSaveYTDAs()
|
||||||
|
{
|
||||||
|
if (Ytd == null)
|
||||||
|
{
|
||||||
|
FileSaveMenu.Text = "Save YTD";
|
||||||
|
FileSaveAsMenu.Text = "Save YTD As...";
|
||||||
|
ToolbarSaveMenu.Text = "Save YTD";
|
||||||
|
ToolbarSaveAsMenu.Text = "Save YTD As...";
|
||||||
|
FileSaveMenu.Enabled = false;
|
||||||
|
FileSaveAsMenu.Enabled = false;
|
||||||
|
ToolbarSaveMenu.Enabled = false;
|
||||||
|
ToolbarSaveAsMenu.Enabled = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var cansave = (ExploreForm?.EditMode ?? false);
|
||||||
|
var s = "Save " + FileName;
|
||||||
|
var sas = "Save " + FileName + " As...";
|
||||||
|
FileSaveMenu.Text = s;
|
||||||
|
FileSaveAsMenu.Text = sas;
|
||||||
|
ToolbarSaveMenu.Text = s;
|
||||||
|
ToolbarSaveAsMenu.Text = sas;
|
||||||
|
FileSaveMenu.Enabled = cansave;
|
||||||
|
FileSaveAsMenu.Enabled = true;
|
||||||
|
ToolbarSaveMenu.Enabled = cansave;
|
||||||
|
ToolbarSaveAsMenu.Enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateSaveTextureAs()
|
||||||
private void UpdateSaveAs()
|
|
||||||
{
|
{
|
||||||
if (CurrentTexture == null)
|
if (CurrentTexture == null)
|
||||||
{
|
{
|
||||||
FileSaveAsMenu.Text = "Save As...";
|
FileSaveTextureAsMenu.Text = "Save Texture As...";
|
||||||
ToolbarSaveAsMenu.Text = "Save As...";
|
ToolbarSaveTextureAsMenu.Text = "Save Texture As...";
|
||||||
FileSaveAsMenu.Enabled = false;
|
FileSaveTextureAsMenu.Enabled = false;
|
||||||
ToolbarSaveAsMenu.Enabled = false;
|
ToolbarSaveTextureAsMenu.Enabled = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string fname = CurrentTexture.Name + ".dds";
|
string fname = CurrentTexture.Name + ".dds";
|
||||||
string sas = "Save " + fname + " As...";
|
string sas = "Save " + fname + " As...";
|
||||||
FileSaveAsMenu.Text = sas;
|
FileSaveTextureAsMenu.Text = sas;
|
||||||
ToolbarSaveAsMenu.Text = sas;
|
ToolbarSaveTextureAsMenu.Text = sas;
|
||||||
FileSaveAsMenu.Enabled = true;
|
FileSaveTextureAsMenu.Enabled = true;
|
||||||
ToolbarSaveAsMenu.Enabled = true;
|
ToolbarSaveTextureAsMenu.Enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void SaveAs()
|
|
||||||
|
private void SaveYTD(bool saveas = false)
|
||||||
|
{
|
||||||
|
if (Ytd == null) return;
|
||||||
|
if (!(ExploreForm?.EditMode ?? false))
|
||||||
|
{
|
||||||
|
saveas = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var isinrpf = false;
|
||||||
|
var rpfFileEntry = Ytd.RpfFileEntry;
|
||||||
|
if (rpfFileEntry == null)
|
||||||
|
{
|
||||||
|
saveas = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (rpfFileEntry?.Parent != null)
|
||||||
|
{
|
||||||
|
if (!saveas)
|
||||||
|
{
|
||||||
|
isinrpf = true;
|
||||||
|
if (!rpfFileEntry.Path.ToLowerInvariant().StartsWith("mods"))
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("This file is NOT located in the mods folder - Are you SURE you want to save this file?\r\nWARNING: This could cause permanent damage to your game!!!", "WARNING: Are you sure about this?", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
saveas = true;//that was a close one
|
||||||
|
isinrpf = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(rpfFileEntry?.Path))
|
||||||
|
{
|
||||||
|
isinrpf = false; //saving direct to filesystem in RPF explorer...
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
saveas = true;//this probably shouldn't happen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = Ytd.Save();
|
||||||
|
|
||||||
|
if (saveas) //save direct to filesystem in external location
|
||||||
|
{
|
||||||
|
SaveYTDFileDialog.FileName = FileName;
|
||||||
|
if (SaveYTDFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||||
|
string fpath = SaveYTDFileDialog.FileName;
|
||||||
|
File.WriteAllBytes(fpath, data);
|
||||||
|
}
|
||||||
|
else if (!isinrpf) //save direct to filesystem in RPF explorer
|
||||||
|
{
|
||||||
|
File.WriteAllBytes(rpfFileEntry.Path, data);
|
||||||
|
ExploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer...
|
||||||
|
}
|
||||||
|
else //save to RPF...
|
||||||
|
{
|
||||||
|
if (!(ExploreForm?.EnsureRpfValidEncryption(rpfFileEntry.File) ?? false))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Unable to save file, RPF encryption needs to be OPEN for this operation!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ytd.RpfFileEntry = RpfFile.CreateFile(rpfFileEntry.Parent, rpfFileEntry.Name, data);
|
||||||
|
ExploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer...
|
||||||
|
}
|
||||||
|
|
||||||
|
Modified = false;
|
||||||
|
UpdateStatus("YTD file saved successfully at " + DateTime.Now.ToString());
|
||||||
|
UpdateFormTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveTextureAs()
|
||||||
{
|
{
|
||||||
if (CurrentTexture == null) return;
|
if (CurrentTexture == null) return;
|
||||||
string fname = CurrentTexture.Name + ".dds";
|
string fname = CurrentTexture.Name + ".dds";
|
||||||
SaveFileDialog.FileName = fname;
|
SaveDDSFileDialog.FileName = fname;
|
||||||
if (SaveFileDialog.ShowDialog() != DialogResult.OK) return;
|
if (SaveDDSFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||||
string fpath = SaveFileDialog.FileName;
|
string fpath = SaveDDSFileDialog.FileName;
|
||||||
byte[] dds = DDSIO.GetDDSFile(CurrentTexture);
|
byte[] dds = DDSIO.GetDDSFile(CurrentTexture);
|
||||||
File.WriteAllBytes(fpath, dds);
|
File.WriteAllBytes(fpath, dds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveAll()
|
private void SaveAllTextures()
|
||||||
{
|
{
|
||||||
if (TexDict?.Textures?.data_items == null) return;
|
if (TexDict?.Textures?.data_items == null) return;
|
||||||
if (FolderBrowserDialog.ShowDialogNew() != DialogResult.OK) return;
|
if (FolderBrowserDialog.ShowDialogNew() != DialogResult.OK) return;
|
||||||
@ -305,29 +575,76 @@ namespace CodeWalker.Forms
|
|||||||
UpdateZoom();
|
UpdateZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FileSaveAllMenu_Click(object sender, EventArgs e)
|
private void FileSaveMenu_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SaveAll();
|
SaveYTD();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FileSaveAsMenu_Click(object sender, EventArgs e)
|
private void FileSaveAsMenu_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SaveAs();
|
SaveYTD(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FileSaveTextureAsMenu_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SaveTextureAs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FileSaveAllTexturesMenu_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SaveAllTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveButton_ButtonClick(object sender, EventArgs e)
|
private void SaveButton_ButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SaveAs();
|
if (Ytd != null)
|
||||||
|
{
|
||||||
|
SaveYTD();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SaveTextureAs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToolbarSaveMenu_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SaveYTD();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToolbarSaveAsMenu_Click(object sender, EventArgs e)
|
private void ToolbarSaveAsMenu_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SaveAs();
|
SaveYTD(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToolbarSaveAllMenu_Click(object sender, EventArgs e)
|
private void ToolbarSaveTextureAsMenu_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SaveAll();
|
SaveTextureAs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToolbarSaveAllTexturesMenu_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SaveAllTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddTextureButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
AddTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveTextureButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
RemoveTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReplaceTextureButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ReplaceTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SelTextureNameTextBox_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
RenameTexture(SelTextureNameTextBox.Text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,15 +121,14 @@
|
|||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</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="FileSaveAsMenu.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="FileSaveMenu.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||||
YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAABUSURBVDhPY/j//z9FGEx8+/btPwn4PRAbMAABigFOTk5w
|
xAAADsQBlSsOGwAAAFRJREFUOE9j+P//P0UYTHz79u0/Cfg9EBswAAGKAU5OTnD84f1HOEYWA9FtbW1w
|
||||||
/OH9RzhGFgPRbW1tcEPIMgCEYYaQbQAIg/QQZQAyRlZDWwOIwaMGDEoDyMFwA8jH/xkAuAOq5KQIy40A
|
Q8gyAIRhhpBtAAiD9BBlADJGVkNbA4jBowYMSgPIwXADyMf/GQC4A6rkpAjLjQAAAABJRU5ErkJggg==
|
||||||
AAAASUVORK5CYII=
|
|
||||||
</value>
|
</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="FileSaveAllMenu.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="FileSaveAllTexturesMenu.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||||
wwAADsMBx2+oZAAAAHZJREFUOE/tkLENwCAMBBkpMzCcF2IwgmTRJnpiSyhgQ5EyLx128VzhYKXWejlk
|
wwAADsMBx2+oZAAAAHZJREFUOE/tkLENwCAMBBkpMzCcF2IwgmTRJnpiSyhgQ5EyLx128VzhYKXWejlk
|
||||||
@ -161,15 +160,14 @@
|
|||||||
K0QAIeQTi/cp4B9tCZE2c6oRhQAAAABJRU5ErkJggg==
|
K0QAIeQTi/cp4B9tCZE2c6oRhQAAAABJRU5ErkJggg==
|
||||||
</value>
|
</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ToolbarSaveAsMenu.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="ToolbarSaveMenu.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||||
YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAABUSURBVDhPY/j//z9FGEx8+/btPwn4PRAbMAABigFOTk5w
|
xAAADsQBlSsOGwAAAFRJREFUOE9j+P//P0UYTHz79u0/Cfg9EBswAAGKAU5OTnD84f1HOEYWA9FtbW1w
|
||||||
/OH9RzhGFgPRbW1tcEPIMgCEYYaQbQAIg/QQZQAyRlZDWwOIwaMGDEoDyMFwA8jH/xkAuAOq5KQIy40A
|
Q8gyAIRhhpBtAAiD9BBlADJGVkNbA4jBowYMSgPIwXADyMf/GQC4A6rkpAjLjQAAAABJRU5ErkJggg==
|
||||||
AAAASUVORK5CYII=
|
|
||||||
</value>
|
</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ToolbarSaveAllMenu.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="ToolbarSaveAllTexturesMenu.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||||
wwAADsMBx2+oZAAAAHZJREFUOE/tkLENwCAMBBkpMzCcF2IwgmTRJnpiSyhgQ5EyLx128VzhYKXWejlk
|
wwAADsMBx2+oZAAAAHZJREFUOE/tkLENwCAMBBkpMzCcF2IwgmTRJnpiSyhgQ5EyLx128VzhYKXWejlk
|
||||||
@ -212,12 +210,18 @@
|
|||||||
+6sAAAAASUVORK5CYII=
|
+6sAAAAASUVORK5CYII=
|
||||||
</value>
|
</value>
|
||||||
</data>
|
</data>
|
||||||
<metadata name="SaveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="SaveDDSFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>358, 17</value>
|
<value>358, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="FolderBrowserDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="FolderBrowserDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>489, 17</value>
|
<value>489, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="OpenDDSFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>654, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="SaveYTDFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>813, 17</value>
|
||||||
|
</metadata>
|
||||||
<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>
|
||||||
AAABAAMAICAAAAAAGACoDAAANgAAABAQAAAAABgAaAMAAN4MAABAQAAAAAAYACgyAABGEAAAKAAAACAA
|
AAABAAMAICAAAAAAGACoDAAANgAAABAQAAAAABgAaAMAAN4MAABAQAAAAAAYACgyAABGEAAAKAAAACAA
|
||||||
|
Loading…
Reference in New Issue
Block a user