diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 019fb53b..2240e4b2 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index b340b43a..5f253efc 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm index 042720c7..a2f632b2 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index 9a46369b..fb55d779 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/BFRESGroupNode.cs b/Switch_FileFormatsMain/FileFormats/BFRES/BFRESGroupNode.cs index 852da7a5..8ee41bf8 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/BFRESGroupNode.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/BFRESGroupNode.cs @@ -514,7 +514,7 @@ namespace Bfres.Structs if (setting.DataBlockOutput != null) { var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); - var tex = ftex.FromGx2Surface(surface, setting); + var tex = ftex.FromGx2Surface(surface, setting.TexName); ftex.UpdateTex(tex); ftex.IsEdited = true; @@ -570,7 +570,7 @@ namespace Bfres.Structs FTEX ftex = new FTEX(); ftex.texture = new ResU.Texture(); var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); - var tex = ftex.FromGx2Surface(surface, setting); + var tex = ftex.FromGx2Surface(surface, setting.TexName); ftex.UpdateTex(tex); ftex.IsEdited = true; @@ -646,7 +646,7 @@ namespace Bfres.Structs var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); FTEX ftex = new FTEX(); ftex.texture = new ResU.Texture(); - ftex.texture = ftex.FromGx2Surface(surface, setting); + ftex.texture = ftex.FromGx2Surface(surface, setting.TexName); ftex.IsEdited = true; ftex.Read(ftex.texture); diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FMAT.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FMAT.cs index 8876179d..9f8047b4 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FMAT.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FMAT.cs @@ -541,8 +541,8 @@ namespace Bfres.Structs Text = text; textureMap = texture; - ImageKey = "texture"; - SelectedImageKey = "texture"; + ImageKey = "TextureMaterialMap"; + SelectedImageKey = "TextureMaterialMap"; } public override void OnClick(TreeView treeView) diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs index 12ab58fd..b42ca025 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs @@ -54,7 +54,7 @@ namespace Bfres.Structs bool IsReplaced = false; - public override bool CanEdit { get; set; } = false; + public override bool CanEdit { get; set; } = true; public int format; public Texture texture; @@ -159,7 +159,7 @@ namespace Bfres.Structs if (setting.DataBlockOutput != null) { var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); - var tex = FromGx2Surface(surface, setting); + var tex = FromGx2Surface(surface, setting.TexName); UpdateTex(tex); texture.Name = Text; @@ -229,7 +229,7 @@ namespace Bfres.Structs if (setting.DataBlockOutput != null) { var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); - var tex = FromGx2Surface(surface, setting); + var tex = FromGx2Surface(surface, setting.TexName); UpdateTex(tex); texture.Name = Text; IsReplaced = true; @@ -252,7 +252,7 @@ namespace Bfres.Structs if (setting.DataBlockOutput != null) { var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); - var tex = FromGx2Surface(surface, setting); + var tex = FromGx2Surface(surface, setting.TexName); UpdateTex(tex); texture.Name = Text; IsReplaced = true; @@ -305,10 +305,10 @@ namespace Bfres.Structs } //We reuse GX2 data as it's the same thing - public Texture FromGx2Surface(GX2.GX2Surface surf, GTXImporterSettings settings) + public Texture FromGx2Surface(GX2.GX2Surface surf, string Name) { Texture tex = new Texture(); - tex.Name = settings.TexName; + tex.Name = Name; tex.Path = ""; tex.AAMode = (GX2AAMode)surf.aa; tex.Alignment = (uint)surf.alignment; @@ -350,7 +350,6 @@ namespace Bfres.Structs { CanReplace = true; CanDelete = true; - CanEdit = false; CanExport = true; ImageKey = "Texture"; @@ -383,7 +382,53 @@ namespace Bfres.Structs public override void SetImageData(Bitmap bitmap, int ArrayLevel) { - throw new NotImplementedException("Cannot set image data! Operation not implemented!"); + if (bitmap == null) + return; //Image is likely disposed and not needed to be applied + + texture.Format = ConvertToGx2Format(Format); + texture.Width = (uint)bitmap.Width; + texture.Height = (uint)bitmap.Height; + + if (MipCount != 1) + { + MipCount = GenerateMipCount(bitmap.Width, bitmap.Height); + if (MipCount == 0) + MipCount = 1; + } + + texture.MipCount = MipCount; + texture.MipOffsets = new uint[MipCount]; + + try + { + //Create image block from bitmap first + var data = GenerateMipsAndCompress(bitmap, Format); + + //Swizzle and create surface + var surface = GX2.CreateGx2Texture(data, Text, + (uint)texture.TileMode, + (uint)texture.AAMode, + (uint)texture.Width, + (uint)texture.Height, + (uint)texture.Depth, + (uint)texture.Format, + (uint)texture.Swizzle, + (uint)texture.Dim, + (uint)texture.MipCount + ); + + var tex = FromGx2Surface(surface, texture.Name); + UpdateTex(tex); + + IsEdited = true; + Read(texture); + LoadOpenGLTexture(); + LibraryGUI.Instance.UpdateViewport(); + } + catch (Exception ex) + { + STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString()); + } } ResFile ResFileTexture2; diff --git a/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs b/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs index 75418d02..7e9b89ff 100644 --- a/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs +++ b/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs @@ -367,6 +367,7 @@ namespace FirstPlugin Nodes.Add(setting.textureData); Textures.Add(setting.textureData.Text, setting.textureData); setting.textureData.LoadOpenGLTexture(); + LibraryGUI.Instance.UpdateViewport(); } else { @@ -802,7 +803,6 @@ namespace FirstPlugin ContextMenuStrip.Items.Add(new ToolStripMenuItem("Rename", null, Rename, Keys.Control | Keys.N)); ContextMenuStrip.Items.Add(new ToolStripSeparator()); ContextMenuStrip.Items.Add(new ToolStripMenuItem("Delete", null, Remove, Keys.Control | Keys.Delete)); - // LoadOpenGLTexture(); } public static SurfaceFormat GenericToBntxSurfaceFormat(TEX_FORMAT texFormat) { @@ -1160,7 +1160,6 @@ namespace FirstPlugin Texture.MipCount = MipCount; Texture.MipOffsets = new long[MipCount]; - try { Texture.TextureData[ArrayLevel].Clear(); //Clear previous mip maps @@ -1173,13 +1172,14 @@ namespace FirstPlugin //Combine mip map data byte[] combinedMips = Utils.CombineByteArray(mipmaps.ToArray()); Texture.TextureData[ArrayLevel][0] = combinedMips; + + LoadOpenGLTexture(); + LibraryGUI.Instance.UpdateViewport(); } catch (Exception ex) { STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString()); } - - } public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0) diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index e5a6e10d..e9923959 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index 2a71ae8d..391b3a75 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ diff --git a/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs b/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs index d52098c7..10149483 100644 --- a/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs +++ b/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs @@ -107,6 +107,7 @@ namespace Switch_Toolbox.Library imgList.Images.Add("material", Properties.Resources.materialSphere); imgList.Images.Add("model", Properties.Resources.model); imgList.Images.Add("folder", Properties.Resources.skeleton); + imgList.Images.Add("TextureMaterialMap", Properties.Resources.TextureMaterialMap); //Data types imgList.Images.Add("bool", Properties.Resources.IconBool); diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs index 80f930d7..5960502b 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs @@ -37,6 +37,7 @@ this.pictureBoxCustom1 = new Switch_Toolbox.Library.Forms.PictureBoxCustom(); this.blueChannelBtn = new Switch_Toolbox.Library.Forms.STButton(); this.stPanel3 = new Switch_Toolbox.Library.Forms.STPanel(); + this.editBtn = new Switch_Toolbox.Library.Forms.STButton(); this.toggleAlphaChk = new Switch_Toolbox.Library.Forms.STCheckBox(); this.saveBtn = new Switch_Toolbox.Library.Forms.STButton(); this.arrayLevelCounterLabel = new Switch_Toolbox.Library.Forms.STLabel(); @@ -55,6 +56,7 @@ this.propertyGridToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.displayVerticalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.imageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editInExternalProgramToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.resizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reEncodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.flipHorizontalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -170,6 +172,7 @@ // // stPanel3 // + this.stPanel3.Controls.Add(this.editBtn); this.stPanel3.Controls.Add(this.toggleAlphaChk); this.stPanel3.Controls.Add(this.saveBtn); this.stPanel3.Controls.Add(this.arrayLevelCounterLabel); @@ -183,12 +186,27 @@ this.stPanel3.Size = new System.Drawing.Size(715, 51); this.stPanel3.TabIndex = 3; // + // editBtn + // + this.editBtn.BackColor = System.Drawing.Color.Transparent; + this.editBtn.BackgroundImage = global::Switch_Toolbox.Library.Properties.Resources.Edit; + this.editBtn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.editBtn.Enabled = false; + this.editBtn.FlatAppearance.BorderSize = 0; + this.editBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.editBtn.Location = new System.Drawing.Point(40, 3); + this.editBtn.Name = "editBtn"; + this.editBtn.Size = new System.Drawing.Size(24, 23); + this.editBtn.TabIndex = 16; + this.editBtn.UseVisualStyleBackColor = false; + this.editBtn.Click += new System.EventHandler(this.editBtn_Click); + // // toggleAlphaChk // this.toggleAlphaChk.AutoSize = true; this.toggleAlphaChk.Checked = true; this.toggleAlphaChk.CheckState = System.Windows.Forms.CheckState.Checked; - this.toggleAlphaChk.Location = new System.Drawing.Point(50, 7); + this.toggleAlphaChk.Location = new System.Drawing.Point(85, 7); this.toggleAlphaChk.Name = "toggleAlphaChk"; this.toggleAlphaChk.Size = new System.Drawing.Size(83, 17); this.toggleAlphaChk.TabIndex = 15; @@ -354,7 +372,7 @@ this.propertyGridToolStripMenuItem.CheckOnClick = true; this.propertyGridToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.propertyGridToolStripMenuItem.Name = "propertyGridToolStripMenuItem"; - this.propertyGridToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.propertyGridToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.propertyGridToolStripMenuItem.Text = "Property Grid"; this.propertyGridToolStripMenuItem.CheckedChanged += new System.EventHandler(this.propertyGridToolStripMenuItem_CheckedChanged); this.propertyGridToolStripMenuItem.Click += new System.EventHandler(this.propertyGridToolStripMenuItem_Click); @@ -362,7 +380,7 @@ // displayVerticalToolStripMenuItem // this.displayVerticalToolStripMenuItem.Name = "displayVerticalToolStripMenuItem"; - this.displayVerticalToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.displayVerticalToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.displayVerticalToolStripMenuItem.Text = "Display Vertical"; this.displayVerticalToolStripMenuItem.CheckedChanged += new System.EventHandler(this.displayVerticalToolStripMenuItem_CheckedChanged); this.displayVerticalToolStripMenuItem.Click += new System.EventHandler(this.displayVerticalToolStripMenuItem_Click); @@ -370,6 +388,7 @@ // imageToolStripMenuItem // this.imageToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.editInExternalProgramToolStripMenuItem, this.resizeToolStripMenuItem, this.reEncodeToolStripMenuItem, this.flipHorizontalToolStripMenuItem, @@ -381,6 +400,13 @@ this.imageToolStripMenuItem.Size = new System.Drawing.Size(52, 20); this.imageToolStripMenuItem.Text = "Image"; // + // editInExternalProgramToolStripMenuItem + // + this.editInExternalProgramToolStripMenuItem.Name = "editInExternalProgramToolStripMenuItem"; + this.editInExternalProgramToolStripMenuItem.Size = new System.Drawing.Size(230, 22); + this.editInExternalProgramToolStripMenuItem.Text = "Edit In External Program"; + this.editInExternalProgramToolStripMenuItem.Click += new System.EventHandler(this.editInExternalProgramToolStripMenuItem_Click); + // // resizeToolStripMenuItem // this.resizeToolStripMenuItem.Name = "resizeToolStripMenuItem"; @@ -513,5 +539,7 @@ private System.Windows.Forms.ToolStripMenuItem reEncodeToolStripMenuItem; private STCheckBox toggleAlphaChk; private System.Windows.Forms.ToolStripMenuItem displayVerticalToolStripMenuItem; + private STButton editBtn; + private System.Windows.Forms.ToolStripMenuItem editInExternalProgramToolStripMenuItem; } } \ No newline at end of file diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs index d15e48ab..1608466d 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs @@ -7,11 +7,16 @@ using System.Linq; using System.Activities.Statements; using System.Threading; using System.Windows.Forms; +using System.Runtime.InteropServices; +using System.IO; +using System.Diagnostics; namespace Switch_Toolbox.Library.Forms { public partial class ImageEditorBase : UserControl { + public FileSystemWatcher FileWatcher; + private Thread Thread; int CurMipDisplayLevel = 0; @@ -21,6 +26,7 @@ namespace Switch_Toolbox.Library.Forms public STGenericTexture ActiveTexture; public bool PropertyShowTop = false; + public bool CanModify = true; //Instead of disabling/enabling channels, this will only show the selected channel public bool UseChannelToggle = false; @@ -104,6 +110,7 @@ namespace Switch_Toolbox.Library.Forms imageToolStripMenuItem.Enabled = false; adjustmentsToolStripMenuItem.Enabled = false; + editBtn.BackgroundImage = BitmapExtension.GrayScale(Properties.Resources.Edit); foreach (var type in Enum.GetValues(typeof(Runtime.PictureBoxBG)).Cast()) imageBGComboBox.Items.Add(type); @@ -128,6 +135,18 @@ namespace Switch_Toolbox.Library.Forms LoadChannelEditor(null); OnDataAcquiredEvent += new DataAcquired(ThreadReportsDataAquiredEvent); + + SetUpFileSystemWatcher(); + } + + private void SetUpFileSystemWatcher() + { + FileWatcher = new FileSystemWatcher(); + FileWatcher.Path = Path.GetTempPath(); + FileWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.LastAccess | NotifyFilters.LastWrite; + FileWatcher.EnableRaisingEvents = false; + FileWatcher.Changed += new FileSystemEventHandler(OnFileWatcherChanged); + FileWatcher.Filter = ""; } public void SetEditorOrientation(bool ToVertical) @@ -155,9 +174,19 @@ namespace Switch_Toolbox.Library.Forms } public void LoadProperties(object prop) => propertiesEditor.LoadProperties(prop); - public void LoadImage(STGenericTexture texture) + { + editBtn.Enabled = false; + + //Disable the file watcher when an image is switched + FileWatcher.EnableRaisingEvents = false; + FileWatcher.Filter = ""; + + UpdateImage(texture); + } + + private void UpdateImage(STGenericTexture texture) { ResetChannelEditor(); @@ -170,6 +199,17 @@ namespace Switch_Toolbox.Library.Forms } ActiveTexture = texture; + + if (ActiveTexture.CanEdit) + { + editBtn.Enabled = true; + editBtn.BackgroundImage = Properties.Resources.Edit; + } + else + { + editBtn.BackgroundImage = BitmapExtension.GrayScale(Properties.Resources.Edit); + } + CurMipDisplayLevel = 0; CurArrayDisplayLevel = 0; hasBeenEdited = false; @@ -770,5 +810,90 @@ namespace Switch_Toolbox.Library.Forms splitContainer1.SplitterDistance = this.Height / 2; } + + private void editBtn_Click(object sender, EventArgs e) { + EditInExternalProgram(); + } + + private void editInExternalProgramToolStripMenuItem_Click(object sender, EventArgs e) { + EditInExternalProgram(); + } + + private void EditInExternalProgram(bool UseDefaultEditor = true) + { + if (!ActiveTexture.CanEdit) + return; + + string UseExtension = ".dds"; + + string TemporaryName = Path.GetTempFileName(); + Utils.DeleteIfExists(Path.ChangeExtension(TemporaryName, UseExtension)); + File.Move(TemporaryName, Path.ChangeExtension(TemporaryName, UseExtension)); + TemporaryName = Path.ChangeExtension(TemporaryName, ".dds"); + + ActiveTexture.SaveDDS(TemporaryName); + + if (UseDefaultEditor) + Process.Start(TemporaryName); + else + ShowOpenWithDialog(TemporaryName); + + FileWatcher.Filter = Path.GetFileName(TemporaryName); + + //Start watching for changes + FileWatcher.EnableRaisingEvents = true; + } + + public static Process ShowOpenWithDialog(string path) + { + var args = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "shell32.dll"); + args += ",OpenAs_RunDLL " + path; + return Process.Start("rundll32.exe", args); + } + + private void OnFileWatcherChanged(object sender, FileSystemEventArgs e) + { + string FileName = e.FullPath; + + Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType); + var Result = MessageBox.Show("Texture has been modifed in external program! Would you like to apply the edits?", "Texture Editor", + MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); + + if (Result == DialogResult.Yes) + { + if (FileName.EndsWith(".dds")) + { + DDS dds = new DDS(FileName); + SaveAndApplyImage(dds.GetBitmap()); + } + else + { + SaveAndApplyImage(new Bitmap(FileName)); + } + } + else + { + FileWatcher.Filter = ""; + FileWatcher.EnableRaisingEvents = false; + } + } + + private void SaveAndApplyImage(Bitmap image) + { + if (saveBtn.InvokeRequired) + { + saveBtn.Invoke(new MethodInvoker( + delegate () + { + UpdateEdit(image); + ApplyEdit(); + })); + } + else + { + UpdateEdit(image); + ApplyEdit(); + } + } } } diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx index 851b0a13..57b6267d 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx @@ -117,9 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - @@ -328,6 +325,9 @@ mGk4zW7tt3aFGa0JAhPXKv5Grfv8ckaj93+veSuXxEAIUwAAAABJRU5ErkJggg== + + 17, 17 + 25 diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImagePropertiesEditor.cs b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImagePropertiesEditor.cs index a6be96c9..a2e207b1 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImagePropertiesEditor.cs +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImagePropertiesEditor.cs @@ -68,12 +68,36 @@ namespace Switch_Toolbox.Library.Forms public void LoadProperties(object prop) { - stPropertyGrid1.LoadProperty(prop, OnPropertyChanged); - stPropertyGrid1.Refresh(); + if (stPropertyGrid1.InvokeRequired) + { + stPropertyGrid1.Invoke(new MethodInvoker( + delegate () + { + stPropertyGrid1.LoadProperty(prop, OnPropertyChanged); + stPropertyGrid1.Refresh(); + })); + } + else + { + stPropertyGrid1.LoadProperty(prop, OnPropertyChanged); + stPropertyGrid1.Refresh(); + } + } + + public void UpdateProperties() + { + if (stPropertyGrid1.InvokeRequired) + { + stPropertyGrid1.Invoke(new MethodInvoker( + delegate () + { + stPropertyGrid1.Refresh(); + })); + } + else + stPropertyGrid1.Refresh(); } - public void UpdateProperties() => stPropertyGrid1.Refresh(); - public void OnPropertyChanged() { } diff --git a/Switch_Toolbox_Library/Imaging/BitmapExtension.cs b/Switch_Toolbox_Library/Imaging/BitmapExtension.cs index 71615e3d..c91e77cf 100644 --- a/Switch_Toolbox_Library/Imaging/BitmapExtension.cs +++ b/Switch_Toolbox_Library/Imaging/BitmapExtension.cs @@ -297,10 +297,12 @@ namespace Switch_Toolbox.Library return true; } - public static bool GrayScale(Bitmap b) + public static Bitmap GrayScale(Image b) { return GrayScale(new Bitmap(b)); + } + public static Bitmap GrayScale(Bitmap b) { BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), - ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); + ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); int stride = bmData.Stride; System.IntPtr Scan0 = bmData.Scan0; @@ -308,9 +310,9 @@ namespace Switch_Toolbox.Library { byte* p = (byte*)(void*)Scan0; - int nOffset = stride - b.Width * 3; + int nOffset = stride - b.Width * 4; - byte red, green, blue; + byte red, green, blue, alpha; for (int y = 0; y < b.Height; ++y) { @@ -319,12 +321,13 @@ namespace Switch_Toolbox.Library blue = p[0]; green = p[1]; red = p[2]; + alpha = p[3]; p[0] = p[1] = p[2] = (byte)(.299 * red + .587 * green + .114 * blue); - p += 3; + p += 4; } p += nOffset; } @@ -332,7 +335,7 @@ namespace Switch_Toolbox.Library b.UnlockBits(bmData); - return true; + return b; } public static bool Invert(Bitmap b) { diff --git a/Switch_Toolbox_Library/Properties/Resources.Designer.cs b/Switch_Toolbox_Library/Properties/Resources.Designer.cs index fc9472df..c6b9449f 100644 --- a/Switch_Toolbox_Library/Properties/Resources.Designer.cs +++ b/Switch_Toolbox_Library/Properties/Resources.Designer.cs @@ -290,6 +290,16 @@ namespace Switch_Toolbox.Library.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap Edit { + get { + object obj = ResourceManager.GetObject("Edit", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -820,6 +830,16 @@ namespace Switch_Toolbox.Library.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap TextureMaterialMap { + get { + object obj = ResourceManager.GetObject("TextureMaterialMap", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/Switch_Toolbox_Library/Properties/Resources.resx b/Switch_Toolbox_Library/Properties/Resources.resx index 2cb2614f..4da70120 100644 --- a/Switch_Toolbox_Library/Properties/Resources.resx +++ b/Switch_Toolbox_Library/Properties/Resources.resx @@ -160,20 +160,23 @@ ..\Resources\ErrorCheck.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\minimize_sele.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Bfres.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\Bone.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\diffuseSphere.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\boneWeightGradient2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\maximize_sele.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\diffuseSphere.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\DataTyypes\IconCurve.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\skeleton.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -187,9 +190,6 @@ ..\Resources\mesh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\DataTyypes\IconVec3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\arrowL.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -211,9 +211,6 @@ ..\Resources\DefaultTexture.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Playback\PauseBtn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\Byaml.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -226,6 +223,9 @@ ..\Resources\model.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\skeletonAnimation.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\DataTyypes\IconFloat.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -235,18 +235,15 @@ ..\Resources\Cubemaps\specularSDR.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\InjectTexErrored.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\normalsSphere.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\FileBank.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\boneWeightGradient.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\arrowMinimize .png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\DataTyypes\IconList.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -268,6 +265,9 @@ ..\Resources\normalMapSphere.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Aamp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\Texture.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -283,11 +283,20 @@ ..\Resources\NumbericUpDownArrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\TextureMaterialMap.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\minimize_sele.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Forms\Toolbar\images\minimize_sele.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Aamp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\DataTyypes\IconVec3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\QuestionCheck.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\Folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -301,11 +310,8 @@ ..\Resources\LoadingImage.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Bfres.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\DataTyypes\IconCurve.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\InjectTexErrored.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ..\Resources\Bnsh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -322,8 +328,8 @@ ..\Resources\CheckerBackground.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\skeletonAnimation.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\arrowMinimize .png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\UVPattern.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -334,8 +340,8 @@ ..\Resources\Playback\ResetArrowR.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\FileBank.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Playback\PauseBtn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\CheckBox\Hovered.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -349,7 +355,7 @@ ..\Resources\minimize.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\QuestionCheck.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/Switch_Toolbox_Library/Resources/Edit.png b/Switch_Toolbox_Library/Resources/Edit.png new file mode 100644 index 00000000..56d13437 Binary files /dev/null and b/Switch_Toolbox_Library/Resources/Edit.png differ diff --git a/Switch_Toolbox_Library/Resources/TextureError.png b/Switch_Toolbox_Library/Resources/TextureError.png index 3d1d3e3d..64579d18 100644 Binary files a/Switch_Toolbox_Library/Resources/TextureError.png and b/Switch_Toolbox_Library/Resources/TextureError.png differ diff --git a/Switch_Toolbox_Library/Resources/TextureMaterialMap.png b/Switch_Toolbox_Library/Resources/TextureMaterialMap.png new file mode 100644 index 00000000..1ba028a9 Binary files /dev/null and b/Switch_Toolbox_Library/Resources/TextureMaterialMap.png differ diff --git a/Switch_Toolbox_Library/Resources/materialSphere.png b/Switch_Toolbox_Library/Resources/materialSphere.png index bf30ffa2..f56a54c8 100644 Binary files a/Switch_Toolbox_Library/Resources/materialSphere.png and b/Switch_Toolbox_Library/Resources/materialSphere.png differ diff --git a/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj b/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj index 11c445e1..b9b4d6a7 100644 --- a/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj +++ b/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj @@ -996,6 +996,12 @@ + + + + + + diff --git a/Switch_Toolbox_Library/Util/Util.cs b/Switch_Toolbox_Library/Util/Util.cs index d83114cf..9015840b 100644 --- a/Switch_Toolbox_Library/Util/Util.cs +++ b/Switch_Toolbox_Library/Util/Util.cs @@ -36,6 +36,12 @@ namespace Switch_Toolbox.Library color.A.ToString("X2"); } + public static void DeleteIfExists(string FilePath) + { + if (File.Exists(FilePath)) + File.Delete(FilePath); + } + public static Color HexToColor(string HexText) { try