mirror of
https://github.com/Brawl345/customizemii.git
synced 2024-12-04 21:54:16 +01:00
This commit is contained in:
parent
8a7787e326
commit
adeb60b1e6
@ -76,6 +76,9 @@
|
||||
<Compile Include="CustomizeMii_ComplexForwarder.Designer.cs">
|
||||
<DependentUpon>CustomizeMii_ComplexForwarder.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CustomizeMii_DragDrop.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CustomizeMii_Forwarders.cs" />
|
||||
<Compile Include="CustomizeMii_Main.cs">
|
||||
<SubType>Form</SubType>
|
||||
@ -89,6 +92,10 @@
|
||||
<Compile Include="CustomizeMii_InputBox.Designer.cs">
|
||||
<DependentUpon>CustomizeMii_InputBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CustomizeMii_PrivateFunctions.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MP3Info.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="CustomizeMii_BnsConvert.resx">
|
||||
@ -143,7 +150,6 @@
|
||||
<Content Include="Instructions.txt" />
|
||||
<None Include="Resources\btnSend.png" />
|
||||
<None Include="Resources\btnCreate.png" />
|
||||
<None Include="Resources\btnCreateWad.png" />
|
||||
<None Include="Resources\CustomizeMii.ico" />
|
||||
<None Include="Resources\Instructions.rtf" />
|
||||
</ItemGroup>
|
||||
|
@ -473,6 +473,7 @@ namespace CustomizeMii
|
||||
string[] ChannelTitles = Wii.WadInfo.GetChannelTitles(WadFile);
|
||||
string TitleID = Wii.WadInfo.GetTitleID(WadFile, 1);
|
||||
|
||||
SetText(tbTitleID, TitleID);
|
||||
SetText(tbAllLanguages, ChannelTitles[1]);
|
||||
|
||||
if (ChannelTitles[0] != ChannelTitles[1])
|
||||
@ -488,7 +489,18 @@ namespace CustomizeMii
|
||||
if (ChannelTitles[6] != ChannelTitles[1])
|
||||
SetText(tbDutch, ChannelTitles[6]);
|
||||
|
||||
SetText(tbTitleID, TitleID);
|
||||
string[] trailer = Directory.GetFiles(TempUnpackPath, "*.trailer");
|
||||
if (trailer.Length > 0)
|
||||
{
|
||||
DateTime timestamp = Wii.WadInfo.GetCreationTime(trailer[0]);
|
||||
|
||||
if (timestamp > new DateTime(1970, 1, 1))
|
||||
{
|
||||
SetLabel(lbCreatedValue, timestamp.ToString() + " (UTC)");
|
||||
}
|
||||
else SetLabel(lbCreatedValue, "No Timestamp!");
|
||||
}
|
||||
else SetLabel(lbCreatedValue, "No Timestamp!");
|
||||
|
||||
EventHandler AddBannerTpls = new EventHandler(this.AddBannerTpls);
|
||||
EventHandler AddIconTpls = new EventHandler(this.AddIconTpls);
|
||||
@ -725,7 +737,7 @@ namespace CustomizeMii
|
||||
|
||||
bwCreateWad.ReportProgress(95, "Packing WAD...");
|
||||
if (File.Exists(wadInfo.outFile)) File.Delete(wadInfo.outFile);
|
||||
Wii.WadPack.PackWad(TempUnpackPath, wadInfo.outFile, false);
|
||||
Wii.WadPack.PackWad(TempUnpackPath, wadInfo.outFile);
|
||||
|
||||
bwCreateWad.ReportProgress(100, " ");
|
||||
CreationTimer.Stop();
|
||||
|
118
CustomizeMii/CustomizeMii_BnsConvert.Designer.cs
generated
118
CustomizeMii/CustomizeMii_BnsConvert.Designer.cs
generated
@ -51,6 +51,8 @@ namespace CustomizeMii
|
||||
this.tbAudioFile = new System.Windows.Forms.TextBox();
|
||||
this.btnBrowseAudioFile = new System.Windows.Forms.Button();
|
||||
this.gbLoop = new System.Windows.Forms.GroupBox();
|
||||
this.tbarLoopStartSample = new System.Windows.Forms.TrackBar();
|
||||
this.lbStartSample = new System.Windows.Forms.Label();
|
||||
this.tbLoopStart = new System.Windows.Forms.TextBox();
|
||||
this.rbEnterManually = new System.Windows.Forms.RadioButton();
|
||||
this.rbFromAudioFile = new System.Windows.Forms.RadioButton();
|
||||
@ -71,15 +73,20 @@ namespace CustomizeMii
|
||||
this.lbSamplerate = new System.Windows.Forms.Label();
|
||||
this.lbBitdepth = new System.Windows.Forms.Label();
|
||||
this.cbSourceSound = new System.Windows.Forms.CheckBox();
|
||||
this.gbPrelisten = new System.Windows.Forms.GroupBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.btnPlay = new System.Windows.Forms.Button();
|
||||
this.gbLoop.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbarLoopStartSample)).BeginInit();
|
||||
this.gbWaveInfo.SuspendLayout();
|
||||
this.gbPrelisten.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Location = new System.Drawing.Point(186, 179);
|
||||
this.btnCancel.Location = new System.Drawing.Point(186, 189);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(160, 23);
|
||||
this.btnCancel.TabIndex = 10;
|
||||
@ -90,7 +97,7 @@ namespace CustomizeMii
|
||||
// btnConvert
|
||||
//
|
||||
this.btnConvert.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnConvert.Location = new System.Drawing.Point(15, 179);
|
||||
this.btnConvert.Location = new System.Drawing.Point(15, 189);
|
||||
this.btnConvert.Name = "btnConvert";
|
||||
this.btnConvert.Size = new System.Drawing.Size(160, 23);
|
||||
this.btnConvert.TabIndex = 9;
|
||||
@ -127,41 +134,66 @@ namespace CustomizeMii
|
||||
//
|
||||
// gbLoop
|
||||
//
|
||||
this.gbLoop.Controls.Add(this.tbarLoopStartSample);
|
||||
this.gbLoop.Controls.Add(this.lbStartSample);
|
||||
this.gbLoop.Controls.Add(this.tbLoopStart);
|
||||
this.gbLoop.Controls.Add(this.rbEnterManually);
|
||||
this.gbLoop.Controls.Add(this.rbFromAudioFile);
|
||||
this.gbLoop.Controls.Add(this.rbNone);
|
||||
this.gbLoop.Location = new System.Drawing.Point(15, 72);
|
||||
this.gbLoop.Location = new System.Drawing.Point(15, 70);
|
||||
this.gbLoop.Name = "gbLoop";
|
||||
this.gbLoop.Size = new System.Drawing.Size(331, 94);
|
||||
this.gbLoop.Size = new System.Drawing.Size(331, 113);
|
||||
this.gbLoop.TabIndex = 14;
|
||||
this.gbLoop.TabStop = false;
|
||||
this.gbLoop.Text = "Loop";
|
||||
//
|
||||
// tbarLoopStartSample
|
||||
//
|
||||
this.tbarLoopStartSample.Enabled = false;
|
||||
this.tbarLoopStartSample.Location = new System.Drawing.Point(107, 62);
|
||||
this.tbarLoopStartSample.Maximum = 1059620;
|
||||
this.tbarLoopStartSample.Name = "tbarLoopStartSample";
|
||||
this.tbarLoopStartSample.Size = new System.Drawing.Size(142, 45);
|
||||
this.tbarLoopStartSample.TabIndex = 3;
|
||||
this.tbarLoopStartSample.TickStyle = System.Windows.Forms.TickStyle.None;
|
||||
this.tbarLoopStartSample.Scroll += new System.EventHandler(this.tbarLoopStartSample_Scroll);
|
||||
//
|
||||
// lbStartSample
|
||||
//
|
||||
this.lbStartSample.AutoSize = true;
|
||||
this.lbStartSample.Location = new System.Drawing.Point(35, 74);
|
||||
this.lbStartSample.Name = "lbStartSample";
|
||||
this.lbStartSample.Size = new System.Drawing.Size(66, 13);
|
||||
this.lbStartSample.TabIndex = 2;
|
||||
this.lbStartSample.Text = "(startsample)";
|
||||
//
|
||||
// tbLoopStart
|
||||
//
|
||||
this.tbLoopStart.Enabled = false;
|
||||
this.tbLoopStart.Location = new System.Drawing.Point(227, 64);
|
||||
this.tbLoopStart.Location = new System.Drawing.Point(256, 66);
|
||||
this.tbLoopStart.Name = "tbLoopStart";
|
||||
this.tbLoopStart.Size = new System.Drawing.Size(60, 20);
|
||||
this.tbLoopStart.TabIndex = 1;
|
||||
this.tbLoopStart.Text = "0";
|
||||
this.tbLoopStart.TextChanged += new System.EventHandler(this.tbLoopStart_TextChanged);
|
||||
this.tbLoopStart.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbLoopStart_KeyPress);
|
||||
//
|
||||
// rbEnterManually
|
||||
//
|
||||
this.rbEnterManually.AutoSize = true;
|
||||
this.rbEnterManually.Location = new System.Drawing.Point(6, 65);
|
||||
this.rbEnterManually.Location = new System.Drawing.Point(6, 59);
|
||||
this.rbEnterManually.Name = "rbEnterManually";
|
||||
this.rbEnterManually.Size = new System.Drawing.Size(215, 17);
|
||||
this.rbEnterManually.Size = new System.Drawing.Size(95, 17);
|
||||
this.rbEnterManually.TabIndex = 0;
|
||||
this.rbEnterManually.Text = "Enter Manually Loop Start Sample:";
|
||||
this.rbEnterManually.Text = "Enter Manually";
|
||||
this.rbEnterManually.UseVisualStyleBackColor = true;
|
||||
this.rbEnterManually.CheckedChanged += new System.EventHandler(this.rbSelectionChanged);
|
||||
//
|
||||
// rbFromAudioFile
|
||||
//
|
||||
this.rbFromAudioFile.AutoSize = true;
|
||||
this.rbFromAudioFile.Location = new System.Drawing.Point(6, 42);
|
||||
this.rbFromAudioFile.Enabled = false;
|
||||
this.rbFromAudioFile.Location = new System.Drawing.Point(6, 39);
|
||||
this.rbFromAudioFile.Name = "rbFromAudioFile";
|
||||
this.rbFromAudioFile.Size = new System.Drawing.Size(281, 17);
|
||||
this.rbFromAudioFile.TabIndex = 0;
|
||||
@ -200,49 +232,49 @@ namespace CustomizeMii
|
||||
this.gbWaveInfo.Controls.Add(this.lbBitdepth);
|
||||
this.gbWaveInfo.Location = new System.Drawing.Point(363, 20);
|
||||
this.gbWaveInfo.Name = "gbWaveInfo";
|
||||
this.gbWaveInfo.Size = new System.Drawing.Size(135, 182);
|
||||
this.gbWaveInfo.Size = new System.Drawing.Size(135, 192);
|
||||
this.gbWaveInfo.TabIndex = 15;
|
||||
this.gbWaveInfo.TabStop = false;
|
||||
this.gbWaveInfo.Text = "Wave Info";
|
||||
//
|
||||
// lbStatusValue
|
||||
//
|
||||
this.lbStatusValue.Location = new System.Drawing.Point(75, 151);
|
||||
this.lbStatusValue.Location = new System.Drawing.Point(75, 157);
|
||||
this.lbStatusValue.Name = "lbStatusValue";
|
||||
this.lbStatusValue.Size = new System.Drawing.Size(54, 13);
|
||||
this.lbStatusValue.TabIndex = 7;
|
||||
//
|
||||
// lbLoopStartValue
|
||||
//
|
||||
this.lbLoopStartValue.Location = new System.Drawing.Point(75, 130);
|
||||
this.lbLoopStartValue.Location = new System.Drawing.Point(75, 135);
|
||||
this.lbLoopStartValue.Name = "lbLoopStartValue";
|
||||
this.lbLoopStartValue.Size = new System.Drawing.Size(54, 13);
|
||||
this.lbLoopStartValue.TabIndex = 7;
|
||||
//
|
||||
// lbLoopCountValue
|
||||
//
|
||||
this.lbLoopCountValue.Location = new System.Drawing.Point(75, 109);
|
||||
this.lbLoopCountValue.Location = new System.Drawing.Point(75, 113);
|
||||
this.lbLoopCountValue.Name = "lbLoopCountValue";
|
||||
this.lbLoopCountValue.Size = new System.Drawing.Size(54, 13);
|
||||
this.lbLoopCountValue.TabIndex = 7;
|
||||
//
|
||||
// lbFormatValue
|
||||
//
|
||||
this.lbFormatValue.Location = new System.Drawing.Point(75, 88);
|
||||
this.lbFormatValue.Location = new System.Drawing.Point(75, 91);
|
||||
this.lbFormatValue.Name = "lbFormatValue";
|
||||
this.lbFormatValue.Size = new System.Drawing.Size(54, 13);
|
||||
this.lbFormatValue.TabIndex = 7;
|
||||
//
|
||||
// lbChannelCountValue
|
||||
//
|
||||
this.lbChannelCountValue.Location = new System.Drawing.Point(75, 67);
|
||||
this.lbChannelCountValue.Location = new System.Drawing.Point(75, 69);
|
||||
this.lbChannelCountValue.Name = "lbChannelCountValue";
|
||||
this.lbChannelCountValue.Size = new System.Drawing.Size(54, 13);
|
||||
this.lbChannelCountValue.TabIndex = 7;
|
||||
//
|
||||
// lbSamplerateValue
|
||||
//
|
||||
this.lbSamplerateValue.Location = new System.Drawing.Point(75, 46);
|
||||
this.lbSamplerateValue.Location = new System.Drawing.Point(75, 47);
|
||||
this.lbSamplerateValue.Name = "lbSamplerateValue";
|
||||
this.lbSamplerateValue.Size = new System.Drawing.Size(54, 13);
|
||||
this.lbSamplerateValue.TabIndex = 7;
|
||||
@ -257,7 +289,7 @@ namespace CustomizeMii
|
||||
// lbStatus
|
||||
//
|
||||
this.lbStatus.AutoSize = true;
|
||||
this.lbStatus.Location = new System.Drawing.Point(6, 151);
|
||||
this.lbStatus.Location = new System.Drawing.Point(6, 157);
|
||||
this.lbStatus.Name = "lbStatus";
|
||||
this.lbStatus.Size = new System.Drawing.Size(40, 13);
|
||||
this.lbStatus.TabIndex = 6;
|
||||
@ -266,7 +298,7 @@ namespace CustomizeMii
|
||||
// lbLoopStart
|
||||
//
|
||||
this.lbLoopStart.AutoSize = true;
|
||||
this.lbLoopStart.Location = new System.Drawing.Point(6, 130);
|
||||
this.lbLoopStart.Location = new System.Drawing.Point(6, 135);
|
||||
this.lbLoopStart.Name = "lbLoopStart";
|
||||
this.lbLoopStart.Size = new System.Drawing.Size(59, 13);
|
||||
this.lbLoopStart.TabIndex = 5;
|
||||
@ -275,7 +307,7 @@ namespace CustomizeMii
|
||||
// lbLoopCount
|
||||
//
|
||||
this.lbLoopCount.AutoSize = true;
|
||||
this.lbLoopCount.Location = new System.Drawing.Point(6, 109);
|
||||
this.lbLoopCount.Location = new System.Drawing.Point(6, 113);
|
||||
this.lbLoopCount.Name = "lbLoopCount";
|
||||
this.lbLoopCount.Size = new System.Drawing.Size(39, 13);
|
||||
this.lbLoopCount.TabIndex = 4;
|
||||
@ -284,7 +316,7 @@ namespace CustomizeMii
|
||||
// lbFormat
|
||||
//
|
||||
this.lbFormat.AutoSize = true;
|
||||
this.lbFormat.Location = new System.Drawing.Point(6, 88);
|
||||
this.lbFormat.Location = new System.Drawing.Point(6, 91);
|
||||
this.lbFormat.Name = "lbFormat";
|
||||
this.lbFormat.Size = new System.Drawing.Size(42, 13);
|
||||
this.lbFormat.TabIndex = 3;
|
||||
@ -293,7 +325,7 @@ namespace CustomizeMii
|
||||
// lbChannelCount
|
||||
//
|
||||
this.lbChannelCount.AutoSize = true;
|
||||
this.lbChannelCount.Location = new System.Drawing.Point(6, 67);
|
||||
this.lbChannelCount.Location = new System.Drawing.Point(6, 69);
|
||||
this.lbChannelCount.Name = "lbChannelCount";
|
||||
this.lbChannelCount.Size = new System.Drawing.Size(54, 13);
|
||||
this.lbChannelCount.TabIndex = 2;
|
||||
@ -302,7 +334,7 @@ namespace CustomizeMii
|
||||
// lbSamplerate
|
||||
//
|
||||
this.lbSamplerate.AutoSize = true;
|
||||
this.lbSamplerate.Location = new System.Drawing.Point(6, 46);
|
||||
this.lbSamplerate.Location = new System.Drawing.Point(6, 47);
|
||||
this.lbSamplerate.Name = "lbSamplerate";
|
||||
this.lbSamplerate.Size = new System.Drawing.Size(63, 13);
|
||||
this.lbSamplerate.TabIndex = 1;
|
||||
@ -321,7 +353,7 @@ namespace CustomizeMii
|
||||
//
|
||||
this.cbSourceSound.AutoSize = true;
|
||||
this.cbSourceSound.Enabled = false;
|
||||
this.cbSourceSound.Location = new System.Drawing.Point(15, 50);
|
||||
this.cbSourceSound.Location = new System.Drawing.Point(15, 48);
|
||||
this.cbSourceSound.Name = "cbSourceSound";
|
||||
this.cbSourceSound.Size = new System.Drawing.Size(170, 17);
|
||||
this.cbSourceSound.TabIndex = 16;
|
||||
@ -329,13 +361,44 @@ namespace CustomizeMii
|
||||
this.cbSourceSound.UseVisualStyleBackColor = true;
|
||||
this.cbSourceSound.CheckedChanged += new System.EventHandler(this.cbSourceSound_CheckedChanged);
|
||||
//
|
||||
// gbPrelisten
|
||||
//
|
||||
this.gbPrelisten.Controls.Add(this.label1);
|
||||
this.gbPrelisten.Controls.Add(this.btnPlay);
|
||||
this.gbPrelisten.Location = new System.Drawing.Point(519, 20);
|
||||
this.gbPrelisten.Name = "gbPrelisten";
|
||||
this.gbPrelisten.Size = new System.Drawing.Size(135, 192);
|
||||
this.gbPrelisten.TabIndex = 17;
|
||||
this.gbPrelisten.TabStop = false;
|
||||
this.gbPrelisten.Text = "Prelisten Loop";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Location = new System.Drawing.Point(6, 25);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(123, 118);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Note:\r\n\r\nYou will only hear the looped part, not the part before.\r\nAlso, the Loop" +
|
||||
" might be inaccurate (only a few samples)";
|
||||
//
|
||||
// btnPlay
|
||||
//
|
||||
this.btnPlay.Location = new System.Drawing.Point(6, 156);
|
||||
this.btnPlay.Name = "btnPlay";
|
||||
this.btnPlay.Size = new System.Drawing.Size(123, 23);
|
||||
this.btnPlay.TabIndex = 13;
|
||||
this.btnPlay.Text = "Play Loop";
|
||||
this.btnPlay.UseVisualStyleBackColor = true;
|
||||
this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click);
|
||||
//
|
||||
// CustomizeMii_BnsConvert
|
||||
//
|
||||
this.AcceptButton = this.btnConvert;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.btnCancel;
|
||||
this.ClientSize = new System.Drawing.Size(510, 220);
|
||||
this.ClientSize = new System.Drawing.Size(674, 230);
|
||||
this.Controls.Add(this.gbPrelisten);
|
||||
this.Controls.Add(this.cbSourceSound);
|
||||
this.Controls.Add(this.gbWaveInfo);
|
||||
this.Controls.Add(this.gbLoop);
|
||||
@ -351,8 +414,10 @@ namespace CustomizeMii
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CustomizeMii_BnsConvert_FormClosing);
|
||||
this.gbLoop.ResumeLayout(false);
|
||||
this.gbLoop.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbarLoopStartSample)).EndInit();
|
||||
this.gbWaveInfo.ResumeLayout(false);
|
||||
this.gbWaveInfo.PerformLayout();
|
||||
this.gbPrelisten.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -386,6 +451,11 @@ namespace CustomizeMii
|
||||
private System.Windows.Forms.Label lbSamplerateValue;
|
||||
private System.Windows.Forms.Label lbBitdepthValue;
|
||||
private System.Windows.Forms.CheckBox cbSourceSound;
|
||||
private System.Windows.Forms.GroupBox gbPrelisten;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button btnPlay;
|
||||
private System.Windows.Forms.Label lbStartSample;
|
||||
private System.Windows.Forms.TrackBar tbarLoopStartSample;
|
||||
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
using WaveFile;
|
||||
using System.Media;
|
||||
|
||||
namespace CustomizeMii
|
||||
{
|
||||
@ -36,6 +37,9 @@ namespace CustomizeMii
|
||||
private int loopStart;
|
||||
private bool error = false;
|
||||
private bool cancelled = false;
|
||||
private int sampleCount;
|
||||
private SoundPlayer sPlayer;
|
||||
private bool mp3LengthKnown = false;
|
||||
|
||||
public string AudioFile { get { return tbAudioFile.Text; } }
|
||||
public bool LoopNone { get { return rbNone.Checked; } }
|
||||
@ -53,7 +57,7 @@ namespace CustomizeMii
|
||||
private void CustomizeMii_BnsConvert_Load(object sender, EventArgs e)
|
||||
{
|
||||
//this.Size = new System.Drawing.Size(358, 220);
|
||||
this.Size = new System.Drawing.Size(btnCancel.Location.X + btnCancel.Size.Width + 15, 220);
|
||||
this.Size = new System.Drawing.Size(btnCancel.Location.X + btnCancel.Size.Width + 15, this.Size.Height);
|
||||
|
||||
this.CenterToParent();
|
||||
bwGatherInfo = new BackgroundWorker();
|
||||
@ -81,6 +85,19 @@ namespace CustomizeMii
|
||||
private void rbSelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
tbLoopStart.Enabled = rbEnterManually.Checked;
|
||||
if (tbAudioFile.Text.ToLower().EndsWith(".mp3")) { tbarLoopStartSample.Enabled = (rbEnterManually.Checked && mp3LengthKnown); }
|
||||
else { tbarLoopStartSample.Enabled = rbEnterManually.Checked; }
|
||||
|
||||
if (!rbNone.Checked && this.Size.Width > 400)
|
||||
this.Size = new System.Drawing.Size(gbPrelisten.Location.X + gbPrelisten.Size.Width + 15, this.Size.Height);
|
||||
else if (rbNone.Checked && this.Size.Width > 400)
|
||||
this.Size = new System.Drawing.Size(gbWaveInfo.Location.X + gbWaveInfo.Size.Width + 15, this.Size.Height);
|
||||
|
||||
}
|
||||
|
||||
private void tbLoopStart_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
e.Handled = !char.IsDigit(e.KeyChar) && e.KeyChar != '\b';
|
||||
}
|
||||
|
||||
private void btnConvert_Click(object sender, EventArgs e)
|
||||
@ -98,12 +115,14 @@ namespace CustomizeMii
|
||||
tbLoopStart.SelectAll();
|
||||
}
|
||||
|
||||
if (this.sPlayer != null) { this.sPlayer.Stop(); this.sPlayer.Dispose(); }
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.sPlayer != null) { this.sPlayer.Stop(); this.sPlayer.Dispose(); }
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
@ -135,7 +154,7 @@ namespace CustomizeMii
|
||||
bwGatherInfo.RunWorkerAsync(audio);
|
||||
|
||||
//this.Size = new System.Drawing.Size(510, 220);
|
||||
this.Size = new System.Drawing.Size(gbWaveInfo.Location.X + gbWaveInfo.Size.Width + 15, 220);
|
||||
this.Size = new System.Drawing.Size(gbWaveInfo.Location.X + gbWaveInfo.Size.Width + 15, this.Size.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -143,7 +162,7 @@ namespace CustomizeMii
|
||||
tbAudioFile.Text = string.Empty;
|
||||
|
||||
//this.Size = new System.Drawing.Size(358, 220);
|
||||
this.Size = new System.Drawing.Size(btnCancel.Location.X + btnCancel.Size.Width + 15, 220);
|
||||
this.Size = new System.Drawing.Size(btnCancel.Location.X + btnCancel.Size.Width + 15, this.Size.Height);
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,6 +179,8 @@ namespace CustomizeMii
|
||||
if (ofd.FileName != tbAudioFile.Text)
|
||||
{
|
||||
btnConvert.Enabled = false;
|
||||
tbarLoopStartSample.Enabled = false;
|
||||
mp3LengthKnown = false;
|
||||
|
||||
cbSourceSound.Checked = false;
|
||||
tbAudioFile.Text = ofd.FileName;
|
||||
@ -177,8 +198,7 @@ namespace CustomizeMii
|
||||
|
||||
bwGatherInfo.RunWorkerAsync(ofd.FileName);
|
||||
|
||||
//this.Size = new System.Drawing.Size(510, 220);
|
||||
this.Size = new System.Drawing.Size(gbWaveInfo.Location.X + gbWaveInfo.Size.Width + 15, 220);
|
||||
this.Size = new System.Drawing.Size(gbWaveInfo.Location.X + gbWaveInfo.Size.Width + 15, this.Size.Height);
|
||||
}
|
||||
else if (ofd.FileName.EndsWith(".mp3"))
|
||||
{
|
||||
@ -188,8 +208,16 @@ namespace CustomizeMii
|
||||
if (rbFromAudioFile.Checked) rbNone.Checked = true;
|
||||
rbFromAudioFile.Enabled = false;
|
||||
|
||||
//this.Size = new System.Drawing.Size(358, 220);
|
||||
this.Size = new System.Drawing.Size(btnCancel.Location.X + btnCancel.Size.Width + 15, 220);
|
||||
this.Size = new System.Drawing.Size(btnCancel.Location.X + btnCancel.Size.Width + 15, this.Size.Height);
|
||||
|
||||
try
|
||||
{
|
||||
MP3Info mp3Info = new MP3Info(ofd.FileName);
|
||||
tbarLoopStartSample.Maximum = mp3Info.AudioSamples;
|
||||
mp3LengthKnown = true;
|
||||
if (rbEnterManually.Checked) tbarLoopStartSample.Enabled = true;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -207,6 +235,9 @@ namespace CustomizeMii
|
||||
else
|
||||
{ wave = new Wave((string)e.Argument); }
|
||||
|
||||
try { this.sampleCount = wave.SampleCount; }
|
||||
catch { }
|
||||
|
||||
try { bitDepth = wave.BitDepth; }
|
||||
catch { bitDepth = -1; }
|
||||
|
||||
@ -262,6 +293,8 @@ namespace CustomizeMii
|
||||
}
|
||||
|
||||
bool statusOk = true;
|
||||
tbarLoopStartSample.Maximum = this.sampleCount;
|
||||
if (rbEnterManually.Checked) tbarLoopStartSample.Enabled = true;
|
||||
|
||||
if (bitDepth == -1) lbBitdepthValue.Text = "Error";
|
||||
else lbBitdepthValue.Text = bitDepth.ToString();
|
||||
@ -352,5 +385,63 @@ namespace CustomizeMii
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnPlay_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (btnPlay.Text == "Stop")
|
||||
{
|
||||
if (sPlayer != null)
|
||||
{
|
||||
sPlayer.Stop();
|
||||
sPlayer = null;
|
||||
|
||||
btnPlay.Text = "Play Loop";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
int loopStart = rbFromAudioFile.Checked ? int.Parse(lbLoopStartValue.Text) : int.Parse(tbLoopStart.Text);
|
||||
|
||||
Wave wave;
|
||||
if (cbSourceSound.Checked)
|
||||
{
|
||||
using (FileStream fs = new FileStream(CustomizeMii_Main.TempUnpackPath + "00000000.app_OUT\\meta\\sound.bin", FileMode.Open))
|
||||
{
|
||||
byte[] audio = new byte[fs.Length - 32];
|
||||
fs.Seek(32, SeekOrigin.Begin);
|
||||
fs.Read(audio, 0, audio.Length);
|
||||
|
||||
wave = new Wave(audio);
|
||||
}
|
||||
}
|
||||
else wave = new Wave(tbAudioFile.Text);
|
||||
|
||||
sPlayer = new SoundPlayer(wave.TrimStart(loopStart));
|
||||
sPlayer.PlayLooping();
|
||||
|
||||
btnPlay.Text = "Stop";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sPlayer = null;
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tbarLoopStartSample_Scroll(object sender, EventArgs e)
|
||||
{
|
||||
try { tbLoopStart.Text = tbarLoopStartSample.Value.ToString(); }
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void tbLoopStart_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (tbarLoopStartSample.Enabled)
|
||||
try { tbarLoopStartSample.Value = int.Parse(tbLoopStart.Text); }
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
252
CustomizeMii/CustomizeMii_DragDrop.cs
Normal file
252
CustomizeMii/CustomizeMii_DragDrop.cs
Normal file
@ -0,0 +1,252 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CustomizeMii
|
||||
{
|
||||
partial class CustomizeMii_Main
|
||||
{
|
||||
private void CustomizeMii_Main_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop) && pbProgress.Value == 100)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
||||
if (data.Length == 1 && data[0].ToLower().EndsWith(".wad"))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
}
|
||||
|
||||
private void CustomizeMii_Main_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
||||
if (data.Length == 1 && data[0].ToLower().EndsWith(".wad"))
|
||||
{
|
||||
LoadChannel(data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private void tbReplace_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tbSourceWad.Text))
|
||||
{
|
||||
if (pbProgress.Value == 100 && e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
||||
if (data.Length == 1)
|
||||
{
|
||||
if (data[0].ToLower().EndsWith(".wad") ||
|
||||
data[0].ToLower().EndsWith("00000000.app"))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
else if ((cmbReplace.SelectedIndex == 2 && data[0].ToLower().EndsWith("sound.bin")) ||
|
||||
(cmbReplace.SelectedIndex == 1 && data[0].ToLower().EndsWith("icon.bin")) ||
|
||||
(cmbReplace.SelectedIndex == 0 && data[0].ToLower().EndsWith("banner.bin")))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tbReplace_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
||||
if (data.Length == 1 && (data[0].ToLower().EndsWith(".wad") ||
|
||||
data[0].ToLower().EndsWith("00000000.app") ||
|
||||
data[0].ToLower().EndsWith("sound.bin") ||
|
||||
data[0].ToLower().EndsWith("icon.bin") ||
|
||||
data[0].ToLower().EndsWith("banner.bin")))
|
||||
{
|
||||
ReplacePart(data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private void tbDol_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop) && pbProgress.Value == 100)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
||||
if (data.Length == 1 && (data[0].ToLower().EndsWith(".wad") || data[0].ToLower().EndsWith(".dol")))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
}
|
||||
|
||||
private void tbDol_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
||||
if (data[0].ToLower().EndsWith(".wad"))
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] wad = Wii.Tools.LoadFileToByteArray(data[0]);
|
||||
|
||||
int numContents = Wii.WadInfo.GetContentNum(wad);
|
||||
|
||||
if (numContents == 3)
|
||||
{
|
||||
int bootIndex = Wii.WadInfo.GetBootIndex(wad);
|
||||
string appFile = string.Empty;
|
||||
|
||||
if (bootIndex == 1)
|
||||
{ appFile = "00000002.app"; }
|
||||
else if (bootIndex == 2)
|
||||
{ appFile = "00000001.app"; }
|
||||
|
||||
if (!string.IsNullOrEmpty(appFile))
|
||||
{
|
||||
if (Directory.Exists(TempTempPath + "TempWad")) Directory.Delete(TempTempPath + "TempWad", true);
|
||||
Wii.WadUnpack.UnpackWad(data[0], TempTempPath + "TempWad");
|
||||
|
||||
File.Copy(TempTempPath + "TempWad\\" + appFile, TempDolPath, true);
|
||||
SetText(tbDol, data[0]);
|
||||
btnBrowseDol.Text = "Clear";
|
||||
}
|
||||
else
|
||||
ErrorBox("The DOL file couldn't be found!");
|
||||
}
|
||||
else
|
||||
ErrorBox("The DOL file couldn't be found!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SetText(tbDol, string.Empty);
|
||||
ErrorBox(ex.Message);
|
||||
}
|
||||
}
|
||||
else if (data[0].ToLower().EndsWith(".dol"))
|
||||
{
|
||||
SetText(tbDol, data[0]);
|
||||
btnBrowseDol.Text = "Clear";
|
||||
}
|
||||
}
|
||||
|
||||
private void tbSound_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop) && pbProgress.Value == 100)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
||||
if (File.Exists(Application.StartupPath + "\\lame.exe"))
|
||||
{
|
||||
if (data.Length == 1 && (data[0].ToLower().EndsWith(".wav") ||
|
||||
data[0].ToLower().EndsWith(".bns") ||
|
||||
data[0].ToLower().EndsWith(".mp3")))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.Length == 1 && (data[0].ToLower().EndsWith(".wav") ||
|
||||
data[0].ToLower().EndsWith(".bns")))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tbSound_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
||||
if (data[0].ToLower().EndsWith(".mp3"))
|
||||
{
|
||||
ConvertMp3ToWave(data[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetText(tbSound, data[0]);
|
||||
|
||||
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_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop) && pbProgress.Value == 100)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
bool correct = true;
|
||||
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
if (!(data[0].ToLower().EndsWith(".tpl") ||
|
||||
data[0].ToLower().EndsWith(".png") ||
|
||||
data[0].ToLower().EndsWith(".jpg") ||
|
||||
data[0].ToLower().EndsWith(".gif") ||
|
||||
data[0].ToLower().EndsWith(".bmp")))
|
||||
correct = false;
|
||||
|
||||
if (correct) e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
}
|
||||
|
||||
private void lbxBannerTpls_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
List<string> errors = new List<string>();
|
||||
|
||||
foreach (string thisFile in data)
|
||||
{
|
||||
try
|
||||
{
|
||||
AddTpl(lbxBannerTpls, thisFile);
|
||||
}
|
||||
catch { errors.Add(thisFile); }
|
||||
}
|
||||
|
||||
if (errors.Count > 0)
|
||||
{
|
||||
ErrorBox(string.Format("These files were not added, because either they already exist or an error occured during conversion:\n\n{0}", string.Join("\n", (errors.ToArray()))));
|
||||
}
|
||||
}
|
||||
|
||||
private void lbxIconTpls_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop) && pbProgress.Value == 100)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
bool correct = true;
|
||||
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
if (!(data[0].ToLower().EndsWith(".tpl") ||
|
||||
data[0].ToLower().EndsWith(".png") ||
|
||||
data[0].ToLower().EndsWith(".jpg") ||
|
||||
data[0].ToLower().EndsWith(".gif") ||
|
||||
data[0].ToLower().EndsWith(".bmp")))
|
||||
correct = false;
|
||||
|
||||
if (correct) e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
}
|
||||
|
||||
private void lbxIconTpls_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
List<string> errors = new List<string>();
|
||||
|
||||
foreach (string thisFile in data)
|
||||
{
|
||||
try
|
||||
{
|
||||
AddTpl(lbxIconTpls, thisFile);
|
||||
}
|
||||
catch { errors.Add(thisFile); }
|
||||
}
|
||||
|
||||
if (errors.Count > 0)
|
||||
{
|
||||
ErrorBox(string.Format("These files were not added, because either they already exist or an error occured during conversion:\n\n{0}", string.Join("\n", (errors.ToArray()))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ namespace CustomizeMii
|
||||
|
||||
private void CustomizeMii_InputBox_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.CenterToScreen();
|
||||
this.CenterToParent();
|
||||
}
|
||||
|
||||
private void btnExit_Click(object sender, EventArgs e)
|
||||
|
63
CustomizeMii/CustomizeMii_Main.Designer.cs
generated
63
CustomizeMii/CustomizeMii_Main.Designer.cs
generated
@ -50,6 +50,8 @@ namespace CustomizeMii
|
||||
this.btnCreateWad = new System.Windows.Forms.Button();
|
||||
this.tabControl = new System.Windows.Forms.TabControl();
|
||||
this.tabSource = new System.Windows.Forms.TabPage();
|
||||
this.lbCreatedValue = new System.Windows.Forms.Label();
|
||||
this.lbCreated = new System.Windows.Forms.Label();
|
||||
this.tbReplace = new System.Windows.Forms.TextBox();
|
||||
this.btnBrowseReplace = new System.Windows.Forms.Button();
|
||||
this.cmbReplace = new System.Windows.Forms.ComboBox();
|
||||
@ -218,6 +220,8 @@ namespace CustomizeMii
|
||||
//
|
||||
// tabSource
|
||||
//
|
||||
this.tabSource.Controls.Add(this.lbCreatedValue);
|
||||
this.tabSource.Controls.Add(this.lbCreated);
|
||||
this.tabSource.Controls.Add(this.tbReplace);
|
||||
this.tabSource.Controls.Add(this.btnBrowseReplace);
|
||||
this.tabSource.Controls.Add(this.cmbReplace);
|
||||
@ -236,19 +240,39 @@ namespace CustomizeMii
|
||||
this.tabSource.Text = "Source";
|
||||
this.tabSource.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lbCreatedValue
|
||||
//
|
||||
this.lbCreatedValue.AutoSize = true;
|
||||
this.lbCreatedValue.Location = new System.Drawing.Point(125, 45);
|
||||
this.lbCreatedValue.Name = "lbCreatedValue";
|
||||
this.lbCreatedValue.Size = new System.Drawing.Size(0, 13);
|
||||
this.lbCreatedValue.TabIndex = 12;
|
||||
//
|
||||
// lbCreated
|
||||
//
|
||||
this.lbCreated.AutoSize = true;
|
||||
this.lbCreated.Location = new System.Drawing.Point(8, 45);
|
||||
this.lbCreated.Name = "lbCreated";
|
||||
this.lbCreated.Size = new System.Drawing.Size(111, 13);
|
||||
this.lbCreated.TabIndex = 11;
|
||||
this.lbCreated.Text = "Created / Last Edited:";
|
||||
//
|
||||
// tbReplace
|
||||
//
|
||||
this.tbReplace.Location = new System.Drawing.Point(100, 173);
|
||||
this.tbReplace.AllowDrop = true;
|
||||
this.tbReplace.Location = new System.Drawing.Point(100, 177);
|
||||
this.tbReplace.Name = "tbReplace";
|
||||
this.tbReplace.ReadOnly = true;
|
||||
this.tbReplace.Size = new System.Drawing.Size(254, 20);
|
||||
this.tbReplace.TabIndex = 10;
|
||||
this.tbReplace.Tag = "Disabled";
|
||||
this.tbReplace.TextChanged += new System.EventHandler(this.tbReplace_TextChanged);
|
||||
this.tbReplace.DragDrop += new System.Windows.Forms.DragEventHandler(this.tbReplace_DragDrop);
|
||||
this.tbReplace.DragEnter += new System.Windows.Forms.DragEventHandler(this.tbReplace_DragEnter);
|
||||
//
|
||||
// btnBrowseReplace
|
||||
//
|
||||
this.btnBrowseReplace.Location = new System.Drawing.Point(360, 171);
|
||||
this.btnBrowseReplace.Location = new System.Drawing.Point(360, 175);
|
||||
this.btnBrowseReplace.Name = "btnBrowseReplace";
|
||||
this.btnBrowseReplace.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnBrowseReplace.TabIndex = 9;
|
||||
@ -264,7 +288,7 @@ namespace CustomizeMii
|
||||
"Banner",
|
||||
"Icon",
|
||||
"Sound"});
|
||||
this.cmbReplace.Location = new System.Drawing.Point(11, 172);
|
||||
this.cmbReplace.Location = new System.Drawing.Point(11, 176);
|
||||
this.cmbReplace.Name = "cmbReplace";
|
||||
this.cmbReplace.Size = new System.Drawing.Size(83, 21);
|
||||
this.cmbReplace.TabIndex = 7;
|
||||
@ -272,7 +296,7 @@ namespace CustomizeMii
|
||||
//
|
||||
// btnSaveBaseWad
|
||||
//
|
||||
this.btnSaveBaseWad.Location = new System.Drawing.Point(360, 127);
|
||||
this.btnSaveBaseWad.Location = new System.Drawing.Point(360, 142);
|
||||
this.btnSaveBaseWad.Name = "btnSaveBaseWad";
|
||||
this.btnSaveBaseWad.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnSaveBaseWad.TabIndex = 6;
|
||||
@ -282,7 +306,7 @@ namespace CustomizeMii
|
||||
//
|
||||
// btnPreviewBaseWad
|
||||
//
|
||||
this.btnPreviewBaseWad.Location = new System.Drawing.Point(360, 93);
|
||||
this.btnPreviewBaseWad.Location = new System.Drawing.Point(360, 106);
|
||||
this.btnPreviewBaseWad.Name = "btnPreviewBaseWad";
|
||||
this.btnPreviewBaseWad.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnPreviewBaseWad.TabIndex = 5;
|
||||
@ -292,7 +316,7 @@ namespace CustomizeMii
|
||||
//
|
||||
// btnLoadBaseWad
|
||||
//
|
||||
this.btnLoadBaseWad.Location = new System.Drawing.Point(360, 59);
|
||||
this.btnLoadBaseWad.Location = new System.Drawing.Point(360, 70);
|
||||
this.btnLoadBaseWad.Name = "btnLoadBaseWad";
|
||||
this.btnLoadBaseWad.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnLoadBaseWad.TabIndex = 4;
|
||||
@ -318,14 +342,14 @@ namespace CustomizeMii
|
||||
"WADder Base 3",
|
||||
"UniiLoader",
|
||||
"Backup Channel"});
|
||||
this.lbxBaseWads.Location = new System.Drawing.Point(11, 51);
|
||||
this.lbxBaseWads.Location = new System.Drawing.Point(11, 70);
|
||||
this.lbxBaseWads.Name = "lbxBaseWads";
|
||||
this.lbxBaseWads.Size = new System.Drawing.Size(343, 108);
|
||||
this.lbxBaseWads.Size = new System.Drawing.Size(343, 95);
|
||||
this.lbxBaseWads.TabIndex = 3;
|
||||
//
|
||||
// btnBrowseSource
|
||||
//
|
||||
this.btnBrowseSource.Location = new System.Drawing.Point(360, 13);
|
||||
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;
|
||||
@ -335,7 +359,7 @@ namespace CustomizeMii
|
||||
//
|
||||
// tbSourceWad
|
||||
//
|
||||
this.tbSourceWad.Location = new System.Drawing.Point(84, 15);
|
||||
this.tbSourceWad.Location = new System.Drawing.Point(84, 14);
|
||||
this.tbSourceWad.Name = "tbSourceWad";
|
||||
this.tbSourceWad.ReadOnly = true;
|
||||
this.tbSourceWad.Size = new System.Drawing.Size(270, 20);
|
||||
@ -345,7 +369,7 @@ namespace CustomizeMii
|
||||
// lbSource
|
||||
//
|
||||
this.lbSource.AutoSize = true;
|
||||
this.lbSource.Location = new System.Drawing.Point(8, 18);
|
||||
this.lbSource.Location = new System.Drawing.Point(8, 17);
|
||||
this.lbSource.Name = "lbSource";
|
||||
this.lbSource.Size = new System.Drawing.Size(70, 13);
|
||||
this.lbSource.TabIndex = 0;
|
||||
@ -613,12 +637,15 @@ namespace CustomizeMii
|
||||
//
|
||||
// tbSound
|
||||
//
|
||||
this.tbSound.AllowDrop = true;
|
||||
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";
|
||||
this.tbSound.DragDrop += new System.Windows.Forms.DragEventHandler(this.tbSound_DragDrop);
|
||||
this.tbSound.DragEnter += new System.Windows.Forms.DragEventHandler(this.tbSound_DragEnter);
|
||||
//
|
||||
// cmbNandLoader
|
||||
//
|
||||
@ -644,12 +671,15 @@ namespace CustomizeMii
|
||||
//
|
||||
// tbDol
|
||||
//
|
||||
this.tbDol.AllowDrop = true;
|
||||
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";
|
||||
this.tbDol.DragDrop += new System.Windows.Forms.DragEventHandler(this.tbDol_DragDrop);
|
||||
this.tbDol.DragEnter += new System.Windows.Forms.DragEventHandler(this.tbDol_DragEnter);
|
||||
//
|
||||
// tbTitleID
|
||||
//
|
||||
@ -805,6 +835,7 @@ namespace CustomizeMii
|
||||
//
|
||||
// lbxBannerTpls
|
||||
//
|
||||
this.lbxBannerTpls.AllowDrop = true;
|
||||
this.lbxBannerTpls.FormattingEnabled = true;
|
||||
this.lbxBannerTpls.Location = new System.Drawing.Point(11, 12);
|
||||
this.lbxBannerTpls.Name = "lbxBannerTpls";
|
||||
@ -812,6 +843,8 @@ namespace CustomizeMii
|
||||
this.lbxBannerTpls.Sorted = true;
|
||||
this.lbxBannerTpls.TabIndex = 0;
|
||||
this.lbxBannerTpls.SelectedIndexChanged += new System.EventHandler(this.lbxBannerTpls_SelectedIndexChanged);
|
||||
this.lbxBannerTpls.DragDrop += new System.Windows.Forms.DragEventHandler(this.lbxBannerTpls_DragDrop);
|
||||
this.lbxBannerTpls.DragEnter += new System.Windows.Forms.DragEventHandler(this.lbxBannerTpls_DragEnter);
|
||||
//
|
||||
// tabIcon
|
||||
//
|
||||
@ -922,6 +955,7 @@ namespace CustomizeMii
|
||||
//
|
||||
// lbxIconTpls
|
||||
//
|
||||
this.lbxIconTpls.AllowDrop = true;
|
||||
this.lbxIconTpls.FormattingEnabled = true;
|
||||
this.lbxIconTpls.Location = new System.Drawing.Point(11, 12);
|
||||
this.lbxIconTpls.Name = "lbxIconTpls";
|
||||
@ -929,6 +963,8 @@ namespace CustomizeMii
|
||||
this.lbxIconTpls.Sorted = true;
|
||||
this.lbxIconTpls.TabIndex = 6;
|
||||
this.lbxIconTpls.SelectedIndexChanged += new System.EventHandler(this.lbxIconTpls_SelectedIndexChanged);
|
||||
this.lbxIconTpls.DragDrop += new System.Windows.Forms.DragEventHandler(this.lbxIconTpls_DragDrop);
|
||||
this.lbxIconTpls.DragEnter += new System.Windows.Forms.DragEventHandler(this.lbxIconTpls_DragEnter);
|
||||
//
|
||||
// tabBrlyt
|
||||
//
|
||||
@ -1442,6 +1478,7 @@ namespace CustomizeMii
|
||||
//
|
||||
// CustomizeMii_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(451, 290);
|
||||
@ -1454,6 +1491,8 @@ namespace CustomizeMii
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "CustomizeMii X by Leathl";
|
||||
this.Load += new System.EventHandler(this.CustomizeMii_Main_Load);
|
||||
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.CustomizeMii_Main_DragDrop);
|
||||
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.CustomizeMii_Main_DragEnter);
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CustomizeMii_Main_FormClosing);
|
||||
this.tabControl.ResumeLayout(false);
|
||||
this.tabSource.ResumeLayout(false);
|
||||
@ -1607,6 +1646,8 @@ namespace CustomizeMii
|
||||
private System.Windows.Forms.ToolStripMenuItem cmDolFromSource;
|
||||
private System.Windows.Forms.Panel panCredits;
|
||||
private System.Windows.Forms.Label lbForwardMiiVersion;
|
||||
private System.Windows.Forms.Label lbCreated;
|
||||
private System.Windows.Forms.Label lbCreatedValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//#define Mono //Change all "\\" to "/" (in all files, without quotes) while compiling for OS X / Linux (Mono)
|
||||
//#define Mono //Change all "\\" to "/" (in all files; without quotes) while compiling for OS X / Linux (Mono)
|
||||
//#define Debug //Always remember to turn off :)
|
||||
|
||||
using System;
|
||||
@ -45,6 +45,7 @@ namespace CustomizeMii
|
||||
#endregion
|
||||
|
||||
#region Variables
|
||||
public bool Mono = false;
|
||||
public static string TempPath = Path.GetTempPath() + "CustomizeMii_Temp\\XXX\\";
|
||||
public static string TempWadPath = Path.GetTempPath() + "CustomizeMii_Temp\\XXX\\TempWad.wad";
|
||||
public static string TempUnpackPath = Path.GetTempPath() + "CustomizeMii_Temp\\XXX\\Unpack\\";
|
||||
@ -87,6 +88,7 @@ namespace CustomizeMii
|
||||
private Forwarder.Complex ComplexForwarder = new Forwarder.Complex();
|
||||
private delegate void BoxInvoker(string message);
|
||||
private delegate void SetTextInvoker(string text, TextBox tb);
|
||||
private delegate void SetLabelInvoker(string text, Label lb);
|
||||
private double separatorBtn;
|
||||
private Timer tmrCredits = new Timer();
|
||||
private ToolTip tTip = new ToolTip();
|
||||
@ -100,17 +102,21 @@ namespace CustomizeMii
|
||||
|
||||
private void CustomizeMii_Main_Load(object sender, EventArgs e)
|
||||
{
|
||||
MethodInvoker Update = new MethodInvoker(UpdateCheck);
|
||||
|
||||
UpdatePaths();
|
||||
UpdateCheck();
|
||||
Update.BeginInvoke(null, null);
|
||||
|
||||
#if !Mono
|
||||
UpdateCheckForwardMii();
|
||||
MethodInvoker FUpdate = new MethodInvoker(UpdateCheckForwardMii);
|
||||
FUpdate.BeginInvoke(null, null);
|
||||
CommonKeyCheck();
|
||||
#endif
|
||||
|
||||
InitializeStartup();
|
||||
|
||||
#if Mono
|
||||
Mono = true;
|
||||
//TextBox.MaxLength is not implemented in Mono, so don't use it
|
||||
for (int i = 0; i < tabControl.TabPages.Count; i++)
|
||||
for(int j=0;j<tabControl.TabPages[i].Controls.Count;j++)
|
||||
@ -172,16 +178,19 @@ namespace CustomizeMii
|
||||
tmrCredits.Interval = CreditsScrollSpeed;
|
||||
tmrCredits.Tick += new EventHandler(tmrCredits_Tick);
|
||||
|
||||
#if !Mono
|
||||
if (File.Exists(Application.StartupPath + "\\ForwardMii.dll") && lbForwardMiiVersion.Tag != (object)"Update")
|
||||
{
|
||||
SetForwardMiiLabel();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !Debug
|
||||
DisableControls(null, null);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !Mono
|
||||
private void SetForwardMiiLabel()
|
||||
{
|
||||
try
|
||||
@ -191,6 +200,7 @@ namespace CustomizeMii
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
#endif
|
||||
|
||||
private void CommonKeyCheck()
|
||||
{
|
||||
@ -621,6 +631,17 @@ namespace CustomizeMii
|
||||
tb.Text = text;
|
||||
}
|
||||
|
||||
private void SetLabel(Label lb, string text)
|
||||
{
|
||||
SetLabelInvoker invoker = new SetLabelInvoker(this.SetLabel);
|
||||
this.Invoke(invoker, text, lb);
|
||||
}
|
||||
|
||||
private void SetLabel(string text, Label lb)
|
||||
{
|
||||
lb.Text = text;
|
||||
}
|
||||
|
||||
private string GetCurBannerPath()
|
||||
{
|
||||
if (string.IsNullOrEmpty(BannerReplace))
|
||||
@ -984,26 +1005,7 @@ namespace CustomizeMii
|
||||
|
||||
private void btnBrowseSource_Click(object sender, EventArgs e)
|
||||
{
|
||||
#if Mono
|
||||
CommonKeyCheck();
|
||||
#endif
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
LoadChannel();
|
||||
}
|
||||
|
||||
private void btnLoadBaseWad_Click(object sender, EventArgs e)
|
||||
@ -1221,102 +1223,7 @@ namespace CustomizeMii
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tbSourceWad.Text))
|
||||
{
|
||||
if (pbProgress.Value == 100)
|
||||
{
|
||||
if (cmbReplace.SelectedIndex == 2) //sound
|
||||
{
|
||||
try
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|sound.bin|sound.bin|All|*.wad;00000000.app;sound.bin";
|
||||
ofd.FilterIndex = 4;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (ofd.FileName != tbSourceWad.Text)
|
||||
{
|
||||
SoundReplace = ofd.FileName;
|
||||
SetText(tbReplace, SoundReplace);
|
||||
BackgroundWorker bwSoundReplace = new BackgroundWorker();
|
||||
bwSoundReplace.DoWork += new DoWorkEventHandler(bwSoundReplace_DoWork);
|
||||
bwSoundReplace.ProgressChanged += new ProgressChangedEventHandler(bwSoundReplace_ProgressChanged);
|
||||
bwSoundReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwSoundReplace_RunWorkerCompleted);
|
||||
bwSoundReplace.WorkerReportsProgress = true;
|
||||
bwSoundReplace.RunWorkerAsync(ofd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SoundReplace = string.Empty;
|
||||
SetText(tbReplace, SoundReplace);
|
||||
ErrorBox(ex.Message);
|
||||
}
|
||||
}
|
||||
else if (cmbReplace.SelectedIndex == 1) //icon
|
||||
{
|
||||
try
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|icon.bin|icon.bin|All|*.wad;00000000.app;icon.bin";
|
||||
ofd.FilterIndex = 4;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (ofd.FileName != tbSourceWad.Text)
|
||||
{
|
||||
IconReplace = ofd.FileName;
|
||||
SetText(tbReplace, IconReplace);
|
||||
BackgroundWorker bwIconReplace = new BackgroundWorker();
|
||||
bwIconReplace.DoWork += new DoWorkEventHandler(bwIconReplace_DoWork);
|
||||
bwIconReplace.ProgressChanged += new ProgressChangedEventHandler(bwIconReplace_ProgressChanged);
|
||||
bwIconReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwIconReplace_RunWorkerCompleted);
|
||||
bwIconReplace.WorkerReportsProgress = true;
|
||||
bwIconReplace.RunWorkerAsync(ofd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
IconReplace = string.Empty;
|
||||
SetText(tbReplace, IconReplace);
|
||||
ErrorBox(ex.Message);
|
||||
}
|
||||
}
|
||||
else //banner
|
||||
{
|
||||
try
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|banner.bin|banner.bin|All|*.wad;00000000.app;banner.bin";
|
||||
ofd.FilterIndex = 4;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (ofd.FileName != tbSourceWad.Text)
|
||||
{
|
||||
BannerReplace = ofd.FileName;
|
||||
SetText(tbReplace, BannerReplace);
|
||||
BackgroundWorker bwBannerReplace = new BackgroundWorker();
|
||||
bwBannerReplace.DoWork += new DoWorkEventHandler(bwBannerReplace_DoWork);
|
||||
bwBannerReplace.ProgressChanged += new ProgressChangedEventHandler(bwBannerReplace_ProgressChanged);
|
||||
bwBannerReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwBannerReplace_RunWorkerCompleted);
|
||||
bwBannerReplace.WorkerReportsProgress = true;
|
||||
bwBannerReplace.RunWorkerAsync(ofd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BannerReplace = string.Empty;
|
||||
SetText(tbReplace, BannerReplace);
|
||||
ErrorBox(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ReplacePart();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1873,7 +1780,7 @@ namespace CustomizeMii
|
||||
}
|
||||
|
||||
//Check BNS sound length
|
||||
if (tbSound.Text.StartsWith("BNS:") || tbSound.Text.EndsWith(".bns"))
|
||||
if (tbSound.Text.StartsWith("BNS:") || tbSound.Text.ToLower().EndsWith(".bns"))
|
||||
{
|
||||
string bnsFile = tbSound.Text;
|
||||
if (tbSound.Text.StartsWith("BNS:")) bnsFile = TempBnsPath;
|
||||
@ -2690,176 +2597,90 @@ namespace CustomizeMii
|
||||
|
||||
private void btnDeleteBanner_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
if (lbxBannerTpls.SelectedIndex != -1)
|
||||
{
|
||||
string TplName = lbxBannerTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
|
||||
string CurBannerPath = GetCurBannerPath();
|
||||
string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurBannerPath + "blyt\\banner.brlyt");
|
||||
int idx = lbxBannerTpls.SelectedIndex;
|
||||
|
||||
if (!Wii.Tools.StringExistsInStringArray(TplName, brlytTpls))
|
||||
try
|
||||
{
|
||||
File.Delete(CurBannerPath + "timg\\" + TplName);
|
||||
lbxBannerTpls.Items.Remove(lbxBannerTpls.SelectedItem);
|
||||
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) || cbFailureChecks.Checked)
|
||||
{
|
||||
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!");
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex) { ErrorBox(ex.Message); }
|
||||
|
||||
for (; ; )
|
||||
{
|
||||
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!");
|
||||
try
|
||||
{
|
||||
lbxBannerTpls.SelectedIndex = idx;
|
||||
break;
|
||||
}
|
||||
catch { idx--; }
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { ErrorBox(ex.Message); }
|
||||
|
||||
lbxBannerTpls.Select();
|
||||
}
|
||||
|
||||
private void btnDeleteIcon_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
if (lbxIconTpls.SelectedIndex != -1)
|
||||
{
|
||||
string TplName = lbxIconTpls.SelectedItem.ToString().Replace(" (Transparent)", string.Empty);
|
||||
string CurIconPath = GetCurIconPath();
|
||||
int idx = lbxIconTpls.SelectedIndex;
|
||||
|
||||
string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurIconPath + "blyt\\icon.brlyt");
|
||||
|
||||
if (!Wii.Tools.StringExistsInStringArray(TplName, brlytTpls))
|
||||
try
|
||||
{
|
||||
File.Delete(CurIconPath + "timg\\" + TplName);
|
||||
lbxIconTpls.Items.Remove(lbxIconTpls.SelectedItem);
|
||||
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) || cbFailureChecks.Checked)
|
||||
{
|
||||
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!");
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex) { ErrorBox(ex.Message); }
|
||||
|
||||
for (; ; )
|
||||
{
|
||||
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!");
|
||||
try
|
||||
{
|
||||
lbxIconTpls.SelectedIndex = idx;
|
||||
break;
|
||||
}
|
||||
catch { idx--; }
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { ErrorBox(ex.Message); }
|
||||
|
||||
lbxIconTpls.Select();
|
||||
}
|
||||
|
||||
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.ToLower().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.ToLower().EndsWith(".tpl"))
|
||||
{
|
||||
File.Copy(ofd.FileName, CurBannerPath + "timg\\" + TplName, true);
|
||||
lbxBannerTpls.Items.Add(TplName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Image img = Image.FromFile(ofd.FileName);
|
||||
Wii.TPL.ConvertToTPL(img, CurBannerPath + "timg\\" + TplName, TplFormat);
|
||||
lbxBannerTpls.Items.Add(TplName);
|
||||
}
|
||||
}
|
||||
}
|
||||
try { AddTpl(lbxBannerTpls); }
|
||||
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.ToLower().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.ToLower().EndsWith(".tpl"))
|
||||
{
|
||||
File.Copy(ofd.FileName, CuriconPath + "timg\\" + TplName, true);
|
||||
lbxIconTpls.Items.Add(TplName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Image img = Image.FromFile(ofd.FileName);
|
||||
Wii.TPL.ConvertToTPL(img, CuriconPath + "timg\\" + TplName, TplFormat);
|
||||
lbxIconTpls.Items.Add(TplName);
|
||||
}
|
||||
}
|
||||
}
|
||||
try { AddTpl(lbxIconTpls); }
|
||||
catch (Exception ex) { ErrorBox(ex.Message); }
|
||||
}
|
||||
|
||||
@ -3256,7 +3077,7 @@ namespace CustomizeMii
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (ofd.FileName.EndsWith(".wad"))
|
||||
if (ofd.FileName.ToLower().EndsWith(".wad"))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
284
CustomizeMii/CustomizeMii_PrivateFunctions.cs
Normal file
284
CustomizeMii/CustomizeMii_PrivateFunctions.cs
Normal file
@ -0,0 +1,284 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CustomizeMii
|
||||
{
|
||||
partial class CustomizeMii_Main
|
||||
{
|
||||
private void AddTpl(ListBox lbx)
|
||||
{
|
||||
AddTpl(lbx, null);
|
||||
}
|
||||
|
||||
private void AddTpl(ListBox lbx, string inputFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputFile))
|
||||
{
|
||||
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)
|
||||
{
|
||||
inputFile = ofd.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(inputFile))
|
||||
{
|
||||
for (int i = 0; i < lbx.Items.Count; i++)
|
||||
if (lbx.Items[i].ToString().ToLower() == Path.GetFileNameWithoutExtension(inputFile).ToLower() + ".tpl")
|
||||
throw new Exception("This TPL already exists, use the Replace button");
|
||||
|
||||
string CurPath;
|
||||
if (lbx == lbxBannerTpls) CurPath = GetCurBannerPath();
|
||||
else CurPath = GetCurIconPath();
|
||||
|
||||
string[] brlytTpls = Wii.Brlyt.GetBrlytTpls(CurPath + string.Format("blyt\\{0}.brlyt", lbx == lbxBannerTpls ? "banner" : "icon"));
|
||||
string TplName = Path.GetFileNameWithoutExtension(inputFile) + ".tpl";
|
||||
int TplFormat = 6;
|
||||
|
||||
int switchVal = lbx == lbxBannerTpls ? cmbFormatBanner.SelectedIndex : cmbFormatIcon.SelectedIndex;
|
||||
switch (switchVal)
|
||||
{
|
||||
case 0:
|
||||
TplFormat = 6;
|
||||
break;
|
||||
case 1:
|
||||
TplFormat = 4;
|
||||
break;
|
||||
case 2:
|
||||
TplFormat = 5;
|
||||
break;
|
||||
default:
|
||||
if (!inputFile.ToLower().EndsWith(".tpl"))
|
||||
throw new Exception("This format is not supported, you must choose either RGBA8, RGB565 or RGB5A3!");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!Wii.Tools.StringExistsInStringArray(TplName, brlytTpls))
|
||||
{
|
||||
if (MessageBox.Show(string.Format("{0} is not required by your {1}.brlyt and thus only wastes memory!\nDo you still want to add it?", TplName, lbx == lbxBannerTpls ? "banner" : "icon"), "TPL not required", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
|
||||
return;
|
||||
}
|
||||
|
||||
if (inputFile.ToLower().EndsWith(".tpl"))
|
||||
{
|
||||
File.Copy(inputFile, CurPath + "timg\\" + TplName, true);
|
||||
lbx.Items.Add(TplName);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Image img = Image.FromFile(inputFile))
|
||||
{
|
||||
Wii.TPL.ConvertToTPL(img, CurPath + "timg\\" + TplName, TplFormat);
|
||||
lbx.Items.Add(TplName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { throw ex; }
|
||||
}
|
||||
|
||||
private void LoadChannel()
|
||||
{
|
||||
LoadChannel(null);
|
||||
}
|
||||
|
||||
private void LoadChannel(string inputFile)
|
||||
{
|
||||
if (this.Mono) CommonKeyCheck();
|
||||
|
||||
if (pbProgress.Value == 100)
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputFile))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SourceWad = inputFile;
|
||||
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(inputFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReplacePart()
|
||||
{
|
||||
ReplacePart(null);
|
||||
}
|
||||
|
||||
private void ReplacePart(string inputFile)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tbSourceWad.Text))
|
||||
{
|
||||
if (pbProgress.Value == 100)
|
||||
{
|
||||
if (cmbReplace.SelectedIndex == 2) //sound
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputFile))
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|sound.bin|sound.bin|All|*.wad;00000000.app;sound.bin";
|
||||
ofd.FilterIndex = 4;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (ofd.FileName != tbSourceWad.Text)
|
||||
{
|
||||
SoundReplace = ofd.FileName;
|
||||
SetText(tbReplace, SoundReplace);
|
||||
BackgroundWorker bwSoundReplace = new BackgroundWorker();
|
||||
bwSoundReplace.DoWork += new DoWorkEventHandler(bwSoundReplace_DoWork);
|
||||
bwSoundReplace.ProgressChanged += new ProgressChangedEventHandler(bwSoundReplace_ProgressChanged);
|
||||
bwSoundReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwSoundReplace_RunWorkerCompleted);
|
||||
bwSoundReplace.WorkerReportsProgress = true;
|
||||
bwSoundReplace.RunWorkerAsync(ofd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inputFile != tbSourceWad.Text)
|
||||
{
|
||||
SoundReplace = inputFile;
|
||||
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(inputFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SoundReplace = string.Empty;
|
||||
SetText(tbReplace, SoundReplace);
|
||||
ErrorBox(ex.Message);
|
||||
}
|
||||
}
|
||||
else if (cmbReplace.SelectedIndex == 1) //icon
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputFile))
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|icon.bin|icon.bin|All|*.wad;00000000.app;icon.bin";
|
||||
ofd.FilterIndex = 4;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (ofd.FileName != tbSourceWad.Text)
|
||||
{
|
||||
IconReplace = ofd.FileName;
|
||||
SetText(tbReplace, IconReplace);
|
||||
BackgroundWorker bwIconReplace = new BackgroundWorker();
|
||||
bwIconReplace.DoWork += new DoWorkEventHandler(bwIconReplace_DoWork);
|
||||
bwIconReplace.ProgressChanged += new ProgressChangedEventHandler(bwIconReplace_ProgressChanged);
|
||||
bwIconReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwIconReplace_RunWorkerCompleted);
|
||||
bwIconReplace.WorkerReportsProgress = true;
|
||||
bwIconReplace.RunWorkerAsync(ofd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inputFile != tbSourceWad.Text)
|
||||
{
|
||||
IconReplace = inputFile;
|
||||
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(inputFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
IconReplace = string.Empty;
|
||||
SetText(tbReplace, IconReplace);
|
||||
ErrorBox(ex.Message);
|
||||
}
|
||||
}
|
||||
else //banner
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputFile))
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Wii Channels|*.wad|00000000.app|00000000.app|banner.bin|banner.bin|All|*.wad;00000000.app;banner.bin";
|
||||
ofd.FilterIndex = 4;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (ofd.FileName != tbSourceWad.Text)
|
||||
{
|
||||
BannerReplace = ofd.FileName;
|
||||
SetText(tbReplace, BannerReplace);
|
||||
BackgroundWorker bwBannerReplace = new BackgroundWorker();
|
||||
bwBannerReplace.DoWork += new DoWorkEventHandler(bwBannerReplace_DoWork);
|
||||
bwBannerReplace.ProgressChanged += new ProgressChangedEventHandler(bwBannerReplace_ProgressChanged);
|
||||
bwBannerReplace.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwBannerReplace_RunWorkerCompleted);
|
||||
bwBannerReplace.WorkerReportsProgress = true;
|
||||
bwBannerReplace.RunWorkerAsync(ofd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inputFile != tbSourceWad.Text)
|
||||
{
|
||||
BannerReplace = inputFile;
|
||||
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(inputFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BannerReplace = string.Empty;
|
||||
SetText(tbReplace, BannerReplace);
|
||||
ErrorBox(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
245
CustomizeMii/MP3Info.cs
Normal file
245
CustomizeMii/MP3Info.cs
Normal file
@ -0,0 +1,245 @@
|
||||
/* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
|
||||
class MP3Info
|
||||
{
|
||||
//Private Variables
|
||||
private int fileSize;
|
||||
private int headerPos;
|
||||
private BitArray bitHeader;
|
||||
private MpegVersion mpegVersion;
|
||||
private MpegLayer mpegLayer;
|
||||
private int bitrate;
|
||||
private int frequency;
|
||||
private bool paddingBit;
|
||||
private int frameLength;
|
||||
private int frameCount;
|
||||
private double secLength;
|
||||
private int waveSamples;
|
||||
|
||||
//Public Variables
|
||||
public int FileSize { get { return fileSize; } }
|
||||
public MpegVersion MPEGVersion { get { return mpegVersion; } }
|
||||
public MpegLayer MPEGLayer { get { return mpegLayer; } }
|
||||
public int Bitrate { get { return bitrate; } }
|
||||
public int Frequency { get { return frequency; } }
|
||||
public int FrameLength { get { return frameLength; } }
|
||||
public int FrameCount { get { return frameCount; } }
|
||||
public double Seconds { get { return secLength; } }
|
||||
public int AudioSamples { get { return waveSamples; } }
|
||||
|
||||
//Public Functions
|
||||
public MP3Info(string mp3File)
|
||||
{
|
||||
FileInfo fi = new FileInfo(mp3File);
|
||||
this.fileSize = (int)fi.Length;
|
||||
|
||||
FileStream fs = fi.OpenRead();
|
||||
fs.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
this.headerPos = SearchHeader(fs);
|
||||
|
||||
byte[] header = new byte[4];
|
||||
fs.Seek(this.headerPos, SeekOrigin.Begin);
|
||||
fs.Read(header, 0, header.Length);
|
||||
fs.Close();
|
||||
|
||||
GetHeaderBits(header);
|
||||
LoadHeader();
|
||||
}
|
||||
|
||||
public MP3Info(byte[] mp3Header)
|
||||
{
|
||||
GetHeaderBits(mp3Header);
|
||||
LoadHeader();
|
||||
}
|
||||
|
||||
//Private Functions
|
||||
private void ShowHeader()
|
||||
{
|
||||
//For debugging
|
||||
if (this.bitHeader != null)
|
||||
{
|
||||
string strBits = string.Empty;
|
||||
foreach (bool x in this.bitHeader)
|
||||
if (x) strBits += "1"; else strBits += "0";
|
||||
|
||||
for (int i = strBits.Length - 8; i >= 0; i -= 8)
|
||||
strBits = strBits.Insert(i, " ");
|
||||
|
||||
System.Windows.Forms.MessageBox.Show(strBits);
|
||||
}
|
||||
}
|
||||
|
||||
private int SearchHeader(Stream fileStream)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
while ((tmp = fileStream.ReadByte()) != -1)
|
||||
{
|
||||
if (tmp == 255)
|
||||
{
|
||||
tmp = fileStream.ReadByte();
|
||||
BitArray tmpBits = new BitArray(new int[] { tmp });
|
||||
if (tmpBits[7] && tmpBits[6] && tmpBits[5]) return (int)(fileStream.Position - 2);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Frame Header couldn't be found!");
|
||||
}
|
||||
|
||||
private void GetHeaderBits(byte[] fourBytes)
|
||||
{
|
||||
BitArray tmp = new BitArray(fourBytes);
|
||||
this.bitHeader = new BitArray(4 * 8);
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < 32; i += 8)
|
||||
for (int j = 7; j >= 0; j--)
|
||||
this.bitHeader[count++] = tmp[i + j];
|
||||
}
|
||||
|
||||
private void LoadHeader()
|
||||
{
|
||||
GetVersion(this.bitHeader[11], this.bitHeader[12]);
|
||||
if (this.mpegVersion == MpegVersion.Reserved) throw new NotSupportedException("Unsupported MPEG Version!");
|
||||
GetLayer(this.bitHeader[13], this.bitHeader[14]);
|
||||
if (this.mpegLayer == MpegLayer.Reserved) throw new NotSupportedException("Unsupported MPEG Layer!");
|
||||
GetBitrate(this.bitHeader[16], this.bitHeader[17], this.bitHeader[18], this.bitHeader[19]);
|
||||
if (this.bitrate == 0) throw new NotSupportedException("Unsupported Bitrate!");
|
||||
GetFrequency(this.bitHeader[20], this.bitHeader[21]);
|
||||
if (this.frequency == -1) throw new NotSupportedException("Unsupported Frequency");
|
||||
this.paddingBit = this.bitHeader[22];
|
||||
|
||||
GetFrameLength();
|
||||
GetFrameCount();
|
||||
GetSeconds();
|
||||
GetWaveSamples();
|
||||
}
|
||||
|
||||
private void GetVersion(params bool[] twoBits)
|
||||
{
|
||||
if (twoBits[0] && twoBits[1]) this.mpegVersion = MpegVersion.MpegVersion1;
|
||||
else if (twoBits[0] && !twoBits[1]) this.mpegVersion = MpegVersion.MpegVersion2;
|
||||
else if (!twoBits[0] && twoBits[1]) this.mpegVersion = MpegVersion.Reserved;
|
||||
else if (!twoBits[0] && !twoBits[1]) this.mpegVersion = MpegVersion.MpegVersion25;
|
||||
}
|
||||
|
||||
private void GetLayer(params bool[] twoBits)
|
||||
{
|
||||
if (twoBits[0] && twoBits[1]) this.mpegLayer = MpegLayer.I;
|
||||
else if (twoBits[0] && !twoBits[1]) this.mpegLayer = MpegLayer.II;
|
||||
else if (!twoBits[0] && twoBits[1]) this.mpegLayer = MpegLayer.III;
|
||||
else if (!twoBits[0] && !twoBits[1]) this.mpegLayer = MpegLayer.Reserved;
|
||||
}
|
||||
|
||||
private void GetBitrate(params bool[] fourBits)
|
||||
{
|
||||
int[] bitrateTable = GetBitrateTable();
|
||||
|
||||
Array.Reverse(fourBits);
|
||||
BitArray bArray = new BitArray(fourBits);
|
||||
byte[] index = new byte[1];
|
||||
bArray.CopyTo(index, 0);
|
||||
|
||||
this.bitrate = bitrateTable[index[0]];
|
||||
}
|
||||
|
||||
private int[] GetBitrateTable()
|
||||
{
|
||||
if (this.mpegVersion == MpegVersion.MpegVersion1)
|
||||
{
|
||||
if (this.mpegLayer == MpegLayer.I) return new int[] { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0 };
|
||||
if (this.mpegLayer == MpegLayer.II) return new int[] { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0 };
|
||||
if (this.mpegLayer == MpegLayer.III) return new int[] { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0 };
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.mpegLayer == MpegLayer.I) return new int[] { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 };
|
||||
if (this.mpegLayer == MpegLayer.II ||
|
||||
this.mpegLayer == MpegLayer.III) return new int[] { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 };
|
||||
}
|
||||
|
||||
throw new NotSupportedException("Unsupported MPEG Version or Layer!");
|
||||
}
|
||||
|
||||
private void GetFrequency(params bool[] twoBits)
|
||||
{
|
||||
int[] frequencyTable = GetFrequencyTable();
|
||||
|
||||
Array.Reverse(twoBits);
|
||||
BitArray bArray = new BitArray(twoBits);
|
||||
byte[] index = new byte[1];
|
||||
bArray.CopyTo(index, 0);
|
||||
|
||||
this.frequency = frequencyTable[index[0]];
|
||||
}
|
||||
|
||||
private int[] GetFrequencyTable()
|
||||
{
|
||||
if (this.mpegVersion == MpegVersion.MpegVersion1)
|
||||
return new int[] { 44100, 48000, 32000, -1 };
|
||||
else if (this.mpegVersion == MpegVersion.MpegVersion2)
|
||||
return new int[] { 22050, 24000, 16000, -1 };
|
||||
else if (this.mpegVersion == MpegVersion.MpegVersion25)
|
||||
return new int[] { 32000, 16000, 8000, -1 };
|
||||
else
|
||||
return new int[] { 0, 0, 0, -1 };
|
||||
}
|
||||
|
||||
private void GetFrameLength()
|
||||
{
|
||||
double frmSize = (double)((this.mpegLayer == MpegLayer.I ? 12 : 144) * ((1000.0 * (float)this.bitrate / (float)this.frequency)));
|
||||
this.frameLength = (int)Math.Ceiling(frmSize);
|
||||
}
|
||||
|
||||
private void GetFrameCount()
|
||||
{
|
||||
this.frameCount = (this.fileSize - this.headerPos) / this.frameLength;
|
||||
}
|
||||
|
||||
private void GetSeconds()
|
||||
{
|
||||
this.secLength = ((this.fileSize - this.headerPos) * 8.00) / (1000.00 * this.bitrate);
|
||||
}
|
||||
|
||||
private void GetWaveSamples()
|
||||
{
|
||||
this.waveSamples = this.frameCount * 1125;
|
||||
}
|
||||
|
||||
//Structs & Enums
|
||||
public enum MpegVersion : int
|
||||
{
|
||||
Reserved = 0,
|
||||
MpegVersion1 = 1,
|
||||
MpegVersion25 = 2,
|
||||
MpegVersion2 = 3
|
||||
}
|
||||
|
||||
public enum MpegLayer : int
|
||||
{
|
||||
Reserved = 0,
|
||||
I = 1,
|
||||
II = 2,
|
||||
III = 3
|
||||
}
|
||||
}
|
@ -11,7 +11,10 @@ Changelog:
|
||||
|
||||
Version 2.1
|
||||
- Replaced the TPL preview window with the one from ShowMiiWads for easier handling
|
||||
-
|
||||
- Added loop prelistening to the BNS conversion window (only for wave files)
|
||||
- Added drag & drop ability cause the file dialogs kept bothering me
|
||||
- Improvement in startup speed (thanks shadow1643)
|
||||
- Added Unix timestamp as footer (interesting to know when channels were created, huh?)
|
||||
- Little improvements
|
||||
|
||||
Version 2.01
|
||||
|
@ -58,6 +58,10 @@ namespace WaveFile
|
||||
/// The start sample of the first Loop (if exist)
|
||||
/// </summary>
|
||||
public int LoopStart { get { return GetLoopStart(); } }
|
||||
/// <summary>
|
||||
/// The total number of Frames
|
||||
/// </summary>
|
||||
public int SampleCount { get { return GetFrameCount(); } }
|
||||
|
||||
|
||||
|
||||
@ -123,6 +127,42 @@ namespace WaveFile
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trims the start of the wave to the given sample
|
||||
/// </summary>
|
||||
/// <param name="newStartSample"></param>
|
||||
/// <returns></returns>
|
||||
public MemoryStream TrimStart(int newStartSample)
|
||||
{
|
||||
if (newStartSample > this.SampleCount) throw new Exception(string.Format("The loop start sample ({0}) is higher than the total number of samples ({1}) in this file!", newStartSample, this.SampleCount));
|
||||
|
||||
MemoryStream msOut = new MemoryStream();
|
||||
msOut.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
if (newStartSample == 0)
|
||||
{
|
||||
msOut.Write(waveFile, 0, waveFile.Length);
|
||||
msOut.Seek(0, SeekOrigin.Begin);
|
||||
return msOut;
|
||||
}
|
||||
|
||||
msOut.Write(waveFile, 0, this.dataOffset + 8);
|
||||
msOut.Write(waveFile, this.ChannelCount * 2 * newStartSample, waveFile.Length - (this.dataOffset + 8 + (this.ChannelCount * 2 * newStartSample)));
|
||||
|
||||
int cutted = (this.ChannelCount * 2 * newStartSample) - (this.dataOffset + 8);
|
||||
|
||||
byte[] newLength = BitConverter.GetBytes((UInt32)msOut.Position);
|
||||
byte[] dataLength = BitConverter.GetBytes(BitConverter.ToInt32(waveFile, this.dataOffset + 4) - cutted);
|
||||
|
||||
msOut.Seek(4, SeekOrigin.Begin);
|
||||
msOut.Write(newLength, 0, newLength.Length);
|
||||
msOut.Seek(this.dataOffset + 4, SeekOrigin.Begin);
|
||||
msOut.Write(dataLength, 0, dataLength.Length);
|
||||
|
||||
msOut.Seek(0, SeekOrigin.Begin);
|
||||
return msOut;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the Wave file
|
||||
/// </summary>
|
||||
@ -135,6 +175,13 @@ namespace WaveFile
|
||||
|
||||
//Private Functions
|
||||
|
||||
private int GetFrameCount()
|
||||
{
|
||||
int dataLength = GetDataLength();
|
||||
|
||||
return (dataLength / (this.ChannelCount * 2));
|
||||
}
|
||||
|
||||
private int GetLoopStart()
|
||||
{
|
||||
if (smplOffset == -1) return 0;
|
||||
|
@ -57,6 +57,21 @@ namespace Wii
|
||||
return big;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current UTC Unix Timestamp as a Byte Array
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static byte[] GetTimestamp()
|
||||
{
|
||||
DateTime dtNow = DateTime.UtcNow;
|
||||
TimeSpan tsTimestamp = (dtNow - new DateTime(1970, 1, 1, 0, 0, 0));
|
||||
|
||||
int timestamp = (int)tsTimestamp.TotalSeconds;
|
||||
ASCIIEncoding enc = new ASCIIEncoding();
|
||||
byte[] timestampBytes = enc.GetBytes("CMiiUT" + timestamp.ToString());
|
||||
return timestampBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Byte Array out of the given one
|
||||
/// from the given offset with the specified length
|
||||
@ -1347,6 +1362,50 @@ namespace Wii
|
||||
|
||||
return decryptedkey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes the Timestamp in the Trailer, if available.
|
||||
/// Returns null if no Timestamp was found.
|
||||
/// </summary>
|
||||
/// <param name="trailer"></param>
|
||||
/// <returns></returns>
|
||||
public static DateTime GetCreationTime(string trailer)
|
||||
{
|
||||
byte[] bTrailer = Tools.LoadFileToByteArray(trailer);
|
||||
return GetCreationTime(bTrailer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes the Timestamp in the Trailer, if available.
|
||||
/// Returns null if no Timestamp was found.
|
||||
/// </summary>
|
||||
/// <param name="trailer"></param>
|
||||
/// <returns></returns>
|
||||
public static DateTime GetCreationTime(byte[] trailer)
|
||||
{
|
||||
DateTime result = new DateTime(1970, 1, 1);
|
||||
|
||||
if (trailer[0] == 'C' &&
|
||||
trailer[1] == 'M' &&
|
||||
trailer[2] == 'i' &&
|
||||
trailer[3] == 'i' &&
|
||||
trailer[4] == 'U' &&
|
||||
trailer[5] == 'T')
|
||||
{
|
||||
ASCIIEncoding enc = new ASCIIEncoding();
|
||||
string stringSeconds = enc.GetString(trailer, 6, 10);
|
||||
int seconds = 0;
|
||||
|
||||
if (int.TryParse(stringSeconds, out seconds))
|
||||
{
|
||||
result = result.AddSeconds((double)seconds);
|
||||
return result;
|
||||
}
|
||||
else return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class WadEdit
|
||||
@ -2267,6 +2326,18 @@ namespace Wii
|
||||
|
||||
return wadtmd;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the Title Key in the Tik
|
||||
/// </summary>
|
||||
/// <param name="tik"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] ChangeTitleKey(byte[] tik)
|
||||
{
|
||||
byte[] newKey = new byte[] { 0x47, 0x6f, 0x74, 0x74, 0x61, 0x47, 0x65, 0x74, 0x53, 0x6f, 0x6d, 0x65, 0x42, 0x65, 0x65, 0x72 };
|
||||
Tools.InsertByteArray(tik, newKey, 447);
|
||||
return tik;
|
||||
}
|
||||
}
|
||||
|
||||
public class WadUnpack
|
||||
@ -2575,7 +2646,7 @@ namespace Wii
|
||||
/// Packs the contents in the given directory and creates the destination wad file
|
||||
/// </summary>
|
||||
/// <param name="directory"></param>
|
||||
public static void PackWad(string contentdirectory, string destinationfile, bool includefooter)
|
||||
public static void PackWad(string contentdirectory, string destinationfile)
|
||||
{
|
||||
if (contentdirectory[contentdirectory.Length - 1] != '\\') { contentdirectory = contentdirectory + "\\"; }
|
||||
|
||||
@ -2589,12 +2660,13 @@ namespace Wii
|
||||
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]);
|
||||
|
||||
tik = WadEdit.ChangeTitleKey(tik);
|
||||
|
||||
string[,] contents = WadInfo.GetContentInfo(tmd);
|
||||
|
||||
FileStream wadstream = new FileStream(destinationfile, FileMode.Create);
|
||||
@ -2638,23 +2710,20 @@ namespace Wii
|
||||
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 Footer Timestamp
|
||||
byte[] footer = Tools.GetTimestamp();
|
||||
Array.Resize(ref footer, Tools.AddPadding(footer.Length, 16));
|
||||
|
||||
int footerLength = footer.Length;
|
||||
wadstream.Seek(Tools.AddPadding(contpos), SeekOrigin.Begin);
|
||||
wadstream.Write(footer, 0, footer.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);
|
||||
byte[] footersize = Tools.FileLengthToByteArray(footerLength);
|
||||
|
||||
wadstream.Seek(0x00, SeekOrigin.Begin);
|
||||
wadstream.Write(wadheader, 0, wadheader.Length);
|
||||
@ -2667,7 +2736,7 @@ namespace Wii
|
||||
wadstream.Seek(0x18, SeekOrigin.Begin);
|
||||
wadstream.Write(allcontsize, 0, allcontsize.Length);
|
||||
wadstream.Seek(0x1c, SeekOrigin.Begin);
|
||||
wadstream.Write(trailersize, 0, trailersize.Length);
|
||||
wadstream.Write(footersize, 0, footersize.Length);
|
||||
|
||||
wadstream.Close();
|
||||
}
|
||||
@ -2699,6 +2768,8 @@ namespace Wii
|
||||
byte[] tik = Tools.LoadFileToByteArray(ticketdir + path2 + ".tik");
|
||||
byte[] tmd = Tools.LoadFileToByteArray(contentdir + "title.tmd");
|
||||
|
||||
tik = WadEdit.ChangeTitleKey(tik);
|
||||
|
||||
string[,] contents = WadInfo.GetContentInfo(tmd);
|
||||
|
||||
FileStream wadstream = new FileStream(destinationfile, FileMode.Create);
|
||||
@ -2758,12 +2829,20 @@ namespace Wii
|
||||
allcont += thiscont.Length;
|
||||
}
|
||||
|
||||
//Write Footer Timestamp
|
||||
byte[] footer = Tools.GetTimestamp();
|
||||
Array.Resize(ref footer, Tools.AddPadding(footer.Length, 16));
|
||||
|
||||
int footerLength = footer.Length;
|
||||
wadstream.Seek(Tools.AddPadding(contpos), SeekOrigin.Begin);
|
||||
wadstream.Write(footer, 0, footer.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 };
|
||||
byte[] footersize = Tools.FileLengthToByteArray(footerLength);
|
||||
|
||||
wadstream.Seek(0x00, SeekOrigin.Begin);
|
||||
wadstream.Write(wadheader, 0, wadheader.Length);
|
||||
@ -2776,7 +2855,7 @@ namespace Wii
|
||||
wadstream.Seek(0x18, SeekOrigin.Begin);
|
||||
wadstream.Write(allcontsize, 0, allcontsize.Length);
|
||||
wadstream.Seek(0x1c, SeekOrigin.Begin);
|
||||
wadstream.Write(trailersize, 0, trailersize.Length);
|
||||
wadstream.Write(footersize, 0, footersize.Length);
|
||||
|
||||
wadstream.Close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user