From f1f598c218de352064066d58432e4f1e51fac44d Mon Sep 17 00:00:00 2001 From: leathl Date: Mon, 18 Jan 2010 20:13:32 +0000 Subject: [PATCH] CustomizeMii 2.1 --- .../CustomizeMii_BackgroundWorkers.cs | 53 ++- .../CustomizeMii_ComplexForwarder.Designer.cs | 106 +++-- CustomizeMii/CustomizeMii_ComplexForwarder.cs | 27 +- CustomizeMii/CustomizeMii_Forwarders.cs | 23 +- CustomizeMii/CustomizeMii_InputBox.cs | 1 + CustomizeMii/CustomizeMii_Main.Designer.cs | 54 +-- CustomizeMii/CustomizeMii_Main.cs | 407 +++++------------- CustomizeMii/CustomizeMii_Main.resx | 1 + CustomizeMii/CustomizeMii_Preview.cs | 76 +++- CustomizeMii/CustomizeMii_PrivateFunctions.cs | 302 ++++++++++++- .../CustomizeMii_Transmit.Designer.cs | 4 +- CustomizeMii/CustomizeMii_Transmit.cs | 3 +- CustomizeMii/Instructions.txt | 14 +- CustomizeMii/Properties/AssemblyInfo.cs | 2 +- CustomizeMii/Readme.txt | 6 +- CustomizeMii/Resources/Instructions.rtf | 16 +- CustomizeMii/Wii.cs | 91 +++- CustomizeMiiInstaller/InstallerHelper.cs | 10 + ForwardMii/ForwardMii.cs | 2 +- ForwardMii/ForwardMii_GX.cs | 74 ++-- ForwardMii/Resources/GX/main.cpp | 8 +- 21 files changed, 771 insertions(+), 509 deletions(-) diff --git a/CustomizeMii/CustomizeMii_BackgroundWorkers.cs b/CustomizeMii/CustomizeMii_BackgroundWorkers.cs index fc5453c..624f391 100644 --- a/CustomizeMii/CustomizeMii_BackgroundWorkers.cs +++ b/CustomizeMii/CustomizeMii_BackgroundWorkers.cs @@ -36,8 +36,10 @@ namespace CustomizeMii void bwBannerReplace_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { - pbProgress.Value = 100; - lbStatusText.Text = string.Empty; + currentProgress.progressValue = 100; + currentProgress.progressState = " "; + + this.Invoke(ProgressUpdate); SetText(tbReplace, BannerReplace); } @@ -104,8 +106,10 @@ namespace CustomizeMii void bwIconReplace_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { - pbProgress.Value = 100; - lbStatusText.Text = string.Empty; + currentProgress.progressValue = 100; + currentProgress.progressState = " "; + + this.Invoke(ProgressUpdate); SetText(tbReplace, IconReplace); } @@ -172,8 +176,10 @@ namespace CustomizeMii void bwSoundReplace_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { - pbProgress.Value = 100; - lbStatusText.Text = string.Empty; + currentProgress.progressValue = 100; + currentProgress.progressState = " "; + + this.Invoke(ProgressUpdate); SetText(tbReplace, SoundReplace); } @@ -252,9 +258,11 @@ namespace CustomizeMii if (File.Exists(TempWavePath)) File.Delete(TempWavePath); - lbStatusText.Text = string.Empty; Mp3Path = string.Empty; - pbProgress.Value = 100; + currentProgress.progressValue = 100; + currentProgress.progressState = " "; + + this.Invoke(ProgressUpdate); } void bwConvertToBns_ProgressChanged(object sender, ProgressChangedEventArgs e) @@ -371,9 +379,11 @@ namespace CustomizeMii } } - lbStatusText.Text = string.Empty; Mp3Path = string.Empty; - pbProgress.Value = 100; + currentProgress.progressValue = 100; + currentProgress.progressState = " "; + + this.Invoke(ProgressUpdate); } void bwConvertMp3_ProgressChanged(object sender, ProgressChangedEventArgs e) @@ -435,8 +445,10 @@ namespace CustomizeMii void bwLoadChannel_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { - pbProgress.Value = 100; - lbStatusText.Text = string.Empty; + currentProgress.progressValue = 100; + currentProgress.progressState = " "; + + this.Invoke(ProgressUpdate); } void bwLoadChannel_ProgressChanged(object sender, ProgressChangedEventArgs e) @@ -538,13 +550,15 @@ namespace CustomizeMii { EventHandler EnableControls = new EventHandler(this.EnableControls); EventHandler Initialize = new EventHandler(this.Initialize); - pbProgress.Value = 100; - lbStatusText.Text = string.Empty; + currentProgress.progressValue = 100; + currentProgress.progressState = " "; + + this.Invoke(ProgressUpdate); this.Invoke(EnableControls); - this.Invoke(Initialize); if (transmitInfo.timeElapsed > 0) { + this.Invoke(Initialize); System.Windows.Forms.DialogResult dlg; if (transmitInfo.usedCompression) @@ -737,8 +751,10 @@ namespace CustomizeMii { EventHandler EnableControls = new EventHandler(this.EnableControls); EventHandler Initialize = new EventHandler(this.Initialize); - pbProgress.Value = 100; - lbStatusText.Text = string.Empty; + currentProgress.progressValue = 100; + currentProgress.progressState = " "; + + this.Invoke(ProgressUpdate); this.Invoke(EnableControls); this.Invoke(Initialize); } @@ -878,7 +894,7 @@ namespace CustomizeMii { CreateForwarderSimple(TempUnpackPath + "\\00000002.app"); } - else if (tbDol.Text.StartsWith("Complex Forwarder:")) + else if (tbDol.Text.StartsWith("Complex Forwarder")) { bwCreateWad.ReportProgress(82, "Compiling Forwarder..."); CreateForwarderComplex(TempUnpackPath + "\\00000002.app"); @@ -968,7 +984,6 @@ namespace CustomizeMii 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))); } else sendWadReady = 1; diff --git a/CustomizeMii/CustomizeMii_ComplexForwarder.Designer.cs b/CustomizeMii/CustomizeMii_ComplexForwarder.Designer.cs index 0a5e3b7..cd613b3 100644 --- a/CustomizeMii/CustomizeMii_ComplexForwarder.Designer.cs +++ b/CustomizeMii/CustomizeMii_ComplexForwarder.Designer.cs @@ -45,8 +45,7 @@ namespace CustomizeMii /// private void InitializeComponent() { - this.lbAppFolder = new System.Windows.Forms.Label(); - this.tbAppFolder = new System.Windows.Forms.TextBox(); + this.tb1 = new System.Windows.Forms.TextBox(); this.cbImage43 = new System.Windows.Forms.CheckBox(); this.cbImage169 = new System.Windows.Forms.CheckBox(); this.tbImage43 = new System.Windows.Forms.TextBox(); @@ -56,28 +55,25 @@ namespace CustomizeMii this.label1 = new System.Windows.Forms.Label(); this.btnOK = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.tb2 = new System.Windows.Forms.TextBox(); + this.tb3 = new System.Windows.Forms.TextBox(); + this.tb4 = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // - // lbAppFolder + // tb1 // - this.lbAppFolder.AutoSize = true; - this.lbAppFolder.Location = new System.Drawing.Point(12, 17); - this.lbAppFolder.Name = "lbAppFolder"; - this.lbAppFolder.Size = new System.Drawing.Size(107, 13); - this.lbAppFolder.TabIndex = 0; - this.lbAppFolder.Text = "Application Directory:"; - // - // tbAppFolder - // - this.tbAppFolder.Location = new System.Drawing.Point(125, 14); - this.tbAppFolder.Name = "tbAppFolder"; - this.tbAppFolder.Size = new System.Drawing.Size(221, 20); - this.tbAppFolder.TabIndex = 1; + this.tb1.Location = new System.Drawing.Point(12, 62); + this.tb1.Name = "tb1"; + this.tb1.Size = new System.Drawing.Size(334, 20); + this.tb1.TabIndex = 1; + this.tb1.Text = "SD:/apps/example/boot.dol"; // // cbImage43 // + this.cbImage43.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.cbImage43.AutoSize = true; - this.cbImage43.Location = new System.Drawing.Point(15, 111); + this.cbImage43.Location = new System.Drawing.Point(15, 224); this.cbImage43.Name = "cbImage43"; this.cbImage43.Size = new System.Drawing.Size(73, 17); this.cbImage43.TabIndex = 3; @@ -87,8 +83,9 @@ namespace CustomizeMii // // cbImage169 // + this.cbImage169.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.cbImage169.AutoSize = true; - this.cbImage169.Location = new System.Drawing.Point(15, 141); + this.cbImage169.Location = new System.Drawing.Point(15, 254); this.cbImage169.Name = "cbImage169"; this.cbImage169.Size = new System.Drawing.Size(79, 17); this.cbImage169.TabIndex = 3; @@ -98,24 +95,27 @@ namespace CustomizeMii // // tbImage43 // + this.tbImage43.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.tbImage43.Enabled = false; - this.tbImage43.Location = new System.Drawing.Point(94, 109); + this.tbImage43.Location = new System.Drawing.Point(94, 222); this.tbImage43.Name = "tbImage43"; this.tbImage43.Size = new System.Drawing.Size(171, 20); this.tbImage43.TabIndex = 4; // // tbImage169 // + this.tbImage169.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.tbImage169.Enabled = false; - this.tbImage169.Location = new System.Drawing.Point(94, 138); + this.tbImage169.Location = new System.Drawing.Point(94, 251); this.tbImage169.Name = "tbImage169"; this.tbImage169.Size = new System.Drawing.Size(171, 20); this.tbImage169.TabIndex = 5; // // btnBrowseImage43 // + this.btnBrowseImage43.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.btnBrowseImage43.Enabled = false; - this.btnBrowseImage43.Location = new System.Drawing.Point(271, 109); + this.btnBrowseImage43.Location = new System.Drawing.Point(271, 222); this.btnBrowseImage43.Name = "btnBrowseImage43"; this.btnBrowseImage43.Size = new System.Drawing.Size(75, 23); this.btnBrowseImage43.TabIndex = 6; @@ -125,8 +125,9 @@ namespace CustomizeMii // // btnBrowseImage169 // + this.btnBrowseImage169.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.btnBrowseImage169.Enabled = false; - this.btnBrowseImage169.Location = new System.Drawing.Point(271, 138); + this.btnBrowseImage169.Location = new System.Drawing.Point(271, 251); this.btnBrowseImage169.Name = "btnBrowseImage169"; this.btnBrowseImage169.Size = new System.Drawing.Size(75, 23); this.btnBrowseImage169.TabIndex = 6; @@ -136,7 +137,8 @@ namespace CustomizeMii // // label1 // - this.label1.Location = new System.Drawing.Point(0, 55); + this.label1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.label1.Location = new System.Drawing.Point(0, 174); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(358, 40); this.label1.TabIndex = 7; @@ -146,7 +148,8 @@ namespace CustomizeMii // // btnOK // - this.btnOK.Location = new System.Drawing.Point(15, 179); + this.btnOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.btnOK.Location = new System.Drawing.Point(15, 292); this.btnOK.Name = "btnOK"; this.btnOK.Size = new System.Drawing.Size(160, 23); this.btnOK.TabIndex = 8; @@ -156,8 +159,9 @@ namespace CustomizeMii // // btnCancel // + this.btnCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(186, 179); + this.btnCancel.Location = new System.Drawing.Point(186, 292); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(160, 23); this.btnCancel.TabIndex = 8; @@ -165,15 +169,51 @@ namespace CustomizeMii this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // + // label2 + // + this.label2.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.label2.Location = new System.Drawing.Point(0, 14); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(358, 40); + this.label2.TabIndex = 7; + this.label2.Text = "The forwarder will try to load in this order.\r\nEntries must begin with \"SD:/\" or " + + "\"USB:/\" and end with \".dol\" or \".elf\"!\r\nYou may enter whatever path you want."; + this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // tb2 + // + this.tb2.Location = new System.Drawing.Point(12, 88); + this.tb2.Name = "tb2"; + this.tb2.Size = new System.Drawing.Size(334, 20); + this.tb2.TabIndex = 1; + this.tb2.Text = "SD:/apps/example/boot.elf"; + // + // tb3 + // + this.tb3.Location = new System.Drawing.Point(12, 114); + this.tb3.Name = "tb3"; + this.tb3.Size = new System.Drawing.Size(334, 20); + this.tb3.TabIndex = 1; + this.tb3.Text = "USB:/apps/example/boot.dol"; + // + // tb4 + // + this.tb4.Location = new System.Drawing.Point(12, 140); + this.tb4.Name = "tb4"; + this.tb4.Size = new System.Drawing.Size(334, 20); + this.tb4.TabIndex = 1; + this.tb4.Text = "USB:/apps/example/boot.elf"; + // // CustomizeMii_ComplexForwarder // this.AcceptButton = this.btnOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(358, 220); + this.ClientSize = new System.Drawing.Size(358, 333); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnOK); + this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.btnBrowseImage169); this.Controls.Add(this.btnBrowseImage43); @@ -181,11 +221,14 @@ namespace CustomizeMii this.Controls.Add(this.tbImage43); this.Controls.Add(this.cbImage169); this.Controls.Add(this.cbImage43); - this.Controls.Add(this.tbAppFolder); - this.Controls.Add(this.lbAppFolder); + this.Controls.Add(this.tb4); + this.Controls.Add(this.tb3); + this.Controls.Add(this.tb2); + this.Controls.Add(this.tb1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "CustomizeMii_ComplexForwarder"; this.Text = "CustomizeMii_ComplexForwarder"; + this.Load += new System.EventHandler(this.CustomizeMii_ComplexForwarder_Load); this.ResumeLayout(false); this.PerformLayout(); @@ -193,9 +236,8 @@ namespace CustomizeMii #endregion - private System.Windows.Forms.Label lbAppFolder; private System.Windows.Forms.Label label1; - public System.Windows.Forms.TextBox tbAppFolder; + public System.Windows.Forms.TextBox tb1; public System.Windows.Forms.CheckBox cbImage43; public System.Windows.Forms.CheckBox cbImage169; public System.Windows.Forms.TextBox tbImage43; @@ -204,5 +246,9 @@ namespace CustomizeMii public System.Windows.Forms.Button btnBrowseImage169; private System.Windows.Forms.Button btnOK; private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Label label2; + public System.Windows.Forms.TextBox tb2; + public System.Windows.Forms.TextBox tb3; + public System.Windows.Forms.TextBox tb4; } } \ No newline at end of file diff --git a/CustomizeMii/CustomizeMii_ComplexForwarder.cs b/CustomizeMii/CustomizeMii_ComplexForwarder.cs index 5d1f208..0498e61 100644 --- a/CustomizeMii/CustomizeMii_ComplexForwarder.cs +++ b/CustomizeMii/CustomizeMii_ComplexForwarder.cs @@ -31,6 +31,10 @@ namespace CustomizeMii public CustomizeMii_ComplexForwarder() { InitializeComponent(); + } + + private void CustomizeMii_ComplexForwarder_Load(object sender, EventArgs e) + { this.CenterToParent(); } @@ -54,18 +58,21 @@ namespace CustomizeMii private void btnOK_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(tbAppFolder.Text)) + TextBox[] tbs = new TextBox[] { tb1, tb2, tb3, tb4 }; + foreach (TextBox tbThis in tbs) { - tbAppFolder.Focus(); - } - else - { - if (!File.Exists(tbImage43.Text)) tbImage43.Text = string.Empty; - if (!File.Exists(tbImage169.Text)) tbImage169.Text = string.Empty; - - this.DialogResult = DialogResult.OK; - this.Close(); + if ((!tbThis.Text.StartsWith("USB:/") && !tbThis.Text.StartsWith("SD:/")) || + (!tbThis.Text.EndsWith(".dol") && !tbThis.Text.EndsWith(".elf"))) + { tbThis.Focus(); tbThis.SelectAll(); return; } } + + tb1.Focus(); + + if (!File.Exists(tbImage43.Text)) tbImage43.Text = string.Empty; + if (!File.Exists(tbImage169.Text)) tbImage169.Text = string.Empty; + + this.DialogResult = DialogResult.OK; + this.Close(); } private void btnBrowse_Click(object sender, EventArgs e) diff --git a/CustomizeMii/CustomizeMii_Forwarders.cs b/CustomizeMii/CustomizeMii_Forwarders.cs index bfc2e7c..613178d 100644 --- a/CustomizeMii/CustomizeMii_Forwarders.cs +++ b/CustomizeMii/CustomizeMii_Forwarders.cs @@ -25,14 +25,16 @@ namespace CustomizeMii internal class Complex { - private string thisAppFolder; - private bool elfFirst = false; - private bool usbFirst = false; + private string path1 = "SD:/apps/example/boot.dol"; + private string path2 = "SD:/apps/example/boot.elf"; + private string path3 = "USB:/apps/example/boot.dol"; + private string path4 = "USB:/apps/example/boot.elf"; private string image43; private string image169; - public string AppFolder { get { return thisAppFolder; } set { thisAppFolder = value; } } - public bool ElfFirst { get { return elfFirst; } set { elfFirst = value; } } - public bool UsbFirst { get { return usbFirst; } set { usbFirst = value; } } + public string Path1 { get { return path1; } set { path1 = value; } } + public string Path2 { get { return path2; } set { path2 = value; } } + public string Path3 { get { return path3; } set { path3 = value; } } + public string Path4 { get { return path4; } set { path4 = value; } } public string Image43 { get { return image43; } set { image43 = value; } } public string Image169 { get { return image169; } set { image169 = value; } } @@ -43,15 +45,16 @@ namespace CustomizeMii public void Save(string Destination) { - GXForwarder Forwarder = new GXForwarder(thisAppFolder, usbFirst, elfFirst, image43, image169); + GXForwarder Forwarder = new GXForwarder(image43, image169, path1, path2, path3, path4); Forwarder.Save(Destination, true); } public void Clear() { - thisAppFolder = string.Empty; - elfFirst = false; - usbFirst = false; + path1 = "SD:/apps/example/boot.dol"; + path2 = "SD:/apps/example/boot.elf"; + path3 = "USB:/apps/example/boot.dol"; + path4 = "USB:/apps/example/boot.elf"; image43 = string.Empty; image169 = string.Empty; } diff --git a/CustomizeMii/CustomizeMii_InputBox.cs b/CustomizeMii/CustomizeMii_InputBox.cs index 0969964..957bdbe 100644 --- a/CustomizeMii/CustomizeMii_InputBox.cs +++ b/CustomizeMii/CustomizeMii_InputBox.cs @@ -47,6 +47,7 @@ namespace CustomizeMii private void CustomizeMii_InputBox_Load(object sender, EventArgs e) { this.CenterToParent(); + if (this.Location.X == 0 && this.Location.Y == 0) this.CenterToScreen(); } private void btnExit_Click(object sender, EventArgs e) diff --git a/CustomizeMii/CustomizeMii_Main.Designer.cs b/CustomizeMii/CustomizeMii_Main.Designer.cs index 5e9c36d..6d3f5ab 100644 --- a/CustomizeMii/CustomizeMii_Main.Designer.cs +++ b/CustomizeMii/CustomizeMii_Main.Designer.cs @@ -141,11 +141,11 @@ namespace CustomizeMii this.tabInstructions = new System.Windows.Forms.TabPage(); this.rtbInstructions = new System.Windows.Forms.RichTextBox(); this.tabCredits = new System.Windows.Forms.TabPage(); - this.label1 = new System.Windows.Forms.Label(); + this.lbCreditInstaller = new System.Windows.Forms.Label(); this.lbForwardMiiVersion = new System.Windows.Forms.Label(); this.panCredits = new System.Windows.Forms.Panel(); this.lbCreditThanks = new System.Windows.Forms.Label(); - this.llbUpdateAvailabe = new System.Windows.Forms.LinkLabel(); + this.llbUpdateAvailable = new System.Windows.Forms.LinkLabel(); this.llbSite = new System.Windows.Forms.LinkLabel(); this.lbCreditVersion = new System.Windows.Forms.Label(); this.lbCreditInfo = new System.Windows.Forms.Label(); @@ -412,6 +412,7 @@ namespace CustomizeMii // llbTranslateChannel // this.llbTranslateChannel.AutoSize = true; + this.llbTranslateChannel.Enabled = false; this.llbTranslateChannel.Location = new System.Drawing.Point(322, 42); this.llbTranslateChannel.Name = "llbTranslateChannel"; this.llbTranslateChannel.Size = new System.Drawing.Size(103, 13); @@ -555,6 +556,7 @@ namespace CustomizeMii this.tbAllLanguages.Name = "tbAllLanguages"; this.tbAllLanguages.Size = new System.Drawing.Size(311, 20); this.tbAllLanguages.TabIndex = 1; + this.tbAllLanguages.TextChanged += new System.EventHandler(this.tbAllLanguages_TextChanged); // // lbAllLanguages // @@ -639,8 +641,8 @@ namespace CustomizeMii this.lbOptionsOptional.Name = "lbOptionsOptional"; this.lbOptionsOptional.Size = new System.Drawing.Size(457, 34); this.lbOptionsOptional.TabIndex = 10; - this.lbOptionsOptional.Text = "These are optional. Fill them in only if you want to change them.\r\nIf you want a " + - "looped sound, set the loop points first (e.g. with Wavosaur)."; + this.lbOptionsOptional.Text = "These are optional. Fill them in only if you want to change them.\r\nIt is highly r" + + "ecommended to convert your sound to BNS."; this.lbOptionsOptional.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // btnBrowseSound @@ -1231,10 +1233,10 @@ namespace CustomizeMii // // tabCredits // - this.tabCredits.Controls.Add(this.label1); + this.tabCredits.Controls.Add(this.lbCreditInstaller); this.tabCredits.Controls.Add(this.lbForwardMiiVersion); this.tabCredits.Controls.Add(this.panCredits); - this.tabCredits.Controls.Add(this.llbUpdateAvailabe); + this.tabCredits.Controls.Add(this.llbUpdateAvailable); this.tabCredits.Controls.Add(this.llbSite); this.tabCredits.Controls.Add(this.lbCreditVersion); this.tabCredits.Controls.Add(this.lbCreditInfo); @@ -1246,14 +1248,14 @@ namespace CustomizeMii this.tabCredits.Text = "About"; this.tabCredits.UseVisualStyleBackColor = true; // - // label1 + // lbCreditInstaller // - this.label1.Location = new System.Drawing.Point(0, 28); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(443, 13); - this.label1.TabIndex = 7; - this.label1.Text = "CustomizeMii Installer by WiiCrazy / I.R.on"; - this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter; + this.lbCreditInstaller.Location = new System.Drawing.Point(0, 28); + this.lbCreditInstaller.Name = "lbCreditInstaller"; + this.lbCreditInstaller.Size = new System.Drawing.Size(443, 13); + this.lbCreditInstaller.TabIndex = 7; + this.lbCreditInstaller.Text = "CustomizeMii Installer X by WiiCrazy / I.R.on"; + this.lbCreditInstaller.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // lbForwardMiiVersion // @@ -1283,18 +1285,18 @@ namespace CustomizeMii this.lbCreditThanks.Text = resources.GetString("lbCreditThanks.Text"); this.lbCreditThanks.TextAlign = System.Drawing.ContentAlignment.TopCenter; // - // llbUpdateAvailabe + // llbUpdateAvailable // - this.llbUpdateAvailabe.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.llbUpdateAvailabe.Location = new System.Drawing.Point(0, 67); - this.llbUpdateAvailabe.Name = "llbUpdateAvailabe"; - this.llbUpdateAvailabe.Size = new System.Drawing.Size(443, 13); - this.llbUpdateAvailabe.TabIndex = 4; - this.llbUpdateAvailabe.TabStop = true; - this.llbUpdateAvailabe.Text = "Version X is availabe, get it here!"; - this.llbUpdateAvailabe.TextAlign = System.Drawing.ContentAlignment.TopCenter; - this.llbUpdateAvailabe.Visible = false; - this.llbUpdateAvailabe.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llbUpdateAvailabe_LinkClicked); + this.llbUpdateAvailable.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.llbUpdateAvailable.Location = new System.Drawing.Point(0, 67); + this.llbUpdateAvailable.Name = "llbUpdateAvailable"; + this.llbUpdateAvailable.Size = new System.Drawing.Size(443, 13); + this.llbUpdateAvailable.TabIndex = 4; + this.llbUpdateAvailable.TabStop = true; + this.llbUpdateAvailable.Text = "Version X is available, get it here!"; + this.llbUpdateAvailable.TextAlign = System.Drawing.ContentAlignment.TopCenter; + this.llbUpdateAvailable.Visible = false; + this.llbUpdateAvailable.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llbUpdateAvailable_LinkClicked); // // llbSite // @@ -1673,7 +1675,7 @@ namespace CustomizeMii private System.Windows.Forms.Label lbBrlanActions; private System.Windows.Forms.Label lbBrlytWarning; private System.Windows.Forms.Label lbBrlanWarning; - private System.Windows.Forms.LinkLabel llbUpdateAvailabe; + private System.Windows.Forms.LinkLabel llbUpdateAvailable; private System.Windows.Forms.Button btnDeleteBanner; private System.Windows.Forms.Button btnAddBanner; private System.Windows.Forms.Button btnAddIcon; @@ -1709,7 +1711,7 @@ namespace CustomizeMii private System.Windows.Forms.Label lbForwardMiiVersion; private System.Windows.Forms.Label lbCreated; private System.Windows.Forms.Label lbCreatedValue; - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label lbCreditInstaller; private System.Windows.Forms.ToolStripMenuItem tsExtractBrl; private System.Windows.Forms.ToolStripMenuItem cmExtractBrlyt; private System.Windows.Forms.ToolStripMenuItem cmExtractBrlan; diff --git a/CustomizeMii/CustomizeMii_Main.cs b/CustomizeMii/CustomizeMii_Main.cs index 040cffb..1ee55c5 100644 --- a/CustomizeMii/CustomizeMii_Main.cs +++ b/CustomizeMii/CustomizeMii_Main.cs @@ -25,7 +25,6 @@ using System.Diagnostics; using System.Drawing; using System.IO; using System.Net; -using System.Text.RegularExpressions; using System.Windows.Forms; #if !Mono @@ -159,6 +158,9 @@ namespace CustomizeMii { this.Text = this.Text.Replace("X", version); this.lbCreditVersion.Text = this.lbCreditVersion.Text.Replace("X", version); + if (File.Exists(Application.StartupPath + "\\CustomizeMiiInstaller.dll")) + this.lbCreditInstaller.Text = this.lbCreditInstaller.Text.Replace("X", GetInstallerVersion()); + else this.lbCreditInstaller.Text = this.lbCreditInstaller.Text.Replace(" X", string.Empty); if (Directory.Exists(TempPath)) Directory.Delete(TempPath, true); ProgressUpdate = new EventHandler(this.UpdateProgress); SetButtonText(); @@ -194,7 +196,7 @@ namespace CustomizeMii { try { - lbForwardMiiVersion.Text = lbForwardMiiVersion.Text.Replace("X", ForwardMii_Plugin.GetVersion()); + lbForwardMiiVersion.Text = lbForwardMiiVersion.Text.Replace("X", GetForwardMiiVersion()); lbForwardMiiVersion.Visible = true; } catch { } @@ -414,6 +416,7 @@ namespace CustomizeMii if (!string.IsNullOrEmpty(currentProgress.progressState)) { + if (currentProgress.progressState == " ") currentProgress.progressState = string.Empty; lbStatusText.Text = currentProgress.progressState; currentProgress.progressState = string.Empty; } @@ -424,66 +427,6 @@ namespace CustomizeMii tbSourceWad.Text = SourceWad; } - private void ForwarderDialogSimple() - { - CustomizeMii_InputBox ib = new CustomizeMii_InputBox(false); - ib.Size = new Size(ib.Size.Width, 120); - ib.lbInfo.Text = "Enter the application folder where the forwarder will point to (3-18 chars)"; - ib.tbInput.MaxLength = 18; - ib.btnExit.Text = "Close"; - ib.cbElf.Visible = true; - - ib.tbInput.Text = SimpleForwarder.AppFolder; - ib.cbElf.Checked = SimpleForwarder.ForwardToElf; - - if (ib.ShowDialog() == DialogResult.OK) - { - SimpleForwarder.ForwardToElf = ib.cbElf.Checked; - SimpleForwarder.AppFolder = ib.Input; - SetText(tbDol, string.Format("Simple Forwarder: \"SD:\\apps\\{0}\\boot.{1}\"", - SimpleForwarder.AppFolder, SimpleForwarder.ForwardToElf == true ? "elf" : "dol")); - btnBrowseDol.Text = "Clear"; - } - } - - private void ForwarderDialogComplex() - { - CustomizeMii_ComplexForwarder cf = new CustomizeMii_ComplexForwarder(); - cf.tbAppFolder.Text = ComplexForwarder.AppFolder; - //cf.rbSD.Checked = !ComplexForwarder.UsbFirst; - //cf.rbUSB.Checked = ComplexForwarder.UsbFirst; - //cf.rbDOL.Checked = !ComplexForwarder.ElfFirst; - //cf.rbELF.Checked = ComplexForwarder.ElfFirst; - - if (!string.IsNullOrEmpty(ComplexForwarder.Image43)) - { - cf.cbImage43.Checked = true; - cf.tbImage43.Enabled = true; - cf.btnBrowseImage43.Enabled = true; - - cf.tbImage43.Text = ComplexForwarder.Image43; - } - if (!string.IsNullOrEmpty(ComplexForwarder.Image169)) - { - cf.cbImage169.Checked = true; - cf.tbImage169.Enabled = true; - cf.btnBrowseImage169.Enabled = true; - - cf.tbImage169.Text = ComplexForwarder.Image169; - } - - if (cf.ShowDialog() == DialogResult.OK) - { - ComplexForwarder.AppFolder = cf.tbAppFolder.Text; - //ComplexForwarder.UsbFirst = cf.rbUSB.Checked; - //ComplexForwarder.ElfFirst = cf.rbELF.Checked; - ComplexForwarder.Image43 = cf.tbImage43.Text; - ComplexForwarder.Image169 = cf.tbImage169.Text; - - SetText(tbDol, string.Format("Complex Forwarder: \"{0}\"", ComplexForwarder.AppFolder)); - } - } - private void tabControl_Selecting(object sender, TabControlCancelEventArgs e) { tmrCredits.Stop(); @@ -617,13 +560,14 @@ namespace CustomizeMii if (newVersion > thisVersion) { - llbUpdateAvailabe.Text = llbUpdateAvailabe.Text.Replace("X", NewVersion); - llbUpdateAvailabe.Visible = true; + llbUpdateAvailable.Text = llbUpdateAvailable.Text.Replace("X", NewVersion); + llbUpdateAvailable.Visible = true; lbForwardMiiVersion.Tag = "Update"; + lbForwardMiiVersion.Visible = false; if (MessageBox.Show("Version " + NewVersion + - " is availabe.\nDo you want the download page to be opened?", - "Update availabe", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == + " is available.\nDo you want the download page to be opened?", + "Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Process.Start("http://code.google.com/p/customizemii/downloads/list"); @@ -634,6 +578,11 @@ namespace CustomizeMii } } + private string GetInstallerVersion() + { + return CustomizeMiiInstaller.CustomizeMiiInstaller_Plugin.GetVersion(); + } + #if !Mono private string GetForwardMiiVersion() { @@ -661,8 +610,8 @@ namespace CustomizeMii if (newVersion > thisVersion) { if (MessageBox.Show("Version " + NewVersion + - " of the ForwardMii-Plugin is availabe.\nDo you want the download page to be opened?", - "ForwardMii Update availabe", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == + " of the ForwardMii-Plugin is available.\nDo you want the download page to be opened?", + "ForwardMii Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Process.Start("http://code.google.com/p/customizemii/downloads/list"); @@ -705,25 +654,11 @@ namespace CustomizeMii if (tbSourceWad.Text != SourceWadUrls[lbxBaseWads.SelectedIndex]) { - try - { - SourceWad = "http://customizemii.googlecode.com/svn/branches/Base_WADs/" + SourceWadUrls[lbxBaseWads.SelectedIndex]; - tbSourceWad.Text = SourceWad; - WebClient Client = new WebClient(); - Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Client_DownloadProgressChanged); - Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted); + SourceWad = "http://customizemii.googlecode.com/svn/branches/Base_WADs/" + SourceWadUrls[lbxBaseWads.SelectedIndex]; + tbSourceWad.Text = SourceWad; - lbStatusText.Text = "Downloading Base WAD..."; - pbProgress.Value = 0; - if (!Directory.Exists(TempWadPath.Remove(TempWadPath.LastIndexOf('\\')))) - Directory.CreateDirectory(TempWadPath.Remove(TempWadPath.LastIndexOf('\\'))); - Client.DownloadFileAsync(new Uri(SourceWad), TempWadPath); - } - catch (Exception ex) - { - tbSourceWad.Text = string.Empty; - ErrorBox(ex.Message); - } + System.Threading.Thread dlThread = new System.Threading.Thread(new System.Threading.ThreadStart(DownloadBaseWad)); + dlThread.Start(); } } else @@ -734,15 +669,41 @@ namespace CustomizeMii } } + void DownloadBaseWad() + { + try + { + WebClient Client = new WebClient(); + Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Client_DownloadProgressChanged); + Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted); + + currentProgress.progressState = "Downloading Base WAD..."; + currentProgress.progressValue= 0; + this.Invoke(ProgressUpdate); + + if (!Directory.Exists(TempWadPath.Remove(TempWadPath.LastIndexOf('\\')))) + Directory.CreateDirectory(TempWadPath.Remove(TempWadPath.LastIndexOf('\\'))); + Client.DownloadFileAsync(new Uri(SourceWad), TempWadPath); + } + catch (Exception ex) + { + SetText(tbSourceWad, string.Empty); + ErrorBox(ex.Message); + } + } + void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { - pbProgress.Value = e.ProgressPercentage; + currentProgress.progressValue = e.ProgressPercentage; + currentProgress.progressState = "Downloading Base WAD..."; + this.Invoke(ProgressUpdate); } void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { - pbProgress.Value = 100; - lbStatusText.Text = string.Empty; + currentProgress.progressValue = 0; + currentProgress.progressState = string.Empty; + this.Invoke(ProgressUpdate); if (File.Exists(TempWadPath)) { @@ -781,7 +742,7 @@ namespace CustomizeMii catch (Exception ex) { ErrorBox(ex.Message); } } else - InfoBox("There's no preview of this channel availabe, sorry!"); + InfoBox("There's no preview of this channel available, sorry!"); } else { @@ -1332,211 +1293,6 @@ namespace CustomizeMii } } - private bool FailureCheck() - { - try - { - //Check Unpack Folder - if (CheckUnpackFolder() == false) - { - if (UnpackFolderErrorCount > 0) - { - ErrorBox("Something's wrong with the temporary files.\nYou may have to start again." + - "\n\nIf this message keeps bothering you, please report as much information " + - "as possible at the issue tracker: http://code.google.com/p/customizemii/issues/list"); - } - else - { - ErrorBox("Something's wrong with the temporary files.\nYou may have to start again."); - } - - UnpackFolderErrorCount++; - return false; - } - - //Check Channel Title Boxes - if (!(!string.IsNullOrEmpty(tbAllLanguages.Text) || - (!string.IsNullOrEmpty(tbEnglish.Text) && - !string.IsNullOrEmpty(tbJapanese.Text) && - !string.IsNullOrEmpty(tbGerman.Text) && - !string.IsNullOrEmpty(tbFrench.Text) && - !string.IsNullOrEmpty(tbSpanish.Text) && - !string.IsNullOrEmpty(tbItalian.Text) && - !string.IsNullOrEmpty(tbDutch.Text)))) - { - ErrorBox("You must either enter a general Channel Title or one for each language!"); - return false; - } - - //Check Title ID Length + Chars - if (tbTitleID.Text.Length != 4) - { - ErrorBox("The Title ID must be 4 characters long!"); return false; - } - - Regex allowedchars = new Regex("[A-Z0-9]{4}$"); - if (!allowedchars.IsMatch(tbTitleID.Text.ToUpper())) - { - ErrorBox("Please enter a valid Title ID!"); return false; - } - - //Check brlan files - string[] ValidBrlans = new string[] { "banner.brlan", "icon.brlan", "banner_loop.brlan", "icon_loop.brlan", "banner_start.brlan", "icon_start.brlan" }; - foreach (string thisBrlan in lbxBrlanBanner.Items) - { - if (!Wii.Tools.StringExistsInStringArray(thisBrlan.ToLower(), ValidBrlans)) - { - ErrorBox(thisBrlan + " is not a valid brlan filename!"); - return false; - } - } - foreach (string thisBrlan in lbxBrlanIcon.Items) - { - if (!Wii.Tools.StringExistsInStringArray(thisBrlan.ToLower(), ValidBrlans)) - { - ErrorBox(thisBrlan + " is not a valid brlan filename!"); - return false; - } - } - - //Check TPLs - List BannerTpls = new List(); - List IconTpls = new List(); - foreach (string thisTpl in lbxBannerTpls.Items) BannerTpls.Add(thisTpl.Replace(" (Transparent)", string.Empty)); - foreach (string thisTpl in lbxIconTpls.Items) IconTpls.Add(thisTpl.Replace(" (Transparent)", string.Empty)); - - string[] BannerBrlytPath; - string[] IconBrlytPath; - - if (string.IsNullOrEmpty(BannerReplace)) - BannerBrlytPath = Directory.GetFiles(TempUnpackBannerBrlytPath); - else - BannerBrlytPath = Directory.GetFiles(TempBannerPath + "arc\\blyt"); - if (string.IsNullOrEmpty(IconReplace)) - IconBrlytPath = Directory.GetFiles(TempUnpackIconBrlytPath); - else - IconBrlytPath = Directory.GetFiles(TempIconPath + "arc\\blyt"); - - string[] BannerMissing; - string[] BannerUnused; - string[] IconMissing; - string[] IconUnused; - - //Check for missing TPLs - if (Wii.Brlyt.CheckForMissingTpls(BannerBrlytPath[0], BannerTpls.ToArray(), out BannerMissing) == true) - { - ErrorBox("The following Banner TPLs are required by the banner.brlyt, but missing:\n\n" + string.Join("\n", BannerMissing)); - return false; - } - if (Wii.Brlyt.CheckForMissingTpls(IconBrlytPath[0], IconTpls.ToArray(), out IconMissing) == true) - { - ErrorBox("The following Icon TPLs are required by the icon.brlyt, but missing:\n\n" + string.Join("\n", IconMissing)); - return false; - } - - //Check Sound length - int soundLength = 0; - if (!string.IsNullOrEmpty(tbSound.Text) && string.IsNullOrEmpty(SoundReplace)) - { - if (!tbSound.Text.ToLower().EndsWith(".bns") && !tbSound.Text.StartsWith("BNS:")) - { - string SoundFile = tbSound.Text; - if (tbSound.Text.ToLower().EndsWith(".mp3")) SoundFile = TempWavePath; - - soundLength = Wii.Sound.GetWaveLength(SoundFile); - if (soundLength > SoundMaxLength) - { - ErrorBox(string.Format("Your Sound is longer than {0} seconds and thus not supported.\nIt is recommended to use a Sound shorter than {1} seconds, the maximum length is {0} seconds!", SoundMaxLength, SoundWarningLength)); - return false; - } - } - } - - /*Errors till here.. - From here only Warnings!*/ - - if (soundLength > SoundWarningLength) - { - if (MessageBox.Show(string.Format("Your Sound is longer than {0} seconds.\nIt is recommended to use Sounds that are shorter than {0} seconds!\nDo you still want to continue?", SoundWarningLength), "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) - return false; - } - - //Check BNS sound length - if (tbSound.Text.StartsWith("BNS:") || tbSound.Text.ToLower().EndsWith(".bns")) - { - string bnsFile = tbSound.Text; - if (tbSound.Text.StartsWith("BNS:")) bnsFile = TempBnsPath; - - int bnsLength = Wii.Sound.GetBnsLength(bnsFile); - if (bnsLength > BnsWarningLength) - { - if (MessageBox.Show(string.Format("Your BNS Sound is longer than {0} seconds.\nIt is recommended to use Sounds that are shorter than {0} seconds!\nDo you still want to continue?", BnsWarningLength), "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) - return false; - } - } - - //Check if brlyt or brlan were changed - if (BrlytChanged == true && BrlanChanged == false) - { - if (MessageBox.Show("You have changed the brlyt, but didn't change the brlan.\nAre you sure this is correct?", "brlyt Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) - return false; - } - else if (BrlanChanged == true && BrlytChanged == false) - { - if (MessageBox.Show("You have changed the brlan, but didn't change the brlyt.\nAre you sure this is correct?", "brlan Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) - return false; - } - - //Check for unused TPLs (Do this at the end of the failure checks, because we don't want a - // MessageBox asking if unused TPLs should be deleted and after that any error) - if (Wii.Brlyt.CheckForUnusedTpls(BannerBrlytPath[0], BannerTpls.ToArray(), out BannerUnused) == true) - { - DialogResult dlgresult = MessageBox.Show( - "The following Banner TPLs are unused by the banner.brlyt:\n\n" + - string.Join("\n", BannerUnused) + - "\n\nDo you want them to be deleted before the WAD is being created? (Saves space!)", - "Delete unused TPLs?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); - if (dlgresult == DialogResult.Yes) - { - foreach (string thisTpl in BannerUnused) - { - if (string.IsNullOrEmpty(BannerReplace)) - File.Delete(TempUnpackBannerTplPath + thisTpl); - else - File.Delete(TempBannerPath + "arc\\timg\\" + thisTpl); - } - } - else if (dlgresult == DialogResult.Cancel) return false; - } - if (Wii.Brlyt.CheckForUnusedTpls(IconBrlytPath[0], IconTpls.ToArray(), out IconUnused) == true) - { - DialogResult dlgresult = MessageBox.Show( - "The following Icon TPLs are unused by the icon.brlyt:\n\n" + - string.Join("\n", IconUnused) + - "\n\nDo you want them to be deleted before the WAD is being created? (Saves memory!)", - "Delete unused TPLs?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); - if (dlgresult == DialogResult.Yes) - { - foreach (string thisTpl in IconUnused) - { - if (string.IsNullOrEmpty(IconReplace)) - File.Delete(TempUnpackIconTplPath + thisTpl); - else - File.Delete(TempIconPath + "arc\\timg\\" + thisTpl); - } - } - else if (dlgresult == DialogResult.Cancel) return false; - } - - return true; - } - catch (Exception ex) - { - ErrorBox(ex.Message); - return false; - } - } - private bool CheckUnpackFolder() { try @@ -1871,7 +1627,7 @@ namespace CustomizeMii { if (!File.Exists(Application.StartupPath + "\\CustomizeMiiInstaller.dll")) { - ErrorBox("The CustomizeMiiInstaller.dll wasn't found!"); + ErrorBox("CustomizeMiiInstaller.dll wasn't found!"); } else { @@ -2276,11 +2032,11 @@ namespace CustomizeMii } } - private void llbUpdateAvailabe_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + private void llbUpdateAvailable_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { - llbUpdateAvailabe.LinkVisited = true; + llbUpdateAvailable.LinkVisited = true; Process.Start("http://code.google.com/p/customizemii/downloads/list"); } catch (Exception ex) { ErrorBox(ex.Message); } @@ -2296,7 +2052,7 @@ namespace CustomizeMii { string TplName = lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty); string CurBannerPath = GetCurBannerPath(); - string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurBannerPath + "blyt\\banner.brlyt"); + string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurBannerPath + "blyt\\banner.brlyt", (File.Exists(CurBannerPath + "anim\\banner.brlan")) ? CurBannerPath + "anim\\banner.brlan" : CurBannerPath + "anim\\banner_loop.brlan"); if (!Wii.Tools.StringExistsInStringArray(TplName, brlytTpls) || cbFailureChecks.Checked) { @@ -2335,7 +2091,7 @@ namespace CustomizeMii string TplName = lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty); string CurIconPath = GetCurIconPath(); - string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurIconPath + "blyt\\icon.brlyt"); + string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurIconPath + "blyt\\icon.brlyt", CurIconPath + "anim\\icon.brlan"); if (!Wii.Tools.StringExistsInStringArray(TplName, brlytTpls) || cbFailureChecks.Checked) { @@ -2380,7 +2136,7 @@ namespace CustomizeMii if (lbBrlytActions.Text == "Banner") { string CurBannerPath = GetCurBannerPath(); - string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurBannerPath + "blyt\\banner.brlyt"); + string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurBannerPath + "blyt\\banner.brlyt", (File.Exists(CurBannerPath + "anim\\banner.brlan")) ? CurBannerPath + "anim\\banner.brlan" : CurBannerPath + "anim\\banner_loop.brlan"); MessageBox.Show("These are the TPLs required by your banner.brlyt:\n\n" + string.Join("\n", brlytTpls), "TPLs specified in banner.brlyt", MessageBoxButtons.OK, @@ -2389,7 +2145,7 @@ namespace CustomizeMii else { string CurIconPath = GetCurIconPath(); - string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurIconPath + "blyt\\icon.brlyt"); + string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurIconPath + "blyt\\icon.brlyt", CurIconPath + "anim\\icon.brlan"); MessageBox.Show("These are the TPLs required by your icon.brlyt:\n\n" + string.Join("\n", brlytTpls), "TPLs specified in icon.brlyt", MessageBoxButtons.OK, @@ -2489,7 +2245,7 @@ namespace CustomizeMii } else { - if (MessageBox.Show("You don't have the ForwardMii.dll in your application folder.\nYou can download it on the project page, do you want the page to be opened?", "Plugin not availabe", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) + if (MessageBox.Show("You don't have the ForwardMii.dll in your application folder.\nYou can download it on the project page, do you want the page to be opened?", "Plugin not available", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Process.Start("http://code.google.com/p/customizemii/downloads/list"); } @@ -2504,7 +2260,21 @@ namespace CustomizeMii if (cmSender == cmSimpleForwarder) ForwarderDialogSimple(); else - ForwarderDialogComplex(); + { + try + { + if (double.Parse(GetForwardMiiVersion()) < 1.1) + { + ErrorBox("Version 1.1 or higher of the ForwardMii.dll is required!"); + return; + } + ForwarderDialogComplex(); + } + catch (Exception ex) + { + ErrorBox(ex.Message); + } + } } private void btnOptionsExtract_Click(object sender, EventArgs e) @@ -2913,12 +2683,24 @@ namespace CustomizeMii tbGerman.Text = tempText.Remove(startIndex, 7).Insert(startIndex, "Kanal"); tbDutch.Text = tempText.Remove(startIndex, 7).Insert(startIndex, "Kanaal"); - if (tempText[startIndex - 1] != ' ') tbFrench.Text = tempText.Remove(startIndex, 7).Insert(0, "Chaîne "); - else tbFrench.Text = tempText.Remove(startIndex - 1, 8).Insert(0, "Chaîne "); - if (tempText[startIndex - 1] != ' ') tbSpanish.Text = tempText.Remove(startIndex, 7).Insert(0, "Canal "); - else tbSpanish.Text = tempText.Remove(startIndex - 1, 8).Insert(0, "Canal "); - if (tempText[startIndex - 1] != ' ') tbItalian.Text = tempText.Remove(startIndex, 7).Insert(0, "Canale "); - else tbItalian.Text = tempText.Remove(startIndex - 1, 8).Insert(0, "Canale "); + try + { + if (tempText[startIndex - 1] != ' ') tbFrench.Text = tempText.Remove(startIndex, 7).Insert(0, "Chaîne "); + else tbFrench.Text = tempText.Remove(startIndex - 1, 8).Insert(0, "Chaîne "); + } + catch { tbFrench.Text = tempText.Remove(startIndex, 7).Insert(0, "Chaîne"); } + try + { + if (tempText[startIndex - 1] != ' ') tbSpanish.Text = tempText.Remove(startIndex, 7).Insert(0, "Canal "); + else tbSpanish.Text = tempText.Remove(startIndex - 1, 8).Insert(0, "Canal "); + } + catch { tbSpanish.Text = tempText.Remove(startIndex, 7).Insert(0, "Canal"); } + try + { + if (tempText[startIndex - 1] != ' ') tbItalian.Text = tempText.Remove(startIndex, 7).Insert(0, "Canale "); + else tbItalian.Text = tempText.Remove(startIndex - 1, 8).Insert(0, "Canale "); + } + catch { tbItalian.Text = tempText.Remove(startIndex, 7).Insert(0, "Canale"); } tbAllLanguages.Text = string.Empty; } @@ -2937,5 +2719,10 @@ namespace CustomizeMii ErrorBox(ex.Message); } } + + private void tbAllLanguages_TextChanged(object sender, EventArgs e) + { + llbTranslateChannel.Enabled = tbAllLanguages.Text.ToLower().Contains("channel"); + } } } diff --git a/CustomizeMii/CustomizeMii_Main.resx b/CustomizeMii/CustomizeMii_Main.resx index 0ca0828..5e6aa76 100644 --- a/CustomizeMii/CustomizeMii_Main.resx +++ b/CustomizeMii/CustomizeMii_Main.resx @@ -120,6 +120,7 @@ Thanks: Xuzz for his idea and hard work +WiiCrazy / I.R.on for CustomizeMii Installer Xuzz, SquidMan, megazig, Matt_P, Omega and The Lemon Man for Wii.py SquidMan for Zetsubou Andre Perrot for gbalzss diff --git a/CustomizeMii/CustomizeMii_Preview.cs b/CustomizeMii/CustomizeMii_Preview.cs index 3e92f81..bf3ea9f 100644 --- a/CustomizeMii/CustomizeMii_Preview.cs +++ b/CustomizeMii/CustomizeMii_Preview.cs @@ -26,6 +26,7 @@ namespace CustomizeMii { public string startTPL; public bool startIcon = false; + private Image[,] images; public CustomizeMii_Preview() { @@ -87,6 +88,11 @@ namespace CustomizeMii cbIcon.Items.Add((object)picname); } + if (bannerpics.Length > iconpics.Length) + images = new Image[2, bannerpics.Length]; + else + images = new Image[2, iconpics.Length]; + try { if (startIndex != -1) @@ -105,19 +111,35 @@ namespace CustomizeMii { if (cbBanner.SelectedIndex != -1) { - byte[] tpl; + //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"); + //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); + //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; + //Image tmpImg = Wii.TPL.ConvertFromTPL(tpl); + //pbPic.Image = tmpImg; - cbIcon.SelectedIndex = -1; + //cbIcon.SelectedIndex = -1; + + if (images[0, cbBanner.SelectedIndex] == null) + { + 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); + + images[0, cbBanner.SelectedIndex] = Wii.TPL.ConvertFromTPL(tpl); + } + + pbPic.Image = images[0, cbBanner.SelectedIndex]; } } @@ -125,19 +147,35 @@ namespace CustomizeMii { if (cbIcon.SelectedIndex != -1) { - byte[] tpl; + //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); + //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"); - Image tmpImg = Wii.TPL.ConvertFromTPL(tpl); - pbPic.Image = tmpImg; + //lbSize.Text = Wii.TPL.GetTextureWidth(tpl).ToString() + " x " + Wii.TPL.GetTextureHeight(tpl).ToString(); + //lbFormat.Text = Wii.TPL.GetTextureFormatName(tpl); - cbBanner.SelectedIndex = -1; + //Image tmpImg = Wii.TPL.ConvertFromTPL(tpl); + //pbPic.Image = tmpImg; + + //cbBanner.SelectedIndex = -1; + + if (images[1, cbIcon.SelectedIndex] == null) + { + 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); + + images[1, cbIcon.SelectedIndex] = Wii.TPL.ConvertFromTPL(tpl); + } + + pbPic.Image = images[1, cbIcon.SelectedIndex]; } } diff --git a/CustomizeMii/CustomizeMii_PrivateFunctions.cs b/CustomizeMii/CustomizeMii_PrivateFunctions.cs index 1110d4d..321f4c8 100644 --- a/CustomizeMii/CustomizeMii_PrivateFunctions.cs +++ b/CustomizeMii/CustomizeMii_PrivateFunctions.cs @@ -16,15 +16,306 @@ */ using System; -using System.Windows.Forms; +using System.Collections.Generic; using System.ComponentModel; -using System.IO; using System.Drawing; +using System.IO; +using System.Text.RegularExpressions; +using System.Windows.Forms; namespace CustomizeMii { partial class CustomizeMii_Main { + private bool FailureCheck() + { + try + { + currentProgress.progressValue = 100; + currentProgress.progressState = "Error Checks..."; + this.Invoke(ProgressUpdate); + + //Check Unpack Folder + if (CheckUnpackFolder() == false) + { + if (UnpackFolderErrorCount > 0) + { + ErrorBox("Something's wrong with the temporary files.\nYou may have to start again." + + "\n\nIf this message keeps bothering you, please report as much information " + + "as possible at the issue tracker: http://code.google.com/p/customizemii/issues/list"); + } + else + { + ErrorBox("Something's wrong with the temporary files.\nYou may have to start again."); + } + + UnpackFolderErrorCount++; + return false; + } + + //Check Channel Title Boxes + if (!(!string.IsNullOrEmpty(tbAllLanguages.Text) || + (!string.IsNullOrEmpty(tbEnglish.Text) && + !string.IsNullOrEmpty(tbJapanese.Text) && + !string.IsNullOrEmpty(tbGerman.Text) && + !string.IsNullOrEmpty(tbFrench.Text) && + !string.IsNullOrEmpty(tbSpanish.Text) && + !string.IsNullOrEmpty(tbItalian.Text) && + !string.IsNullOrEmpty(tbDutch.Text)))) + { + ErrorBox("You must either enter a general Channel Title or one for each language!"); + return false; + } + + //Check Title ID Length + Chars + if (tbTitleID.Text.Length != 4) + { + ErrorBox("The Title ID must be 4 characters long!"); return false; + } + + Regex allowedchars = new Regex("[A-Z0-9]{4}$"); + if (!allowedchars.IsMatch(tbTitleID.Text.ToUpper())) + { + ErrorBox("Please enter a valid Title ID!"); return false; + } + + //Check brlan files + string[] ValidBrlans = new string[] { "banner.brlan", "icon.brlan", "banner_loop.brlan", "icon_loop.brlan", "banner_start.brlan", "icon_start.brlan" }; + foreach (string thisBrlan in lbxBrlanBanner.Items) + { + if (!Wii.Tools.StringExistsInStringArray(thisBrlan.ToLower(), ValidBrlans)) + { + ErrorBox(thisBrlan + " is not a valid brlan filename!"); + return false; + } + } + foreach (string thisBrlan in lbxBrlanIcon.Items) + { + if (!Wii.Tools.StringExistsInStringArray(thisBrlan.ToLower(), ValidBrlans)) + { + ErrorBox(thisBrlan + " is not a valid brlan filename!"); + return false; + } + } + + //Check TPLs + List BannerTpls = new List(); + List IconTpls = new List(); + foreach (string thisTpl in lbxBannerTpls.Items) BannerTpls.Add(thisTpl.Replace(" (Transparent)", string.Empty)); + foreach (string thisTpl in lbxIconTpls.Items) IconTpls.Add(thisTpl.Replace(" (Transparent)", string.Empty)); + + string[] BannerBrlytPath; + string[] BannerBrlanPath; + string[] IconBrlytPath; + string[] IconBrlanPath; + + if (string.IsNullOrEmpty(BannerReplace)) + { + BannerBrlytPath = Directory.GetFiles(TempUnpackBannerBrlytPath); + BannerBrlanPath = Directory.GetFiles(TempUnpackBannerBrlanPath); + } + else + { + BannerBrlytPath = Directory.GetFiles(TempBannerPath + "arc\\blyt"); + BannerBrlanPath = Directory.GetFiles(TempBannerPath + "arc\\anim"); + } + if (string.IsNullOrEmpty(IconReplace)) + { + IconBrlytPath = Directory.GetFiles(TempUnpackIconBrlytPath); + IconBrlanPath = Directory.GetFiles(TempUnpackIconBrlanPath); + } + else + { + IconBrlytPath = Directory.GetFiles(TempIconPath + "arc\\blyt"); + IconBrlanPath = Directory.GetFiles(TempIconPath + "arc\\anim"); + } + + string[] BannerMissing; + string[] BannerUnused; + string[] IconMissing; + string[] IconUnused; + + //Check for missing TPLs + if (Wii.Brlyt.CheckForMissingTpls(BannerBrlytPath[0], BannerBrlanPath[0], BannerTpls.ToArray(), out BannerMissing) == true) + { + ErrorBox("The following Banner TPLs are required by the banner.brlyt, but missing:\n\n" + string.Join("\n", BannerMissing)); + return false; + } + if (Wii.Brlyt.CheckForMissingTpls(IconBrlytPath[0], IconBrlanPath[0], IconTpls.ToArray(), out IconMissing) == true) + { + ErrorBox("The following Icon TPLs are required by the icon.brlyt, but missing:\n\n" + string.Join("\n", IconMissing)); + return false; + } + + //Check Sound length + int soundLength = 0; + if (!string.IsNullOrEmpty(tbSound.Text) && string.IsNullOrEmpty(SoundReplace)) + { + if (!tbSound.Text.ToLower().EndsWith(".bns") && !tbSound.Text.StartsWith("BNS:")) + { + string SoundFile = tbSound.Text; + if (tbSound.Text.ToLower().EndsWith(".mp3")) SoundFile = TempWavePath; + + soundLength = Wii.Sound.GetWaveLength(SoundFile); + if (soundLength > SoundMaxLength) + { + ErrorBox(string.Format("Your Sound is longer than {0} seconds and thus not supported.\nIt is recommended to use a Sound shorter than {1} seconds, the maximum length is {0} seconds!", SoundMaxLength, SoundWarningLength)); + return false; + } + } + } + + /*Errors till here.. + From here only Warnings!*/ + + if (soundLength > SoundWarningLength) + { + if (MessageBox.Show(string.Format("Your Sound is longer than {0} seconds.\nIt is recommended to use Sounds that are shorter than {0} seconds!\nDo you still want to continue?", SoundWarningLength), "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) + return false; + } + + //Check BNS sound length + if (tbSound.Text.StartsWith("BNS:") || tbSound.Text.ToLower().EndsWith(".bns")) + { + string bnsFile = tbSound.Text; + if (tbSound.Text.StartsWith("BNS:")) bnsFile = TempBnsPath; + + int bnsLength = Wii.Sound.GetBnsLength(bnsFile); + if (bnsLength > BnsWarningLength) + { + if (MessageBox.Show(string.Format("Your BNS Sound is longer than {0} seconds.\nIt is recommended to use Sounds that are shorter than {0} seconds!\nDo you still want to continue?", BnsWarningLength), "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) + return false; + } + } + + //Check if brlyt or brlan were changed + if (BrlytChanged == true && BrlanChanged == false) + { + if (MessageBox.Show("You have changed the brlyt, but didn't change the brlan.\nAre you sure this is correct?", "brlyt Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + return false; + } + else if (BrlanChanged == true && BrlytChanged == false) + { + if (MessageBox.Show("You have changed the brlan, but didn't change the brlyt.\nAre you sure this is correct?", "brlan Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + return false; + } + + //Check for unused TPLs (Do this at the end of the failure checks, because we don't want a + // MessageBox asking if unused TPLs should be deleted and after that any error) + if (Wii.Brlyt.CheckForUnusedTpls(BannerBrlytPath[0], BannerBrlanPath[0], BannerTpls.ToArray(), out BannerUnused) == true) + { + DialogResult dlgresult = MessageBox.Show( + "The following Banner TPLs are unused by the banner.brlyt:\n\n" + + string.Join("\n", BannerUnused) + + "\n\nDo you want them to be deleted before the WAD is being created? (Saves space!)", + "Delete unused TPLs?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + if (dlgresult == DialogResult.Yes) + { + foreach (string thisTpl in BannerUnused) + { + if (string.IsNullOrEmpty(BannerReplace)) + File.Delete(TempUnpackBannerTplPath + thisTpl); + else + File.Delete(TempBannerPath + "arc\\timg\\" + thisTpl); + } + } + else if (dlgresult == DialogResult.Cancel) return false; + } + if (Wii.Brlyt.CheckForUnusedTpls(IconBrlytPath[0], IconBrlanPath[0], IconTpls.ToArray(), out IconUnused) == true) + { + DialogResult dlgresult = MessageBox.Show( + "The following Icon TPLs are unused by the icon.brlyt:\n\n" + + string.Join("\n", IconUnused) + + "\n\nDo you want them to be deleted before the WAD is being created? (Saves memory!)", + "Delete unused TPLs?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + if (dlgresult == DialogResult.Yes) + { + foreach (string thisTpl in IconUnused) + { + if (string.IsNullOrEmpty(IconReplace)) + File.Delete(TempUnpackIconTplPath + thisTpl); + else + File.Delete(TempIconPath + "arc\\timg\\" + thisTpl); + } + } + else if (dlgresult == DialogResult.Cancel) return false; + } + + currentProgress.progressState = " "; + currentProgress.progressValue = 100; + this.Invoke(ProgressUpdate); + + return true; + } + catch (Exception ex) + { + ErrorBox(ex.Message); + return false; + } + } + + private void ForwarderDialogSimple() + { + CustomizeMii_InputBox ib = new CustomizeMii_InputBox(false); + ib.Size = new Size(ib.Size.Width, 120); + ib.lbInfo.Text = "Enter the application folder where the forwarder will point to (3-18 chars)"; + ib.tbInput.MaxLength = 18; + ib.btnExit.Text = "Cancel"; + ib.cbElf.Visible = true; + + ib.tbInput.Text = SimpleForwarder.AppFolder; + ib.cbElf.Checked = SimpleForwarder.ForwardToElf; + + if (ib.ShowDialog() == DialogResult.OK) + { + SimpleForwarder.ForwardToElf = ib.cbElf.Checked; + SimpleForwarder.AppFolder = ib.Input; + SetText(tbDol, string.Format("Simple Forwarder: \"SD:\\apps\\{0}\\boot.{1}\"", + SimpleForwarder.AppFolder, SimpleForwarder.ForwardToElf == true ? "elf" : "dol")); + btnBrowseDol.Text = "Clear"; + } + } + + private void ForwarderDialogComplex() + { + CustomizeMii_ComplexForwarder cf = new CustomizeMii_ComplexForwarder(); + cf.tb1.Text = ComplexForwarder.Path1; + cf.tb2.Text = ComplexForwarder.Path2; + cf.tb3.Text = ComplexForwarder.Path3; + cf.tb4.Text = ComplexForwarder.Path4; + + if (!string.IsNullOrEmpty(ComplexForwarder.Image43)) + { + cf.cbImage43.Checked = true; + cf.tbImage43.Enabled = true; + cf.btnBrowseImage43.Enabled = true; + + cf.tbImage43.Text = ComplexForwarder.Image43; + } + if (!string.IsNullOrEmpty(ComplexForwarder.Image169)) + { + cf.cbImage169.Checked = true; + cf.tbImage169.Enabled = true; + cf.btnBrowseImage169.Enabled = true; + + cf.tbImage169.Text = ComplexForwarder.Image169; + } + + if (cf.ShowDialog() == DialogResult.OK) + { + ComplexForwarder.Path1 = cf.tb1.Text; + ComplexForwarder.Path2 = cf.tb2.Text; + ComplexForwarder.Path3 = cf.tb3.Text; + ComplexForwarder.Path4 = cf.tb4.Text; + + ComplexForwarder.Image43 = cf.tbImage43.Text; + ComplexForwarder.Image169 = cf.tbImage169.Text; + + SetText(tbDol, string.Format("Complex Forwarder")); + btnBrowseDol.Text = "Clear"; + } + } + private void FixTpls() { string[] bannerTpls = Directory.GetFiles(GetCurBannerPath() + "timg\\", "*.tpl"); @@ -49,7 +340,7 @@ namespace CustomizeMii else if ((Ctrl is TextBox) && (Ctrl.Tag != (object)"Disabled")) Ctrl.Enabled = true; else if (Ctrl is CheckBox && Ctrl.Tag != (object)"Independent") Ctrl.Enabled = true; else if (Ctrl is ComboBox) Ctrl.Enabled = true; - else if (Ctrl is LinkLabel && Ctrl.Tag != (object)"Independent") Ctrl.Enabled = true; + //else if (Ctrl is LinkLabel && Ctrl.Tag != (object)"Independent") Ctrl.Enabled = true; } } } @@ -67,7 +358,7 @@ namespace CustomizeMii else if ((Ctrl is TextBox) && (Ctrl.Tag != (object)"Disabled")) Ctrl.Enabled = false; else if (Ctrl is CheckBox && Ctrl.Tag != (object)"Independent") Ctrl.Enabled = false; else if (Ctrl is ComboBox) Ctrl.Enabled = false; - else if (Ctrl is LinkLabel && Ctrl.Tag != (object)"Independent") Ctrl.Enabled = false; + //else if (Ctrl is LinkLabel && Ctrl.Tag != (object)"Independent") Ctrl.Enabled = false; } } } @@ -384,7 +675,8 @@ namespace CustomizeMii if (lbx == lbxBannerTpls) CurPath = GetCurBannerPath(); else CurPath = GetCurIconPath(); - string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurPath + string.Format("blyt\\{0}.brlyt", lbx == lbxBannerTpls ? "banner" : "icon")); + string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurPath + string.Format("blyt\\{0}.brlyt", lbx == lbxBannerTpls ? "banner" : "icon"), + CurPath + string.Format("anim\\{0}.brlan", lbx == lbxBannerTpls ? (File.Exists(CurPath + "anim\\banner.brlan")) ? "banner" : "banner_loop" : "icon")); string TplName = Path.GetFileNameWithoutExtension(inputFile) + ".tpl"; int TplFormat = 6; diff --git a/CustomizeMii/CustomizeMii_Transmit.Designer.cs b/CustomizeMii/CustomizeMii_Transmit.Designer.cs index f399f19..2ef0dde 100644 --- a/CustomizeMii/CustomizeMii_Transmit.Designer.cs +++ b/CustomizeMii/CustomizeMii_Transmit.Designer.cs @@ -69,8 +69,8 @@ namespace CustomizeMii this.cmbProtocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbProtocol.FormattingEnabled = true; this.cmbProtocol.Items.AddRange(new object[] { - "Homebrewchannel 1.0.5+ (JODI)", - "Homebrewchannel -1.0.4 (HAXX)"}); + "Homebrew Channel 1.0.5+ (JODI)", + "Homebrew Channel -1.0.4 (HAXX)"}); this.cmbProtocol.Location = new System.Drawing.Point(67, 13); this.cmbProtocol.Name = "cmbProtocol"; this.cmbProtocol.Size = new System.Drawing.Size(194, 21); diff --git a/CustomizeMii/CustomizeMii_Transmit.cs b/CustomizeMii/CustomizeMii_Transmit.cs index 57afe0d..f019030 100644 --- a/CustomizeMii/CustomizeMii_Transmit.cs +++ b/CustomizeMii/CustomizeMii_Transmit.cs @@ -29,11 +29,12 @@ namespace CustomizeMii public CustomizeMii_Transmit() { InitializeComponent(); - this.CenterToParent(); } private void CustomizeMii_Transmit_Load(object sender, System.EventArgs e) { + this.CenterToParent(); + try { cmbProtocol.SelectedIndex = Properties.Settings.Default.Protocol; diff --git a/CustomizeMii/Instructions.txt b/CustomizeMii/Instructions.txt index 9f4ca00..308ba66 100644 --- a/CustomizeMii/Instructions.txt +++ b/CustomizeMii/Instructions.txt @@ -39,9 +39,11 @@ CHANNEL INFORMATION You may want to change the channel information, i.e. the title and ID. Let's change the channel title first. It's the text that will be displayed when you hold your cursor -over the channel. Goto the "Title" tab and fill a title for all languages. If you want to change the +over the channel. Goto the "Title" tab and enter a title for all languages. If you want to change the title for a specific language, just use the language's textbox. If you want a different title for every language, you don't need to fill in a title for all languages. +You may also use the translate "Channel" button. Enter the english name in the all languages textbox +(e.g. "MPlayer Channel"). Click translate and it will be automatically translated to each language. Now, the title ID. Open the "Options" tab and you'll see a textbox for the ID. The ID is 4 characters long and only contains letters and numerics. Lower case letters will automatically converted to upper case. Change it to a unique(!) ID, because channels will overwrite existing channles with the same ID! @@ -120,15 +122,17 @@ That's it, here's nothing left to do. -CREATING THE WAD +CREATING THE WAD (OR SENDING IT TO THE WII) Well, your channel should be ready to be created. -Goto the "Options" tab and check the Lz77 checkbox, if you want to compress your channel to safe some Wii memory. -If your channel doesn't work, first try it again without compression. -Now just click on the create WAD button (The big one with the different text each startup). +Just click on the create WAD button. CustomizeMii will do some failure checks and if all went fine, a save dialog will pop up. If you get an error or warning, read the message carefully. It should give you enough information to fix the problem yourself. +You can also send the Channel directly to the Wii. For it to work, the Channel must be less than 4 MB of space. +Make sure the Homebrew Channel is running and connected. Click the send WAD button. Choose a protocol +and enter your Wii's IP and the IOS to use for installation. Click on transmit to start the creation and +transmission process. After the channel was sent, you will be asked if you want to save the Channel. So, if you got down to here, you're done by now. Please, if you find any bugs or have suggestions, take some seconds to report them at the issue tracker: http://code.google.com/p/customizemii/issues/list \ No newline at end of file diff --git a/CustomizeMii/Properties/AssemblyInfo.cs b/CustomizeMii/Properties/AssemblyInfo.cs index 06a9bdb..4736fac 100644 --- a/CustomizeMii/Properties/AssemblyInfo.cs +++ b/CustomizeMii/Properties/AssemblyInfo.cs @@ -24,7 +24,7 @@ using System.Resources; // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // die mit einer Assembly verknüpft sind. [assembly: AssemblyTitle("CustomizeMii")] -[assembly: AssemblyDescription("CustomizeMii is a custom channel creator for the Wii")] +[assembly: AssemblyDescription("A custom channel creator for the Wii")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CustomizeMii")] diff --git a/CustomizeMii/Readme.txt b/CustomizeMii/Readme.txt index dac638b..222301c 100644 --- a/CustomizeMii/Readme.txt +++ b/CustomizeMii/Readme.txt @@ -17,7 +17,11 @@ Version 2.1 - Added drag & drop ability cause the file dialogs kept bothering me - Improvement in startup speed (thanks shadow1643) - Added creation/last edited time (only for CustomizeMii 2.1+ channels) + - Added a button to translate the word "Channel" to every language + - Improved detection of required TPLs - Little improvements and fixes + - Changed the complex forwarder to be more configurable (choose any path you want) + - ForwardMii is now bundled with CustomizeMii Version 2.01 - Base WAD downloading works again @@ -71,8 +75,8 @@ The author can't be held responsible for any damages arising from the use of it. ----------------------------------------------------------------------------------------- Thanks: -WiiCrazy / I.R.on for CustomizeMii Installer Xuzz for his idea and hard work +WiiCrazy / I.R.on for CustomizeMii Installer Xuzz, SquidMan, megazig, Matt_P, Omega and The Lemon Man for Wii.py SquidMan for Zetsubou Andre Perrot for gbalzss diff --git a/CustomizeMii/Resources/Instructions.rtf b/CustomizeMii/Resources/Instructions.rtf index 687e0e2..c1ae885 100644 --- a/CustomizeMii/Resources/Instructions.rtf +++ b/CustomizeMii/Resources/Instructions.rtf @@ -41,17 +41,15 @@ banner/icon/sound of WAD A!\par \par You may want to change the channel information, i.e. the title and ID.\par Let's change the channel title first. It's the text that will be displayed when you hold your cursor\par -over the channel. Goto the "Title" tab and fill a title for all languages. If you want to change the\par +over the channel. Goto the "Title" tab and enter a title for all languages. If you want to change the\par title for a specific language, just use the language's textbox. If you want a different title for every\par language, you don't need to fill in a title for all languages.\par +You may also use the translate "Channel" button. Enter the english name in the all languages textbox\par +(e.g. "MPlayer Channel"). Click translate and it will be automatically translated to each language.\par Now, the title ID. Open the "Options" tab and you'll see a textbox for the ID. The ID is 4 characters long\par and only contains letters and numerics. Lower case letters will automatically converted to upper case.\par Change it to a unique(!) ID, because channels will overwrite existing channles with the same ID!\par \par -I recommend not to use any title ID beginning with the following characters, because official channels\par -use these and thus your channel may overwrite them:\par -C, E, F, H, J, L, M, N, P, Q, W\par -\par \par \par \b INSERTING A NEW DOL\b0\par @@ -125,12 +123,14 @@ That's it, here's nothing left to do.\par \b CREATING THE WAD\b0\par \par Well, your channel should be ready to be created.\par -Goto the "Options" tab and check the Lz77 checkbox, if you want to compress your channel to safe some Wii memory.\par -If your channel doesn't work, first try it again without compression.\par -Now just click on the create WAD button (The big one with the different text each startup).\par +Just click on the create WAD button.\par CustomizeMii will do some failure checks and if all went fine, a save dialog will pop up.\par If you get an error or warning, read the message carefully. It should give you enough information to fix\par the problem yourself.\par +You can also send the Channel directly to the Wii. For it to work, the Channel must be less than 4 MB of space.\par +Make sure the Homebrew Channel is running and connected. Click the send WAD button. Choose a protocol\par +and enter your Wii's IP and the IOS to use for installation. Click on transmit to start the creation and\par +transmission process. After the channel was sent, you will be asked if you want to save the Channel.\par \par So, if you got down to here, you're done by now. Please, if you find any bugs or have suggestions, take some\par seconds to report them at the issue tracker: {\field{\*\fldinst{HYPERLINK "http://code.google.com/p/customizemii/issues/list"}}{\fldrslt{\ul\cf2 http://code.google.com/p/customizemii/issues/list}}}\lang7\i\f0\fs17\par diff --git a/CustomizeMii/Wii.cs b/CustomizeMii/Wii.cs index 2c8a9e8..f1d926a 100644 --- a/CustomizeMii/Wii.cs +++ b/CustomizeMii/Wii.cs @@ -5615,10 +5615,11 @@ namespace Wii /// /// /// - public static bool CheckForMissingTpls(string brlyt, string[] tpls, out string[] missingtpls) + public static bool CheckForMissingTpls(string brlyt, string brlan, string[] tpls, out string[] missingtpls) { byte[] brlytArray = Tools.LoadFileToByteArray(brlyt); - return CheckForMissingTpls(brlytArray, tpls, out missingtpls); + byte[] brlanArray = Tools.LoadFileToByteArray(brlan); + return CheckForMissingTpls(brlytArray, brlanArray, tpls, out missingtpls); } /// @@ -5629,10 +5630,10 @@ namespace Wii /// /// /// - public static bool CheckForMissingTpls(byte[] brlyt, string[] tpls, out string[] missingtpls) + public static bool CheckForMissingTpls(byte[] brlyt, byte[] brlan, string[] tpls, out string[] missingtpls) { List missings = new List(); - string[] brlytTpls = GetBrlytTpls(brlyt); + string[] brlytTpls = GetBrlytTpls(brlyt, brlan); bool missing = false; for (int i = 0; i < brlytTpls.Length; i++) @@ -5656,10 +5657,11 @@ namespace Wii /// /// /// - public static bool CheckForUnusedTpls(string brlyt, string[] tpls, out string[] unusedtpls) + public static bool CheckForUnusedTpls(string brlyt, string brlan, string[] tpls, out string[] unusedtpls) { byte[] brlytArray = Tools.LoadFileToByteArray(brlyt); - return CheckForUnusedTpls(brlytArray, tpls, out unusedtpls); + byte[] brlanArray = Tools.LoadFileToByteArray(brlan); + return CheckForUnusedTpls(brlytArray, brlanArray, tpls, out unusedtpls); } /// @@ -5670,10 +5672,10 @@ namespace Wii /// /// /// - public static bool CheckForUnusedTpls(byte[] brlyt, string[] tpls, out string[] unusedtpls) + public static bool CheckForUnusedTpls(byte[] brlyt, byte[] brlan, string[] tpls, out string[] unusedtpls) { List unuseds = new List(); - string[] brlytTpls = GetBrlytTpls(brlyt); + string[] brlytTpls = GetBrlytTpls(brlyt, brlan); bool missing = false; for (int i = 0; i < tpls.Length; i++) @@ -5705,10 +5707,11 @@ namespace Wii /// /// /// - public static string[] GetBrlytTpls(string brlyt) + public static string[] GetBrlytTpls(string brlyt, string brlan) { byte[] temp = Tools.LoadFileToByteArray(brlyt); - return GetBrlytTpls(temp); + byte[] temp2 = Tools.LoadFileToByteArray(brlan); + return GetBrlytTpls(temp, temp2); } /// @@ -5716,7 +5719,7 @@ namespace Wii /// /// /// - public static string[] GetBrlytTpls(byte[] brlyt) + public static string[] GetBrlytTpls(byte[] brlyt, byte[] brlan) { int texcount = Tools.HexStringToInt(brlyt[44].ToString("x2") + brlyt[45].ToString("x2")); int texnamepos = 48 + (texcount * 8); @@ -5734,9 +5737,71 @@ namespace Wii texnamepos++; } + //Lets also get brlan tpls (frame animations) + string[] brlanTpls = GetBrlanTpls(brlan); + foreach (string thisTpl in brlanTpls) + { + if (thisTpl.EndsWith(".tpl")) + { + if (!Tpls.Contains(thisTpl)) + Tpls.Add(thisTpl); + } + } + return Tpls.ToArray(); } + /// + /// Returns the name of all Tpls specified in the brlan + /// + /// + /// + public static string[] GetBrlanTpls(string brlan) + { + byte[] temp = Tools.LoadFileToByteArray(brlan); + return GetBrlanTpls(temp); + } + + /// + /// Returns the name of all Tpls specified in the brlan + /// + /// + /// + public static string[] GetBrlanTpls(byte[] brlan) + { + List tpls = new List(); + int texcount = Tools.HexStringToInt(brlan[28].ToString("x2") + brlan[29].ToString("x2")); + int pailen; + if (brlan[32] == 0x00 && brlan[33] == 0x00 && brlan[34] == 0x00 && brlan[35] == 0x00) + pailen = Tools.HexStringToInt(brlan[36].ToString("x2") + brlan[37].ToString("x2") + brlan[38].ToString("x2") + brlan[39].ToString("x2")); + else + pailen = Tools.HexStringToInt(brlan[32].ToString("x2") + brlan[33].ToString("x2") + brlan[34].ToString("x2") + brlan[35].ToString("x2")); + + int texnameendpos = 16 + pailen; + + for (int i = texnameendpos; i > 0; i--) + { + if (brlan[i] != 0x00) + { texnameendpos = i + 1; break; } + } + + for (int i = 0; i < texcount; i++) + { + List thisTex = new List(); + while (brlan[texnameendpos] != 0x00) + { + thisTex.Add((char)brlan[texnameendpos--]); + } + + thisTex.Reverse(); + tpls.Add(new string(thisTex.ToArray())); + texnameendpos--; + } + + tpls.Reverse(); + return tpls.ToArray(); + } + /// /// Returns true, if the given Tpl is specified in the brlyt. /// TplName must end with ".tpl"! @@ -5744,9 +5809,9 @@ namespace Wii /// /// /// - public static bool IsTplInBrlyt(byte[] brlyt, string TplName) + public static bool IsTplInBrlyt(byte[] brlyt, byte[] brlan, string TplName) { - string[] brlytTpls = GetBrlytTpls(brlyt); + string[] brlytTpls = GetBrlytTpls(brlyt, brlan); bool exists = Array.Exists(brlytTpls, Tpl => Tpl == TplName); return exists; } diff --git a/CustomizeMiiInstaller/InstallerHelper.cs b/CustomizeMiiInstaller/InstallerHelper.cs index a6fbdea..a370862 100644 --- a/CustomizeMiiInstaller/InstallerHelper.cs +++ b/CustomizeMiiInstaller/InstallerHelper.cs @@ -22,6 +22,16 @@ using System.Security.Cryptography; namespace CustomizeMiiInstaller { + public class CustomizeMiiInstaller_Plugin + { + const string version = "1.0"; + + public static string GetVersion() + { + return version; + } + } + public class InstallerHelper { public static MemoryStream CreateInstaller(string wadFile, byte iosToUse) diff --git a/ForwardMii/ForwardMii.cs b/ForwardMii/ForwardMii.cs index b337dce..7e34de6 100644 --- a/ForwardMii/ForwardMii.cs +++ b/ForwardMii/ForwardMii.cs @@ -21,7 +21,7 @@ namespace ForwardMii { public class ForwardMii_Plugin { - const string version = "1.02"; //Hint for myself: Never use a char in the Version (UpdateCheck)! + const string version = "1.1"; //Hint for myself: Never use a char in the Version (UpdateCheck)! public static string GetVersion() { diff --git a/ForwardMii/ForwardMii_GX.cs b/ForwardMii/ForwardMii_GX.cs index 2094e36..12d2fb9 100644 --- a/ForwardMii/ForwardMii_GX.cs +++ b/ForwardMii/ForwardMii_GX.cs @@ -29,14 +29,16 @@ namespace ForwardMii public class GXForwarder { private readonly string TempDir = Path.GetTempPath() + "ForwardMii_Temp\\" + Guid.NewGuid() + "\\"; - private string thisAppFolder; - private bool elfFirst = false; - private bool usbFirst = false; + private string path1; + private string path2; + private string path3; + private string path4; private string image43; private string image169; - public string AppFolder { get { return thisAppFolder; } set { thisAppFolder = value; } } - public bool ElfFirst { get { return elfFirst; } set { elfFirst = value; } } - public bool UsbFirst { get { return usbFirst; } set { usbFirst = value; } } + public string Path1 { get { return path1; } set { path1 = value; } } + public string Path2 { get { return path2; } set { path2 = value; } } + public string Path3 { get { return path3; } set { path3 = value; } } + public string Path4 { get { return path4; } set { path4 = value; } } public string Image43 { get { return image43; } set { image43 = value; } } public string Image169 { get { return image169; } set { image169 = value; } } @@ -45,50 +47,32 @@ namespace ForwardMii } - public GXForwarder(string AppFolder) + public GXForwarder(params string[] paths) { if (ForwardMii_Plugin.CheckDevKit() == false) throw new Exception("DevkitPro or one of it's components wasn't found!"); - thisAppFolder = AppFolder; + path1 = paths[0]; + path2 = paths[1]; + path3 = paths[2]; + path4 = paths[3]; } - public GXForwarder(string AppFolder, bool UsbFirst) + public GXForwarder(string Image43, string Image169, params string[] paths) { if (ForwardMii_Plugin.CheckDevKit() == false) throw new Exception("DevkitPro or one of it's components wasn't found!"); - thisAppFolder = AppFolder; - usbFirst = UsbFirst; - } - - public GXForwarder(string AppFolder, string Image43, string Image169) - { - if (ForwardMii_Plugin.CheckDevKit() == false) throw new Exception("DevkitPro or one of it's components wasn't found!"); - thisAppFolder = AppFolder; + path1 = paths[0]; + path2 = paths[1]; + path3 = paths[2]; + path4 = paths[3]; image43 = Image43; image169 = Image169; } - public GXForwarder(string AppFolder, bool UsbFirst, bool ElfFirst) - { - if (ForwardMii_Plugin.CheckDevKit() == false) throw new Exception("DevkitPro or one of it's components wasn't found!"); - thisAppFolder = AppFolder; - usbFirst = UsbFirst; - elfFirst = ElfFirst; - } - - public GXForwarder(string AppFolder, bool UsbFirst, bool ElfFirst, string Image43, string Image169) - { - if (ForwardMii_Plugin.CheckDevKit() == false) throw new Exception("DevkitPro or one of it's components wasn't found!"); - thisAppFolder = AppFolder; - image43 = Image43; - image169 = Image169; - usbFirst = UsbFirst; - elfFirst = ElfFirst; - } - public void Clear() { - thisAppFolder = string.Empty; - elfFirst = false; - usbFirst = false; + path1 = string.Empty; + path2 = string.Empty; + path3 = string.Empty; + path4 = string.Empty; image43 = string.Empty; image169 = string.Empty; } @@ -254,12 +238,14 @@ namespace ForwardMii for (int i = 0; i < lines.Length; i++) { - if (lines[i].Contains("appfolder")) - lines[i] = lines[i].Replace("appfolder", thisAppFolder); - else if (lines[i].Contains("#define USB_FIRST")) - lines[i] = lines[i].Replace("false", usbFirst.ToString().ToLower()); - else if (lines[i].Contains("#define ELF_FIRST")) - lines[i] = lines[i].Replace("false", elfFirst.ToString().ToLower()); + if (lines[i].Contains("---path1---")) + lines[i] = lines[i].Replace("---path1---", path1); + else if (lines[i].Contains("---path2---")) + lines[i] = lines[i].Replace("---path2---", path2); + else if (lines[i].Contains("---path3---")) + lines[i] = lines[i].Replace("---path3---", path3); + else if (lines[i].Contains("---path4---")) + lines[i] = lines[i].Replace("---path4---", path4); } using (FileStream fs = new FileStream(TempDir + "source\\main.cpp", FileMode.Create)) diff --git a/ForwardMii/Resources/GX/main.cpp b/ForwardMii/Resources/GX/main.cpp index c1d79b3..135709f 100644 --- a/ForwardMii/Resources/GX/main.cpp +++ b/ForwardMii/Resources/GX/main.cpp @@ -43,10 +43,10 @@ #define USB_FIRST false #define ELF_FIRST false -#define SD_DOL "SD:/apps/appfolder/boot.dol" -#define SD_ELF "SD:/apps/appfolder/boot.elf" -#define USB_DOL "USB:/apps/appfolder/boot.dol" -#define USB_ELF "USB:/apps/appfolder/boot.elf" +#define SD_DOL "---path1---" +#define SD_ELF "---path2---" +#define USB_DOL "---path3---" +#define USB_ELF "---path4---" static PNGUPROP imgProp; static IMGCTX ctx;