From 8a7787e326ffead0d509589dbbc09ce39be93e54 Mon Sep 17 00:00:00 2001 From: leathl Date: Thu, 31 Dec 2009 03:34:47 +0000 Subject: [PATCH] Replaced the TPL preview window with the one from ShowMiiWads --- CustomizeMii/CustomizeMii.csproj | 20 +- CustomizeMii/CustomizeMii_Main.Designer.cs | 18 +- CustomizeMii/CustomizeMii_Main.cs | 426 +++++++++--------- CustomizeMii/CustomizeMii_Preview.Designer.cs | 256 ++++++++++- CustomizeMii/CustomizeMii_Preview.cs | 199 +++++++- CustomizeMii/CustomizeMii_Preview.resx | 6 + CustomizeMii/Properties/Resources.Designer.cs | 11 +- CustomizeMii/Properties/Resources.resx | 9 +- CustomizeMii/Readme.txt | 5 + .../{btnCreateWad.png => btnCreate.png} | Bin 5352 -> 3444 bytes CustomizeMii/Resources/btnSend.png | Bin 0 -> 3414 bytes 11 files changed, 691 insertions(+), 259 deletions(-) rename CustomizeMii/Resources/{btnCreateWad.png => btnCreate.png} (50%) create mode 100644 CustomizeMii/Resources/btnSend.png diff --git a/CustomizeMii/CustomizeMii.csproj b/CustomizeMii/CustomizeMii.csproj index 23abde7..bf6c750 100644 --- a/CustomizeMii/CustomizeMii.csproj +++ b/CustomizeMii/CustomizeMii.csproj @@ -83,12 +83,6 @@ CustomizeMii_Main.cs - - Form - - - CustomizeMii_Preview.cs - Form @@ -109,9 +103,6 @@ CustomizeMii_Main.cs - - CustomizeMii_Preview.cs - ResXFileCodeGenerator Resources.Designer.cs @@ -128,12 +119,21 @@ + + CustomizeMii_Preview.cs + True Settings.settings True + + Form + + + CustomizeMii_Preview.cs + @@ -141,6 +141,8 @@ + + diff --git a/CustomizeMii/CustomizeMii_Main.Designer.cs b/CustomizeMii/CustomizeMii_Main.Designer.cs index b0ce432..eb469d0 100644 --- a/CustomizeMii/CustomizeMii_Main.Designer.cs +++ b/CustomizeMii/CustomizeMii_Main.Designer.cs @@ -52,7 +52,6 @@ namespace CustomizeMii this.tabSource = new System.Windows.Forms.TabPage(); this.tbReplace = new System.Windows.Forms.TextBox(); this.btnBrowseReplace = new System.Windows.Forms.Button(); - this.btnClearReplace = new System.Windows.Forms.Button(); this.cmbReplace = new System.Windows.Forms.ComboBox(); this.btnSaveBaseWad = new System.Windows.Forms.Button(); this.btnPreviewBaseWad = new System.Windows.Forms.Button(); @@ -221,7 +220,6 @@ namespace CustomizeMii // this.tabSource.Controls.Add(this.tbReplace); this.tabSource.Controls.Add(this.btnBrowseReplace); - this.tabSource.Controls.Add(this.btnClearReplace); this.tabSource.Controls.Add(this.cmbReplace); this.tabSource.Controls.Add(this.btnSaveBaseWad); this.tabSource.Controls.Add(this.btnPreviewBaseWad); @@ -243,13 +241,14 @@ namespace CustomizeMii this.tbReplace.Location = new System.Drawing.Point(100, 173); this.tbReplace.Name = "tbReplace"; this.tbReplace.ReadOnly = true; - this.tbReplace.Size = new System.Drawing.Size(173, 20); + this.tbReplace.Size = new System.Drawing.Size(254, 20); this.tbReplace.TabIndex = 10; this.tbReplace.Tag = "Disabled"; + this.tbReplace.TextChanged += new System.EventHandler(this.tbReplace_TextChanged); // // btnBrowseReplace // - this.btnBrowseReplace.Location = new System.Drawing.Point(279, 172); + this.btnBrowseReplace.Location = new System.Drawing.Point(360, 171); this.btnBrowseReplace.Name = "btnBrowseReplace"; this.btnBrowseReplace.Size = new System.Drawing.Size(75, 23); this.btnBrowseReplace.TabIndex = 9; @@ -257,16 +256,6 @@ namespace CustomizeMii this.btnBrowseReplace.UseVisualStyleBackColor = true; this.btnBrowseReplace.Click += new System.EventHandler(this.btnBrowseReplace_Click); // - // btnClearReplace - // - this.btnClearReplace.Location = new System.Drawing.Point(360, 172); - this.btnClearReplace.Name = "btnClearReplace"; - this.btnClearReplace.Size = new System.Drawing.Size(75, 23); - this.btnClearReplace.TabIndex = 8; - this.btnClearReplace.Text = "Clear"; - this.btnClearReplace.UseVisualStyleBackColor = true; - this.btnClearReplace.Click += new System.EventHandler(this.btnClearReplace_Click); - // // cmbReplace // this.cmbReplace.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -1562,7 +1551,6 @@ namespace CustomizeMii private System.Windows.Forms.ComboBox cmbReplace; private System.Windows.Forms.TextBox tbReplace; private System.Windows.Forms.Button btnBrowseReplace; - private System.Windows.Forms.Button btnClearReplace; private System.Windows.Forms.CheckBox cbLz77; private System.Windows.Forms.LinkLabel llbSite; private System.Windows.Forms.TabPage tabBrlyt; diff --git a/CustomizeMii/CustomizeMii_Main.cs b/CustomizeMii/CustomizeMii_Main.cs index 7b53ca9..d6cfba6 100644 --- a/CustomizeMii/CustomizeMii_Main.cs +++ b/CustomizeMii/CustomizeMii_Main.cs @@ -36,11 +36,15 @@ namespace CustomizeMii { public partial class CustomizeMii_Main : Form { + #region Constants const string version = "2.1"; //Hint for myself: Never use a char in the Version (UpdateCheck)! const int SoundMaxLength = 30; //In seconds const int SoundWarningLength = 20; //In seconds const int BnsWarningLength = 45; //In seconds - const int CreditsScrollSpeed = 85; //Timer Intervall for the scrolling Credits + const int CreditsScrollSpeed = 75; //Timer Intervall for the scrolling Credits + #endregion + + #region Variables public static string TempPath = Path.GetTempPath() + "CustomizeMii_Temp\\XXX\\"; public static string TempWadPath = Path.GetTempPath() + "CustomizeMii_Temp\\XXX\\TempWad.wad"; public static string TempUnpackPath = Path.GetTempPath() + "CustomizeMii_Temp\\XXX\\Unpack\\"; @@ -57,18 +61,18 @@ namespace CustomizeMii public static string TempUnpackIconBrlytPath = Path.GetTempPath() + "CustomizeMii_Temp\\XXX\\Unpack\\00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\blyt\\"; public static string TempUnpackBannerBrlanPath = Path.GetTempPath() + "CustomizeMii_Temp\\XXX\\Unpack\\00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\anim\\"; public static string TempUnpackIconBrlanPath = Path.GetTempPath() + "CustomizeMii_Temp\\XXX\\Unpack\\00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\anim\\"; - public static string[] ButtonTexts = new string[] { "Image", "Create WAD!", "Fire!", "Go Go Go!", "Let's do it!", "What are you waitin' for?", "I want my Channel!", "Houston, We've Got a Problem!", "Error, please contact anyone!", "Isn't she sweet?", "Is that milk?", "In your face!", "_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_", "Take me to a higher place!", "What's goin' on?", "I'm a Button!", "Click!", "Today's date is " + DateTime.Now.ToShortDateString(), "Launch Time: " + DateTime.Now.ToLongTimeString(), string.Format("My name is {0}", Environment.UserName) }; + //public static string[] ButtonTexts = new string[] { "Create WAD!", "Fire!", "Go Go Go!", "Let's do it!", "What are you waitin' for?", "I want my Channel!", "Houston, We've Got a Problem!", "Error, please contact anyone!", "Isn't she sweet?", "Is that milk?", "In your face!", "_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_", "Take me to a higher place!", "What's goin' on?", "I'm a Button!", "Click!", "Today's date is " + DateTime.Now.ToShortDateString(), "Launch Time: " + DateTime.Now.ToLongTimeString(), string.Format("My name is {0}", Environment.UserName) }; public static string[] SourceWadUrls = new string[] { "StaticBase.wad", "MPlayer_CE_Short.wad", "MPlayer_CE_Long.wad", "Snes9xGX.wad", "FCE_Ultra_wilsoff.wad", "FCE_Ultra_Leathl.wad", "Wii64.wad", "WiiSX_Full.wad", "WiiSX_Retro.wad", "WADder_Base_1.wad", "WADder_Base_2.wad", "WADder_Base_3.wad", "UniiLoader.wad", "Backup_Channel.wad" }; public static string[] SourceWadPreviewUrls = new string[] { "http://www.youtube.com/watch?v=pFNKldTYQq0", "http://www.youtube.com/watch?v=Up1RZebUc_U", "http://www.youtube.com/watch?v=Up1RZebUc_U", "http://www.youtube.com/watch?v=P-Mxd6DMvFY", "http://www.youtube.com/watch?v=wrbrg-DH_h4", "http://www.youtube.com/watch?v=MfiVbQaiXw8", "http://www.youtube.com/watch?v=krCQ2J7ZH8Y", "http://www.youtube.com/watch?v=rZC1DKUM6QI", "http://www.youtube.com/watch?v=Uiy8w-bp1kI", "http://www.youtube.com/watch?v=BbSYCSI8tz8", "http://www.youtube.com/watch?v=PIFZevHQ8lQ", "http://www.youtube.com/watch?v=OIhvDNjphhc", "http://www.youtube.com/watch?v=KLcncEArQLY&NR=1", "http://www.youtube.com/watch?v=xE_EgdCRV1I" }; - private string BannerTplPath = string.Empty; - private string IconTplPath = string.Empty; + public static string BannerReplace = string.Empty; + public static string IconReplace = string.Empty; + public static string BannerTplPath = string.Empty; + public static string IconTplPath = string.Empty; private string SourceWad = string.Empty; private string BannerBrlytPath = string.Empty; private string IconBrlytPath = string.Empty; private string BannerBrlanPath = string.Empty; private string IconBrlanPath = string.Empty; - private string BannerReplace = string.Empty; - private string IconReplace = string.Empty; private string SoundReplace = string.Empty; private bool BrlytChanged = false; private bool BrlanChanged = false; @@ -83,8 +87,10 @@ namespace CustomizeMii private Forwarder.Complex ComplexForwarder = new Forwarder.Complex(); private delegate void BoxInvoker(string message); private delegate void SetTextInvoker(string text, TextBox tb); - double separatorBtn; - Timer tmrCredits = new Timer(); + private double separatorBtn; + private Timer tmrCredits = new Timer(); + private ToolTip tTip = new ToolTip(); + #endregion public CustomizeMii_Main() { @@ -176,15 +182,6 @@ namespace CustomizeMii #endif } - void rtbInstructions_LinkClicked(object sender, LinkClickedEventArgs e) - { - try - { - Process.Start(e.LinkText); - } - catch (Exception ex) { ErrorBox(ex.Message); } - } - private void SetForwardMiiLabel() { try @@ -276,38 +273,37 @@ namespace CustomizeMii private void SetToolTips() { - ToolTip TTip = new ToolTip(); - TTip.SetToolTip(btnCreateWad, "Save WAD or send it directly to the Wii..."); - TTip.SetToolTip(btnBrowseSource, "Browse for a WAD that is used as a Base..."); - TTip.SetToolTip(btnLoadBaseWad, "Load the selected Base WAD..."); - TTip.SetToolTip(btnPreviewBaseWad, "Preview the selected Base WAD, a Browserwindow will be opened..."); - TTip.SetToolTip(btnSaveBaseWad, "Download and save the selected Base WAD to your HDD..."); - TTip.SetToolTip(btnBrowseReplace, "Browse for a Banner / Icon / Sound to use instead of the one within the Base WAD...\nWAD's, 00000000.app's and banner.bin's / icon.bin's / sound.bin's can be loaded..."); - TTip.SetToolTip(btnClearReplace, "Clear the replaced Banner / Icon / Sound and use the one within the Base WAD..."); - TTip.SetToolTip(btnBrowseDol, "Browse for a DOL file that will be inserted into the WAD\nor choose the DOL form the source WAD to switch the NAND Loader..."); - TTip.SetToolTip(btnBrowseSound, "Browse for a sound that will be inserted into the WAD\nor convert a sound to BNS format..."); - TTip.SetToolTip(btnAddBanner, "Add an image or TPL to the Banner..."); - TTip.SetToolTip(btnAddIcon, "Add an image or TPL to the Icon..."); - TTip.SetToolTip(btnDeleteBanner, "Delete the selected TPL...\nRequired TPLs can't be deleted..."); - TTip.SetToolTip(btnDeleteIcon, "Delete the selected TPL...\nRequired TPLs can't be deleted..."); - TTip.SetToolTip(btnReplaceBanner, "Replace the selected TPL with any image...\nThe image wil be stretched to fit the size of the TPL..."); - TTip.SetToolTip(btnReplaceIcon, "Replace the selected TPL with any image...\nThe image wil be stretched to fit the size of the TPL..."); - TTip.SetToolTip(btnExtractBanner, "Extract the selected TPL as an image..."); - TTip.SetToolTip(btnExtractIcon, "Extract the selected TPL as an image..."); - TTip.SetToolTip(btnPreviewBanner, "Preview the selected TPL..."); - TTip.SetToolTip(btnPreviewIcon, "Preview the selected TPL..."); - TTip.SetToolTip(btnBrlytReplace, "Replace the selected brlyt with any other...\nThis is for advanced users only!"); - TTip.SetToolTip(btnBrlytExtract, "Extract the selected brlyt..."); - TTip.SetToolTip(btnBrlytListTpls, "List the TPLs required by the selected brlyt..."); - TTip.SetToolTip(btnBrlanAdd, "Add a brlan file...\nThis is for advanced users only!"); - TTip.SetToolTip(btnBrlanDelete, "Delete the selected brlan file...\nThis is for advanced users only!"); - TTip.SetToolTip(btnBrlanReplace, "Replace the selected brlan file...\nThis is for advanced users only!"); - TTip.SetToolTip(btnBrlanExtract, "Extract the selected brlan file..."); - TTip.SetToolTip(btnOptionsExtract, "Extract contents of the WAD..."); - TTip.SetToolTip(btnForwarder, "Create a forwarder that will be inserted as a DOL..."); + tTip.SetToolTip(btnCreateWad, "Create and save the WAD or send it directly to the Wii...\nBe sure the Homebrew Channel is running and connected if you want to send the WAD..."); + tTip.SetToolTip(btnBrowseSource, "Browse for a WAD that is used as a Base..."); + tTip.SetToolTip(btnLoadBaseWad, "Load the selected Base WAD..."); + tTip.SetToolTip(btnPreviewBaseWad, "Preview the selected Base WAD, a Browserwindow will be opened..."); + tTip.SetToolTip(btnSaveBaseWad, "Download and save the selected Base WAD to your HDD..."); + tTip.SetToolTip(btnBrowseReplace, "Browse for a Banner / Icon / Sound to use instead of the one within the Base WAD...\nWAD's, 00000000.app's and banner.bin's / icon.bin's / sound.bin's can be loaded..."); + //TTip.SetToolTip(btnClearReplace, "Clear the replaced Banner / Icon / Sound and use the one within the Base WAD..."); + tTip.SetToolTip(btnBrowseDol, "Browse for a DOL file that will be inserted into the WAD\nor choose the DOL form the source WAD to switch the NAND Loader..."); + tTip.SetToolTip(btnBrowseSound, "Browse for a sound that will be inserted into the WAD\nor convert a sound to BNS format..."); + tTip.SetToolTip(btnAddBanner, "Add an image or TPL to the Banner..."); + tTip.SetToolTip(btnAddIcon, "Add an image or TPL to the Icon..."); + tTip.SetToolTip(btnDeleteBanner, "Delete the selected TPL...\nRequired TPLs can't be deleted..."); + tTip.SetToolTip(btnDeleteIcon, "Delete the selected TPL...\nRequired TPLs can't be deleted..."); + tTip.SetToolTip(btnReplaceBanner, "Replace the selected TPL with any image...\nThe image wil be stretched to fit the size of the TPL..."); + tTip.SetToolTip(btnReplaceIcon, "Replace the selected TPL with any image...\nThe image wil be stretched to fit the size of the TPL..."); + tTip.SetToolTip(btnExtractBanner, "Extract the selected TPL as an image..."); + tTip.SetToolTip(btnExtractIcon, "Extract the selected TPL as an image..."); + tTip.SetToolTip(btnPreviewBanner, "Preview the selected TPL..."); + tTip.SetToolTip(btnPreviewIcon, "Preview the selected TPL..."); + tTip.SetToolTip(btnBrlytReplace, "Replace the selected brlyt with any other...\nThis is for advanced users only!"); + tTip.SetToolTip(btnBrlytExtract, "Extract the selected brlyt..."); + tTip.SetToolTip(btnBrlytListTpls, "List the TPLs required by the selected brlyt..."); + tTip.SetToolTip(btnBrlanAdd, "Add a brlan file...\nThis is for advanced users only!"); + tTip.SetToolTip(btnBrlanDelete, "Delete the selected brlan file...\nThis is for advanced users only!"); + tTip.SetToolTip(btnBrlanReplace, "Replace the selected brlan file...\nThis is for advanced users only!"); + tTip.SetToolTip(btnBrlanExtract, "Extract the selected brlan file..."); + tTip.SetToolTip(btnOptionsExtract, "Extract contents of the WAD..."); + tTip.SetToolTip(btnForwarder, "Create a forwarder that will be inserted as a DOL..."); - TTip.SetToolTip(cbLz77, "Use Lz77 compression for the banner.bin and icon.bin...\nIf the created WAD does not work, try it without compression first..."); - TTip.SetToolTip(cbFailureChecks, "Turn off the security checks...\nNot recommended, you may get a bricking WAD..."); + tTip.SetToolTip(cbLz77, "Use Lz77 compression for the banner.bin and icon.bin...\nIf the created WAD does not work, try it without compression first..."); + tTip.SetToolTip(cbFailureChecks, "Turn off the security checks...\nNot recommended, you may get a bricking WAD..."); } private bool CheckForForwardMii() @@ -318,6 +314,15 @@ namespace CustomizeMii return false; } + void rtbInstructions_LinkClicked(object sender, LinkClickedEventArgs e) + { + try + { + Process.Start(e.LinkText); + } + catch (Exception ex) { ErrorBox(ex.Message); } + } + #if !Mono private bool CheckDevKit() { @@ -359,34 +364,28 @@ namespace CustomizeMii private void SetButtonText() { - //Random Randomizer = new Random(); - //btnCreateWad.Text = ButtonTexts[Randomizer.Next(0, ButtonTexts.Length - 1)]; - - //if (btnCreateWad.Text == "Image") - //{ - // btnCreateWad.Text = string.Empty; - // btnCreateWad.Image = Properties.Resources.btnCreateWad; - //} - btnCreateWad.Text = string.Empty; Image tmpImg = new Bitmap(btnCreateWad.Width, btnCreateWad.Height); - Graphics gImg = Graphics.FromImage(tmpImg); + using (Graphics gImg = Graphics.FromImage(tmpImg)) + { + gImg.Clear(Color.Transparent); - gImg.Clear(Color.Transparent); + separatorBtn = btnCreateWad.Width * 0.5; - separatorBtn = btnCreateWad.Width * 0.5; + gImg.DrawLine(Pens.Gray, new Point((int)separatorBtn, 0), new Point((int)separatorBtn, btnCreateWad.Height)); - gImg.DrawLine(Pens.Gray, new Point((int)separatorBtn, 0), new Point((int)separatorBtn, btnCreateWad.Height)); + //gImg.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; + //gImg.DrawString("Send", btnCreateWad.Font, Brushes.Black, new PointF(95, 10)); + //gImg.DrawString("Save", btnCreateWad.Font, Brushes.Black, new PointF(320, 10)); - string sSend = "Send"; - string sSave = "Save"; + Image tmpCreate = Properties.Resources.btnCreate; + Image tmpSend = Properties.Resources.btnSend; + gImg.DrawImage(ResizeImage(tmpCreate, tmpCreate.Width, tmpCreate.Height), new Point(280, 0)); + gImg.DrawImage(ResizeImage(tmpSend, tmpSend.Width, tmpSend.Height), new Point(55, 0)); - gImg.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; - gImg.DrawString(sSend, btnCreateWad.Font, Brushes.Black, new PointF(95, 10)); - gImg.DrawString(sSave, btnCreateWad.Font, Brushes.Black, new PointF(320, 10)); - - btnCreateWad.Image = tmpImg; + btnCreateWad.Image = tmpImg; + } } private void ErrorBox(string message) @@ -1182,126 +1181,142 @@ namespace CustomizeMii } } - private void btnBrowseReplace_Click(object sender, EventArgs e) + private void tbReplace_TextChanged(object sender, EventArgs e) { - if (!string.IsNullOrEmpty(tbSourceWad.Text)) + if (string.IsNullOrEmpty(tbReplace.Text)) { - if (pbProgress.Value == 100) - { - if (cmbReplace.SelectedIndex == 2) //sound - { - try - { - OpenFileDialog ofd = new OpenFileDialog(); - ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|sound.bin|sound.bin|All|*.wad;00000000.app;sound.bin"; - ofd.FilterIndex = 4; - - if (ofd.ShowDialog() == DialogResult.OK) - { - if (ofd.FileName != tbSourceWad.Text) - { - SoundReplace = ofd.FileName; - SetText(tbReplace, SoundReplace); - BackgroundWorker bwSoundReplace = new BackgroundWorker(); - bwSoundReplace.DoWork += new DoWorkEventHandler(bwSoundReplace_DoWork); - bwSoundReplace.ProgressChanged += new ProgressChangedEventHandler(bwSoundReplace_ProgressChanged); - bwSoundReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwSoundReplace_RunWorkerCompleted); - bwSoundReplace.WorkerReportsProgress = true; - bwSoundReplace.RunWorkerAsync(ofd.FileName); - } - } - } - catch (Exception ex) - { - SoundReplace = string.Empty; - SetText(tbReplace, SoundReplace); - ErrorBox(ex.Message); - } - } - else if (cmbReplace.SelectedIndex == 1) //icon - { - try - { - OpenFileDialog ofd = new OpenFileDialog(); - ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|icon.bin|icon.bin|All|*.wad;00000000.app;icon.bin"; - ofd.FilterIndex = 4; - - if (ofd.ShowDialog() == DialogResult.OK) - { - if (ofd.FileName != tbSourceWad.Text) - { - IconReplace = ofd.FileName; - SetText(tbReplace, IconReplace); - BackgroundWorker bwIconReplace = new BackgroundWorker(); - bwIconReplace.DoWork += new DoWorkEventHandler(bwIconReplace_DoWork); - bwIconReplace.ProgressChanged += new ProgressChangedEventHandler(bwIconReplace_ProgressChanged); - bwIconReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwIconReplace_RunWorkerCompleted); - bwIconReplace.WorkerReportsProgress = true; - bwIconReplace.RunWorkerAsync(ofd.FileName); - } - } - } - catch (Exception ex) - { - IconReplace = string.Empty; - SetText(tbReplace, IconReplace); - ErrorBox(ex.Message); - } - } - else //banner - { - try - { - OpenFileDialog ofd = new OpenFileDialog(); - ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|banner.bin|banner.bin|All|*.wad;00000000.app;banner.bin"; - ofd.FilterIndex = 4; - - if (ofd.ShowDialog() == DialogResult.OK) - { - if (ofd.FileName != tbSourceWad.Text) - { - BannerReplace = ofd.FileName; - SetText(tbReplace, BannerReplace); - BackgroundWorker bwBannerReplace = new BackgroundWorker(); - bwBannerReplace.DoWork += new DoWorkEventHandler(bwBannerReplace_DoWork); - bwBannerReplace.ProgressChanged += new ProgressChangedEventHandler(bwBannerReplace_ProgressChanged); - bwBannerReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwBannerReplace_RunWorkerCompleted); - bwBannerReplace.WorkerReportsProgress = true; - bwBannerReplace.RunWorkerAsync(ofd.FileName); - } - } - } - catch (Exception ex) - { - BannerReplace = string.Empty; - SetText(tbReplace, BannerReplace); - ErrorBox(ex.Message); - } - } - } + btnBrowseReplace.Text = "Browse..."; + tTip.SetToolTip(btnBrowseReplace, "Browse for a Banner / Icon / Sound to use instead of the one within the Base WAD...\nWAD's, 00000000.app's and banner.bin's / icon.bin's / sound.bin's can be loaded..."); + } + else + { + btnBrowseReplace.Text = "Clear"; + tTip.SetToolTip(btnBrowseReplace, "Clear the replaced Banner / Icon / Sound and use the one within the Base WAD..."); } } - private void btnClearReplace_Click(object sender, EventArgs e) + private void btnBrowseReplace_Click(object sender, EventArgs e) { - if (cmbReplace.SelectedIndex == 2) //sound + if (btnBrowseReplace.Text == "Clear") { - SoundReplace = string.Empty; - SetText(tbReplace, SoundReplace); - if (File.Exists(TempSoundPath)) File.Delete(TempSoundPath); - SetText(tbSound, string.Empty); + if (cmbReplace.SelectedIndex == 2) //sound + { + SoundReplace = string.Empty; + SetText(tbReplace, SoundReplace); + if (File.Exists(TempSoundPath)) File.Delete(TempSoundPath); + SetText(tbSound, string.Empty); + } + else if (cmbReplace.SelectedIndex == 1) //icon + { + IconReplace = string.Empty; + SetText(tbReplace, IconReplace); + if (Directory.Exists(TempIconPath)) Directory.Delete(TempIconPath, true); + } + else //banner + { + BannerReplace = string.Empty; + SetText(tbReplace, BannerReplace); + if (Directory.Exists(TempBannerPath)) Directory.Delete(TempBannerPath, true); + } } - else if (cmbReplace.SelectedIndex == 1) //icon + else { - IconReplace = string.Empty; - SetText(tbReplace, IconReplace); - if (Directory.Exists(TempIconPath)) Directory.Delete(TempIconPath, true); - } - else //banner - { - BannerReplace = string.Empty; - SetText(tbReplace, BannerReplace); - if (Directory.Exists(TempBannerPath)) Directory.Delete(TempBannerPath, true); + if (!string.IsNullOrEmpty(tbSourceWad.Text)) + { + if (pbProgress.Value == 100) + { + if (cmbReplace.SelectedIndex == 2) //sound + { + try + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|sound.bin|sound.bin|All|*.wad;00000000.app;sound.bin"; + ofd.FilterIndex = 4; + + if (ofd.ShowDialog() == DialogResult.OK) + { + if (ofd.FileName != tbSourceWad.Text) + { + SoundReplace = ofd.FileName; + SetText(tbReplace, SoundReplace); + BackgroundWorker bwSoundReplace = new BackgroundWorker(); + bwSoundReplace.DoWork += new DoWorkEventHandler(bwSoundReplace_DoWork); + bwSoundReplace.ProgressChanged += new ProgressChangedEventHandler(bwSoundReplace_ProgressChanged); + bwSoundReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwSoundReplace_RunWorkerCompleted); + bwSoundReplace.WorkerReportsProgress = true; + bwSoundReplace.RunWorkerAsync(ofd.FileName); + } + } + } + catch (Exception ex) + { + SoundReplace = string.Empty; + SetText(tbReplace, SoundReplace); + ErrorBox(ex.Message); + } + } + else if (cmbReplace.SelectedIndex == 1) //icon + { + try + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|icon.bin|icon.bin|All|*.wad;00000000.app;icon.bin"; + ofd.FilterIndex = 4; + + if (ofd.ShowDialog() == DialogResult.OK) + { + if (ofd.FileName != tbSourceWad.Text) + { + IconReplace = ofd.FileName; + SetText(tbReplace, IconReplace); + BackgroundWorker bwIconReplace = new BackgroundWorker(); + bwIconReplace.DoWork += new DoWorkEventHandler(bwIconReplace_DoWork); + bwIconReplace.ProgressChanged += new ProgressChangedEventHandler(bwIconReplace_ProgressChanged); + bwIconReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwIconReplace_RunWorkerCompleted); + bwIconReplace.WorkerReportsProgress = true; + bwIconReplace.RunWorkerAsync(ofd.FileName); + } + } + } + catch (Exception ex) + { + IconReplace = string.Empty; + SetText(tbReplace, IconReplace); + ErrorBox(ex.Message); + } + } + else //banner + { + try + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|banner.bin|banner.bin|All|*.wad;00000000.app;banner.bin"; + ofd.FilterIndex = 4; + + if (ofd.ShowDialog() == DialogResult.OK) + { + if (ofd.FileName != tbSourceWad.Text) + { + BannerReplace = ofd.FileName; + SetText(tbReplace, BannerReplace); + BackgroundWorker bwBannerReplace = new BackgroundWorker(); + bwBannerReplace.DoWork += new DoWorkEventHandler(bwBannerReplace_DoWork); + bwBannerReplace.ProgressChanged += new ProgressChangedEventHandler(bwBannerReplace_ProgressChanged); + bwBannerReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwBannerReplace_RunWorkerCompleted); + bwBannerReplace.WorkerReportsProgress = true; + bwBannerReplace.RunWorkerAsync(ofd.FileName); + } + } + } + catch (Exception ex) + { + BannerReplace = string.Empty; + SetText(tbReplace, BannerReplace); + ErrorBox(ex.Message); + } + } + } + } } } @@ -1556,19 +1571,23 @@ namespace CustomizeMii { try { - string Tpl = BannerTplPath + lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty); - Image Img = Wii.TPL.ConvertFromTPL(Tpl); + //string Tpl = BannerTplPath + lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty); + //Image Img = Wii.TPL.ConvertFromTPL(Tpl); + + //CustomizeMii_Preview pvw = new CustomizeMii_Preview(); + + //if (Img.Width > 200) pvw.Width = Img.Width + 50; + //else pvw.Width = 250; + //if (Img.Height > 200) pvw.Height = Img.Height + 50; + //else pvw.Height = 250; + + //pvw.pbImage.Image = Img; + //pvw.Text = string.Format("CustomizeMii - Preview ({0} x {1})", Img.Width, Img.Height); + + //pvw.ShowDialog(); CustomizeMii_Preview pvw = new CustomizeMii_Preview(); - - if (Img.Width > 200) pvw.Width = Img.Width + 50; - else pvw.Width = 250; - if (Img.Height > 200) pvw.Height = Img.Height + 50; - else pvw.Height = 250; - - pvw.pbImage.Image = Img; - pvw.Text = string.Format("CustomizeMii - Preview ({0} x {1})", Img.Width, Img.Height); - + pvw.startTPL = lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty); pvw.ShowDialog(); } catch (Exception ex) @@ -1695,19 +1714,24 @@ namespace CustomizeMii { try { - string Tpl = IconTplPath + lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty); - Image Img = Wii.TPL.ConvertFromTPL(Tpl); + //string Tpl = IconTplPath + lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty); + //Image Img = Wii.TPL.ConvertFromTPL(Tpl); + + //CustomizeMii_Preview pvw = new CustomizeMii_Preview(); + + //if (Img.Width > 200) pvw.Width = Img.Width + 50; + //else pvw.Width = 250; + //if (Img.Height > 200) pvw.Height = Img.Height + 50; + //else pvw.Height = 250; + + //pvw.pbImage.Image = Img; + //pvw.Text = string.Format("CustomizeMii - Preview ({0} x {1})", Img.Width, Img.Height); + + //pvw.ShowDialog(); CustomizeMii_Preview pvw = new CustomizeMii_Preview(); - - if (Img.Width > 200) pvw.Width = Img.Width + 50; - else pvw.Width = 250; - if (Img.Height > 200) pvw.Height = Img.Height + 50; - else pvw.Height = 250; - - pvw.pbImage.Image = Img; - pvw.Text = string.Format("CustomizeMii - Preview ({0} x {1})", Img.Width, Img.Height); - + pvw.startIcon = true; + pvw.startTPL = lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty); pvw.ShowDialog(); } catch (Exception ex) diff --git a/CustomizeMii/CustomizeMii_Preview.Designer.cs b/CustomizeMii/CustomizeMii_Preview.Designer.cs index 3a53663..106839f 100644 --- a/CustomizeMii/CustomizeMii_Preview.Designer.cs +++ b/CustomizeMii/CustomizeMii_Preview.Designer.cs @@ -1,12 +1,12 @@ -/* This file is part of CustomizeMii +/* This file is part of ShowMiiWads * Copyright (C) 2009 Leathl * - * CustomizeMii is free software: you can redistribute it and/or + * ShowMiiWads is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * CustomizeMii is distributed in the hope that it will be + * ShowMiiWads is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + namespace CustomizeMii { partial class CustomizeMii_Preview @@ -45,39 +45,249 @@ namespace CustomizeMii /// private void InitializeComponent() { - this.pbImage = new System.Windows.Forms.PictureBox(); - ((System.ComponentModel.ISupportInitialize)(this.pbImage)).BeginInit(); + this.components = new System.ComponentModel.Container(); + this.Panel = new System.Windows.Forms.Panel(); + this.btnClose = new System.Windows.Forms.Button(); + this.cbIcon = new System.Windows.Forms.ComboBox(); + this.lbIcon = new System.Windows.Forms.Label(); + this.lbBanner = new System.Windows.Forms.Label(); + this.cbBanner = new System.Windows.Forms.ComboBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.lbFormat = new System.Windows.Forms.Label(); + this.lbFormatText = new System.Windows.Forms.Label(); + this.lbSize = new System.Windows.Forms.Label(); + this.lbSizeText = new System.Windows.Forms.Label(); + this.pbPic = new System.Windows.Forms.PictureBox(); + this.btnReplace = new System.Windows.Forms.Button(); + this.cmFormat = new System.Windows.Forms.ContextMenuStrip(this.components); + this.cmRGBA8 = new System.Windows.Forms.ToolStripMenuItem(); + this.cmRGB565 = new System.Windows.Forms.ToolStripMenuItem(); + this.cmRGB5A3 = new System.Windows.Forms.ToolStripMenuItem(); + this.Panel.SuspendLayout(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbPic)).BeginInit(); + this.cmFormat.SuspendLayout(); this.SuspendLayout(); // - // pbImage + // Panel // - this.pbImage.Dock = System.Windows.Forms.DockStyle.Fill; - this.pbImage.Location = new System.Drawing.Point(0, 0); - this.pbImage.Name = "pbImage"; - this.pbImage.Size = new System.Drawing.Size(194, 176); - this.pbImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; - this.pbImage.TabIndex = 0; - this.pbImage.TabStop = false; + this.Panel.Controls.Add(this.btnReplace); + this.Panel.Controls.Add(this.btnClose); + this.Panel.Controls.Add(this.cbIcon); + this.Panel.Controls.Add(this.lbIcon); + this.Panel.Controls.Add(this.lbBanner); + this.Panel.Controls.Add(this.cbBanner); + this.Panel.Dock = System.Windows.Forms.DockStyle.Bottom; + this.Panel.Location = new System.Drawing.Point(0, 434); + this.Panel.Name = "Panel"; + this.Panel.Size = new System.Drawing.Size(817, 28); + this.Panel.TabIndex = 0; + // + // btnClose + // + this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnClose.Location = new System.Drawing.Point(670, 4); + this.btnClose.Name = "btnClose"; + this.btnClose.Size = new System.Drawing.Size(137, 21); + this.btnClose.TabIndex = 3; + this.btnClose.Text = "Close"; + this.btnClose.UseVisualStyleBackColor = true; + this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + // + // cbIcon + // + this.cbIcon.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.cbIcon.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbIcon.FormattingEnabled = true; + this.cbIcon.Location = new System.Drawing.Point(239, 4); + this.cbIcon.MaxDropDownItems = 20; + this.cbIcon.Name = "cbIcon"; + this.cbIcon.Size = new System.Drawing.Size(121, 21); + this.cbIcon.TabIndex = 1; + this.cbIcon.SelectedIndexChanged += new System.EventHandler(this.cbIcon_SelectedIndexChanged); + // + // lbIcon + // + this.lbIcon.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lbIcon.AutoSize = true; + this.lbIcon.Location = new System.Drawing.Point(203, 7); + this.lbIcon.Name = "lbIcon"; + this.lbIcon.Size = new System.Drawing.Size(31, 13); + this.lbIcon.TabIndex = 2; + this.lbIcon.Text = "Icon:"; + // + // lbBanner + // + this.lbBanner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lbBanner.AutoSize = true; + this.lbBanner.Location = new System.Drawing.Point(3, 7); + this.lbBanner.Name = "lbBanner"; + this.lbBanner.Size = new System.Drawing.Size(44, 13); + this.lbBanner.TabIndex = 1; + this.lbBanner.Text = "Banner:"; + // + // cbBanner + // + this.cbBanner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.cbBanner.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbBanner.FormattingEnabled = true; + this.cbBanner.Location = new System.Drawing.Point(51, 4); + this.cbBanner.MaxDropDownItems = 20; + this.cbBanner.Name = "cbBanner"; + this.cbBanner.Size = new System.Drawing.Size(121, 21); + this.cbBanner.TabIndex = 0; + this.cbBanner.SelectedIndexChanged += new System.EventHandler(this.cbBanner_SelectedIndexChanged); + // + // panel1 + // + this.panel1.Controls.Add(this.lbFormat); + this.panel1.Controls.Add(this.lbFormatText); + this.panel1.Controls.Add(this.lbSize); + this.panel1.Controls.Add(this.lbSizeText); + this.panel1.Dock = System.Windows.Forms.DockStyle.Top; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(817, 22); + this.panel1.TabIndex = 2; + // + // lbFormat + // + this.lbFormat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lbFormat.AutoSize = true; + this.lbFormat.Location = new System.Drawing.Point(756, 5); + this.lbFormat.Name = "lbFormat"; + this.lbFormat.Size = new System.Drawing.Size(43, 13); + this.lbFormat.TabIndex = 3; + this.lbFormat.Text = "RGBA8"; + // + // lbFormatText + // + this.lbFormatText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lbFormatText.Location = new System.Drawing.Point(550, 5); + this.lbFormatText.Name = "lbFormatText"; + this.lbFormatText.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.lbFormatText.Size = new System.Drawing.Size(205, 13); + this.lbFormatText.TabIndex = 2; + this.lbFormatText.Text = "Texture Format:"; + this.lbFormatText.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // lbSize + // + this.lbSize.AutoSize = true; + this.lbSize.Location = new System.Drawing.Point(39, 5); + this.lbSize.Name = "lbSize"; + this.lbSize.Size = new System.Drawing.Size(30, 13); + this.lbSize.TabIndex = 1; + this.lbSize.Text = "0 x 0"; + // + // lbSizeText + // + this.lbSizeText.AutoSize = true; + this.lbSizeText.Location = new System.Drawing.Point(4, 5); + this.lbSizeText.Name = "lbSizeText"; + this.lbSizeText.Size = new System.Drawing.Size(30, 13); + this.lbSizeText.TabIndex = 0; + this.lbSizeText.Text = "Size:"; + // + // pbPic + // + this.pbPic.Dock = System.Windows.Forms.DockStyle.Fill; + this.pbPic.Location = new System.Drawing.Point(0, 22); + this.pbPic.Name = "pbPic"; + this.pbPic.Size = new System.Drawing.Size(817, 412); + this.pbPic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.pbPic.TabIndex = 3; + this.pbPic.TabStop = false; + // + // btnReplace + // + this.btnReplace.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnReplace.Location = new System.Drawing.Point(512, 4); + this.btnReplace.Name = "btnReplace"; + this.btnReplace.Size = new System.Drawing.Size(137, 21); + this.btnReplace.TabIndex = 3; + this.btnReplace.Text = "Replace"; + this.btnReplace.UseVisualStyleBackColor = true; + this.btnReplace.Click += new System.EventHandler(this.btnReplace_Click); + // + // cmFormat + // + this.cmFormat.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.cmRGBA8, + this.cmRGB565, + this.cmRGB5A3}); + this.cmFormat.Name = "cmFormat"; + this.cmFormat.Size = new System.Drawing.Size(234, 70); + // + // cmRGBA8 + // + this.cmRGBA8.Name = "cmRGBA8"; + this.cmRGBA8.Size = new System.Drawing.Size(233, 22); + this.cmRGBA8.Tag = "rgba8"; + this.cmRGBA8.Text = "As RGBA8 (High Quality)"; + this.cmRGBA8.Click += new System.EventHandler(this.cmFormat_Click); + // + // cmRGB565 + // + this.cmRGB565.Name = "cmRGB565"; + this.cmRGB565.Size = new System.Drawing.Size(233, 22); + this.cmRGB565.Tag = "rgb565"; + this.cmRGB565.Text = "As RGB565 (Moderate Quality)"; + this.cmRGB565.Click += new System.EventHandler(this.cmFormat_Click); + // + // cmRGB5A3 + // + this.cmRGB5A3.Name = "cmRGB5A3"; + this.cmRGB5A3.Size = new System.Drawing.Size(233, 22); + this.cmRGB5A3.Tag = "rgb5a3"; + this.cmRGB5A3.Text = "As RGB5A3 (Low Quality)"; + this.cmRGB5A3.Click += new System.EventHandler(this.cmFormat_Click); // // CustomizeMii_Preview // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(194, 176); - this.Controls.Add(this.pbImage); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.MinimumSize = new System.Drawing.Size(200, 200); + this.CancelButton = this.btnClose; + this.ClientSize = new System.Drawing.Size(817, 462); + this.Controls.Add(this.pbPic); + this.Controls.Add(this.panel1); + this.Controls.Add(this.Panel); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(833, 500); this.Name = "CustomizeMii_Preview"; - this.Text = "CustomizeMii - Preview"; - this.Load += new System.EventHandler(this.CustomizeMii_Preview_Load); - ((System.ComponentModel.ISupportInitialize)(this.pbImage)).EndInit(); + this.Text = "Preview"; + this.Load += new System.EventHandler(this.Preview_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Preview_FormClosing); + this.Panel.ResumeLayout(false); + this.Panel.PerformLayout(); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbPic)).EndInit(); + this.cmFormat.ResumeLayout(false); this.ResumeLayout(false); } #endregion - public System.Windows.Forms.PictureBox pbImage; - + private System.Windows.Forms.Panel Panel; + private System.Windows.Forms.Label lbIcon; + private System.Windows.Forms.Label lbBanner; + public System.Windows.Forms.ComboBox cbBanner; + public System.Windows.Forms.Button btnClose; + public System.Windows.Forms.ComboBox cbIcon; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.PictureBox pbPic; + private System.Windows.Forms.Label lbSize; + private System.Windows.Forms.Label lbFormat; + public System.Windows.Forms.Label lbSizeText; + public System.Windows.Forms.Label lbFormatText; + public System.Windows.Forms.Button btnReplace; + private System.Windows.Forms.ContextMenuStrip cmFormat; + private System.Windows.Forms.ToolStripMenuItem cmRGBA8; + private System.Windows.Forms.ToolStripMenuItem cmRGB565; + private System.Windows.Forms.ToolStripMenuItem cmRGB5A3; } } \ No newline at end of file diff --git a/CustomizeMii/CustomizeMii_Preview.cs b/CustomizeMii/CustomizeMii_Preview.cs index bd0a822..3e92f81 100644 --- a/CustomizeMii/CustomizeMii_Preview.cs +++ b/CustomizeMii/CustomizeMii_Preview.cs @@ -14,27 +14,214 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Text; +using System.IO; using System.Windows.Forms; namespace CustomizeMii { public partial class CustomizeMii_Preview : Form { + public string startTPL; + public bool startIcon = false; + public CustomizeMii_Preview() { InitializeComponent(); + this.Icon = global::CustomizeMii.Properties.Resources.CustomizeMii; } - private void CustomizeMii_Preview_Load(object sender, EventArgs e) + private void btnClose_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void Preview_FormClosing(object sender, FormClosingEventArgs e) + { + cbBanner.Items.Clear(); + cbIcon.Items.Clear(); + } + + private void Preview_Load(object sender, EventArgs e) { this.CenterToParent(); + + string[] bannerpics; + string[] iconpics; + + if (string.IsNullOrEmpty(CustomizeMii_Main.BannerReplace)) + bannerpics = Directory.GetFiles(CustomizeMii_Main.TempUnpackBannerTplPath, "*.tpl"); + else bannerpics = Directory.GetFiles(CustomizeMii_Main.BannerTplPath, "*.tpl"); + + if (string.IsNullOrEmpty(CustomizeMii_Main.IconReplace)) + iconpics = Directory.GetFiles(CustomizeMii_Main.TempUnpackIconTplPath, "*.tpl"); + else iconpics = Directory.GetFiles(CustomizeMii_Main.IconTplPath, "*.tpl"); + + int startIndex = -1; + if (!startIcon) + { + for (int i = 0; i < bannerpics.Length; i++) + if (Path.GetFileName(bannerpics[i]) == startTPL) + startIndex = i; + } + else + { + for (int i = 0; i < iconpics.Length; i++) + if (Path.GetFileName(iconpics[i]) == startTPL) + startIndex = i; + } + + foreach (string thispic in bannerpics) + { + string picname = thispic.Remove(0, thispic.LastIndexOf('\\') + 1); + picname = picname.Remove(picname.LastIndexOf('.')); + cbBanner.Items.Add((object)picname); + } + + foreach (string thispic in iconpics) + { + string picname = thispic.Remove(0, thispic.LastIndexOf('\\') + 1); + picname = picname.Remove(picname.LastIndexOf('.')); + cbIcon.Items.Add((object)picname); + } + + try + { + if (startIndex != -1) + if (!startIcon) + cbBanner.SelectedIndex = startIndex; + else + cbIcon.SelectedIndex = startIndex; + } + catch { } + + if (cbBanner.SelectedIndex != -1) cbBanner.Select(); + else if (cbIcon.SelectedIndex != -1) cbIcon.Select(); + } + + private void cbBanner_SelectedIndexChanged(object sender, EventArgs e) + { + if (cbBanner.SelectedIndex != -1) + { + byte[] tpl; + + if (string.IsNullOrEmpty(CustomizeMii_Main.BannerReplace)) + tpl = Wii.Tools.LoadFileToByteArray(CustomizeMii_Main.TempUnpackBannerTplPath + cbBanner.SelectedItem.ToString() + ".tpl"); + else tpl = Wii.Tools.LoadFileToByteArray(CustomizeMii_Main.BannerTplPath + cbBanner.SelectedItem.ToString() + ".tpl"); + + lbSize.Text = Wii.TPL.GetTextureWidth(tpl).ToString() + " x " + Wii.TPL.GetTextureHeight(tpl).ToString(); + lbFormat.Text = Wii.TPL.GetTextureFormatName(tpl); + + Image tmpImg = Wii.TPL.ConvertFromTPL(tpl); + pbPic.Image = tmpImg; + + cbIcon.SelectedIndex = -1; + } + } + + private void cbIcon_SelectedIndexChanged(object sender, EventArgs e) + { + if (cbIcon.SelectedIndex != -1) + { + byte[] tpl; + + if (string.IsNullOrEmpty(CustomizeMii_Main.IconReplace)) + tpl = Wii.Tools.LoadFileToByteArray(CustomizeMii_Main.TempUnpackIconTplPath + cbIcon.SelectedItem.ToString() + ".tpl"); + else tpl = Wii.Tools.LoadFileToByteArray(CustomizeMii_Main.IconTplPath + cbIcon.SelectedItem.ToString() + ".tpl"); + + lbSize.Text = Wii.TPL.GetTextureWidth(tpl).ToString() + " x " + Wii.TPL.GetTextureHeight(tpl).ToString(); + lbFormat.Text = Wii.TPL.GetTextureFormatName(tpl); + + Image tmpImg = Wii.TPL.ConvertFromTPL(tpl); + pbPic.Image = tmpImg; + + cbBanner.SelectedIndex = -1; + } + } + + private void cmSave_Click(object sender, EventArgs e) + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.FileName = pbPic.ImageLocation.Remove(0, pbPic.ImageLocation.LastIndexOf('\\') + 1); + sfd.Filter = "PNG|*.png"; + if (sfd.ShowDialog() == DialogResult.OK) + File.Copy(pbPic.ImageLocation, sfd.FileName); + } + + private Image ResizeImage(Image img, int x, int y) + { + Image newimage = new Bitmap(x, y); + using (Graphics gfx = Graphics.FromImage(newimage)) + { + gfx.DrawImage(img, 0, 0, x, y); + } + return newimage; + } + + private void btnReplace_Click(object sender, EventArgs e) + { + cmFormat.Show(MousePosition); + } + + private void cmFormat_Click(object sender, EventArgs e) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "PNG|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TPL|*.tpl|All|*.png;*.jpg;*.gif;*.bmp;*.tpl"; + ofd.FilterIndex = 6; + + if (ofd.ShowDialog() == DialogResult.OK) + { + try + { + string Tpl; + + if (cbBanner.SelectedIndex != -1) { Tpl = CustomizeMii_Main.BannerTplPath + cbBanner.SelectedItem + ".tpl"; } + else { Tpl = CustomizeMii_Main.IconTplPath + cbIcon.SelectedItem + ".tpl"; } + + byte[] TplArray = Wii.Tools.LoadFileToByteArray(Tpl); + Image Img; + + if (!ofd.FileName.ToLower().EndsWith(".tpl")) Img = Image.FromFile(ofd.FileName); + else Img = Wii.TPL.ConvertFromTPL(ofd.FileName); + + int TplFormat; + int X = Wii.TPL.GetTextureWidth(TplArray); + int Y = Wii.TPL.GetTextureHeight(TplArray); + + if (X != Img.Width || + Y != Img.Height) + { + Img = ResizeImage(Img, X, Y); + } + + ToolStripMenuItem cmSender = sender as ToolStripMenuItem; + switch (cmSender.Tag.ToString().ToLower()) + { + case "rgb565": + TplFormat = 4; + lbFormat.Text = "RGB565"; + break; + case "rgb5a3": + TplFormat = 5; + lbFormat.Text = "RGB5A3"; + break; + default: + TplFormat = 6; + lbFormat.Text = "RGBA8"; + break; + } + + Wii.TPL.ConvertToTPL(Img, Tpl, TplFormat); + pbPic.Image = Wii.TPL.ConvertFromTPL(Tpl); + + if (cbBanner.SelectedIndex != -1) cbBanner.Select(); + else if (cbIcon.SelectedIndex != -1) cbIcon.Select(); + } + catch (Exception ex) + { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } + } } } } diff --git a/CustomizeMii/CustomizeMii_Preview.resx b/CustomizeMii/CustomizeMii_Preview.resx index ff31a6d..5d61c82 100644 --- a/CustomizeMii/CustomizeMii_Preview.resx +++ b/CustomizeMii/CustomizeMii_Preview.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 14, 7 + + + 36 + \ No newline at end of file diff --git a/CustomizeMii/Properties/Resources.Designer.cs b/CustomizeMii/Properties/Resources.Designer.cs index 313627d..b220131 100644 --- a/CustomizeMii/Properties/Resources.Designer.cs +++ b/CustomizeMii/Properties/Resources.Designer.cs @@ -60,9 +60,16 @@ namespace CustomizeMii.Properties { } } - internal static System.Drawing.Bitmap btnCreateWad { + internal static System.Drawing.Bitmap btnCreate { get { - object obj = ResourceManager.GetObject("btnCreateWad", resourceCulture); + object obj = ResourceManager.GetObject("btnCreate", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap btnSend { + get { + object obj = ResourceManager.GetObject("btnSend", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } diff --git a/CustomizeMii/Properties/Resources.resx b/CustomizeMii/Properties/Resources.resx index 7f2b7d7..4063328 100644 --- a/CustomizeMii/Properties/Resources.resx +++ b/CustomizeMii/Properties/Resources.resx @@ -118,13 +118,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\btnCreateWad.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\CustomizeMii.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\resources\instructions.rtf;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + ..\Resources\btnCreate.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\btnSend.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/CustomizeMii/Readme.txt b/CustomizeMii/Readme.txt index f0e14aa..eb9fcdf 100644 --- a/CustomizeMii/Readme.txt +++ b/CustomizeMii/Readme.txt @@ -10,7 +10,12 @@ Thanks to icefire / Xuzz for the basic idea of this Application! Changelog: Version 2.1 + - Replaced the TPL preview window with the one from ShowMiiWads for easier handling - + - Little improvements + +Version 2.01 + - Base WAD downloading works again Version 2.0 - Added BNS conversion (Mono and Stereo, with and without loop) diff --git a/CustomizeMii/Resources/btnCreateWad.png b/CustomizeMii/Resources/btnCreate.png similarity index 50% rename from CustomizeMii/Resources/btnCreateWad.png rename to CustomizeMii/Resources/btnCreate.png index 85dc5b64347773a980c952c05ae837680e89aae3..702cc1e3d2b3f7167d5e388b5be66b117064de1a 100644 GIT binary patch delta 720 zcmV;>0x$jODfAkU7YZN<1^@s6!-ZVNu_2xce*&LLL_t(|+U#2GjoUB`eYp+X5xjyr zf^Gz_;1#rjS1@h^cLcBC8$m@U@QtARaTGuhq`z`7+JX--k~o$`@{x~hZE{>LLE-1;|ryf)0cq=Uk!)xUXEc3Sl)X+1XQn`hE;%JTM z1NqYJteNP0D@G%L`4Trz5;~nE4@L!ae>6{T$YG`cOzi%kNY%)KSQ9H4!IxMR*{&^Q zRtQ-YzZbFr^nJQ0$pe6VH=+H(UKv@ow&X}5qiY`uMujFOd6gh7IFnIvwXYxPk993s zg`;AdM!r-g%`T027}Y=AP3XL_Dc}yhv!XVU+AAZ%no(#WAhQBMXL=)h+A2!RURx z(wq7NvfGI9kr6fsrD*8$%G76JmA#1S4r1;=&#p2#?<6$t$ZceV*Y{e_u{I)E%w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+vdBQB^doTwy* zsTk$li-6ykI0qh(o?{X^JQ`i8m~1F=@G;B1auPt>q{@dBOA&lKonu{QoUf~_ldV#t zv}6HVY2X_z=e%g@C~>?s$1TC_2Jj~P(iEltYI|^hkw82wsxI-_dEv0(W|7tkd{e)c ze}$iw>Q#F;xsX3gof~9;ywC3heh^gcfE)Z%hB@~Qu4UXHTH%E7ewSOkr6zT`)f0Q= zN`W5_5S}ubFNOOv1aGgvh`WrhWWK*bW_X==9iuvGlaK4&{N4(DPl`)Fr7h60RlrX~ z>Uj4+TOIiC9v68FLV^4B_O4uUp*5_O%q2t0H|G98B z5COH^3f`8KZ8o8O^8C{#XthCoL}yTTKi~$vMvCfm(xz}smnd!^Gf%sK8Ee4Tf4e{3 zD=O>lar*?v0e!1f_`E1{Otn2cr%$~>@ilrR*=_}I(T{1sv94|05OZ&{QV*6$=y;!d zLLVPEA4}w)!_GZA}x+T~d6L<0X-kH)u0WNRMM| z@^4QV|DgS3m3!)X15pUddzbzXHTPhux7y^)aJ-i@r#;P5>_mM}r)eG1jmwddTb)d;qe1@fcjCRe0rhzAP;PP|q}PqG@u8kD?AYH_f1upE13e{Y6DiuIoz zR?sBXXqAg?o!q*#jaD8wq|G2t`TfYgVe^n^`#&td#g z`$)H1uLC8{xl>G!^?;y5e_&Qg*ZqFCKZvsLgx_*62mX{%-yc`lb@=1P+ENKE^)D9k z;n#<GpijrUydBZ;@tu9Jjxmh9lP|T79d-_OUio z?REZeGSk;3Pw~qCPwB0sN$sJ+ybWgvuOMxs?<8 z*4w_YMd6JK&Wdt8j|i(#8IKKH!VxF7P$=;40RV?0<3IjM$1MN=002ovPDHLkV1mHO B8dd-R diff --git a/CustomizeMii/Resources/btnSend.png b/CustomizeMii/Resources/btnSend.png new file mode 100644 index 0000000000000000000000000000000000000000..53546d577b797174f585cce0b49a0b96d84f54f4 GIT binary patch literal 3414 zcmV-c4XN^pP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$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