diff --git a/CustomizeMii/CustomizeMii.csproj b/CustomizeMii/CustomizeMii.csproj
deleted file mode 100644
index f7ee603..0000000
--- a/CustomizeMii/CustomizeMii.csproj
+++ /dev/null
@@ -1,154 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 9.0.30729
- 2.0
- {46B7F0BC-101B-4167-95AD-4C5D78AA0A20}
- WinExe
- Properties
- CustomizeMii
- CustomizeMii
- v2.0
- 512
-
-
- Resources\CustomizeMii.ico
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.1.0.%2a
- false
- false
- true
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
- Form
-
-
- CustomizeMii_Main.cs
-
-
- Form
-
-
- CustomizeMii_Preview.cs
-
-
- Form
-
-
- CustomizeMii_InputBox.cs
-
-
-
-
- CustomizeMii_InputBox.cs
-
-
- CustomizeMii_Main.cs
-
-
- CustomizeMii_Preview.cs
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
- True
- Resources.resx
- True
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
-
-
- True
- Settings.settings
- True
-
-
-
-
-
-
-
-
-
-
-
-
- False
- .NET Framework Client Profile
- false
-
-
- False
- .NET Framework 2.0 %28x86%29
- true
-
-
- False
- .NET Framework 3.0 %28x86%29
- false
-
-
- False
- .NET Framework 3.5
- false
-
-
- False
- .NET Framework 3.5 SP1
- false
-
-
-
-
-
\ No newline at end of file
diff --git a/CustomizeMii/CustomizeMii.csproj.user b/CustomizeMii/CustomizeMii.csproj.user
deleted file mode 100644
index 3258829..0000000
--- a/CustomizeMii/CustomizeMii.csproj.user
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- publish\
-
-
-
-
-
-
-
-
-
-
- de-DE
- false
-
-
\ No newline at end of file
diff --git a/CustomizeMii/CustomizeMii_InputBox.Designer.cs b/CustomizeMii/CustomizeMii_InputBox.Designer.cs
deleted file mode 100644
index 6711986..0000000
--- a/CustomizeMii/CustomizeMii_InputBox.Designer.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-/* 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
-{
- partial class CustomizeMii_InputBox
- {
- ///
- /// Erforderliche Designervariable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Verwendete Ressourcen bereinigen.
- ///
- /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Vom Windows Form-Designer generierter Code
-
- ///
- /// Erforderliche Methode für die Designerunterstützung.
- /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
- ///
- private void InitializeComponent()
- {
- this.tbInput = new System.Windows.Forms.TextBox();
- this.lbInfo = new System.Windows.Forms.Label();
- this.btnOK = new System.Windows.Forms.Button();
- this.btnExit = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // tbInput
- //
- this.tbInput.Location = new System.Drawing.Point(7, 34);
- this.tbInput.MaxLength = 3;
- this.tbInput.Name = "tbInput";
- this.tbInput.Size = new System.Drawing.Size(222, 20);
- this.tbInput.TabIndex = 0;
- //
- // lbInfo
- //
- this.lbInfo.AutoSize = true;
- this.lbInfo.Location = new System.Drawing.Point(4, 9);
- this.lbInfo.Name = "lbInfo";
- this.lbInfo.Size = new System.Drawing.Size(225, 13);
- this.lbInfo.TabIndex = 1;
- this.lbInfo.Text = "Please enter \"45e\" to create the Common-Key";
- //
- // btnOK
- //
- this.btnOK.Location = new System.Drawing.Point(7, 62);
- this.btnOK.Name = "btnOK";
- this.btnOK.Size = new System.Drawing.Size(108, 23);
- this.btnOK.TabIndex = 2;
- this.btnOK.Text = "OK";
- this.btnOK.UseVisualStyleBackColor = true;
- this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
- //
- // btnExit
- //
- this.btnExit.Location = new System.Drawing.Point(121, 62);
- this.btnExit.Name = "btnExit";
- this.btnExit.Size = new System.Drawing.Size(108, 23);
- this.btnExit.TabIndex = 3;
- this.btnExit.Text = "Exit";
- this.btnExit.UseVisualStyleBackColor = true;
- this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
- //
- // CustomizeMii_InputBox
- //
- this.AcceptButton = this.btnOK;
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.CancelButton = this.btnExit;
- this.ClientSize = new System.Drawing.Size(238, 92);
- this.Controls.Add(this.btnExit);
- this.Controls.Add(this.btnOK);
- this.Controls.Add(this.lbInfo);
- this.Controls.Add(this.tbInput);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- this.Name = "CustomizeMii_InputBox";
- this.ShowInTaskbar = false;
- this.Text = "InputBox";
- this.Load += new System.EventHandler(this.CustomizeMii_InputBox_Load);
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.TextBox tbInput;
- private System.Windows.Forms.Label lbInfo;
- private System.Windows.Forms.Button btnOK;
- private System.Windows.Forms.Button btnExit;
- }
-}
\ No newline at end of file
diff --git a/CustomizeMii/CustomizeMii_InputBox.cs b/CustomizeMii/CustomizeMii_InputBox.cs
deleted file mode 100644
index 337ba6a..0000000
--- a/CustomizeMii/CustomizeMii_InputBox.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-/* 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 .
- */
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Text;
-using System.Windows.Forms;
-
-namespace CustomizeMii
-{
- public partial class CustomizeMii_InputBox : Form
- {
- public string Input
- {
- get { return tbInput.Text; }
- }
-
- public CustomizeMii_InputBox()
- {
- InitializeComponent();
- }
-
- private void CustomizeMii_InputBox_Load(object sender, EventArgs e)
- {
- this.CenterToScreen();
- }
-
- private void btnExit_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
-
- private void btnOK_Click(object sender, EventArgs e)
- {
- if (tbInput.Text == "45e")
- {
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- tbInput.Focus();
- tbInput.SelectAll();
- }
- }
- }
-}
diff --git a/CustomizeMii/CustomizeMii_Main.Designer.cs b/CustomizeMii/CustomizeMii_Main.Designer.cs
deleted file mode 100644
index d37be45..0000000
--- a/CustomizeMii/CustomizeMii_Main.Designer.cs
+++ /dev/null
@@ -1,1366 +0,0 @@
-/* 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
-{
- partial class CustomizeMii_Main
- {
- ///
- /// Erforderliche Designervariable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Verwendete Ressourcen bereinigen.
- ///
- /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Vom Windows Form-Designer generierter Code
-
- ///
- /// Erforderliche Methode für die Designerunterstützung.
- /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
- ///
- private void InitializeComponent()
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomizeMii_Main));
- this.btnCreateWad = new System.Windows.Forms.Button();
- this.tabControl = new System.Windows.Forms.TabControl();
- this.tabSource = new System.Windows.Forms.TabPage();
- this.tbReplace = new System.Windows.Forms.TextBox();
- this.btnBrowseReplace = new System.Windows.Forms.Button();
- this.btnClearReplace = new System.Windows.Forms.Button();
- this.cmbReplace = new System.Windows.Forms.ComboBox();
- this.btnSaveBaseWad = new System.Windows.Forms.Button();
- this.btnPreviewBaseWad = new System.Windows.Forms.Button();
- this.btnLoadBaseWad = new System.Windows.Forms.Button();
- this.lbxBaseWads = new System.Windows.Forms.ListBox();
- this.btnBrowseSource = new System.Windows.Forms.Button();
- this.tbSourceWad = new System.Windows.Forms.TextBox();
- this.lbSource = new System.Windows.Forms.Label();
- this.tabTitle = new System.Windows.Forms.TabPage();
- this.tbItalian = new System.Windows.Forms.TextBox();
- this.tbFrench = new System.Windows.Forms.TextBox();
- this.tbJapanese = new System.Windows.Forms.TextBox();
- this.tbDutch = new System.Windows.Forms.TextBox();
- this.tbSpanish = new System.Windows.Forms.TextBox();
- this.tbGerman = new System.Windows.Forms.TextBox();
- this.tbEnglish = new System.Windows.Forms.TextBox();
- this.lbDutch = new System.Windows.Forms.Label();
- this.lbItalian = new System.Windows.Forms.Label();
- this.lbSpanish = new System.Windows.Forms.Label();
- this.lbFrench = new System.Windows.Forms.Label();
- this.lbGerman = new System.Windows.Forms.Label();
- this.lbJapanese = new System.Windows.Forms.Label();
- this.lbEnglish = new System.Windows.Forms.Label();
- this.lbSpecificLanguageTitles = new System.Windows.Forms.Label();
- this.tbAllLanguages = new System.Windows.Forms.TextBox();
- this.lbAllLanguages = new System.Windows.Forms.Label();
- this.tabOptions = new System.Windows.Forms.TabPage();
- this.cbLz77 = new System.Windows.Forms.CheckBox();
- this.lbOptionsOptional = new System.Windows.Forms.Label();
- this.btnBrowseSound = new System.Windows.Forms.Button();
- this.tbSound = new System.Windows.Forms.TextBox();
- this.cmbNandLoader = new System.Windows.Forms.ComboBox();
- this.btnBrowseDol = new System.Windows.Forms.Button();
- this.tbDol = new System.Windows.Forms.TextBox();
- this.tbTitleID = new System.Windows.Forms.TextBox();
- this.lbNewSound = new System.Windows.Forms.Label();
- this.lbNandLoader = new System.Windows.Forms.Label();
- this.lbNewDol = new System.Windows.Forms.Label();
- this.lbTitleID = new System.Windows.Forms.Label();
- this.tabBanner = new System.Windows.Forms.TabPage();
- this.cbBannerMakeTransparent = new System.Windows.Forms.CheckBox();
- this.cmbFormatBanner = new System.Windows.Forms.ComboBox();
- this.lbFormatBanner = new System.Windows.Forms.Label();
- this.btnPreviewBanner = new System.Windows.Forms.Button();
- this.btnExtractBanner = new System.Windows.Forms.Button();
- this.btnDeleteBanner = new System.Windows.Forms.Button();
- this.btnAddBanner = new System.Windows.Forms.Button();
- this.btnReplaceBanner = new System.Windows.Forms.Button();
- this.lbxBannerTpls = new System.Windows.Forms.ListBox();
- this.tabIcon = new System.Windows.Forms.TabPage();
- this.cbIconMakeTransparent = new System.Windows.Forms.CheckBox();
- this.cmbFormatIcon = new System.Windows.Forms.ComboBox();
- this.lbFormatIcon = new System.Windows.Forms.Label();
- this.btnPreviewIcon = new System.Windows.Forms.Button();
- this.btnExtractIcon = new System.Windows.Forms.Button();
- this.btnAddIcon = new System.Windows.Forms.Button();
- this.btnDeleteIcon = new System.Windows.Forms.Button();
- this.btnReplaceIcon = new System.Windows.Forms.Button();
- this.lbxIconTpls = new System.Windows.Forms.ListBox();
- this.tabBrlyt = new System.Windows.Forms.TabPage();
- this.btnBrlytListTpls = new System.Windows.Forms.Button();
- this.lbBrlytWarning = new System.Windows.Forms.Label();
- this.lbBrlytActions = new System.Windows.Forms.Label();
- this.btnBrlytExtract = new System.Windows.Forms.Button();
- this.btnBrlytReplace = new System.Windows.Forms.Button();
- this.lbBrlytIcon = new System.Windows.Forms.Label();
- this.lbBrlytBanner = new System.Windows.Forms.Label();
- this.lbxBrlytIcon = new System.Windows.Forms.ListBox();
- this.lbxBrlytBanner = new System.Windows.Forms.ListBox();
- this.tabBrlan = new System.Windows.Forms.TabPage();
- this.lbBrlanWarning = new System.Windows.Forms.Label();
- this.lbBrlanActions = new System.Windows.Forms.Label();
- this.btnBrlanExtract = new System.Windows.Forms.Button();
- this.btnBrlanDelete = new System.Windows.Forms.Button();
- this.btnBrlanReplace = new System.Windows.Forms.Button();
- this.lbBrlanIcon = new System.Windows.Forms.Label();
- this.lbBrlanBanner = new System.Windows.Forms.Label();
- this.btnBrlanAdd = new System.Windows.Forms.Button();
- this.lbxBrlanIcon = new System.Windows.Forms.ListBox();
- this.lbxBrlanBanner = new System.Windows.Forms.ListBox();
- this.tabInstructions = new System.Windows.Forms.TabPage();
- this.rtbInstructions = new System.Windows.Forms.RichTextBox();
- this.tabCredits = new System.Windows.Forms.TabPage();
- this.llbUpdateAvailabe = new System.Windows.Forms.LinkLabel();
- this.llbSite = new System.Windows.Forms.LinkLabel();
- this.lbCreditThanks = new System.Windows.Forms.Label();
- this.lbCreditVersion = new System.Windows.Forms.Label();
- this.lbCreditInfo = new System.Windows.Forms.Label();
- this.ssMain = new System.Windows.Forms.StatusStrip();
- this.lbStatus = new System.Windows.Forms.ToolStripStatusLabel();
- this.lbStatusText = new System.Windows.Forms.ToolStripStatusLabel();
- this.pbProgress = new System.Windows.Forms.ToolStripProgressBar();
- this.tabControl.SuspendLayout();
- this.tabSource.SuspendLayout();
- this.tabTitle.SuspendLayout();
- this.tabOptions.SuspendLayout();
- this.tabBanner.SuspendLayout();
- this.tabIcon.SuspendLayout();
- this.tabBrlyt.SuspendLayout();
- this.tabBrlan.SuspendLayout();
- this.tabInstructions.SuspendLayout();
- this.tabCredits.SuspendLayout();
- this.ssMain.SuspendLayout();
- this.SuspendLayout();
- //
- // btnCreateWad
- //
- this.btnCreateWad.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.btnCreateWad.Location = new System.Drawing.Point(0, 235);
- this.btnCreateWad.Name = "btnCreateWad";
- this.btnCreateWad.Size = new System.Drawing.Size(451, 33);
- this.btnCreateWad.TabIndex = 0;
- this.btnCreateWad.Text = "Create WAD";
- this.btnCreateWad.UseVisualStyleBackColor = true;
- this.btnCreateWad.Click += new System.EventHandler(this.btnCreateWad_Click);
- //
- // tabControl
- //
- this.tabControl.Controls.Add(this.tabSource);
- this.tabControl.Controls.Add(this.tabTitle);
- this.tabControl.Controls.Add(this.tabOptions);
- this.tabControl.Controls.Add(this.tabBanner);
- this.tabControl.Controls.Add(this.tabIcon);
- this.tabControl.Controls.Add(this.tabBrlyt);
- this.tabControl.Controls.Add(this.tabBrlan);
- this.tabControl.Controls.Add(this.tabInstructions);
- this.tabControl.Controls.Add(this.tabCredits);
- this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
- this.tabControl.Location = new System.Drawing.Point(0, 0);
- this.tabControl.Name = "tabControl";
- this.tabControl.SelectedIndex = 0;
- this.tabControl.Size = new System.Drawing.Size(451, 235);
- this.tabControl.TabIndex = 1;
- this.tabControl.Selecting += new System.Windows.Forms.TabControlCancelEventHandler(this.tabControl_Selecting);
- //
- // tabSource
- //
- this.tabSource.Controls.Add(this.tbReplace);
- this.tabSource.Controls.Add(this.btnBrowseReplace);
- this.tabSource.Controls.Add(this.btnClearReplace);
- this.tabSource.Controls.Add(this.cmbReplace);
- this.tabSource.Controls.Add(this.btnSaveBaseWad);
- this.tabSource.Controls.Add(this.btnPreviewBaseWad);
- this.tabSource.Controls.Add(this.btnLoadBaseWad);
- this.tabSource.Controls.Add(this.lbxBaseWads);
- this.tabSource.Controls.Add(this.btnBrowseSource);
- this.tabSource.Controls.Add(this.tbSourceWad);
- this.tabSource.Controls.Add(this.lbSource);
- this.tabSource.Location = new System.Drawing.Point(4, 22);
- this.tabSource.Name = "tabSource";
- this.tabSource.Padding = new System.Windows.Forms.Padding(3);
- this.tabSource.Size = new System.Drawing.Size(443, 209);
- this.tabSource.TabIndex = 0;
- this.tabSource.Text = "Source";
- this.tabSource.UseVisualStyleBackColor = true;
- //
- // tbReplace
- //
- this.tbReplace.Location = new System.Drawing.Point(100, 173);
- this.tbReplace.Name = "tbReplace";
- this.tbReplace.ReadOnly = true;
- this.tbReplace.Size = new System.Drawing.Size(173, 20);
- this.tbReplace.TabIndex = 10;
- this.tbReplace.Tag = "Disabled";
- //
- // btnBrowseReplace
- //
- this.btnBrowseReplace.Location = new System.Drawing.Point(279, 172);
- this.btnBrowseReplace.Name = "btnBrowseReplace";
- this.btnBrowseReplace.Size = new System.Drawing.Size(75, 23);
- this.btnBrowseReplace.TabIndex = 9;
- this.btnBrowseReplace.Text = "Browse...";
- this.btnBrowseReplace.UseVisualStyleBackColor = true;
- this.btnBrowseReplace.Click += new System.EventHandler(this.btnBrowseReplace_Click);
- //
- // btnClearReplace
- //
- this.btnClearReplace.Location = new System.Drawing.Point(360, 172);
- this.btnClearReplace.Name = "btnClearReplace";
- this.btnClearReplace.Size = new System.Drawing.Size(75, 23);
- this.btnClearReplace.TabIndex = 8;
- this.btnClearReplace.Text = "Clear";
- this.btnClearReplace.UseVisualStyleBackColor = true;
- this.btnClearReplace.Click += new System.EventHandler(this.btnClearReplace_Click);
- //
- // cmbReplace
- //
- this.cmbReplace.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.cmbReplace.FormattingEnabled = true;
- this.cmbReplace.Items.AddRange(new object[] {
- "Banner",
- "Icon",
- "Sound"});
- this.cmbReplace.Location = new System.Drawing.Point(11, 172);
- this.cmbReplace.Name = "cmbReplace";
- this.cmbReplace.Size = new System.Drawing.Size(83, 21);
- this.cmbReplace.TabIndex = 7;
- this.cmbReplace.SelectedIndexChanged += new System.EventHandler(this.cmbReplace_SelectedIndexChanged);
- //
- // btnSaveBaseWad
- //
- this.btnSaveBaseWad.Location = new System.Drawing.Point(360, 127);
- this.btnSaveBaseWad.Name = "btnSaveBaseWad";
- this.btnSaveBaseWad.Size = new System.Drawing.Size(75, 23);
- this.btnSaveBaseWad.TabIndex = 6;
- this.btnSaveBaseWad.Text = "Save";
- this.btnSaveBaseWad.UseVisualStyleBackColor = true;
- this.btnSaveBaseWad.Click += new System.EventHandler(this.btnSaveBaseWad_Click);
- //
- // btnPreviewBaseWad
- //
- this.btnPreviewBaseWad.Location = new System.Drawing.Point(360, 93);
- this.btnPreviewBaseWad.Name = "btnPreviewBaseWad";
- this.btnPreviewBaseWad.Size = new System.Drawing.Size(75, 23);
- this.btnPreviewBaseWad.TabIndex = 5;
- this.btnPreviewBaseWad.Text = "Preview";
- this.btnPreviewBaseWad.UseVisualStyleBackColor = true;
- this.btnPreviewBaseWad.Click += new System.EventHandler(this.btnPreviewBaseWad_Click);
- //
- // btnLoadBaseWad
- //
- this.btnLoadBaseWad.Location = new System.Drawing.Point(360, 59);
- this.btnLoadBaseWad.Name = "btnLoadBaseWad";
- this.btnLoadBaseWad.Size = new System.Drawing.Size(75, 23);
- this.btnLoadBaseWad.TabIndex = 4;
- this.btnLoadBaseWad.Text = "Load";
- this.btnLoadBaseWad.UseVisualStyleBackColor = true;
- this.btnLoadBaseWad.Click += new System.EventHandler(this.btnLoadBaseWad_Click);
- //
- // lbxBaseWads
- //
- this.lbxBaseWads.FormattingEnabled = true;
- this.lbxBaseWads.Items.AddRange(new object[] {
- "Static Base",
- "Genesis Plus GX",
- "MPlayer CE (No Wii)",
- "MPlayer CE (With Wii)",
- "Snes9xGX",
- "FCE Ultra (Wilsoff)",
- "FCE Ultra (Leathl)",
- "Wii64",
- "WiiSX Full",
- "WiiSX Retro",
- "WADder Base 1",
- "WADder Base 2",
- "WADder Base 3",
- "UniiLoader",
- "Backup Channel"});
- this.lbxBaseWads.Location = new System.Drawing.Point(11, 51);
- this.lbxBaseWads.Name = "lbxBaseWads";
- this.lbxBaseWads.Size = new System.Drawing.Size(343, 108);
- this.lbxBaseWads.TabIndex = 3;
- //
- // btnBrowseSource
- //
- this.btnBrowseSource.Location = new System.Drawing.Point(360, 12);
- this.btnBrowseSource.Name = "btnBrowseSource";
- this.btnBrowseSource.Size = new System.Drawing.Size(75, 23);
- this.btnBrowseSource.TabIndex = 2;
- this.btnBrowseSource.Text = "Browse...";
- this.btnBrowseSource.UseVisualStyleBackColor = true;
- this.btnBrowseSource.Click += new System.EventHandler(this.btnBrowseSource_Click);
- //
- // tbSourceWad
- //
- this.tbSourceWad.Location = new System.Drawing.Point(84, 15);
- this.tbSourceWad.Name = "tbSourceWad";
- this.tbSourceWad.ReadOnly = true;
- this.tbSourceWad.Size = new System.Drawing.Size(270, 20);
- this.tbSourceWad.TabIndex = 1;
- this.tbSourceWad.Tag = "Disabled";
- //
- // lbSource
- //
- this.lbSource.AutoSize = true;
- this.lbSource.Location = new System.Drawing.Point(8, 18);
- this.lbSource.Name = "lbSource";
- this.lbSource.Size = new System.Drawing.Size(70, 13);
- this.lbSource.TabIndex = 0;
- this.lbSource.Text = "Source Wad:";
- //
- // tabTitle
- //
- this.tabTitle.Controls.Add(this.tbItalian);
- this.tabTitle.Controls.Add(this.tbFrench);
- this.tabTitle.Controls.Add(this.tbJapanese);
- this.tabTitle.Controls.Add(this.tbDutch);
- this.tabTitle.Controls.Add(this.tbSpanish);
- this.tabTitle.Controls.Add(this.tbGerman);
- this.tabTitle.Controls.Add(this.tbEnglish);
- this.tabTitle.Controls.Add(this.lbDutch);
- this.tabTitle.Controls.Add(this.lbItalian);
- this.tabTitle.Controls.Add(this.lbSpanish);
- this.tabTitle.Controls.Add(this.lbFrench);
- this.tabTitle.Controls.Add(this.lbGerman);
- this.tabTitle.Controls.Add(this.lbJapanese);
- this.tabTitle.Controls.Add(this.lbEnglish);
- this.tabTitle.Controls.Add(this.lbSpecificLanguageTitles);
- this.tabTitle.Controls.Add(this.tbAllLanguages);
- this.tabTitle.Controls.Add(this.lbAllLanguages);
- this.tabTitle.Location = new System.Drawing.Point(4, 22);
- this.tabTitle.Name = "tabTitle";
- this.tabTitle.Padding = new System.Windows.Forms.Padding(3);
- this.tabTitle.Size = new System.Drawing.Size(443, 209);
- this.tabTitle.TabIndex = 1;
- this.tabTitle.Text = "Title";
- this.tabTitle.UseVisualStyleBackColor = true;
- //
- // tbItalian
- //
- this.tbItalian.Location = new System.Drawing.Point(301, 143);
- this.tbItalian.MaxLength = 20;
- this.tbItalian.Name = "tbItalian";
- this.tbItalian.Size = new System.Drawing.Size(124, 20);
- this.tbItalian.TabIndex = 16;
- //
- // tbFrench
- //
- this.tbFrench.Location = new System.Drawing.Point(301, 115);
- this.tbFrench.MaxLength = 20;
- this.tbFrench.Name = "tbFrench";
- this.tbFrench.Size = new System.Drawing.Size(124, 20);
- this.tbFrench.TabIndex = 15;
- //
- // tbJapanese
- //
- this.tbJapanese.Location = new System.Drawing.Point(301, 87);
- this.tbJapanese.MaxLength = 20;
- this.tbJapanese.Name = "tbJapanese";
- this.tbJapanese.Size = new System.Drawing.Size(124, 20);
- this.tbJapanese.TabIndex = 14;
- //
- // tbDutch
- //
- this.tbDutch.Location = new System.Drawing.Point(70, 171);
- this.tbDutch.MaxLength = 20;
- this.tbDutch.Name = "tbDutch";
- this.tbDutch.Size = new System.Drawing.Size(124, 20);
- this.tbDutch.TabIndex = 13;
- //
- // tbSpanish
- //
- this.tbSpanish.Location = new System.Drawing.Point(70, 143);
- this.tbSpanish.MaxLength = 20;
- this.tbSpanish.Name = "tbSpanish";
- this.tbSpanish.Size = new System.Drawing.Size(124, 20);
- this.tbSpanish.TabIndex = 12;
- //
- // tbGerman
- //
- this.tbGerman.Location = new System.Drawing.Point(70, 115);
- this.tbGerman.MaxLength = 20;
- this.tbGerman.Name = "tbGerman";
- this.tbGerman.Size = new System.Drawing.Size(124, 20);
- this.tbGerman.TabIndex = 11;
- //
- // tbEnglish
- //
- this.tbEnglish.Location = new System.Drawing.Point(70, 87);
- this.tbEnglish.MaxLength = 20;
- this.tbEnglish.Name = "tbEnglish";
- this.tbEnglish.Size = new System.Drawing.Size(124, 20);
- this.tbEnglish.TabIndex = 10;
- //
- // lbDutch
- //
- this.lbDutch.AutoSize = true;
- this.lbDutch.Location = new System.Drawing.Point(8, 174);
- this.lbDutch.Name = "lbDutch";
- this.lbDutch.Size = new System.Drawing.Size(39, 13);
- this.lbDutch.TabIndex = 9;
- this.lbDutch.Text = "Dutch:";
- //
- // lbItalian
- //
- this.lbItalian.AutoSize = true;
- this.lbItalian.Location = new System.Drawing.Point(221, 146);
- this.lbItalian.Name = "lbItalian";
- this.lbItalian.Size = new System.Drawing.Size(38, 13);
- this.lbItalian.TabIndex = 8;
- this.lbItalian.Text = "Italian:";
- //
- // lbSpanish
- //
- this.lbSpanish.AutoSize = true;
- this.lbSpanish.Location = new System.Drawing.Point(8, 146);
- this.lbSpanish.Name = "lbSpanish";
- this.lbSpanish.Size = new System.Drawing.Size(48, 13);
- this.lbSpanish.TabIndex = 7;
- this.lbSpanish.Text = "Spanish:";
- //
- // lbFrench
- //
- this.lbFrench.AutoSize = true;
- this.lbFrench.Location = new System.Drawing.Point(221, 118);
- this.lbFrench.Name = "lbFrench";
- this.lbFrench.Size = new System.Drawing.Size(43, 13);
- this.lbFrench.TabIndex = 6;
- this.lbFrench.Text = "French:";
- //
- // lbGerman
- //
- this.lbGerman.AutoSize = true;
- this.lbGerman.Location = new System.Drawing.Point(8, 118);
- this.lbGerman.Name = "lbGerman";
- this.lbGerman.Size = new System.Drawing.Size(47, 13);
- this.lbGerman.TabIndex = 5;
- this.lbGerman.Text = "German:";
- //
- // lbJapanese
- //
- this.lbJapanese.AutoSize = true;
- this.lbJapanese.Location = new System.Drawing.Point(221, 90);
- this.lbJapanese.Name = "lbJapanese";
- this.lbJapanese.Size = new System.Drawing.Size(56, 13);
- this.lbJapanese.TabIndex = 4;
- this.lbJapanese.Text = "Japanese:";
- //
- // lbEnglish
- //
- this.lbEnglish.AutoSize = true;
- this.lbEnglish.Location = new System.Drawing.Point(8, 90);
- this.lbEnglish.Name = "lbEnglish";
- this.lbEnglish.Size = new System.Drawing.Size(44, 13);
- this.lbEnglish.TabIndex = 3;
- this.lbEnglish.Text = "English:";
- //
- // lbSpecificLanguageTitles
- //
- this.lbSpecificLanguageTitles.AutoSize = true;
- this.lbSpecificLanguageTitles.Location = new System.Drawing.Point(8, 63);
- this.lbSpecificLanguageTitles.Name = "lbSpecificLanguageTitles";
- this.lbSpecificLanguageTitles.Size = new System.Drawing.Size(175, 13);
- this.lbSpecificLanguageTitles.TabIndex = 2;
- this.lbSpecificLanguageTitles.Text = "Specific Language Titles (Optional):";
- //
- // tbAllLanguages
- //
- this.tbAllLanguages.Location = new System.Drawing.Point(114, 19);
- this.tbAllLanguages.MaxLength = 20;
- this.tbAllLanguages.Name = "tbAllLanguages";
- this.tbAllLanguages.Size = new System.Drawing.Size(311, 20);
- this.tbAllLanguages.TabIndex = 1;
- //
- // lbAllLanguages
- //
- this.lbAllLanguages.AutoSize = true;
- this.lbAllLanguages.Location = new System.Drawing.Point(8, 22);
- this.lbAllLanguages.Name = "lbAllLanguages";
- this.lbAllLanguages.Size = new System.Drawing.Size(77, 13);
- this.lbAllLanguages.TabIndex = 0;
- this.lbAllLanguages.Text = "All Languages:";
- //
- // tabOptions
- //
- this.tabOptions.Controls.Add(this.cbLz77);
- this.tabOptions.Controls.Add(this.lbOptionsOptional);
- this.tabOptions.Controls.Add(this.btnBrowseSound);
- this.tabOptions.Controls.Add(this.tbSound);
- this.tabOptions.Controls.Add(this.cmbNandLoader);
- this.tabOptions.Controls.Add(this.btnBrowseDol);
- this.tabOptions.Controls.Add(this.tbDol);
- this.tabOptions.Controls.Add(this.tbTitleID);
- this.tabOptions.Controls.Add(this.lbNewSound);
- this.tabOptions.Controls.Add(this.lbNandLoader);
- this.tabOptions.Controls.Add(this.lbNewDol);
- this.tabOptions.Controls.Add(this.lbTitleID);
- this.tabOptions.Location = new System.Drawing.Point(4, 22);
- this.tabOptions.Name = "tabOptions";
- this.tabOptions.Padding = new System.Windows.Forms.Padding(3);
- this.tabOptions.Size = new System.Drawing.Size(443, 209);
- this.tabOptions.TabIndex = 2;
- this.tabOptions.Text = "Options";
- this.tabOptions.UseVisualStyleBackColor = true;
- //
- // cbLz77
- //
- this.cbLz77.AutoSize = true;
- this.cbLz77.Location = new System.Drawing.Point(11, 180);
- this.cbLz77.Name = "cbLz77";
- this.cbLz77.Size = new System.Drawing.Size(134, 17);
- this.cbLz77.TabIndex = 11;
- this.cbLz77.Text = "Use Lz77 Compression";
- this.cbLz77.UseVisualStyleBackColor = true;
- //
- // lbOptionsOptional
- //
- this.lbOptionsOptional.Location = new System.Drawing.Point(-7, 9);
- 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.TextAlign = System.Drawing.ContentAlignment.TopCenter;
- //
- // btnBrowseSound
- //
- this.btnBrowseSound.Location = new System.Drawing.Point(360, 144);
- this.btnBrowseSound.Name = "btnBrowseSound";
- this.btnBrowseSound.Size = new System.Drawing.Size(75, 23);
- this.btnBrowseSound.TabIndex = 9;
- this.btnBrowseSound.Text = "Browse...";
- this.btnBrowseSound.UseVisualStyleBackColor = true;
- this.btnBrowseSound.Click += new System.EventHandler(this.btnBrowseSound_Click);
- //
- // tbSound
- //
- this.tbSound.Location = new System.Drawing.Point(90, 147);
- this.tbSound.Name = "tbSound";
- this.tbSound.ReadOnly = true;
- this.tbSound.Size = new System.Drawing.Size(264, 20);
- this.tbSound.TabIndex = 8;
- this.tbSound.Tag = "Disabled";
- //
- // cmbNandLoader
- //
- this.cmbNandLoader.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.cmbNandLoader.FormattingEnabled = true;
- this.cmbNandLoader.Items.AddRange(new object[] {
- "comex",
- "Waninkoko"});
- this.cmbNandLoader.Location = new System.Drawing.Point(143, 111);
- this.cmbNandLoader.Name = "cmbNandLoader";
- this.cmbNandLoader.Size = new System.Drawing.Size(211, 21);
- this.cmbNandLoader.TabIndex = 7;
- //
- // btnBrowseDol
- //
- this.btnBrowseDol.Location = new System.Drawing.Point(360, 80);
- this.btnBrowseDol.Name = "btnBrowseDol";
- this.btnBrowseDol.Size = new System.Drawing.Size(75, 23);
- this.btnBrowseDol.TabIndex = 6;
- this.btnBrowseDol.Text = "Browse...";
- this.btnBrowseDol.UseVisualStyleBackColor = true;
- this.btnBrowseDol.Click += new System.EventHandler(this.btnBrowseDol_Click);
- //
- // tbDol
- //
- this.tbDol.Location = new System.Drawing.Point(90, 83);
- this.tbDol.Name = "tbDol";
- this.tbDol.ReadOnly = true;
- this.tbDol.Size = new System.Drawing.Size(264, 20);
- this.tbDol.TabIndex = 5;
- this.tbDol.Tag = "Disabled";
- //
- // tbTitleID
- //
- this.tbTitleID.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
- this.tbTitleID.Location = new System.Drawing.Point(90, 49);
- this.tbTitleID.MaxLength = 4;
- this.tbTitleID.Name = "tbTitleID";
- this.tbTitleID.Size = new System.Drawing.Size(55, 20);
- this.tbTitleID.TabIndex = 4;
- //
- // lbNewSound
- //
- this.lbNewSound.AutoSize = true;
- this.lbNewSound.Location = new System.Drawing.Point(8, 150);
- this.lbNewSound.Name = "lbNewSound";
- this.lbNewSound.Size = new System.Drawing.Size(66, 13);
- this.lbNewSound.TabIndex = 3;
- this.lbNewSound.Text = "New Sound:";
- //
- // lbNandLoader
- //
- this.lbNandLoader.AutoSize = true;
- this.lbNandLoader.Location = new System.Drawing.Point(49, 114);
- this.lbNandLoader.Name = "lbNandLoader";
- this.lbNandLoader.Size = new System.Drawing.Size(77, 13);
- this.lbNandLoader.TabIndex = 2;
- this.lbNandLoader.Text = "NAND Loader:";
- //
- // lbNewDol
- //
- this.lbNewDol.AutoSize = true;
- this.lbNewDol.Location = new System.Drawing.Point(8, 86);
- this.lbNewDol.Name = "lbNewDol";
- this.lbNewDol.Size = new System.Drawing.Size(57, 13);
- this.lbNewDol.TabIndex = 1;
- this.lbNewDol.Text = "New DOL:";
- //
- // lbTitleID
- //
- this.lbTitleID.AutoSize = true;
- this.lbTitleID.Location = new System.Drawing.Point(8, 52);
- this.lbTitleID.Name = "lbTitleID";
- this.lbTitleID.Size = new System.Drawing.Size(44, 13);
- this.lbTitleID.TabIndex = 0;
- this.lbTitleID.Text = "Title ID:";
- //
- // tabBanner
- //
- this.tabBanner.Controls.Add(this.cbBannerMakeTransparent);
- this.tabBanner.Controls.Add(this.cmbFormatBanner);
- this.tabBanner.Controls.Add(this.lbFormatBanner);
- this.tabBanner.Controls.Add(this.btnPreviewBanner);
- this.tabBanner.Controls.Add(this.btnExtractBanner);
- this.tabBanner.Controls.Add(this.btnDeleteBanner);
- this.tabBanner.Controls.Add(this.btnAddBanner);
- this.tabBanner.Controls.Add(this.btnReplaceBanner);
- this.tabBanner.Controls.Add(this.lbxBannerTpls);
- this.tabBanner.Location = new System.Drawing.Point(4, 22);
- this.tabBanner.Name = "tabBanner";
- this.tabBanner.Padding = new System.Windows.Forms.Padding(3);
- this.tabBanner.Size = new System.Drawing.Size(443, 209);
- this.tabBanner.TabIndex = 3;
- this.tabBanner.Text = "Banner";
- this.tabBanner.UseVisualStyleBackColor = true;
- //
- // cbBannerMakeTransparent
- //
- this.cbBannerMakeTransparent.AutoSize = true;
- this.cbBannerMakeTransparent.Location = new System.Drawing.Point(11, 189);
- this.cbBannerMakeTransparent.Name = "cbBannerMakeTransparent";
- this.cbBannerMakeTransparent.Size = new System.Drawing.Size(113, 17);
- this.cbBannerMakeTransparent.TabIndex = 6;
- this.cbBannerMakeTransparent.Text = "Make Transparent";
- this.cbBannerMakeTransparent.UseVisualStyleBackColor = true;
- this.cbBannerMakeTransparent.CheckedChanged += new System.EventHandler(this.cbBannerMakeTransparent_CheckedChanged);
- //
- // cmbFormatBanner
- //
- this.cmbFormatBanner.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.cmbFormatBanner.FormattingEnabled = true;
- this.cmbFormatBanner.Items.AddRange(new object[] {
- "RGBA8",
- "RGB565",
- "RGB5A3",
- "IA8",
- "IA4",
- "I8",
- "I4",
- "CMP"});
- this.cmbFormatBanner.Location = new System.Drawing.Point(360, 182);
- this.cmbFormatBanner.Name = "cmbFormatBanner";
- this.cmbFormatBanner.Size = new System.Drawing.Size(75, 21);
- this.cmbFormatBanner.TabIndex = 5;
- //
- // lbFormatBanner
- //
- this.lbFormatBanner.AutoSize = true;
- this.lbFormatBanner.Location = new System.Drawing.Point(360, 166);
- this.lbFormatBanner.Name = "lbFormatBanner";
- this.lbFormatBanner.Size = new System.Drawing.Size(42, 13);
- this.lbFormatBanner.TabIndex = 4;
- this.lbFormatBanner.Text = "Format:";
- //
- // btnPreviewBanner
- //
- this.btnPreviewBanner.Location = new System.Drawing.Point(360, 132);
- this.btnPreviewBanner.Name = "btnPreviewBanner";
- this.btnPreviewBanner.Size = new System.Drawing.Size(75, 23);
- this.btnPreviewBanner.TabIndex = 3;
- this.btnPreviewBanner.Text = "Preview";
- this.btnPreviewBanner.UseVisualStyleBackColor = true;
- this.btnPreviewBanner.Click += new System.EventHandler(this.btnPreviewBanner_Click);
- //
- // btnExtractBanner
- //
- this.btnExtractBanner.Location = new System.Drawing.Point(360, 102);
- this.btnExtractBanner.Name = "btnExtractBanner";
- this.btnExtractBanner.Size = new System.Drawing.Size(75, 23);
- this.btnExtractBanner.TabIndex = 2;
- this.btnExtractBanner.Text = "Extract";
- this.btnExtractBanner.UseVisualStyleBackColor = true;
- this.btnExtractBanner.Click += new System.EventHandler(this.btnExtractBanner_Click);
- //
- // btnDeleteBanner
- //
- this.btnDeleteBanner.Location = new System.Drawing.Point(360, 42);
- this.btnDeleteBanner.Name = "btnDeleteBanner";
- this.btnDeleteBanner.Size = new System.Drawing.Size(75, 23);
- this.btnDeleteBanner.TabIndex = 1;
- this.btnDeleteBanner.Text = "Delete";
- this.btnDeleteBanner.UseVisualStyleBackColor = true;
- this.btnDeleteBanner.Click += new System.EventHandler(this.btnDeleteBanner_Click);
- //
- // btnAddBanner
- //
- this.btnAddBanner.Location = new System.Drawing.Point(360, 12);
- this.btnAddBanner.Name = "btnAddBanner";
- this.btnAddBanner.Size = new System.Drawing.Size(75, 23);
- this.btnAddBanner.TabIndex = 1;
- this.btnAddBanner.Text = "Add";
- this.btnAddBanner.UseVisualStyleBackColor = true;
- this.btnAddBanner.Click += new System.EventHandler(this.btnAddBanner_Click);
- //
- // btnReplaceBanner
- //
- this.btnReplaceBanner.Location = new System.Drawing.Point(360, 72);
- this.btnReplaceBanner.Name = "btnReplaceBanner";
- this.btnReplaceBanner.Size = new System.Drawing.Size(75, 23);
- this.btnReplaceBanner.TabIndex = 1;
- this.btnReplaceBanner.Text = "Replace";
- this.btnReplaceBanner.UseVisualStyleBackColor = true;
- this.btnReplaceBanner.Click += new System.EventHandler(this.btnReplaceBanner_Click);
- //
- // lbxBannerTpls
- //
- this.lbxBannerTpls.FormattingEnabled = true;
- this.lbxBannerTpls.Location = new System.Drawing.Point(11, 12);
- this.lbxBannerTpls.Name = "lbxBannerTpls";
- this.lbxBannerTpls.Size = new System.Drawing.Size(343, 173);
- this.lbxBannerTpls.Sorted = true;
- this.lbxBannerTpls.TabIndex = 0;
- this.lbxBannerTpls.SelectedIndexChanged += new System.EventHandler(this.lbxBannerTpls_SelectedIndexChanged);
- //
- // tabIcon
- //
- this.tabIcon.Controls.Add(this.cbIconMakeTransparent);
- this.tabIcon.Controls.Add(this.cmbFormatIcon);
- this.tabIcon.Controls.Add(this.lbFormatIcon);
- this.tabIcon.Controls.Add(this.btnPreviewIcon);
- this.tabIcon.Controls.Add(this.btnExtractIcon);
- this.tabIcon.Controls.Add(this.btnAddIcon);
- this.tabIcon.Controls.Add(this.btnDeleteIcon);
- this.tabIcon.Controls.Add(this.btnReplaceIcon);
- this.tabIcon.Controls.Add(this.lbxIconTpls);
- this.tabIcon.Location = new System.Drawing.Point(4, 22);
- this.tabIcon.Name = "tabIcon";
- this.tabIcon.Padding = new System.Windows.Forms.Padding(3);
- this.tabIcon.Size = new System.Drawing.Size(443, 209);
- this.tabIcon.TabIndex = 4;
- this.tabIcon.Text = "Icon";
- this.tabIcon.UseVisualStyleBackColor = true;
- //
- // cbIconMakeTransparent
- //
- this.cbIconMakeTransparent.AutoSize = true;
- this.cbIconMakeTransparent.Location = new System.Drawing.Point(11, 189);
- this.cbIconMakeTransparent.Name = "cbIconMakeTransparent";
- this.cbIconMakeTransparent.Size = new System.Drawing.Size(113, 17);
- this.cbIconMakeTransparent.TabIndex = 12;
- this.cbIconMakeTransparent.Text = "Make Transparent";
- this.cbIconMakeTransparent.UseVisualStyleBackColor = true;
- this.cbIconMakeTransparent.CheckedChanged += new System.EventHandler(this.cbIconMakeTransparent_CheckedChanged);
- //
- // cmbFormatIcon
- //
- this.cmbFormatIcon.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.cmbFormatIcon.FormattingEnabled = true;
- this.cmbFormatIcon.Items.AddRange(new object[] {
- "RGBA8",
- "RGB565",
- "RGB5A3",
- "IA8",
- "IA4",
- "I8",
- "I4",
- "CMP"});
- this.cmbFormatIcon.Location = new System.Drawing.Point(360, 182);
- this.cmbFormatIcon.Name = "cmbFormatIcon";
- this.cmbFormatIcon.Size = new System.Drawing.Size(75, 21);
- this.cmbFormatIcon.TabIndex = 11;
- //
- // lbFormatIcon
- //
- this.lbFormatIcon.AutoSize = true;
- this.lbFormatIcon.Location = new System.Drawing.Point(360, 166);
- this.lbFormatIcon.Name = "lbFormatIcon";
- this.lbFormatIcon.Size = new System.Drawing.Size(42, 13);
- this.lbFormatIcon.TabIndex = 10;
- this.lbFormatIcon.Text = "Format:";
- //
- // btnPreviewIcon
- //
- this.btnPreviewIcon.Location = new System.Drawing.Point(360, 132);
- this.btnPreviewIcon.Name = "btnPreviewIcon";
- this.btnPreviewIcon.Size = new System.Drawing.Size(75, 23);
- this.btnPreviewIcon.TabIndex = 9;
- this.btnPreviewIcon.Text = "Preview";
- this.btnPreviewIcon.UseVisualStyleBackColor = true;
- this.btnPreviewIcon.Click += new System.EventHandler(this.btnPreviewIcon_Click);
- //
- // btnExtractIcon
- //
- this.btnExtractIcon.Location = new System.Drawing.Point(360, 102);
- this.btnExtractIcon.Name = "btnExtractIcon";
- this.btnExtractIcon.Size = new System.Drawing.Size(75, 23);
- this.btnExtractIcon.TabIndex = 8;
- this.btnExtractIcon.Text = "Extract";
- this.btnExtractIcon.UseVisualStyleBackColor = true;
- this.btnExtractIcon.Click += new System.EventHandler(this.btnExtractIcon_Click);
- //
- // btnAddIcon
- //
- this.btnAddIcon.Location = new System.Drawing.Point(360, 12);
- this.btnAddIcon.Name = "btnAddIcon";
- this.btnAddIcon.Size = new System.Drawing.Size(75, 23);
- this.btnAddIcon.TabIndex = 7;
- this.btnAddIcon.Text = "Add";
- this.btnAddIcon.UseVisualStyleBackColor = true;
- this.btnAddIcon.Click += new System.EventHandler(this.btnAddIcon_Click);
- //
- // btnDeleteIcon
- //
- this.btnDeleteIcon.Location = new System.Drawing.Point(360, 42);
- this.btnDeleteIcon.Name = "btnDeleteIcon";
- this.btnDeleteIcon.Size = new System.Drawing.Size(75, 23);
- this.btnDeleteIcon.TabIndex = 7;
- this.btnDeleteIcon.Text = "Delete";
- this.btnDeleteIcon.UseVisualStyleBackColor = true;
- this.btnDeleteIcon.Click += new System.EventHandler(this.btnDeleteIcon_Click);
- //
- // btnReplaceIcon
- //
- this.btnReplaceIcon.Location = new System.Drawing.Point(360, 72);
- this.btnReplaceIcon.Name = "btnReplaceIcon";
- this.btnReplaceIcon.Size = new System.Drawing.Size(75, 23);
- this.btnReplaceIcon.TabIndex = 7;
- this.btnReplaceIcon.Text = "Replace";
- this.btnReplaceIcon.UseVisualStyleBackColor = true;
- this.btnReplaceIcon.Click += new System.EventHandler(this.btnReplaceIcon_Click);
- //
- // lbxIconTpls
- //
- this.lbxIconTpls.FormattingEnabled = true;
- this.lbxIconTpls.Location = new System.Drawing.Point(11, 12);
- this.lbxIconTpls.Name = "lbxIconTpls";
- this.lbxIconTpls.Size = new System.Drawing.Size(343, 173);
- this.lbxIconTpls.Sorted = true;
- this.lbxIconTpls.TabIndex = 6;
- this.lbxIconTpls.SelectedIndexChanged += new System.EventHandler(this.lbxIconTpls_SelectedIndexChanged);
- //
- // tabBrlyt
- //
- this.tabBrlyt.Controls.Add(this.btnBrlytListTpls);
- this.tabBrlyt.Controls.Add(this.lbBrlytWarning);
- this.tabBrlyt.Controls.Add(this.lbBrlytActions);
- this.tabBrlyt.Controls.Add(this.btnBrlytExtract);
- this.tabBrlyt.Controls.Add(this.btnBrlytReplace);
- this.tabBrlyt.Controls.Add(this.lbBrlytIcon);
- this.tabBrlyt.Controls.Add(this.lbBrlytBanner);
- this.tabBrlyt.Controls.Add(this.lbxBrlytIcon);
- this.tabBrlyt.Controls.Add(this.lbxBrlytBanner);
- this.tabBrlyt.Location = new System.Drawing.Point(4, 22);
- this.tabBrlyt.Name = "tabBrlyt";
- this.tabBrlyt.Padding = new System.Windows.Forms.Padding(3);
- this.tabBrlyt.Size = new System.Drawing.Size(443, 209);
- this.tabBrlyt.TabIndex = 6;
- this.tabBrlyt.Text = "brlyt";
- this.tabBrlyt.UseVisualStyleBackColor = true;
- //
- // btnBrlytListTpls
- //
- this.btnBrlytListTpls.Location = new System.Drawing.Point(360, 131);
- this.btnBrlytListTpls.Name = "btnBrlytListTpls";
- this.btnBrlytListTpls.Size = new System.Drawing.Size(75, 23);
- this.btnBrlytListTpls.TabIndex = 8;
- this.btnBrlytListTpls.Text = "List TPLs";
- this.btnBrlytListTpls.UseVisualStyleBackColor = true;
- this.btnBrlytListTpls.Click += new System.EventHandler(this.btnBrlytListTpls_Click);
- //
- // lbBrlytWarning
- //
- this.lbBrlytWarning.ForeColor = System.Drawing.Color.Red;
- this.lbBrlytWarning.Location = new System.Drawing.Point(-4, 192);
- this.lbBrlytWarning.Name = "lbBrlytWarning";
- this.lbBrlytWarning.Size = new System.Drawing.Size(451, 23);
- this.lbBrlytWarning.TabIndex = 7;
- this.lbBrlytWarning.Text = "Be careful with these features, wrong handling WILL BRICK your Wii!";
- this.lbBrlytWarning.TextAlign = System.Drawing.ContentAlignment.TopCenter;
- //
- // lbBrlytActions
- //
- this.lbBrlytActions.Location = new System.Drawing.Point(357, 42);
- this.lbBrlytActions.Name = "lbBrlytActions";
- this.lbBrlytActions.Size = new System.Drawing.Size(78, 11);
- this.lbBrlytActions.TabIndex = 6;
- this.lbBrlytActions.TextAlign = System.Drawing.ContentAlignment.TopCenter;
- //
- // btnBrlytExtract
- //
- this.btnBrlytExtract.Location = new System.Drawing.Point(360, 98);
- this.btnBrlytExtract.Name = "btnBrlytExtract";
- this.btnBrlytExtract.Size = new System.Drawing.Size(75, 23);
- this.btnBrlytExtract.TabIndex = 5;
- this.btnBrlytExtract.Text = "Extract";
- this.btnBrlytExtract.UseVisualStyleBackColor = true;
- this.btnBrlytExtract.Click += new System.EventHandler(this.btnBrlytExtract_Click);
- //
- // btnBrlytReplace
- //
- this.btnBrlytReplace.Location = new System.Drawing.Point(360, 65);
- this.btnBrlytReplace.Name = "btnBrlytReplace";
- this.btnBrlytReplace.Size = new System.Drawing.Size(75, 23);
- this.btnBrlytReplace.TabIndex = 5;
- this.btnBrlytReplace.Text = "Replace";
- this.btnBrlytReplace.UseVisualStyleBackColor = true;
- this.btnBrlytReplace.Click += new System.EventHandler(this.btnBrlytReplace_Click);
- //
- // lbBrlytIcon
- //
- this.lbBrlytIcon.AutoSize = true;
- this.lbBrlytIcon.Location = new System.Drawing.Point(11, 102);
- this.lbBrlytIcon.Name = "lbBrlytIcon";
- this.lbBrlytIcon.Size = new System.Drawing.Size(31, 13);
- this.lbBrlytIcon.TabIndex = 4;
- this.lbBrlytIcon.Text = "Icon:";
- //
- // lbBrlytBanner
- //
- this.lbBrlytBanner.AutoSize = true;
- this.lbBrlytBanner.Location = new System.Drawing.Point(11, 11);
- this.lbBrlytBanner.Name = "lbBrlytBanner";
- this.lbBrlytBanner.RightToLeft = System.Windows.Forms.RightToLeft.No;
- this.lbBrlytBanner.Size = new System.Drawing.Size(44, 13);
- this.lbBrlytBanner.TabIndex = 3;
- this.lbBrlytBanner.Text = "Banner:";
- //
- // lbxBrlytIcon
- //
- this.lbxBrlytIcon.FormattingEnabled = true;
- this.lbxBrlytIcon.Location = new System.Drawing.Point(11, 120);
- this.lbxBrlytIcon.Name = "lbxBrlytIcon";
- this.lbxBrlytIcon.Size = new System.Drawing.Size(343, 69);
- this.lbxBrlytIcon.Sorted = true;
- this.lbxBrlytIcon.TabIndex = 1;
- this.lbxBrlytIcon.SelectedIndexChanged += new System.EventHandler(this.lbxBrlytIcon_SelectedIndexChanged);
- //
- // lbxBrlytBanner
- //
- this.lbxBrlytBanner.FormattingEnabled = true;
- this.lbxBrlytBanner.Location = new System.Drawing.Point(11, 29);
- this.lbxBrlytBanner.Name = "lbxBrlytBanner";
- this.lbxBrlytBanner.Size = new System.Drawing.Size(343, 69);
- this.lbxBrlytBanner.Sorted = true;
- this.lbxBrlytBanner.TabIndex = 0;
- this.lbxBrlytBanner.SelectedIndexChanged += new System.EventHandler(this.lbxBrlytBanner_SelectedIndexChanged);
- //
- // tabBrlan
- //
- this.tabBrlan.Controls.Add(this.lbBrlanWarning);
- this.tabBrlan.Controls.Add(this.lbBrlanActions);
- this.tabBrlan.Controls.Add(this.btnBrlanExtract);
- this.tabBrlan.Controls.Add(this.btnBrlanDelete);
- this.tabBrlan.Controls.Add(this.btnBrlanReplace);
- this.tabBrlan.Controls.Add(this.lbBrlanIcon);
- this.tabBrlan.Controls.Add(this.lbBrlanBanner);
- this.tabBrlan.Controls.Add(this.btnBrlanAdd);
- this.tabBrlan.Controls.Add(this.lbxBrlanIcon);
- this.tabBrlan.Controls.Add(this.lbxBrlanBanner);
- this.tabBrlan.Location = new System.Drawing.Point(4, 22);
- this.tabBrlan.Name = "tabBrlan";
- this.tabBrlan.Padding = new System.Windows.Forms.Padding(3);
- this.tabBrlan.Size = new System.Drawing.Size(443, 209);
- this.tabBrlan.TabIndex = 7;
- this.tabBrlan.Text = "brlan";
- this.tabBrlan.UseVisualStyleBackColor = true;
- //
- // lbBrlanWarning
- //
- this.lbBrlanWarning.ForeColor = System.Drawing.Color.Red;
- this.lbBrlanWarning.Location = new System.Drawing.Point(-4, 192);
- this.lbBrlanWarning.Name = "lbBrlanWarning";
- this.lbBrlanWarning.Size = new System.Drawing.Size(451, 23);
- this.lbBrlanWarning.TabIndex = 15;
- this.lbBrlanWarning.Text = "Be careful with these features, wrong handling WILL BRICK your Wii!";
- this.lbBrlanWarning.TextAlign = System.Drawing.ContentAlignment.TopCenter;
- //
- // lbBrlanActions
- //
- this.lbBrlanActions.Location = new System.Drawing.Point(357, 14);
- this.lbBrlanActions.Name = "lbBrlanActions";
- this.lbBrlanActions.Size = new System.Drawing.Size(78, 13);
- this.lbBrlanActions.TabIndex = 14;
- this.lbBrlanActions.TextAlign = System.Drawing.ContentAlignment.TopCenter;
- //
- // btnBrlanExtract
- //
- this.btnBrlanExtract.Location = new System.Drawing.Point(360, 153);
- this.btnBrlanExtract.Name = "btnBrlanExtract";
- this.btnBrlanExtract.Size = new System.Drawing.Size(75, 23);
- this.btnBrlanExtract.TabIndex = 11;
- this.btnBrlanExtract.Text = "Extract";
- this.btnBrlanExtract.UseVisualStyleBackColor = true;
- this.btnBrlanExtract.Click += new System.EventHandler(this.btnBrlanExtract_Click);
- //
- // btnBrlanDelete
- //
- this.btnBrlanDelete.Location = new System.Drawing.Point(360, 77);
- this.btnBrlanDelete.Name = "btnBrlanDelete";
- this.btnBrlanDelete.Size = new System.Drawing.Size(75, 23);
- this.btnBrlanDelete.TabIndex = 12;
- this.btnBrlanDelete.Text = "Delete";
- this.btnBrlanDelete.UseVisualStyleBackColor = true;
- this.btnBrlanDelete.Click += new System.EventHandler(this.btnBrlanDelete_Click);
- //
- // btnBrlanReplace
- //
- this.btnBrlanReplace.Location = new System.Drawing.Point(360, 115);
- this.btnBrlanReplace.Name = "btnBrlanReplace";
- this.btnBrlanReplace.Size = new System.Drawing.Size(75, 23);
- this.btnBrlanReplace.TabIndex = 13;
- this.btnBrlanReplace.Text = "Replace";
- this.btnBrlanReplace.UseVisualStyleBackColor = true;
- this.btnBrlanReplace.Click += new System.EventHandler(this.btnBrlanReplace_Click);
- //
- // lbBrlanIcon
- //
- this.lbBrlanIcon.AutoSize = true;
- this.lbBrlanIcon.Location = new System.Drawing.Point(11, 102);
- this.lbBrlanIcon.Name = "lbBrlanIcon";
- this.lbBrlanIcon.Size = new System.Drawing.Size(31, 13);
- this.lbBrlanIcon.TabIndex = 10;
- this.lbBrlanIcon.Text = "Icon:";
- //
- // lbBrlanBanner
- //
- this.lbBrlanBanner.AutoSize = true;
- this.lbBrlanBanner.Location = new System.Drawing.Point(11, 11);
- this.lbBrlanBanner.Name = "lbBrlanBanner";
- this.lbBrlanBanner.RightToLeft = System.Windows.Forms.RightToLeft.No;
- this.lbBrlanBanner.Size = new System.Drawing.Size(44, 13);
- this.lbBrlanBanner.TabIndex = 9;
- this.lbBrlanBanner.Text = "Banner:";
- //
- // btnBrlanAdd
- //
- this.btnBrlanAdd.Location = new System.Drawing.Point(360, 39);
- this.btnBrlanAdd.Name = "btnBrlanAdd";
- this.btnBrlanAdd.Size = new System.Drawing.Size(75, 23);
- this.btnBrlanAdd.TabIndex = 8;
- this.btnBrlanAdd.Text = "Add";
- this.btnBrlanAdd.UseVisualStyleBackColor = true;
- this.btnBrlanAdd.Click += new System.EventHandler(this.btnBrlanAdd_Click);
- //
- // lbxBrlanIcon
- //
- this.lbxBrlanIcon.FormattingEnabled = true;
- this.lbxBrlanIcon.Location = new System.Drawing.Point(11, 120);
- this.lbxBrlanIcon.Name = "lbxBrlanIcon";
- this.lbxBrlanIcon.Size = new System.Drawing.Size(343, 69);
- this.lbxBrlanIcon.Sorted = true;
- this.lbxBrlanIcon.TabIndex = 7;
- this.lbxBrlanIcon.SelectedIndexChanged += new System.EventHandler(this.lbxBrlanIcon_SelectedIndexChanged);
- //
- // lbxBrlanBanner
- //
- this.lbxBrlanBanner.FormattingEnabled = true;
- this.lbxBrlanBanner.Location = new System.Drawing.Point(11, 29);
- this.lbxBrlanBanner.Name = "lbxBrlanBanner";
- this.lbxBrlanBanner.Size = new System.Drawing.Size(343, 69);
- this.lbxBrlanBanner.Sorted = true;
- this.lbxBrlanBanner.TabIndex = 6;
- this.lbxBrlanBanner.SelectedIndexChanged += new System.EventHandler(this.lbxBrlanBanner_SelectedIndexChanged);
- //
- // tabInstructions
- //
- this.tabInstructions.Controls.Add(this.rtbInstructions);
- this.tabInstructions.Location = new System.Drawing.Point(4, 22);
- this.tabInstructions.Name = "tabInstructions";
- this.tabInstructions.Padding = new System.Windows.Forms.Padding(3);
- this.tabInstructions.Size = new System.Drawing.Size(443, 209);
- this.tabInstructions.TabIndex = 8;
- this.tabInstructions.Text = "Instructions";
- this.tabInstructions.UseVisualStyleBackColor = true;
- //
- // rtbInstructions
- //
- this.rtbInstructions.BackColor = System.Drawing.SystemColors.Window;
- this.rtbInstructions.Dock = System.Windows.Forms.DockStyle.Fill;
- this.rtbInstructions.Location = new System.Drawing.Point(3, 3);
- this.rtbInstructions.Name = "rtbInstructions";
- this.rtbInstructions.ReadOnly = true;
- this.rtbInstructions.Size = new System.Drawing.Size(437, 203);
- this.rtbInstructions.TabIndex = 0;
- this.rtbInstructions.Text = "";
- //
- // tabCredits
- //
- 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);
- this.tabCredits.Name = "tabCredits";
- this.tabCredits.Padding = new System.Windows.Forms.Padding(3);
- this.tabCredits.Size = new System.Drawing.Size(443, 209);
- this.tabCredits.TabIndex = 5;
- this.tabCredits.Text = "Credits";
- this.tabCredits.UseVisualStyleBackColor = true;
- //
- // llbUpdateAvailabe
- //
- 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, 62);
- 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);
- //
- // llbSite
- //
- this.llbSite.Location = new System.Drawing.Point(0, 35);
- this.llbSite.Name = "llbSite";
- this.llbSite.Size = new System.Drawing.Size(443, 13);
- this.llbSite.TabIndex = 3;
- this.llbSite.TabStop = true;
- this.llbSite.Text = "http://customizemii.googlecode.com";
- this.llbSite.TextAlign = System.Drawing.ContentAlignment.TopCenter;
- this.llbSite.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llbSite_LinkClicked);
- //
- // lbCreditThanks
- //
- this.lbCreditThanks.Location = new System.Drawing.Point(0, 91);
- this.lbCreditThanks.Name = "lbCreditThanks";
- this.lbCreditThanks.Size = new System.Drawing.Size(443, 79);
- this.lbCreditThanks.TabIndex = 2;
- this.lbCreditThanks.Text = resources.GetString("lbCreditThanks.Text");
- this.lbCreditThanks.TextAlign = System.Drawing.ContentAlignment.TopCenter;
- //
- // lbCreditVersion
- //
- this.lbCreditVersion.Location = new System.Drawing.Point(0, 13);
- this.lbCreditVersion.Name = "lbCreditVersion";
- this.lbCreditVersion.Size = new System.Drawing.Size(443, 13);
- this.lbCreditVersion.TabIndex = 1;
- this.lbCreditVersion.Text = "CustomizeMii Version X by Leathl";
- this.lbCreditVersion.TextAlign = System.Drawing.ContentAlignment.TopCenter;
- //
- // lbCreditInfo
- //
- this.lbCreditInfo.ForeColor = System.Drawing.Color.Red;
- this.lbCreditInfo.Location = new System.Drawing.Point(0, 189);
- this.lbCreditInfo.Name = "lbCreditInfo";
- this.lbCreditInfo.Size = new System.Drawing.Size(443, 16);
- this.lbCreditInfo.TabIndex = 0;
- this.lbCreditInfo.Text = "Thanks to icefire / Xuzz for the basic idea of this Application!";
- this.lbCreditInfo.TextAlign = System.Drawing.ContentAlignment.TopCenter;
- //
- // ssMain
- //
- this.ssMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.lbStatus,
- this.lbStatusText,
- this.pbProgress});
- this.ssMain.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
- this.ssMain.Location = new System.Drawing.Point(0, 268);
- this.ssMain.Name = "ssMain";
- this.ssMain.Size = new System.Drawing.Size(451, 22);
- this.ssMain.SizingGrip = false;
- this.ssMain.TabIndex = 2;
- this.ssMain.Text = "ssMain";
- //
- // lbStatus
- //
- this.lbStatus.Name = "lbStatus";
- this.lbStatus.Size = new System.Drawing.Size(45, 17);
- this.lbStatus.Text = "Status: ";
- //
- // lbStatusText
- //
- this.lbStatusText.Name = "lbStatusText";
- this.lbStatusText.Size = new System.Drawing.Size(0, 17);
- this.lbStatusText.Spring = true;
- this.lbStatusText.TextChanged += new System.EventHandler(this.lbStatusText_TextChanged);
- //
- // pbProgress
- //
- this.pbProgress.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
- this.pbProgress.Name = "pbProgress";
- this.pbProgress.Size = new System.Drawing.Size(100, 16);
- this.pbProgress.Value = 100;
- //
- // CustomizeMii_Main
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(451, 290);
- this.Controls.Add(this.tabControl);
- this.Controls.Add(this.btnCreateWad);
- this.Controls.Add(this.ssMain);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.Name = "CustomizeMii_Main";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "CustomizeMii X by Leathl";
- this.Load += new System.EventHandler(this.CustomizeMii_Main_Load);
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CustomizeMii_Main_FormClosing);
- this.tabControl.ResumeLayout(false);
- this.tabSource.ResumeLayout(false);
- this.tabSource.PerformLayout();
- this.tabTitle.ResumeLayout(false);
- this.tabTitle.PerformLayout();
- this.tabOptions.ResumeLayout(false);
- this.tabOptions.PerformLayout();
- this.tabBanner.ResumeLayout(false);
- this.tabBanner.PerformLayout();
- this.tabIcon.ResumeLayout(false);
- this.tabIcon.PerformLayout();
- this.tabBrlyt.ResumeLayout(false);
- this.tabBrlyt.PerformLayout();
- this.tabBrlan.ResumeLayout(false);
- this.tabBrlan.PerformLayout();
- this.tabInstructions.ResumeLayout(false);
- this.tabCredits.ResumeLayout(false);
- this.ssMain.ResumeLayout(false);
- this.ssMain.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Button btnCreateWad;
- private System.Windows.Forms.TabControl tabControl;
- private System.Windows.Forms.TabPage tabSource;
- private System.Windows.Forms.TabPage tabTitle;
- private System.Windows.Forms.TabPage tabOptions;
- private System.Windows.Forms.TabPage tabBanner;
- private System.Windows.Forms.TabPage tabIcon;
- private System.Windows.Forms.TabPage tabCredits;
- private System.Windows.Forms.Label lbSource;
- private System.Windows.Forms.Button btnBrowseSource;
- private System.Windows.Forms.TextBox tbSourceWad;
- private System.Windows.Forms.ListBox lbxBaseWads;
- private System.Windows.Forms.Button btnSaveBaseWad;
- private System.Windows.Forms.Button btnPreviewBaseWad;
- private System.Windows.Forms.Button btnLoadBaseWad;
- private System.Windows.Forms.TextBox tbAllLanguages;
- private System.Windows.Forms.Label lbAllLanguages;
- private System.Windows.Forms.Label lbSpecificLanguageTitles;
- private System.Windows.Forms.Label lbEnglish;
- private System.Windows.Forms.Label lbJapanese;
- private System.Windows.Forms.Label lbDutch;
- private System.Windows.Forms.Label lbItalian;
- private System.Windows.Forms.Label lbSpanish;
- private System.Windows.Forms.Label lbFrench;
- private System.Windows.Forms.Label lbGerman;
- private System.Windows.Forms.TextBox tbItalian;
- private System.Windows.Forms.TextBox tbFrench;
- private System.Windows.Forms.TextBox tbJapanese;
- private System.Windows.Forms.TextBox tbDutch;
- private System.Windows.Forms.TextBox tbSpanish;
- private System.Windows.Forms.TextBox tbGerman;
- private System.Windows.Forms.TextBox tbEnglish;
- private System.Windows.Forms.Label lbNewDol;
- private System.Windows.Forms.Label lbTitleID;
- private System.Windows.Forms.Label lbNandLoader;
- private System.Windows.Forms.Label lbNewSound;
- private System.Windows.Forms.Button btnBrowseDol;
- private System.Windows.Forms.TextBox tbDol;
- private System.Windows.Forms.TextBox tbTitleID;
- private System.Windows.Forms.ComboBox cmbNandLoader;
- private System.Windows.Forms.TextBox tbSound;
- private System.Windows.Forms.Button btnBrowseSound;
- private System.Windows.Forms.Label lbOptionsOptional;
- private System.Windows.Forms.Button btnPreviewBanner;
- private System.Windows.Forms.Button btnExtractBanner;
- private System.Windows.Forms.Button btnReplaceBanner;
- private System.Windows.Forms.ListBox lbxBannerTpls;
- private System.Windows.Forms.Label lbFormatBanner;
- private System.Windows.Forms.ComboBox cmbFormatBanner;
- private System.Windows.Forms.ComboBox cmbFormatIcon;
- private System.Windows.Forms.Label lbFormatIcon;
- private System.Windows.Forms.Button btnPreviewIcon;
- private System.Windows.Forms.Button btnExtractIcon;
- private System.Windows.Forms.Button btnReplaceIcon;
- private System.Windows.Forms.ListBox lbxIconTpls;
- private System.Windows.Forms.Label lbCreditInfo;
- private System.Windows.Forms.Label lbCreditVersion;
- private System.Windows.Forms.Label lbCreditThanks;
- private System.Windows.Forms.StatusStrip ssMain;
- private System.Windows.Forms.ToolStripProgressBar pbProgress;
- private System.Windows.Forms.ToolStripStatusLabel lbStatus;
- private System.Windows.Forms.ToolStripStatusLabel lbStatusText;
- private System.Windows.Forms.ComboBox cmbReplace;
- private System.Windows.Forms.TextBox tbReplace;
- private System.Windows.Forms.Button btnBrowseReplace;
- private System.Windows.Forms.Button btnClearReplace;
- private System.Windows.Forms.CheckBox cbLz77;
- private System.Windows.Forms.LinkLabel llbSite;
- private System.Windows.Forms.TabPage tabBrlyt;
- private System.Windows.Forms.TabPage tabBrlan;
- private System.Windows.Forms.ListBox lbxBrlytIcon;
- private System.Windows.Forms.ListBox lbxBrlytBanner;
- private System.Windows.Forms.Label lbBrlytIcon;
- private System.Windows.Forms.Label lbBrlytBanner;
- private System.Windows.Forms.Button btnBrlytReplace;
- private System.Windows.Forms.Button btnBrlytExtract;
- private System.Windows.Forms.Button btnBrlanExtract;
- private System.Windows.Forms.Button btnBrlanDelete;
- private System.Windows.Forms.Button btnBrlanReplace;
- private System.Windows.Forms.Label lbBrlanIcon;
- private System.Windows.Forms.Label lbBrlanBanner;
- private System.Windows.Forms.Button btnBrlanAdd;
- private System.Windows.Forms.ListBox lbxBrlanIcon;
- private System.Windows.Forms.ListBox lbxBrlanBanner;
- private System.Windows.Forms.Label lbBrlytActions;
- 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.Button btnDeleteBanner;
- private System.Windows.Forms.Button btnAddBanner;
- private System.Windows.Forms.Button btnAddIcon;
- private System.Windows.Forms.Button btnDeleteIcon;
- private System.Windows.Forms.Button btnBrlytListTpls;
- private System.Windows.Forms.CheckBox cbBannerMakeTransparent;
- private System.Windows.Forms.CheckBox cbIconMakeTransparent;
- private System.Windows.Forms.TabPage tabInstructions;
- private System.Windows.Forms.RichTextBox rtbInstructions;
- }
-}
-
diff --git a/CustomizeMii/CustomizeMii_Main.cs b/CustomizeMii/CustomizeMii_Main.cs
deleted file mode 100644
index 28d73f6..0000000
--- a/CustomizeMii/CustomizeMii_Main.cs
+++ /dev/null
@@ -1,3070 +0,0 @@
-/* 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 .
- */
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Drawing;
-using System.IO;
-using System.Net;
-using System.Text.RegularExpressions;
-using System.Windows.Forms;
-
-namespace CustomizeMii
-{
- public partial class CustomizeMii_Main : Form
- {
- const string Version = "1.1"; //Hint for myself: Never use a char in the Version (UpdateCheck)!
- const int SoundMaxLength = 30; //In seconds
- const int SoundWarningLength = 20; //In seconds
- protected string TempWadPath = Path.GetTempPath() + "CustomizeMii_Temp\\TempWad.wad";
- protected string TempUnpackPath = Path.GetTempPath() + "CustomizeMii_Temp\\Unpack\\";
- protected string TempBannerPath = Path.GetTempPath() + "CustomizeMii_Temp\\Banner\\";
- protected string TempIconPath = Path.GetTempPath() + "CustomizeMii_Temp\\Icon\\";
- protected string TempSoundPath = Path.GetTempPath() + "CustomizeMii_Temp\\sound.bin";
- protected string TempTempPath = Path.GetTempPath() + "CustomizeMii_Temp\\Temp\\";
- protected string TempUnpackBannerTplPath = Path.GetTempPath() + "CustomizeMii_Temp\\Unpack\\00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\timg\\";
- protected string TempUnpackIconTplPath = Path.GetTempPath() + "CustomizeMii_Temp\\Unpack\\00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\timg\\";
- protected string TempUnpackBannerBrlytPath = Path.GetTempPath() + "CustomizeMii_Temp\\Unpack\\00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\blyt\\";
- protected string TempUnpackIconBrlytPath = Path.GetTempPath() + "CustomizeMii_Temp\\Unpack\\00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\blyt\\";
- protected string TempUnpackBannerBrlanPath = Path.GetTempPath() + "CustomizeMii_Temp\\Unpack\\00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\anim\\";
- protected string TempUnpackIconBrlanPath = Path.GetTempPath() + "CustomizeMii_Temp\\Unpack\\00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\anim\\";
- protected string[] ButtonTexts = new string[] { "Create WAD!", "Fire!", "Go Go Go!", "Let's do it!", "What are you waitin' for?", "I want my Channel!", "Houston, We've Got a Problem!", "Error, please contact anyone!", "Isn't she sweet?", "Is that milk?", "In your face!", "_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_", "Wo ist der Notausgang?", "Take me to a higher place!", "What's goin' on?", "I'm a Button!", "Click!", "Today's date is " + DateTime.Now.ToShortDateString(), "Launch Time: " + DateTime.Now.ToLongTimeString() };
- protected string[] SourceWadUrls = new string[] { "http://wadder.net/bases/StaticBase.wad", "http://wadder.net/bases/GenesisGX.wad", "http://wadder.net/bases/MP-CE-Std.wad", "http://wadder.net/bases/MP-CE-Ext.wad", "http://wadder.net/bases/SNES9XGX.wad", "http://wadder.net/bases/FCEUGX-wilsoff.wad", "http://wadder.net/bases/FCEUGX.wad", "http://wadder.net/bases/Wii64.wad", "http://wadder.net/bases/WiiSXFull.wad", "http://wadder.net/bases/WiiSXRetro.wad", "http://wadder.net/bases/WADderBase1.wad", "http://wadder.net/bases/WADderBase2.wad", "http://wadder.net/bases/WADderBase3.wad", "http://wadder.net/bases/UniiLoader.wad", "http://wadder.net/bases/BackupChannel.wad" };
- protected string[] SourceWadPreviewUrls = new string[] { "http://www.youtube.com/watch?v=pFNKldTYQq0", "http://www.youtube.com/watch?v=p9A6iEQvv9w", "http://www.youtube.com/watch?v=Up1RZebUc_U", "http://www.youtube.com/watch?v=Up1RZebUc_U", "http://www.youtube.com/watch?v=P-Mxd6DMvFY", "http://www.youtube.com/watch?v=wrbrg-DH_h4", "http://www.youtube.com/watch?v=MfiVbQaiXw8", "http://www.youtube.com/watch?v=krCQ2J7ZH8Y", "http://www.youtube.com/watch?v=rZC1DKUM6QI", "http://www.youtube.com/watch?v=Uiy8w-bp1kI", "http://www.youtube.com/watch?v=BbSYCSI8tz8", "http://www.youtube.com/watch?v=PIFZevHQ8lQ", "http://www.youtube.com/watch?v=OIhvDNjphhc", "http://www.youtube.com/watch?v=KLcncEArQLY&NR=1", "http://www.youtube.com/watch?v=xE_EgdCRV1I" };
- private string BannerTplPath = string.Empty;
- private string IconTplPath = string.Empty;
- private string SourceWad = string.Empty;
- private string BannerBrlytPath = string.Empty;
- private string IconBrlytPath = string.Empty;
- private string BannerBrlanPath = string.Empty;
- private string IconBrlanPath = string.Empty;
- private string BannerReplace = string.Empty;
- private string IconReplace = string.Empty;
- private string SoundReplace = string.Empty;
- private int NandLoader = 0;
- private TextBox tbToChange;
- private string textToChange;
- private bool BrlytChanged = false;
- private bool BrlanChanged = false;
- private int ProgressValue;
- private string ProgressState;
- private EventHandler ProgressUpdate;
- private ToolTip TTip = new ToolTip();
- private int UnpackFolderErrorCount = 0;
- private Stopwatch CreationTimer = new Stopwatch();
- List Transparents = new List();
-
- public CustomizeMii_Main()
- {
- InitializeComponent();
- this.Icon = global::CustomizeMii.Properties.Resources.CustomizeMii;
- }
-
- private void CustomizeMii_Main_Load(object sender, EventArgs e)
- {
- InitializeStartup();
- CommonKeyCheck();
- }
-
- private void CustomizeMii_Main_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (Directory.Exists(Path.GetTempPath() + "CustomizeMii_Temp")) Directory.Delete(Path.GetTempPath() + "CustomizeMii_Temp", true);
- }
-
- private void InitializeStartup()
- {
- this.Text = this.Text.Replace("X", Version);
- this.lbCreditVersion.Text = this.lbCreditVersion.Text.Replace("X", Version);
- ProgressUpdate = new EventHandler(this.UpdateProgress);
- SetButtonText();
- cmbNandLoader.SelectedIndex = 0;
- cmbFormatBanner.SelectedIndex = 0;
- cmbFormatIcon.SelectedIndex = 0;
- cmbReplace.SelectedIndex = 0;
- pbProgress.Value = 100;
- BrlanChanged = false;
- BrlytChanged = false;
- UpdateCheck();
- DisableControls(null, null);
- SetToolTips();
- btnBrowseDol.Text = "Browse...";
- btnBrowseSound.Text = "Browse...";
- rtbInstructions.Rtf = Properties.Resources.Instructions;
- rtbInstructions.LinkClicked += new LinkClickedEventHandler(rtbInstructions_LinkClicked);
- }
-
- void rtbInstructions_LinkClicked(object sender, LinkClickedEventArgs e)
- {
- try
- {
- Process.Start(e.LinkText);
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
-
- private void CommonKeyCheck()
- {
- if (!File.Exists(Application.StartupPath + "\\common-key.bin") && !File.Exists(Application.StartupPath + "\\key.bin"))
- {
- CustomizeMii_InputBox ib = new CustomizeMii_InputBox();
-
- if (ib.ShowDialog() == DialogResult.OK)
- {
- Wii.Tools.CreateCommonKey(ib.Input, Application.StartupPath);
- }
- }
- else
- {
- if (File.Exists(Application.StartupPath + "\\common-key.bin"))
- {
- if (Wii.Tools.CheckCommonKey(Application.StartupPath + "\\common-key.bin") == false)
- {
- File.Delete(Application.StartupPath + "\\common-key.bin");
- CommonKeyCheck();
- }
- }
- else if (File.Exists(Application.StartupPath + "\\key.bin"))
- {
- if (Wii.Tools.CheckCommonKey(Application.StartupPath + "\\key.bin") == false)
- {
- File.Delete(Application.StartupPath + "\\key.bin");
- CommonKeyCheck();
- }
- }
- }
- }
-
- private void Initialize(object sender, EventArgs e)
- {
- InitializeStartup();
- ClearAll();
- }
-
- private void ClearAll()
- {
- tbAllLanguages.Text = string.Empty;
- tbDol.Text = string.Empty;
- tbDutch.Text = string.Empty;
- tbEnglish.Text = string.Empty;
- tbFrench.Text = string.Empty;
- tbGerman.Text = string.Empty;
- tbItalian.Text = string.Empty;
- tbJapanese.Text = string.Empty;
- tbReplace.Text = string.Empty;
- tbSound.Text = string.Empty;
- tbSourceWad.Text = string.Empty;
- tbSpanish.Text = string.Empty;
- tbTitleID.Text = string.Empty;
-
- BannerReplace = string.Empty;
- IconReplace = string.Empty;
- SoundReplace = string.Empty;
- SourceWad = string.Empty;
- BannerTplPath = string.Empty;
- IconTplPath = string.Empty;
-
- lbxBannerTpls.Items.Clear();
- lbxBrlanBanner.Items.Clear();
- lbxBrlanIcon.Items.Clear();
- lbxBrlytBanner.Items.Clear();
- lbxBrlytIcon.Items.Clear();
- lbxIconTpls.Items.Clear();
-
- cbLz77.Checked = false;
- cbIconMakeTransparent.Checked = false;
- cbBannerMakeTransparent.Checked = false;
- }
-
- private void SetToolTips()
- {
- TTip.SetToolTip(btnCreateWad, "Create WAD...");
- TTip.SetToolTip(btnBrowseSource, "Browse for a WAD that is used as a Base...");
- TTip.SetToolTip(btnLoadBaseWad, "Load the selected Base WAD...");
- TTip.SetToolTip(btnPreviewBaseWad, "Preview the selected Base WAD, a Browserwindow will be opened...");
- TTip.SetToolTip(btnSaveBaseWad, "Download and save the selected Base WAD to your HDD...");
- TTip.SetToolTip(btnBrowseReplace, "Browse for a Banner / Icon / Sound to use instead of the one within the Base WAD...\nWAD's, 00000000.app's and banner.bin's / icon.bin's / sound.bin's can be loaded...");
- TTip.SetToolTip(btnClearReplace, "Clear the replaced Banner / Icon / Sound and use the one within the Base WAD...");
- TTip.SetToolTip(btnBrowseDol, "Browse for a DOL file that will be inserted into the WAD...");
- TTip.SetToolTip(btnBrowseSound, "Browse for a WAV sound that will be inserted into the WAD...");
- TTip.SetToolTip(btnAddBanner, "Add an image or TPL to the Banner...");
- TTip.SetToolTip(btnAddIcon, "Add an image or TPL to the Icon...");
- TTip.SetToolTip(btnDeleteBanner, "Delete the selected TPL...\nRequired TPLs can't be deleted...");
- TTip.SetToolTip(btnDeleteIcon, "Delete the selected TPL...\nRequired TPLs can't be deleted...");
- TTip.SetToolTip(btnReplaceBanner, "Replace the selected TPL with any image...\nThe image wil be stretched to fit the size of the TPL...");
- TTip.SetToolTip(btnReplaceIcon, "Replace the selected TPL with any image...\nThe image wil be stretched to fit the size of the TPL...");
- TTip.SetToolTip(btnExtractBanner, "Extract the selected TPL as an image...");
- TTip.SetToolTip(btnExtractIcon, "Extract the selected TPL as an image...");
- TTip.SetToolTip(btnPreviewBanner, "Preview the selected TPL...");
- TTip.SetToolTip(btnPreviewIcon, "Preview the selected TPL...");
- TTip.SetToolTip(btnBrlytReplace, "Replace the selected brlyt with any other...\nThis is for advanced users only!");
- TTip.SetToolTip(btnBrlytExtract, "Extract the selected brlyt...");
- TTip.SetToolTip(btnBrlytListTpls, "List the TPLs required by the selected brlyt...");
- TTip.SetToolTip(btnBrlanAdd, "Add a brlan file...\nThis is for advanced users only!");
- TTip.SetToolTip(btnBrlanDelete, "Delete the selected brlan file...\nThis is for advanced users only!");
- TTip.SetToolTip(btnBrlanReplace, "Replace the selected brlan file...\nThis is for advanced users only!");
- TTip.SetToolTip(btnBrlanExtract, "Extract the selected brlan file...");
-
- TTip.SetToolTip(cbLz77, "Use Lz77 compression for the banner.bin, icon.bin and sound.bin...\nIf the created WAD does not work, try it without compression first...");
- }
-
- private void SetButtonText()
- {
- Random randomize = new Random();
- btnCreateWad.Text = ButtonTexts[randomize.Next(0, ButtonTexts.Length - 1)];
- }
-
- private void ErrorBox(string message)
- {
- MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
-
- private void InfoBox(string message)
- {
- MessageBox.Show(message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
-
- private bool CheckInet()
- {
- try
- {
- System.Net.IPHostEntry IpHost = System.Net.Dns.GetHostEntry("www.google.com");
- return true;
- }
- catch
- {
- return false;
- }
- }
-
- private void UpdateProgress(object sender, EventArgs e)
- {
- pbProgress.Value = ProgressValue;
-
- if (!string.IsNullOrEmpty(ProgressState))
- lbStatusText.Text = ProgressState;
- }
-
- private void AddBannerTpls(object sender, EventArgs e)
- {
- try
- {
- string[] BannerTpls;
- if (string.IsNullOrEmpty(BannerReplace))
- BannerTpls = Directory.GetFiles(TempUnpackBannerTplPath);
- else
- BannerTpls = Directory.GetFiles(TempBannerPath + "arc\\timg");
-
- AddBannerTpls(BannerTpls);
- }
- catch { }
- }
-
- private void AddIconTpls(object sender, EventArgs e)
- {
- try
- {
- string[] IconTpls;
- if (string.IsNullOrEmpty(IconReplace))
- IconTpls = Directory.GetFiles(TempUnpackIconTplPath);
- else
- IconTpls = Directory.GetFiles(TempIconPath + "arc\\timg");
-
- AddIconTpls(IconTpls);
- }
- catch { }
- }
-
- private void AddBannerTpls(string[] tpls)
- {
- if (tpls.Length > 0)
- {
- lbxBannerTpls.Items.Clear();
- BannerTplPath = tpls[0].Remove(tpls[0].LastIndexOf('\\') + 1);
-
- for (int i = 0; i < tpls.Length; i++)
- {
- if (Transparents.Contains(tpls[i].Remove(0, tpls[i].LastIndexOf('\\') + 1)))
- lbxBannerTpls.Items.Add(tpls[i].Remove(0, tpls[i].LastIndexOf('\\') + 1) + " (Transparent)");
- else
- lbxBannerTpls.Items.Add(tpls[i].Remove(0, tpls[i].LastIndexOf('\\') + 1));
- }
- }
- }
-
- private void AddIconTpls(string[] tpls)
- {
- if (tpls.Length > 0)
- {
- lbxIconTpls.Items.Clear();
- IconTplPath = tpls[0].Remove(tpls[0].LastIndexOf('\\') + 1);
-
- for (int i = 0; i < tpls.Length; i++)
- {
- if (Transparents.Contains(tpls[i].Remove(0, tpls[i].LastIndexOf('\\') + 1)))
- lbxIconTpls.Items.Add(tpls[i].Remove(0, tpls[i].LastIndexOf('\\') + 1) + " (Transparent)");
- else
- lbxIconTpls.Items.Add(tpls[i].Remove(0, tpls[i].LastIndexOf('\\') + 1));
- }
- }
- }
-
- private void AddBannerBrlyt(string[] brlyt)
- {
- if (brlyt.Length > 0)
- {
- lbxBrlytBanner.Items.Clear();
- BannerBrlytPath = brlyt[0].Remove(brlyt[0].LastIndexOf('\\') + 1);
-
- for (int i = 0; i < brlyt.Length; i++)
- {
- lbxBrlytBanner.Items.Add(brlyt[i].Remove(0, brlyt[i].LastIndexOf('\\') + 1));
- }
- }
- }
-
- private void AddIconBrlyt(string[] brlyt)
- {
- if (brlyt.Length > 0)
- {
- lbxBrlytIcon.Items.Clear();
- IconBrlytPath = brlyt[0].Remove(brlyt[0].LastIndexOf('\\') + 1);
-
- for (int i = 0; i < brlyt.Length; i++)
- {
- lbxBrlytIcon.Items.Add(brlyt[i].Remove(0, brlyt[i].LastIndexOf('\\') + 1));
- }
- }
- }
-
- private void AddBannerBrlan(string[] brlan)
- {
- if (brlan.Length > 0)
- {
- lbxBrlanBanner.Items.Clear();
- BannerBrlanPath = brlan[0].Remove(brlan[0].LastIndexOf('\\') + 1);
-
- for (int i = 0; i < brlan.Length; i++)
- {
- lbxBrlanBanner.Items.Add(brlan[i].Remove(0, brlan[i].LastIndexOf('\\') + 1));
- }
- }
- }
-
- private void AddIconBrlan(string[] brlan)
- {
- if (brlan.Length > 0)
- {
- lbxBrlanIcon.Items.Clear();
- IconBrlanPath = brlan[0].Remove(brlan[0].LastIndexOf('\\') + 1);
-
- for (int i = 0; i < brlan.Length; i++)
- {
- lbxBrlanIcon.Items.Add(brlan[i].Remove(0, brlan[i].LastIndexOf('\\') + 1));
- }
- }
- }
-
- private void SetText(TextBox tb, string text)
- {
- EventHandler ChangeText = new EventHandler(this.ChangeText);
- tbToChange = tb;
- textToChange = text;
- this.Invoke(ChangeText);
- }
-
- private string GetCurBannerPath()
- {
- if (string.IsNullOrEmpty(BannerReplace))
- return TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\";
- else
- return TempBannerPath + "arc\\";
- }
-
- private string GetCurIconPath()
- {
- if (string.IsNullOrEmpty(IconReplace))
- return TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\";
- else
- return TempIconPath + "arc\\";
- }
-
- private void ChangeText(object sender, EventArgs e)
- {
- tbToChange.Text = textToChange;
- }
-
- private void SetSourceWad(object sender, EventArgs e)
- {
- tbSourceWad.Text = SourceWad;
- }
-
- private void tabControl_Selecting(object sender, TabControlCancelEventArgs e)
- {
- if (tabControl.SelectedTab == tabBanner)
- {
- lbxBannerTpls.SelectedIndex = -1;
- cbBannerMakeTransparent.Checked = false;
- cbBannerMakeTransparent.Enabled = false;
- AddBannerTpls(null, null);
- }
- else if (tabControl.SelectedTab == tabIcon)
- {
- lbxIconTpls.SelectedIndex = -1;
- cbIconMakeTransparent.Checked = false;
- cbIconMakeTransparent.Enabled = false;
- AddIconTpls(null, null);
- }
- else if (tabControl.SelectedTab == tabBrlyt)
- {
- try
- {
- string[] BannerBrlyt;
- if (string.IsNullOrEmpty(BannerReplace))
- BannerBrlyt = Directory.GetFiles(TempUnpackBannerBrlytPath);
- else
- BannerBrlyt = Directory.GetFiles(TempBannerPath + "arc\\blyt");
-
- string[] IconBrlyt;
- if (string.IsNullOrEmpty(IconReplace))
- IconBrlyt = Directory.GetFiles(TempUnpackIconBrlytPath);
- else
- IconBrlyt = Directory.GetFiles(TempIconPath + "arc\\blyt");
-
- AddBannerBrlyt(BannerBrlyt);
- AddIconBrlyt(IconBrlyt);
-
- if (lbxBrlytBanner.SelectedIndex == -1 && lbxBrlytIcon.SelectedIndex == -1)
- {
- if (lbxBrlytBanner.Items.Count > 0) lbxBrlytBanner.SelectedIndex = 0;
- else if (lbxBrlytIcon.Items.Count > 0) lbxBrlytIcon.SelectedIndex = 0;
- }
- }
- catch { }
- }
- else if (tabControl.SelectedTab == tabBrlan)
- {
- try
- {
- string[] BannerBrlan;
- if (string.IsNullOrEmpty(BannerReplace))
- BannerBrlan = Directory.GetFiles(TempUnpackBannerBrlanPath);
- else
- BannerBrlan = Directory.GetFiles(TempBannerPath + "arc\\anim");
-
- string[] IconBrlan;
- if (string.IsNullOrEmpty(IconReplace))
- IconBrlan = Directory.GetFiles(TempUnpackIconBrlanPath);
- else
- IconBrlan = Directory.GetFiles(TempIconPath + "arc\\anim");
-
- AddBannerBrlan(BannerBrlan);
- AddIconBrlan(IconBrlan);
-
- if (lbxBrlanBanner.SelectedIndex == -1 && lbxBrlanIcon.SelectedIndex == -1)
- {
- if (lbxBrlanBanner.Items.Count > 0) lbxBrlanBanner.SelectedIndex = 0;
- else if (lbxBrlanIcon.Items.Count > 0) lbxBrlanIcon.SelectedIndex = 0;
- }
- }
- catch { }
- }
- }
-
- private void lbStatusText_TextChanged(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(lbStatusText.Text) && pbProgress.Value == 100)
- {
- if (tabControl.SelectedTab == tabBanner)
- {
- try
- {
- string[] BannerTpls;
- if (string.IsNullOrEmpty(BannerReplace))
- BannerTpls = Directory.GetFiles(TempUnpackBannerTplPath);
- else
- BannerTpls = Directory.GetFiles(TempBannerPath + "arc\\timg");
-
- AddBannerTpls(BannerTpls);
- }
- catch { }
- }
- else if (tabControl.SelectedTab == tabIcon)
- {
- try
- {
- string[] IconTpls;
- if (string.IsNullOrEmpty(IconReplace))
- IconTpls = Directory.GetFiles(TempUnpackIconTplPath);
- else
- IconTpls = Directory.GetFiles(TempIconPath + "arc\\timg");
-
- AddIconTpls(IconTpls);
- }
- catch { }
- }
- else if (tabControl.SelectedTab == tabBrlyt)
- {
- try
- {
- string[] BannerBrlyt;
- if (string.IsNullOrEmpty(BannerReplace))
- BannerBrlyt = Directory.GetFiles(TempUnpackBannerBrlytPath);
- else
- BannerBrlyt = Directory.GetFiles(TempBannerPath + "arc\\blyt");
-
- string[] IconBrlyt;
- if (string.IsNullOrEmpty(IconReplace))
- IconBrlyt = Directory.GetFiles(TempUnpackIconBrlytPath);
- else
- IconBrlyt = Directory.GetFiles(TempIconPath + "arc\\blyt");
-
- AddBannerBrlyt(BannerBrlyt);
- AddIconBrlyt(IconBrlyt);
- }
- catch { }
- }
- else if (tabControl.SelectedTab == tabBrlan)
- {
- try
- {
- string[] BannerBrlan;
- if (string.IsNullOrEmpty(BannerReplace))
- BannerBrlan = Directory.GetFiles(TempUnpackBannerBrlanPath);
- else
- BannerBrlan = Directory.GetFiles(TempBannerPath + "arc\\anim");
-
- string[] IconBrlan;
- if (string.IsNullOrEmpty(IconReplace))
- IconBrlan = Directory.GetFiles(TempUnpackIconBrlanPath);
- else
- IconBrlan = Directory.GetFiles(TempIconPath + "arc\\anim");
-
- AddBannerBrlan(BannerBrlan);
- AddIconBrlan(IconBrlan);
- }
- catch { }
- }
- }
- }
-
- private Image ResizeImage(Image img, int x, int y)
- {
- Image newimage = new Bitmap(x, y);
- using (Graphics gfx = Graphics.FromImage(newimage))
- {
- gfx.DrawImage(img, 0, 0, x, y);
- }
- return newimage;
- }
-
- private void MakeBannerTplsTransparent()
- {
- foreach (string thisTpl in lbxBannerTpls.Items)
- {
- if (thisTpl.EndsWith("(Transparent)"))
- {
- string Tpl = BannerTplPath + thisTpl.Replace(" (Transparent)", string.Empty);
- byte[] TplArray = Wii.Tools.LoadFileToByteArray(Tpl);
- int Width = Wii.TPL.GetTextureWidth(TplArray);
- int Height = Wii.TPL.GetTextureHeight(TplArray);
-
- Image Img = new Bitmap(Width, Height);
- Wii.TPL.ConvertToTPL(Img, Tpl, 5);
- }
- }
- }
-
- private void MakeIconTplsTransparent()
- {
- foreach (string thisTpl in lbxIconTpls.Items)
- {
- if (thisTpl.EndsWith("(Transparent)"))
- {
- string Tpl = IconTplPath + thisTpl.Replace(" (Transparent)", string.Empty);
- byte[] TplArray = Wii.Tools.LoadFileToByteArray(Tpl);
- int Width = Wii.TPL.GetTextureWidth(TplArray);
- int Height = Wii.TPL.GetTextureHeight(TplArray);
-
- Image Img = new Bitmap(Width, Height);
- Wii.TPL.ConvertToTPL(Img, Tpl, 5);
- }
- }
- }
-
- private void EnableControls(object sender, EventArgs e)
- {
- for (int i = 0; i < tabControl.TabCount; i++)
- {
- if (tabControl.TabPages[i] != tabSource)
- {
- foreach (Control Ctrl in tabControl.TabPages[i].Controls)
- {
- if (Ctrl is Button) Ctrl.Enabled = true;
- else if ((Ctrl is TextBox) && (Ctrl.Tag != (object)"Disabled")) Ctrl.Enabled = true;
- else if (Ctrl is CheckBox && Ctrl == cbLz77) Ctrl.Enabled = true;
- else if (Ctrl is ComboBox) Ctrl.Enabled = true;
- }
- }
- }
- }
-
- private void DisableControls(object sender, EventArgs e)
- {
- for (int i = 0; i < tabControl.TabCount; i++)
- {
- if (tabControl.TabPages[i] != tabSource)
- {
- foreach (Control Ctrl in tabControl.TabPages[i].Controls)
- {
- if (Ctrl is Button) Ctrl.Enabled = false;
- else if ((Ctrl is TextBox) && (Ctrl.Tag != (object)"Disabled")) Ctrl.Enabled = false;
- else if (Ctrl is CheckBox) Ctrl.Enabled = false;
- else if (Ctrl is ComboBox) Ctrl.Enabled = false;
- }
- }
- }
- }
-
- private void UpdateCheck()
- {
- if (CheckInet() == true)
- {
- try
- {
- WebClient GetVersion = new WebClient();
- string NewVersion = GetVersion.DownloadString("http://customizemii.googlecode.com/svn/version.txt"); //TODO: Replace
-
- int newVersion = Convert.ToInt32(NewVersion.Replace(".", string.Empty).Length == 2 ? (NewVersion.Replace(".", string.Empty) + "0") : NewVersion.Replace(".", string.Empty));
- int thisVersion = Convert.ToInt32(Version.Replace(".", string.Empty).Length == 2 ? (Version.Replace(".", string.Empty) + "0") : Version.Replace(".", string.Empty));
-
- if (newVersion > thisVersion)
- {
- llbUpdateAvailabe.Text = llbUpdateAvailabe.Text.Replace("X", NewVersion);
- llbUpdateAvailabe.Visible = true;
-
- if (MessageBox.Show("Version " + NewVersion +
- " is availabe.\nDo you want the download page to be opened?",
- "Update availabe", MessageBoxButtons.YesNo, MessageBoxIcon.Information) ==
- DialogResult.Yes)
- {
- Process.Start("http://code.google.com/p/customizemii/downloads/list");
- }
- }
- }
- catch { }
- }
- }
-
- private void llbSite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- try
- {
- llbSite.LinkVisited = true;
- Process.Start("http://customizemii.googlecode.com");
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
-
- private void btnBrowseSource_Click(object sender, EventArgs e)
- {
- if (pbProgress.Value == 100)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Wii Channels|*.wad";
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- SourceWad = ofd.FileName;
- BackgroundWorker bwLoadChannel = new BackgroundWorker();
- bwLoadChannel.DoWork += new DoWorkEventHandler(bwLoadChannel_DoWork);
- bwLoadChannel.ProgressChanged += new ProgressChangedEventHandler(bwLoadChannel_ProgressChanged);
- bwLoadChannel.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwLoadChannel_RunWorkerCompleted);
- bwLoadChannel.WorkerReportsProgress = true;
- bwLoadChannel.RunWorkerAsync(ofd.FileName);
- }
- }
- }
-
- void bwLoadChannel_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- pbProgress.Value = 100;
- lbStatusText.Text = string.Empty;
- }
-
- void bwLoadChannel_ProgressChanged(object sender, ProgressChangedEventArgs e)
- {
- ProgressValue = e.ProgressPercentage;
- ProgressState = (string)e.UserState;
-
- this.Invoke(ProgressUpdate);
- }
-
- void bwLoadChannel_DoWork(object sender, DoWorkEventArgs e)
- {
- try
- {
- BackgroundWorker bwLoadChannel = sender as BackgroundWorker;
- EventHandler SetSourceWad = new EventHandler(this.SetSourceWad);
- byte[] WadFile = Wii.Tools.LoadFileToByteArray((string)e.Argument);
-
- if (Directory.Exists(TempUnpackPath)) Directory.Delete(TempUnpackPath, true);
-
- bwLoadChannel.ReportProgress(0, "Loading WAD...");
- Wii.WadUnpack.UnpackWad(WadFile, TempUnpackPath);
- if (Wii.U8.CheckU8(TempUnpackPath + "00000000.app") == false)
- throw new Exception("CustomizeMii only edits Channel WADs!");
-
- this.Invoke(SetSourceWad);
-
- bwLoadChannel.ReportProgress(25, "Loading 00000000.app...");
- Wii.U8.UnpackU8(TempUnpackPath + "00000000.app", TempUnpackPath + "00000000.app_OUT");
-
- bwLoadChannel.ReportProgress(50, "Loading banner.bin...");
- Wii.U8.UnpackU8(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin", TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT");
-
- bwLoadChannel.ReportProgress(75, "Loading icon.bin...");
- Wii.U8.UnpackU8(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin", TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT");
-
- bwLoadChannel.ReportProgress(90, "Gathering Information...");
- string[] ChannelTitles = Wii.WadInfo.GetChannelTitles(WadFile);
- string TitleID = Wii.WadInfo.GetTitleID(WadFile, 1);
-
- SetText(tbAllLanguages, ChannelTitles[1]);
-
- if (ChannelTitles[0] != ChannelTitles[1])
- SetText(tbJapanese, ChannelTitles[0]);
- if (ChannelTitles[2] != ChannelTitles[1])
- SetText(tbGerman, ChannelTitles[2]);
- if (ChannelTitles[3] != ChannelTitles[1])
- SetText(tbFrench, ChannelTitles[3]);
- if (ChannelTitles[4] != ChannelTitles[1])
- SetText(tbSpanish, ChannelTitles[4]);
- if (ChannelTitles[5] != ChannelTitles[1])
- SetText(tbItalian, ChannelTitles[5]);
- if (ChannelTitles[6] != ChannelTitles[1])
- SetText(tbDutch, ChannelTitles[6]);
-
- SetText(tbTitleID, TitleID);
-
- EventHandler AddBannerTpls = new EventHandler(this.AddBannerTpls);
- EventHandler AddIconTpls = new EventHandler(this.AddIconTpls);
- this.Invoke(AddBannerTpls);
- this.Invoke(AddIconTpls);
-
- bwLoadChannel.ReportProgress(100);
- EventHandler EnableCtrls = new EventHandler(this.EnableControls);
- this.Invoke(EnableCtrls);
- }
- catch (Exception ex)
- {
- if (Directory.Exists(TempUnpackPath)) Directory.Delete(TempUnpackPath, true);
- SourceWad = string.Empty;
- ErrorBox(ex.Message);
- }
- }
-
- private void btnLoadBaseWad_Click(object sender, EventArgs e)
- {
- if (lbxBaseWads.SelectedIndex != -1)
- {
- if (CheckInet() == true)
- {
- if (pbProgress.Value == 100)
- {
- try
- {
- SourceWad = SourceWadUrls[lbxBaseWads.SelectedIndex];
- tbSourceWad.Text = SourceWad;
- WebClient Client = new WebClient();
- Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Client_DownloadProgressChanged);
- Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
-
- 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);
- }
- }
-
- }
- else
- {
- ErrorBox("You're not connected to the Internet!");
- }
- }
- }
-
- void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
- {
- pbProgress.Value = e.ProgressPercentage;
- }
-
- void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
- {
- BackgroundWorker bwLoadChannel = new BackgroundWorker();
- bwLoadChannel.DoWork += new DoWorkEventHandler(bwLoadChannel_DoWork);
- bwLoadChannel.ProgressChanged += new ProgressChangedEventHandler(bwLoadChannel_ProgressChanged);
- bwLoadChannel.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwLoadChannel_RunWorkerCompleted);
- bwLoadChannel.WorkerReportsProgress = true;
- bwLoadChannel.RunWorkerAsync(TempWadPath);
- }
-
- private void btnPreviewBaseWad_Click(object sender, EventArgs e)
- {
- if (lbxBaseWads.SelectedIndex != -1)
- {
- if (CheckInet() == true)
- {
- if (!string.IsNullOrEmpty(SourceWadPreviewUrls[lbxBaseWads.SelectedIndex]))
- {
- try
- {
- Process.Start(SourceWadPreviewUrls[lbxBaseWads.SelectedIndex]);
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
- else
- InfoBox("There's no preview of this channel availabe, sorry!");
- }
- else
- {
- ErrorBox("You're not connected to the Internet!");
- }
- }
- }
-
- private void btnSaveBaseWad_Click(object sender, EventArgs e)
- {
- if (lbxBaseWads.SelectedIndex != -1)
- {
- if (CheckInet() == true)
- {
- if (pbProgress.Value == 100)
- {
- string Url = SourceWadUrls[lbxBaseWads.SelectedIndex];
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.Filter = "Wii Channels|*.wad";
- sfd.FileName = Url.Remove(0, Url.LastIndexOf('/') + 1);
-
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- try
- {
- WebClient SaveClient = new WebClient();
- SaveClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(SaveClient_DownloadProgressChanged);
- SaveClient.DownloadFileCompleted += new AsyncCompletedEventHandler(SaveClient_DownloadFileCompleted);
-
- lbStatusText.Text = "Downloading Base WAD...";
- pbProgress.Value = 0;
- SaveClient.DownloadFileAsync(new Uri(Url), sfd.FileName);
- }
- catch (Exception ex)
- {
- ErrorBox(ex.Message);
- }
- }
- }
-
- }
- else
- {
- ErrorBox("You're not connected to the Internet!");
- }
- }
- }
-
- void SaveClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
- {
- pbProgress.Value = e.ProgressPercentage;
- }
-
- void SaveClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
- {
- lbStatusText.Text = string.Empty;
- pbProgress.Value = 100;
- }
-
- private void cmbReplace_SelectedIndexChanged(object sender, EventArgs e)
- {
- switch (cmbReplace.SelectedIndex)
- {
- case 1:
- tbReplace.Text = IconReplace;
- break;
- case 2:
- tbReplace.Text = SoundReplace;
- break;
- default:
- tbReplace.Text = BannerReplace;
- break;
- }
- }
-
- private void btnBrowseReplace_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(tbSourceWad.Text)){
- if (pbProgress.Value == 100)
- {
- if (cmbReplace.SelectedIndex == 2) //sound
- {
- try
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|sound.bin|sound.bin|All|*.wad;00000000.app;sound.bin";
- ofd.FilterIndex = 4;
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- SoundReplace = ofd.FileName;
- SetText(tbReplace, SoundReplace);
- BackgroundWorker bwSoundReplace = new BackgroundWorker();
- bwSoundReplace.DoWork += new DoWorkEventHandler(bwSoundReplace_DoWork);
- bwSoundReplace.ProgressChanged += new ProgressChangedEventHandler(bwSoundReplace_ProgressChanged);
- bwSoundReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwSoundReplace_RunWorkerCompleted);
- bwSoundReplace.WorkerReportsProgress = true;
- bwSoundReplace.RunWorkerAsync(ofd.FileName);
- }
- }
- catch (Exception ex)
- {
- SoundReplace = string.Empty;
- SetText(tbReplace, SoundReplace);
- ErrorBox(ex.Message);
- }
- }
- else if (cmbReplace.SelectedIndex == 1) //icon
- {
- try
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|icon.bin|icon.bin|All|*.wad;00000000.app;icon.bin";
- ofd.FilterIndex = 4;
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- IconReplace = ofd.FileName;
- SetText(tbReplace, IconReplace);
- BackgroundWorker bwIconReplace = new BackgroundWorker();
- bwIconReplace.DoWork += new DoWorkEventHandler(bwIconReplace_DoWork);
- bwIconReplace.ProgressChanged += new ProgressChangedEventHandler(bwIconReplace_ProgressChanged);
- bwIconReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwIconReplace_RunWorkerCompleted);
- bwIconReplace.WorkerReportsProgress = true;
- bwIconReplace.RunWorkerAsync(ofd.FileName);
- }
- }
- catch (Exception ex)
- {
- IconReplace = string.Empty;
- SetText(tbReplace, IconReplace);
- ErrorBox(ex.Message);
- }
- }
- else //banner
- {
- try
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|banner.bin|banner.bin|All|*.wad;00000000.app;banner.bin";
- ofd.FilterIndex = 4;
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- BannerReplace = ofd.FileName;
- SetText(tbReplace, BannerReplace);
- BackgroundWorker bwBannerReplace = new BackgroundWorker();
- bwBannerReplace.DoWork += new DoWorkEventHandler(bwBannerReplace_DoWork);
- bwBannerReplace.ProgressChanged += new ProgressChangedEventHandler(bwBannerReplace_ProgressChanged);
- bwBannerReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwBannerReplace_RunWorkerCompleted);
- bwBannerReplace.WorkerReportsProgress = true;
- bwBannerReplace.RunWorkerAsync(ofd.FileName);
- }
- }
- catch (Exception ex)
- {
- BannerReplace = string.Empty;
- SetText(tbReplace, BannerReplace);
- ErrorBox(ex.Message);
- }
- }
- }
- }
- }
-
- void bwBannerReplace_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- pbProgress.Value = 100;
- lbStatusText.Text = string.Empty;
- SetText(tbReplace, BannerReplace);
- }
-
- void bwBannerReplace_ProgressChanged(object sender, ProgressChangedEventArgs e)
- {
- ProgressValue = e.ProgressPercentage;
- ProgressState = (string)e.UserState;
-
- this.Invoke(ProgressUpdate);
- }
-
- void bwBannerReplace_DoWork(object sender, DoWorkEventArgs e)
- {
- try
- {
- BackgroundWorker bwBannerReplace = sender as BackgroundWorker;
- string thisFile = (string)e.Argument;
- if (Directory.Exists(TempTempPath)) Directory.Delete(TempTempPath, true);
- if (Directory.Exists(TempBannerPath)) Directory.Delete(TempBannerPath, true);
-
- if (thisFile.EndsWith(".bin"))
- {
- bwBannerReplace.ReportProgress(0, "Loading banner.bin...");
- Wii.U8.UnpackU8(thisFile, TempBannerPath);
- }
- else if (thisFile.EndsWith(".app"))
- {
- bwBannerReplace.ReportProgress(0, "Loading 00000000.app...");
- Wii.U8.UnpackU8(thisFile, TempTempPath);
- bwBannerReplace.ReportProgress(50, "Loading banner.bin...");
- Wii.U8.UnpackU8(TempTempPath + "meta\\banner.bin", TempBannerPath);
- Directory.Delete(TempTempPath, true);
- }
- else
- {
- bwBannerReplace.ReportProgress(0, "Loading WAD...");
- Wii.WadUnpack.UnpackWad(thisFile, TempTempPath);
- if (Wii.U8.CheckU8(TempTempPath + "00000000.app") == false)
- throw new Exception("CustomizeMii only handles Channel WADs!");
- bwBannerReplace.ReportProgress(30, "Loading 00000000.app...");
- Wii.U8.UnpackU8(TempTempPath + "00000000.app", TempTempPath + "00000000.app_OUT");
- bwBannerReplace.ReportProgress(60, "Loading banner.bin...");
- Wii.U8.UnpackU8(TempTempPath + "00000000.app_OUT\\meta\\banner.bin", TempBannerPath);
- Directory.Delete(TempTempPath, true);
- }
-
- EventHandler AddBannerTpls = new EventHandler(this.AddBannerTpls);
- EventHandler AddIconTpls = new EventHandler(this.AddIconTpls);
- this.Invoke(AddBannerTpls);
- this.Invoke(AddIconTpls);
- }
- catch (Exception ex)
- {
- if (Directory.Exists(TempTempPath)) Directory.Delete(TempTempPath, true);
- if (Directory.Exists(TempBannerPath)) Directory.Delete(TempBannerPath, true);
- BannerReplace = string.Empty;
- ErrorBox(ex.Message);
- }
- }
-
- void bwIconReplace_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- pbProgress.Value = 100;
- lbStatusText.Text = string.Empty;
- SetText(tbReplace, IconReplace);
- }
-
- void bwIconReplace_ProgressChanged(object sender, ProgressChangedEventArgs e)
- {
- ProgressValue = e.ProgressPercentage;
- ProgressState = (string)e.UserState;
-
- this.Invoke(ProgressUpdate);
- }
-
- void bwIconReplace_DoWork(object sender, DoWorkEventArgs e)
- {
- try
- {
- BackgroundWorker bwIconReplace = sender as BackgroundWorker;
- string thisFile = (string)e.Argument;
- if (Directory.Exists(TempTempPath)) Directory.Delete(TempTempPath, true);
- if (Directory.Exists(TempIconPath)) Directory.Delete(TempIconPath, true);
-
- if (thisFile.EndsWith(".bin"))
- {
- bwIconReplace.ReportProgress(0, "Loading icon.bin...");
- Wii.U8.UnpackU8(thisFile, TempIconPath);
- }
- else if (thisFile.EndsWith(".app"))
- {
- bwIconReplace.ReportProgress(0, "Loading 00000000.app...");
- Wii.U8.UnpackU8(thisFile, TempTempPath);
- bwIconReplace.ReportProgress(50, "Loading icon.bin...");
- Wii.U8.UnpackU8(TempTempPath + "meta\\icon.bin", TempIconPath);
- Directory.Delete(TempTempPath, true);
- }
- else
- {
- bwIconReplace.ReportProgress(0, "Loading WAD...");
- Wii.WadUnpack.UnpackWad(thisFile, TempTempPath);
- if (Wii.U8.CheckU8(TempTempPath + "00000000.app") == false)
- throw new Exception("CustomizeMii only handles Channel WADs!");
- bwIconReplace.ReportProgress(30, "Loading 00000000.app...");
- Wii.U8.UnpackU8(TempTempPath + "00000000.app", TempTempPath + "00000000.app_OUT");
- bwIconReplace.ReportProgress(60, "Loading icon.bin...");
- Wii.U8.UnpackU8(TempTempPath + "00000000.app_OUT\\meta\\icon.bin", TempIconPath);
- Directory.Delete(TempTempPath, true);
- }
-
- EventHandler AddBannerTpls = new EventHandler(this.AddBannerTpls);
- EventHandler AddIconTpls = new EventHandler(this.AddIconTpls);
- this.Invoke(AddBannerTpls);
- this.Invoke(AddIconTpls);
- }
- catch (Exception ex)
- {
- if (Directory.Exists(TempTempPath)) Directory.Delete(TempTempPath, true);
- if (Directory.Exists(TempIconPath)) Directory.Delete(TempIconPath, true);
- IconReplace = string.Empty;
- ErrorBox(ex.Message);
- }
- }
-
- void bwSoundReplace_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- pbProgress.Value = 100;
- lbStatusText.Text = string.Empty;
- SetText(tbReplace, SoundReplace);
- }
-
- void bwSoundReplace_ProgressChanged(object sender, ProgressChangedEventArgs e)
- {
- ProgressValue = e.ProgressPercentage;
- ProgressState = (string)e.UserState;
-
- this.Invoke(ProgressUpdate);
- }
-
- void bwSoundReplace_DoWork(object sender, DoWorkEventArgs e)
- {
- try
- {
- BackgroundWorker bwSoundReplace = sender as BackgroundWorker;
- string thisFile = (string)e.Argument;
- if (File.Exists(TempSoundPath)) File.Delete(TempSoundPath);
- if (Directory.Exists(TempTempPath)) Directory.Delete(TempTempPath, true);
-
- if (thisFile.EndsWith(".bin"))
- {
- bwSoundReplace.ReportProgress(0, "Copying sound.bin...");
- File.Copy(thisFile, TempSoundPath);
- }
- else if (thisFile.EndsWith(".app"))
- {
- bwSoundReplace.ReportProgress(0, "Loading 00000000.app...");
- Wii.U8.UnpackU8(thisFile, TempTempPath);
- bwSoundReplace.ReportProgress(80, "Copying sound.bin...");
- File.Copy(TempTempPath + "meta\\sound.bin", TempSoundPath);
- Directory.Delete(TempTempPath, true);
- }
- else
- {
- bwSoundReplace.ReportProgress(0, "Loading WAD...");
- Wii.WadUnpack.UnpackWad(thisFile, TempTempPath);
- if (Wii.U8.CheckU8(TempTempPath + "00000000.app") == false)
- throw new Exception("CustomizeMii only handles Channel WADs!");
- bwSoundReplace.ReportProgress(50, "Loading 00000000.app...");
- Wii.U8.UnpackU8(TempTempPath + "00000000.app", TempTempPath + "00000000.app_OUT");
- bwSoundReplace.ReportProgress(90, "Copying sound.bin...");
- File.Copy(TempTempPath + "00000000.app_OUT\\meta\\sound.bin", TempSoundPath);
- Directory.Delete(TempTempPath, true);
- }
-
- SetText(tbSound, SoundReplace);
- }
- catch (Exception ex)
- {
- if (Directory.Exists(TempTempPath)) Directory.Delete(TempTempPath, true);
- if (File.Exists(TempSoundPath)) File.Delete(TempSoundPath);
- SoundReplace = string.Empty;
- ErrorBox(ex.Message);
- }
- }
-
- private void btnClearReplace_Click(object sender, EventArgs e)
- {
- if (cmbReplace.SelectedIndex == 2) //sound
- {
- SoundReplace = string.Empty;
- SetText(tbReplace, SoundReplace);
- if (File.Exists(TempSoundPath)) File.Delete(TempSoundPath);
- SetText(tbSound, string.Empty);
- }
- else if (cmbReplace.SelectedIndex == 1) //icon
- {
- IconReplace = string.Empty;
- SetText(tbReplace, IconReplace);
- if (Directory.Exists(TempIconPath)) Directory.Delete(TempIconPath, true);
- }
- else //banner
- {
- BannerReplace = string.Empty;
- SetText(tbReplace, BannerReplace);
- if (Directory.Exists(TempBannerPath)) Directory.Delete(TempBannerPath, true);
- }
- }
-
- private void btnBrowseDol_Click(object sender, EventArgs e)
- {
- if (btnBrowseDol.Text == "Clear")
- {
- SetText(tbDol, string.Empty);
- btnBrowseDol.Text = "Browse...";
- }
- else
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "DOL Files|*.dol";
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- SetText(tbDol, ofd.FileName);
- btnBrowseDol.Text = "Clear";
- }
- }
- }
-
- private void btnBrowseSound_Click(object sender, EventArgs e)
- {
- if (btnBrowseSound.Text == "Clear")
- {
- SetText(tbSound, string.Empty);
- btnBrowseSound.Text = "Browse...";
- }
- else
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Wave Files|*.wav";
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- SetText(tbSound, ofd.FileName);
- btnBrowseSound.Text = "Clear";
-
- if (!string.IsNullOrEmpty(SoundReplace))
- {
- SoundReplace = string.Empty;
- if (cmbReplace.SelectedIndex == 2) SetText(tbReplace, SoundReplace);
- if (File.Exists(TempSoundPath)) File.Delete(TempSoundPath);
- }
- }
- }
- }
-
- private void lbxBannerTpls_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (lbxBannerTpls.SelectedIndex != -1)
- {
- try
- {
- cbBannerMakeTransparent.Enabled = true;
- cbBannerMakeTransparent.Checked = lbxBannerTpls.SelectedItem.ToString().EndsWith("(Transparent)");
-
- string TplFile = BannerTplPath + lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- int TplFormat = Wii.TPL.GetTextureFormat(TplFile);
-
- switch (TplFormat)
- {
- case 0:
- cmbFormatBanner.SelectedIndex = 6;
- break;
- case 1:
- cmbFormatBanner.SelectedIndex = 5;
- break;
- case 2:
- cmbFormatBanner.SelectedIndex = 4;
- break;
- case 3:
- cmbFormatBanner.SelectedIndex = 3;
- break;
- case 4:
- cmbFormatBanner.SelectedIndex = 1;
- break;
- case 5:
- cmbFormatBanner.SelectedIndex = 2;
- break;
- case 6:
- cmbFormatBanner.SelectedIndex = 0;
- break;
- case 14:
- cmbFormatBanner.SelectedIndex = 7;
- break;
- default:
- cmbFormatBanner.SelectedIndex = -1;
- break;
- }
- }
- catch (Exception ex)
- {
- ErrorBox(ex.Message);
- }
- }
- else
- cbBannerMakeTransparent.Enabled = false;
- }
-
- private void lbxIconTpls_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (lbxIconTpls.SelectedIndex != -1)
- {
- try
- {
- cbIconMakeTransparent.Enabled = true;
- cbIconMakeTransparent.Checked = lbxIconTpls.SelectedItem.ToString().EndsWith("(Transparent)");
-
- string TplFile = IconTplPath + lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- int TplFormat = Wii.TPL.GetTextureFormat(TplFile);
-
- switch (TplFormat)
- {
- case 0:
- cmbFormatIcon.SelectedIndex = 6;
- break;
- case 1:
- cmbFormatIcon.SelectedIndex = 5;
- break;
- case 2:
- cmbFormatIcon.SelectedIndex = 4;
- break;
- case 3:
- cmbFormatIcon.SelectedIndex = 3;
- break;
- case 4:
- cmbFormatIcon.SelectedIndex = 1;
- break;
- case 5:
- cmbFormatIcon.SelectedIndex = 2;
- break;
- case 6:
- cmbFormatIcon.SelectedIndex = 0;
- break;
- case 14:
- cmbFormatIcon.SelectedIndex = 7;
- break;
- default:
- cmbFormatIcon.SelectedIndex = -1;
- break;
- }
- }
- catch (Exception ex)
- {
- ErrorBox(ex.Message);
- }
- }
- else
- cbIconMakeTransparent.Enabled = false;
- }
-
- private void btnReplaceBanner_Click(object sender, EventArgs e)
- {
- if (lbxBannerTpls.SelectedIndex != -1)
- {
- int Format = cmbFormatBanner.SelectedIndex;
-
- if (Format == 0 || Format == 1 || Format == 2)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Png|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TPL|*.tpl|All|*.png;*.jpg;*.gif;*.bmp;*.tpl";
- ofd.FilterIndex = 6;
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- try
- {
- string Tpl = BannerTplPath + lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- byte[] TplArray = Wii.Tools.LoadFileToByteArray(Tpl);
- Image Img;
-
- if (!ofd.FileName.EndsWith(".tpl")) Img = Image.FromFile(ofd.FileName);
- else Img = Wii.TPL.ConvertFromTPL(ofd.FileName);
-
- int TplFormat;
- int X = Wii.TPL.GetTextureWidth(TplArray);
- int Y = Wii.TPL.GetTextureHeight(TplArray);
-
- if (X != Img.Width ||
- Y != Img.Height)
- {
- Img = ResizeImage(Img, X, Y);
- }
-
- switch (Format)
- {
- case 1:
- TplFormat = 4;
- break;
- case 2:
- TplFormat = 5;
- break;
- default:
- TplFormat = 6;
- break;
- }
-
- Wii.TPL.ConvertToTPL(Img, Tpl, TplFormat);
- }
- catch (Exception ex)
- {
- ErrorBox(ex.Message);
- }
- }
- }
- else
- {
- ErrorBox("This format is not supported, you must choose either RGBA8, RGB565 or RGB5A3!");
- }
- }
- }
-
- private void btnExtractBanner_Click(object sender, EventArgs e)
- {
- if (lbxBannerTpls.SelectedIndex != -1)
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.Filter = "Png|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TPL|*.tpl|All|*.png;*.jpg;*.gif;*.bmp;*.tpl";
- sfd.FilterIndex = 6;
-
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- try
- {
- if (!sfd.FileName.EndsWith(".tpl"))
- {
- string Tpl = BannerTplPath + lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- Image Img = Wii.TPL.ConvertFromTPL(Tpl);
-
- switch (sfd.FileName.Remove(0, sfd.FileName.LastIndexOf('.')))
- {
- case ".jpg":
- Img.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
- break;
- case ".gif":
- Img.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Gif);
- break;
- case ".bmp":
- Img.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
- break;
- default:
- Img.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Png);
- break;
- }
- }
- else
- {
- string Tpl = BannerTplPath + lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- File.Copy(Tpl, sfd.FileName, true);
- }
- }
- catch (Exception ex)
- {
- ErrorBox(ex.Message);
- }
- }
- }
- }
-
- private void btnPreviewBanner_Click(object sender, EventArgs e)
- {
- if (lbxBannerTpls.SelectedIndex != -1)
- {
- try
- {
- string Tpl = BannerTplPath + lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- Image Img = Wii.TPL.ConvertFromTPL(Tpl);
-
- CustomizeMii_Preview pvw = new CustomizeMii_Preview();
-
- if (Img.Width > 200) pvw.Width = Img.Width + 50;
- else pvw.Width = 250;
- if (Img.Height > 200) pvw.Height = Img.Height + 50;
- else pvw.Height = 250;
-
- pvw.pbImage.Image = Img;
- pvw.Text = "CustomizeMii - Preview (" + Img.Width.ToString() + " x " + Img.Height.ToString() + ")";
-
- pvw.ShowDialog();
- }
- catch (Exception ex)
- {
- ErrorBox(ex.Message);
- }
- }
- }
-
- private void btnReplaceIcon_Click(object sender, EventArgs e)
- {
- if (lbxIconTpls.SelectedIndex != -1)
- {
- int Format = cmbFormatIcon.SelectedIndex;
-
- if (Format == 0 || Format == 1 || Format == 2)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Png|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TPL|*.tpl|All|*.png;*.jpg;*.gif;*.bmp;*.tpl";
- ofd.FilterIndex = 6;
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- try
- {
- string Tpl = IconTplPath + lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- byte[] TplArray = Wii.Tools.LoadFileToByteArray(Tpl);
- Image Img;
-
- if (!ofd.FileName.EndsWith(".tpl")) Img = Image.FromFile(ofd.FileName);
- else Img = Wii.TPL.ConvertFromTPL(ofd.FileName);
-
- int TplFormat;
- int X = Wii.TPL.GetTextureWidth(TplArray);
- int Y = Wii.TPL.GetTextureHeight(TplArray);
-
- if (X != Img.Width ||
- Y != Img.Height)
- {
- Img = ResizeImage(Img, X, Y);
- }
-
- switch (Format)
- {
- case 1:
- TplFormat = 4;
- break;
- case 2:
- TplFormat = 5;
- break;
- default:
- TplFormat = 6;
- break;
- }
-
- Wii.TPL.ConvertToTPL(Img, Tpl, TplFormat);
- }
- catch (Exception ex)
- {
- ErrorBox(ex.Message);
- }
- }
- }
- else
- {
- ErrorBox("This format is not supported, you must choose either RGBA8, RGB565 or RGB5A3!");
- }
- }
- }
-
- private void btnExtractIcon_Click(object sender, EventArgs e)
- {
- if (lbxIconTpls.SelectedIndex != -1)
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.Filter = "Png|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TPL|*.tpl|All|*.png;*.jpg;*.gif;*.bmp;*.tpl";
- sfd.FilterIndex = 6;
-
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- try
- {
- if (!sfd.FileName.EndsWith(".tpl"))
- {
- string Tpl = IconTplPath + lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- Image Img = Wii.TPL.ConvertFromTPL(Tpl);
-
- switch (sfd.FileName.Remove(0, sfd.FileName.LastIndexOf('.')))
- {
- case ".jpg":
- Img.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
- break;
- case ".gif":
- Img.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Gif);
- break;
- case ".bmp":
- Img.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
- break;
- default:
- Img.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Png);
- break;
- }
- }
- else
- {
- string Tpl = IconTplPath + lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- File.Copy(Tpl, sfd.FileName, true);
- }
- }
- catch (Exception ex)
- {
- ErrorBox(ex.Message);
- }
- }
- }
- }
-
- private void btnPreviewIcon_Click(object sender, EventArgs e)
- {
- if (lbxIconTpls.SelectedIndex != -1)
- {
- try
- {
- string Tpl = IconTplPath + lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- Image Img = Wii.TPL.ConvertFromTPL(Tpl);
-
- CustomizeMii_Preview pvw = new CustomizeMii_Preview();
-
- if (Img.Width > 200) pvw.Width = Img.Width + 50;
- else pvw.Width = 250;
- if (Img.Height > 200) pvw.Height = Img.Height + 50;
- else pvw.Height = 250;
-
- pvw.pbImage.Image = Img;
- pvw.Text = "CustomizeMii - Preview (" + Img.Width.ToString() + " x " + Img.Height.ToString() + ")";
-
- pvw.ShowDialog();
- }
- catch (Exception ex)
- {
- ErrorBox(ex.Message);
- }
- }
- }
-
- 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, ValidBrlans))
- {
- ErrorBox(thisBrlan + " is not a valid brlan filename!");
- return false;
- }
- }
- foreach (string thisBrlan in lbxBrlanIcon.Items)
- {
- if (!Wii.Tools.StringExistsInStringArray(thisBrlan, 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 = -1;
- if (!string.IsNullOrEmpty(tbSound.Text) && string.IsNullOrEmpty(SoundReplace))
- {
- soundlength = Wii.Sound.GetWaveLength(tbSound.Text);
- 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 != -1)
- {
- 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 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
- {
- //Check Unpack Root
- string[] RootFiles = Directory.GetFiles(TempUnpackPath);
- string[] RootDirs = Directory.GetDirectories(TempUnpackPath);
-
- foreach (string thisFile in RootFiles)
- {
- if (!thisFile.EndsWith(".app") &&
- !thisFile.EndsWith(".cert") &&
- !thisFile.EndsWith(".tik") &&
- !thisFile.EndsWith(".tmd"))
- File.Delete(thisFile);
- }
-
- if (RootDirs.Length > 1)
- {
- foreach (string thisDir in RootDirs)
- {
- if (!thisDir.EndsWith("00000000.app_OUT"))
- Directory.Delete(thisDir, true);
- }
- }
-
- //Check 00000000.app_OUT
- string[] MetaFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT");
- string[] MetaDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT");
-
- foreach (string thisFile in MetaFiles)
- File.Delete(thisFile);
- foreach (string thisDir in MetaDirs)
- if (!thisDir.EndsWith("meta"))
- Directory.Delete(thisDir, true);
-
- string[] AppFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta");
- string[] AppDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta");
-
- foreach (string thisFile in AppFiles)
- {
- if (!thisFile.EndsWith("banner.bin") &&
- !thisFile.EndsWith("icon.bin") &&
- !thisFile.EndsWith("sound.bin"))
- File.Delete(thisFile);
- }
-
- if (AppDirs.Length > 2)
- {
- foreach (string thisDir in AppDirs)
- {
- if (!thisDir.EndsWith("banner.bin_OUT") &&
- !thisDir.EndsWith("icon.bin_OUT"))
- Directory.Delete(thisDir, true);
- }
- }
-
- //Check banner.bin_OUT / Banner Replace Path
- if (string.IsNullOrEmpty(BannerReplace))
- {
- string[] ArcFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT");
- string[] ArcDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT");
-
- foreach (string thisFile in ArcFiles)
- File.Delete(thisFile);
- foreach (string thisDir in ArcDirs)
- if (!thisDir.EndsWith("arc"))
- Directory.Delete(thisDir, true);
-
- string[] BannerFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT\\arc");
- string[] BannerDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT\\arc");
-
- foreach (string thisFile in BannerFiles)
- File.Delete(thisFile);
-
- if (BannerDirs.Length > 3)
- {
- foreach (string thisDir in BannerDirs)
- {
- if (!thisDir.EndsWith("anim") &&
- !thisDir.EndsWith("blyt") &&
- !thisDir.EndsWith("timg"))
- Directory.Delete(thisDir, true);
- }
- }
-
- string[] AnimFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\anim");
- string[] AnimDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\anim");
-
- foreach (string thisFile in AnimFiles)
- {
- if (!thisFile.EndsWith(".brlan"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in AnimDirs)
- Directory.Delete(thisDir, true);
-
- string[] BlytFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\blyt");
- string[] BlytDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\blyt");
-
- foreach (string thisFile in BlytFiles)
- {
- if (!thisFile.EndsWith(".brlyt"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in BlytDirs)
- Directory.Delete(thisDir, true);
-
- string[] TimgFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\timg");
- string[] TimgDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT\\arc\\timg");
-
- foreach (string thisFile in TimgFiles)
- {
- if (!thisFile.EndsWith(".tpl"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in TimgDirs)
- Directory.Delete(thisDir, true);
- }
- else
- {
- string[] ArcFiles = Directory.GetFiles(TempBannerPath);
- string[] ArcDirs = Directory.GetDirectories(TempBannerPath);
-
- foreach (string thisFile in ArcFiles)
- File.Delete(thisFile);
- foreach (string thisDir in ArcDirs)
- if (!thisDir.EndsWith("arc"))
- Directory.Delete(thisDir, true);
-
- string[] BannerFiles = Directory.GetFiles(TempBannerPath + "arc");
- string[] BannerDirs = Directory.GetDirectories(TempBannerPath + "arc");
-
- foreach (string thisFile in BannerFiles)
- File.Delete(thisFile);
-
- if (BannerDirs.Length > 3)
- {
- foreach (string thisDir in BannerDirs)
- {
- if (!thisDir.EndsWith("anim") &&
- !thisDir.EndsWith("blyt") &&
- !thisDir.EndsWith("timg"))
- Directory.Delete(thisDir, true);
- }
- }
-
- string[] AnimFiles = Directory.GetFiles(TempBannerPath + "arc\\anim");
- string[] AnimDirs = Directory.GetDirectories(TempBannerPath + "arc\\anim");
-
- foreach (string thisFile in AnimFiles)
- {
- if (!thisFile.EndsWith(".brlan"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in AnimDirs)
- Directory.Delete(thisDir, true);
-
- string[] BlytFiles = Directory.GetFiles(TempBannerPath + "arc\\blyt");
- string[] BlytDirs = Directory.GetDirectories(TempBannerPath + "arc\\blyt");
-
- foreach (string thisFile in BlytFiles)
- {
- if (!thisFile.EndsWith(".brlyt"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in BlytDirs)
- Directory.Delete(thisDir, true);
-
- string[] TimgFiles = Directory.GetFiles(TempBannerPath + "arc\\timg");
- string[] TimgDirs = Directory.GetDirectories(TempBannerPath + "arc\\timg");
-
- foreach (string thisFile in TimgFiles)
- {
- if (!thisFile.EndsWith(".tpl"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in TimgDirs)
- Directory.Delete(thisDir, true);
- }
-
- //Check icon.bin_OUT / Icon Replace Path
- if (string.IsNullOrEmpty(IconReplace))
- {
- string[] ArcFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT");
- string[] ArcDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT");
-
- foreach (string thisFile in ArcFiles)
- File.Delete(thisFile);
- foreach (string thisDir in ArcDirs)
- if (!thisDir.EndsWith("arc"))
- Directory.Delete(thisDir, true);
-
- string[] IconFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT\\arc");
- string[] IconDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT\\arc");
-
- foreach (string thisFile in IconFiles)
- File.Delete(thisFile);
-
- if (IconDirs.Length > 3)
- {
- foreach (string thisDir in IconDirs)
- {
- if (!thisDir.EndsWith("anim") &&
- !thisDir.EndsWith("blyt") &&
- !thisDir.EndsWith("timg"))
- Directory.Delete(thisDir, true);
- }
- }
-
- string[] AnimFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\anim");
- string[] AnimDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\anim");
-
- foreach (string thisFile in AnimFiles)
- {
- if (!thisFile.EndsWith(".brlan"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in AnimDirs)
- Directory.Delete(thisDir, true);
-
- string[] BlytFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\blyt");
- string[] BlytDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\blyt");
-
- foreach (string thisFile in BlytFiles)
- {
- if (!thisFile.EndsWith(".brlyt"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in BlytDirs)
- Directory.Delete(thisDir, true);
-
- string[] TimgFiles = Directory.GetFiles(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\timg");
- string[] TimgDirs = Directory.GetDirectories(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT\\arc\\timg");
-
- foreach (string thisFile in TimgFiles)
- {
- if (!thisFile.EndsWith(".tpl"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in TimgDirs)
- Directory.Delete(thisDir, true);
- }
- else
- {
- string[] ArcFiles = Directory.GetFiles(TempIconPath);
- string[] ArcDirs = Directory.GetDirectories(TempIconPath);
-
- foreach (string thisFile in ArcFiles)
- File.Delete(thisFile);
- foreach (string thisDir in ArcDirs)
- if (!thisDir.EndsWith("arc"))
- Directory.Delete(thisDir, true);
-
- string[] IconFiles = Directory.GetFiles(TempIconPath + "arc");
- string[] IconDirs = Directory.GetDirectories(TempIconPath + "arc");
-
- foreach (string thisFile in IconFiles)
- File.Delete(thisFile);
-
- if (IconDirs.Length > 3)
- {
- foreach (string thisDir in IconDirs)
- {
- if (!thisDir.EndsWith("anim") &&
- !thisDir.EndsWith("blyt") &&
- !thisDir.EndsWith("timg"))
- Directory.Delete(thisDir, true);
- }
- }
-
- string[] AnimFiles = Directory.GetFiles(TempIconPath + "arc\\anim");
- string[] AnimDirs = Directory.GetDirectories(TempIconPath + "arc\\anim");
-
- foreach (string thisFile in AnimFiles)
- {
- if (!thisFile.EndsWith(".brlan"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in AnimDirs)
- Directory.Delete(thisDir, true);
-
- string[] BlytFiles = Directory.GetFiles(TempIconPath + "arc\\blyt");
- string[] BlytDirs = Directory.GetDirectories(TempIconPath + "arc\\blyt");
-
- foreach (string thisFile in BlytFiles)
- {
- if (!thisFile.EndsWith(".brlyt"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in BlytDirs)
- Directory.Delete(thisDir, true);
-
- string[] TimgFiles = Directory.GetFiles(TempIconPath + "arc\\timg");
- string[] TimgDirs = Directory.GetDirectories(TempIconPath + "arc\\timg");
-
- foreach (string thisFile in TimgFiles)
- {
- if (!thisFile.EndsWith(".tpl"))
- File.Delete(thisFile);
- }
-
- foreach (string thisDir in TimgDirs)
- Directory.Delete(thisDir, true);
- }
-
- return true;
- }
- catch (Exception ex) { ErrorBox(ex.Message); return false; }
- }
-
- private void btnCreateWad_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(tbSourceWad.Text))
- {
- if (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();
- 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(sfd.FileName);
- }
- catch (Exception ex)
- {
- CreationTimer.Stop();
- ErrorBox(ex.Message);
- }
- }
- }
- }
- }
-
- void bwCreateWad_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- EventHandler EnableControls = new EventHandler(this.EnableControls);
- EventHandler Initialize = new EventHandler(this.Initialize);
- pbProgress.Value = 100;
- lbStatusText.Text = string.Empty;
- this.Invoke(EnableControls);
- this.Invoke(Initialize);
- }
-
- void bwCreateWad_ProgressChanged(object sender, ProgressChangedEventArgs e)
- {
- ProgressValue = e.ProgressPercentage;
- ProgressState = (string)e.UserState;
-
- this.Invoke(ProgressUpdate);
- }
-
- void bwCreateWad_DoWork(object sender, DoWorkEventArgs e)
- {
- try
- {
- BackgroundWorker bwCreateWad = sender as BackgroundWorker;
- EventHandler DisableControls = new EventHandler(this.DisableControls);
- this.Invoke(DisableControls);
-
- bwCreateWad.ReportProgress(0, "Making TPLs transparent");
- MakeBannerTplsTransparent();
- MakeIconTplsTransparent();
-
- bwCreateWad.ReportProgress(5, "Packing icon.bin...");
- byte[] iconbin;
-
- if (!string.IsNullOrEmpty(IconReplace))
- iconbin = Wii.U8.PackU8(TempIconPath);
- else
- iconbin = Wii.U8.PackU8(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT");
-
- if (cbLz77.Checked == true) iconbin = Wii.Lz77.Compress(iconbin);
- iconbin = Wii.U8.AddHeaderIMD5(iconbin);
- Wii.Tools.SaveFileFromByteArray(iconbin, TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin");
- Directory.Delete(TempUnpackPath + "00000000.app_OUT\\meta\\icon.bin_OUT", true);
-
- bwCreateWad.ReportProgress(25, "Packing banner.bin...");
- byte[] bannerbin;
-
- if (!string.IsNullOrEmpty(BannerReplace))
- bannerbin = Wii.U8.PackU8(TempBannerPath);
- else
- bannerbin = Wii.U8.PackU8(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT");
-
- if (cbLz77.Checked == true) bannerbin = Wii.Lz77.Compress(bannerbin);
- bannerbin = Wii.U8.AddHeaderIMD5(bannerbin);
- Wii.Tools.SaveFileFromByteArray(bannerbin, TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin");
- Directory.Delete(TempUnpackPath + "00000000.app_OUT\\meta\\banner.bin_OUT", true);
-
- if (!string.IsNullOrEmpty(SoundReplace) || !string.IsNullOrEmpty(tbSound.Text))
- {
- bwCreateWad.ReportProgress(50, "Packing sound.bin...");
-
- if (!string.IsNullOrEmpty(SoundReplace))
- {
- File.Delete(TempUnpackPath + "00000000.app_OUT\\meta\\sound.bin");
- File.Copy(TempSoundPath, TempUnpackPath + "00000000.app_OUT\\meta\\sound.bin");
- }
- else if (!string.IsNullOrEmpty(tbSound.Text))
- {
- Wii.Sound.WaveToSoundBin(tbSound.Text, TempUnpackPath + "00000000.app_OUT\\meta\\sound.bin", cbLz77.Checked);
- }
- }
-
- bwCreateWad.ReportProgress(60, "Packing 00000000.app...");
- int[] Sizes = new int[3];
- string[] Titles = new string[] { tbJapanese.Text, tbEnglish.Text, tbGerman.Text, tbFrench.Text, tbSpanish.Text, tbItalian.Text, tbDutch.Text };
-
- for (int i = 0; i < Titles.Length; i++)
- if (string.IsNullOrEmpty(Titles[i])) Titles[i] = tbAllLanguages.Text;
-
- byte[] nullapp = Wii.U8.PackU8(TempUnpackPath + "00000000.app_OUT", out Sizes[0], out Sizes[1], out Sizes[2]);
- nullapp = Wii.U8.AddHeaderIMET(nullapp, Titles, Sizes);
- Wii.Tools.SaveFileFromByteArray(nullapp, TempUnpackPath + "00000000.app");
- Directory.Delete(TempUnpackPath + "00000000.app_OUT", true);
-
- string[] tikfile = Directory.GetFiles(TempUnpackPath, "*.tik");
- string[] tmdfile = Directory.GetFiles(TempUnpackPath, "*.tmd");
- byte[] tmd = Wii.Tools.LoadFileToByteArray(tmdfile[0]);
-
- if (!string.IsNullOrEmpty(tbDol.Text))
- {
- bwCreateWad.ReportProgress(80, "Inserting new DOL...");
- string[] AppFiles = Directory.GetFiles(TempUnpackPath, "*.app");
-
- foreach (string thisApp in AppFiles)
- if (!thisApp.EndsWith("00000000.app")) File.Delete(thisApp);
-
- if (NandLoader == 0)
- {
- using (BinaryReader nandloader = new BinaryReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CustomizeMii.Resources.comex.app")))
- {
- using (FileStream fs = new FileStream(TempUnpackPath + "\\00000001.app", FileMode.Create))
- {
- byte[] temp = nandloader.ReadBytes((int)nandloader.BaseStream.Length);
- fs.Write(temp, 0, temp.Length);
- }
- }
-
- File.Copy(tbDol.Text, TempUnpackPath + "\\00000002.app");
- tmd = Wii.WadEdit.ChangeTmdBootIndex(tmd, 1);
- }
- else
- {
- using (BinaryReader nandloader = new BinaryReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CustomizeMii.Resources.Waninkoko.app")))
- {
- using (FileStream fs = new FileStream(TempUnpackPath + "\\00000002.app", FileMode.Create))
- {
- byte[] temp = nandloader.ReadBytes((int)nandloader.BaseStream.Length);
- fs.Write(temp, 0, temp.Length);
- }
- }
-
- File.Copy(tbDol.Text, TempUnpackPath + "\\00000001.app");
- tmd = Wii.WadEdit.ChangeTmdBootIndex(tmd, 2);
- }
-
- tmd = Wii.WadEdit.ChangeTmdContentCount(tmd, 3);
-
- bwCreateWad.ReportProgress(80, "Updating TMD...");
- File.Delete(tmdfile[0]);
- using (FileStream fs = new FileStream(tmdfile[0], FileMode.Create))
- {
- byte[] tmdconts = new byte[108];
- tmdconts[7] = 0x01;
- tmdconts[39] = 0x01;
- tmdconts[41] = 0x01;
- tmdconts[43] = 0x01;
- tmdconts[75] = 0x02;
- tmdconts[77] = 0x02;
- tmdconts[79] = 0x01;
-
- fs.Write(tmd, 0, 484);
- fs.Write(tmdconts, 0, tmdconts.Length);
- }
- }
-
- bwCreateWad.ReportProgress(85, "Updating TMD...");
- Wii.WadEdit.UpdateTmdContents(tmdfile[0]);
-
- Wii.WadEdit.ChangeTitleID(tikfile[0], 0, tbTitleID.Text.ToUpper());
- Wii.WadEdit.ChangeTitleID(tmdfile[0], 1, tbTitleID.Text.ToUpper());
-
- bwCreateWad.ReportProgress(90, "Trucha Signing...");
- Wii.WadEdit.TruchaSign(tmdfile[0], 1);
- Wii.WadEdit.TruchaSign(tikfile[0], 0);
-
- bwCreateWad.ReportProgress(95, "Packing WAD...");
- if (File.Exists((string)e.Argument)) File.Delete((string)e.Argument);
- Wii.WadPack.PackWad(TempUnpackPath, (string)e.Argument, false);
-
- bwCreateWad.ReportProgress(100, " ");
- CreationTimer.Stop();
- InfoBox(string.Format("Successfully created custom channel!\nTime elapsed: {0} ms", CreationTimer.ElapsedMilliseconds));
- }
- catch (Exception ex)
- {
- CreationTimer.Stop();
- EventHandler EnableControls = new EventHandler(this.EnableControls);
- this.Invoke(EnableControls);
- ErrorBox(ex.Message);
- }
- }
-
- private void lbxBrlytBanner_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (lbxBrlytBanner.SelectedIndex != -1)
- lbxBrlytIcon.SelectedIndex = -1;
-
- if (lbxBrlytIcon.SelectedIndex == -1)
- lbBrlytActions.Text = "Banner";
- else
- lbBrlytActions.Text = "Icon";
- }
-
- private void lbxBrlytIcon_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (lbxBrlytIcon.SelectedIndex != -1)
- lbxBrlytBanner.SelectedIndex = -1;
-
- if (lbxBrlytIcon.SelectedIndex == -1)
- lbBrlytActions.Text = "Banner";
- else
- lbBrlytActions.Text = "Icon";
- }
-
- private void lbxBrlanBanner_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (lbxBrlanBanner.SelectedIndex != -1)
- lbxBrlanIcon.SelectedIndex = -1;
-
- if (lbxBrlanIcon.SelectedIndex == -1)
- lbBrlanActions.Text = "Banner";
- else
- lbBrlanActions.Text = "Icon";
- }
-
- private void lbxBrlanIcon_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (lbxBrlanIcon.SelectedIndex != -1)
- lbxBrlanBanner.SelectedIndex = -1;
-
- if (lbxBrlanIcon.SelectedIndex == -1)
- lbBrlanActions.Text = "Banner";
- else
- lbBrlanActions.Text = "Icon";
- }
-
- //private void btnBrlytAdd_Click(object sender, EventArgs e)
- //{
- // if (!string.IsNullOrEmpty(lbBrlytActions.Text))
- // {
- // OpenFileDialog ofd = new OpenFileDialog();
- // ofd.Filter = "brlyt Files|*.brlyt";
-
- // if (ofd.ShowDialog() == DialogResult.OK)
- // {
- // try
- // {
- // bool Exists = false;
-
- // if (lbBrlytActions.Text == "Banner")
- // {
- // for (int i = 0; i < lbxBrlytBanner.Items.Count; i++)
- // if (lbxBrlytBanner.Items[i].ToString() == ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1))
- // Exists = true;
-
- // if (Exists == true)
- // ErrorBox("This file already exists, use the Replace button!");
- // else
- // {
- // if (string.IsNullOrEmpty(BannerReplace))
- // File.Copy(ofd.FileName, TempUnpackBannerBrlytPath + ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- // else
- // File.Copy(ofd.FileName, BannerBrlytPath + ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- // lbxBrlytBanner.Items.Add(ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- // BrlytChanged = true;
- // }
- // }
- // else
- // {
- // for (int i = 0; i < lbxBrlytIcon.Items.Count; i++)
- // if (lbxBrlytIcon.Items[i].ToString() == ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1))
- // Exists = true;
-
- // if (Exists == true)
- // ErrorBox("This file already exists, use the Replace button!");
- // else
- // {
- // if (string.IsNullOrEmpty(IconReplace))
- // File.Copy(ofd.FileName, TempUnpackIconBrlytPath + ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- // else
- // File.Copy(ofd.FileName, IconBrlytPath + ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- // lbxBrlytIcon.Items.Add(ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- // BrlytChanged = true;
- // }
- // }
- // }
- // catch (Exception ex) { ErrorBox(ex.Message); }
- // }
- // }
- //}
-
- private void btnBrlanAdd_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(lbBrlanActions.Text))
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "brlan Files|*.brlan";
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- try
- {
- bool Exists = false;
-
- if (lbBrlanActions.Text == "Banner")
- {
- for (int i = 0; i < lbxBrlanBanner.Items.Count; i++)
- if (lbxBrlanBanner.Items[i].ToString() == ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1))
- Exists = true;
-
- if (Exists == true)
- ErrorBox("This file already exists, use the Replace button!");
- else
- {
- if (string.IsNullOrEmpty(BannerReplace))
- File.Copy(ofd.FileName, TempUnpackBannerBrlanPath + ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- else
- File.Copy(ofd.FileName, BannerBrlanPath + ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- lbxBrlanBanner.Items.Add(ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- BrlanChanged = true;
- }
- }
- else
- {
- for (int i = 0; i < lbxBrlanIcon.Items.Count; i++)
- if (lbxBrlanIcon.Items[i].ToString() == ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1))
- Exists = true;
-
- if (Exists == true)
- ErrorBox("This file already exists, use the Replace button!");
- else
- {
- if (string.IsNullOrEmpty(IconReplace))
- File.Copy(ofd.FileName, TempUnpackIconBrlanPath + ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- else
- File.Copy(ofd.FileName, IconBrlanPath + ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- lbxBrlanIcon.Items.Add(ofd.FileName.Remove(0, ofd.FileName.LastIndexOf('\\') + 1));
- BrlanChanged = true;
- }
- }
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
- }
- }
-
- private void btnBrlytExtract_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(lbBrlytActions.Text))
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.Filter = "brlyt Files|*.brlyt";
-
- if (lbBrlytActions.Text == "Banner")
- sfd.FileName = lbxBrlytBanner.SelectedItem.ToString();
- else
- sfd.FileName = lbxBrlytIcon.SelectedItem.ToString();
-
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- try
- {
- string brlytFile;
-
- if (lbBrlytActions.Text == "Banner")
- {
- if (string.IsNullOrEmpty(BannerReplace))
- brlytFile = TempUnpackBannerBrlytPath + lbxBrlytBanner.SelectedItem.ToString();
- else
- brlytFile = BannerBrlytPath + lbxBrlytBanner.Items.ToString();
- }
- else
- {
- if (string.IsNullOrEmpty(IconReplace))
- brlytFile = TempUnpackIconBrlytPath + lbxBrlytIcon.SelectedItem.ToString();
- else
- brlytFile = IconBrlytPath + lbxBrlytIcon.Items.ToString();
- }
-
- File.Copy(brlytFile, sfd.FileName);
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
- }
- }
-
- private void btnBrlanExtract_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(lbBrlanActions.Text))
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.Filter = "brlan Files|*.brlan";
-
- if (lbBrlanActions.Text == "Banner")
- sfd.FileName = lbxBrlanBanner.SelectedItem.ToString();
- else
- sfd.FileName = lbxBrlanIcon.SelectedItem.ToString();
-
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- try
- {
- string brlanFile;
-
- if (lbBrlanActions.Text == "Banner")
- {
- if (string.IsNullOrEmpty(BannerReplace))
- brlanFile = TempUnpackBannerBrlanPath + lbxBrlanBanner.SelectedItem.ToString();
- else
- brlanFile = BannerBrlanPath + lbxBrlanBanner.Items.ToString();
- }
- else
- {
- if (string.IsNullOrEmpty(IconReplace))
- brlanFile = TempUnpackIconBrlanPath + lbxBrlanIcon.SelectedItem.ToString();
- else
- brlanFile = IconBrlanPath + lbxBrlanIcon.Items.ToString();
- }
-
- File.Copy(brlanFile, sfd.FileName);
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
- }
- }
-
- //private void btnBrlytDelete_Click(object sender, EventArgs e)
- //{
- // if (!string.IsNullOrEmpty(lbBrlytActions.Text))
- // {
- // try
- // {
- // string brlytFile;
-
- // if (lbBrlytActions.Text == "Banner")
- // {
- // if (lbxBrlytBanner.Items.Count > 1)
- // {
- // if (string.IsNullOrEmpty(BannerReplace))
- // brlytFile = TempUnpackBannerBrlytPath + lbxBrlytBanner.SelectedItem.ToString();
- // else
- // brlytFile = BannerBrlytPath + lbxBrlytBanner.SelectedItem.ToString();
-
- // lbxBrlytBanner.Items.Remove(lbxBrlytBanner.SelectedItem);
- // File.Delete(brlytFile);
- // BrlytChanged = true;
- // }
- // else
- // {
- // ErrorBox("You can't delete the last file.\nAdd a new one first in order to delete this one.");
- // }
- // }
- // else
- // {
- // if (lbxBrlytIcon.Items.Count > 1)
- // {
- // if (string.IsNullOrEmpty(IconReplace))
- // brlytFile = TempUnpackIconBrlytPath + lbxBrlytIcon.SelectedItem.ToString();
- // else
- // brlytFile = IconBrlytPath + lbxBrlytIcon.SelectedItem.ToString();
-
- // lbxBrlytIcon.Items.Remove(lbxBrlytIcon.SelectedItem);
- // File.Delete(brlytFile);
- // BrlytChanged = true;
- // }
- // else
- // {
- // ErrorBox("You can't delete the last file.\nAdd a new one first in order to delete this one.");
- // }
- // }
- // }
- // catch { }
- // }
- //}
-
- private void btnBrlanDelete_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(lbBrlanActions.Text))
- {
- try
- {
- string brlanFile;
-
- if (lbBrlanActions.Text == "Banner")
- {
- if (lbxBrlanBanner.Items.Count > 1)
- {
- if (string.IsNullOrEmpty(BannerReplace))
- brlanFile = TempUnpackBannerBrlanPath + lbxBrlanBanner.SelectedItem.ToString();
- else
- brlanFile = BannerBrlanPath + lbxBrlanBanner.SelectedItem.ToString();
-
- lbxBrlanBanner.Items.Remove(lbxBrlanBanner.SelectedItem);
- File.Delete(brlanFile);
- BrlanChanged = true;
- }
- else
- {
- ErrorBox("You can't delete the last file.\nAdd a new one first in order to delete this one.");
- }
- }
- else
- {
- if (lbxBrlanIcon.Items.Count > 1)
- {
- if (string.IsNullOrEmpty(IconReplace))
- brlanFile = TempUnpackIconBrlanPath + lbxBrlanIcon.SelectedItem.ToString();
- else
- brlanFile = IconBrlanPath + lbxBrlanIcon.SelectedItem.ToString();
-
- lbxBrlanIcon.Items.Remove(lbxBrlanIcon.SelectedItem);
- File.Delete(brlanFile);
- BrlanChanged = true;
- }
- else
- {
- ErrorBox("You can't delete the last file.\nAdd a new one first in order to delete this one.");
- }
- }
- }
- catch { }
- }
- }
-
- private void btnBrlytReplace_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(lbBrlytActions.Text))
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "brlyt Files|*.brlyt";
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- try
- {
- if (lbBrlytActions.Text == "Banner")
- {
- if (string.IsNullOrEmpty(BannerReplace))
- {
- File.Delete(TempUnpackBannerBrlytPath + lbxBrlytBanner.SelectedItem.ToString());
- File.Copy(ofd.FileName, TempUnpackBannerBrlytPath + lbxBrlytBanner.SelectedItem.ToString());
- BrlytChanged = true;
- }
- else
- {
- File.Delete(BannerBrlytPath + lbxBrlytBanner.SelectedItem.ToString());
- File.Copy(ofd.FileName, BannerBrlytPath + lbxBrlytBanner.SelectedItem.ToString());
- BrlytChanged = true;
- }
- }
- else
- {
- if (string.IsNullOrEmpty(IconReplace))
- {
- File.Delete(TempUnpackIconBrlytPath + lbxBrlytIcon.SelectedItem.ToString());
- File.Copy(ofd.FileName, TempUnpackIconBrlytPath + lbxBrlytIcon.SelectedItem.ToString());
- BrlytChanged = true;
- }
- else
- {
- File.Delete(IconBrlytPath + lbxBrlytIcon.SelectedItem.ToString());
- File.Copy(ofd.FileName, IconBrlytPath + lbxBrlytIcon.SelectedItem.ToString());
- BrlytChanged = true;
- }
- }
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
- }
- }
-
- private void btnBrlanReplace_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(lbBrlanActions.Text))
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "brlan Files|*.brlan";
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- try
- {
- if (lbBrlanActions.Text == "Banner")
- {
- if (string.IsNullOrEmpty(BannerReplace))
- {
- File.Delete(TempUnpackBannerBrlanPath + lbxBrlanBanner.SelectedItem.ToString());
- File.Copy(ofd.FileName, TempUnpackBannerBrlanPath + lbxBrlanBanner.SelectedItem.ToString());
- BrlanChanged = true;
- }
- else
- {
- File.Delete(BannerBrlanPath + lbxBrlanBanner.SelectedItem.ToString());
- File.Copy(ofd.FileName, BannerBrlanPath + lbxBrlanBanner.SelectedItem.ToString());
- BrlanChanged = true;
- }
- }
- else
- {
- if (string.IsNullOrEmpty(IconReplace))
- {
- File.Delete(TempUnpackIconBrlanPath + lbxBrlanIcon.SelectedItem.ToString());
- File.Copy(ofd.FileName, TempUnpackIconBrlanPath + lbxBrlanIcon.SelectedItem.ToString());
- BrlanChanged = true;
- }
- else
- {
- File.Delete(IconBrlanPath + lbxBrlanIcon.SelectedItem.ToString());
- File.Copy(ofd.FileName, IconBrlanPath + lbxBrlanIcon.SelectedItem.ToString());
- BrlanChanged = true;
- }
- }
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
- }
- }
-
- private void llbUpdateAvailabe_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- try
- {
- llbUpdateAvailabe.LinkVisited = true;
- Process.Start("http://code.google.com/p/customizemii/downloads/list");
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
-
- private void btnDeleteBanner_Click(object sender, EventArgs e)
- {
- try
- {
- string TplName = lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- string CurBannerPath = GetCurBannerPath();
- string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurBannerPath + "blyt\\banner.brlyt");
-
- if (!Wii.Tools.StringExistsInStringArray(TplName, brlytTpls))
- {
- File.Delete(CurBannerPath + "timg\\" + TplName);
- lbxBannerTpls.Items.Remove(lbxBannerTpls.SelectedItem);
- }
- else
- {
- ErrorBox("This TPL is required by your banner.brlyt and thus can't be deleted!\nYou can still replace the image using the Replace button!");
- }
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
-
- private void btnDeleteIcon_Click(object sender, EventArgs e)
- {
- try
- {
- string TplName = lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- string CurIconPath = GetCurIconPath();
-
- string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurIconPath + "blyt\\icon.brlyt");
-
- if (!Wii.Tools.StringExistsInStringArray(TplName, brlytTpls))
- {
- File.Delete(CurIconPath + "timg\\" + TplName);
- lbxIconTpls.Items.Remove(lbxIconTpls.SelectedItem);
- }
- else
- {
- ErrorBox("This TPL is required by your icon.brlyt and thus can't be deleted!\nYou can still replace the image using the Replace button!");
- }
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
-
- private void btnAddBanner_Click(object sender, EventArgs e)
- {
- try
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "TPL|*.tpl|PNG|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|All|*.tpl;*.png;*.jpg;*.gif;*.bmp";
- ofd.FilterIndex = 6;
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- for (int i = 0; i < lbxBannerTpls.Items.Count; i++)
- {
- if (lbxBannerTpls.Items[i].ToString().ToLower() == Path.GetFileNameWithoutExtension(ofd.FileName).ToLower() + ".tpl")
- {
- ErrorBox("This TPL already exists, use the Replace button");
- return;
- }
- }
-
- string CurBannerPath = GetCurBannerPath();
- string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurBannerPath + "blyt\\banner.brlyt");
- string TplName = Path.GetFileNameWithoutExtension(ofd.FileName) + ".tpl";
- int TplFormat = 6;
-
- switch (cmbFormatBanner.SelectedIndex)
- {
- case 0:
- TplFormat = 6;
- break;
- case 1:
- TplFormat = 4;
- break;
- case 2:
- TplFormat = 5;
- break;
- default:
- if (!ofd.FileName.EndsWith(".tpl"))
- {
- ErrorBox("This format is not supported, you must choose either RGBA8, RGB565 or RGB5A3!");
- return;
- }
- break;
- }
-
- if (!Wii.Tools.StringExistsInStringArray(TplName, brlytTpls))
- {
- if (MessageBox.Show("This TPL is not required by your banner.brlyt and thus only wastes memory!\nDo you still want to add it?", "TPL not required", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
- return;
- }
-
- if (ofd.FileName.EndsWith(".tpl"))
- {
- File.Copy(ofd.FileName, CurBannerPath + "timg\\" + TplName);
- lbxBannerTpls.Items.Add(TplName);
- }
- else
- {
- Image img = Image.FromFile(ofd.FileName);
- Wii.TPL.ConvertToTPL(img, CurBannerPath + "timg\\" + TplName, TplFormat);
- lbxBannerTpls.Items.Add(TplName);
- }
- }
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
-
- private void btnAddIcon_Click(object sender, EventArgs e)
- {
- try
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "TPL|*.tpl|PNG|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|All|*.tpl;*.png;*.jpg;*.gif;*.bmp";
- ofd.FilterIndex = 6;
-
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- for (int i = 0; i < lbxIconTpls.Items.Count; i++)
- {
- if (lbxIconTpls.Items[i].ToString().ToLower() == Path.GetFileNameWithoutExtension(ofd.FileName).ToLower() + ".tpl")
- {
- ErrorBox("This TPL already exists, use the Replace button");
- return;
- }
- }
-
- string CuriconPath = GetCurIconPath();
- string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CuriconPath + "blyt\\icon.brlyt");
- string TplName = Path.GetFileNameWithoutExtension(ofd.FileName) + ".tpl";
- int TplFormat = 6;
-
- switch (cmbFormatIcon.SelectedIndex)
- {
- case 0:
- TplFormat = 6;
- break;
- case 1:
- TplFormat = 4;
- break;
- case 2:
- TplFormat = 5;
- break;
- default:
- if (!ofd.FileName.EndsWith(".tpl"))
- {
- ErrorBox("This format is not supported, you must choose either RGBA8, RGB565 or RGB5A3!");
- return;
- }
- break;
- }
-
- if (!Wii.Tools.StringExistsInStringArray(TplName, brlytTpls))
- {
- if (MessageBox.Show("This TPL is not required by your icon.brlyt and thus only wastes memory!\nDo you still want to add it?", "TPL not required", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
- return;
- }
-
- if (ofd.FileName.EndsWith(".tpl"))
- {
- File.Copy(ofd.FileName, CuriconPath + "timg\\" + TplName);
- lbxIconTpls.Items.Add(TplName);
- }
- else
- {
- Image img = Image.FromFile(ofd.FileName);
- Wii.TPL.ConvertToTPL(img, CuriconPath + "timg\\" + TplName, TplFormat);
- lbxIconTpls.Items.Add(TplName);
- }
- }
- }
- catch (Exception ex) { ErrorBox(ex.Message); }
- }
-
- private void btnBrlytListTpls_Click(object sender, EventArgs e)
- {
- if (lbBrlytActions.Text == "Banner")
- {
- string CurBannerPath = GetCurBannerPath();
- string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurBannerPath + "blyt\\banner.brlyt");
-
- MessageBox.Show("These are the TPLs required by your banner.brlyt:\n\n" +
- string.Join("\n", brlytTpls), "TPLs specified in banner.brlyt", MessageBoxButtons.OK,
- MessageBoxIcon.Information);
- }
- else
- {
- string CurIconPath = GetCurIconPath();
- string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurIconPath + "blyt\\icon.brlyt");
-
- MessageBox.Show("These are the TPLs required by your icon.brlyt:\n\n" +
- string.Join("\n", brlytTpls), "TPLs specified in icon.brlyt", MessageBoxButtons.OK,
- MessageBoxIcon.Information);
- }
- }
-
- private void cbBannerMakeTransparent_CheckedChanged(object sender, EventArgs e)
- {
- if (lbxBannerTpls.SelectedIndex != -1)
- {
- if (cbBannerMakeTransparent.Checked == true)
- {
- try
- {
- if (!lbxBannerTpls.SelectedItem.ToString().EndsWith("(Transparent)"))
- {
- string thisItem = lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- lbxBannerTpls.Items.Remove(lbxBannerTpls.SelectedItem);
- lbxBannerTpls.Items.Add(thisItem + " (Transparent)");
- lbxBannerTpls.SelectedItem = thisItem + " (Transparent)";
- Transparents.Add(thisItem);
- }
- }
- catch { }
- }
- else
- {
- try
- {
- string thisItem = lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- lbxBannerTpls.Items.Remove(lbxBannerTpls.SelectedItem);
- lbxBannerTpls.Items.Add(thisItem.Replace(" (Transparent)", string.Empty));
- lbxBannerTpls.SelectedItem = thisItem.Replace(" (Transparent)", string.Empty);
- Transparents.Remove(thisItem.Replace(" (Transparent)", string.Empty));
- }
- catch { }
- }
- }
- }
-
- private void cbIconMakeTransparent_CheckedChanged(object sender, EventArgs e)
- {
- if (lbxIconTpls.SelectedIndex != -1)
- {
- if (cbIconMakeTransparent.Checked == true)
- {
- try
- {
- if (!lbxIconTpls.SelectedItem.ToString().EndsWith("(Transparent)"))
- {
- string thisItem = lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- lbxIconTpls.Items.Remove(lbxIconTpls.SelectedItem);
- lbxIconTpls.Items.Add(thisItem + " (Transparent)");
- lbxIconTpls.SelectedItem = thisItem + " (Transparent)";
- Transparents.Add(thisItem);
- }
- }
- catch { }
- }
- else
- {
- try
- {
- string thisItem = lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
- lbxIconTpls.Items.Remove(lbxIconTpls.SelectedItem);
- lbxIconTpls.Items.Add(thisItem.Replace(" (Transparent)", string.Empty));
- lbxIconTpls.SelectedItem = thisItem.Replace(" (Transparent)", string.Empty);
- Transparents.Remove(thisItem.Replace(" (Transparent)", string.Empty));
- }
- catch { }
- }
- }
- }
- }
-}
diff --git a/CustomizeMii/CustomizeMii_Main.resx b/CustomizeMii/CustomizeMii_Main.resx
deleted file mode 100644
index edd5a76..0000000
--- a/CustomizeMii/CustomizeMii_Main.resx
+++ /dev/null
@@ -1,134 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- Thanks:
-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
-
-
- 16, 7
-
-
- 42
-
-
\ No newline at end of file
diff --git a/CustomizeMii/CustomizeMii_Preview.Designer.cs b/CustomizeMii/CustomizeMii_Preview.Designer.cs
deleted file mode 100644
index 3a53663..0000000
--- a/CustomizeMii/CustomizeMii_Preview.Designer.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-/* 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
-{
- partial class CustomizeMii_Preview
- {
- ///
- /// Erforderliche Designervariable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Verwendete Ressourcen bereinigen.
- ///
- /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Vom Windows Form-Designer generierter Code
-
- ///
- /// Erforderliche Methode für die Designerunterstützung.
- /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
- ///
- private void InitializeComponent()
- {
- this.pbImage = new System.Windows.Forms.PictureBox();
- ((System.ComponentModel.ISupportInitialize)(this.pbImage)).BeginInit();
- this.SuspendLayout();
- //
- // pbImage
- //
- this.pbImage.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pbImage.Location = new System.Drawing.Point(0, 0);
- this.pbImage.Name = "pbImage";
- this.pbImage.Size = new System.Drawing.Size(194, 176);
- this.pbImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
- this.pbImage.TabIndex = 0;
- this.pbImage.TabStop = false;
- //
- // CustomizeMii_Preview
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(194, 176);
- this.Controls.Add(this.pbImage);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
- this.MinimumSize = new System.Drawing.Size(200, 200);
- this.Name = "CustomizeMii_Preview";
- this.Text = "CustomizeMii - Preview";
- this.Load += new System.EventHandler(this.CustomizeMii_Preview_Load);
- ((System.ComponentModel.ISupportInitialize)(this.pbImage)).EndInit();
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- public System.Windows.Forms.PictureBox pbImage;
-
- }
-}
\ No newline at end of file
diff --git a/CustomizeMii/CustomizeMii_Preview.cs b/CustomizeMii/CustomizeMii_Preview.cs
deleted file mode 100644
index bd0a822..0000000
--- a/CustomizeMii/CustomizeMii_Preview.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/* 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 .
- */
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Text;
-using System.Windows.Forms;
-
-namespace CustomizeMii
-{
- public partial class CustomizeMii_Preview : Form
- {
- public CustomizeMii_Preview()
- {
- InitializeComponent();
- }
-
- private void CustomizeMii_Preview_Load(object sender, EventArgs e)
- {
- this.CenterToParent();
- }
- }
-}
diff --git a/CustomizeMii/Instructions.txt b/CustomizeMii/Instructions.txt
deleted file mode 100644
index d1e5283..0000000
--- a/CustomizeMii/Instructions.txt
+++ /dev/null
@@ -1,125 +0,0 @@
-These are some basic instructions for CustomizeMii.
-
-At the very beginning, let me say this again: Don't install any WADs without a proper brick protection!
-
-Ok, so you want to create your own custom channels?
-First it is important to understand how the creation of a custom channel with CustomizeMii works.
-Skip this if you already know.
-
-Basically, you can't create a channel from scratch. Well, you could, but not with this application.
-You need a base WAD which you can modify. You can either download one within this application or use
-any WAD (must be a channel of course) from anywhere.
-You can then edit the WAD file.
-The editing of animations is for advanced users, so if you're not familiar with brlyt's and brlan's
-(I guess you're not unless you created your own animations), get a static base WAD or one with the
-animation you want.
-
-So, let's start to create a channel. Download a base WAD through the application or load one from your HDD.
-You can preview the downloadable WADs through the preview button.
-All options below are optional!
-
-
-
-MIXING BANNER, ICON AND SOUND
-
-The options below the downloadable base WADs are the "replace" options.
-Let's say you have loaded WAD A as a base, but you want the icon of WAD B and you have a 00000000.app that
-contains a sound that you want to use.
-No problem! Just use the dropdownbox which yet says "Banner" and choose "Icon". Click on the browse button
-next to it and choose WAD B. The icon of WAD B will replace the icon of WAD A.
-After that, choose "Sound" from the dropdownbox and browse for the 00000000.app, the sound.bin will be
-extracted and used instead of the one within WAD A.
-
-Note: These features are non-destructive, i.e. you can always use the clear button to get back to the
-banner/icon/sound of WAD A!
-
-
-
-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
-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.
-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!
-
-I recommend not to use any title ID beginning with the following characters, because official channels
-use these and thus your channel may overwrite them:
-C, E, F, H, J, L, M, N, P, Q, W
-
-
-
-INSERTING A NEW DOL
-
-Let's bring some life into the channel. In the "Options" tab, use the browse button for a new DOL.
-Either load a forwarder or the DOL of any application. Note that some channles require more than just a DOL
-and thus may not work in a channel (e.g. MPlayer CE).
-Choose a NAND loader or just stick with the one selected (both will do fine).
-
-
-
-INSERTING A NEW SOUND
-
-For the sound, you can either use a wave file or the sound replace function to use the sound of an
-existing sound.bin/00000000.app/WAD.
-If you want looped sound, open your wave file with wavosaur and add loop points before.
-
-
-
-EDITING THE BANNER/ICON (If you're an advanced user and want to edit the brlyt/brlan, do that first!)
-
-So, let's begin with the real customization. I will only talk about the banner here, the instructions
-are the same for the icon.
-Goto the "Banner" tab. You shouldn't touch the add and remove buttons, they're for advanced users that
-change the animation. (However, they can't really harm your channel, as CustomizeMii will check for missing
-and unneeded TPLs while creating a WAD).
-You will see a list with all TPLs inside the banner.bin. When you select a TPL,
-it's current format will be shown in the "Format" dropdownbox. Note that CustomizeMii can read 8 different
-TPL formats, but only write 3 (RGBA8, RGB565 and RGB5A3), that should be enough for your needs.
-You can use the preview button to preview a TPL (obvious, right?), but you get one more important info,
-the image size. It will be shown in the title of the preview window. If your images aren't the same size,
-they will be resized! So be sure to have at least the correct aspect ratio, so your images wont be
-squeezed or whatever.
-Before replacing the image, choose a format from the dropdownbox.
-(RGBA8 = High Quality, Big Size --- RGB565 = Moderate Quality, Small Size --- RGB5A3 = Bad Quality, Small Size)
-Now you can use the replace button to insert your image. Preview the TPL after replacing to check the
-image. Maybe you want to use another format though? No problem, just replace the TPL again.
-
-Note: You can use the "Make Transparent" checkbox to make a TPL transparent, e.g. if you don't like
-one piece of an animation (It's non-destructive, i.e. you can always uncheck the box).
-
-
-
-EDITING THE ANIMATION (Advanced users only!)
-
-Skip this part, if you don't really know what brlyt and brlan files are and how they're structured.
-Goto the "brlyt" tab. You will see the banner.brlyt and icon.brlyt there.
-Above the buttons is a text that will indicate whether you're doing actions on the "Banner" or
-the "Icon" (When you select the banner.brlyt, you're editing the "Banner" and vice versa).
-Now, just replace the banner.brlyt and icon.brlyt files as you want. You can use the list TPLs button
-afterwards to see all TPLs that are required by the banner.brlyt/icon.brlyt (Don't worry, CustomizeMii
-won't let you create a WAD, if you forgot a required TPL).
-Now, goto the "brlan" tab. It's similar to the "brlyt" tab. You shouldn't touch the add or delete button
-unless your base WAD only has a banner.brlan and you want to use a banner_Start.brlan and banner_Loop.brlan.
-In this case, first add the two files and then delete the old banner.brlan.
-Else just replace the files with yours. Be absolutely sure the your brlan files only refer to panes that are
-indicated in your brlyt files!
-That's it, here's nothing left to do.
-
-
-
-CREATING THE WAD
-
-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).
-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.
-
-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/Resources.resx b/CustomizeMii/Properties/Resources.resx
deleted file mode 100644
index 10c0e07..0000000
--- a/CustomizeMii/Properties/Resources.resx
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- ..\Resources\CustomizeMii.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- ..\resources\instructions.rtf;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
-
-
\ No newline at end of file
diff --git a/CustomizeMii/Properties/Settings.Designer.cs b/CustomizeMii/Properties/Settings.Designer.cs
deleted file mode 100644
index c26659c..0000000
--- a/CustomizeMii/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-/* 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 .
- */
-
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:2.0.50727.4927
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace CustomizeMii.Properties
-{
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
-
- private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default
- {
- get
- {
- return defaultInstance;
- }
- }
- }
-}
diff --git a/CustomizeMii/Properties/Settings.settings b/CustomizeMii/Properties/Settings.settings
deleted file mode 100644
index abf36c5..0000000
--- a/CustomizeMii/Properties/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/CustomizeMii/Resources/CustomizeMii.ico b/CustomizeMii/Resources/CustomizeMii.ico
deleted file mode 100644
index 43fef89..0000000
Binary files a/CustomizeMii/Resources/CustomizeMii.ico and /dev/null differ
diff --git a/CustomizeMii/Resources/Instructions.rtf b/CustomizeMii/Resources/Instructions.rtf
deleted file mode 100644
index 951eaea..0000000
Binary files a/CustomizeMii/Resources/Instructions.rtf and /dev/null differ
diff --git a/CustomizeMii/Resources/Waninkoko.app b/CustomizeMii/Resources/Waninkoko.app
deleted file mode 100644
index ccf3026..0000000
Binary files a/CustomizeMii/Resources/Waninkoko.app and /dev/null differ
diff --git a/CustomizeMii/Resources/comex.app b/CustomizeMii/Resources/comex.app
deleted file mode 100644
index a8d94c8..0000000
Binary files a/CustomizeMii/Resources/comex.app and /dev/null differ
diff --git a/CustomizeMii/Wii.cs b/CustomizeMii/Wii.cs
deleted file mode 100644
index ed43d0e..0000000
--- a/CustomizeMii/Wii.cs
+++ /dev/null
@@ -1,5493 +0,0 @@
-/* This file is part of ShowMiiWads
- * Copyright (C) 2009 Leathl
- *
- * ShowMiiWads is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * ShowMiiWads is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-//Wii.py by Xuzz, SquidMan, megazig, Matt_P, Omega and The Lemon Man was the base for TPL conversion
-//Zetsubou by SquidMan was a reference for TPL conversion
-//gbalzss by Andre Perrot was the base for LZ77 (de-)compression
-//Thanks to the authors!
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using System.Security.Cryptography;
-using System.Drawing;
-using System.Net;
-
-namespace Wii
-{
- public class Tools
- {
- public static event EventHandler ProgressChanged;
-
- public static void ChangeProgress(int ProgressPercent)
- {
- EventHandler progressChanged = ProgressChanged;
- if (progressChanged != null)
- {
- progressChanged(new object(), new ProgressChangedEventArgs(ProgressPercent));
- }
- }
-
- ///
- /// Writes the small Byte Array into the big one at the given offset
- ///
- ///
- ///
- ///
- ///
- public static byte[] InsertByteArray(byte[] big, byte[] small, int offset)
- {
- for (int i = 0; i < small.Length; i++)
- big[offset + i] = small[i];
- return big;
- }
-
- ///
- /// Creates a new Byte Array out of the given one
- /// from the given offset with the specified length
- ///
- ///
- ///
- ///
- ///
- public static byte[] GetPartOfByteArray(byte[] array, int offset, int length)
- {
- byte[] ret = new byte[length];
- for (int i = 0; i < length; i++)
- ret[i] = array[offset + i];
- return ret;
- }
-
- ///
- /// Converts UInt32 Array into Byte Array
- ///
- ///
- ///
- public static byte[] UInt32ArrayToByteArray(UInt32[] array)
- {
- List results = new List();
- foreach (UInt32 value in array)
- {
- byte[] converted = BitConverter.GetBytes(value);
- results.AddRange(converted);
- }
- return results.ToArray();
- }
-
- ///
- /// Converts UInt16 Array into Byte Array
- ///
- ///
- ///
- public static byte[] UInt16ArrayToByteArray(UInt16[] array)
- {
- List results = new List();
- foreach (UInt16 value in array)
- {
- byte[] converted = BitConverter.GetBytes(value);
- results.AddRange(converted);
- }
- return results.ToArray();
- }
-
- ///
- /// Converts UInt16 Array into Byte Array
- ///
- ///
- ///
- public static byte[] UIntArrayToByteArray(uint[] array)
- {
- List results = new List();
- foreach (uint value in array)
- {
- byte[] converted = BitConverter.GetBytes(value);
- results.AddRange(converted);
- }
- return results.ToArray();
- }
-
- ///
- /// Converts Byte Array into UInt16 Array
- ///
- ///
- ///
- public static UInt32[] ByteArrayToUInt32Array(byte[] array)
- {
- UInt32[] converted = new UInt32[array.Length / 2];
- int j = 0;
- for (int i = 0; i < array.Length; i += 4)
- {
- converted[j] = BitConverter.ToUInt32(array, i);
- j++;
- }
- return converted;
- }
-
- ///
- /// Converts Byte Array into UInt16 Array
- ///
- ///
- ///
- public static UInt16[] ByteArrayToUInt16Array(byte[] array)
- {
- UInt16[] converted = new UInt16[array.Length / 2];
- int j = 0;
- for (int i = 0; i < array.Length; i += 2)
- {
- converted[j] = BitConverter.ToUInt16(array, i);
- j++;
- }
- return converted;
- }
-
- ///
- /// Returns the file length as a Byte Array
- ///
- ///
- ///
- public static byte[] FileLengthToByteArray(int filelength)
- {
- byte[] length = BitConverter.GetBytes(filelength);
- Array.Reverse(length);
- return length;
- }
-
- ///
- /// Adds a padding to the next 64 bytes, if necessary
- ///
- ///
- ///
- public static int AddPadding(int value)
- {
- return AddPadding(value, 64);
- }
-
- ///
- /// Adds a padding to the given value, if necessary
- ///
- ///
- ///
- ///
- public static int AddPadding(int value, int padding)
- {
- if (value % padding != 0)
- {
- value = value + (padding - (value % padding));
- }
-
- return value;
- }
-
- ///
- /// Converts a Hex-String to Int
- ///
- ///
- ///
- public static int HexStringToInt(string hexstring)
- {
- try { return int.Parse(hexstring, System.Globalization.NumberStyles.HexNumber); }
- catch { throw new Exception("An Error occured, maybe the Wad file is corrupt!"); }
- }
-
- ///
- /// Converts a Hex-String to Long
- ///
- ///
- ///
- public static long HexStringToLong(string hexstring)
- {
- try { return long.Parse(hexstring, System.Globalization.NumberStyles.HexNumber); }
- catch { throw new Exception("An Error occured, maybe the Wad file is corrupt!"); }
- }
-
- ///
- /// Writes a Byte Array to a file
- ///
- ///
- public static void SaveFileFromByteArray(byte[] file, string destination)
- {
- using (FileStream fs = new FileStream(destination, FileMode.Create))
- fs.Write(file, 0, file.Length);
- }
-
- ///
- /// Loads a file into a Byte Array
- ///
- ///
- ///
- public static byte[] LoadFileToByteArray(string sourcefile)
- {
- if (File.Exists(sourcefile))
- {
- using (FileStream fs = new FileStream(sourcefile, FileMode.Open))
- {
- byte[] filearray = new byte[fs.Length];
- fs.Read(filearray, 0, filearray.Length);
- return filearray;
- }
- }
- else throw new FileNotFoundException("File couldn't be found:\r\n" + sourcefile);
- }
-
- ///
- /// Loads a file into a Byte Array
- ///
- ///
- ///
- public static byte[] LoadFileToByteArray(string sourcefile, int offset, int length)
- {
- if (File.Exists(sourcefile))
- {
- using (FileStream fs = new FileStream(sourcefile, FileMode.Open))
- {
- if (fs.Length < length) length = (int)fs.Length;
- byte[] filearray = new byte[length];
- fs.Read(filearray, offset, length);
- return filearray;
- }
- }
- else throw new FileNotFoundException("File couldn't be found:\r\n" + sourcefile);
- }
-
- ///
- /// Checks the SHA1 of the Common-Key
- ///
- ///
- ///
- public static bool CheckCommonKey(string pathtocommonkey)
- {
- byte[] sum = new byte[] { 0xEB, 0xEA, 0xE6, 0xD2, 0x76, 0x2D, 0x4D, 0x3E, 0xA1, 0x60, 0xA6, 0xD8, 0x32, 0x7F, 0xAC, 0x9A, 0x25, 0xF8, 0x06, 0x2B };
-
- FileInfo fi = new FileInfo(pathtocommonkey);
- if (fi.Length != 16) return false;
- else
- {
- byte[] ckey = LoadFileToByteArray(pathtocommonkey);
-
- SHA1Managed sha1 = new SHA1Managed();
- byte[] newsum = sha1.ComputeHash(ckey);
-
- if (CompareByteArrays(sum, newsum) == true) return true;
- else return false;
- }
- }
-
- ///
- /// Creates the Common Key
- ///
- /// Must be "45e"
- /// Destination Path
- public static void CreateCommonKey(string fat, string destinationpath)
- {
- //What an effort, lol
- byte[] encryptedwater = new byte[] { 0x4d, 0x89, 0x21, 0x34, 0x62, 0x81, 0xe4, 0x02, 0x37, 0x36, 0xc4, 0xb4, 0xde, 0x40, 0x32, 0xab };
- byte[] key = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, byte.Parse(fat.Remove(2), System.Globalization.NumberStyles.HexNumber), byte.Parse(fat.Remove(0, 2) + "0", System.Globalization.NumberStyles.HexNumber) };
- byte[] decryptedwater = new byte[10];
-
- RijndaelManaged decryptkey = new RijndaelManaged();
- decryptkey.Mode = CipherMode.CBC;
- decryptkey.Padding = PaddingMode.None;
- decryptkey.KeySize = 128;
- decryptkey.BlockSize = 128;
- decryptkey.Key = key;
- Array.Reverse(key);
- decryptkey.IV = key;
-
- ICryptoTransform cryptor = decryptkey.CreateDecryptor();
-
- using (MemoryStream memory = new MemoryStream(encryptedwater))
- {
- using (CryptoStream crypto = new CryptoStream(memory, cryptor, CryptoStreamMode.Read))
- crypto.Read(decryptedwater, 0, 10);
- }
-
- string water = BitConverter.ToString(decryptedwater).Replace("-", "").ToLower() + " ";
-
- water = water.Insert(0, fat[2].ToString());
- water = water.Insert(2, fat[2].ToString());
- water = water.Insert(7, fat[2].ToString());
- water = water.Insert(11, fat[2].ToString());
-
- water = water.Insert(7, fat[1].ToString());
- water = water.Insert(10, fat[1].ToString());
- water = water.Insert(18, fat[1].ToString());
- water = water.Insert(19, fat[1].ToString());
-
- water = water.Insert(3, fat[0].ToString());
- water = water.Insert(15, fat[0].ToString());
- water = water.Insert(16, fat[0].ToString());
- water = water.Insert(22, fat[0].ToString());
-
- byte[] cheese = new byte[16];
- int count = -1;
-
- for (int i = 0; i < 32; i += 2)
- cheese[++count] = byte.Parse(water.Remove(0, i).Remove(2), System.Globalization.NumberStyles.HexNumber);
-
- if (destinationpath[destinationpath.Length - 1] != '\\') destinationpath = destinationpath + "\\";
- using (FileStream keystream = new FileStream(destinationpath + "\\common-key.bin", FileMode.Create))
- {
- keystream.Write(cheese, 0, cheese.Length);
- }
- }
-
- ///
- /// Counts the appearance of a specific character in a string
- ///
- ///
- ///
- ///
- public static int CountCharsInString(string theString, char theChar)
- {
- int count = 0;
- foreach (char thisChar in theString)
- {
- if (thisChar == theChar)
- count++;
- }
- return count;
- }
-
- ///
- /// Compares two Byte Arrays and returns true, if they match
- ///
- ///
- ///
- ///
- public static bool CompareByteArrays(byte[] first, byte[] second)
- {
- if (first.Length != second.Length) return false;
- else
- {
- for (int i = 0; i < first.Length; i++)
- if (first[i] != second[i]) return false;
-
- return true;
- }
- }
-
- ///
- /// Converts a Hex String to a Byte Array
- ///
- ///
- ///
- public static byte[] HexStringToByteArray(string hexstring)
- {
- byte[] ba = new byte[hexstring.Length / 2];
-
- for (int i = 0; i < hexstring.Length / 2; i++)
- {
- ba[i] = byte.Parse(hexstring.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
- }
-
- return ba;
- }
-
- ///
- /// Checks, if the given string does exist in the string Array
- ///
- ///
- ///
- ///
- public static bool StringExistsInStringArray(string theString, string[] theStringArray)
- {
- return Array.Exists(theStringArray, thisString => thisString == theString);
- }
-
- ///
- /// Copies an entire Directoy
- ///
- ///
- ///
- public static void CopyDirectory(string source, string destination)
- {
- string[] subdirs = Directory.GetDirectories(source);
- string[] files = Directory.GetFiles(source);
-
- foreach (string thisFile in files)
- {
- if (!Directory.Exists(destination)) Directory.CreateDirectory(destination);
- if (File.Exists(destination + "\\" + Path.GetFileName(thisFile))) File.Delete(destination + "\\" + Path.GetFileName(thisFile));
- File.Copy(thisFile, destination + "\\" + Path.GetFileName(thisFile));
- }
-
- foreach (string thisDir in subdirs)
- {
- CopyDirectory(thisDir, destination + "\\" + thisDir.Remove(0, thisDir.LastIndexOf('\\') + 1));
- }
- }
- }
-
- public class WadInfo
- {
- public const int Headersize = 64;
- public static string[] RegionCode = new string[4] { "Japan", "USA", "Europe", "Region Free" };
-
- ///
- /// Returns the Header of a Wadfile
- ///
- ///
- ///
- public static byte[] GetHeader(byte[] wadfile)
- {
- byte[] Header = new byte[0x20];
-
- for (int i = 0; i < Header.Length; i++)
- {
- Header[i] = wadfile[i];
- }
-
- return Header;
- }
-
- ///
- /// Returns the size of the Certificate
- ///
- ///
- ///
- public static int GetCertSize(byte[] wadfile)
- {
- int size = int.Parse(wadfile[0x08].ToString("x2") + wadfile[0x09].ToString("x2") + wadfile[0x0a].ToString("x2") + wadfile[0x0b].ToString("x2"), System.Globalization.NumberStyles.HexNumber);
- return size;
- }
-
- ///
- /// Returns the size of the Ticket
- ///
- ///
- ///
- public static int GetTikSize(byte[] wadfile)
- {
- int size = int.Parse(wadfile[0x10].ToString("x2") + wadfile[0x11].ToString("x2") + wadfile[0x12].ToString("x2") + wadfile[0x13].ToString("x2"), System.Globalization.NumberStyles.HexNumber);
- return size;
- }
-
- ///
- /// Returns the size of the TMD
- ///
- ///
- ///
- public static int GetTmdSize(byte[] wadfile)
- {
- int size = int.Parse(wadfile[0x14].ToString("x2") + wadfile[0x15].ToString("x2") + wadfile[0x16].ToString("x2") + wadfile[0x17].ToString("x2"), System.Globalization.NumberStyles.HexNumber);
- return size;
- }
-
- ///
- /// Returns the size of all Contents
- ///
- ///
- ///
- public static int GetContentSize(byte[] wadfile)
- {
- int size = int.Parse(wadfile[0x18].ToString("x2") + wadfile[0x19].ToString("x2") + wadfile[0x1a].ToString("x2") + wadfile[0x1b].ToString("x2"), System.Globalization.NumberStyles.HexNumber);
- return size;
- }
-
- ///
- /// Returns the size of the Footer
- ///
- ///
- ///
- public static int GetFooterSize(byte[] wadfile)
- {
- int size = int.Parse(wadfile[0x1c].ToString("x2") + wadfile[0x1d].ToString("x2") + wadfile[0x1e].ToString("x2") + wadfile[0x1f].ToString("x2"), System.Globalization.NumberStyles.HexNumber);
- return size;
- }
-
- ///
- /// Returns the position of the tmd in the wad file
- ///
- ///
- ///
- public static int GetTmdPos(byte[] wadfile)
- {
- return Headersize + Tools.AddPadding(GetCertSize(wadfile)) + Tools.AddPadding(GetTikSize(wadfile));
- }
-
- ///
- /// Returns the position of the ticket in the wad file, ticket or tmd
- ///
- ///
- ///
- public static int GetTikPos(byte[] wadfile)
- {
- return Headersize + Tools.AddPadding(GetCertSize(wadfile));
- }
-
- ///
- /// Returns the title ID of the wad file.
- ///
- ///
- /// 0 = Tik, 1 = Tmd
- ///
- public static string GetTitleID(byte[] wadtiktmd, int type)
- {
- string channeltype = GetChannelType(wadtiktmd, type);
- int tikpos = 0;
- int tmdpos = 0;
-
- if (IsThisWad(wadtiktmd) == true)
- {
- //It's a wad
- tikpos = GetTikPos(wadtiktmd);
- tmdpos = GetTmdPos(wadtiktmd);
- }
-
- if (type == 1)
- {
- if (!channeltype.Contains("System:"))
- {
- string tmdid = Convert.ToChar(wadtiktmd[tmdpos + 0x190]).ToString() + Convert.ToChar(wadtiktmd[tmdpos + 0x191]).ToString() + Convert.ToChar(wadtiktmd[tmdpos + 0x192]).ToString() + Convert.ToChar(wadtiktmd[tmdpos + 0x193]).ToString();
- return tmdid;
- }
- else if (channeltype.Contains("IOS"))
- {
- int tmdid = Tools.HexStringToInt(wadtiktmd[tmdpos + 0x190].ToString("x2") + wadtiktmd[tmdpos + 0x191].ToString("x2") + wadtiktmd[tmdpos + 0x192].ToString("x2") + wadtiktmd[tmdpos + 0x193].ToString("x2"));
- return "IOS" + tmdid;
- }
- else if (channeltype.Contains("System")) return "SYSTEM";
- else return "";
- }
- else
- {
- if (!channeltype.Contains("System:"))
- {
- string tikid = Convert.ToChar(wadtiktmd[tikpos + 0x1e0]).ToString() + Convert.ToChar(wadtiktmd[tikpos + 0x1e1]).ToString() + Convert.ToChar(wadtiktmd[tikpos + 0x1e2]).ToString() + Convert.ToChar(wadtiktmd[tikpos + 0x1e3]).ToString();
- return tikid;
- }
- else if (channeltype.Contains("IOS"))
- {
- int tikid = Tools.HexStringToInt(wadtiktmd[tikpos + 0x1e0].ToString("x2") + wadtiktmd[tikpos + 0x1e1].ToString("x2") + wadtiktmd[tikpos + 0x1e2].ToString("x2") + wadtiktmd[tikpos + 0x1e3].ToString("x2"));
- return "IOS" + tikid;
- }
- else if (channeltype.Contains("System")) return "SYSTEM";
- else return "";
- }
- }
-
- ///
- /// Returns the full title ID of the wad file as a hex string.
- ///
- ///
- /// 0 = Tik, 1 = Tmd
- ///
- public static string GetFullTitleID(byte[] wadtiktmd, int type)
- {
- int tikpos = 0;
- int tmdpos = 0;
-
- if (IsThisWad(wadtiktmd) == true)
- {
- //It's a wad
- tikpos = GetTikPos(wadtiktmd);
- tmdpos = GetTmdPos(wadtiktmd);
- }
-
- if (type == 1)
- {
- string tmdid = wadtiktmd[tmdpos + 0x18c].ToString("x2") +
- wadtiktmd[tmdpos + 0x18d].ToString("x2") +
- wadtiktmd[tmdpos + 0x18e].ToString("x2") +
- wadtiktmd[tmdpos + 0x18f].ToString("x2") +
- wadtiktmd[tmdpos + 0x190].ToString("x2") +
- wadtiktmd[tmdpos + 0x191].ToString("x2") +
- wadtiktmd[tmdpos + 0x192].ToString("x2") +
- wadtiktmd[tmdpos + 0x193].ToString("x2");
- return tmdid;
- }
- else
- {
- string tikid = wadtiktmd[tikpos + 0x1dc].ToString() +
- wadtiktmd[tikpos + 0x1dd].ToString() +
- wadtiktmd[tikpos + 0x1de].ToString() +
- wadtiktmd[tikpos + 0x1df].ToString() +
- wadtiktmd[tikpos + 0x1e0].ToString() +
- wadtiktmd[tikpos + 0x1e1].ToString() +
- wadtiktmd[tikpos + 0x1e2].ToString() +
- wadtiktmd[tikpos + 0x1e3].ToString();
- return tikid;
- }
- }
-
- ///
- /// Returns the title for each language of a wad file.
- /// Order: Jap, Eng, Ger, Fra, Spa, Ita, Dut
- ///
- ///
- ///
- public static string[] GetChannelTitles(string wadfile)
- {
- byte[] wadarray = Tools.LoadFileToByteArray(wadfile);
- return GetChannelTitles(wadarray);
- }
-
- ///
- /// Returns the title for each language of a wad file.
- /// Order: Jap, Eng, Ger, Fra, Spa, Ita, Dut
- ///
- ///
- ///
- public static string[] GetChannelTitles(byte[] wadfile)
- {
- if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\common-key.bin") || File.Exists(System.Windows.Forms.Application.StartupPath + "\\key.bin"))
- {
- string channeltype = GetChannelType(wadfile, 0);
-
- if (!channeltype.Contains("System:"))
- {
- if (!channeltype.Contains("Hidden"))
- {
- string[] titles = new string[7];
-
- //Detection from footer is turned off, cause the footer
- //can be easily edited and thus the titles in it could be simply wrong
-
- //int footer = GetFooterSize(wadfile);
- //if (footer > 0)
- //{
- // int footerpos = wadfile.Length - footer;
- // int count = 0;
- // int imetpos = 0;
-
- // if ((wadfile.Length - (wadfile.Length - footer)) < 250) return new string[7];
-
- // for (int z = 0; z < 250; z++)
- // {
- // if (Convert.ToChar(wadfile[footerpos + z]) == 'I')
- // if (Convert.ToChar(wadfile[footerpos + z + 1]) == 'M')
- // if (Convert.ToChar(wadfile[footerpos + z + 2]) == 'E')
- // if (Convert.ToChar(wadfile[footerpos + z + 3]) == 'T')
- // {
- // imetpos = footerpos + z;
- // break;
- // }
- // }
-
- // int jappos = imetpos + 29;
-
- // for (int i = jappos; i < jappos + 588; i += 84)
- // {
- // for (int j = 0; j < 40; j += 2)
- // {
- // if (wadfile[i + j] != 0x00)
- // {
- // char temp = Convert.ToChar(wadfile[i + j]);
- // titles[count] += temp;
- // }
- // }
-
- // count++;
- // }
-
- // return titles;
- //}
-
- string[,] conts = GetContentInfo(wadfile);
- byte[] titlekey = GetTitleKey(wadfile);
- int nullapp = 0;
-
- for (int i = 0; i < conts.GetLength(0); i++)
- {
- if (conts[i, 1] == "00000000")
- nullapp = i;
- }
-
- byte[] contenthandle = WadEdit.DecryptContent(wadfile, nullapp, titlekey);
- int imetpos = 0;
-
- if (contenthandle.Length < 400) return new string[7];
-
- for (int z = 0; z < 400; z++)
- {
- if (Convert.ToChar(contenthandle[z]) == 'I')
- if (Convert.ToChar(contenthandle[z + 1]) == 'M')
- if (Convert.ToChar(contenthandle[z + 2]) == 'E')
- if (Convert.ToChar(contenthandle[z + 3]) == 'T')
- {
- imetpos = z;
- break;
- }
- }
-
- int jappos = imetpos + 29;
- int count = 0;
-
- for (int i = jappos; i < jappos + 588; i += 84)
- {
- for (int j = 0; j < 40; j += 2)
- {
- if (contenthandle[i + j] != 0x00)
- {
- char temp = Convert.ToChar(contenthandle[i + j]);
- titles[count] += temp;
- }
- }
-
- count++;
- }
-
- return titles;
- }
- else return new string[7];
- }
- else return new string[7];
- }
- else return new string[7];
- }
-
- ///
- /// Returns the title for each language of a 00.app file
- /// Order: Jap, Eng, Ger, Fra, Spa, Ita, Dut
- ///
- ///
- ///
- public static string[] GetChannelTitlesFromApp(string app)
- {
- byte[] tmp = Tools.LoadFileToByteArray(app);
- return GetChannelTitlesFromApp(tmp);
- }
-
- ///
- /// Returns the title for each language of a 00.app file
- /// Order: Jap, Eng, Ger, Fra, Spa, Ita, Dut
- ///
- ///
- ///
- public static string[] GetChannelTitlesFromApp(byte[] app)
- {
- string[] titles = new string[7];
-
- int imetpos = 0;
- int length = 400;
-
- if (app.Length < 400) length = app.Length - 4;
-
- for (int z = 0; z < length; z++)
- {
- if (Convert.ToChar(app[z]) == 'I')
- if (Convert.ToChar(app[z + 1]) == 'M')
- if (Convert.ToChar(app[z + 2]) == 'E')
- if (Convert.ToChar(app[z + 3]) == 'T')
- {
- imetpos = z;
- break;
- }
- }
-
- if (imetpos != 0)
- {
- int jappos = imetpos + 29;
- int count = 0;
-
- for (int i = jappos; i < jappos + 588; i += 84)
- {
- for (int j = 0; j < 40; j += 2)
- {
- if (app[i + j] != 0x00)
- {
- char temp = Convert.ToChar(app[i + j]);
- titles[count] += temp;
- }
- }
-
- count++;
- }
- }
-
- return titles;
- }
-
- ///
- /// Returns the Type of the Channel as a string
- /// Wad or Tik needed for WiiWare / VC detection!
- ///
- ///
- ///
- public static string GetChannelType(byte[] wadtiktmd, int type)
- {
- int tikpos = 0;
- int tmdpos = 0;
-
- if (IsThisWad(wadtiktmd) == true)
- {
- //It's a wad
- tikpos = GetTikPos(wadtiktmd);
- tmdpos = GetTmdPos(wadtiktmd);
- }
-
- string thistype = "";
-
- if (type == 0)
- { thistype = wadtiktmd[tikpos + 0x1dc].ToString("x2") + wadtiktmd[tikpos + 0x1dd].ToString("x2") + wadtiktmd[tikpos + 0x1de].ToString("x2") + wadtiktmd[tikpos + 0x1df].ToString("x2"); }
- else { thistype = wadtiktmd[tmdpos + 0x18c].ToString("x2") + wadtiktmd[tmdpos + 0x18d].ToString("x2") + wadtiktmd[tmdpos + 0x18e].ToString("x2") + wadtiktmd[tmdpos + 0x18f].ToString("x2"); }
- string channeltype = "Unknown";
-
- if (thistype == "00010001")
- {
- channeltype = CheckWiiWareVC(wadtiktmd, type);
- }
- else if (thistype == "00010002") channeltype = "System Channel";
- else if (thistype == "00010004" || thistype == "00010000") channeltype = "Game Channel";
- else if (thistype == "00010005") channeltype = "Downloaded Content";
- else if (thistype == "00010008") channeltype = "Hidden Channel";
- else if (thistype == "00000001")
- {
- channeltype = "System: IOS";
-
- string thisid = "";
- if (type == 0) { thisid = wadtiktmd[tikpos + 0x1e0].ToString("x2") + wadtiktmd[tikpos + 0x1e1].ToString("x2") + wadtiktmd[tikpos + 0x1e2].ToString("x2") + wadtiktmd[tikpos + 0x1e3].ToString("x2"); }
- else { thisid = wadtiktmd[tmdpos + 0x190].ToString("x2") + wadtiktmd[tmdpos + 0x191].ToString("x2") + wadtiktmd[tmdpos + 0x192].ToString("x2") + wadtiktmd[tmdpos + 0x193].ToString("x2"); }
-
- if (thisid == "00000001") channeltype = "System: Boot2";
- else if (thisid == "00000002") channeltype = "System: Menu";
- else if (thisid == "00000100") channeltype = "System: BC";
- else if (thisid == "00000101") channeltype = "System: MIOS";
- }
-
- return channeltype;
- }
-
- ///
- /// Returns the amount of included Contents (app-files)
- ///
- ///
- ///
- public static int GetContentNum(byte[] wadtmd)
- {
- int tmdpos = 0;
-
- if (IsThisWad(wadtmd) == true)
- {
- //It's a wad file, so get the tmd position
- tmdpos = GetTmdPos(wadtmd);
- }
-
- int contents = Tools.HexStringToInt(wadtmd[tmdpos + 0x1de].ToString("x2") + wadtmd[tmdpos + 0x1df].ToString("x2"));
-
- return contents;
- }
-
- ///
- /// Returns the approx. destination size on the Wii
- ///
- ///
- ///
- public static string GetNandSize(byte[] wadtmd, bool ConvertToMB)
- {
- int tmdpos = 0;
- int minsize = 0;
- int maxsize = 0;
- int numcont = GetContentNum(wadtmd);
-
- if (IsThisWad(wadtmd) == true)
- {
- //It's a wad
- tmdpos = GetTmdPos(wadtmd);
- }
-
- for (int i = 0; i < numcont; i++)
- {
- int cont = 36 * i;
- int contentsize = Tools.HexStringToInt(wadtmd[tmdpos + 0x1e4 + 8 + cont].ToString("x2") +
- wadtmd[tmdpos + 0x1e5 + 8 + cont].ToString("x2") +
- wadtmd[tmdpos + 0x1e6 + 8 + cont].ToString("x2") +
- wadtmd[tmdpos + 0x1e7 + 8 + cont].ToString("x2") +
- wadtmd[tmdpos + 0x1e8 + 8 + cont].ToString("x2") +
- wadtmd[tmdpos + 0x1e9 + 8 + cont].ToString("x2") +
- wadtmd[tmdpos + 0x1ea + 8 + cont].ToString("x2") +
- wadtmd[tmdpos + 0x1eb + 8 + cont].ToString("x2"));
-
- string type = wadtmd[tmdpos + 0x1e4 + 6 + cont].ToString("x2") + wadtmd[tmdpos + 0x1e5 + 6 + cont].ToString("x2");
-
- if (type == "0001")
- {
- minsize += contentsize;
- maxsize += contentsize;
- }
- else if (type == "8001")
- maxsize += contentsize;
- }
-
- string size = "";
-
- if (maxsize == minsize) size = maxsize.ToString();
- else size = minsize.ToString() + " - " + maxsize.ToString();
-
- if (ConvertToMB == true)
- {
- if (size.Contains("-"))
- {
- string min = size.Remove(size.IndexOf(' '));
- string max = size.Remove(0, size.IndexOf('-') + 2);
-
- min = Convert.ToString(Math.Round(Convert.ToDouble(min) * 0.0009765625 * 0.0009765625, 2));
- max = Convert.ToString(Math.Round(Convert.ToDouble(max) * 0.0009765625 * 0.0009765625, 2));
- if (min.Length > 4) { min = min.Remove(4); }
- if (max.Length > 4) { max = max.Remove(4); }
- size = min + " - " + max + " MB";
- }
- else
- {
- size = Convert.ToString(Math.Round(Convert.ToDouble(size) * 0.0009765625 * 0.0009765625, 2));
- if (size.Length > 4) { size = size.Remove(4); }
- size = size + " MB";
- }
- }
-
- return size.Replace(",", ".");
- }
-
- ///
- /// Returns the approx. destination block on the Wii
- ///
- ///
- ///
- public static string GetNandBlocks(byte[] wadtmd)
- {
- string size = GetNandSize(wadtmd, false);
-
- if (size.Contains("-"))
- {
- string size1 = size.Remove(size.IndexOf(' '));
- string size2 = size.Remove(0, size.LastIndexOf(' ') + 1);
-
- double blocks1 = (double)((Convert.ToDouble(size1) / 1024) / 128);
- double blocks2 = (double)((Convert.ToDouble(size2) / 1024) / 128);
-
- return Math.Ceiling(blocks1) + " - " + Math.Ceiling(blocks2);
- }
- else
- {
- double blocks = (double)((Convert.ToDouble(size) / 1024) / 128);
-
- return Math.Ceiling(blocks).ToString();
- }
- }
-
- ///
- /// Returns the title version of the wad file
- ///
- ///
- ///
- public static int GetTitleVersion(string wadtmd)
- {
- byte[] temp = Tools.LoadFileToByteArray(wadtmd, 0, 10000);
- return GetTitleVersion(temp);
- }
-
- ///
- /// Returns the title version of the wad file
- ///
- ///
- ///
- public static int GetTitleVersion(byte[] wadtmd)
- {
- int tmdpos = 0;
-
- if (IsThisWad(wadtmd) == true) { tmdpos = GetTmdPos(wadtmd); }
- return Tools.HexStringToInt(wadtmd[tmdpos + 0x1dc].ToString("x2") + wadtmd[tmdpos + 0x1dd].ToString("x2"));
- }
-
- ///
- /// Returns the IOS that is needed by the wad file
- ///
- ///
- ///
- public static string GetIosFlag(byte[] wadtmd)
- {
- string type = GetChannelType(wadtmd, 1);
-
- if (!type.Contains("IOS") && !type.Contains("BC"))
- {
- int tmdpos = 0;
- if (IsThisWad(wadtmd) == true) { tmdpos = GetTmdPos(wadtmd); }
- return "IOS" + Tools.HexStringToInt(wadtmd[tmdpos + 0x188].ToString("x2") + wadtmd[tmdpos + 0x189].ToString("x2") + wadtmd[tmdpos + 0x18a].ToString("x2") + wadtmd[tmdpos + 0x18b].ToString("x2"));
- }
- else return "";
- }
-
- ///
- /// Returns the region of the wad file
- ///
- ///
- ///
- public static string GetRegionFlag(byte[] wadtmd)
- {
- int tmdpos = 0;
- string channeltype = GetChannelType(wadtmd, 1);
-
- if (IsThisWad(wadtmd) == true) { tmdpos = GetTmdPos(wadtmd); }
-
- if (!channeltype.Contains("System:"))
- {
- int region = Tools.HexStringToInt(wadtmd[tmdpos + 0x19d].ToString("x2"));
- return RegionCode[region];
- }
- else return "";
- }
-
- ///
- /// Returns the Path where the wad will be installed on the Wii
- ///
- ///
- ///
- public static string GetNandPath(string wadfile)
- {
- byte[] wad = Tools.LoadFileToByteArray(wadfile);
- return GetNandPath(wad, 0);
- }
-
- ///
- /// Returns the Path where the wad will be installed on the Wii
- ///
- ///
- /// 0 = Tik, 1 = Tmd
- ///
- public static string GetNandPath(byte[] wadtiktmd, int type)
- {
- int tikpos = 0;
- int tmdpos = 0;
-
- if (IsThisWad(wadtiktmd) == true)
- {
- tikpos = GetTikPos(wadtiktmd);
- tmdpos = GetTmdPos(wadtiktmd);
- }
-
- string thispath = "";
-
- if (type == 0)
- {
- thispath = wadtiktmd[tikpos + 0x1dc].ToString("x2") +
- wadtiktmd[tikpos + 0x1dd].ToString("x2") +
- wadtiktmd[tikpos + 0x1de].ToString("x2") +
- wadtiktmd[tikpos + 0x1df].ToString("x2") +
- wadtiktmd[tikpos + 0x1e0].ToString("x2") +
- wadtiktmd[tikpos + 0x1e1].ToString("x2") +
- wadtiktmd[tikpos + 0x1e2].ToString("x2") +
- wadtiktmd[tikpos + 0x1e3].ToString("x2");
- }
- else
- {
- thispath = wadtiktmd[tmdpos + 0x18c].ToString("x2") +
- wadtiktmd[tmdpos + 0x18d].ToString("x2") +
- wadtiktmd[tmdpos + 0x18e].ToString("x2") +
- wadtiktmd[tmdpos + 0x18f].ToString("x2") +
- wadtiktmd[tmdpos + 0x190].ToString("x2") +
- wadtiktmd[tmdpos + 0x191].ToString("x2") +
- wadtiktmd[tmdpos + 0x192].ToString("x2") +
- wadtiktmd[tmdpos + 0x193].ToString("x2");
- }
-
- thispath = thispath.Insert(8, "\\");
- return thispath;
- }
-
- ///
- /// Returns true, if the wad file is a WiiWare / VC title.
- ///
- ///
- /// 0 = Tik, 1 = Tmd
- ///
- public static string CheckWiiWareVC(byte[] wadtiktmd, int type)
- {
- int tiktmdpos = 0;
- int offset = 0x221;
- int idoffset = 0x1e0;
-
- if (type == 1) { offset = 0x197; idoffset = 0x190; }
- if (IsThisWad(wadtiktmd) == true)
- {
- if (type == 1) tiktmdpos = GetTmdPos(wadtiktmd);
- else tiktmdpos = GetTikPos(wadtiktmd);
- }
-
- if (wadtiktmd[tiktmdpos + offset] == 0x01)
- {
- char idchar = Convert.ToChar(wadtiktmd[tiktmdpos + idoffset]);
- char idchar2 = Convert.ToChar(wadtiktmd[tiktmdpos + idoffset + 1]);
-
- if (idchar == 'H') return "System Channel";
- else if (idchar == 'W') return "WiiWare";
- else
- {
- if (idchar == 'C') return "C64";
- else if (idchar == 'E' && idchar2 == 'A') return "NeoGeo";
- else if (idchar == 'E') return "VC - Arcade";
- else if (idchar == 'F') return "NES";
- else if (idchar == 'J') return "SNES";
- else if (idchar == 'L') return "Sega Master System";
- else if (idchar == 'M') return "Sega Genesis";
- else if (idchar == 'N') return "Nintendo 64";
- else if (idchar == 'P') return "Turbografx";
- else if (idchar == 'Q') return "Turbografx CD";
- else return "Channel Title";
- }
- }
- else return "Channel Title";
- }
-
- ///
- /// Returns all information stored in the tmd for all contents in the wad file.
- /// [x, 0] = Content ID, [x, 1] = Index, [x, 2] = Type, [x, 3] = Size, [x, 4] = Sha1
- ///
- ///
- ///
- public static string[,] GetContentInfo(byte[] wadtmd)
- {
- int tmdpos = 0;
-
- if (IsThisWad(wadtmd) == true) { tmdpos = GetTmdPos(wadtmd); }
- int contentcount = GetContentNum(wadtmd);
- string[,] contentinfo = new string[contentcount, 5];
-
- for (int i = 0; i < contentcount; i++)
- {
- contentinfo[i, 0] = wadtmd[tmdpos + 0x1e4 + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1e5 + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1e6 + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1e7 + (36 * i)].ToString("x2");
- contentinfo[i, 1] = "0000" +
- wadtmd[tmdpos + 0x1e8 + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1e9 + (36 * i)].ToString("x2");
- contentinfo[i, 2] = wadtmd[tmdpos + 0x1ea + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1eb + (36 * i)].ToString("x2");
- contentinfo[i, 3] = Tools.HexStringToInt(
- wadtmd[tmdpos + 0x1ec + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1ed + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1ee + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1ef + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1f0 + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1f1 + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1f2 + (36 * i)].ToString("x2") +
- wadtmd[tmdpos + 0x1f3 + (36 * i)].ToString("x2")).ToString();
-
- for (int j = 0; j < 20; j++)
- {
- contentinfo[i, 4] += wadtmd[tmdpos + 0x1f4 + (36 * i) + j].ToString("x2");
- }
- }
-
- return contentinfo;
- }
-
- ///
- /// Returns the Tik of the wad file as a Byte-Array
- ///
- ///
- ///
- public static byte[] ReturnTik(byte[] wadfile)
- {
- int tikpos = GetTikPos(wadfile);
- int tiksize = GetTikSize(wadfile);
-
- byte[] tik = new byte[tiksize];
-
- for (int i = 0; i < tiksize; i++)
- {
- tik[i] = wadfile[tikpos + i];
- }
-
- return tik;
- }
-
- ///
- /// Returns the Tmd of the wad file as a Byte-Array
- ///
- ///
- ///
- public static byte[] ReturnTmd(byte[] wadfile)
- {
- int tmdpos = GetTmdPos(wadfile);
- int tmdsize = GetTmdSize(wadfile);
-
- byte[] tmd = new byte[tmdsize];
-
- for (int i = 0; i < tmdsize; i++)
- {
- tmd[i] = wadfile[tmdpos + i];
- }
-
- return tmd;
- }
-
- ///
- /// Checks, if the given file is a wad
- ///
- ///
- ///
- public static bool IsThisWad(byte[] wadtiktmd)
- {
- if (wadtiktmd[0] == 0x00 &&
- wadtiktmd[1] == 0x00 &&
- wadtiktmd[2] == 0x00 &&
- wadtiktmd[3] == 0x20 &&
- wadtiktmd[4] == 0x49 &&
- wadtiktmd[5] == 0x73)
- { return true; }
-
- return false;
- }
-
- ///
- /// Returns the decrypted TitleKey
- ///
- ///
- ///
- public static byte[] GetTitleKey(byte[] wadtik)
- {
- byte[] commonkey = new byte[16];
-
- if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\common-key.bin"))
- { commonkey = Tools.LoadFileToByteArray(System.Windows.Forms.Application.StartupPath + "\\common-key.bin"); }
- else if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\key.bin"))
- { commonkey = Tools.LoadFileToByteArray(System.Windows.Forms.Application.StartupPath + "\\key.bin"); }
- else { throw new FileNotFoundException("The (common-)key.bin must be in the application directory!"); }
-
- byte[] encryptedkey = new byte[16];
- byte[] iv = new byte[16];
- int tikpos = 0;
-
- if (IsThisWad(wadtik) == true)
- {
- //It's a wad file, so get the tik position
- tikpos = GetTikPos(wadtik);
- }
-
- for (int i = 0; i < 16; i++)
- {
- encryptedkey[i] = wadtik[tikpos + 0x1bf + i];
- }
-
- for (int j = 0; j < 8; j++)
- {
- iv[j] = wadtik[tikpos + 0x1dc + j];
- iv[j + 8] = 0x00;
- }
-
- RijndaelManaged decrypt = new RijndaelManaged();
- decrypt.Mode = CipherMode.CBC;
- decrypt.Padding = PaddingMode.None;
- decrypt.KeySize = 128;
- decrypt.BlockSize = 128;
- decrypt.Key = commonkey;
- decrypt.IV = iv;
-
- ICryptoTransform cryptor = decrypt.CreateDecryptor();
-
- MemoryStream memory = new MemoryStream(encryptedkey);
- CryptoStream crypto = new CryptoStream(memory, cryptor, CryptoStreamMode.Read);
-
- byte[] decryptedkey = new byte[16];
- crypto.Read(decryptedkey, 0, decryptedkey.Length);
-
- crypto.Close();
- memory.Close();
-
- return decryptedkey;
- }
- }
-
- public class WadEdit
- {
- ///
- /// Changes the region of the wad file
- ///
- ///
- /// 0 = JAP, 1 = USA, 2 = EUR, 3 = FREE
- ///
- public static byte[] ChangeRegion(byte[] wadfile, int region)
- {
-
- int tmdpos = WadInfo.GetTmdPos(wadfile);
-
- if (region == 0) wadfile[tmdpos + 0x19d] = 0x00;
- else if (region == 1) wadfile[tmdpos + 0x19d] = 0x01;
- else if (region == 2) wadfile[tmdpos + 0x19d] = 0x02;
- else wadfile[tmdpos + 0x19d] = 0x03;
-
- wadfile = TruchaSign(wadfile, 1);
-
- return wadfile;
- }
-
- ///
- /// Changes the region of the wad file
- ///
- ///
- ///
- public static void ChangeRegion(string wadfile, int region)
- {
- byte[] wadarray = Tools.LoadFileToByteArray(wadfile);
- wadarray = ChangeRegion(wadarray, region);
-
- using (FileStream fs = new FileStream(wadfile, FileMode.Open, FileAccess.Write))
- {
- fs.Seek(0, SeekOrigin.Begin);
- fs.Write(wadarray, 0, wadarray.Length);
- }
- }
-
- ///
- /// Changes the Channel Title of the wad file
- /// All languages have the same title
- ///
- ///
- ///
- ///
- public static byte[] ChangeChannelTitle(byte[] wadfile, string title)
- {
- return ChangeChannelTitle(wadfile, title, title, title, title, title, title, title);
- }
-
- ///
- /// Changes the Channel Title of the wad file
- /// Each language has a specific title
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static void ChangeChannelTitle(string wadfile, string jap, string eng, string ger, string fra, string spa, string ita, string dut)
- {
- byte[] wadarray = Tools.LoadFileToByteArray(wadfile);
- wadarray = ChangeChannelTitle(wadarray, jap, eng, ger, fra, spa, ita, dut);
-
- using (FileStream fs = new FileStream(wadfile, FileMode.Open, FileAccess.Write))
- {
- fs.Seek(0, SeekOrigin.Begin);
- fs.Write(wadarray, 0, wadarray.Length);
- }
- }
-
- ///
- /// Changes the Channel Title of the wad file
- /// Each language has a specific title
- ///
- ///
- /// Japanese Title
- /// English Title
- /// German Title
- /// French Title
- /// Spanish Title
- /// Italian Title
- /// Dutch Title
- ///
- public static byte[] ChangeChannelTitle(byte[] wadfile, string jap, string eng, string ger, string fra, string spa, string ita, string dut)
- {
- Tools.ChangeProgress(0);
-
- char[] japchars = jap.ToCharArray();
- char[] engchars = eng.ToCharArray();
- char[] gerchars = ger.ToCharArray();
- char[] frachars = fra.ToCharArray();
- char[] spachars = spa.ToCharArray();
- char[] itachars = ita.ToCharArray();
- char[] dutchars = dut.ToCharArray();
-
- byte[] titlekey = WadInfo.GetTitleKey(wadfile);
- string[,] conts = WadInfo.GetContentInfo(wadfile);
- int tmdpos = WadInfo.GetTmdPos(wadfile);
- int tmdsize = WadInfo.GetTmdSize(wadfile);
- int nullapp = 0;
- int contentpos = 64 + Tools.AddPadding(WadInfo.GetCertSize(wadfile)) + Tools.AddPadding(WadInfo.GetTikSize(wadfile)) + Tools.AddPadding(WadInfo.GetTmdSize(wadfile));
- SHA1Managed sha1 = new SHA1Managed();
-
- Tools.ChangeProgress(10);
-
- for (int i = 0; i < conts.GetLength(0); i++)
- {
- if (conts[i, 1] == "00000000")
- {
- nullapp = i;
- break;
- }
- else
- contentpos += Tools.AddPadding(Convert.ToInt32(conts[i, 3]));
- }
-
- byte[] contenthandle = DecryptContent(wadfile, nullapp, titlekey);
-
- Tools.ChangeProgress(25);
-
- int imetpos = 0;
-
- for (int z = 0; z < 400; z++)
- {
- if (Convert.ToChar(contenthandle[z]) == 'I')
- if (Convert.ToChar(contenthandle[z + 1]) == 'M')
- if (Convert.ToChar(contenthandle[z + 2]) == 'E')
- if (Convert.ToChar(contenthandle[z + 3]) == 'T')
- {
- imetpos = z;
- break;
- }
- }
-
- Tools.ChangeProgress(40);
-
- int count = 0;
-
- for (int x = imetpos; x < imetpos + 40; x += 2)
- {
- if (japchars.Length > count) { contenthandle[x + 29] = Convert.ToByte(japchars[count]); }
- else { contenthandle[x + 29] = 0x00; }
- if (engchars.Length > count) { contenthandle[x + 29 + 84] = Convert.ToByte(engchars[count]); }
- else { contenthandle[x + 29 + 84] = 0x00; }
- if (gerchars.Length > count) { contenthandle[x + 29 + 84 * 2] = Convert.ToByte(gerchars[count]); }
- else { contenthandle[x + 29 + 84 * 2] = 0x00; }
- if (frachars.Length > count) { contenthandle[x + 29 + 84 * 3] = Convert.ToByte(frachars[count]); }
- else { contenthandle[x + 29 + 84 * 3] = 0x00; }
- if (spachars.Length > count) { contenthandle[x + 29 + 84 * 4] = Convert.ToByte(spachars[count]); }
- else { contenthandle[x + 29 + 84 * 4] = 0x00; }
- if (itachars.Length > count) { contenthandle[x + 29 + 84 * 5] = Convert.ToByte(itachars[count]); }
- else { contenthandle[x + 29 + 84 * 5] = 0x00; }
- if (dutchars.Length > count) { contenthandle[x + 29 + 84 * 6] = Convert.ToByte(dutchars[count]); }
- else { contenthandle[x + 29 + 84 * 6] = 0x00; }
-
- count++;
- }
-
- Tools.ChangeProgress(50);
-
- byte[] newmd5 = new byte[16];
- contenthandle = FixMD5InImet(contenthandle, out newmd5);
- byte[] newsha = sha1.ComputeHash(contenthandle);
-
- contenthandle = EncryptContent(contenthandle, WadInfo.ReturnTmd(wadfile), nullapp, titlekey, false);
-
- Tools.ChangeProgress(70);
-
- for (int y = 0; y < contenthandle.Length; y++)
- {
- wadfile[contentpos + y] = contenthandle[y];
- }
-
- //SHA1 in TMD
- byte[] tmd = Tools.GetPartOfByteArray(wadfile, tmdpos, tmdsize);
- for (int i = 0; i < 20; i++)
- tmd[0x1f4 + (36 * nullapp) + i] = newsha[i];
- TruchaSign(tmd, 1);
- wadfile = Tools.InsertByteArray(wadfile, tmd, tmdpos);
-
- int footer = WadInfo.GetFooterSize(wadfile);
-
- Tools.ChangeProgress(80);
-
- if (footer > 0)
- {
- int footerpos = wadfile.Length - footer;
- int imetposfoot = 0;
-
- for (int z = 0; z < 200; z++)
- {
- if (Convert.ToChar(wadfile[footerpos + z]) == 'I')
- if (Convert.ToChar(wadfile[footerpos + z + 1]) == 'M')
- if (Convert.ToChar(wadfile[footerpos + z + 2]) == 'E')
- if (Convert.ToChar(wadfile[footerpos + z + 3]) == 'T')
- {
- imetposfoot = footerpos + z;
- break;
- }
- }
-
- Tools.ChangeProgress(90);
-
- int count2 = 0;
-
- for (int x = imetposfoot; x < imetposfoot + 40; x += 2)
- {
- if (japchars.Length > count2) { wadfile[x + 29] = Convert.ToByte(japchars[count2]); }
- else { wadfile[x + 29] = 0x00; }
- if (engchars.Length > count2) { wadfile[x + 29 + 84] = Convert.ToByte(engchars[count2]); }
- else { wadfile[x + 29 + 84] = 0x00; }
- if (gerchars.Length > count2) { wadfile[x + 29 + 84 * 2] = Convert.ToByte(gerchars[count2]); }
- else { wadfile[x + 29 + 84 * 2] = 0x00; }
- if (frachars.Length > count2) { wadfile[x + 29 + 84 * 3] = Convert.ToByte(frachars[count2]); }
- else { wadfile[x + 29 + 84 * 3] = 0x00; }
- if (spachars.Length > count2) { wadfile[x + 29 + 84 * 4] = Convert.ToByte(spachars[count2]); }
- else { wadfile[x + 29 + 84 * 4] = 0x00; }
- if (itachars.Length > count2) { wadfile[x + 29 + 84 * 5] = Convert.ToByte(itachars[count2]); }
- else { wadfile[x + 29 + 84 * 5] = 0x00; }
- if (dutchars.Length > count2) { wadfile[x + 29 + 84 * 6] = Convert.ToByte(dutchars[count2]); }
- else { wadfile[x + 29 + 84 * 6] = 0x00; }
-
- count2++;
- }
-
- for (int i = 0; i < 16; i++)
- wadfile[imetposfoot + 1456 + i] = newmd5[i];
- }
-
- Tools.ChangeProgress(100);
- return wadfile;
- }
-
- ///
- /// Changes the Title ID in the Tik or Tmd file
- ///
- ///
- /// 0 = Tik, 1 = Tmd
- ///
- public static void ChangeTitleID(string tiktmdfile, int type, string titleid)
- {
- byte[] temp = Tools.LoadFileToByteArray(tiktmdfile);
- temp = ChangeTitleID(temp, type, titleid);
- Tools.SaveFileFromByteArray(temp, tiktmdfile);
- }
-
- ///
- /// Changes the Title ID in the Tik or Tmd file
- ///
- ///
- /// 0 = Tik, 1 = Tmd
- ///
- public static byte[] ChangeTitleID(byte[] tiktmd, int type, string titleid)
- {
- int offset = 0x1e0;
- if (type == 1) offset = 0x190;
- char[] id = titleid.ToCharArray();
-
- tiktmd[offset] = (byte)id[0];
- tiktmd[offset + 1] = (byte)id[1];
- tiktmd[offset + 2] = (byte)id[2];
- tiktmd[offset + 3] = (byte)id[3];
-
- tiktmd = TruchaSign(tiktmd, type);
-
- return tiktmd;
- }
-
- ///
- /// Changes the title ID of the wad file
- ///
- ///
- ///
- ///
- public static byte[] ChangeTitleID(byte[] wadfile, string titleid)
- {
- Tools.ChangeProgress(0);
-
- int tikpos = WadInfo.GetTikPos(wadfile);
- int tmdpos = WadInfo.GetTmdPos(wadfile);
- char[] id = titleid.ToCharArray();
-
- byte[] oldtitlekey = WadInfo.GetTitleKey(wadfile);
-
- Tools.ChangeProgress(20);
-
- //Change the ID in the ticket
- wadfile[tikpos + 0x1e0] = (byte)id[0];
- wadfile[tikpos + 0x1e1] = (byte)id[1];
- wadfile[tikpos + 0x1e2] = (byte)id[2];
- wadfile[tikpos + 0x1e3] = (byte)id[3];
-
- //Change the ID in the tmd
- wadfile[tmdpos + 0x190] = (byte)id[0];
- wadfile[tmdpos + 0x191] = (byte)id[1];
- wadfile[tmdpos + 0x192] = (byte)id[2];
- wadfile[tmdpos + 0x193] = (byte)id[3];
-
- Tools.ChangeProgress(40);
-
- //Trucha-Sign both
- wadfile = TruchaSign(wadfile, 0);
-
- Tools.ChangeProgress(50);
-
- wadfile = TruchaSign(wadfile, 1);
-
- Tools.ChangeProgress(60);
-
- byte[] newtitlekey = WadInfo.GetTitleKey(wadfile);
- byte[] tmd = WadInfo.ReturnTmd(wadfile);
-
- int contentcount = WadInfo.GetContentNum(wadfile);
-
- wadfile = ReEncryptAllContents(wadfile, oldtitlekey, newtitlekey);
-
- Tools.ChangeProgress(100);
- return wadfile;
- }
-
- ///
- /// Changes the title ID of the wad file
- ///
- ///
- ///
- public static void ChangeTitleID(string wadfile, string titleid)
- {
- byte[] wadarray = Tools.LoadFileToByteArray(wadfile);
- wadarray = ChangeTitleID(wadarray, titleid);
-
- using (FileStream fs = new FileStream(wadfile, FileMode.Open, FileAccess.Write))
- {
- fs.Seek(0, SeekOrigin.Begin);
- fs.Write(wadarray, 0, wadarray.Length);
- }
- }
-
- ///
- /// Clears the Signature of the Tik / Tmd to 0x00
- ///
- /// Wad, Tik or Tmd
- /// 0 = Tik, 1 = Tmd
- ///
- public static byte[] ClearSignature(byte[] wadtiktmd, int type)
- {
- int tmdtikpos = 0;
- int tmdtiksize = wadtiktmd.Length; ;
-
- if (WadInfo.IsThisWad(wadtiktmd) == true)
- {
- //It's a wad file, so get the tik or tmd position and length
- switch (type)
- {
- case 1:
- tmdtikpos = WadInfo.GetTmdPos(wadtiktmd);
- tmdtiksize = WadInfo.GetTmdSize(wadtiktmd);
- break;
- default:
- tmdtikpos = WadInfo.GetTikPos(wadtiktmd);
- tmdtiksize = WadInfo.GetTikSize(wadtiktmd);
- break;
- }
- }
-
- for (int i = 4; i < 260; i++)
- {
- wadtiktmd[tmdtikpos + i] = 0x00;
- }
-
- return wadtiktmd;
- }
-
- ///
- /// Trucha-Signs the Tik or Tmd
- ///
- /// Wad or Tik or Tmd
- /// 0 = Tik, 1 = Tmd
- ///
- public static void TruchaSign(string file, int type)
- {
- byte[] temp = Tools.LoadFileToByteArray(file);
- temp = TruchaSign(temp, type);
- Tools.SaveFileFromByteArray(temp, file);
- }
-
- ///
- /// Trucha-Signs the Tik or Tmd
- ///
- /// Wad or Tik or Tmd
- /// 0 = Tik, 1 = Tmd
- ///
- public static byte[] TruchaSign(byte[] wadtiktmd, int type)
- {
- SHA1Managed sha = new SHA1Managed();
- int[] position = new int[2] { 0x1f1, 0x1d4 }; //0x104 0x1c1
- int[] tosign = new int[2] { 0x140, 0x140 }; //0x104 0x140
- int tiktmdpos = 0;
- int tiktmdsize = wadtiktmd.Length;
-
- if (sha.ComputeHash(wadtiktmd, tiktmdpos + tosign[type], tiktmdsize - tosign[type])[0] != 0x00)
- {
- ClearSignature(wadtiktmd, type);
-
- if (WadInfo.IsThisWad(wadtiktmd) == true)
- {
- //It's a wad file
- if (type == 0) //Get Tik position and size
- {
- tiktmdpos = WadInfo.GetTikPos(wadtiktmd);
- tiktmdsize = WadInfo.GetTikSize(wadtiktmd);
- }
- else //Get Tmd position and size
- {
- tiktmdpos = WadInfo.GetTmdPos(wadtiktmd);
- tiktmdsize = WadInfo.GetTmdSize(wadtiktmd);
- }
- }
-
- byte[] sha1 = new byte[20];
-
- for (UInt16 i = 0; i < 65535; i++)
- {
- byte[] hex = BitConverter.GetBytes(i);
- wadtiktmd[tiktmdpos + position[type]] = hex[0];
- wadtiktmd[tiktmdpos + position[type] + 1] = hex[1];
-
- sha1 = sha.ComputeHash(wadtiktmd, tiktmdpos + tosign[type], tiktmdsize - tosign[type]);
- if (sha1[0] == 0x00) break;
- }
-
- return wadtiktmd;
- }
- else return wadtiktmd;
- }
-
- ///
- /// Decrypts the given content
- ///
- ///
- ///
- public static byte[] DecryptContent(byte[] wadfile, int contentcount, byte[] titlekey)
- {
- int tmdpos = WadInfo.GetTmdPos(wadfile);
- byte[] iv = new byte[16];
- string[,] continfo = WadInfo.GetContentInfo(wadfile);
- int contentsize = Convert.ToInt32(continfo[contentcount, 3]);
- int paddedsize = Tools.AddPadding(contentsize, 16);
-
- int contentpos = 64 + Tools.AddPadding(WadInfo.GetCertSize(wadfile)) + Tools.AddPadding(WadInfo.GetTikSize(wadfile)) + Tools.AddPadding(WadInfo.GetTmdSize(wadfile));
-
- for (int x = 0; x < contentcount; x++)
- {
- contentpos += Tools.AddPadding(Convert.ToInt32(continfo[x, 3]));
- }
-
- iv[0] = wadfile[tmdpos + 0x1e8 + (0x24 * contentcount)];
- iv[1] = wadfile[tmdpos + 0x1e9 + (0x24 * contentcount)];
-
- RijndaelManaged decrypt = new RijndaelManaged();
- decrypt.Mode = CipherMode.CBC;
- decrypt.Padding = PaddingMode.None;
- decrypt.KeySize = 128;
- decrypt.BlockSize = 128;
- decrypt.Key = titlekey;
- decrypt.IV = iv;
-
- ICryptoTransform cryptor = decrypt.CreateDecryptor();
-
- MemoryStream memory = new MemoryStream(wadfile, contentpos, paddedsize);
- CryptoStream crypto = new CryptoStream(memory, cryptor, CryptoStreamMode.Read);
-
- bool fullread = false;
- byte[] buffer = new byte[16384];
- byte[] cont = new byte[1];
-
- using (MemoryStream ms = new MemoryStream())
- {
- while (fullread == false)
- {
- int len = 0;
- if ((len = crypto.Read(buffer, 0, buffer.Length)) <= 0)
- {
- fullread = true;
- cont = ms.ToArray();
- }
- ms.Write(buffer, 0, len);
- }
- }
-
- memory.Close();
- crypto.Close();
-
- Array.Resize(ref cont, contentsize);
-
- return cont;
- }
-
- ///
- /// Decrypts the given content
- ///
- ///
- ///
- ///
- ///
- ///
- public static byte[] DecryptContent(byte[] content, byte[] tmd, int contentcount, byte[] titlekey)
- {
- byte[] iv = new byte[16];
- string[,] continfo = WadInfo.GetContentInfo(tmd);
- int contentsize = content.Length;
- int paddedsize = Tools.AddPadding(contentsize, 16);
- Array.Resize(ref content, paddedsize);
-
- iv[0] = tmd[0x1e8 + (0x24 * contentcount)];
- iv[1] = tmd[0x1e9 + (0x24 * contentcount)];
-
- RijndaelManaged decrypt = new RijndaelManaged();
- decrypt.Mode = CipherMode.CBC;
- decrypt.Padding = PaddingMode.None;
- decrypt.KeySize = 128;
- decrypt.BlockSize = 128;
- decrypt.Key = titlekey;
- decrypt.IV = iv;
-
- ICryptoTransform cryptor = decrypt.CreateDecryptor();
-
- MemoryStream memory = new MemoryStream(content, 0, paddedsize);
- CryptoStream crypto = new CryptoStream(memory, cryptor, CryptoStreamMode.Read);
-
- bool fullread = false;
- byte[] buffer = new byte[memory.Length];
- byte[] cont = new byte[1];
-
- using (MemoryStream ms = new MemoryStream())
- {
- while (fullread == false)
- {
- int len = 0;
- if ((len = crypto.Read(buffer, 0, buffer.Length)) <= 0)
- {
- fullread = true;
- cont = ms.ToArray();
- }
- ms.Write(buffer, 0, len);
- }
- }
-
- memory.Close();
- crypto.Close();
-
- return cont;
- }
-
- ///
- /// Encrypts the given content and adds a padding to the next 64 bytes
- ///
- ///
- ///
- ///
- ///
- ///
- public static byte[] EncryptContent(byte[] content, byte[] tmd, int contentcount, byte[] titlekey, bool addpadding)
- {
- byte[] iv = new byte[16];
- string[,] continfo = WadInfo.GetContentInfo(tmd);
- int contentsize = content.Length;
- int paddedsize = Tools.AddPadding(contentsize, 16);
- Array.Resize(ref content, paddedsize);
-
- iv[0] = tmd[0x1e8 + (0x24 * contentcount)];
- iv[1] = tmd[0x1e9 + (0x24 * contentcount)];
-
- RijndaelManaged encrypt = new RijndaelManaged();
- encrypt.Mode = CipherMode.CBC;
- encrypt.Padding = PaddingMode.None;
- encrypt.KeySize = 128;
- encrypt.BlockSize = 128;
- encrypt.Key = titlekey;
- encrypt.IV = iv;
-
- ICryptoTransform cryptor = encrypt.CreateEncryptor();
-
- MemoryStream memory = new MemoryStream(content, 0, paddedsize);
- CryptoStream crypto = new CryptoStream(memory, cryptor, CryptoStreamMode.Read);
-
- bool fullread = false;
- byte[] buffer = new byte[memory.Length];
- byte[] cont = new byte[1];
-
- using (MemoryStream ms = new MemoryStream())
- {
- while (fullread == false)
- {
- int len = 0;
- if ((len = crypto.Read(buffer, 0, buffer.Length)) <= 0)
- {
- fullread = true;
- cont = ms.ToArray();
- }
- ms.Write(buffer, 0, len);
- }
- }
-
- memory.Close();
- crypto.Close();
-
- if (addpadding == true) { Array.Resize(ref cont, Tools.AddPadding(cont.Length)); }
- return cont;
- }
-
- ///
- /// Re-Encrypts the given content
- ///
- ///
- ///
- public static byte[] ReEncryptAllContents(byte[] wadfile, byte[] oldtitlekey, byte[] newtitlekey)
- {
- int contentnum = WadInfo.GetContentNum(wadfile);
- int certsize = WadInfo.GetCertSize(wadfile);
- int tiksize = WadInfo.GetTikSize(wadfile);
- int tmdsize = WadInfo.GetTmdSize(wadfile);
- int contentpos = 64 + Tools.AddPadding(certsize) + Tools.AddPadding(tiksize) + Tools.AddPadding(tmdsize);
-
- for (int i = 0; i < contentnum; i++)
- {
- byte[] tmd = WadInfo.ReturnTmd(wadfile);
- byte[] decryptedcontent = DecryptContent(wadfile, i, oldtitlekey);
- byte[] encryptedcontent = EncryptContent(decryptedcontent, tmd, i, newtitlekey, false);
-
- for (int j = 0; j < encryptedcontent.Length; j++)
- {
- wadfile[contentpos + j] = encryptedcontent[j];
- }
- contentpos += Tools.AddPadding(encryptedcontent.Length);
- }
-
- return wadfile;
- }
-
- ///
- /// Fixes the MD5 Sum in the IMET Header
- ///
- ///
- ///
- public static byte[] FixMD5InImet(byte[] file, out byte[] newmd5)
- {
- if (Convert.ToChar(file[128]) == 'I' &&
- Convert.ToChar(file[129]) == 'M' &&
- Convert.ToChar(file[130]) == 'E' &&
- Convert.ToChar(file[131]) == 'T')
- {
- byte[] buffer = new byte[1536];
-
- using (MemoryStream ms = new MemoryStream())
- {
- ms.Write(file, 0x40, 1536);
- buffer = ms.ToArray();
- }
-
- for (int i = 0; i < 16; i++)
- buffer[1520 + i] = 0x00;
-
- MD5 md5 = new MD5CryptoServiceProvider();
- byte[] hash = md5.ComputeHash(buffer);
-
- for (int i = 0; i < 16; i++)
- file[1584 + i] = hash[i];
-
- newmd5 = hash;
- return file;
- }
- else
- {
- byte[] oldmd5 = new byte[16];
-
- using (MemoryStream ms = new MemoryStream())
- {
- ms.Write(file, 1584, 16);
- oldmd5 = ms.ToArray();
- }
-
- newmd5 = oldmd5;
- return file;
- }
- }
-
- ///
- /// Fixes the MD5 Sum in the IMET Header.
- ///
- ///
- ///
- public static byte[] FixMD5InImet(byte[] file)
- {
- byte[] tmp = new byte[16];
- return FixMD5InImet(file, out tmp);
- }
-
- ///
- /// Updates the Content Info in the Tmd.
- /// Tmd and Contents must be in the same Directory
- ///
- ///
- public static void UpdateTmdContents(string tmdfile)
- {
- FileStream tmd = new FileStream(tmdfile, FileMode.Open, FileAccess.ReadWrite);
-
- tmd.Seek(0x1de, SeekOrigin.Begin);
- int contentcount = Tools.HexStringToInt(tmd.ReadByte().ToString("x2") + tmd.ReadByte().ToString("x2"));
-
- for (int i = 0; i < contentcount; i++)
- {
- int oldsize = 0;
- int contentpos = 0x1e4 + (36 * i);
-
- tmd.Seek(contentpos + 4, SeekOrigin.Begin);
- string index = "0000" + tmd.ReadByte().ToString("x2") + tmd.ReadByte().ToString("x2");
-
- tmd.Seek(contentpos + 8, SeekOrigin.Begin);
- try
- {
- oldsize = Tools.HexStringToInt(tmd.ReadByte().ToString("x2") +
- tmd.ReadByte().ToString("x2") +
- tmd.ReadByte().ToString("x2") +
- tmd.ReadByte().ToString("x2") +
- tmd.ReadByte().ToString("x2") +
- tmd.ReadByte().ToString("x2") +
- tmd.ReadByte().ToString("x2") +
- tmd.ReadByte().ToString("x2"));
- }
- catch { }
-
- byte[] oldsha1 = new byte[20];
- tmd.Read(oldsha1, 0, oldsha1.Length);
-
- if (File.Exists(tmdfile.Remove(tmdfile.LastIndexOf('\\') + 1) + index + ".app"))
- {
- byte[] content = Wii.Tools.LoadFileToByteArray(tmdfile.Remove(tmdfile.LastIndexOf('\\') + 1) + index + ".app");
- int newsize = content.Length;
-
- if (newsize != oldsize)
- {
- byte[] changedsize = Tools.FileLengthToByteArray(newsize);
-
- tmd.Seek(contentpos + 8, SeekOrigin.Begin);
- for (int x = 8; x > changedsize.Length; x--) tmd.WriteByte(0x00);
- tmd.Write(changedsize, 0, changedsize.Length);
- }
-
- SHA1Managed sha1 = new SHA1Managed();
- byte[] newsha1 = sha1.ComputeHash(content);
- sha1.Clear();
-
- if (Tools.CompareByteArrays(newsha1, oldsha1) == false)
- {
- tmd.Seek(contentpos + 16, SeekOrigin.Begin);
- tmd.Write(newsha1, 0, newsha1.Length);
- }
- }
- else
- {
- throw new Exception("At least one content file wasn't found!");
- }
- }
-
- tmd.Close();
- }
-
- ///
- /// Changes the Boot Index in the Tmd to the given value
- ///
- ///
- ///
- public static byte[] ChangeTmdBootIndex(byte[] wadtmd, int newindex)
- {
- int tmdpos = 0;
-
- if (WadInfo.IsThisWad(wadtmd) == true)
- tmdpos = WadInfo.GetTmdPos(wadtmd);
-
- byte[] index = BitConverter.GetBytes((UInt16)newindex);
- wadtmd[tmdpos + 0x1e0] = index[1];
- wadtmd[tmdpos + 0x1e1] = index[0];
-
- return wadtmd;
- }
-
- ///
- /// Changes the Content Count in the Tmd
- ///
- ///
- ///
- ///
- public static byte[] ChangeTmdContentCount(byte[] wadtmd, int newcount)
- {
- int tmdpos = 0;
-
- if (WadInfo.IsThisWad(wadtmd) == true)
- tmdpos = WadInfo.GetTmdPos(wadtmd);
-
- byte[] count = BitConverter.GetBytes((UInt16)newcount);
- wadtmd[tmdpos + 0x1de] = count[1];
- wadtmd[tmdpos + 0x1df] = count[0];
-
- return wadtmd;
- }
-
- ///
- /// Changes the Slot where the IOS Wad will be installed to
- ///
- ///
- ///
- ///
- public static byte[] ChangeIosSlot(byte[] wadfile, int newslot)
- {
- Tools.ChangeProgress(0);
-
- int tikpos = WadInfo.GetTikPos(wadfile);
- int tmdpos = WadInfo.GetTmdPos(wadfile);
- byte[] slot = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(newslot));
-
- byte[] oldtitlekey = WadInfo.GetTitleKey(wadfile);
-
- Tools.ChangeProgress(20);
-
- //Change the ID in the ticket
- wadfile[tikpos + 0x1e0] = slot[0];
- wadfile[tikpos + 0x1e1] = slot[1];
- wadfile[tikpos + 0x1e2] = slot[2];
- wadfile[tikpos + 0x1e3] = slot[3];
-
- //Change the ID in the tmd
- wadfile[tmdpos + 0x190] = slot[0];
- wadfile[tmdpos + 0x191] = slot[1];
- wadfile[tmdpos + 0x192] = slot[2];
- wadfile[tmdpos + 0x193] = slot[3];
-
- Tools.ChangeProgress(40);
-
- //Trucha-Sign both
- wadfile = TruchaSign(wadfile, 0);
-
- Tools.ChangeProgress(50);
-
- wadfile = TruchaSign(wadfile, 1);
-
- Tools.ChangeProgress(60);
-
- byte[] newtitlekey = WadInfo.GetTitleKey(wadfile);
- byte[] tmd = WadInfo.ReturnTmd(wadfile);
-
- int contentcount = WadInfo.GetContentNum(wadfile);
-
- wadfile = ReEncryptAllContents(wadfile, oldtitlekey, newtitlekey);
-
- Tools.ChangeProgress(100);
- return wadfile;
- }
-
- ///
- /// Changes the Title Version of a Wad or Tmd
- ///
- ///
- ///
- ///
- public static byte[] ChangeTitleVersion(byte[] wadtmd, int newversion)
- {
- if (newversion > 65535) throw new Exception("Version can be max. 65535");
-
- int offset = 0x1dc;
- int tmdpos = 0;
-
- if (WadInfo.IsThisWad(wadtmd))
- tmdpos = WadInfo.GetTmdPos(wadtmd);
-
- byte[] version = BitConverter.GetBytes((UInt16)newversion);
- Array.Reverse(version);
-
- wadtmd[tmdpos + offset] = version[0];
- wadtmd[tmdpos + offset + 1] = version[1];
-
- wadtmd = TruchaSign(wadtmd, 1);
-
- return wadtmd;
- }
- }
-
- public class WadUnpack
- {
- ///
- /// Unpacks the the wad file
- ///
- public static void UnpackWad(string pathtowad, string destinationpath)
- {
- byte[] wadfile = Tools.LoadFileToByteArray(pathtowad);
- UnpackWad(wadfile, destinationpath);
- }
-
- ///
- /// Unpacks the wad file to *wadpath*\wadunpack\
- ///
- ///
- public static void UnpackWad(string pathtowad)
- {
- string destinationpath = pathtowad.Remove(pathtowad.LastIndexOf('\\'));
- byte[] wadfile = Tools.LoadFileToByteArray(pathtowad);
- UnpackWad(wadfile, destinationpath);
- }
-
- ///
- /// Unpacks the 00000000.app of a wad
- ///
- ///
- ///
- public static void UnpackNullApp(string wadfile, string destination)
- {
- if (!destination.EndsWith(".app")) destination += "\\00000000.app";
-
- byte[] wad = Tools.LoadFileToByteArray(wadfile);
- byte[] nullapp = UnpackNullApp(wad);
- Tools.SaveFileFromByteArray(nullapp, destination);
- }
-
- ///
- /// Unpacks the 00000000.app of a wad
- ///
- ///
- ///
- public static byte[] UnpackNullApp(byte[] wadfile)
- {
- int certsize = WadInfo.GetCertSize(wadfile);
- int tiksize = WadInfo.GetTikSize(wadfile);
- int tmdpos = WadInfo.GetTmdPos(wadfile);
- int tmdsize = WadInfo.GetTmdSize(wadfile);
- int contentpos = 64 + Tools.AddPadding(certsize) + Tools.AddPadding(tiksize) + Tools.AddPadding(tmdsize);
-
- byte[] titlekey = WadInfo.GetTitleKey(wadfile);
- string[,] contents = WadInfo.GetContentInfo(wadfile);
-
- for (int i = 0; i < contents.GetLength(0); i++)
- {
- if (contents[i, 1] == "00000000")
- {
- return WadEdit.DecryptContent(wadfile, i, titlekey);
- }
- }
-
- throw new Exception("00000000.app couldn't be found in the Wad");
- }
-
- ///
- /// Unpacks the wad file
- ///
- public static void UnpackWad(byte[] wadfile, string destinationpath)
- {
- if (destinationpath[destinationpath.Length - 1] != '\\')
- { destinationpath = destinationpath + "\\"; }
-
- if (!Directory.Exists(destinationpath))
- { Directory.CreateDirectory(destinationpath); }
- if (Directory.GetFiles(destinationpath, "*.app").Length > 0)
- {
- throw new Exception("At least one of the files to unpack already exists!");
- }
-
- int certpos = 0x40;
- int certsize = WadInfo.GetCertSize(wadfile);
- int tikpos = WadInfo.GetTikPos(wadfile);
- int tiksize = WadInfo.GetTikSize(wadfile);
- int tmdpos = WadInfo.GetTmdPos(wadfile);
- int tmdsize = WadInfo.GetTmdSize(wadfile);
- int contentlength = WadInfo.GetContentSize(wadfile);
- int footersize = WadInfo.GetFooterSize(wadfile);
- int footerpos = 64 + Tools.AddPadding(certsize) + Tools.AddPadding(tiksize) + Tools.AddPadding(tmdsize) + Tools.AddPadding(contentlength);
- string wadpath = WadInfo.GetNandPath(wadfile, 0).Remove(8, 1);
- string[,] contents = WadInfo.GetContentInfo(wadfile);
- byte[] titlekey = WadInfo.GetTitleKey(wadfile);
- int contentpos = 64 + Tools.AddPadding(certsize) + Tools.AddPadding(tiksize) + Tools.AddPadding(tmdsize);
-
- //unpack cert
- using (FileStream cert = new FileStream(destinationpath + wadpath + ".cert", FileMode.Create))
- {
- cert.Seek(0, SeekOrigin.Begin);
- cert.Write(wadfile, certpos, certsize);
- }
-
- //unpack ticket
- using (FileStream tik = new FileStream(destinationpath + wadpath + ".tik", FileMode.Create))
- {
- tik.Seek(0, SeekOrigin.Begin);
- tik.Write(wadfile, tikpos, tiksize);
- }
-
- //unpack tmd
- using (FileStream tmd = new FileStream(destinationpath + wadpath + ".tmd", FileMode.Create))
- {
- tmd.Seek(0, SeekOrigin.Begin);
- tmd.Write(wadfile, tmdpos, tmdsize);
- }
-
- //unpack trailer
- try
- {
- if (footersize > 0)
- {
- using (FileStream trailer = new FileStream(destinationpath + wadpath + ".trailer", FileMode.Create))
- {
- trailer.Seek(0, SeekOrigin.Begin);
- trailer.Write(wadfile, footerpos, footersize);
- }
- }
- }
- catch { } //who cares if the trailer doesn't extract properly?
-
- Tools.ChangeProgress(0);
-
- //unpack contents
- for (int i = 0; i < contents.GetLength(0); i++)
- {
- Tools.ChangeProgress((i + 1) * 100 / contents.GetLength(0));
- byte[] thiscontent = WadEdit.DecryptContent(wadfile, i, titlekey);
- FileStream content = new FileStream(destinationpath + contents[i, 1] + ".app", FileMode.Create);
-
- content.Write(thiscontent, 0, thiscontent.Length);
- content.Close();
-
- contentpos += Tools.AddPadding(thiscontent.Length);
-
- //sha1 comparison
- SHA1Managed sha1 = new SHA1Managed();
- byte[] thishash = sha1.ComputeHash(thiscontent);
- byte[] tmdhash = Tools.HexStringToByteArray(contents[i, 4]);
-
- if (Tools.CompareByteArrays(thishash, tmdhash) == false)
- throw new Exception("At least one content's hash doesn't match the hash in the Tmd!");
- }
- }
-
- ///
- /// Unpacks the wad file to the given directory.
- /// Shared contents will be unpacked to /shared1
- ///
- ///
- ///
- public static void UnpackToNand(string wadfile, string nandpath)
- {
- byte[] wadarray = Tools.LoadFileToByteArray(wadfile);
- UnpackToNand(wadarray, nandpath);
- }
-
- ///
- /// Unpacks the wad file to the given directory.
- /// Shared contents will be unpacked to /shared1
- ///
- ///
- ///
- public static void UnpackToNand(byte[] wadfile, string nandpath)
- {
- string path = WadInfo.GetNandPath(wadfile, 0);
- string path1 = path.Remove(path.IndexOf('\\'));
- string path2 = path.Remove(0, path.IndexOf('\\') + 1);
-
- if (nandpath[nandpath.Length - 1] != '\\') { nandpath = nandpath + "\\"; }
-
- if (!Directory.Exists(nandpath + "ticket")) { Directory.CreateDirectory(nandpath + "ticket"); }
- if (!Directory.Exists(nandpath + "title")) { Directory.CreateDirectory(nandpath + "title"); }
- if (!Directory.Exists(nandpath + "ticket\\" + path1)) { Directory.CreateDirectory(nandpath + "ticket\\" + path1); }
- if (!Directory.Exists(nandpath + "title\\" + path1)) { Directory.CreateDirectory(nandpath + "title\\" + path1); }
- if (!Directory.Exists(nandpath + "title\\" + path1 + "\\" + path2)) { Directory.CreateDirectory(nandpath + "title\\" + path1 + "\\" + path2); }
- if (!Directory.Exists(nandpath + "title\\" + path1 + "\\" + path2 + "\\content")) { Directory.CreateDirectory(nandpath + "title\\" + path1 + "\\" + path2 + "\\content"); }
- if (!Directory.Exists(nandpath + "title\\" + path1 + "\\" + path2 + "\\data")) { Directory.CreateDirectory(nandpath + "title\\" + path1 + "\\" + path2 + "\\data"); }
- if (!Directory.Exists(nandpath + "shared1")) Directory.CreateDirectory(nandpath + "shared1");
-
- int certsize = WadInfo.GetCertSize(wadfile);
- int tikpos = WadInfo.GetTikPos(wadfile);
- int tiksize = WadInfo.GetTikSize(wadfile);
- int tmdpos = WadInfo.GetTmdPos(wadfile);
- int tmdsize = WadInfo.GetTmdSize(wadfile);
- int contentlength = WadInfo.GetContentSize(wadfile);
- string[,] contents = WadInfo.GetContentInfo(wadfile);
- byte[] titlekey = WadInfo.GetTitleKey(wadfile);
- int contentpos = 64 + Tools.AddPadding(certsize) + Tools.AddPadding(tiksize) + Tools.AddPadding(tmdsize);
-
- //unpack ticket
- using (FileStream tik = new FileStream(nandpath + "ticket\\" + path1 + "\\" + path2 + ".tik", FileMode.Create))
- {
- tik.Seek(0, SeekOrigin.Begin);
- tik.Write(wadfile, tikpos, tiksize);
- }
-
- //unpack tmd
- using (FileStream tmd = new FileStream(nandpath + "title\\" + path1 + "\\" + path2 + "\\content\\title.tmd", FileMode.Create))
- {
- tmd.Seek(0, SeekOrigin.Begin);
- tmd.Write(wadfile, tmdpos, tmdsize);
- }
-
- Tools.ChangeProgress(0);
-
- //unpack contents
- for (int i = 0; i < contents.GetLength(0); i++)
- {
- Tools.ChangeProgress((i + 1) * 100 / contents.GetLength(0));
- byte[] thiscontent = WadEdit.DecryptContent(wadfile, i, titlekey);
-
- if (contents[i, 2] == "8001")
- {
- if (File.Exists(nandpath + "shared1\\content.map"))
- {
- byte[] contmap = Tools.LoadFileToByteArray(nandpath + "shared1\\content.map");
-
- if (ContentMap.CheckSharedContent(contmap, contents[i, 4]) == false)
- {
- string newname = ContentMap.GetNewSharedContentName(contmap);
-
- FileStream content = new FileStream(nandpath + "shared1\\" + newname + ".app", FileMode.Create);
- content.Write(thiscontent, 0, thiscontent.Length);
- content.Close();
- ContentMap.AddSharedContent(nandpath + "shared1\\content.map", newname, contents[i, 4]);
- }
- }
- else
- {
- FileStream content = new FileStream(nandpath + "shared1\\00000000.app", FileMode.Create);
- content.Write(thiscontent, 0, thiscontent.Length);
- content.Close();
- ContentMap.AddSharedContent(nandpath + "shared1\\content.map", "00000000", contents[i, 4]);
- }
- }
- else
- {
- FileStream content = new FileStream(nandpath + "title\\" + path1 + "\\" + path2 + "\\content\\" + contents[i, 0] + ".app", FileMode.Create);
-
- content.Write(thiscontent, 0, thiscontent.Length);
- content.Close();
- }
-
- contentpos += Tools.AddPadding(thiscontent.Length);
- }
-
- //add titleid to uid.sys, if it doesn't exist
- string titleid = WadInfo.GetFullTitleID(wadfile, 1);
-
- if (File.Exists(nandpath + "\\sys\\uid.sys"))
- {
- FileStream fs = new FileStream(nandpath + "\\sys\\uid.sys", FileMode.Open);
- byte[] uidsys = new byte[fs.Length];
- fs.Read(uidsys, 0, uidsys.Length);
- fs.Close();
-
- if (UID.CheckUID(uidsys, titleid) == false)
- {
- uidsys = UID.AddUID(uidsys, titleid);
- Tools.SaveFileFromByteArray(uidsys, nandpath + "\\sys\\uid.sys");
- }
- }
- else
- {
- if (!Directory.Exists(nandpath + "\\sys")) Directory.CreateDirectory(nandpath + "\\sys");
- byte[] uidsys = UID.AddUID(new byte[0], titleid);
- Tools.SaveFileFromByteArray(uidsys, nandpath + "\\sys\\uid.sys");
- }
- }
- }
-
- public class WadPack
- {
- public static byte[] wadheader = new byte[8] { 0x00, 0x00, 0x00, 0x20, 0x49, 0x73, 0x00, 0x00 };
-
- ///
- /// Packs the contents in the given directory and creates the destination wad file
- ///
- ///
- public static void PackWad(string contentdirectory, string destinationfile, bool includefooter)
- {
- if (contentdirectory[contentdirectory.Length - 1] != '\\') { contentdirectory = contentdirectory + "\\"; }
-
- if (!Directory.Exists(contentdirectory)) throw new DirectoryNotFoundException("The directory doesn't exists:\r\n" + contentdirectory);
- if (Directory.GetFiles(contentdirectory, "*.app").Length < 1) throw new Exception("No *.app file was found");
- if (Directory.GetFiles(contentdirectory, "*.cert").Length < 1) throw new Exception("No *.cert file was found");
- if (Directory.GetFiles(contentdirectory, "*.tik").Length < 1) throw new Exception("No *.tik file was found");
- if (Directory.GetFiles(contentdirectory, "*.tmd").Length < 1) throw new Exception("No *.tmd file was found");
- if (File.Exists(destinationfile)) throw new Exception("The destination file already exists!");
-
- string[] certfile = Directory.GetFiles(contentdirectory, "*.cert");
- string[] tikfile = Directory.GetFiles(contentdirectory, "*.tik");
- string[] tmdfile = Directory.GetFiles(contentdirectory, "*.tmd");
- string[] trailerfile = Directory.GetFiles(contentdirectory, "*.trailer");
-
- byte[] cert = Tools.LoadFileToByteArray(certfile[0]);
- byte[] tik = Tools.LoadFileToByteArray(tikfile[0]);
- byte[] tmd = Tools.LoadFileToByteArray(tmdfile[0]);
-
- string[,] contents = WadInfo.GetContentInfo(tmd);
-
- FileStream wadstream = new FileStream(destinationfile, FileMode.Create);
-
- //Trucha-Sign Tik and Tmd, if they aren't already
- WadEdit.TruchaSign(tik, 0);
- WadEdit.TruchaSign(tmd, 1);
-
- //Write Cert
- wadstream.Seek(64, SeekOrigin.Begin);
- wadstream.Write(cert, 0, cert.Length);
-
- //Write Tik
- wadstream.Seek(64 + Tools.AddPadding(cert.Length), SeekOrigin.Begin);
- wadstream.Write(tik, 0, tik.Length);
-
- //Write Tmd
- wadstream.Seek(64 + Tools.AddPadding(cert.Length) + Tools.AddPadding(tik.Length), SeekOrigin.Begin);
- wadstream.Write(tmd, 0, tmd.Length);
-
- //Write Content
- int allcont = 0;
- int contpos = 64 + Tools.AddPadding(cert.Length) + Tools.AddPadding(tik.Length) + Tools.AddPadding(tmd.Length);
- int contcount = WadInfo.GetContentNum(tmd);
-
- Tools.ChangeProgress(0);
- byte[] titlekey = WadInfo.GetTitleKey(tik);
-
- for (int i = 0; i < contents.GetLength(0); i++)
- {
- Tools.ChangeProgress((i + 1) * 100 / contents.GetLength(0));
- byte[] thiscont = Tools.LoadFileToByteArray(contentdirectory + contents[i, 1] + ".app");
-
- //if (i == contents.GetLength(0) - 1) { thiscont = WadEdit.EncryptContent(thiscont, tmd, i, titlekey, false); }
- //else { thiscont = WadEdit.EncryptContent(thiscont, tmd, i, titlekey, true); }
- thiscont = WadEdit.EncryptContent(thiscont, tmd, i, titlekey, true);
-
- wadstream.Seek(contpos, SeekOrigin.Begin);
- wadstream.Write(thiscont, 0, thiscont.Length);
- contpos += thiscont.Length;
- allcont += thiscont.Length;
- }
-
- //Write Trailer, if exists and includefooter = true
- int trailerlength = 0;
- if (trailerfile.Length > 0 && includefooter == true)
- {
- byte[] trailer = Tools.LoadFileToByteArray(trailerfile[0]);
- trailerlength = trailer.Length;
- Array.Resize(ref trailer, Tools.AddPadding(trailer.Length));
- wadstream.Seek(Tools.AddPadding(contpos), SeekOrigin.Begin);
- wadstream.Write(trailer, 0, trailer.Length);
- }
-
- //Write Header
- byte[] certsize = Tools.FileLengthToByteArray(cert.Length);
- byte[] tiksize = Tools.FileLengthToByteArray(tik.Length);
- byte[] tmdsize = Tools.FileLengthToByteArray(tmd.Length);
- byte[] allcontsize = Tools.FileLengthToByteArray(allcont);
- byte[] trailersize = Tools.FileLengthToByteArray(trailerlength);
-
- wadstream.Seek(0x00, SeekOrigin.Begin);
- wadstream.Write(wadheader, 0, wadheader.Length);
- wadstream.Seek(0x08, SeekOrigin.Begin);
- wadstream.Write(certsize, 0, certsize.Length);
- wadstream.Seek(0x10, SeekOrigin.Begin);
- wadstream.Write(tiksize, 0, tiksize.Length);
- wadstream.Seek(0x14, SeekOrigin.Begin);
- wadstream.Write(tmdsize, 0, tmdsize.Length);
- wadstream.Seek(0x18, SeekOrigin.Begin);
- wadstream.Write(allcontsize, 0, allcontsize.Length);
- wadstream.Seek(0x1c, SeekOrigin.Begin);
- wadstream.Write(trailersize, 0, trailersize.Length);
-
- wadstream.Close();
- }
-
- ///
- /// Packs a Wad from a title installed on Nand
- /// Returns: 0 = OK, 1 = Files missing, 2 = Shared contents missing, 3 = Cert missing
- ///
- ///
- /// XXXXXXXX\XXXXXXXX
- ///
- ///
- public static void PackWadFromNand(string nandpath, string path, string destinationfile)
- {
- if (nandpath[nandpath.Length - 1] != '\\') { nandpath = nandpath + "\\"; }
- string path1 = path.Remove(8);
- string path2 = path.Remove(0, 9);
- string ticketdir = nandpath + "ticket\\" + path1 + "\\";
- string contentdir = nandpath + "title\\" + path1 + "\\" + path2 + "\\content\\";
- string sharedir = nandpath + "shared1\\";
- string certdir = nandpath + "sys\\";
-
- if (!Directory.Exists(ticketdir) ||
- !Directory.Exists(contentdir)) throw new DirectoryNotFoundException("Directory doesn't exist:\r\n" + contentdir);
- if (!Directory.Exists(sharedir)) throw new DirectoryNotFoundException("Directory doesn't exist:\r\n" + sharedir);
- if (!File.Exists(certdir + "cert.sys")) throw new FileNotFoundException("File doesn't exist:\r\n" + certdir + "cert.sys");
-
- byte[] cert = Tools.LoadFileToByteArray(certdir + "cert.sys");
- byte[] tik = Tools.LoadFileToByteArray(ticketdir + path2 + ".tik");
- byte[] tmd = Tools.LoadFileToByteArray(contentdir + "title.tmd");
-
- string[,] contents = WadInfo.GetContentInfo(tmd);
-
- FileStream wadstream = new FileStream(destinationfile, FileMode.Create);
-
- //Trucha-Sign Tik and Tmd, if they aren't already
- WadEdit.TruchaSign(tik, 0);
- WadEdit.TruchaSign(tmd, 1);
-
- //Write Cert
- wadstream.Seek(64, SeekOrigin.Begin);
- wadstream.Write(cert, 0, cert.Length);
-
- //Write Tik
- wadstream.Seek(64 + Tools.AddPadding(cert.Length), SeekOrigin.Begin);
- wadstream.Write(tik, 0, tik.Length);
-
- //Write Tmd
- wadstream.Seek(64 + Tools.AddPadding(cert.Length) + Tools.AddPadding(tik.Length), SeekOrigin.Begin);
- wadstream.Write(tmd, 0, tmd.Length);
-
- //Write Content
- int allcont = 0;
- int contpos = 64 + Tools.AddPadding(cert.Length) + Tools.AddPadding(tik.Length) + Tools.AddPadding(tmd.Length);
- int contcount = WadInfo.GetContentNum(tmd);
-
- Tools.ChangeProgress(0);
- byte[] titlekey = WadInfo.GetTitleKey(tik);
- byte[] contentmap = Tools.LoadFileToByteArray(sharedir + "content.map");
-
- for (int i = 0; i < contents.GetLength(0); i++)
- {
- Tools.ChangeProgress((i + 1) * 100 / contents.GetLength(0));
- byte[] thiscont = new byte[1];
-
- if (contents[i, 2] == "8001")
- {
- string contname = ContentMap.GetSharedContentName(contentmap, contents[i, 4]);
-
- if (contname == "fail")
- {
- wadstream.Close();
- File.Delete(destinationfile);
- throw new FileNotFoundException("At least one shared content is missing!");
- }
-
- thiscont = Tools.LoadFileToByteArray(sharedir + contname + ".app");
- }
- else thiscont = Tools.LoadFileToByteArray(contentdir + contents[i, 0] + ".app");
-
- //if (i == contents.GetLength(0) - 1) { thiscont = WadEdit.EncryptContent(thiscont, tmd, i, titlekey, false); }
- //else { thiscont = WadEdit.EncryptContent(thiscont, tmd, i, titlekey, true); }
- thiscont = WadEdit.EncryptContent(thiscont, tmd, i, titlekey, true);
-
- wadstream.Seek(contpos, SeekOrigin.Begin);
- wadstream.Write(thiscont, 0, thiscont.Length);
- contpos += thiscont.Length;
- allcont += thiscont.Length;
- }
-
- //Write Header
- byte[] certsize = Tools.FileLengthToByteArray(cert.Length);
- byte[] tiksize = Tools.FileLengthToByteArray(tik.Length);
- byte[] tmdsize = Tools.FileLengthToByteArray(tmd.Length);
- byte[] allcontsize = Tools.FileLengthToByteArray(allcont);
- byte[] trailersize = new byte[] { 0x00, 0x00, 0x00, 0x00 };
-
- wadstream.Seek(0x00, SeekOrigin.Begin);
- wadstream.Write(wadheader, 0, wadheader.Length);
- wadstream.Seek(0x08, SeekOrigin.Begin);
- wadstream.Write(certsize, 0, certsize.Length);
- wadstream.Seek(0x10, SeekOrigin.Begin);
- wadstream.Write(tiksize, 0, tiksize.Length);
- wadstream.Seek(0x14, SeekOrigin.Begin);
- wadstream.Write(tmdsize, 0, tmdsize.Length);
- wadstream.Seek(0x18, SeekOrigin.Begin);
- wadstream.Write(allcontsize, 0, allcontsize.Length);
- wadstream.Seek(0x1c, SeekOrigin.Begin);
- wadstream.Write(trailersize, 0, trailersize.Length);
-
- wadstream.Close();
- }
- }
-
- public class UID
- {
- ///
- /// Checks if the given Title ID exists in the uid.sys
- ///
- ///
- ///
- ///
- public static bool CheckUID(byte[] uidsys, string fulltitleid)
- {
- for (int i = 0; i < uidsys.Length; i += 12)
- {
- string temp = "";
-
- for (int y = i; y < i + 8; y++)
- temp += uidsys[y].ToString("x2");
-
- if (temp == fulltitleid) return true;
- }
-
- return false;
- }
-
- ///
- /// Gets a new UID
- ///
- ///
- ///
- public static string GetNewUID(byte[] uidsys)
- {
- string lastuid = uidsys[uidsys.Length - 4].ToString("x2") +
- uidsys[uidsys.Length - 3].ToString("x2") +
- uidsys[uidsys.Length - 2].ToString("x2") +
- uidsys[uidsys.Length - 1].ToString("x2");
-
- string newuid = (int.Parse(lastuid, System.Globalization.NumberStyles.HexNumber) + 1).ToString("x8");
- return newuid;
- }
-
- ///
- /// Adds a Title ID to uid.sys
- ///
- ///
- ///
- ///
- public static byte[] AddUID(byte[] uidsys, string fulltitleid)
- {
- if (uidsys.Length > 11)
- {
- MemoryStream uid = new MemoryStream();
- byte[] titleid = Tools.HexStringToByteArray(fulltitleid);
- byte[] newuid = Tools.HexStringToByteArray(GetNewUID(uidsys));
-
- uid.Write(uidsys, 0, uidsys.Length);
- uid.Write(titleid, 0, titleid.Length);
- uid.Write(newuid, 0, newuid.Length);
-
- return uid.ToArray();
- }
- else
- {
- MemoryStream uid = new MemoryStream();
- byte[] titleid = Tools.HexStringToByteArray(fulltitleid);
- byte[] newuid = new byte[] { 0x00, 0x00, 0x10, 0x00 };
-
- uid.Write(titleid, 0, titleid.Length);
- uid.Write(newuid, 0, newuid.Length);
-
- return uid.ToArray();
- }
- }
- }
-
- public class ContentMap
- {
- ///
- /// Gets the name of the shared content in /shared1/.
- /// Returns "fail", if the content doesn't exist
- ///
- ///
- ///
- ///
- public static string GetSharedContentName(byte[] contentmap, string sha1ofcontent)
- {
- int contindex = 0;
- string result = "";
-
- for (int i = 0; i < contentmap.Length - 19; i++)
- {
- string tmp = "";
- for (int y = 0; y < 20; y++)
- {
- tmp += contentmap[i + y].ToString("x2");
- }
-
- if (tmp == sha1ofcontent)
- {
- contindex = i;
- break;
- }
- }
-
- if (contindex == 0) return "fail";
-
- result += Convert.ToChar(contentmap[contindex - 8]);
- result += Convert.ToChar(contentmap[contindex - 7]);
- result += Convert.ToChar(contentmap[contindex - 6]);
- result += Convert.ToChar(contentmap[contindex - 5]);
- result += Convert.ToChar(contentmap[contindex - 4]);
- result += Convert.ToChar(contentmap[contindex - 3]);
- result += Convert.ToChar(contentmap[contindex - 2]);
- result += Convert.ToChar(contentmap[contindex - 1]);
-
- return result;
- }
-
- ///
- /// Checks, if the shared content exists
- ///
- ///
- ///
- ///
- public static bool CheckSharedContent(byte[] contentmap, string sha1ofcontent)
- {
- for (int i = 0; i < contentmap.Length - 19; i++)
- {
- string tmp = "";
- for (int y = 0; y < 20; y++)
- {
- tmp += contentmap[i + y].ToString("x2");
- }
-
- if (tmp == sha1ofcontent) return true;
- }
-
- return false;
- }
-
- public static string GetNewSharedContentName(byte[] contentmap)
- {
- string name = "";
-
- name += Convert.ToChar(contentmap[contentmap.Length - 28]);
- name += Convert.ToChar(contentmap[contentmap.Length - 27]);
- name += Convert.ToChar(contentmap[contentmap.Length - 26]);
- name += Convert.ToChar(contentmap[contentmap.Length - 25]);
- name += Convert.ToChar(contentmap[contentmap.Length - 24]);
- name += Convert.ToChar(contentmap[contentmap.Length - 23]);
- name += Convert.ToChar(contentmap[contentmap.Length - 22]);
- name += Convert.ToChar(contentmap[contentmap.Length - 21]);
-
- string newname = (int.Parse(name, System.Globalization.NumberStyles.HexNumber) + 1).ToString("x8");
-
- return newname;
- }
-
- public static void AddSharedContent(string contentmap, string contentname, string sha1ofcontent)
- {
- byte[] name = new byte[8];
- byte[] sha1 = new byte[20];
-
- for (int i = 0; i < 8; i++)
- {
- name[i] = (byte)contentname[i];
- }
-
- for (int i = 0; i < sha1ofcontent.Length; i += 2)
- {
- sha1[i / 2] = Convert.ToByte(sha1ofcontent.Substring(i, 2), 16);
- }
-
- using (FileStream map = new FileStream(contentmap, FileMode.OpenOrCreate, FileAccess.ReadWrite))
- {
- map.Seek(0, SeekOrigin.End);
- map.Write(name, 0, name.Length);
- map.Write(sha1, 0, sha1.Length);
- }
- }
- }
-
- public class U8
- {
- ///
- /// Checks if the given file is a U8 Archive
- ///
- ///
- ///
- public static bool CheckU8(byte[] file)
- {
- int length = 2500;
- if (file.Length < length) length = file.Length - 4;
-
- for (int i = 0; i < length; i++)
- {
- if (file[i] == 0x55 && file[i + 1] == 0xAA && file[i + 2] == 0x38 && file[i + 3] == 0x2D)
- return true;
- }
-
- return false;
- }
-
- ///
- /// Checks if the given file is a U8 Archive
- ///
- ///
- ///
- public static bool CheckU8(string file)
- {
- byte[] buff = Tools.LoadFileToByteArray(file, 0, 2500);
- return CheckU8(buff);
- }
-
- ///
- /// Gets all contents of a folder (including (sub-)files and (sub-)folders)
- ///
- ///
- ///
- ///
- public static string[] GetDirContent(string dir, bool root)
- {
- string[] files = Directory.GetFiles(dir);
- string[] dirs = Directory.GetDirectories(dir);
- string all = "";
-
- if (root == false)
- all += dir + "\n";
-
- for (int i = 0; i < files.Length; i++)
- all += files[i] + "\n";
-
- foreach (string thisDir in dirs)
- {
- string[] temp = GetDirContent(thisDir, false);
-
- foreach (string thisTemp in temp)
- all += thisTemp + "\n";
- }
-
- return all.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
- }
-
- ///
- /// Detecs if the U8 file has an IMD5 or IMET Header.
- /// Return: 0 = No Header, 1 = IMD5, 2 = IMET
- ///
- ///
- public static int DetectHeader(string file)
- {
- byte[] temp = Tools.LoadFileToByteArray(file, 0, 400);
- return DetectHeader(temp);
- }
-
- ///
- /// Detecs if the U8 file has an IMD5 or IMET Header.
- /// Return: 0 = No Header, 1 = IMD5, 2 = IMET
- ///
- ///
- public static int DetectHeader(byte[] file)
- {
- for (int i = 0; i < 16; i++) //Just to be safe
- {
- if (Convert.ToChar(file[i]) == 'I')
- if (Convert.ToChar(file[i + 1]) == 'M')
- if (Convert.ToChar(file[i + 2]) == 'D')
- if (Convert.ToChar(file[i + 3]) == '5')
- return 1;
- }
-
- int length = 400;
- if (file.Length < 400) length = file.Length - 4;
-
- for (int z = 0; z < length; z++)
- {
- if (Convert.ToChar(file[z]) == 'I')
- if (Convert.ToChar(file[z + 1]) == 'M')
- if (Convert.ToChar(file[z + 2]) == 'E')
- if (Convert.ToChar(file[z + 3]) == 'T')
- return 2;
- }
-
- return 0;
- }
-
- ///
- /// Adds an IMD5 Header to the given U8 Archive
- ///
- ///
- ///
- public static byte[] AddHeaderIMD5(byte[] u8archive)
- {
- MemoryStream ms = new MemoryStream();
- MD5 md5 = MD5.Create();
-
- byte[] imd5 = new byte[4];
- imd5[0] = (byte)'I';
- imd5[1] = (byte)'M';
- imd5[2] = (byte)'D';
- imd5[3] = (byte)'5';
-
- byte[] size = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(u8archive.Length));
- byte[] hash = md5.ComputeHash(u8archive, 0, u8archive.Length);
-
- ms.Seek(0, SeekOrigin.Begin);
- ms.Write(imd5, 0, imd5.Length);
- ms.Write(size, 0, size.Length);
-
- ms.Seek(0x10, SeekOrigin.Begin);
- ms.Write(hash, 0, hash.Length);
-
- ms.Write(u8archive, 0, u8archive.Length);
-
- md5.Clear();
- return ms.ToArray();
- }
-
- ///
- /// Adds an IMET Header to the given 00.app
- ///
- ///
- /// Order: Jap, Eng, Ger, Fra, Spa, Ita, Dut
- /// Order: Banner.bin, Icon.bin, Sound.bin
- ///
- public static byte[] AddHeaderIMET(byte[] nullapp, string[] channeltitles, int[] sizes)
- {
- if (channeltitles.Length < 7) return nullapp;
- for (int i = 0; i < channeltitles.Length; i++)
- if (channeltitles[i].Length > 20) return nullapp;
-
- MemoryStream ms = new MemoryStream();
- MD5 md5 = MD5.Create();
-
- byte[] imet = new byte[4];
- imet[0] = (byte)'I';
- imet[1] = (byte)'M';
- imet[2] = (byte)'E';
- imet[3] = (byte)'T';
-
- byte[] unknown = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(0x0000060000000003));
-
- byte[] iconsize = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(sizes[1]));
- byte[] bannersize = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(sizes[0]));
- byte[] soundsize = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(sizes[2]));
-
- byte[] japtitle = new byte[84];
- byte[] engtitle = new byte[84];
- byte[] gertitle = new byte[84];
- byte[] fratitle = new byte[84];
- byte[] spatitle = new byte[84];
- byte[] itatitle = new byte[84];
- byte[] duttitle = new byte[84];
-
- for (int i = 0; i < 20; i++)
- {
- if (channeltitles[0].Length > i)
- {
- japtitle[i * 2 + 1] = (byte)channeltitles[0][i];
- }
- if (channeltitles[1].Length > i)
- {
- engtitle[i * 2 + 1] = (byte)channeltitles[1][i];
- }
- if (channeltitles[2].Length > i)
- {
- gertitle[i * 2 + 1] = (byte)channeltitles[2][i];
- }
- if (channeltitles[3].Length > i)
- {
- fratitle[i * 2 + 1] = (byte)channeltitles[3][i];
- }
- if (channeltitles[4].Length > i)
- {
- spatitle[i * 2 + 1] = (byte)channeltitles[4][i];
- }
- if (channeltitles[5].Length > i)
- {
- itatitle[i * 2 + 1] = (byte)channeltitles[5][i];
- }
- if (channeltitles[6].Length > i)
- {
- duttitle[i * 2 + 1] = (byte)channeltitles[6][i];
- }
- }
-
- byte[] crypto = new byte[16];
-
- ms.Seek(128, SeekOrigin.Begin);
- ms.Write(imet, 0, imet.Length);
- ms.Write(unknown, 0, unknown.Length);
- ms.Write(iconsize, 0, iconsize.Length);
- ms.Write(bannersize, 0, bannersize.Length);
- ms.Write(soundsize, 0, soundsize.Length);
-
- ms.Seek(4, SeekOrigin.Current);
- ms.Write(japtitle, 0, japtitle.Length);
- ms.Write(engtitle, 0, engtitle.Length);
- ms.Write(gertitle, 0, gertitle.Length);
- ms.Write(fratitle, 0, fratitle.Length);
- ms.Write(spatitle, 0, spatitle.Length);
- ms.Write(itatitle, 0, itatitle.Length);
- ms.Write(duttitle, 0, duttitle.Length);
-
- ms.Seek(0x348, SeekOrigin.Current);
- ms.Write(crypto, 0, crypto.Length);
-
- byte[] tohash = ms.ToArray();
- crypto = md5.ComputeHash(tohash, 0x40, 0x600);
-
- ms.Seek(-16, SeekOrigin.Current);
- ms.Write(crypto, 0, crypto.Length);
- ms.Write(nullapp, 0, nullapp.Length);
-
- md5.Clear();
- return ms.ToArray();
- }
-
- ///
- /// Packs a U8 Archive
- ///
- ///
- ///
- public static void PackU8(string folder, string outfile)
- {
- byte[] u8 = PackU8(folder);
-
- using (FileStream fs = new FileStream(outfile, FileMode.Create))
- fs.Write(u8, 0, u8.Length);
- }
-
- ///
- /// Packs a U8 Archive
- ///
- ///
- ///
- public static void PackU8(string folder, string outfile, bool addimd5header)
- {
- byte[] u8 = PackU8(folder);
-
- if (addimd5header == true)
- u8 = AddHeaderIMD5(u8);
-
- using (FileStream fs = new FileStream(outfile, FileMode.Create))
- fs.Write(u8, 0, u8.Length);
- }
-
- ///
- /// Packs a U8 Archive
- ///
- ///
- ///
- public static byte[] PackU8(string folder)
- {
- int a = 0, b = 0, c = 0;
- return PackU8(folder, out a, out b, out c);
- }
-
- ///
- /// Packs a U8 Archive
- ///
- ///
- ///
- public static byte[] PackU8(string folder, bool addimd5header)
- {
- byte[] u8 = PackU8(folder);
-
- if (addimd5header == true)
- u8 = AddHeaderIMD5(u8);
-
- return u8;
- }
-
- ///
- /// Packs a U8 Archive
- ///
- ///
- ///
- public static byte[] PackU8(string folder, out int bannersize, out int iconsize, out int soundsize)
- {
- int datapad = 32, stringtablepad = 32; //Biggie seems to use these paddings, so let's do it, too ;)
- string rootpath = folder;
- if (rootpath[rootpath.Length - 1] != '\\') rootpath = rootpath + "\\";
-
- bannersize = 0; iconsize = 0; soundsize = 0;
-
- string[] files = GetDirContent(folder, true);
- int nodecount = files.Length + 1; //All files and dirs + rootnode
- int recursion = 0;
- int currentnodes = 0;
- string name = string.Empty;
- string stringtable = "\0";
- byte[] tempnode = new byte[12];
-
- MemoryStream nodes = new MemoryStream();
- MemoryStream data = new MemoryStream();
- BinaryWriter writedata = new BinaryWriter(data);
-
- tempnode[0] = 0x01;
- tempnode[1] = 0x00;
- tempnode[2] = 0x00;
- tempnode[3] = 0x00;
- tempnode[4] = 0x00;
- tempnode[5] = 0x00;
- tempnode[6] = 0x00;
- tempnode[7] = 0x00;
-
- byte[] temp = BitConverter.GetBytes((UInt32)files.Length + 1); Array.Reverse(temp);
- tempnode[8] = temp[0];
- tempnode[9] = temp[1];
- tempnode[10] = temp[2];
- tempnode[11] = temp[3];
-
- nodes.Write(tempnode, 0, tempnode.Length);
-
- for (int i = 0; i < files.Length; i++)
- {
- files[i] = files[i].Remove(0, rootpath.Length - 1);
-
- recursion = Tools.CountCharsInString(files[i], '\\') - 1;
- name = files[i].Remove(0, files[i].LastIndexOf('\\') + 1);
-
- byte[] temp1 = BitConverter.GetBytes((UInt16)stringtable.Length); Array.Reverse(temp1);
- tempnode[2] = temp1[0];
- tempnode[3] = temp1[1];
-
- stringtable += name + "\0";
-
- if (Directory.Exists(rootpath + files[i])) //It's a dir
- {
- tempnode[0] = 0x01;
- tempnode[1] = 0x00;
-
- byte[] temp2 = BitConverter.GetBytes((UInt32)recursion); Array.Reverse(temp2);
- tempnode[4] = temp2[0];
- tempnode[5] = temp2[1];
- tempnode[6] = temp2[2];
- tempnode[7] = temp2[3];
-
- int size = currentnodes + 1;
-
- for (int j = i; j < files.Length; j++)
- if (files[j].Contains(files[i])) size++;
-
- byte[] temp3 = BitConverter.GetBytes((UInt32)size); Array.Reverse(temp3);
- tempnode[8] = temp3[0];
- tempnode[9] = temp3[1];
- tempnode[10] = temp3[2];
- tempnode[11] = temp3[3];
- }
- else //It's a file
- {
- byte[] tempfile = new byte[0x40];
- int lzoffset = -1;
-
- if (files[i].EndsWith("banner.bin"))
- {
- tempfile = Wii.Tools.LoadFileToByteArray(rootpath + files[i], 0, tempfile.Length);
-
- for (int x = 0; x < tempfile.Length; x++)
- {
- if (tempfile[x] == 'L')
- if (tempfile[x + 1] == 'Z')
- if (tempfile[x + 2] == '7')
- if (tempfile[x + 3] == '7')
- {
- lzoffset = x;
- break;
- }
- }
-
- if (lzoffset != -1)
- {
- bannersize = BitConverter.ToInt32(new byte[] { tempfile[lzoffset + 5], tempfile[lzoffset + 6], tempfile[lzoffset + 7], tempfile[lzoffset + 8] }, 0);
- }
- else
- {
- FileInfo fibanner = new FileInfo(rootpath + files[i]);
- bannersize = (int)fibanner.Length - 32;
- }
- }
- else if (files[i].EndsWith("icon.bin"))
- {tempfile = Wii.Tools.LoadFileToByteArray(rootpath + files[i], 0, tempfile.Length);
-
- for (int x = 0; x < tempfile.Length; x++)
- {
- if (tempfile[x] == 'L')
- if (tempfile[x + 1] == 'Z')
- if (tempfile[x + 2] == '7')
- if (tempfile[x + 3] == '7')
- {
- lzoffset = x;
- }
- }
-
- if (lzoffset != -1)
- {
- iconsize = BitConverter.ToInt32(new byte[] { tempfile[lzoffset + 5], tempfile[lzoffset + 6], tempfile[lzoffset + 7], tempfile[lzoffset + 8] }, 0);
- }
- else
- {
- FileInfo fiicon = new FileInfo(rootpath + files[i]);
- iconsize = (int)fiicon.Length - 32;
- }
- }
- else if (files[i].EndsWith("sound.bin"))
- {tempfile = Wii.Tools.LoadFileToByteArray(rootpath + files[i], 0, tempfile.Length);
-
- for (int x = 0; x < tempfile.Length; x++)
- {
- if (tempfile[x] == 'L')
- if (tempfile[x + 1] == 'Z')
- if (tempfile[x + 2] == '7')
- if (tempfile[x + 3] == '7')
- {
- lzoffset = x;
- break;
- }
- }
-
- if (lzoffset != -1)
- {
- soundsize = BitConverter.ToInt32(new byte[] { tempfile[lzoffset + 5], tempfile[lzoffset + 6], tempfile[lzoffset + 7], tempfile[lzoffset + 8] }, 0);
- }
- else
- {
- FileInfo fisound = new FileInfo(rootpath + files[i]);
- soundsize = (int)fisound.Length - 32;
- }
- }
-
- tempnode[0] = 0x00;
- tempnode[1] = 0x00;
-
- byte[] temp2 = BitConverter.GetBytes((UInt32)data.Position); Array.Reverse(temp2);
- tempnode[4] = temp2[0];
- tempnode[5] = temp2[1];
- tempnode[6] = temp2[2];
- tempnode[7] = temp2[3];
-
- FileInfo fi = new FileInfo(rootpath + files[i]);
- byte[] temp3 = BitConverter.GetBytes((UInt32)fi.Length); Array.Reverse(temp3);
- tempnode[8] = temp3[0];
- tempnode[9] = temp3[1];
- tempnode[10] = temp3[2];
- tempnode[11] = temp3[3];
-
- using (FileStream fs = new FileStream(rootpath + files[i], FileMode.Open))
- using (BinaryReader br = new BinaryReader(fs))
- writedata.Write(br.ReadBytes((int)br.BaseStream.Length));
-
- writedata.Seek(Tools.AddPadding((int)data.Position, datapad), SeekOrigin.Begin);
- }
-
- nodes.Write(tempnode, 0, tempnode.Length);
- currentnodes++;
- }
-
- byte[] type = new byte[2];
- byte[] curpos = new byte[4];
-
- for (int x = 0; x < nodecount * 12; x += 12)
- {
- nodes.Seek(x, SeekOrigin.Begin);
- nodes.Read(type, 0, 2);
-
- if (type[0] == 0x00 && type[1] == 0x00)
- {
- nodes.Seek(x + 4, SeekOrigin.Begin);
- nodes.Read(curpos, 0, 4);
- Array.Reverse(curpos);
-
- UInt32 newpos = BitConverter.ToUInt32(curpos, 0) + (UInt32)(Tools.AddPadding(0x20 + ((12 * nodecount) + stringtable.Length), stringtablepad));
-
- nodes.Seek(x + 4, SeekOrigin.Begin);
- byte[] temp2 = BitConverter.GetBytes(newpos); Array.Reverse(temp2);
- nodes.Write(temp2, 0, 4);
- }
- }
-
- writedata.Close();
- MemoryStream output = new MemoryStream();
- BinaryWriter writeout = new BinaryWriter(output);
-
- writeout.Write((UInt32)0x2d38aa55);
- writeout.Write(IPAddress.HostToNetworkOrder((ushort)0x20));
- writeout.Write(IPAddress.HostToNetworkOrder((ushort)((12 * nodecount) + stringtable.Length)));
- writeout.Write(IPAddress.HostToNetworkOrder((ushort)(Tools.AddPadding(0x20 + ((12 * nodecount) + stringtable.Length), stringtablepad))));
-
- writeout.Seek(0x10, SeekOrigin.Current);
-
- writeout.Write(nodes.ToArray());
- writeout.Write(ASCIIEncoding.ASCII.GetBytes(stringtable));
-
- writeout.Seek(Tools.AddPadding(0x20 + ((12 * nodecount) + stringtable.Length), stringtablepad), SeekOrigin.Begin);
-
- writeout.Write(data.ToArray());
-
- output.Seek(0, SeekOrigin.End);
- for (int i = (int)output.Position; i < Tools.AddPadding((int)output.Position, datapad); i++)
- output.WriteByte(0);
-
- writeout.Close();
- output.Close();
-
- return output.ToArray();
- }
-
- ///
- /// Unpacks the given U8 archive
- /// If the archive is Lz77 compressed, it will be decompressed first!
- ///
- ///
- ///
- public static void UnpackU8(string u8archive, string unpackpath)
- {
- byte[] u8 = Wii.Tools.LoadFileToByteArray(u8archive);
- UnpackU8(u8, unpackpath);
- }
-
- ///
- /// Unpacks the given U8 archive
- /// If the archive is Lz77 compressed, it will be decompressed first!
- ///
- ///
- ///
- public static void UnpackU8(byte[] u8archive, string unpackpath)
- {
- int lz77offset = Lz77.GetLz77Offset(u8archive);
- if (lz77offset != -1) { u8archive = Lz77.Decompress(u8archive, lz77offset); }
-
- if (unpackpath[unpackpath.Length - 1] != '\\') { unpackpath = unpackpath + "\\"; }
- if (!Directory.Exists(unpackpath)) Directory.CreateDirectory(unpackpath);
-
- int u8offset = -1;
- int length = 2500;
- if (u8archive.Length < length) length = u8archive.Length - 4;
-
- for (int i = 0; i < length; i++)
- {
- if (u8archive[i] == 0x55 && u8archive[i + 1] == 0xAA && u8archive[i + 2] == 0x38 && u8archive[i + 3] == 0x2D)
- {
- u8offset = i;
- break;
- }
- }
-
- if (u8offset == -1) throw new Exception("File is not a valid U8 Archive!");
-
- int nodecount = Tools.HexStringToInt(u8archive[u8offset + 0x28].ToString("x2") + u8archive[u8offset + 0x29].ToString("x2") + u8archive[u8offset + 0x2a].ToString("x2") + u8archive[u8offset + 0x2b].ToString("x2"));
- int nodeoffset = 0x20;
-
- string[,] nodes = new string[nodecount, 5];
-
- for (int j = 0; j < nodecount; j++)
- {
- nodes[j, 0] = u8archive[u8offset + nodeoffset].ToString("x2") + u8archive[u8offset + nodeoffset + 1].ToString("x2");
- nodes[j, 1] = u8archive[u8offset + nodeoffset + 2].ToString("x2") + u8archive[u8offset + nodeoffset + 3].ToString("x2");
- nodes[j, 2] = u8archive[u8offset + nodeoffset + 4].ToString("x2") + u8archive[u8offset + nodeoffset + 5].ToString("x2") + u8archive[u8offset + nodeoffset + 6].ToString("x2") + u8archive[u8offset + nodeoffset + 7].ToString("x2");
- nodes[j, 3] = u8archive[u8offset + nodeoffset + 8].ToString("x2") + u8archive[u8offset + nodeoffset + 9].ToString("x2") + u8archive[u8offset + nodeoffset + 10].ToString("x2") + u8archive[u8offset + nodeoffset + 11].ToString("x2");
-
- nodeoffset += 12;
- }
-
- int stringtablepos = u8offset + nodeoffset;
-
- for (int x = 0; x < nodecount; x++)
- {
- bool end = false;
- int nameoffset = Tools.HexStringToInt(nodes[x, 1]);
- string thisname = "";
-
- do
- {
- if (u8archive[stringtablepos + nameoffset] != 0x00)
- {
- char tempchar = Convert.ToChar(u8archive[stringtablepos + nameoffset]);
- thisname += tempchar.ToString();
- nameoffset++;
- }
- else end = true;
- } while (end == false);
-
- nodes[x, 4] = thisname;
- }
-
- string[] dirs = new string[nodecount];
- dirs[0] = unpackpath;
- int[] dircount = new int[nodecount];
- int dirindex = 0;
-
- try
- {
- for (int y = 1; y < nodecount; y++)
- {
- switch (nodes[y, 0])
- {
- case "0100":
- if (dirs[dirindex][dirs[dirindex].Length - 1] != '\\') { dirs[dirindex] = dirs[dirindex] + "\\"; }
- Directory.CreateDirectory(dirs[dirindex] + nodes[y, 4]);
- dirs[dirindex + 1] = dirs[dirindex] + nodes[y, 4];
- dirindex++;
- dircount[dirindex] = Tools.HexStringToInt(nodes[y, 3]);
- break;
- default:
- int filepos = u8offset + Tools.HexStringToInt(nodes[y, 2]);
- int filesize = Tools.HexStringToInt(nodes[y, 3]);
-
- using (FileStream fs = new FileStream(dirs[dirindex] + "\\" + nodes[y, 4], FileMode.Create))
- {
- fs.Write(u8archive, filepos, filesize);
- }
- break;
- }
-
- while (dirindex > 0 && dircount[dirindex] == (y + 1))
- {
- dirindex--;
- }
- }
- }
- catch { }
- }
-
- ///
- /// Gets the Banner.bin out of the 00000000.app
- ///
- ///
- ///
- public static byte[] GetBannerBin(byte[] nullapp)
- {
- int lz77offset = Lz77.GetLz77Offset(nullapp);
- if (lz77offset != -1) { nullapp = Lz77.Decompress(nullapp, lz77offset); }
-
- int u8offset = -1;
- for (int i = 0; i < 2500; i++)
- {
- if (nullapp[i] == 0x55 && nullapp[i + 1] == 0xAA && nullapp[i + 2] == 0x38 && nullapp[i + 3] == 0x2D)
- {
- u8offset = i;
- break;
- }
- }
-
- if (u8offset == -1) throw new Exception("File is not a valid U8 Archive!");
-
- int nodecount = Tools.HexStringToInt(nullapp[u8offset + 0x28].ToString("x2") + nullapp[u8offset + 0x29].ToString("x2") + nullapp[u8offset + 0x2a].ToString("x2") + nullapp[u8offset + 0x2b].ToString("x2"));
- int nodeoffset = 0x20;
-
- string[,] nodes = new string[nodecount, 5];
-
- for (int j = 0; j < nodecount; j++)
- {
- nodes[j, 0] = nullapp[u8offset + nodeoffset].ToString("x2") + nullapp[u8offset + nodeoffset + 1].ToString("x2");
- nodes[j, 1] = nullapp[u8offset + nodeoffset + 2].ToString("x2") + nullapp[u8offset + nodeoffset + 3].ToString("x2");
- nodes[j, 2] = nullapp[u8offset + nodeoffset + 4].ToString("x2") + nullapp[u8offset + nodeoffset + 5].ToString("x2") + nullapp[u8offset + nodeoffset + 6].ToString("x2") + nullapp[u8offset + nodeoffset + 7].ToString("x2");
- nodes[j, 3] = nullapp[u8offset + nodeoffset + 8].ToString("x2") + nullapp[u8offset + nodeoffset + 9].ToString("x2") + nullapp[u8offset + nodeoffset + 10].ToString("x2") + nullapp[u8offset + nodeoffset + 11].ToString("x2");
-
- nodeoffset += 12;
- }
-
- int stringtablepos = u8offset + nodeoffset;
-
- for (int x = 0; x < nodecount; x++)
- {
- bool end = false;
- int nameoffset = Tools.HexStringToInt(nodes[x, 1]);
- string thisname = "";
-
- while (end == false)
- {
- if (nullapp[stringtablepos + nameoffset] != 0x00)
- {
- char tempchar = Convert.ToChar(nullapp[stringtablepos + nameoffset]);
- thisname += tempchar.ToString();
- nameoffset++;
- }
- else end = true;
- }
-
- nodes[x, 4] = thisname;
- }
-
- for (int y = 1; y < nodecount; y++)
- {
- if (nodes[y, 4] == "banner.bin")
- {
- int filepos = u8offset + Tools.HexStringToInt(nodes[y, 2]);
- int filesize = Tools.HexStringToInt(nodes[y, 3]);
-
- MemoryStream ms = new MemoryStream(nullapp);
- byte[] banner = new byte[filesize];
- ms.Seek(filepos, SeekOrigin.Begin);
- ms.Read(banner, 0, filesize);
- ms.Close();
-
- return banner;
- }
- }
-
- throw new Exception("This file doesn't contain banner.bin!");
- }
-
- ///
- /// Gets the Icon.bin out of the 00000000.app
- ///
- ///
- ///
- public static byte[] GetIconBin(byte[] nullapp)
- {
- int lz77offset = Lz77.GetLz77Offset(nullapp);
- if (lz77offset != -1) { nullapp = Lz77.Decompress(nullapp, lz77offset); }
-
- int u8offset = -1;
- for (int i = 0; i < 2500; i++)
- {
- if (nullapp[i] == 0x55 && nullapp[i + 1] == 0xAA && nullapp[i + 2] == 0x38 && nullapp[i + 3] == 0x2D)
- {
- u8offset = i;
- break;
- }
- }
-
- if (u8offset == -1) throw new Exception("File is not a valid U8 Archive!");
-
- int nodecount = Tools.HexStringToInt(nullapp[u8offset + 0x28].ToString("x2") + nullapp[u8offset + 0x29].ToString("x2") + nullapp[u8offset + 0x2a].ToString("x2") + nullapp[u8offset + 0x2b].ToString("x2"));
- int nodeoffset = 0x20;
-
- string[,] nodes = new string[nodecount, 5];
-
- for (int j = 0; j < nodecount; j++)
- {
- nodes[j, 0] = nullapp[u8offset + nodeoffset].ToString("x2") + nullapp[u8offset + nodeoffset + 1].ToString("x2");
- nodes[j, 1] = nullapp[u8offset + nodeoffset + 2].ToString("x2") + nullapp[u8offset + nodeoffset + 3].ToString("x2");
- nodes[j, 2] = nullapp[u8offset + nodeoffset + 4].ToString("x2") + nullapp[u8offset + nodeoffset + 5].ToString("x2") + nullapp[u8offset + nodeoffset + 6].ToString("x2") + nullapp[u8offset + nodeoffset + 7].ToString("x2");
- nodes[j, 3] = nullapp[u8offset + nodeoffset + 8].ToString("x2") + nullapp[u8offset + nodeoffset + 9].ToString("x2") + nullapp[u8offset + nodeoffset + 10].ToString("x2") + nullapp[u8offset + nodeoffset + 11].ToString("x2");
-
- nodeoffset += 12;
- }
-
- int stringtablepos = u8offset + nodeoffset;
-
- for (int x = 0; x < nodecount; x++)
- {
- bool end = false;
- int nameoffset = Tools.HexStringToInt(nodes[x, 1]);
- string thisname = "";
-
- while (end == false)
- {
- if (nullapp[stringtablepos + nameoffset] != 0x00)
- {
- char tempchar = Convert.ToChar(nullapp[stringtablepos + nameoffset]);
- thisname += tempchar.ToString();
- nameoffset++;
- }
- else end = true;
- }
-
- nodes[x, 4] = thisname;
- }
-
- for (int y = 1; y < nodecount; y++)
- {
- if (nodes[y, 4] == "icon.bin")
- {
- int filepos = u8offset + Tools.HexStringToInt(nodes[y, 2]);
- int filesize = Tools.HexStringToInt(nodes[y, 3]);
-
- MemoryStream ms = new MemoryStream(nullapp);
- byte[] icon = new byte[filesize];
- ms.Seek(filepos, SeekOrigin.Begin);
- ms.Read(icon, 0, filesize);
- ms.Close();
-
- return icon;
- }
- }
-
- throw new Exception("This file doesn't contain icon.bin!");
- }
-
- ///
- /// Extracts all Tpl's to the given path
- ///
- ///
- ///
- public static void UnpackTpls(byte[] u8archive, string unpackpath)
- {
- int lz77offset = Lz77.GetLz77Offset(u8archive);
- if (lz77offset != -1) { u8archive = Lz77.Decompress(u8archive, lz77offset); }
-
- if (unpackpath[unpackpath.Length - 1] != '\\') { unpackpath = unpackpath + "\\"; }
- if (!Directory.Exists(unpackpath)) Directory.CreateDirectory(unpackpath);
-
- int u8offset = -1;
- int length = 2500;
- if (u8archive.Length < 2500) length = u8archive.Length - 4;
-
- for (int i = 0; i < 2500; i++)
- {
- if (u8archive[i] == 0x55 && u8archive[i + 1] == 0xAA && u8archive[i + 2] == 0x38 && u8archive[i + 3] == 0x2D)
- {
- u8offset = i;
- break;
- }
- }
-
- if (u8offset == -1) throw new Exception("File is not a valid U8 Archive!");
-
- int nodecount = Tools.HexStringToInt(u8archive[u8offset + 0x28].ToString("x2") + u8archive[u8offset + 0x29].ToString("x2") + u8archive[u8offset + 0x2a].ToString("x2") + u8archive[u8offset + 0x2b].ToString("x2"));
- int nodeoffset = 0x20;
-
- string[,] nodes = new string[nodecount, 5];
-
- for (int j = 0; j < nodecount; j++)
- {
- nodes[j, 0] = u8archive[u8offset + nodeoffset].ToString("x2") + u8archive[u8offset + nodeoffset + 1].ToString("x2");
- nodes[j, 1] = u8archive[u8offset + nodeoffset + 2].ToString("x2") + u8archive[u8offset + nodeoffset + 3].ToString("x2");
- nodes[j, 2] = u8archive[u8offset + nodeoffset + 4].ToString("x2") + u8archive[u8offset + nodeoffset + 5].ToString("x2") + u8archive[u8offset + nodeoffset + 6].ToString("x2") + u8archive[u8offset + nodeoffset + 7].ToString("x2");
- nodes[j, 3] = u8archive[u8offset + nodeoffset + 8].ToString("x2") + u8archive[u8offset + nodeoffset + 9].ToString("x2") + u8archive[u8offset + nodeoffset + 10].ToString("x2") + u8archive[u8offset + nodeoffset + 11].ToString("x2");
-
- nodeoffset += 12;
- }
-
- int stringtablepos = u8offset + nodeoffset;
-
- for (int x = 0; x < nodecount; x++)
- {
- bool end = false;
- int nameoffset = Tools.HexStringToInt(nodes[x, 1]);
- string thisname = "";
-
- while (end == false)
- {
- if (u8archive[stringtablepos + nameoffset] != 0x00)
- {
- char tempchar = Convert.ToChar(u8archive[stringtablepos + nameoffset]);
- thisname += tempchar.ToString();
- nameoffset++;
- }
- else end = true;
- }
-
- nodes[x, 4] = thisname;
- }
-
- for (int y = 1; y < nodecount; y++)
- {
- if (nodes[y, 4].Contains("."))
- {
- if (nodes[y, 4].Remove(0, nodes[y, 4].LastIndexOf('.')) == ".tpl")
- {
- int filepos = u8offset + Tools.HexStringToInt(nodes[y, 2]);
- int filesize = Tools.HexStringToInt(nodes[y, 3]);
-
- using (FileStream fs = new FileStream(unpackpath + nodes[y, 4], FileMode.Create))
- {
- fs.Write(u8archive, filepos, filesize);
- }
- }
- }
- }
- }
- }
-
- public class Lz77
- {
- private const int N = 4096;
- private const int F = 18;
- private const int threshold = 2;
- private static int[] lson = new int[N + 1];
- private static int[] rson = new int[N + 257];
- private static int[] dad = new int[N + 1];
- private static ushort[] text_buf = new ushort[N + 17];
- private static int match_position = 0, match_length = 0;
- private static int textsize = 0;
- private static int codesize = 0;
-
- ///
- /// Returns the Offset to the Lz77 Header
- /// -1 will be returned, if the file is not Lz77 compressed
- ///
- ///
- ///
- public static int GetLz77Offset(byte[] data)
- {
- int length = 5000;
- if (data.Length < 5000) length = data.Length - 4;
-
- for (int i = 0; i < length; i++)
- {
- if (data[i] == 0x55 && data[i + 1] == 0xAA && data[i + 2] == 0x38 && data[i + 3] == 0x2D)
- {
- break;
- }
-
- UInt32 tmp = BitConverter.ToUInt32(data, i);
- if (tmp == 0x37375a4c) return i;
- }
-
- return -1;
- }
-
- ///
- /// Decompresses the given file
- ///
- ///
- ///
- public static void Decompress(string infile, string outfile)
- {
- byte[] input = Tools.LoadFileToByteArray(infile);
- int offset = GetLz77Offset(input);
- if (offset == -1) throw new Exception("File is not Lz77 compressed!");
- Tools.SaveFileFromByteArray(Decompress(input, offset), outfile);
- }
-
- ///
- /// Decompresses the given data
- ///
- ///
- ///
- ///
- public static byte[] Decompress(byte[] compressed, int offset)
- {
- int i, j, k, r, c, z;
- uint flags;
- UInt32 decomp_size;
- UInt32 cur_size = 0;
-
- MemoryStream infile = new MemoryStream(compressed);
- MemoryStream outfile = new MemoryStream();
-
- UInt32 gbaheader = new UInt32();
- byte[] temp = new byte[4];
- infile.Seek(offset + 4, SeekOrigin.Begin);
- infile.Read(temp, 0, 4);
- gbaheader = BitConverter.ToUInt32(temp, 0);
-
- decomp_size = gbaheader >> 8;
- byte[] text_buf = new byte[N + 17];
-
- for (i = 0; i < N - F; i++) text_buf[i] = 0xdf;
- r = N - F; flags = 7; z = 7;
-
- while (true)
- {
- flags <<= 1;
- z++;
- if (z == 8)
- {
- if ((c = (char)infile.ReadByte()) == -1) break;
- flags = (uint)c;
- z = 0;
- }
- if ((flags & 0x80) == 0)
- {
- if ((c = infile.ReadByte()) == infile.Length - 1) break;
- if (cur_size < decomp_size) outfile.WriteByte((byte)c);
- text_buf[r++] = (byte)c;
- r &= (N - 1);
- cur_size++;
- }
- else
- {
- if ((i = infile.ReadByte()) == -1) break;
- if ((j = infile.ReadByte()) == -1) break;
- j = j | ((i << 8) & 0xf00);
- i = ((i >> 4) & 0x0f) + threshold;
- for (k = 0; k <= i; k++)
- {
- c = text_buf[(r - j - 1) & (N - 1)];
- if (cur_size < decomp_size) outfile.WriteByte((byte)c); text_buf[r++] = (byte)c; r &= (N - 1); cur_size++;
- }
- }
- }
-
- return outfile.ToArray();
- }
-
- public static void InitTree()
- {
- int i;
- for (i = N + 1; i <= N + 256; i++) rson[i] = N;
- for (i = 0; i < N; i++) dad[i] = N;
- }
-
- public static void InsertNode(int r)
- {
- int i, p, cmp;
- cmp = 1;
- p = N + 1 + (text_buf[r] == 0xffff ? 0 : text_buf[r]); //text_buf[r];
- rson[r] = lson[r] = N; match_length = 0;
- for (; ; )
- {
- if (cmp >= 0)
- {
- if (rson[p] != N) p = rson[p];
- else { rson[p] = r; dad[r] = p; return; }
- }
- else
- {
- if (lson[p] != N) p = lson[p];
- else { lson[p] = r; dad[r] = p; return; }
- }
- for (i = 1; i < F; i++)
- if ((cmp = text_buf[r + i] - text_buf[p + i]) != 0) break;
- if (i > match_length)
- {
- match_position = p;
- if ((match_length = i) >= F) break;
- }
- }
- dad[r] = dad[p]; lson[r] = lson[p]; rson[r] = rson[p];
- dad[lson[p]] = r; dad[rson[p]] = r;
- if (rson[dad[p]] == p) rson[dad[p]] = r;
- else lson[dad[p]] = r;
- dad[p] = N;
- }
-
- public static void DeleteNode(int p)
- {
- int q;
-
- if (dad[p] == N) return; /* not in tree */
- if (rson[p] == N) q = lson[p];
- else if (lson[p] == N) q = rson[p];
- else
- {
- q = lson[p];
- if (rson[q] != N)
- {
- do { q = rson[q]; } while (rson[q] != N);
- rson[dad[q]] = lson[q]; dad[lson[q]] = dad[q];
- lson[q] = lson[p]; dad[lson[p]] = q;
- }
- rson[q] = rson[p]; dad[rson[p]] = q;
- }
- dad[q] = dad[p];
- if (rson[dad[p]] == p) rson[dad[p]] = q; else lson[dad[p]] = q;
- dad[p] = N;
- }
-
- ///
- /// Lz77 compresses the given File
- ///
- ///
- ///
- public static void Compress(string infile, string outfile)
- {
- byte[] thisfile = Tools.LoadFileToByteArray(infile);
- thisfile = Compress(thisfile);
- Tools.SaveFileFromByteArray(thisfile, outfile);
- }
-
- ///
- /// Lz77 compresses the given and saves it to the given Path
- ///
- ///
- ///
- public static void Compress(byte[] file, string outfile)
- {
- byte[] temp = Compress(file);
- Tools.SaveFileFromByteArray(temp, outfile);
- }
-
- ///
- /// Lz77 compresses the given Byte Array
- ///
- ///
- ///
- public static byte[] Compress(byte[] file)
- {
- int i, c, len, r, s, last_match_length, code_buf_ptr;
- int[] code_buf = new int[17];
- int mask;
- UInt32 filesize = ((Convert.ToUInt32(file.Length)) << 8) + 0x10;
- byte[] filesizebytes = BitConverter.GetBytes(filesize);
-
- MemoryStream output = new MemoryStream();
- output.WriteByte((byte)'L'); output.WriteByte((byte)'Z'); output.WriteByte((byte)'7'); output.WriteByte((byte)'7');
- MemoryStream infile = new MemoryStream(file);
-
- output.Write(filesizebytes, 0, filesizebytes.Length);
-
- InitTree();
- code_buf[0] = 0;
- code_buf_ptr = 1;
- mask = 0x80;
- s = 0;
- r = N - F;
-
- for (i = s; i < r; i++) text_buf[i] = 0xffff;
- for (len = 0; len < F && (c = (int)infile.ReadByte()) != -1; len++)
- text_buf[r + len] = (ushort)c;
-
- if ((textsize = len) == 0) return file;
-
- for (i = 1; i <= F; i++) InsertNode(r - i);
-
- InsertNode(r);
-
- do
- {
- if (match_length > len) match_length = len;
-
- if (match_length <= threshold)
- {
- match_length = 1;
- code_buf[code_buf_ptr++] = text_buf[r];
- }
- else
- {
- code_buf[0] |= mask;
-
- code_buf[code_buf_ptr++] = (char)
- (((r - match_position - 1) >> 8) & 0x0f) |
- ((match_length - (threshold + 1)) << 4);
-
- code_buf[code_buf_ptr++] = (char)((r - match_position - 1) & 0xff);
- }
- if ((mask >>= 1) == 0)
- {
- for (i = 0; i < code_buf_ptr; i++)
- output.WriteByte((byte)code_buf[i]);
- codesize += code_buf_ptr;
- code_buf[0] = 0; code_buf_ptr = 1;
- mask = 0x80;
- }
-
- last_match_length = match_length;
- for (i = 0; i < last_match_length &&
- (c = (int)infile.ReadByte()) != -1; i++)
- {
- DeleteNode(s);
- text_buf[s] = (ushort)c;
- if (s < F - 1) text_buf[s + N] = (ushort)c;
- s = (s + 1) & (N - 1); r = (r + 1) & (N - 1);
- InsertNode(r);
- }
-
- while (i++ < last_match_length)
- {
- DeleteNode(s);
- s = (s + 1) & (N - 1); r = (r + 1) & (N - 1);
- if (--len != 0) InsertNode(r);
- }
- } while (len > 0);
-
-
- if (code_buf_ptr > 1)
- {
- for (i = 0; i < code_buf_ptr; i++) output.WriteByte((byte)code_buf[i]);
- codesize += code_buf_ptr;
- }
-
- if (codesize % 4 != 0)
- for (i = 0; i < 4 - (codesize % 4); i++)
- output.WriteByte(0x00);
-
- infile.Close();
- return output.ToArray();
- }
- }
-
- public class TPL
- {
- ///
- /// Converts a Tpl to a Bitmap
- ///
- ///
- ///
- public static Bitmap ConvertFromTPL(string tpl)
- {
- byte[] tplarray = Wii.Tools.LoadFileToByteArray(tpl);
- return ConvertFromTPL(tplarray);
- }
-
- ///
- /// Converts a Tpl to a Bitmap
- ///
- ///
- ///
- public static Bitmap ConvertFromTPL(byte[] tpl)
- {
- if (GetTextureCount(tpl) > 1) throw new Exception("Tpl's containing more than one Texture are not supported!");
-
- int width = GetTextureWidth(tpl);
- int height = GetTextureHeight(tpl);
- int format = GetTextureFormat(tpl);
- if (format == -1) throw new Exception("The Texture has an unsupported format!");
-
- switch (format)
- {
- case 0:
- byte[] temp0 = FromI4(tpl);
- return ConvertPixelToBitmap(temp0, width, height);
- case 1:
- byte[] temp1 = FromI8(tpl);
- return ConvertPixelToBitmap(temp1, width, height);
- case 2:
- byte[] temp2 = FromIA4(tpl);
- return ConvertPixelToBitmap(temp2, width, height);
- case 3:
- byte[] temp3 = FromIA8(tpl);
- return ConvertPixelToBitmap(temp3, width, height);
- case 4:
- byte[] temp4 = FromRGB565(tpl);
- return ConvertPixelToBitmap(temp4, width, height);
- case 5:
- byte[] temp5 = FromRGB5A3(tpl);
- return ConvertPixelToBitmap(temp5, width, height);
- case 6:
- byte[] temp6 = FromRGBA8(tpl);
- return ConvertPixelToBitmap(temp6, width, height);
- case 14:
- byte[] temp14 = FromCMP(tpl);
- return ConvertPixelToBitmap(temp14, width, height);
- default:
- throw new Exception("The Texture has an unsupported format!");
- }
- }
-
- ///
- /// Converts the Pixel Data into a Png Image
- ///
- /// Byte array with pixel data
- public static System.Drawing.Bitmap ConvertPixelToBitmap(byte[] data, int width, int height)
- {
- if (width == 0) width = 1;
- if (height == 0) height = 1;
-
- System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
- System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(
- new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
- System.Drawing.Imaging.ImageLockMode.WriteOnly, bmp.PixelFormat);
-
- System.Runtime.InteropServices.Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
- bmp.UnlockBits(bmpData);
- return bmp;
- }
-
- ///
- /// Gets the Number of Textures in a Tpl
- ///
- ///
- ///
- public static int GetTextureCount(byte[] tpl)
- {
- byte[] tmp = new byte[4];
- tmp[3] = tpl[4];
- tmp[2] = tpl[5];
- tmp[1] = tpl[6];
- tmp[0] = tpl[7];
- UInt32 count = BitConverter.ToUInt32(tmp, 0);
- return (int)count;
- }
-
- ///
- /// Gets the Format of the Texture in the Tpl
- ///
- ///
- ///
- public static int GetTextureFormat(string tpl)
- {
- byte[] temp = Tools.LoadFileToByteArray(tpl, 0, 50);
- return GetTextureFormat(temp);
- }
-
- ///
- /// Gets the Format of the Texture in the Tpl
- ///
- ///
- ///
- public static int GetTextureFormat(byte[] tpl)
- {
- byte[] tmp = new byte[4];
- tmp[3] = tpl[24];
- tmp[2] = tpl[25];
- tmp[1] = tpl[26];
- tmp[0] = tpl[27];
- UInt32 format = BitConverter.ToUInt32(tmp, 0);
-
- if (format == 0 ||
- format == 1 ||
- format == 2 ||
- format == 3 ||
- format == 4 ||
- format == 5 ||
- format == 6 ||
- format == 14) return (int)format;
-
- else return -1; //Unsupported Format
- }
-
- ///
- /// Gets the Format Name of the Texture in the Tpl
- ///
- ///
- ///
- public static string GetTextureFormatName(byte[] tpl)
- {
- switch (GetTextureFormat(tpl))
- {
- case 0:
- return "I4";
- case 1:
- return "I8";
- case 2:
- return "IA4";
- case 3:
- return "IA8";
- case 4:
- return "RGB565";
- case 5:
- return "RGB5A3";
- case 6:
- return "RGBA8";
- case 14:
- return "CMP";
- default:
- return "Unknown";
- }
- }
-
- public static int avg(int w0, int w1, int c0, int c1)
- {
- int a0 = c0 >> 11;
- int a1 = c1 >> 11;
- int a = (w0 * a0 + w1 * a1) / (w0 + w1);
- int c = (a << 11) & 0xffff;
-
- a0 = (c0 >> 5) & 63;
- a1 = (c1 >> 5) & 63;
- a = (w0 * a0 + w1 * a1) / (w0 + w1);
- c = c | ((a << 5) & 0xffff);
-
- a0 = c0 & 31;
- a1 = c1 & 31;
- a = (w0 * a0 + w1 * a1) / (w0 + w1);
- c = c | a;
-
- return c;
- }
-
- ///
- /// Gets the Width of the Texture in the Tpl
- ///
- ///
- ///
- public static int GetTextureWidth(byte[] tpl)
- {
- byte[] tmp = new byte[2];
- tmp[1] = tpl[22];
- tmp[0] = tpl[23];
- UInt16 width = BitConverter.ToUInt16(tmp, 0);
- return (int)width;
- }
-
- ///
- /// Gets the Height of the Texture in the Tpl
- ///
- ///
- ///
- public static int GetTextureHeight(byte[] tpl)
- {
- byte[] tmp = new byte[2];
- tmp[1] = tpl[20];
- tmp[0] = tpl[21];
- UInt16 height = BitConverter.ToUInt16(tmp, 0);
- return (int)height;
- }
-
- ///
- /// Gets the offset to the Texturedata in the Tpl
- ///
- ///
- ///
- public static int GetTextureOffset(byte[] tpl)
- {
- byte[] tmp = new byte[4];
- tmp[3] = tpl[28];
- tmp[2] = tpl[29];
- tmp[1] = tpl[30];
- tmp[0] = tpl[31];
- UInt32 offset = BitConverter.ToUInt32(tmp, 0);
- return (int)offset;
- }
-
- ///
- /// Converts RGBA8 Tpl Array to RGBA Byte Array
- ///
- ///
- ///
- public static byte[] FromRGBA8(byte[] tpl)
- {
- int width = GetTextureWidth(tpl);
- int height = GetTextureHeight(tpl);
- int offset = GetTextureOffset(tpl);
- UInt32[] output = new UInt32[width * height];
- int inp = 0;
- for (int y = 0; y < height; y += 4)
- {
- for (int x = 0; x < width; x += 4)
- {
- for (int k = 0; k < 2; k++)
- {
- for (int y1 = y; y1 < y + 4; y1++)
- {
- for (int x1 = x; x1 < x + 4; x1++)
- {
- byte[] pixelbytes = new byte[2];
- pixelbytes[1] = tpl[offset + inp * 2];
- pixelbytes[0] = tpl[offset + inp * 2 + 1];
- UInt16 pixel = BitConverter.ToUInt16(pixelbytes, 0);
- inp++;
-
- if ((x1 >= width) || (y1 >= height))
- continue;
-
- if (k == 0)
- {
- int a = (pixel >> 8) & 0xff;
- int r = (pixel >> 0) & 0xff;
- output[x1 + (y1 * width)] |= (UInt32)((r << 16) | (a << 24));
- }
- else
- {
- int g = (pixel >> 8) & 0xff;
- int b = (pixel >> 0) & 0xff;
- output[x1 + (y1 * width)] |= (UInt32)((g << 8) | (b << 0));
- }
- }
- }
- }
- }
- }
-
- return Tools.UInt32ArrayToByteArray(output);
- }
-
- ///
- /// Converts RGB5A3 Tpl Array to RGBA Byte Array
- ///
- ///
- ///
- public static byte[] FromRGB5A3(byte[] tpl)
- {
- int width = GetTextureWidth(tpl);
- int height = GetTextureHeight(tpl);
- int offset = GetTextureOffset(tpl);
- UInt32[] output = new UInt32[width * height];
- int inp = 0;
- int r, g, b;
- int a = 0;
- for (int y = 0; y < height; y += 4)
- {
- for (int x = 0; x < width; x += 4)
- {
- for (int y1 = y; y1 < y + 4; y1++)
- {
- for (int x1 = x; x1 < x + 4; x1++)
- {
- byte[] pixelbytes = new byte[2];
- pixelbytes[1] = tpl[offset + inp * 2];
- pixelbytes[0] = tpl[offset + inp * 2 + 1];
- UInt16 pixel = BitConverter.ToUInt16(pixelbytes, 0);
- inp++;
-
- if (y1 >= height || x1 >= width)
- continue;
-
- if ((pixel & (1 << 15)) != 0)
- {
- b = (((pixel >> 10) & 0x1F) * 255) / 31;
- g = (((pixel >> 5) & 0x1F) * 255) / 31;
- r = (((pixel >> 0) & 0x1F) * 255) / 31;
- a = 255;
- }
- else
- {
- a = (((pixel >> 12) & 0x07) * 255) / 7;
- b = (((pixel >> 8) & 0x0F) * 255) / 15;
- g = (((pixel >> 4) & 0x0F) * 255) / 15;
- r = (((pixel >> 0) & 0x0F) * 255) / 15;
- }
-
- int rgba = (r << 0) | (g << 8) | (b << 16) | (a << 24);
- output[(y1 * width) + x1] = (UInt32)rgba;
- }
- }
- }
- }
-
- return Tools.UInt32ArrayToByteArray(output);
- }
-
- ///
- /// Converts RGB565 Tpl Array to RGBA Byte Array
- ///
- ///
- ///
- public static byte[] FromRGB565(byte[] tpl)
- {
- int width = GetTextureWidth(tpl);
- int height = GetTextureHeight(tpl);
- int offset = GetTextureOffset(tpl);
- UInt32[] output = new UInt32[width * height];
- int inp = 0;
- for (int y = 0; y < height; y += 4)
- {
- for (int x = 0; x < width; x += 4)
- {
- for (int y1 = y; y1 < y + 4; y1++)
- {
- for (int x1 = x; x1 < x + 4; x1++)
- {
- byte[] pixelbytes = new byte[2];
- pixelbytes[1] = tpl[offset + inp * 2];
- pixelbytes[0] = tpl[offset + inp * 2 + 1];
- UInt16 pixel = BitConverter.ToUInt16(pixelbytes, 0);
- inp++;
-
- if (y1 >= height || x1 >= width)
- continue;
-
- int b = (((pixel >> 11) & 0x1F) << 3) & 0xff;
- int g = (((pixel >> 5) & 0x3F) << 2) & 0xff;
- int r = (((pixel >> 0) & 0x1F) << 3) & 0xff;
- int a = 255;
-
- int rgba = (r << 0) | (g << 8) | (b << 16) | (a << 24);
- output[y1 * width + x1] = (UInt32)rgba;
- }
- }
- }
- }
-
- return Tools.UInt32ArrayToByteArray(output);
- }
-
- ///
- /// Converts I4 Tpl Array to RGBA Byte Array
- ///
- ///
- ///
- public static byte[] FromI4(byte[] tpl)
- {
- int width = GetTextureWidth(tpl);
- int height = GetTextureHeight(tpl);
- int offset = GetTextureOffset(tpl);
- UInt32[] output = new UInt32[width * height];
- int inp = 0;
- for (int y = 0; y < height; y += 8)
- {
- for (int x = 0; x < width; x += 8)
- {
- for (int y1 = y; y1 < y + 8; y1++)
- {
- for (int x1 = x; x1 < x + 8; x1 += 2)
- {
- int pixel = tpl[offset + inp];
-
- if (y1 >= height || x1 >= width)
- continue;
-
- int r = (pixel >> 4) * 255 / 15;
- int g = (pixel >> 4) * 255 / 15;
- int b = (pixel >> 4) * 255 / 15;
- int a = (pixel >> 4) * 255 / 15;
-
- int rgba = (r << 0) | (g << 8) | (b << 16) | (a << 24);
- output[y1 * width + x1] = (UInt32)rgba;
-
- pixel = tpl[offset + inp];
- inp++;
-
- if (y1 >= height || x1 >= width)
- continue;
-
- r = (pixel & 0x0F) * 255 / 15;
- g = (pixel & 0x0F) * 255 / 15;
- b = (pixel & 0x0F) * 255 / 15;
- a = (pixel & 0x0F) * 255 / 15;
-
- rgba = (r << 0) | (g << 8) | (b << 16) | (a << 24);
- output[y1 * width + x1 + 1] = (UInt32)rgba;
- }
- }
- }
- }
-
- return Tools.UInt32ArrayToByteArray(output);
- }
-
- ///
- /// Converts IA4 Tpl Array to RGBA Byte Array
- ///
- ///
- ///
- public static byte[] FromIA4(byte[] tpl)
- {
- int width = GetTextureWidth(tpl);
- int height = GetTextureHeight(tpl);
- int offset = GetTextureOffset(tpl);
- UInt32[] output = new UInt32[width * height];
- int inp = 0;
- for (int y = 0; y < height; y += 4)
- {
- for (int x = 0; x < width; x += 8)
- {
- for (int y1 = y; y1 < y + 4; y1++)
- {
- for (int x1 = x; x1 < x + 8; x1++)
- {
- int pixel = tpl[offset + inp];
- inp++;
-
- if (y1 >= height || x1 >= width)
- continue;
-
- int r = ((pixel & 0x0F) * 255 / 15) & 0xff;
- int g = ((pixel & 0x0F) * 255 / 15) & 0xff;
- int b = ((pixel & 0x0F) * 255 / 15) & 0xff;
- int a = (((pixel >> 4) * 255) / 15) & 0xff;
-
- int rgba = (r << 0) | (g << 8) | (b << 16) | (a << 24);
- output[y1 * width + x1] = (UInt32)rgba;
- }
- }
- }
- }
-
- return Tools.UInt32ArrayToByteArray(output);
- }
-
- ///
- /// Converts I8 Tpl Array to RGBA Byte Array
- ///
- ///
- ///
- public static byte[] FromI8(byte[] tpl)
- {
- int width = GetTextureWidth(tpl);
- int height = GetTextureHeight(tpl);
- int offset = GetTextureOffset(tpl);
- UInt32[] output = new UInt32[width * height];
- int inp = 0;
- for (int y = 0; y < height; y += 4)
- {
- for (int x = 0; x < width; x += 8)
- {
- for (int y1 = y; y1 < y + 4; y1++)
- {
- for (int x1 = x; x1 < x + 8; x1++)
- {
- int pixel = tpl[offset + inp];
- inp++;
-
- if (y1 >= height || x1 >= width)
- continue;
-
- int r = pixel;
- int g = pixel;
- int b = pixel;
- int a = 255;
-
- int rgba = (r << 0) | (g << 8) | (b << 16) | (a << 24);
- output[y1 * width + x1] = (UInt32)rgba;
- }
- }
- }
- }
-
- return Tools.UInt32ArrayToByteArray(output);
- }
-
- ///
- /// Converts IA8 Tpl Array to RGBA Byte Array
- ///
- ///
- ///
- public static byte[] FromIA8(byte[] tpl)
- {
- int width = GetTextureWidth(tpl);
- int height = GetTextureHeight(tpl);
- int offset = GetTextureOffset(tpl);
- UInt32[] output = new UInt32[width * height];
- int inp = 0;
- for (int y = 0; y < height; y += 4)
- {
- for (int x = 0; x < width; x += 4)
- {
- for (int y1 = y; y1 < y + 4; y1++)
- {
- for (int x1 = x; x1 < x + 4; x1++)
- {
- byte[] pixelbytes = new byte[2];
- pixelbytes[1] = tpl[offset + inp * 2];
- pixelbytes[0] = tpl[offset + inp * 2 + 1];
- UInt16 pixel = BitConverter.ToUInt16(pixelbytes, 0);
- inp++;
-
- if (y1 >= height || x1 >= width)
- continue;
-
- int r = (pixel >> 8);// &0xff;
- int g = (pixel >> 8);// &0xff;
- int b = (pixel >> 8);// &0xff;
- int a = (pixel >> 8) & 0xff;
-
- int rgba = (r << 0) | (g << 8) | (b << 16) | (a << 24);
- output[y1 * width + x1] = (UInt32)rgba;
- }
- }
- }
- }
-
- return Tools.UInt32ArrayToByteArray(output);
- }
-
- ///
- /// Converts CMP Tpl Array to RGBA Byte Array
- ///
- ///
- ///
- public static byte[] FromCMP(byte[] tpl)
- {
- int width = GetTextureWidth(tpl);
- int height = GetTextureHeight(tpl);
- int offset = GetTextureOffset(tpl);
- UInt32[] output = new UInt32[width * height];
- UInt16[] c = new UInt16[4];
- int[] pix = new int[3];
- int inp = 0;
-
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- int ww = Tools.AddPadding(width, 8);
-
- int x0 = x & 0x03;
- int x1 = (x >> 2) & 0x01;
- int x2 = x >> 3;
-
- int y0 = y & 0x03;
- int y1 = (y >> 2) & 0x01;
- int y2 = y >> 3;
-
- int off = (8 * x1) + (16 * y1) + (32 * x2) + (4 * ww * y2);
-
- byte[] tmp1 = new byte[2];
- tmp1[1] = tpl[offset + off];
- tmp1[0] = tpl[offset + off + 1];
- c[0] = BitConverter.ToUInt16(tmp1, 0);
- tmp1[1] = tpl[offset + off + 2];
- tmp1[0] = tpl[offset + off + 3];
- c[1] = BitConverter.ToUInt16(tmp1, 0);
-
- if (c[0] > c[1])
- {
- c[2] = (UInt16)avg(2, 1, c[0], c[1]);
- c[3] = (UInt16)avg(1, 2, c[0], c[1]);
- }
- else
- {
- c[2] = (UInt16)avg(1, 1, c[0], c[1]);
- c[3] = 0;
- }
-
- byte[] pixeldata = new byte[4];
- pixeldata[3] = tpl[offset + off + 4];
- pixeldata[2] = tpl[offset + off + 5];
- pixeldata[1] = tpl[offset + off + 6];
- pixeldata[0] = tpl[offset + off + 7];
- UInt32 pixel = BitConverter.ToUInt32(pixeldata, 0);
-
- int ix = x0 + (4 * y0);
- int raw = c[(pixel >> (30 - (2 * ix))) & 0x03];
-
- pix[0] = (raw >> 8) & 0xf8;
- pix[1] = (raw >> 3) & 0xf8;
- pix[2] = (raw << 3) & 0xf8;
-
- int intout = (pix[0] << 16) | (pix[1] << 8) | (pix[2] << 0) | (255 << 24);
- output[inp] = (UInt32)intout;
- inp++;
- }
- }
-
- return Tools.UInt32ArrayToByteArray(output);
- }
-
- ///
- /// Gets the pixel data of a Bitmap as an Byte Array
- ///
- ///
- ///
- public static uint[] BitmapToRGBA(Bitmap img)
- {
- int x = img.Width;
- int y = img.Height;
- UInt32[] rgba = new UInt32[x * y];
-
- for (int i = 0; i < y; i += 4)
- {
- for (int j = 0; j < x; j += 4)
- {
- for (int y1 = i; y1 < i + 4; y1++)
- {
- for (int x1 = j; x1 < j + 4; x1++)
- {
- if (y1 >= y || x1 >= x)
- continue;
-
- Color color = img.GetPixel(x1, y1);
- rgba[x1 + (y1 * x)] = (UInt32)color.ToArgb();
- }
- }
- }
- }
-
- return rgba;
- }
-
- ///
- /// Converts an Image to a Tpl
- ///
- ///
- /// 4 = RGB565, 5 = RGB5A3, 6 = RGBA8
- ///
- public static void ConvertToTPL(Bitmap img, string destination, int format)
- {
- byte[] tpl = ConvertToTPL(img, format);
-
- using (FileStream fs = new FileStream(destination, FileMode.Create))
- {
- fs.Write(tpl, 0, tpl.Length);
- }
- }
-
- ///
- /// Converts an Image to a Tpl
- ///
- ///
- /// 4 = RGB565, 5 = RGB5A3, 6 = RGBA8
- ///
- public static void ConvertToTPL(Image img, string destination, int format)
- {
- byte[] tpl = ConvertToTPL((Bitmap)img, format);
-
- using (FileStream fs = new FileStream(destination, FileMode.Create))
- {
- fs.Write(tpl, 0, tpl.Length);
- }
- }
-
- ///
- /// Converts an Image to a Tpl
- ///
- ///
- /// 4 = RGB565, 5 = RGB5A3, 6 = RGBA8
- ///
- public static byte[] ConvertToTPL(Image img, int format)
- {
- return ConvertToTPL((Bitmap)img, format);
- }
-
- ///
- /// Converts an Image to a Tpl
- ///
- ///
- /// 4 = RGB565, 5 = RGB5A3, 6 = RGBA8
- ///
- public static byte[] ConvertToTPL(Bitmap img, int format)
- {
- using (MemoryStream ms = new MemoryStream())
- {
- byte[] rgbaData;
-
- UInt32 tplmagic = 0x20af30;
- UInt32 ntextures = 0x1;
- UInt32 headersize = 0xc;
- UInt32 texheaderoff = 0x14;
- UInt32 texpaletteoff = 0x0;
-
- UInt16 texheight = (UInt16)img.Height;
- UInt16 texwidth = (UInt16)img.Width;
- UInt32 texformat;
- UInt32 texdataoffset = 0x40;
- byte[] rest = new byte[] { 00, 00, 00, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00, 01, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 };
- //This should do it for our needs.. rest includes padding
-
- switch (format)
- {
- case 4: //RGB565
- texformat = 0x4;
- rgbaData = ToRGB565(img);
- break;
- case 5: //RGB5A3
- texformat = 0x5;
- rgbaData = ToRGB5A3(img);
- break;
- default: //RGBA8 = 6
- texformat = 0x6;
- rgbaData = ToRGBA8(img);
- break;
- }
-
- byte[] buffer = BitConverter.GetBytes(tplmagic); Array.Reverse(buffer);
- ms.Seek(0, SeekOrigin.Begin);
- ms.Write(buffer, 0, buffer.Length);
-
- buffer = BitConverter.GetBytes(ntextures); Array.Reverse(buffer);
- ms.Write(buffer, 0, buffer.Length);
-
- buffer = BitConverter.GetBytes(headersize); Array.Reverse(buffer);
- ms.Write(buffer, 0, buffer.Length);
-
- buffer = BitConverter.GetBytes(texheaderoff); Array.Reverse(buffer);
- ms.Write(buffer, 0, buffer.Length);
-
- buffer = BitConverter.GetBytes(texpaletteoff); Array.Reverse(buffer);
- ms.Write(buffer, 0, buffer.Length);
-
- buffer = BitConverter.GetBytes(texheight); Array.Reverse(buffer);
- ms.Write(buffer, 0, buffer.Length);
-
- buffer = BitConverter.GetBytes(texwidth); Array.Reverse(buffer);
- ms.Write(buffer, 0, buffer.Length);
-
- buffer = BitConverter.GetBytes(texformat); Array.Reverse(buffer);
- ms.Write(buffer, 0, buffer.Length);
-
- buffer = BitConverter.GetBytes(texdataoffset); Array.Reverse(buffer);
- ms.Write(buffer, 0, buffer.Length);
-
- ms.Write(rest, 0, rest.Length);
-
- ms.Write(rgbaData, 0, rgbaData.Length);
-
- return ms.ToArray();
- }
- }
-
- ///
- /// Converts an Image to RGBA8 Tpl data
- ///
- ///
- ///
- public static byte[] ToRGBA8(Bitmap img)
- {
- uint[] pixeldata = BitmapToRGBA(img);
- int w = img.Width;
- int h = img.Height;
- int z = 0, iv = 0;
- byte[] output = new byte[Tools.AddPadding(w, 4) * Tools.AddPadding(h, 4) * 4];
- uint[] lr = new uint[32], lg = new uint[32], lb = new uint[32], la = new uint[32];
-
- for (int y1 = 0; y1 < h; y1 += 4)
- {
- for (int x1 = 0; x1 < w; x1 += 4)
- {
- for (int y = y1; y < (y1 + 4); y++)
- {
- for (int x = x1; x < (x1 + 4); x++)
- {
- UInt32 rgba;
-
- if (y >= h || x >= w)
- {
- rgba = 0;
- }
- else
- {
- rgba = pixeldata[x + (y * w)];
- }
-
- lr[z] = (uint)(rgba >> 16) & 0xff;
- lg[z] = (uint)(rgba >> 8) & 0xff;
- lb[z] = (uint)(rgba >> 0) & 0xff;
- la[z] = (uint)(rgba >> 24) & 0xff;
-
- z++;
- }
- }
-
- if (z == 16)
- {
- for (int i = 0; i < 16; i++)
- {
- output[iv++] = (byte)(la[i]);
- output[iv++] = (byte)(lr[i]);
- }
- for (int i = 0; i < 16; i++)
- {
- output[iv++] = (byte)(lg[i]);
- output[iv++] = (byte)(lb[i]);
- }
-
- z = 0;
- }
- }
- }
-
-
- return output;
- }
-
- ///
- /// Converts an Image to RGBA565 Tpl data
- ///
- ///
- ///
- public static byte[] ToRGB565(Bitmap img)
- {
- uint[] pixeldata = BitmapToRGBA(img);
- int w = img.Width;
- int h = img.Height;
- int z = -1;
- byte[] output = new byte[Tools.AddPadding(w, 4) * Tools.AddPadding(h, 4) * 2];
-
- for (int y1 = 0; y1 < h; y1 += 4)
- {
- for (int x1 = 0; x1 < w; x1 += 4)
- {
- for (int y = y1; y < y1 + 4; y++)
- {
- for (int x = x1; x < x1 + 4; x++)
- {
- UInt16 newpixel;
-
- if (y >= h || x >= w)
- {
- newpixel = 0;
- }
- else
- {
- uint rgba = pixeldata[x + (y * w)];
-
- uint b = (rgba >> 16) & 0xff;
- uint g = (rgba >> 8) & 0xff;
- uint r = (rgba >> 0) & 0xff;
-
- newpixel = (UInt16)(((b >> 3) << 11) | ((g >> 2) << 5) | ((r >> 3) << 0));
- }
-
- byte[] temp = BitConverter.GetBytes(newpixel);
- Array.Reverse(temp);
-
- output[++z] = temp[0];
- output[++z] = temp[1];
- }
- }
- }
- }
-
- return output;
- }
-
- ///
- /// Converts an Image to RGBA5A3 Tpl data
- ///
- ///
- ///
- public static byte[] ToRGB5A3(Bitmap img)
- {
- uint[] pixeldata = BitmapToRGBA(img);
- int w = img.Width;
- int h = img.Height;
- int z = -1;
- byte[] output = new byte[Tools.AddPadding(w, 4) * Tools.AddPadding(h, 4) * 2];
-
- for (int y1 = 0; y1 < h; y1 += 4)
- {
- for (int x1 = 0; x1 < w; x1 += 4)
- {
- for (int y = y1; y < y1 + 4; y++)
- {
- for (int x = x1; x < x1 + 4; x++)
- {
- int newpixel;
-
- if (y >= h || x >= w)
- {
- newpixel = 0;
- }
- else
- {
- int rgba = (int)pixeldata[x + (y * w)];
- newpixel = 0;
-
- int r = (rgba >> 16) & 0xff;
- int g = (rgba >> 8) & 0xff;
- int b = (rgba >> 0) & 0xff;
- int a = (rgba >> 24) & 0xff;
-
- if (a <= 0xda)
- {
- //RGB4A3
-
- newpixel &= ~(1 << 15);
-
- r = ((r * 15) / 255) & 0xf;
- g = ((g * 15) / 255) & 0xf;
- b = ((b * 15) / 255) & 0xf;
- a = ((a * 7) / 255) & 0x7;
-
- newpixel |= a << 12;
- newpixel |= b << 0;
- newpixel |= g << 4;
- newpixel |= r << 8;
- }
- else
- {
- //RGB5
-
- newpixel |= (1 << 15);
-
- r = ((r * 31) / 255) & 0x1f;
- g = ((g * 31) / 255) & 0x1f;
- b = ((b * 31) / 255) & 0x1f;
-
- newpixel |= b << 0;
- newpixel |= g << 5;
- newpixel |= r << 10;
- }
- }
-
- byte[] temp = BitConverter.GetBytes((UInt16)newpixel);
- Array.Reverse(temp);
-
- output[++z] = temp[0];
- output[++z] = temp[1];
- }
- }
- }
- }
-
- return output;
- }
- }
-
- public class NAND
- {
- ///
- /// Backups all Saves from a NAND Backup
- ///
- ///
- ///
- public static void BackupSaves(string nandpath, string destinationpath)
- {
- string titlefolder = nandpath + "\\title";
- string[] lowerdirs = Directory.GetDirectories(titlefolder);
- Tools.ChangeProgress(0);
-
- for (int i = 0; i < lowerdirs.Length; i++)
- {
- Tools.ChangeProgress((i + 1) * 100 / lowerdirs.Length);
- string[] upperdirs = Directory.GetDirectories(lowerdirs[i]);
-
- for (int j = 0; j < upperdirs.Length; j++)
- {
- if (Directory.Exists(upperdirs[j] + "\\data"))
- {
- if (Directory.GetFiles(upperdirs[j] + "\\data").Length > 0 ||
- Directory.GetDirectories(upperdirs[j] + "\\data").Length > 0)
- {
- Tools.CopyDirectory(upperdirs[j] + "\\data", (upperdirs[j] + "\\data").Replace(nandpath, destinationpath).Replace("\\title", ""));
- }
- }
- }
- }
- }
-
- ///
- /// Restores all Saves for existing titles to a NAND Backup
- ///
- ///
- ///
- public static void RestoreSaves(string backuppath, string nandpath)
- {
- string titlefolder = nandpath + "\\title";
- string[] lowerdirs = Directory.GetDirectories(backuppath);
- Tools.ChangeProgress(0);
-
- for (int i = 0; i < lowerdirs.Length; i++)
- {
- Tools.ChangeProgress((i + 1) * 100 / lowerdirs.Length);
- string[] upperdirs = Directory.GetDirectories(lowerdirs[i]);
-
- for (int j = 0; j < upperdirs.Length; j++)
- {
- string[] datafiles = Directory.GetFiles(upperdirs[j] + "\\data");
- string upperdirnand = upperdirs[j].Replace(backuppath, titlefolder);
-
- if (Directory.Exists(upperdirnand) &&
- (Directory.GetFiles(upperdirs[j] + "\\data").Length > 0 ||
- Directory.GetDirectories(upperdirs[j] + "\\data").Length > 0))
- {
- if (!Directory.Exists(upperdirnand + "\\data")) Directory.CreateDirectory(upperdirnand + "\\data");
- Tools.CopyDirectory(upperdirs[j] + "\\data", (upperdirs[j] + "\\data").Replace(backuppath, titlefolder));
- }
- }
- }
-
- Tools.ChangeProgress(100);
- }
-
- ///
- /// Backups a single Save
- ///
- ///
- /// Format: XXXXXXXX\XXXXXXXX
- ///
- public static void BackupSingleSave(string nandpath, string titlepath, string destinationpath)
- {
- string datafolder = nandpath + "\\title\\" + titlepath + "\\data";
-
- if (Directory.GetFiles(datafolder).Length > 0 ||
- Directory.GetDirectories(datafolder).Length > 0)
- {
- string savefolder = datafolder.Replace(nandpath, destinationpath).Replace("\\title", "");
- if (!Directory.Exists(savefolder)) Directory.CreateDirectory(savefolder);
-
- Tools.CopyDirectory(datafolder, savefolder);
- }
- else
- {
- throw new Exception("No save data was found!");
- }
- }
-
- ///
- /// Restores a singe Save, if the title exists on NAND Backup
- ///
- ///
- /// Format: XXXXXXXX\XXXXXXXX
- ///
- public static void RestoreSingleSave(string backuppath, string titlepath, string nandpath)
- {
- string titlefoldernand = nandpath + "\\title\\" + titlepath;
- string titlefolder = titlefoldernand.Replace(nandpath, backuppath).Replace("\\title", "");
-
- if (Directory.Exists(titlefoldernand) &&
- (Directory.GetFiles(titlefolder + "\\data").Length > 0 ||
- Directory.GetDirectories(titlefolder + "\\data").Length > 0))
- {
- if (!Directory.Exists(titlefoldernand + "\\data")) Directory.CreateDirectory(titlefoldernand + "\\data");
- Tools.CopyDirectory(titlefolder + "\\data", titlefoldernand + "\\data");
- }
- else
- {
- throw new Exception("Title not found in NAND Backup!");
- }
- }
-
- ///
- /// Checks, if save data exists in the given title folder
- ///
- ///
- /// Format: XXXXXXXX\XXXXXXXX
- public static bool CheckForSaveData(string nandpath, string titlepath)
- {
- string datafolder = nandpath + "\\title\\" + titlepath + "\\data";
-
- if (!Directory.Exists(datafolder)) return false;
- else
- {
- string[] datafiles = Directory.GetFiles(datafolder);
-
- if (datafiles.Length > 0) return true;
- else return false;
- }
- }
-
- ///
- /// Checks, if save data exists in the given title folder
- ///
- ///
- /// Format: XXXXXXXX\XXXXXXXX
- public static bool CheckForBackupData(string backuppath, string titlepath)
- {
- string datafolder = backuppath + "\\" + titlepath + "\\data";
-
- if (!Directory.Exists(datafolder)) return false;
- else
- {
- string[] datafiles = Directory.GetFiles(datafolder);
-
- if (datafiles.Length > 0) return true;
- else return false;
- }
- }
- }
-
- public class Sound
- {
- ///
- /// Checks if the given Wave is a proper PCM WAV file
- ///
- ///
- ///
- public static bool CheckWave(string wavefile)
- {
- byte[] wave = Tools.LoadFileToByteArray(wavefile, 0, 256);
- return CheckWave(wave);
- }
-
- ///
- /// Checks if the given Wave is a proper PCM WAV file
- ///
- ///
- ///
- public static bool CheckWave(byte[] wavefile)
- {
- if (wavefile[0] != 'R' ||
- wavefile[1] != 'I' ||
- wavefile[2] != 'F' ||
- wavefile[3] != 'F' ||
-
- wavefile[8] != 'W' ||
- wavefile[9] != 'A' ||
- wavefile[10] != 'V' ||
- wavefile[11] != 'E' ||
-
- wavefile[12] != 'f' ||
- wavefile[13] != 'm' ||
- wavefile[14] != 't' ||
-
- wavefile[20] != 0x01 || //Format = PCM
- wavefile[21] != 0x00 ||
-
- wavefile[34] != 0x10 || //Bitrate (16bit)
- wavefile[35] != 0x00
- ) return false;
-
- return true;
- }
-
- ///
- /// Returns the playlength of the Wave file in seconds
- ///
- ///
- ///
- public static int GetWaveLength(string wavefile)
- {
- byte[] wave = Tools.LoadFileToByteArray(wavefile, 0, 256);
- return GetWaveLength(wave);
- }
-
- ///
- /// Returns the playlength of the Wave file in seconds
- ///
- ///
- ///
- public static int GetWaveLength(byte[] wavefile)
- {
- if (CheckWave(wavefile) == true)
- {
- byte[] BytesPerSec = new byte[] { wavefile[28], wavefile[29], wavefile[30], wavefile[31] };
- int bps = BitConverter.ToInt32(BytesPerSec, 0);
-
- byte[] Chunksize = new byte[] { wavefile[4], wavefile[5], wavefile[6], wavefile[7] };
- int chunks = BitConverter.ToInt32(Chunksize, 0);
-
- return Math.Abs(chunks / bps);
- }
- else
- throw new Exception("This is not a supported PCM Wave file!");
- }
-
- ///
- /// Converts a wave file to a sound.bin
- ///
- ///
- ///
- public static void WaveToSoundBin(string wavefile, string soundbin, bool compress)
- {
- if (CheckWave(wavefile) == true)
- {
- byte[] sound = Tools.LoadFileToByteArray(wavefile);
- if (compress == true) sound = Lz77.Compress(sound);
- sound = U8.AddHeaderIMD5(sound);
- Wii.Tools.SaveFileFromByteArray(sound, soundbin);
- }
- else
- throw new Exception("This is not a supported 16bit PCM Wave file!");
- }
-
- ///
- /// Converts a sound.bin to a wave file
- ///
- ///
- ///
- public static void SoundBinToWave(string soundbin, string wavefile)
- {
- MemoryStream ms = new MemoryStream(Tools.LoadFileToByteArray(soundbin));
- byte[] wave = new byte[ms.Length - 32];
- int offset = 0;
-
- ms.Seek(32, SeekOrigin.Begin);
- ms.Read(wave, 0, wave.Length);
-
- if ((offset = Lz77.GetLz77Offset(wave)) != -1)
- wave = Lz77.Decompress(wave, offset);
-
- Tools.SaveFileFromByteArray(wave, wavefile);
- }
- }
-
- public class Brlyt
- {
- ///
- /// Checks, if the TPLs match the TPLs specified in the brlyt
- ///
- ///
- ///
- ///
- public static bool CheckBrlytTpls(string brlyt, string[] tpls)
- {
- byte[] brlytArray = Tools.LoadFileToByteArray(brlyt);
- return CheckBrlytTpls(brlytArray, tpls);
- }
-
- ///
- /// Checks, if the TPLs match the TPLs specified in the brlyt
- ///
- ///
- ///
- ///
- public static bool CheckBrlytTpls(byte[] brlyt, string[] tpls)
- {
- int texcount = Tools.HexStringToInt(brlyt[44].ToString("x2") + brlyt[45].ToString("x2"));
- if (tpls.Length != texcount) return false;
-
- int texnamepos = 48 + (texcount * 8);
- for (int i = 0; i < texcount; i++)
- {
- string thisTex = "";
- while (brlyt[texnamepos] != 0x00)
- {
- thisTex += Convert.ToChar(brlyt[texnamepos]);
- texnamepos++;
- }
- texnamepos++;
-
- bool exists = Array.Exists(tpls,tpl => tpl == thisTex);
- if (exists == false) return false;
- }
-
- return true;
- }
-
- ///
- /// Checks, if one or more Tpls specified in the brlyt are missing and returns
- /// the names of the missing ones.
- ///
- ///
- ///
- ///
- ///
- public static bool CheckForMissingTpls(string brlyt, string[] tpls, out string[] missingtpls)
- {
- byte[] brlytArray = Tools.LoadFileToByteArray(brlyt);
- return CheckForMissingTpls(brlytArray, tpls, out missingtpls);
- }
-
- ///
- /// Checks, if one or more Tpls specified in the brlyt are missing and returns
- /// the names of the missing ones.
- ///
- ///
- ///
- ///
- ///
- public static bool CheckForMissingTpls(byte[] brlyt, string[] tpls, out string[] missingtpls)
- {
- List missings = new List();
- string[] brlytTpls = GetBrlytTpls(brlyt);
- bool missing = false;
-
- for (int i = 0; i < brlytTpls.Length; i++)
- {
- if (Tools.StringExistsInStringArray(brlytTpls[i], tpls) == false)
- {
- missings.Add(brlytTpls[i]);
- missing = true;
- }
- }
-
- missingtpls = missings.ToArray();
- return missing;
- }
-
- ///
- /// Checks, if one or more Tpls are not specified in the brlyt and returns
- /// the names of the missing ones.
- ///
- ///
- ///
- ///
- ///
- public static bool CheckForUnusedTpls(string brlyt, string[] tpls, out string[] unusedtpls)
- {
- byte[] brlytArray = Tools.LoadFileToByteArray(brlyt);
- return CheckForUnusedTpls(brlytArray, tpls, out unusedtpls);
- }
-
- ///
- /// Checks, if one or more Tpls are not specified in the brlyt and returns
- /// the names of the missing ones.
- ///
- ///
- ///
- ///
- ///
- public static bool CheckForUnusedTpls(byte[] brlyt, string[] tpls, out string[] unusedtpls)
- {
- List unuseds = new List();
- string[] brlytTpls = GetBrlytTpls(brlyt);
- bool missing = false;
-
- for (int i = 0; i < tpls.Length; i++)
- {
- if (Tools.StringExistsInStringArray(tpls[i], brlytTpls) == false)
- {
- unuseds.Add(tpls[i]);
- missing = true;
- }
- }
-
- unusedtpls = unuseds.ToArray();
- return missing;
- }
-
- ///
- /// Returns the name of all Tpls specified in the brlyt
- ///
- ///
- ///
- public static string[] GetBrlytTpls(string brlyt)
- {
- byte[] temp = Tools.LoadFileToByteArray(brlyt);
- return GetBrlytTpls(temp);
- }
-
- ///
- /// Returns the name of all Tpls specified in the brlyt
- ///
- ///
- ///
- public static string[] GetBrlytTpls(byte[] brlyt)
- {
- int texcount = Tools.HexStringToInt(brlyt[44].ToString("x2") + brlyt[45].ToString("x2"));
- int texnamepos = 48 + (texcount * 8);
- List Tpls = new List();
-
- for (int i = 0; i < texcount; i++)
- {
- string thisTex = "";
- while (brlyt[texnamepos] != 0x00)
- {
- thisTex += Convert.ToChar(brlyt[texnamepos]);
- texnamepos++;
- }
- Tpls.Add(thisTex);
- texnamepos++;
- }
-
- return Tpls.ToArray();
- }
-
- ///
- /// Returns true, if the given Tpl is specified in the brlyt.
- /// TplName must end with ".tpl"!
- ///
- ///
- ///
- ///
- public static bool IsTplInBrlyt(byte[] brlyt, string TplName)
- {
- string[] brlytTpls = GetBrlytTpls(brlyt);
- bool exists = Array.Exists(brlytTpls, Tpl => Tpl == TplName);
- return exists;
- }
- }
-
- public class ProgressChangedEventArgs : EventArgs
- {
- private readonly int p_Percent = 0;
-
- public int PercentProgress
- {
- get { return p_Percent; }
- }
-
- internal ProgressChangedEventArgs(int PercentProgress)
- : base()
- {
- this.p_Percent = PercentProgress;
- }
- }
-}
\ No newline at end of file
diff --git a/CustomizeMii.sln b/TransmitMii.sln
similarity index 54%
rename from CustomizeMii.sln
rename to TransmitMii.sln
index 617b3b2..57aa49b 100644
--- a/CustomizeMii.sln
+++ b/TransmitMii.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C# Express 2008
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomizeMii", "CustomizeMii\CustomizeMii.csproj", "{46B7F0BC-101B-4167-95AD-4C5D78AA0A20}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransmitMii", "TransmitMii\TransmitMii.csproj", "{70517550-06FA-4743-B5D7-2CB7C153E35E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -9,10 +9,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {46B7F0BC-101B-4167-95AD-4C5D78AA0A20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {46B7F0BC-101B-4167-95AD-4C5D78AA0A20}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {46B7F0BC-101B-4167-95AD-4C5D78AA0A20}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {46B7F0BC-101B-4167-95AD-4C5D78AA0A20}.Release|Any CPU.Build.0 = Release|Any CPU
+ {70517550-06FA-4743-B5D7-2CB7C153E35E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {70517550-06FA-4743-B5D7-2CB7C153E35E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {70517550-06FA-4743-B5D7-2CB7C153E35E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {70517550-06FA-4743-B5D7-2CB7C153E35E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/TransmitMii.suo b/TransmitMii.suo
new file mode 100644
index 0000000..f8a1f31
Binary files /dev/null and b/TransmitMii.suo differ
diff --git a/CustomizeMii/License.txt b/TransmitMii/License.txt
similarity index 100%
rename from CustomizeMii/License.txt
rename to TransmitMii/License.txt
diff --git a/CustomizeMii/Program.cs b/TransmitMii/Program.cs
similarity index 67%
rename from CustomizeMii/Program.cs
rename to TransmitMii/Program.cs
index 8848c92..4b73f54 100644
--- a/CustomizeMii/Program.cs
+++ b/TransmitMii/Program.cs
@@ -1,12 +1,12 @@
-/* This file is part of CustomizeMii
+/* This file is part of TransmitMii
* Copyright (C) 2009 Leathl
*
- * CustomizeMii is free software: you can redistribute it and/or
+ * TransmitMii 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
+ * TransmitMii 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.
@@ -18,7 +18,7 @@
using System;
using System.Windows.Forms;
-namespace CustomizeMii
+namespace TransmitMii
{
static class Program
{
@@ -26,11 +26,15 @@ namespace CustomizeMii
/// Der Haupteinstiegspunkt für die Anwendung.
///
[STAThread]
- static void Main()
+ static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new CustomizeMii_Main());
+
+ if (args.Length > 0)
+ Application.Run(new TransmitMii_Main(args));
+ else
+ Application.Run(new TransmitMii_Main());
}
}
}
diff --git a/CustomizeMii/Properties/AssemblyInfo.cs b/TransmitMii/Properties/AssemblyInfo.cs
similarity index 74%
rename from CustomizeMii/Properties/AssemblyInfo.cs
rename to TransmitMii/Properties/AssemblyInfo.cs
index 0c1e38a..e3e1eb0 100644
--- a/CustomizeMii/Properties/AssemblyInfo.cs
+++ b/TransmitMii/Properties/AssemblyInfo.cs
@@ -1,12 +1,12 @@
-/* This file is part of CustomizeMii
+/* This file is part of TransmitMii
* Copyright (C) 2009 Leathl
*
- * CustomizeMii is free software: you can redistribute it and/or
+ * TransmitMii 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
+ * TransmitMii 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.
@@ -18,16 +18,15 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Resources;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// 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: AssemblyTitle("TransmitMii")]
+[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("CustomizeMii")]
+[assembly: AssemblyProduct("TransmitMii")]
[assembly: AssemblyCopyright("Copyright © Leathl 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -38,7 +37,7 @@ using System.Resources;
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
-[assembly: Guid("b8292272-5915-44f7-a7b1-a347bea3ecd5")]
+[assembly: Guid("2f34de47-0b02-4f59-b976-b1630f56d8dc")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
@@ -50,6 +49,5 @@ 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("1.1.0.0")]
-[assembly: AssemblyFileVersion("1.1.0.0")]
-[assembly: NeutralResourcesLanguageAttribute("en")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/CustomizeMii/Properties/Resources.Designer.cs b/TransmitMii/Properties/Resources.Designer.cs
similarity index 69%
rename from CustomizeMii/Properties/Resources.Designer.cs
rename to TransmitMii/Properties/Resources.Designer.cs
index 14c69f3..cbbaff5 100644
--- a/CustomizeMii/Properties/Resources.Designer.cs
+++ b/TransmitMii/Properties/Resources.Designer.cs
@@ -8,7 +8,7 @@
//
//------------------------------------------------------------------------------
-namespace CustomizeMii.Properties {
+namespace TransmitMii.Properties {
using System;
@@ -39,7 +39,7 @@ namespace CustomizeMii.Properties {
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CustomizeMii.Properties.Resources", typeof(Resources).Assembly);
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TransmitMii.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
@@ -60,27 +60,11 @@ namespace CustomizeMii.Properties {
}
}
- internal static System.Drawing.Icon CustomizeMii {
+ internal static System.Drawing.Icon TransmitMii_Icon {
get {
- object obj = ResourceManager.GetObject("CustomizeMii", resourceCulture);
+ object obj = ResourceManager.GetObject("TransmitMii_Icon", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
-
- ///
- /// Sucht eine lokalisierte Zeichenfolge, die {\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil\fcharset0 Arial;}}
- ///{\colortbl ;\red255\green0\blue0;\red0\green0\blue255;}
- ///{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\b\fs20 These are some basic instructions for CustomizeMii.\b0\par
- ///\par
- ///\cf1 At the very beginning, let me say this again: Don't install any WADs without a proper brick protection!\cf0\par
- ///\par
- ///Ok, so you want to create your own custom channels?\par
- ///First it is important to understand how the [Rest der Zeichenfolge wurde abgeschnitten]"; ähnelt.
- ///
- internal static string Instructions {
- get {
- return ResourceManager.GetString("Instructions", resourceCulture);
- }
- }
}
}
diff --git a/CustomizeMii/CustomizeMii_Preview.resx b/TransmitMii/Properties/Resources.resx
similarity index 90%
rename from CustomizeMii/CustomizeMii_Preview.resx
rename to TransmitMii/Properties/Resources.resx
index ff31a6d..fd3a021 100644
--- a/CustomizeMii/CustomizeMii_Preview.resx
+++ b/TransmitMii/Properties/Resources.resx
@@ -1,4 +1,4 @@
-
+
+
\ No newline at end of file
diff --git a/TransmitMii/TransmitMii.csproj.user b/TransmitMii/TransmitMii.csproj.user
new file mode 100644
index 0000000..7ff3943
--- /dev/null
+++ b/TransmitMii/TransmitMii.csproj.user
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/TransmitMii/TransmitMii_Main.Designer.cs b/TransmitMii/TransmitMii_Main.Designer.cs
new file mode 100644
index 0000000..0a212a9
--- /dev/null
+++ b/TransmitMii/TransmitMii_Main.Designer.cs
@@ -0,0 +1,189 @@
+/* This file is part of TransmitMii
+ * Copyright (C) 2009 Leathl
+ *
+ * TransmitMii 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.
+ *
+ * TransmitMii 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 TransmitMii
+{
+ partial class TransmitMii_Main
+ {
+ ///
+ /// Erforderliche Designervariable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Verwendete Ressourcen bereinigen.
+ ///
+ /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Vom Windows Form-Designer generierter Code
+
+ ///
+ /// Erforderliche Methode für die Designerunterstützung.
+ /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
+ ///
+ private void InitializeComponent()
+ {
+ this.lbIP = new System.Windows.Forms.Label();
+ this.lbFile = new System.Windows.Forms.Label();
+ this.tbFile = new System.Windows.Forms.TextBox();
+ this.btnBrowseFile = new System.Windows.Forms.Button();
+ this.btnSend = new System.Windows.Forms.Button();
+ this.lbStatus = new System.Windows.Forms.Label();
+ this.tbIP = new System.Windows.Forms.TextBox();
+ this.lbProtocol = new System.Windows.Forms.Label();
+ this.cmbProtocol = new System.Windows.Forms.ComboBox();
+ this.SuspendLayout();
+ //
+ // lbIP
+ //
+ this.lbIP.AutoSize = true;
+ this.lbIP.Location = new System.Drawing.Point(12, 76);
+ this.lbIP.Name = "lbIP";
+ this.lbIP.Size = new System.Drawing.Size(61, 13);
+ this.lbIP.TabIndex = 2;
+ this.lbIP.Text = "IP Address:";
+ //
+ // lbFile
+ //
+ this.lbFile.AutoSize = true;
+ this.lbFile.Location = new System.Drawing.Point(12, 46);
+ this.lbFile.Name = "lbFile";
+ this.lbFile.Size = new System.Drawing.Size(26, 13);
+ this.lbFile.TabIndex = 3;
+ this.lbFile.Text = "File:";
+ //
+ // tbFile
+ //
+ this.tbFile.Location = new System.Drawing.Point(44, 43);
+ this.tbFile.Name = "tbFile";
+ this.tbFile.Size = new System.Drawing.Size(166, 20);
+ this.tbFile.TabIndex = 4;
+ this.tbFile.MouseLeave += new System.EventHandler(this.tbFile_MouseLeave);
+ this.tbFile.MouseEnter += new System.EventHandler(this.tbFile_MouseEnter);
+ //
+ // btnBrowseFile
+ //
+ this.btnBrowseFile.Location = new System.Drawing.Point(216, 42);
+ this.btnBrowseFile.Name = "btnBrowseFile";
+ this.btnBrowseFile.Size = new System.Drawing.Size(75, 20);
+ this.btnBrowseFile.TabIndex = 5;
+ this.btnBrowseFile.Text = "Browse...";
+ this.btnBrowseFile.UseVisualStyleBackColor = true;
+ this.btnBrowseFile.Click += new System.EventHandler(this.btnBrowseFile_Click);
+ //
+ // btnSend
+ //
+ this.btnSend.Location = new System.Drawing.Point(216, 72);
+ this.btnSend.Name = "btnSend";
+ this.btnSend.Size = new System.Drawing.Size(75, 20);
+ this.btnSend.TabIndex = 5;
+ this.btnSend.Text = "Send";
+ this.btnSend.UseVisualStyleBackColor = true;
+ this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
+ //
+ // lbStatus
+ //
+ this.lbStatus.AutoSize = true;
+ this.lbStatus.Location = new System.Drawing.Point(12, 108);
+ this.lbStatus.Name = "lbStatus";
+ this.lbStatus.Size = new System.Drawing.Size(40, 13);
+ this.lbStatus.TabIndex = 7;
+ this.lbStatus.Text = "Status:";
+ //
+ // tbIP
+ //
+ this.tbIP.Location = new System.Drawing.Point(79, 72);
+ this.tbIP.Name = "tbIP";
+ this.tbIP.Size = new System.Drawing.Size(131, 20);
+ this.tbIP.TabIndex = 8;
+ this.tbIP.MouseLeave += new System.EventHandler(this.tbIP_MouseLeave);
+ this.tbIP.MouseEnter += new System.EventHandler(this.tbIP_MouseEnter);
+ //
+ // lbProtocol
+ //
+ this.lbProtocol.AutoSize = true;
+ this.lbProtocol.Location = new System.Drawing.Point(12, 16);
+ this.lbProtocol.Name = "lbProtocol";
+ this.lbProtocol.Size = new System.Drawing.Size(49, 13);
+ this.lbProtocol.TabIndex = 9;
+ this.lbProtocol.Text = "Protocol:";
+ //
+ // cmbProtocol
+ //
+ this.cmbProtocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cmbProtocol.FormattingEnabled = true;
+ this.cmbProtocol.Items.AddRange(new object[] {
+ "HBC 1.0.5+ (JODI)",
+ "HBC -1.0.4 (HAXX)",
+ "USB Loader GX"});
+ this.cmbProtocol.Location = new System.Drawing.Point(67, 13);
+ this.cmbProtocol.Name = "cmbProtocol";
+ this.cmbProtocol.Size = new System.Drawing.Size(224, 21);
+ this.cmbProtocol.TabIndex = 10;
+ this.cmbProtocol.MouseEnter += new System.EventHandler(this.cmbProtocol_MouseEnter);
+ this.cmbProtocol.MouseLeave += new System.EventHandler(this.cmbProtocol_MouseLeave);
+ //
+ // TransmitMii_Main
+ //
+ this.AllowDrop = true;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(303, 128);
+ this.Controls.Add(this.cmbProtocol);
+ this.Controls.Add(this.lbProtocol);
+ this.Controls.Add(this.tbIP);
+ this.Controls.Add(this.lbStatus);
+ this.Controls.Add(this.btnSend);
+ this.Controls.Add(this.btnBrowseFile);
+ this.Controls.Add(this.tbFile);
+ this.Controls.Add(this.lbFile);
+ this.Controls.Add(this.lbIP);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
+ this.MaximizeBox = false;
+ this.Name = "TransmitMii_Main";
+ this.Text = "TransmitMii X by Leathl";
+ this.Load += new System.EventHandler(this.TransmitMii_Main_Load);
+ this.DragDrop += new System.Windows.Forms.DragEventHandler(this.TransmitMii_Main_DragDrop);
+ this.DragEnter += new System.Windows.Forms.DragEventHandler(this.TransmitMii_Main_DragEnter);
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TransmitMii_Main_FormClosing);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label lbIP;
+ private System.Windows.Forms.Label lbFile;
+ private System.Windows.Forms.TextBox tbFile;
+ private System.Windows.Forms.Button btnBrowseFile;
+ private System.Windows.Forms.Button btnSend;
+ private System.Windows.Forms.Label lbStatus;
+ private System.Windows.Forms.TextBox tbIP;
+ private System.Windows.Forms.Label lbProtocol;
+ private System.Windows.Forms.ComboBox cmbProtocol;
+ }
+}
+
diff --git a/TransmitMii/TransmitMii_Main.cs b/TransmitMii/TransmitMii_Main.cs
new file mode 100644
index 0000000..45c6441
--- /dev/null
+++ b/TransmitMii/TransmitMii_Main.cs
@@ -0,0 +1,361 @@
+/* This file is part of TransmitMii
+ * Copyright (C) 2009 Leathl
+ *
+ * TransmitMii 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.
+ *
+ * TransmitMii 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 .
+ */
+
+using System;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using System.IO.Compression;
+using System.Net;
+using System.Net.Sockets;
+using System.Text.RegularExpressions;
+using System.Windows.Forms;
+
+namespace TransmitMii
+{
+ public partial class TransmitMii_Main : Form
+ {
+ const string version = "1.0"; //Hint for myself: Never use a char in the Version (UpdateCheck)!
+ private bool IsRunning = false;
+ private string fileName;
+ private string statusText;
+ private bool JODI;
+ EventHandler UpdateStatus;
+ EventHandler EnableButtons;
+ BackgroundWorker bwTransmit = new BackgroundWorker();
+ Regex IpAdress;
+
+ public TransmitMii_Main()
+ {
+ InitializeComponent();
+ this.CenterToScreen();
+ this.Icon = Properties.Resources.TransmitMii_Icon;
+ }
+
+ public TransmitMii_Main(string[] args)
+ {
+ InitializeComponent();
+ this.CenterToScreen();
+
+ if (args[0].EndsWith(".dol") || args[0].EndsWith(".elf"))
+ tbFile.Text = args[0];
+ }
+
+ private void TransmitMii_Main_Load(object sender, EventArgs e)
+ {
+ this.Text = this.Text.Replace("X", version);
+ UpdateCheck();
+
+ UpdateStatus = new EventHandler(this.StatusUpdate);
+ EnableButtons = new EventHandler(this.ButtonEnable);
+ bwTransmit.DoWork += new DoWorkEventHandler(bwTransmit_DoWork);
+ bwTransmit.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwTransmit_RunWorkerCompleted);
+ bwTransmit.WorkerSupportsCancellation = true;
+
+ string IpPattern = @"([01]?\d\d?|2[0-4]\d|25[0-5])\." +
+ @"([01]?\d\d?|2[0-4]\d|25[0-5])\." +
+ @"([01]?\d\d?|2[0-4]\d|25[0-5])\." +
+ @"([01]?\d\d?|2[0-4]\d|25[0-5])";
+ IpAdress = new Regex(IpPattern);
+
+ LoadSettings();
+
+ if (!string.IsNullOrEmpty(tbIP.Text) && !string.IsNullOrEmpty(tbFile.Text))
+ btnSend_Click(null, null);
+ }
+
+ private void LoadSettings()
+ {
+ tbIP.Text = Properties.Settings.Default.IPAddress;
+ cmbProtocol.SelectedIndex = Properties.Settings.Default.Protocol;
+ }
+
+ private void SaveSettings()
+ {
+ Properties.Settings.Default.IPAddress = tbIP.Text;
+ Properties.Settings.Default.Protocol = cmbProtocol.SelectedIndex;
+ Properties.Settings.Default.Save();
+ }
+
+ private void UpdateCheck()
+ {
+ try
+ {
+ WebClient GetVersion = new WebClient();
+ string NewVersion = GetVersion.DownloadString("http://customizemii.googlecode.com/svn/transmitmii-version.txt");
+
+ int newVersion = Convert.ToInt32(NewVersion.Replace(".", string.Empty).Length == 2 ? (NewVersion.Replace(".", string.Empty) + "0") : NewVersion.Replace(".", string.Empty));
+ int thisVersion = Convert.ToInt32(version.Replace(".", string.Empty).Length == 2 ? (version.Replace(".", string.Empty) + "0") : version.Replace(".", string.Empty));
+
+ if (newVersion > thisVersion)
+ {
+ if (MessageBox.Show("Version " + NewVersion +
+ " is availabe.\nDo you want the download page to be opened?",
+ "Update availabe", MessageBoxButtons.YesNo, MessageBoxIcon.Information) ==
+ DialogResult.Yes)
+ {
+ Process.Start("http://code.google.com/p/customizemii/downloads/list");
+ }
+ }
+ }
+ catch { }
+ }
+
+ private void ErrorBox(string message)
+ {
+ MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ private void StatusUpdate(string theMessage)
+ {
+ statusText = "Status: " + theMessage;
+ this.Invoke(UpdateStatus);
+ }
+
+ private void StatusUpdate(object sender, EventArgs e)
+ {
+ lbStatus.Text = statusText;
+ }
+
+ private void ButtonEnable(object sender, EventArgs e)
+ {
+ IsRunning = false;
+ btnBrowseFile.Enabled = true;
+ btnSend.Enabled = true;
+ }
+
+ private bool Transmit(string fileName, byte[] fileData, bool JODI) //(byte[] theFile, int fileLength, byte[] args, int argsLength)
+ {
+ TcpClient theClient = new TcpClient();
+ NetworkStream theStream;
+
+ int Blocksize = 4 * 1024;
+ if (!JODI) Blocksize = 16 * 1024;
+ byte[] buffer = new byte[4];
+ string theIP = tbIP.Text;
+
+ StatusUpdate("Connecting...");
+ try { theClient.Connect(theIP, 4299); }
+ catch (Exception ex) { ErrorBox("Connection Failed:\n" + ex.Message); theClient.Close(); return false; }
+ theStream = theClient.GetStream();
+
+ StatusUpdate("Connected... Sending Magic...");
+ buffer[0] = (byte)'H';
+ buffer[1] = (byte)'A';
+ buffer[2] = (byte)'X';
+ buffer[3] = (byte)'X';
+ try { theStream.Write(buffer, 0, 4); }
+ catch (Exception ex) { ErrorBox("Error sending Magic:\n" + ex.Message); theStream.Close(); theClient.Close(); return false; }
+
+ StatusUpdate("Magic Sent... Sending Version Info...");
+ if (JODI)
+ {
+ buffer[0] = 0;
+ buffer[1] = 5;
+ buffer[2] = (byte)(((fileName.Length + 2) >> 8) & 0xff);
+ buffer[3] = (byte)((fileName.Length + 2) & 0xff);
+ }
+ else
+ {
+ buffer[0] = 0;
+ buffer[1] = 1;
+ buffer[2] = 0;
+ buffer[3] = 0;
+ }
+ try { theStream.Write(buffer, 0, 4); }
+ catch (Exception ex) { ErrorBox("Error sending Version Info:\n" + ex.Message); theStream.Close(); theClient.Close(); return false; }
+
+ StatusUpdate("Version Info Sent... Sending Filesize...");
+ //First compressed filesize, then uncompressed filesize
+ buffer[0] = (byte)((fileData.Length >> 24) & 0xff);
+ buffer[1] = (byte)((fileData.Length >> 16) & 0xff);
+ buffer[2] = (byte)((fileData.Length >> 8) & 0xff);
+ buffer[3] = (byte)(fileData.Length & 0xff);
+ try { theStream.Write(buffer, 0, 4); }
+ catch (Exception ex) { ErrorBox("Error sending Filesize:\n" + ex.Message); theStream.Close(); theClient.Close(); return false; }
+
+ if (JODI)
+ {
+ buffer[0] = 0;
+ buffer[1] = 0;
+ buffer[2] = 0;
+ buffer[3] = 0;
+ try { theStream.Write(buffer, 0, 4); }
+ catch (Exception ex) { ErrorBox("Error sending Filesize:\n" + ex.Message); theStream.Close(); theClient.Close(); return false; }
+ }
+
+ StatusUpdate("Filesize Sent... Sending File...");
+ int off = 0;
+ int cur = 0;
+ int count = fileData.Length / Blocksize;
+ int left = fileData.Length % Blocksize;
+
+ try
+ {
+ do
+ {
+ StatusUpdate("Sending File: " + ((cur + 1) * 100 / count).ToString() + "%");
+ theStream.Write(fileData, off, Blocksize);
+ off += Blocksize;
+ cur++;
+ } while (cur < count);
+
+ if (left > 0)
+ {
+ theStream.Write(fileData, off, fileData.Length - off);
+ }
+ }
+ catch (Exception ex) { ErrorBox("Error sending File:\n" + ex.Message); theStream.Close(); theClient.Close(); return false; }
+
+ if (JODI)
+ {
+ StatusUpdate("File Sent... Sending Arguments...");
+ byte[] theArgs = new byte[fileName.Length + 2];
+ for (int i = 0; i < fileName.Length; i++) { theArgs[i] = (byte)fileName.ToCharArray()[i]; }
+ try { theStream.Write(theArgs, 0, theArgs.Length); }
+ catch (Exception ex) { ErrorBox("Error sending Arguments:\n" + ex.Message); theStream.Close(); theClient.Close(); return false; }
+ }
+
+ theStream.Close();
+ theClient.Close();
+
+ StatusUpdate(string.Empty);
+
+ return true;
+ }
+
+ private void btnBrowseFile_Click(object sender, EventArgs e)
+ {
+ OpenFileDialog ofd = new OpenFileDialog();
+ ofd.Filter = "DOL|*.dol|ELF|*.elf|WAD|*.wad|All|*.dol;*.elf;*.wad";
+ ofd.FilterIndex = 4;
+
+ if (ofd.ShowDialog() == DialogResult.OK)
+ {
+ tbFile.Text = ofd.FileName;
+ }
+ }
+
+ private void btnSend_Click(object sender, EventArgs e)
+ {
+ if (File.Exists(tbFile.Text))
+ {
+ if (IpAdress.IsMatch(tbIP.Text))
+ {
+ if (tbFile.Text.EndsWith(".wad") && cmbProtocol.SelectedIndex != 2)
+ { ErrorBox("WAD files can only be sent to USB Loader GX!"); return; }
+
+ btnSend.Enabled = false;
+ btnBrowseFile.Enabled = false;
+ IsRunning = true;
+
+ FileStream fs = new FileStream(tbFile.Text, FileMode.Open);
+ byte[] theFile = new byte[fs.Length];
+ fs.Read(theFile, 0, theFile.Length);
+
+ fileName = Path.GetFileName(tbFile.Text);
+
+ JODI = cmbProtocol.SelectedIndex == 0 ? true : false;
+ bwTransmit.RunWorkerAsync(theFile);
+ }
+ else { tbIP.Focus(); tbIP.SelectAll(); }
+ }
+ else { tbFile.Focus(); tbFile.SelectAll(); }
+ }
+
+ void bwTransmit_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
+ {
+ this.Invoke(EnableButtons);
+ StatusUpdate(string.Empty);
+ }
+
+ void bwTransmit_DoWork(object sender, DoWorkEventArgs e)
+ {
+ byte[] theFile = e.Argument as byte[];
+
+ if (Transmit(fileName, theFile, JODI))
+ {
+ MessageBox.Show("File Sent...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+
+ private void tbFile_MouseEnter(object sender, EventArgs e)
+ {
+ if (IsRunning == false)
+ lbStatus.Text = "The file to transmit...";
+ }
+
+ private void tbFile_MouseLeave(object sender, EventArgs e)
+ {
+ if (IsRunning == false)
+ lbStatus.Text = "Status:";
+ }
+
+ private void tbIP_MouseEnter(object sender, EventArgs e)
+ {
+ if (IsRunning == false)
+ lbStatus.Text = "The IP address of the Wii...";
+ }
+
+ private void cmbProtocol_MouseEnter(object sender, EventArgs e)
+ {
+ if (IsRunning == false)
+ lbStatus.Text = "The protocol to use for transmitting...";
+ }
+
+ private void cmbProtocol_MouseLeave(object sender, EventArgs e)
+ {
+ if (IsRunning == false)
+ lbStatus.Text = "Status:";
+ }
+
+ private void tbIP_MouseLeave(object sender, EventArgs e)
+ {
+ if (IsRunning == false)
+ lbStatus.Text = "Status:";
+ }
+
+ private void TransmitMii_Main_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ bwTransmit.CancelAsync();
+ SaveSettings();
+ }
+
+ private void TransmitMii_Main_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(DataFormats.FileDrop))
+ {
+ string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
+ if (files.Length == 1)
+ {
+ if (Path.GetExtension(files[0]) == ".dol" || Path.GetExtension(files[0]) == ".elf")
+ e.Effect = DragDropEffects.Copy;
+ else
+ e.Effect = DragDropEffects.None;
+ }
+ else e.Effect = DragDropEffects.None;
+ }
+ else e.Effect = DragDropEffects.None;
+ }
+
+ private void TransmitMii_Main_DragDrop(object sender, DragEventArgs e)
+ {
+ string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
+ tbFile.Text = files[0];
+ }
+ }
+}
diff --git a/CustomizeMii/CustomizeMii_InputBox.resx b/TransmitMii/TransmitMii_Main.resx
similarity index 100%
rename from CustomizeMii/CustomizeMii_InputBox.resx
rename to TransmitMii/TransmitMii_Main.resx
diff --git a/TransmitMii/app.config b/TransmitMii/app.config
new file mode 100644
index 0000000..b2e47bb
--- /dev/null
+++ b/TransmitMii/app.config
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
\ No newline at end of file