From 56cac8cbc83bac5c70c7f24a02f972837ba59893 Mon Sep 17 00:00:00 2001 From: leathl Date: Mon, 28 Dec 2009 21:24:21 +0000 Subject: [PATCH] On our way to 2.1, huh? git-svn-id: svn://localhost/Users/andi/Downloads/code/trunk@13 eddbe33b-e435-4246-ac25-f5eb65f9a13c --- CustomizeMii/CustomizeMii.csproj | 2 +- .../CustomizeMii_BackgroundWorkers.cs | 17 ++- CustomizeMii/CustomizeMii_Main.Designer.cs | 19 ++- CustomizeMii/CustomizeMii_Main.cs | 136 ++++++++++++++---- CustomizeMii/CustomizeMii_Main.resx | 4 +- CustomizeMii/CustomizeMii_Structs.cs | 20 ++- CustomizeMii/Properties/AssemblyInfo.cs | 4 +- CustomizeMii/Readme.txt | 3 + ForwardMii-Plugin/Resources/GX/video.cpp | 1 + 9 files changed, 168 insertions(+), 38 deletions(-) diff --git a/CustomizeMii/CustomizeMii.csproj b/CustomizeMii/CustomizeMii.csproj index dde6bca..23abde7 100644 --- a/CustomizeMii/CustomizeMii.csproj +++ b/CustomizeMii/CustomizeMii.csproj @@ -27,7 +27,7 @@ false true 0 - 2.0.0.%2a + 2.1.0.%2a false true diff --git a/CustomizeMii/CustomizeMii_BackgroundWorkers.cs b/CustomizeMii/CustomizeMii_BackgroundWorkers.cs index 47060c6..b1694a3 100644 --- a/CustomizeMii/CustomizeMii_BackgroundWorkers.cs +++ b/CustomizeMii/CustomizeMii_BackgroundWorkers.cs @@ -25,6 +25,8 @@ namespace CustomizeMii { partial class CustomizeMii_Main { + public int sendWadReady = 0; + private bool sendToWii = false; private bool internalSound; void bwBannerReplace_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) @@ -542,6 +544,9 @@ namespace CustomizeMii EventHandler DisableControls = new EventHandler(this.DisableControls); this.Invoke(DisableControls); + this.sendToWii = wadInfo.sendToWii; + sendWadReady = 0; + bwCreateWad.ReportProgress(0, "Making TPLs transparent"); MakeBannerTplsTransparent(); MakeIconTplsTransparent(); @@ -725,13 +730,19 @@ namespace CustomizeMii bwCreateWad.ReportProgress(100, " "); CreationTimer.Stop(); - FileInfo fi = new FileInfo(wadInfo.outFile); - double fileSize = Math.Round(fi.Length * 0.0009765625 * 0.0009765625, 2); + if (!sendToWii) + { + FileInfo fi = new FileInfo(wadInfo.outFile); + double fileSize = Math.Round(fi.Length * 0.0009765625 * 0.0009765625, 2); - InfoBox(string.Format("Successfully created custom channel!\nTime elapsed: {0} ms\nFilesize: {1} MB\nApprox. Blocks: {2}", CreationTimer.ElapsedMilliseconds, fileSize, Wii.WadInfo.GetNandBlocks(wadInfo.outFile))); + + InfoBox(string.Format("Successfully created custom channel!\nTime elapsed: {0} ms\nFilesize: {1} MB\nApprox. Blocks: {2}", CreationTimer.ElapsedMilliseconds, fileSize, Wii.WadInfo.GetNandBlocks(wadInfo.outFile))); + } + else sendWadReady = 1; } catch (Exception ex) { + sendWadReady = -1; CreationTimer.Stop(); EventHandler EnableControls = new EventHandler(this.EnableControls); this.Invoke(EnableControls); diff --git a/CustomizeMii/CustomizeMii_Main.Designer.cs b/CustomizeMii/CustomizeMii_Main.Designer.cs index 409cea5..b92307f 100644 --- a/CustomizeMii/CustomizeMii_Main.Designer.cs +++ b/CustomizeMii/CustomizeMii_Main.Designer.cs @@ -167,6 +167,7 @@ namespace CustomizeMii this.cmDol = new System.Windows.Forms.ContextMenuStrip(this.components); this.cmLoadDol = new System.Windows.Forms.ToolStripMenuItem(); this.cmDolFromSource = new System.Windows.Forms.ToolStripMenuItem(); + this.panCredits = new System.Windows.Forms.Panel(); this.tabControl.SuspendLayout(); this.tabSource.SuspendLayout(); this.tabTitle.SuspendLayout(); @@ -182,6 +183,7 @@ namespace CustomizeMii this.cmOptionsExtract.SuspendLayout(); this.cmSound.SuspendLayout(); this.cmDol.SuspendLayout(); + this.panCredits.SuspendLayout(); this.SuspendLayout(); // // btnCreateWad @@ -1186,9 +1188,9 @@ namespace CustomizeMii // // tabCredits // + this.tabCredits.Controls.Add(this.panCredits); this.tabCredits.Controls.Add(this.llbUpdateAvailabe); this.tabCredits.Controls.Add(this.llbSite); - this.tabCredits.Controls.Add(this.lbCreditThanks); this.tabCredits.Controls.Add(this.lbCreditVersion); this.tabCredits.Controls.Add(this.lbCreditInfo); this.tabCredits.Location = new System.Drawing.Point(4, 22); @@ -1225,9 +1227,9 @@ namespace CustomizeMii // // lbCreditThanks // - this.lbCreditThanks.Location = new System.Drawing.Point(0, 91); + this.lbCreditThanks.Location = new System.Drawing.Point(8, 0); this.lbCreditThanks.Name = "lbCreditThanks"; - this.lbCreditThanks.Size = new System.Drawing.Size(443, 79); + this.lbCreditThanks.Size = new System.Drawing.Size(427, 150); this.lbCreditThanks.TabIndex = 2; this.lbCreditThanks.Text = resources.GetString("lbCreditThanks.Text"); this.lbCreditThanks.TextAlign = System.Drawing.ContentAlignment.TopCenter; @@ -1429,6 +1431,15 @@ namespace CustomizeMii this.cmDolFromSource.Text = "Take From Source WAD"; this.cmDolFromSource.Click += new System.EventHandler(this.cmDolFromSource_Click); // + // panCredits + // + this.panCredits.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.panCredits.Controls.Add(this.lbCreditThanks); + this.panCredits.Location = new System.Drawing.Point(0, 94); + this.panCredits.Name = "panCredits"; + this.panCredits.Size = new System.Drawing.Size(443, 79); + this.panCredits.TabIndex = 5; + // // CustomizeMii_Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1467,6 +1478,7 @@ namespace CustomizeMii this.cmOptionsExtract.ResumeLayout(false); this.cmSound.ResumeLayout(false); this.cmDol.ResumeLayout(false); + this.panCredits.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -1594,6 +1606,7 @@ namespace CustomizeMii private System.Windows.Forms.ContextMenuStrip cmDol; private System.Windows.Forms.ToolStripMenuItem cmLoadDol; private System.Windows.Forms.ToolStripMenuItem cmDolFromSource; + private System.Windows.Forms.Panel panCredits; } } diff --git a/CustomizeMii/CustomizeMii_Main.cs b/CustomizeMii/CustomizeMii_Main.cs index d7421e1..0b1cec0 100644 --- a/CustomizeMii/CustomizeMii_Main.cs +++ b/CustomizeMii/CustomizeMii_Main.cs @@ -36,10 +36,11 @@ namespace CustomizeMii { public partial class CustomizeMii_Main : Form { - const string version = "2.0"; //Hint for myself: Never use a char in the Version (UpdateCheck)! + 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 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\\"; @@ -82,6 +83,8 @@ 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(); public CustomizeMii_Main() { @@ -111,7 +114,10 @@ namespace CustomizeMii private void CustomizeMii_Main_FormClosing(object sender, FormClosingEventArgs e) { - try { if (Directory.Exists(TempPath)) Directory.Delete(TempPath, true); } + try { + if (Directory.Exists(TempPath)) Directory.Delete(TempPath, true); + if (File.Exists("C:\\cmtempmp3wav.wav")) File.Delete("C:\\cmtempmp3wav.wav"); + } catch { } Environment.Exit(0); } @@ -157,6 +163,8 @@ namespace CustomizeMii btnBrowseSound.Text = "Browse..."; rtbInstructions.Rtf = Properties.Resources.Instructions; rtbInstructions.LinkClicked += new LinkClickedEventHandler(rtbInstructions_LinkClicked); + tmrCredits.Interval = CreditsScrollSpeed; + tmrCredits.Tick += new EventHandler(tmrCredits_Tick); #if !Debug DisableControls(null, null); @@ -254,7 +262,7 @@ namespace CustomizeMii private void SetToolTips() { ToolTip TTip = new ToolTip(); - TTip.SetToolTip(btnCreateWad, "Create WAD..."); + 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..."); @@ -336,14 +344,34 @@ namespace CustomizeMii private void SetButtonText() { - Random Randomizer = new Random(); - btnCreateWad.Text = ButtonTexts[Randomizer.Next(0, ButtonTexts.Length - 1)]; + //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; - } + //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); + + gImg.Clear(Color.Transparent); + + separatorBtn = btnCreateWad.Width * 0.5; + + gImg.DrawLine(Pens.Gray, new Point((int)separatorBtn, 0), new Point((int)separatorBtn, btnCreateWad.Height)); + + string sSend = "Send"; + string sSave = "Save"; + + 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; } private void ErrorBox(string message) @@ -662,6 +690,8 @@ namespace CustomizeMii private void tabControl_Selecting(object sender, TabControlCancelEventArgs e) { + tmrCredits.Stop(); + if (tabControl.SelectedTab == tabBanner) { lbxBannerTpls.SelectedIndex = -1; @@ -684,6 +714,17 @@ namespace CustomizeMii { AddBrlans(null, null); } + else if (tabControl.SelectedTab == tabCredits) + { + lbCreditThanks.Location = new Point(lbCreditThanks.Location.X, panCredits.Height); + tmrCredits.Start(); + } + } + + void tmrCredits_Tick(object sender, EventArgs e) + { + if (lbCreditThanks.Location.Y == -130) lbCreditThanks.Location = new Point(lbCreditThanks.Location.X, panCredits.Height); + lbCreditThanks.Location = new Point(lbCreditThanks.Location.X, lbCreditThanks.Location.Y - 1); } private void lbStatusText_TextChanged(object sender, EventArgs e) @@ -2187,30 +2228,22 @@ namespace CustomizeMii private void btnCreateWad_Click(object sender, EventArgs e) { - if (pbProgress.Value == 100) + Point mousePos = MousePosition; + + if (mousePos.X < (this.Location.X + btnCreateWad.Location.X + Math.Ceiling(separatorBtn) + 3)) { - if (!string.IsNullOrEmpty(tbSourceWad.Text)) + if (pbProgress.Value == 100) { - if (cbFailureChecks.Checked == true || FailureCheck() == true) + if (!string.IsNullOrEmpty(tbSourceWad.Text)) { - SaveFileDialog sfd = new SaveFileDialog(); - sfd.Filter = "Wii Channels|*.wad"; - - if (!string.IsNullOrEmpty(tbAllLanguages.Text)) - sfd.FileName = tbAllLanguages.Text + " - " + tbTitleID.Text.ToUpper() + ".wad"; - else - sfd.FileName = tbEnglish.Text + " - " + tbTitleID.Text.ToUpper() + ".wad"; - - if (sfd.ShowDialog() == DialogResult.OK) + if (cbFailureChecks.Checked == true || FailureCheck() == true) { try { - CreationTimer.Reset(); - CreationTimer.Start(); - WadCreationInfo wadInfo = new WadCreationInfo(); - wadInfo.outFile = sfd.FileName; + wadInfo.outFile = TempPath + "SendToWii.wad"; wadInfo.nandLoader = (WadCreationInfo.NandLoader)cmbNandLoader.SelectedIndex; + wadInfo.sendToWii = true; BackgroundWorker bwCreateWad = new BackgroundWorker(); bwCreateWad.DoWork += new DoWorkEventHandler(bwCreateWad_DoWork); @@ -2218,16 +2251,65 @@ namespace CustomizeMii bwCreateWad.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwCreateWad_RunWorkerCompleted); bwCreateWad.WorkerReportsProgress = true; bwCreateWad.RunWorkerAsync(wadInfo); + + // @WiiCrazy: The WAD will be saved to >> TempTempPath + "SendToWii.wad" << + // here. Now a loop that waits for the BackgroundWorker to finish and then opens + // a new window (wiiload - window or whatever) ?! + // If it finishes successfully, the variable >> sendWadReady << will turn into 1, + // if it errors, it will turn into -1, as long as it's running it is 0. } catch (Exception ex) { - CreationTimer.Stop(); ErrorBox(ex.Message); } } } } } + else + { + if (pbProgress.Value == 100) + { + if (!string.IsNullOrEmpty(tbSourceWad.Text)) + { + if (cbFailureChecks.Checked == true || FailureCheck() == true) + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.Filter = "Wii Channels|*.wad"; + + if (!string.IsNullOrEmpty(tbAllLanguages.Text)) + sfd.FileName = tbAllLanguages.Text + " - " + tbTitleID.Text.ToUpper() + ".wad"; + else + sfd.FileName = tbEnglish.Text + " - " + tbTitleID.Text.ToUpper() + ".wad"; + + if (sfd.ShowDialog() == DialogResult.OK) + { + try + { + CreationTimer.Reset(); + CreationTimer.Start(); + + WadCreationInfo wadInfo = new WadCreationInfo(); + wadInfo.outFile = sfd.FileName; + wadInfo.nandLoader = (WadCreationInfo.NandLoader)cmbNandLoader.SelectedIndex; + + BackgroundWorker bwCreateWad = new BackgroundWorker(); + bwCreateWad.DoWork += new DoWorkEventHandler(bwCreateWad_DoWork); + bwCreateWad.ProgressChanged += new ProgressChangedEventHandler(bwCreateWad_ProgressChanged); + bwCreateWad.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwCreateWad_RunWorkerCompleted); + bwCreateWad.WorkerReportsProgress = true; + bwCreateWad.RunWorkerAsync(wadInfo); + } + catch (Exception ex) + { + CreationTimer.Stop(); + ErrorBox(ex.Message); + } + } + } + } + } + } } private void lbxBrlytBanner_SelectedIndexChanged(object sender, EventArgs e) diff --git a/CustomizeMii/CustomizeMii_Main.resx b/CustomizeMii/CustomizeMii_Main.resx index 1cafef5..0ca0828 100644 --- a/CustomizeMii/CustomizeMii_Main.resx +++ b/CustomizeMii/CustomizeMii_Main.resx @@ -123,7 +123,9 @@ Xuzz for his idea and hard work Xuzz, SquidMan, megazig, Matt_P, Omega and The Lemon Man for Wii.py SquidMan for Zetsubou Andre Perrot for gbalzss -comex and Waninkoko for both their NAND Loader +comex and Waninkoko for both their NAND Loader +djdynamite123 for the forwarder base files (ForwardMii-Plugin) +The USB Loader GX Team for their forwarder source (ForwardMii-Plugin) 16, 7 diff --git a/CustomizeMii/CustomizeMii_Structs.cs b/CustomizeMii/CustomizeMii_Structs.cs index d0eab79..d4775e7 100644 --- a/CustomizeMii/CustomizeMii_Structs.cs +++ b/CustomizeMii/CustomizeMii_Structs.cs @@ -1,4 +1,21 @@ -namespace CustomizeMii +/* This file is part of CustomizeMii + * Copyright (C) 2009 Leathl + * + * CustomizeMii 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 + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + namespace CustomizeMii { public struct BnsConversionInfo { @@ -25,6 +42,7 @@ public string outFile; public NandLoader nandLoader; + public bool sendToWii; } public struct Progress diff --git a/CustomizeMii/Properties/AssemblyInfo.cs b/CustomizeMii/Properties/AssemblyInfo.cs index a855e62..06a9bdb 100644 --- a/CustomizeMii/Properties/AssemblyInfo.cs +++ b/CustomizeMii/Properties/AssemblyInfo.cs @@ -50,6 +50,6 @@ using System.Resources; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] +[assembly: AssemblyVersion("2.1.0.0")] +[assembly: AssemblyFileVersion("2.1.0.0")] [assembly: NeutralResourcesLanguageAttribute("en")] diff --git a/CustomizeMii/Readme.txt b/CustomizeMii/Readme.txt index 2b0e6b0..f0e14aa 100644 --- a/CustomizeMii/Readme.txt +++ b/CustomizeMii/Readme.txt @@ -9,6 +9,9 @@ Thanks to icefire / Xuzz for the basic idea of this Application! ----------------------------------------------------------------------------------------- Changelog: +Version 2.1 + - + Version 2.0 - Added BNS conversion (Mono and Stereo, with and without loop) - Fixed MP3 conversion (some files didn't convert) diff --git a/ForwardMii-Plugin/Resources/GX/video.cpp b/ForwardMii-Plugin/Resources/GX/video.cpp index 0c2deb2..345bcf0 100644 --- a/ForwardMii-Plugin/Resources/GX/video.cpp +++ b/ForwardMii-Plugin/Resources/GX/video.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #define DEFAULT_FIFO_SIZE 256 * 1024 static unsigned int *xfb[2] = { NULL, NULL }; // Double buffered