From 216d772dbb09f5d47f76b0eb1bcc29095cfed535 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Fri, 23 Nov 2018 12:51:08 -0500 Subject: [PATCH] Update placeholder textures and fill channel types by format --- .../FileFormats/BFRES/Bfres Structs/FMAA.cs | 2 - .../FileFormats/Texture/BNTX.cs | 48 ++++++++++++++---- .../GUI/TextureUI/TextureImporterSettings.cs | 11 ++-- .../Properties/Resources.Designer.cs | 20 ++++++++ .../Properties/Resources.resx | 6 +++ .../Resources/BakedBasic.zip | Bin 0 -> 386 bytes .../Resources/Basic_Bake_st0.dds | Bin 0 -> 824 bytes .../Resources/Basic_Bake_st1.dds | Bin 0 -> 1520 bytes .../Switch_FileFormatsMain.csproj | 6 +++ .../Lib/Syroot.NintenTools.NSW.Bfres.dll | Bin 221696 -> 221696 bytes .../Lib/Syroot.NintenTools.NSW.Bfres.pdb | Bin 99892 -> 99912 bytes Switch_Toolbox/MainForm.cs | 4 ++ Switch_Toolbox_Library/GUI.cs | 29 +++++++---- 13 files changed, 101 insertions(+), 25 deletions(-) create mode 100644 Switch_FileFormatsMain/Resources/BakedBasic.zip create mode 100644 Switch_FileFormatsMain/Resources/Basic_Bake_st0.dds create mode 100644 Switch_FileFormatsMain/Resources/Basic_Bake_st1.dds diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/FMAA.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/FMAA.cs index a40f5c3c..d1c451e9 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/FMAA.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/FMAA.cs @@ -40,8 +40,6 @@ namespace Bfres.Structs ((FMAA)fmaa).MaterialAnim.Export(FileName, fmaa.GetResFile()); } } - - } private void Clear(object sender, EventArgs args) { diff --git a/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs b/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs index 63fa4367..48cca70d 100644 --- a/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs +++ b/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs @@ -480,9 +480,9 @@ namespace FirstPlugin if (TextureName == "Basic_MRA") ImportPlaceholderTexture(Properties.Resources.Black, TextureName); if (TextureName == "Basic_Bake_st0") - ImportPlaceholderTexture(Properties.Resources.White, TextureName); + ImportPlaceholderTexture(Properties.Resources.Basic_Bake_st0, TextureName); if (TextureName == "Basic_Bake_st1") - ImportPlaceholderTexture(Properties.Resources.White, TextureName); + ImportPlaceholderTexture(Properties.Resources.Basic_Bake_st1, TextureName); } public TextureImporterSettings LoadSettings(string name) { @@ -724,16 +724,17 @@ namespace FirstPlugin int target = 0; if (TargetString == "NX ") target = 1; - - } public override void OnClick(TreeView treeView) { - BNTXEditor BNTXEditor = new BNTXEditor(); - BNTXEditor.Text = Text; - BNTXEditor.Dock = DockStyle.Fill; - BNTXEditor.LoadProperty(this); - LibraryGUI.Instance.LoadDockContent(BNTXEditor, PluginRuntime.FSHPDockState); + if (LibraryGUI.Instance.dockContent != null && !EditorIsActive(LibraryGUI.Instance.dockContent)) + { + BNTXEditor BNTXEditor = new BNTXEditor(); + BNTXEditor.Text = Text; + BNTXEditor.Dock = DockStyle.Fill; + BNTXEditor.LoadProperty(this); + LibraryGUI.Instance.LoadDockContent(BNTXEditor, PluginRuntime.FSHPDockState); + } } public bool EditorIsActive(DockContent dock) { @@ -1322,6 +1323,35 @@ namespace FirstPlugin { return ColorComponentSelector(image, Texture.ChannelRed, Texture.ChannelGreen, Texture.ChannelBlue, Texture.ChannelAlpha); } + public static ChannelType[] SetChannelsByFormat(SurfaceFormat Format) + { + ChannelType[] channels = new ChannelType[4]; + + switch (Format) + { + case SurfaceFormat.BC5_UNORM: + case SurfaceFormat.BC5_SNORM: + channels[0] = ChannelType.Red; + channels[1] = ChannelType.Green; + channels[2] = ChannelType.Zero; + channels[3] = ChannelType.One; + break; + case SurfaceFormat.BC4_SNORM: + case SurfaceFormat.BC4_UNORM: + channels[0] = ChannelType.Red; + channels[1] = ChannelType.Red; + channels[2] = ChannelType.Red; + channels[3] = ChannelType.Red; + break; + default: + channels[0] = ChannelType.Red; + channels[1] = ChannelType.Green; + channels[2] = ChannelType.Blue; + channels[3] = ChannelType.Alpha; + break; + } + return channels; + } public static Bitmap ColorComponentSelector(Bitmap image, ChannelType R, ChannelType G, ChannelType B, ChannelType A) { BitmapExtension.ColorSwapFilter color = new BitmapExtension.ColorSwapFilter(); diff --git a/Switch_FileFormatsMain/GUI/TextureUI/TextureImporterSettings.cs b/Switch_FileFormatsMain/GUI/TextureUI/TextureImporterSettings.cs index d520fbcd..ca31cadf 100644 --- a/Switch_FileFormatsMain/GUI/TextureUI/TextureImporterSettings.cs +++ b/Switch_FileFormatsMain/GUI/TextureUI/TextureImporterSettings.cs @@ -274,16 +274,17 @@ namespace FirstPlugin if (settings.MipCount == 0) settings.MipCount = 1; - + + ChannelType[] channels = TextureData.SetChannelsByFormat(settings.Format); + tex.ChannelRed = channels[0]; + tex.ChannelGreen = channels[1]; + tex.ChannelBlue = channels[2]; + tex.ChannelAlpha = channels[3]; tex.sparseBinding = settings.sparseBinding; tex.sparseResidency = settings.sparseResidency; tex.AccessFlags = settings.AccessFlags; tex.ArrayLength = settings.arrayLength; tex.MipCount = settings.MipCount; - tex.ChannelRed = settings.RedComp; - tex.ChannelGreen = settings.GreenComp; - tex.ChannelBlue = settings.BlueComp; - tex.ChannelAlpha = settings.AlphaComp; tex.Depth = settings.Depth; tex.Dim = settings.Dim; tex.Flags = settings.Flags; diff --git a/Switch_FileFormatsMain/Properties/Resources.Designer.cs b/Switch_FileFormatsMain/Properties/Resources.Designer.cs index 2e4d973f..3347895e 100644 --- a/Switch_FileFormatsMain/Properties/Resources.Designer.cs +++ b/Switch_FileFormatsMain/Properties/Resources.Designer.cs @@ -70,6 +70,26 @@ namespace FirstPlugin.Properties { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Basic_Bake_st0 { + get { + object obj = ResourceManager.GetObject("Basic_Bake_st0", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Basic_Bake_st1 { + get { + object obj = ResourceManager.GetObject("Basic_Bake_st1", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// diff --git a/Switch_FileFormatsMain/Properties/Resources.resx b/Switch_FileFormatsMain/Properties/Resources.resx index c2ed4034..0439ca74 100644 --- a/Switch_FileFormatsMain/Properties/Resources.resx +++ b/Switch_FileFormatsMain/Properties/Resources.resx @@ -139,4 +139,10 @@ ..\Resources\White.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\Basic_Bake_st0.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Basic_Bake_st1.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/Switch_FileFormatsMain/Resources/BakedBasic.zip b/Switch_FileFormatsMain/Resources/BakedBasic.zip new file mode 100644 index 0000000000000000000000000000000000000000..82f09a09fa1c288560fcba326db991ade89f247d GIT binary patch literal 386 zcmWIWW@Zs#U|`^2@Qx|>RX(@(q!W;5!OXxQ1f-o3i!+nsof5NCvtRuG@Be>(h5)#YWk4IBMqMfN0^0O}6^o6A*lj!nwUMnO3}|66)WT_H0>AFp z_dfdXU~o$QY5ynppNnfw{d|3WeN^k2_`O+IwSYD=GKnzY_ASsEK%f97vH2ZYKQ^~R eG=lUO0WnJ0fqfF-&B_K+!vus4K>7`c!vFx?8gbbG literal 0 HcmV?d00001 diff --git a/Switch_FileFormatsMain/Resources/Basic_Bake_st0.dds b/Switch_FileFormatsMain/Resources/Basic_Bake_st0.dds new file mode 100644 index 0000000000000000000000000000000000000000..d46533f23c8af3a6929a4769b872820a7179ed9a GIT binary patch literal 824 zcmZ>930A0KU|?Vu;9^h!(jd&h1R@w1*dP?qqykVS3lO_RgcxGe#3A5-A>8oy!T(i2 YFiMYx!(dMbzkdDy4@#&1{{R0E0F-eNl>h($ literal 0 HcmV?d00001 diff --git a/Switch_FileFormatsMain/Resources/Basic_Bake_st1.dds b/Switch_FileFormatsMain/Resources/Basic_Bake_st1.dds new file mode 100644 index 0000000000000000000000000000000000000000..f4849daad79022fb8a8cfa002acba68177560a1b GIT binary patch literal 1520 zcmZ>930A0KU|?Vu;9^h!(jd&h0wNd~*dP?qqykVSNUKXkh$%Kr90Cp)!j^Urp@081 mivI(_D1S6OKp`-i9!B%SXn8FQOhRsjG)pJl=T literal 0 HcmV?d00001 diff --git a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj index d87a228b..fab5e50c 100644 --- a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj +++ b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj @@ -505,6 +505,12 @@ True + + + + + + diff --git a/Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll b/Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll index 99a3286de68319b89183381298bfded5ae2a72b0..3b110e65e7c8f37d7e7768f80af5903e5043216b 100644 GIT binary patch delta 3158 zcmZYBdr(x@9S87p_Wtf=7opje2&=Lt=(N1nN0Z53MnK&WgW7gvS}lZNYK)-7L{O@U zY0L!|H%1J@4w-BlHNNsc88Jr#0LWj;!k|{|r)V}k z+}=bD*Va7>;eV^y%SKev7;xD-T{fCgoO6W|GDL`r5T))5LXwm7pU~=Vvo|wHQr&xm zXzn;ov3nm0mo2C1Gi~#7PEnG~+GusN*r0_Uh3nbpa|#`zCJl%SMAe))O;cT}H!FN% zIdvOTbq-ng*T@WqH_1`=Fl$2Y;M{3ievwPgo|Z&ha{hGI$?mdyvxv==^sDCxft*b$ z(O7J&`+%*3O!a29Vo_a@RF~$pGh+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@c0l@m^BKCB}P61=s7NaXdI0SMJWw zeCXgGD}7~-s=?c>HS;!}C>V@qs}BUS*9VkS2tQG+(5LMveO11sqRL1?jhd^)>Dzcs zWJ!(sVCJ^@)pIUBdF}DvPapg1driKwNNbJyUa9=ly;gq8n(e+hmN@G>){vEcD!Ewx qzfb$3)sd=NH6O1WTwALS;69)7z~Fc4)VoA!_78gM)tfl%bNnBWoiSqo diff --git a/Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb b/Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb index a8815baf4b5a9f1cbe46f6c2ffbec88fc70d51b1..b73bfd5b07e1ed00324926105b951c360aa3a850 100644 GIT binary patch delta 1981 zcmai!drVVz6vxlGrKObuT6tAaiUx3m-~^YIVI0L7A(@Y;)0v6Z8QH@r3`8D-w5U~L zd@bmHy3D0Zbn1Kz1Vdtj7LWl#A4Z+o<^nTrGjp59C}w14``$~7{9(46e!l1TJ-_oi zzhCdYxh=ajJ-apgOH9tIMAPy$ccvN>3hr3QmFRAf`8uQhRZFVlwwK<$`>$ z82qf{9y}$|1f#iN2MR|1e3RnkhzzJGC@;V)P1M!9uwIj(}o`!Z~ ztQyl9UU}5uH>zzqD)-9MVN~l4BL~<64uT^}KAesP;%OyDP_s9JT%c3&^4bXMQ^t{W zO^F8j-fN)S;5YCP3@iDGB>5(i4vhE7>!K+(*%wVyK(a5E(v_r zE8r`e58F1R+6r8BT18*DOi;5v7ka!c_jCw7XtOFAyF7c*4K-eJpHY#^JqWe7(^(Y_ zwVR-Y9l20*oE3Vx!wya8bVGM_4nm)H($^}=zHEX{>&k_G-eraU*=2{SZQX7JSN9+^ zwuc(!M!C>IwnD>u?a({qR5Z6qMg6^2=-n%(b8_AaHT2t|zd%DM+~dZ0m1huI?J>2e zD9vkXQIpY2=T%e;Ra23dTq^q3M=mvW`NFJiDoXJ?-Duq$ej?@g-2AGrqPrU=7wk&f zy|nDmz9-SeQL~b8A7gg@s0*dk#_#k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&})Z&a@l@1fbL&*VZE?#0J^@< z+^nNmkGWY-dJlb|qXMX&@;%g|qYf{%=&8{gVr|t?l<$ZOqnpBxr_|3sW~q%n-fZda z$k=zjIq#q9)Z7IHcvC30`l>OAQX8&^h7&8>nGzL4C`Bn01Y4fs*D)lld29}n?Tswn z&K)(8VsOk%ktTh(ZFXpc-&C_U^?yb;s$$OA=%xPW6#7?+#p$s&hjxQ_=TIKkP2$zU zv576?abvs@nkZY-gNg8E3VK9*wuz^Ut3@0Z?3bKWG@Oi4(DA&#IaS1q(@g9zDULOP zm5E%Ls8qfXxN92knx^b33f!H=yR($tWz+3HV}4bKNZQP^6MBtI(TX96f))JJgeVlC z-NbRjKBP5Wb8g$ra}{178n$p8FBd&q_@Jo_dnPM}FfuCm(?k0b`)zdZsT37kdG(xH zlq0o~lNB24nSf`)dk&#y*0##y9`28owR#b;jboo_L`#D9H2+&|MS9BUP8=F3H+3WZ zsFp@%c#IF3WdGaQ2km#Xv%hxQws9D9v_MP{C%1D6TSQ_Bzrh9KTnVq?5)oU<7OoVz zrJTz9MQJIojy{2TDT*OVJ0aixJ0?{(h#yM1fG>#oWn9Mn;-fOo;A>*2jQ>!oABe$n zeu=}ystR7ranAY*&SX;_ri3a61BH+LW~KJOF>3E}ad!t-^G2~_C+Fh=o}IjwbDT3? z=0F4Q6IoT9!^gxcRh-ODanr_0LD~;FckdOv%sTizcOY*ISLC6MI-5!Z|M&ex= KBODW#p!_c^UIV27 diff --git a/Switch_Toolbox/MainForm.cs b/Switch_Toolbox/MainForm.cs index 804c2e84..2a564346 100644 --- a/Switch_Toolbox/MainForm.cs +++ b/Switch_Toolbox/MainForm.cs @@ -289,6 +289,8 @@ namespace Switch_Toolbox } if (format.UseEditMenu) editToolStripMenuItem.Enabled = true; + + return; } } //If magic fails, then check extensions @@ -317,6 +319,8 @@ namespace Switch_Toolbox } if (format.UseEditMenu) editToolStripMenuItem.Enabled = true; + + return; } } } diff --git a/Switch_Toolbox_Library/GUI.cs b/Switch_Toolbox_Library/GUI.cs index 0a448f9e..93ca255a 100644 --- a/Switch_Toolbox_Library/GUI.cs +++ b/Switch_Toolbox_Library/GUI.cs @@ -19,26 +19,36 @@ namespace Switch_Toolbox.Library public static LibraryGUI Instance { get { return _instance == null ? _instance = new LibraryGUI() : _instance; } } public DockPanel dockPanel; + public DockContent dockContent; public void LoadDockContent(Control control, DockState dockState) { - DockContent content = new DockContent(); - content.Controls.Add(control); - content.Show(dockPanel, dockState); + dockContent = new DockContent(); + dockContent.Controls.Add(control); + dockContent.Show(dockPanel, dockState); } - public bool IsContentDocked(Control control) + public UserControl GetContentDocked(UserControl control) { foreach (DockContent dockContent in dockPanel.Contents) { foreach (Control ctrl in dockContent.Controls) - if (ctrl == control) - return true; + if (ctrl.GetType() == control.GetType()) + return (UserControl)ctrl; } - return false; + return null; + } + public DockContent GetContentDocked(DockContent DockContent) + { + foreach (DockContent dock in dockPanel.Contents) + if (dock.GetType() == DockContent.GetType()) + return dock; + + return null; } public void LoadDockContent(DockContent DockContent, DockState dockState) { - DockContent.Show(dockPanel, dockState); + dockContent = DockContent; + dockContent.Show(dockPanel, dockState); } public void LoadViewport(Viewport viewport) { @@ -47,8 +57,9 @@ namespace Switch_Toolbox.Library viewport.Show(dockPanel, DockState.Document); } - public bool IsContentActive(DockContent dockContent) + public bool IsContentActive(DockContent DockContent) { + dockContent = DockContent; return dockPanel.Contents.Contains(dockContent); } }