CustomizeMii 3.0

git-svn-id: svn://localhost/Users/andi/Downloads/code/trunk@34 eddbe33b-e435-4246-ac25-f5eb65f9a13c
This commit is contained in:
leathl 2010-03-28 18:29:30 +00:00
parent c6c40b6e72
commit 153acfac45
30 changed files with 2646 additions and 10072 deletions

View File

@ -1,714 +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 <http://www.gnu.org/licenses/>.
*/
//These classes are based on bns.py (by megazig) of the Wii.py Framework with improvements by me (Leathl)
//Thanks to Xuzz, SquidMan, megazig, Matt_P, Omega and The Lemon Man, the authors of Wii.py!
using System;
using System.Collections.Generic;
using System.IO;
using WaveFile;
namespace BNS
{
internal class BNS_Data
{
//Private Varialbes
private byte[] magic = new byte[] { (byte)'D', (byte)'A', (byte)'T', (byte)'A' };
private UInt32 size = 0x0004d000;
private byte[] data;
//Public Variables
public UInt32 Size { get { return size; } set { size = value; } }
public byte[] Data { get { return data; } set { data = value; } }
public BNS_Data() { }
public void Write(Stream outStream)
{
byte[] temp = BitConverter.GetBytes(size); Array.Reverse(temp);
outStream.Write(magic, 0, magic.Length);
outStream.Write(temp, 0, temp.Length);
outStream.Write(data, 0, data.Length);
}
}
internal class BNS_Info
{
//Private Variables
private byte[] magic = new byte[] { (byte)'I', (byte)'N', (byte)'F', (byte)'O' };
private UInt32 size = 0x000000a0;
private byte codec = 0x00;
private byte hasLoop = 0x00;
private byte channelCount = 0x02;
private byte zero = 0x00;
private UInt16 sampleRate = 0xac44;
private UInt16 pad0 = 0x0000;
private UInt32 loopStart = 0x00000000;
private UInt32 loopEnd = 0x00000000; //Or total sample count
private UInt32 offsetToChannelStart = 0x00000018;
private UInt32 pad1 = 0x00000000;
private UInt32 channel1StartOffset = 0x00000020;
private UInt32 channel2StartOffset = 0x0000002C;
private UInt32 channel1Start = 0x00000000;
private UInt32 coefficients1Offset = 0x0000038;
private UInt32 pad2 = 0x00000000;
private UInt32 channel2Start = 0x00000000;
private UInt32 coefficients2Offset = 0x00000068;
private UInt32 pad3 = 0x00000000;
private int[] coefficients1 = new int[16];
private UInt16 channel1Gain = 0x0000;
private UInt16 channel1PredictiveScale = 0x0000;
private UInt16 channel1PreviousValue = 0x0000;
private UInt16 channel1NextPreviousValue = 0x0000;
private UInt16 channel1LoopPredictiveScale = 0x0000;
private UInt16 channel1LoopPreviousValue = 0x0000;
private UInt16 channel1LoopNextPreviousValue = 0x0000;
private UInt16 channel1LoopPadding = 0x0000;
private int[] coefficients2 = new int[16];
private UInt16 channel2Gain = 0x0000;
private UInt16 channel2PredictiveScale = 0x0000;
private UInt16 channel2PreviousValue = 0x0000;
private UInt16 channel2NextPreviousValue = 0x0000;
private UInt16 channel2LoopPredictiveScale = 0x0000;
private UInt16 channel2LoopPreviousValue = 0x0000;
private UInt16 channel2LoopNextPreviousValue = 0x0000;
private UInt16 channel2LoopPadding = 0x0000;
//Public Variables
public byte HasLoop { get { return hasLoop; } set { hasLoop = value; } }
public UInt32 Coefficients1Offset { get { return coefficients1Offset; } set { coefficients1Offset = value; } }
public UInt32 Channel1StartOffset { get { return channel1StartOffset; } set { channel1StartOffset = value; } }
public UInt32 Channel2StartOffset { get { return channel2StartOffset; } set { channel2StartOffset = value; } }
public UInt32 Size { get { return size; } set { size = value; } }
public UInt16 SampleRate { get { return sampleRate; } set { sampleRate = value; } }
public byte ChannelCount { get { return channelCount; } set { channelCount = value; } }
public UInt32 Channel1Start { get { return channel1Start; } set { channel1Start = value; } }
public UInt32 Channel2Start { get { return channel2Start; } set { channel2Start = value; } }
public UInt32 LoopStart { get { return loopStart; } set { loopStart = value; } }
public UInt32 LoopEnd { get { return loopEnd; } set { loopEnd = value; } }
public int[] Coefficients1 { get { return coefficients1; } set { coefficients1 = value; } }
public int[] Coefficients2 { get { return coefficients2; } set { coefficients2 = value; } }
public BNS_Info() { }
public void Write(Stream outStream)
{
outStream.Write(magic, 0, magic.Length);
byte[] temp = BitConverter.GetBytes(size); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
outStream.WriteByte(codec);
outStream.WriteByte(hasLoop);
outStream.WriteByte(channelCount);
outStream.WriteByte(zero);
temp = BitConverter.GetBytes(sampleRate); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(pad0); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(loopStart); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(loopEnd); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(offsetToChannelStart); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(pad1); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1StartOffset); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel2StartOffset); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1Start); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(coefficients1Offset); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
if (this.channelCount == 2)
{
temp = BitConverter.GetBytes(pad2); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel2Start); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(coefficients2Offset); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(pad3); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
foreach (int thisInt in coefficients1)
{
temp = BitConverter.GetBytes(thisInt); Array.Reverse(temp);
outStream.Write(temp, 2, temp.Length - 2);
}
temp = BitConverter.GetBytes(channel1Gain); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1PredictiveScale); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1PreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1NextPreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1LoopPredictiveScale); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1LoopPreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1LoopNextPreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1LoopPadding); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
foreach (int thisInt in coefficients2)
{
temp = BitConverter.GetBytes(thisInt); Array.Reverse(temp);
outStream.Write(temp, 2, temp.Length - 2);
}
temp = BitConverter.GetBytes(channel2Gain); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel2PredictiveScale); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel2PreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel2NextPreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel2LoopPredictiveScale); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel2LoopPreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel2LoopNextPreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel2LoopPadding); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
}
else if (this.channelCount == 1)
{
foreach (int thisInt in coefficients1)
{
temp = BitConverter.GetBytes(thisInt); Array.Reverse(temp);
outStream.Write(temp, 2, temp.Length - 2);
}
temp = BitConverter.GetBytes(channel1Gain); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1PredictiveScale); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1PreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1NextPreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1LoopPredictiveScale); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1LoopPreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1LoopNextPreviousValue); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(channel1LoopPadding); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
}
}
}
internal class BNS_Header
{
//Private Variables
private byte[] magic = new byte[] { (byte)'B', (byte)'N', (byte)'S', (byte)' ' };
private UInt32 flags = 0xfeff0100;
private UInt32 fileSize = 0x0004d0c0;
private UInt16 size = 0x0020;
private UInt16 chunkCount = 0x0002;
private UInt32 infoOffset = 0x00000020;
private UInt32 infoLength = 0x000000a0;
private UInt32 dataOffset = 0x000000c0;
private UInt32 dataLength = 0x0004d000;
//Public Varialbes
public UInt32 DataOffset { get { return dataOffset; } set { dataOffset = value; } }
public UInt32 InfoLength { get { return infoLength; } set { infoLength = value; } }
public UInt16 Size { get { return size; } set { size = value; } }
public UInt32 DataLength { get { return dataLength; } set { dataLength = value; } }
public UInt32 FileSize { get { return fileSize; } set { fileSize = value; } }
public BNS_Header() { }
public void Write(Stream outStream)
{
outStream.Write(magic, 0, magic.Length);
byte[] temp = BitConverter.GetBytes(flags); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(fileSize); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(size); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(chunkCount); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(infoOffset); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(infoLength); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(dataOffset); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
temp = BitConverter.GetBytes(dataLength); Array.Reverse(temp);
outStream.Write(temp, 0, temp.Length);
}
}
public class BNS_File
{
//Private Variables
private BNS_Header bnsHeader = new BNS_Header();
private BNS_Info bnsInfo = new BNS_Info();
private BNS_Data bnsData = new BNS_Data();
private int[,] lSamples = new int[2, 2];
private int[,] rlSamples = new int[2, 2];
private int[] tlSamples = new int[2];
private int[] hbcDefTbl = new int[] { 674, 1040, 3598, -1738, 2270, -583, 3967, -1969, 1516, 381, 3453, -1468, 2606, -617, 3795, -1759 };
private int[] defTbl = new int[] { 1820, -856, 3238, -1514, 2333, -550, 3336, -1376, 2444, -949, 3666, -1764, 2654, -701, 3420, -1398 };
private int[] pHist1 = new int[2];
private int[] pHist2 = new int[2];
private int tempSampleCount;
private string waveFile;
private bool loopFromWave = false;
private bool converted = false;
private bool toMono = false;
//Public Variables
/// <summary>
/// 0x00 (0) = No Loop, 0x01 (1) = Loop
/// </summary>
public byte HasLoop { get { return this.bnsInfo.HasLoop; } set { this.bnsInfo.HasLoop = value; } }
/// <summary>
/// The start sample of the Loop
/// </summary>
public UInt32 LoopStart { get { return this.bnsInfo.LoopStart; } set { this.bnsInfo.LoopStart = value; } }
/// <summary>
/// The total number of samples in this file
/// </summary>
public UInt32 TotalSampleCount { get { return this.bnsInfo.LoopEnd; } set { this.bnsInfo.LoopEnd = value; } }
/// <summary>
/// If true and the input Wave file is stereo, the BNS will be converted to Mono.
/// Be sure to set this before you call Convert()!
/// </summary>
public bool StereoToMono { get { return toMono; } set { toMono = value; } }
//Public Functions
public BNS_File(string waveFile)
{
this.waveFile = waveFile;
}
public BNS_File(string waveFile, bool loopFromWave)
{
this.waveFile = waveFile;
this.loopFromWave = loopFromWave;
}
/// <summary>
/// Returns the progress of the conversion
/// </summary>
public event EventHandler<System.ComponentModel.ProgressChangedEventArgs> ProgressChanged;
/// <summary>
/// Converts the Wave file to BNS
/// </summary>
public void Convert()
{
Convert(waveFile, loopFromWave);
}
/// <summary>
/// Returns the BNS file as a Byte Array. If not already converted, it will be done first.
/// </summary>
/// <returns></returns>
public byte[] ToByteArray()
{
return ToMemoryStream().ToArray();
}
/// <summary>
/// Returns the BNS file as a Memory Stream. If not already converted, it will be done first.
/// </summary>
/// <returns></returns>
public MemoryStream ToMemoryStream()
{
if (!converted)
Convert(waveFile, loopFromWave);
MemoryStream ms = new MemoryStream();
this.bnsHeader.Write(ms);
this.bnsInfo.Write(ms);
this.bnsData.Write(ms);
return ms;
}
/// <summary>
/// Saves the BNS file to the given path. If not already converted, it will be done first.
/// </summary>
/// <param name="destionationFile"></param>
public void Save(string destionationFile)
{
if (File.Exists(destionationFile)) File.Delete(destionationFile);
using (FileStream fs = new FileStream(destionationFile, FileMode.Create))
{
byte[] bnsFile = ToMemoryStream().ToArray();
fs.Write(bnsFile, 0, bnsFile.Length);
}
}
/// <summary>
/// Sets the Loop to the given Start Sample. Be sure that you call Convert() first!
/// </summary>
/// <param name="loopStartSample"></param>
public void SetLoop(int loopStartSample)
{
this.bnsInfo.HasLoop = 0x01;
this.bnsInfo.LoopStart = (uint)loopStartSample;
}
//Private Functions
private void Convert(string waveFile, bool loopFromWave)
{
Wave wave = new Wave(waveFile);
int waveLoopCount = wave.LoopCount;
int waveLoopStart = wave.LoopStart;
this.bnsInfo.ChannelCount = (byte)wave.ChannelCount;
this.bnsInfo.SampleRate = (ushort)wave.SampleRate;
if (this.bnsInfo.ChannelCount > 2 || this.bnsInfo.ChannelCount < 1)
throw new Exception("Unsupported Count of Channels!");
if (wave.BitDepth != 16)
throw new Exception("Only 16bit Wave files are supported!");
if (wave.DataFormat != 1)
throw new Exception("The format of this Wave file is not supported!");
this.bnsData.Data = Encode(wave.GetAllFrames());
wave.Close();
if (this.bnsInfo.ChannelCount == 1)
{
this.bnsHeader.InfoLength = 0x60;
this.bnsHeader.DataOffset = 0x80;
this.bnsInfo.Size = 0x60;
this.bnsInfo.Channel1StartOffset = 0x0000001C;
this.bnsInfo.Channel2StartOffset = 0x00000000;
this.bnsInfo.Channel1Start = 0x00000028;
this.bnsInfo.Coefficients1Offset = 0x00000000;
}
this.bnsData.Size = (uint)bnsData.Data.Length + 8;
this.bnsHeader.DataLength = this.bnsData.Size;
this.bnsHeader.FileSize = this.bnsHeader.Size + this.bnsInfo.Size + this.bnsData.Size;
if (loopFromWave)
if (waveLoopCount == 1)
if (waveLoopStart != -1)
{ this.bnsInfo.LoopStart = (uint)waveLoopStart; this.bnsInfo.HasLoop = 0x01; }
this.bnsInfo.LoopEnd = (uint)tempSampleCount;
for (int i = 0; i < 16; i++)
{
this.bnsInfo.Coefficients1[i] = this.defTbl[i];
if (this.bnsInfo.ChannelCount == 2)
this.bnsInfo.Coefficients2[i] = this.defTbl[i];
}
this.converted = true;
}
private byte[] Encode(byte[] inputFrames)
{
int offset = 0;
int[] sampleBuffer = new int[14];
this.tempSampleCount = inputFrames.Length / (bnsInfo.ChannelCount == 2 ? 4 : 2);
int modLength = (inputFrames.Length / (bnsInfo.ChannelCount == 2 ? 4 : 2)) % 14;
Array.Resize(ref inputFrames, inputFrames.Length + ((14 - modLength) * (bnsInfo.ChannelCount == 2 ? 4 : 2)));
int sampleCount = inputFrames.Length / (bnsInfo.ChannelCount == 2 ? 4 : 2);
int blocks = (sampleCount + 13) / 14;
List<int> soundDataLeft = new List<int>();
List<int> soundDataRight = new List<int>();
int co = offset;
if (this.toMono && this.bnsInfo.ChannelCount == 2) this.bnsInfo.ChannelCount = 1;
else if (this.toMono) this.toMono = false;
for (int j = 0; j < sampleCount; j++)
{
soundDataLeft.Add(BitConverter.ToInt16(inputFrames, co));
co += 2;
if (this.bnsInfo.ChannelCount == 2 || toMono)
{
soundDataRight.Add(BitConverter.ToInt16(inputFrames, co));
co += 2;
}
}
byte[] data = new byte[(this.bnsInfo.ChannelCount == 2 ? (blocks * 16) : (blocks * 8))];
int data1Offset = 0;
int data2Offset = blocks * 8;
this.bnsInfo.Channel2Start = (this.bnsInfo.ChannelCount == 2 ? (uint)data2Offset : 0);
int[] leftSoundData = soundDataLeft.ToArray();
int[] rightSoundData = soundDataRight.ToArray();
for (int y = 0; y < blocks; y++)
{
try
{
if (y % (int)(blocks / 100) == 0 || (y + 1) == blocks)
ChangeProgress((y + 1) * 100 / blocks);
}
catch { }
for (int a = 0; a < 14; a++)
sampleBuffer[a] = leftSoundData[y * 14 + a];
byte[] outBuffer = RepackAdpcm(0, this.defTbl, sampleBuffer);
for (int a = 0; a < 8; a++)
data[data1Offset + a] = outBuffer[a];
data1Offset += 8;
if (this.bnsInfo.ChannelCount == 2)
{
for (int a = 0; a < 14; a++)
sampleBuffer[a] = rightSoundData[y * 14 + a];
outBuffer = RepackAdpcm(1, this.defTbl, sampleBuffer);
for (int a = 0; a < 8; a++)
data[data2Offset + a] = outBuffer[a];
data2Offset += 8;
}
}
this.bnsInfo.LoopEnd = (uint)(blocks * 7);
return data;
}
private byte[] RepackAdpcm(int index, int[] table, int[] inputBuffer)
{
byte[] data = new byte[8];
int[] blSamples = new int[2];
int bestIndex = -1;
double bestError = 999999999.0;
double error;
for (int tableIndex = 0; tableIndex < 8; tableIndex++)
{
byte[] testData = CompressAdpcm(index, table, tableIndex, inputBuffer, out error);
if (error < bestError)
{
bestError = error;
for (int i = 0; i < 8; i++)
data[i] = testData[i];
for (int i = 0; i < 2; i++)
blSamples[i] = this.tlSamples[i];
bestIndex = tableIndex;
}
}
for (int i = 0; i < 2; i++)
this.rlSamples[index, i] = blSamples[i];
return data;
}
private byte[] CompressAdpcm(int index, int[] table, int tableIndex, int[] inputBuffer, out double outError)
{
byte[] data = new byte[8];
int error = 0;
int factor1 = table[2 * tableIndex + 0];
int factor2 = table[2 * tableIndex + 1];
int exponent = DetermineStdExponent(index, table, tableIndex, inputBuffer);
while (exponent <= 15)
{
bool breakIt = false;
error = 0;
data[0] = (byte)(exponent | (tableIndex << 4));
for (int i = 0; i < 2; i++)
this.tlSamples[i] = this.rlSamples[index, i];
int j = 0;
for (int i = 0; i < 14; i++)
{
int predictor = (int)((this.tlSamples[1] * factor1 + this.tlSamples[0] * factor2) >> 11);
int residual = (inputBuffer[i] - predictor) >> exponent;
if (residual > 7 || residual < -8)
{
exponent++;
breakIt = true;
break;
}
int nibble = Clamp(residual, -8, 7);
if ((i & 1) != 0)
data[i / 2 + 1] = (byte)(data[i / 2 + 1] | (nibble & 0xf));
else
data[i / 2 + 1] = (byte)(nibble << 4);
predictor += nibble << exponent;
this.tlSamples[0] = this.tlSamples[1];
this.tlSamples[1] = Clamp(predictor, -32768, 32767);
error += (int)(Math.Pow((double)(this.tlSamples[1] - inputBuffer[i]), 2));
}
if (!breakIt) j = 14;
if (j == 14) break;
}
outError = error;
return data;
}
private int DetermineStdExponent(int index, int[] table, int tableIndex, int[] inputBuffer)
{
int[] elSamples = new int[2];
int maxResidual = 0;
int factor1 = table[2 * tableIndex + 0];
int factor2 = table[2 * tableIndex + 1];
for (int i = 0; i < 2; i++)
elSamples[i] = this.rlSamples[index, i];
for (int i = 0; i < 14; i++)
{
int predictor = (elSamples[1] * factor1 + elSamples[0] * factor2) >> 11;
int residual = inputBuffer[i] - predictor;
if (residual > maxResidual)
maxResidual = residual;
elSamples[0] = elSamples[1];
elSamples[1] = inputBuffer[i];
}
return FindExponent(maxResidual);
}
private int FindExponent(double residual)
{
int exponent = 0;
while (residual > 7.5 || residual < -8.5)
{
exponent++;
residual /= 2.0;
}
return exponent;
}
private int Clamp(int input, int min, int max)
{
if (input < min) return min;
if (input > max) return max;
return input;
}
private void ChangeProgress(int progressPercentage)
{
EventHandler<System.ComponentModel.ProgressChangedEventArgs> progressChanged = ProgressChanged;
if (progressChanged != null)
{
progressChanged(new object(), new System.ComponentModel.ProgressChangedEventArgs(progressPercentage, new object()));
}
}
}
}

View File

@ -55,6 +55,7 @@
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
@ -65,13 +66,9 @@
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="CustomizeMiiInstaller, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="libWiiSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\CustomizeMiiInstaller\bin\Release\CustomizeMiiInstaller.dll</HintPath>
</Reference>
<Reference Include="ForwardMii, Version=1.2.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ForwardMii\bin\x86\Release\ForwardMii.dll</HintPath>
<HintPath>.\libWiiSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
@ -79,7 +76,6 @@
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="BNS.cs" />
<Compile Include="CustomizeMii_BackgroundWorkers.cs">
<SubType>Form</SubType>
</Compile>
@ -153,8 +149,8 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<EmbeddedResource Include="Resources\comex.app" />
<EmbeddedResource Include="Resources\Waninkoko.app" />
<None Include="Resources\comex.app" />
<None Include="Resources\Waninkoko.app" />
<EmbeddedResource Include="CustomizeMii_Preview.resx">
<DependentUpon>CustomizeMii_Preview.cs</DependentUpon>
</EmbeddedResource>
@ -170,8 +166,6 @@
<Compile Include="CustomizeMii_Preview.designer.cs">
<DependentUpon>CustomizeMii_Preview.cs</DependentUpon>
</Compile>
<Compile Include="Wave.cs" />
<Compile Include="Wii.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="License.txt" />
@ -182,6 +176,7 @@
<None Include="Resources\btnCreate.png" />
<None Include="Resources\CustomizeMii.ico" />
<None Include="Resources\Instructions.rtf" />
<None Include="Resources\WaninkokoLeathl.app" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
@ -210,6 +205,16 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CustomizeMiiInstaller\CustomizeMiiInstaller.csproj">
<Project>{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}</Project>
<Name>CustomizeMiiInstaller</Name>
</ProjectReference>
<ProjectReference Include="..\ForwardMii\ForwardMii.csproj">
<Project>{20CB2CA7-6767-4758-97FA-97395F47CD6B}</Project>
<Name>ForwardMii</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -14,4 +14,8 @@
<FallbackCulture>de-DE</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<StartArguments>
</StartArguments>
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -19,8 +19,8 @@ using System;
using System.IO;
using System.Windows.Forms;
using System.ComponentModel;
using WaveFile;
using System.Media;
using libWiiSharp;
namespace CustomizeMii
{
@ -40,6 +40,7 @@ namespace CustomizeMii
private int sampleCount;
private SoundPlayer sPlayer;
private bool mp3LengthKnown = false;
private byte[] sourceSound = new byte[0];
public string AudioFile { get { return tbAudioFile.Text; } }
public bool LoopNone { get { return rbNone.Checked; } }
@ -47,6 +48,7 @@ namespace CustomizeMii
public bool LoopManually { get { return rbEnterManually.Checked; } }
public int LoopStartSample { get { return loopStartSample; } }
public int ChannelCount { get { return channelCount; } }
public byte[] SourceSound { get { return sourceSound; } set { sourceSound = value; } }
public CustomizeMii_BnsConvert(bool lameExists)
{
@ -60,17 +62,15 @@ namespace CustomizeMii
this.Size = new System.Drawing.Size(btnCancel.Location.X + btnCancel.Size.Width + 15, this.Size.Height);
this.CenterToParent();
bwGatherInfo = new BackgroundWorker();
bwGatherInfo.WorkerSupportsCancellation = true;
bwGatherInfo.DoWork += new DoWorkEventHandler(bwGatherInfo_DoWork);
byte[] soundBin = Wii.Tools.LoadFileToByteArray(CustomizeMii_Main.TempUnpackPath + "00000000.app_OUT\\meta\\sound.bin", 32, 16);
if (soundBin[0] == 'R' && soundBin[1] == 'I' && soundBin[2] == 'F' && soundBin[3] == 'F')
if (sourceSound[0] == 'R' && sourceSound[1] == 'I' && sourceSound[2] == 'F' && sourceSound[3] == 'F')
{ cbSourceSound.Enabled = true; }
else if (soundBin[0] == 'L' && soundBin[1] == 'Z' && soundBin[2] == '7' && soundBin[3] == '7')
if (soundBin[9] == 'R' && soundBin[10] == 'I' && soundBin[11] == 'F' && soundBin[12] == 'F')
else if (sourceSound[0] == 'L' && sourceSound[1] == 'Z' && sourceSound[2] == '7' && sourceSound[3] == '7')
if (sourceSound[9] == 'R' && sourceSound[10] == 'I' && sourceSound[11] == 'F' && sourceSound[12] == 'F')
{ cbSourceSound.Enabled = true; }
}
@ -133,16 +133,8 @@ namespace CustomizeMii
{
tbAudioFile.Text = "Internal Sound";
FileStream fs = new FileStream(CustomizeMii_Main.TempUnpackPath + "00000000.app_OUT\\meta\\sound.bin", FileMode.Open);
byte[] audio = new byte[fs.Length - 32];
int offset = 0;
fs.Seek(32, SeekOrigin.Begin);
fs.Read(audio, 0, audio.Length);
fs.Close();
if ((offset = Wii.Lz77.GetLz77Offset(audio)) != -1)
audio = Wii.Lz77.Decompress(audio, offset);
if (Lz77.IsLz77Compressed(sourceSound))
{ Lz77 l = new Lz77(); sourceSound = l.Decompress(sourceSound); }
foreach (Label thisLabel in gbWaveInfo.Controls)
if (thisLabel.Name.ToLower().Contains("value"))
@ -151,7 +143,7 @@ namespace CustomizeMii
thisLabel.Text = "Gathering";
}
bwGatherInfo.RunWorkerAsync(audio);
bwGatherInfo.RunWorkerAsync(sourceSound);
//this.Size = new System.Drawing.Size(510, 220);
this.Size = new System.Drawing.Size(gbWaveInfo.Location.X + gbWaveInfo.Size.Width + 15, this.Size.Height);
@ -258,15 +250,6 @@ namespace CustomizeMii
if (!cancelled)
this.Invoke(UpdateValues);
if (e.Argument is byte[])
{
byte[] audio = e.Argument as byte[];
using (FileStream fs = new FileStream(CustomizeMii_Main.TempWavePath, FileMode.Create))
{
fs.Write(audio, 0, audio.Length);
}
}
}
catch
{
@ -407,14 +390,7 @@ namespace CustomizeMii
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);
}
wave = new Wave(sourceSound);
}
else wave = new Wave(tbAudioFile.Text);

View File

@ -93,6 +93,7 @@ namespace CustomizeMii
this.tb1.Size = new System.Drawing.Size(311, 20);
this.tb1.TabIndex = 1;
this.tb1.Text = "SD:/apps/example/boot.dol";
this.tb1.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// cbImage43
//
@ -124,6 +125,7 @@ namespace CustomizeMii
this.tbImage43.Enabled = false;
this.tbImage43.Location = new System.Drawing.Point(94, 280);
this.tbImage43.Name = "tbImage43";
this.tbImage43.ReadOnly = true;
this.tbImage43.Size = new System.Drawing.Size(171, 20);
this.tbImage43.TabIndex = 4;
//
@ -133,6 +135,7 @@ namespace CustomizeMii
this.tbImage169.Enabled = false;
this.tbImage169.Location = new System.Drawing.Point(94, 309);
this.tbImage169.Name = "tbImage169";
this.tbImage169.ReadOnly = true;
this.tbImage169.Size = new System.Drawing.Size(171, 20);
this.tbImage169.TabIndex = 5;
//
@ -212,6 +215,7 @@ namespace CustomizeMii
this.tb2.Size = new System.Drawing.Size(311, 20);
this.tb2.TabIndex = 1;
this.tb2.Text = "SD:/apps/example/boot.elf";
this.tb2.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb3
//
@ -220,6 +224,7 @@ namespace CustomizeMii
this.tb3.Size = new System.Drawing.Size(311, 20);
this.tb3.TabIndex = 1;
this.tb3.Text = "USB:/apps/example/boot.dol";
this.tb3.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb4
//
@ -228,6 +233,7 @@ namespace CustomizeMii
this.tb4.Size = new System.Drawing.Size(311, 20);
this.tb4.TabIndex = 1;
this.tb4.Text = "USB:/apps/example/boot.elf";
this.tb4.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tabPaths
//
@ -288,6 +294,7 @@ namespace CustomizeMii
this.tb5.Name = "tb5";
this.tb5.Size = new System.Drawing.Size(311, 20);
this.tb5.TabIndex = 4;
this.tb5.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb6
//
@ -296,6 +303,7 @@ namespace CustomizeMii
this.tb6.Name = "tb6";
this.tb6.Size = new System.Drawing.Size(311, 20);
this.tb6.TabIndex = 5;
this.tb6.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb7
//
@ -304,6 +312,7 @@ namespace CustomizeMii
this.tb7.Name = "tb7";
this.tb7.Size = new System.Drawing.Size(311, 20);
this.tb7.TabIndex = 2;
this.tb7.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb8
//
@ -312,6 +321,7 @@ namespace CustomizeMii
this.tb8.Name = "tb8";
this.tb8.Size = new System.Drawing.Size(311, 20);
this.tb8.TabIndex = 3;
this.tb8.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tabOptional2
//
@ -346,6 +356,7 @@ namespace CustomizeMii
this.tb9.Name = "tb9";
this.tb9.Size = new System.Drawing.Size(311, 20);
this.tb9.TabIndex = 9;
this.tb9.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb10
//
@ -354,6 +365,7 @@ namespace CustomizeMii
this.tb10.Name = "tb10";
this.tb10.Size = new System.Drawing.Size(311, 20);
this.tb10.TabIndex = 10;
this.tb10.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb11
//
@ -362,6 +374,7 @@ namespace CustomizeMii
this.tb11.Name = "tb11";
this.tb11.Size = new System.Drawing.Size(311, 20);
this.tb11.TabIndex = 7;
this.tb11.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb12
//
@ -370,6 +383,7 @@ namespace CustomizeMii
this.tb12.Name = "tb12";
this.tb12.Size = new System.Drawing.Size(311, 20);
this.tb12.TabIndex = 8;
this.tb12.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tabOptional3
//
@ -404,6 +418,7 @@ namespace CustomizeMii
this.tb13.Name = "tb13";
this.tb13.Size = new System.Drawing.Size(311, 20);
this.tb13.TabIndex = 9;
this.tb13.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb14
//
@ -412,6 +427,7 @@ namespace CustomizeMii
this.tb14.Name = "tb14";
this.tb14.Size = new System.Drawing.Size(311, 20);
this.tb14.TabIndex = 10;
this.tb14.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb15
//
@ -420,6 +436,7 @@ namespace CustomizeMii
this.tb15.Name = "tb15";
this.tb15.Size = new System.Drawing.Size(311, 20);
this.tb15.TabIndex = 7;
this.tb15.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// tb16
//
@ -428,6 +445,7 @@ namespace CustomizeMii
this.tb16.Name = "tb16";
this.tb16.Size = new System.Drawing.Size(311, 20);
this.tb16.TabIndex = 8;
this.tb16.TextChanged += new System.EventHandler(this.tb_TextChanged);
//
// CustomizeMii_ComplexForwarder
//

View File

@ -152,5 +152,29 @@ namespace CustomizeMii
if (!cbPack3.Checked) thisTb.Text = string.Empty;
}
}
private void tb_TextChanged(object sender, EventArgs e)
{
TextBox tbSender = sender as TextBox;
int curPos = tbSender.SelectionStart;
if (tbSender.Text.Contains("\\"))
tbSender.Text = tbSender.Text.Replace("\\", "/");
if (tbSender.Text.Contains("sd:"))
tbSender.Text = tbSender.Text.Replace("sd:", "SD:");
if (tbSender.Text.Contains("usb:"))
tbSender.Text = tbSender.Text.Replace("usb:", "USB:");
if (tbSender.Text.Contains(".DOL"))
tbSender.Text = tbSender.Text.Replace(".DOL", ".dol");
if (tbSender.Text.Contains(".ELF"))
tbSender.Text = tbSender.Text.Replace(".ELF", ".elf");
tbSender.SelectionStart = curPos;
}
}
}

View File

@ -20,6 +20,7 @@ using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
using System.Collections.Generic;
using libWiiSharp;
namespace CustomizeMii
{
@ -42,7 +43,7 @@ namespace CustomizeMii
if (data.Length == 1 && data[0].ToLower().EndsWith(".wad"))
{
LoadChannel(data[0]);
loadChannel(data[0]);
}
}
@ -78,7 +79,7 @@ namespace CustomizeMii
data[0].ToLower().EndsWith("icon.bin") ||
data[0].ToLower().EndsWith("banner.bin")))
{
ReplacePart(data[0]);
replacePart(data[0]);
}
}
@ -101,44 +102,35 @@ namespace CustomizeMii
{
try
{
byte[] wad = Wii.Tools.LoadFileToByteArray(data[0]);
WAD tmpWad = WAD.Load(data[0]);
int numContents = Wii.WadInfo.GetContentNum(wad);
if (numContents == 3)
if (tmpWad.NumOfContents == 3)
{
int bootIndex = Wii.WadInfo.GetBootIndex(wad);
string appFile = string.Empty;
int appIndex = 0;
if (tmpWad.BootIndex == 1) appIndex = 2;
else if (tmpWad.BootIndex == 2) appIndex = 1;
if (bootIndex == 1)
{ appFile = "00000002.app"; }
else if (bootIndex == 2)
{ appFile = "00000001.app"; }
if (!string.IsNullOrEmpty(appFile))
if (appIndex > 0)
{
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]);
newDol = tmpWad.Contents[appIndex];
setControlText(tbDol, data[0]);
btnBrowseDol.Text = "Clear";
}
else
ErrorBox("The DOL file couldn't be found!");
else errorBox("The DOL file couldn't be found!");
}
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);
setControlText(tbDol, string.Empty);
btnBrowseDol.Text = "Browse...";
errorBox(ex.Message);
}
}
else if (data[0].ToLower().EndsWith(".dol"))
{
SetText(tbDol, data[0]);
newDol = File.ReadAllBytes(data[0]);
setControlText(tbDol, data[0]);
btnBrowseDol.Text = "Clear";
}
}
@ -149,7 +141,7 @@ namespace CustomizeMii
{
string[] data = (string[])e.Data.GetData(DataFormats.FileDrop);
if (File.Exists(Application.StartupPath + "\\lame.exe"))
if (File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "lame.exe"))
{
if (data.Length == 1 && (data[0].ToLower().EndsWith(".wav") ||
data[0].ToLower().EndsWith(".bns") ||
@ -171,20 +163,17 @@ namespace CustomizeMii
if (data[0].ToLower().EndsWith(".mp3"))
{
ConvertMp3ToWave(data[0]);
convertMp3ToWave(data[0]);
}
else
{
SetText(tbSound, data[0]);
replacedSound = data[0];
setControlText(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);
}
newSoundBin = Headers.IMD5.AddHeader(File.ReadAllBytes(data[0]));
if (cmbReplace.SelectedIndex == 2) setControlText(tbReplace, string.Empty);
}
}
@ -216,14 +205,14 @@ namespace CustomizeMii
{
try
{
AddTpl(lbxBannerTpls, thisFile);
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()))));
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()))));
}
}
@ -255,14 +244,14 @@ namespace CustomizeMii
{
try
{
AddTpl(lbxIconTpls, thisFile);
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()))));
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()))));
}
}
}

View File

@ -58,6 +58,12 @@ namespace CustomizeMii
Forwarder.Save(Destination, true);
}
public byte[] ToByteArray()
{
GXForwarder Forwarder = new GXForwarder(image43, image169, paths);
return Forwarder.ToByteArray();
}
public void Clear()
{
paths[0] = "SD:/apps/example/boot.dol";
@ -84,10 +90,7 @@ namespace CustomizeMii
public string AppFolder { get { return thisAppFolder; } set { thisAppFolder = value; } }
public bool ForwardToElf { get { return toElf; } set { toElf = value; } }
public Simple()
{
}
public Simple() { }
public void Save(string Destination)
{
@ -95,6 +98,12 @@ namespace CustomizeMii
Forwarder.Save(Destination, true);
}
public byte[] ToByteArray()
{
SDSDHC_Forwarder Forwarder = new SDSDHC_Forwarder(thisAppFolder, toElf);
return Forwarder.ToByteArray();
}
public void Clear()
{
thisAppFolder = string.Empty;

View File

@ -50,6 +50,7 @@ namespace CustomizeMii
this.btnOK = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.cbElf = new System.Windows.Forms.CheckBox();
this.tbInput2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// tbInput
@ -106,6 +107,14 @@ namespace CustomizeMii
this.cbElf.UseVisualStyleBackColor = true;
this.cbElf.Visible = false;
//
// tbInput2
//
this.tbInput2.Location = new System.Drawing.Point(121, 34);
this.tbInput2.Name = "tbInput2";
this.tbInput2.Size = new System.Drawing.Size(108, 20);
this.tbInput2.TabIndex = 1;
this.tbInput2.Visible = false;
//
// CustomizeMii_InputBox
//
this.AcceptButton = this.btnOK;
@ -114,6 +123,7 @@ namespace CustomizeMii
this.BackColor = System.Drawing.SystemColors.Control;
this.CancelButton = this.btnExit;
this.ClientSize = new System.Drawing.Size(238, 92);
this.Controls.Add(this.tbInput2);
this.Controls.Add(this.cbElf);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnOK);
@ -136,5 +146,6 @@ namespace CustomizeMii
public System.Windows.Forms.TextBox tbInput;
public System.Windows.Forms.Button btnExit;
public System.Windows.Forms.CheckBox cbElf;
public System.Windows.Forms.TextBox tbInput2;
}
}

View File

@ -16,22 +16,18 @@
*/
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
{
//Wow, need to change this whole thing, but too lazy ~~
public bool CommonKeyMode = true;
public string Input
{
get { return tbInput.Text; }
}
public string Input { get { return tbInput.Text; } set { tbInput.Text = value; } }
public string Description { get { return lbInfo.Text; } set { lbInfo.Text = value; } }
public string Input2 { get { return tbInput2.Text; } set { tbInput2.Text = value; } }
public CustomizeMii_InputBox()
{
@ -76,7 +72,7 @@ namespace CustomizeMii
}
else
{
if (tbInput.Text.Length > 2)
if (tbInput.Text.Length > 0)
{
this.DialogResult = DialogResult.OK;
this.Close();

View File

@ -86,7 +86,7 @@ namespace CustomizeMii
this.tabOptions = new System.Windows.Forms.TabPage();
this.btnOptionsExtract = new System.Windows.Forms.Button();
this.btnForwarder = new System.Windows.Forms.Button();
this.cbFailureChecks = new System.Windows.Forms.CheckBox();
this.cbSecurityChecksOff = new System.Windows.Forms.CheckBox();
this.cbLz77 = new System.Windows.Forms.CheckBox();
this.lbOptionsOptional = new System.Windows.Forms.Label();
this.btnBrowseSound = new System.Windows.Forms.Button();
@ -147,13 +147,15 @@ namespace CustomizeMii
this.tabInstructions = new System.Windows.Forms.TabPage();
this.rtbInstructions = new System.Windows.Forms.RichTextBox();
this.tabCredits = new System.Windows.Forms.TabPage();
this.lbLicense = new System.Windows.Forms.Label();
this.lbCreditInstaller = new System.Windows.Forms.Label();
this.panCredits = new System.Windows.Forms.Panel();
this.lbCreditThanks = new System.Windows.Forms.Label();
this.llbUpdateAvailable = new System.Windows.Forms.LinkLabel();
this.llbSite = new System.Windows.Forms.LinkLabel();
this.lbCreditVersion = new System.Windows.Forms.Label();
this.lbCreditInfo = new System.Windows.Forms.Label();
this.cmTpls = new System.Windows.Forms.ContextMenuStrip(this.components);
this.cmRename = new System.Windows.Forms.ToolStripMenuItem();
this.ssMain = new System.Windows.Forms.StatusStrip();
this.lbStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.lbStatusText = new System.Windows.Forms.ToolStripStatusLabel();
@ -181,6 +183,7 @@ namespace CustomizeMii
this.cmDol = new System.Windows.Forms.ContextMenuStrip(this.components);
this.cmLoadDol = new System.Windows.Forms.ToolStripMenuItem();
this.cmDolFromSource = new System.Windows.Forms.ToolStripMenuItem();
this.cmResize = new System.Windows.Forms.ToolStripMenuItem();
this.tabControl.SuspendLayout();
this.tabSource.SuspendLayout();
this.tabTitle.SuspendLayout();
@ -192,6 +195,7 @@ namespace CustomizeMii
this.tabInstructions.SuspendLayout();
this.tabCredits.SuspendLayout();
this.panCredits.SuspendLayout();
this.cmTpls.SuspendLayout();
this.ssMain.SuspendLayout();
this.cmForwarder.SuspendLayout();
this.cmOptionsExtract.SuspendLayout();
@ -595,7 +599,7 @@ namespace CustomizeMii
//
this.tabOptions.Controls.Add(this.btnOptionsExtract);
this.tabOptions.Controls.Add(this.btnForwarder);
this.tabOptions.Controls.Add(this.cbFailureChecks);
this.tabOptions.Controls.Add(this.cbSecurityChecksOff);
this.tabOptions.Controls.Add(this.cbLz77);
this.tabOptions.Controls.Add(this.lbOptionsOptional);
this.tabOptions.Controls.Add(this.btnBrowseSound);
@ -638,16 +642,16 @@ namespace CustomizeMii
this.btnForwarder.UseVisualStyleBackColor = true;
this.btnForwarder.Click += new System.EventHandler(this.btnForwarder_Click);
//
// cbFailureChecks
// cbSecurityChecksOff
//
this.cbFailureChecks.AutoSize = true;
this.cbFailureChecks.Location = new System.Drawing.Point(263, 180);
this.cbFailureChecks.Name = "cbFailureChecks";
this.cbFailureChecks.Size = new System.Drawing.Size(172, 17);
this.cbFailureChecks.TabIndex = 12;
this.cbFailureChecks.Tag = "Independent";
this.cbFailureChecks.Text = "/!\\ Turn off security checks /!\\";
this.cbFailureChecks.UseVisualStyleBackColor = true;
this.cbSecurityChecksOff.AutoSize = true;
this.cbSecurityChecksOff.Location = new System.Drawing.Point(263, 180);
this.cbSecurityChecksOff.Name = "cbSecurityChecksOff";
this.cbSecurityChecksOff.Size = new System.Drawing.Size(172, 17);
this.cbSecurityChecksOff.TabIndex = 12;
this.cbSecurityChecksOff.Tag = "Independent";
this.cbSecurityChecksOff.Text = "/!\\ Turn off security checks /!\\";
this.cbSecurityChecksOff.UseVisualStyleBackColor = true;
//
// cbLz77
//
@ -922,6 +926,7 @@ namespace CustomizeMii
this.lbxBannerTpls.Size = new System.Drawing.Size(343, 173);
this.lbxBannerTpls.Sorted = true;
this.lbxBannerTpls.TabIndex = 0;
this.lbxBannerTpls.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lbxBannerTpls_MouseUp);
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);
@ -1057,6 +1062,7 @@ namespace CustomizeMii
this.lbxIconTpls.Size = new System.Drawing.Size(343, 173);
this.lbxIconTpls.Sorted = true;
this.lbxIconTpls.TabIndex = 6;
this.lbxIconTpls.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lbxIconTpls_MouseUp);
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);
@ -1308,12 +1314,12 @@ namespace CustomizeMii
//
// tabCredits
//
this.tabCredits.Controls.Add(this.lbLicense);
this.tabCredits.Controls.Add(this.lbCreditInstaller);
this.tabCredits.Controls.Add(this.panCredits);
this.tabCredits.Controls.Add(this.llbUpdateAvailable);
this.tabCredits.Controls.Add(this.llbSite);
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);
@ -1322,6 +1328,16 @@ namespace CustomizeMii
this.tabCredits.Text = "About";
this.tabCredits.UseVisualStyleBackColor = true;
//
// lbLicense
//
this.lbLicense.Location = new System.Drawing.Point(0, 92);
this.lbLicense.Name = "lbLicense";
this.lbLicense.Size = new System.Drawing.Size(443, 30);
this.lbLicense.TabIndex = 8;
this.lbLicense.Text = "CustomizeMii is licensed under the terms of the GNU General Public License v3,\r\ns" +
"ee License.txt for more information!";
this.lbLicense.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// lbCreditInstaller
//
this.lbCreditInstaller.Location = new System.Drawing.Point(0, 28);
@ -1335,7 +1351,7 @@ namespace CustomizeMii
//
this.panCredits.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panCredits.Controls.Add(this.lbCreditThanks);
this.panCredits.Location = new System.Drawing.Point(0, 94);
this.panCredits.Location = new System.Drawing.Point(0, 125);
this.panCredits.Name = "panCredits";
this.panCredits.Size = new System.Drawing.Size(443, 79);
this.panCredits.TabIndex = 5;
@ -1383,15 +1399,20 @@ namespace CustomizeMii
this.lbCreditVersion.Text = "CustomizeMii Version X by Leathl";
this.lbCreditVersion.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// lbCreditInfo
// cmTpls
//
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;
this.cmTpls.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cmRename,
this.cmResize});
this.cmTpls.Name = "cmTpls";
this.cmTpls.Size = new System.Drawing.Size(153, 70);
//
// cmRename
//
this.cmRename.Name = "cmRename";
this.cmRename.Size = new System.Drawing.Size(117, 22);
this.cmRename.Text = "Rename";
this.cmRename.Click += new System.EventHandler(this.cmRename_Click);
//
// ssMain
//
@ -1603,6 +1624,13 @@ namespace CustomizeMii
this.cmDolFromSource.Text = "Take From Source WAD";
this.cmDolFromSource.Click += new System.EventHandler(this.cmDolFromSource_Click);
//
// cmResize
//
this.cmResize.Name = "cmResize";
this.cmResize.Size = new System.Drawing.Size(152, 22);
this.cmResize.Text = "Resize";
this.cmResize.Click += new System.EventHandler(this.cmResize_Click);
//
// CustomizeMii_Main
//
this.AllowDrop = true;
@ -1639,6 +1667,7 @@ namespace CustomizeMii
this.tabInstructions.ResumeLayout(false);
this.tabCredits.ResumeLayout(false);
this.panCredits.ResumeLayout(false);
this.cmTpls.ResumeLayout(false);
this.ssMain.ResumeLayout(false);
this.ssMain.PerformLayout();
this.cmForwarder.ResumeLayout(false);
@ -1707,7 +1736,6 @@ namespace CustomizeMii
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;
@ -1749,7 +1777,7 @@ namespace CustomizeMii
private System.Windows.Forms.CheckBox cbIconMakeTransparent;
private System.Windows.Forms.TabPage tabInstructions;
private System.Windows.Forms.RichTextBox rtbInstructions;
private System.Windows.Forms.CheckBox cbFailureChecks;
private System.Windows.Forms.CheckBox cbSecurityChecksOff;
private System.Windows.Forms.Button btnForwarder;
private System.Windows.Forms.ContextMenuStrip cmForwarder;
private System.Windows.Forms.ToolStripMenuItem cmSimpleForwarder;
@ -1786,6 +1814,10 @@ namespace CustomizeMii
private System.Windows.Forms.Label lbKorean;
private System.Windows.Forms.LinkLabel llbBannerMultiReplace;
private System.Windows.Forms.LinkLabel llbIconMultiReplace;
private System.Windows.Forms.Label lbLicense;
private System.Windows.Forms.ContextMenuStrip cmTpls;
private System.Windows.Forms.ToolStripMenuItem cmRename;
private System.Windows.Forms.ToolStripMenuItem cmResize;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -127,8 +127,12 @@ SquidMan for Zetsubou
Andre Perrot for gbalzss
comex and Waninkoko for both their NAND Loader
djdynamite123 for his forwarder base files
The USB Loader GX Team for their forwarder source</value>
The USB Loader GX Team for their forwarder source
wilsoff for helping me debugging 3.0</value>
</data>
<metadata name="cmTpls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>566, 7</value>
</metadata>
<metadata name="ssMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>16, 7</value>
</metadata>

View File

@ -47,6 +47,7 @@ namespace CustomizeMii
{
this.components = new System.ComponentModel.Container();
this.Panel = new System.Windows.Forms.Panel();
this.cbCheckerBoard = new System.Windows.Forms.CheckBox();
this.btnReplace = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.cbIcon = new System.Windows.Forms.ComboBox();
@ -67,6 +68,15 @@ namespace CustomizeMii
this.cmIA4 = new System.Windows.Forms.ToolStripMenuItem();
this.cmI8 = new System.Windows.Forms.ToolStripMenuItem();
this.cmI4 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.cmChangeFormat = new System.Windows.Forms.ToolStripMenuItem();
this.cmToRGBA8 = new System.Windows.Forms.ToolStripMenuItem();
this.cmToRGB565 = new System.Windows.Forms.ToolStripMenuItem();
this.cmToRGB5A3 = new System.Windows.Forms.ToolStripMenuItem();
this.cmToIA8 = new System.Windows.Forms.ToolStripMenuItem();
this.cmToIA4 = new System.Windows.Forms.ToolStripMenuItem();
this.cmToI8 = new System.Windows.Forms.ToolStripMenuItem();
this.cmToI4 = new System.Windows.Forms.ToolStripMenuItem();
this.lbNoPreview = new System.Windows.Forms.Label();
this.Panel.SuspendLayout();
this.panel1.SuspendLayout();
@ -76,6 +86,7 @@ namespace CustomizeMii
//
// Panel
//
this.Panel.Controls.Add(this.cbCheckerBoard);
this.Panel.Controls.Add(this.btnReplace);
this.Panel.Controls.Add(this.btnClose);
this.Panel.Controls.Add(this.cbIcon);
@ -88,10 +99,24 @@ namespace CustomizeMii
this.Panel.Size = new System.Drawing.Size(817, 28);
this.Panel.TabIndex = 0;
//
// cbCheckerBoard
//
this.cbCheckerBoard.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.cbCheckerBoard.AutoSize = true;
this.cbCheckerBoard.Checked = true;
this.cbCheckerBoard.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbCheckerBoard.Location = new System.Drawing.Point(390, 7);
this.cbCheckerBoard.Name = "cbCheckerBoard";
this.cbCheckerBoard.Size = new System.Drawing.Size(93, 17);
this.cbCheckerBoard.TabIndex = 4;
this.cbCheckerBoard.Text = "Checkerboard";
this.cbCheckerBoard.UseVisualStyleBackColor = true;
this.cbCheckerBoard.CheckedChanged += new System.EventHandler(this.cbCheckerBoard_CheckedChanged);
//
// btnReplace
//
this.btnReplace.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnReplace.Location = new System.Drawing.Point(512, 4);
this.btnReplace.Location = new System.Drawing.Point(513, 4);
this.btnReplace.Name = "btnReplace";
this.btnReplace.Size = new System.Drawing.Size(137, 21);
this.btnReplace.TabIndex = 3;
@ -116,7 +141,7 @@ namespace CustomizeMii
this.cbIcon.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.cbIcon.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbIcon.FormattingEnabled = true;
this.cbIcon.Location = new System.Drawing.Point(239, 4);
this.cbIcon.Location = new System.Drawing.Point(234, 4);
this.cbIcon.MaxDropDownItems = 20;
this.cbIcon.Name = "cbIcon";
this.cbIcon.Size = new System.Drawing.Size(121, 21);
@ -127,7 +152,7 @@ namespace CustomizeMii
//
this.lbIcon.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lbIcon.AutoSize = true;
this.lbIcon.Location = new System.Drawing.Point(203, 7);
this.lbIcon.Location = new System.Drawing.Point(198, 7);
this.lbIcon.Name = "lbIcon";
this.lbIcon.Size = new System.Drawing.Size(31, 13);
this.lbIcon.TabIndex = 2;
@ -208,6 +233,7 @@ namespace CustomizeMii
//
// pbPic
//
this.pbPic.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.pbPic.Dock = System.Windows.Forms.DockStyle.Fill;
this.pbPic.Location = new System.Drawing.Point(0, 22);
this.pbPic.Name = "pbPic";
@ -225,9 +251,11 @@ namespace CustomizeMii
this.cmIA8,
this.cmIA4,
this.cmI8,
this.cmI4});
this.cmI4,
this.toolStripSeparator1,
this.cmChangeFormat});
this.cmFormat.Name = "cmFormat";
this.cmFormat.Size = new System.Drawing.Size(234, 158);
this.cmFormat.Size = new System.Drawing.Size(234, 186);
//
// cmRGBA8
//
@ -285,6 +313,81 @@ namespace CustomizeMii
this.cmI4.Text = "As I4 (B/W)";
this.cmI4.Click += new System.EventHandler(this.cmFormat_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(230, 6);
//
// cmChangeFormat
//
this.cmChangeFormat.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cmToRGBA8,
this.cmToRGB565,
this.cmToRGB5A3,
this.cmToIA8,
this.cmToIA4,
this.cmToI8,
this.cmToI4});
this.cmChangeFormat.Name = "cmChangeFormat";
this.cmChangeFormat.Size = new System.Drawing.Size(233, 22);
this.cmChangeFormat.Text = "Change Format";
//
// cmToRGBA8
//
this.cmToRGBA8.Name = "cmToRGBA8";
this.cmToRGBA8.Size = new System.Drawing.Size(234, 22);
this.cmToRGBA8.Tag = "rgba8";
this.cmToRGBA8.Text = "To RGBA8 (High Quality)";
this.cmToRGBA8.Click += new System.EventHandler(this.cmChangeFormat_Click);
//
// cmToRGB565
//
this.cmToRGB565.Name = "cmToRGB565";
this.cmToRGB565.Size = new System.Drawing.Size(234, 22);
this.cmToRGB565.Tag = "rgb565";
this.cmToRGB565.Text = "To RGB565 (Moderate Quality)";
this.cmToRGB565.Click += new System.EventHandler(this.cmChangeFormat_Click);
//
// cmToRGB5A3
//
this.cmToRGB5A3.Name = "cmToRGB5A3";
this.cmToRGB5A3.Size = new System.Drawing.Size(234, 22);
this.cmToRGB5A3.Tag = "rgb5a3";
this.cmToRGB5A3.Text = "To RGB5A3 (Low Quality)";
this.cmToRGB5A3.Click += new System.EventHandler(this.cmChangeFormat_Click);
//
// cmToIA8
//
this.cmToIA8.Name = "cmToIA8";
this.cmToIA8.Size = new System.Drawing.Size(234, 22);
this.cmToIA8.Tag = "ia8";
this.cmToIA8.Text = "To IA8 (B/W with Alpha)";
this.cmToIA8.Click += new System.EventHandler(this.cmChangeFormat_Click);
//
// cmToIA4
//
this.cmToIA4.Name = "cmToIA4";
this.cmToIA4.Size = new System.Drawing.Size(234, 22);
this.cmToIA4.Tag = "ia4";
this.cmToIA4.Text = "To IA4 (B/W with Alpha)";
this.cmToIA4.Click += new System.EventHandler(this.cmChangeFormat_Click);
//
// cmToI8
//
this.cmToI8.Name = "cmToI8";
this.cmToI8.Size = new System.Drawing.Size(234, 22);
this.cmToI8.Tag = "i8";
this.cmToI8.Text = "To I8 (B/W)";
this.cmToI8.Click += new System.EventHandler(this.cmChangeFormat_Click);
//
// cmToI4
//
this.cmToI4.Name = "cmToI4";
this.cmToI4.Size = new System.Drawing.Size(234, 22);
this.cmToI4.Tag = "i4";
this.cmToI4.Text = "To I4 (B/W)";
this.cmToI4.Click += new System.EventHandler(this.cmChangeFormat_Click);
//
// lbNoPreview
//
this.lbNoPreview.Dock = System.Windows.Forms.DockStyle.Fill;
@ -347,5 +450,15 @@ namespace CustomizeMii
private System.Windows.Forms.ToolStripMenuItem cmI8;
private System.Windows.Forms.ToolStripMenuItem cmI4;
private System.Windows.Forms.Label lbNoPreview;
private System.Windows.Forms.ToolStripMenuItem cmChangeFormat;
private System.Windows.Forms.ToolStripMenuItem cmToRGBA8;
private System.Windows.Forms.ToolStripMenuItem cmToRGB565;
private System.Windows.Forms.ToolStripMenuItem cmToRGB5A3;
private System.Windows.Forms.ToolStripMenuItem cmToIA8;
private System.Windows.Forms.ToolStripMenuItem cmToIA4;
private System.Windows.Forms.ToolStripMenuItem cmToI8;
private System.Windows.Forms.ToolStripMenuItem cmToI4;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.CheckBox cbCheckerBoard;
}
}

View File

@ -16,17 +16,25 @@
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using libWiiSharp;
namespace CustomizeMii
{
public partial class CustomizeMii_Preview : Form
{
public string startTPL;
public bool startIcon = false;
private TplImage[,] images;
private TplImage[][] images = new TplImage[2][];
private U8 bannerBin;
private U8 iconBin;
private string startTPL;
private bool startIcon = false;
public U8 BannerBin { get { return bannerBin; } set { bannerBin = value; } }
public U8 IconBin { get { return iconBin; } set { iconBin = value; } }
public string StartTPL { get { return startTPL; } set { startTPL = value; } }
public bool StartIcon { get { return startIcon; } set { startIcon = value; } }
public CustomizeMii_Preview()
{
@ -49,51 +57,67 @@ namespace CustomizeMii
private void Preview_Load(object sender, EventArgs e)
{
this.CenterToParent();
string[] bannerpics;
string[] iconpics;
if (string.IsNullOrEmpty(CustomizeMii_Main.BannerReplace))
bannerpics = Directory.GetFiles(CustomizeMii_Main.TempUnpackBannerTplPath, "*.tpl");
else bannerpics = Directory.GetFiles(CustomizeMii_Main.BannerTplPath, "*.tpl");
if (string.IsNullOrEmpty(CustomizeMii_Main.IconReplace))
iconpics = Directory.GetFiles(CustomizeMii_Main.TempUnpackIconTplPath, "*.tpl");
else iconpics = Directory.GetFiles(CustomizeMii_Main.IconTplPath, "*.tpl");
cbBanner.Items.Clear();
cbIcon.Items.Clear();
int startIndex = -1;
List<TplImage> bannerImages = new List<TplImage>();
List<TplImage> iconImages = new List<TplImage>();
for (int i = 0; i < bannerBin.NumOfNodes; i++)
{
if (bannerBin.StringTable[i].ToLower().EndsWith(".tpl"))
{
TplImage tmpImage = new TplImage();
TPL tmpTpl = TPL.Load(bannerBin.Data[i]);
if (i == 10) { }
tmpImage.fileName = bannerBin.StringTable[i];
tmpImage.tplFormat = tmpTpl.GetTextureFormat(0).ToString();
tmpImage.tplImage = tmpTpl.ExtractTexture();
tmpImage.checkerBoard = createCheckerBoard(tmpImage.tplImage.Width, tmpImage.tplImage.Height);
bannerImages.Add(tmpImage);
}
}
for (int i = 0; i < iconBin.NumOfNodes; i++)
{
if (iconBin.StringTable[i].ToLower().EndsWith(".tpl"))
{
TplImage tmpImage = new TplImage();
TPL tmpTpl = TPL.Load(iconBin.Data[i]);
tmpImage.fileName = iconBin.StringTable[i];
tmpImage.tplFormat = tmpTpl.GetTextureFormat(0).ToString();
tmpImage.tplImage = tmpTpl.ExtractTexture();
tmpImage.checkerBoard = createCheckerBoard(tmpImage.tplImage.Width, tmpImage.tplImage.Height);
iconImages.Add(tmpImage);
}
}
images[0] = bannerImages.ToArray();
images[1] = iconImages.ToArray();
for (int i = 0; i < images[0].Length; i++)
{
cbBanner.Items.Add(images[0][i].fileName);
if (!startIcon)
{
for (int i = 0; i < bannerpics.Length; i++)
if (Path.GetFileName(bannerpics[i]) == startTPL)
startIndex = i;
}
else
{
for (int i = 0; i < iconpics.Length; i++)
if (Path.GetFileName(iconpics[i]) == startTPL)
if (images[0][i].fileName.ToLower() == startTPL.ToLower())
startIndex = i;
}
foreach (string thispic in bannerpics)
for (int i = 0; i < images[1].Length; i++)
{
string picname = thispic.Remove(0, thispic.LastIndexOf('\\') + 1);
picname = picname.Remove(picname.LastIndexOf('.'));
cbBanner.Items.Add((object)picname);
cbIcon.Items.Add(images[1][i].fileName);
if (startIcon)
if (images[1][i].fileName.ToLower() == startTPL.ToLower())
startIndex = i;
}
foreach (string thispic in iconpics)
{
string picname = thispic.Remove(0, thispic.LastIndexOf('\\') + 1);
picname = picname.Remove(picname.LastIndexOf('.'));
cbIcon.Items.Add((object)picname);
}
if (bannerpics.Length > iconpics.Length)
images = new TplImage[2, bannerpics.Length];
else
images = new TplImage[2, iconpics.Length];
try
{
if (startIndex != -1)
@ -112,44 +136,11 @@ namespace CustomizeMii
{
if (cbBanner.SelectedIndex != -1)
{
if (images[0, cbBanner.SelectedIndex].tplImage == null)
{
byte[] tpl;
pbPic.Image = images[0][cbBanner.SelectedIndex].tplImage;
lbFormat.Text = images[0][cbBanner.SelectedIndex].tplFormat;
lbSize.Text = string.Format("{0} x {1}", images[0][cbBanner.SelectedIndex].tplImage.Width, images[0][cbBanner.SelectedIndex].tplImage.Height);
if (string.IsNullOrEmpty(CustomizeMii_Main.BannerReplace))
tpl = Wii.Tools.LoadFileToByteArray(CustomizeMii_Main.TempUnpackBannerTplPath + cbBanner.SelectedItem.ToString() + ".tpl");
else tpl = Wii.Tools.LoadFileToByteArray(CustomizeMii_Main.BannerTplPath + cbBanner.SelectedItem.ToString() + ".tpl");
lbSize.Text = Wii.TPL.GetTextureWidth(tpl).ToString() + " x " + Wii.TPL.GetTextureHeight(tpl).ToString();
images[0, cbBanner.SelectedIndex].tplFormat = Wii.TPL.GetTextureFormatName(tpl);
lbFormat.Text = images[0, cbBanner.SelectedIndex].tplFormat;
if (images[0, cbBanner.SelectedIndex].tplFormat.ToLower() == "ci4" ||
images[0, cbBanner.SelectedIndex].tplFormat.ToLower() == "ci8" ||
images[0, cbBanner.SelectedIndex].tplFormat.ToLower() == "ci14x2")
{
int tempW = Wii.TPL.GetTextureWidth(tpl);
int tempH = Wii.TPL.GetTextureHeight(tpl);
images[0, cbBanner.SelectedIndex].tplImage = new Bitmap(tempW, tempH);
}
else
{
images[0, cbBanner.SelectedIndex].tplImage = Wii.TPL.ConvertFromTPL(tpl);
}
tpl = null;
}
pbPic.Image = images[0, cbBanner.SelectedIndex].tplImage;
lbFormat.Text = images[0, cbBanner.SelectedIndex].tplFormat;
lbSize.Text = string.Format("{0} x {1}", images[0, cbBanner.SelectedIndex].tplImage.Width, images[0, cbBanner.SelectedIndex].tplImage.Height);
if (images[0, cbBanner.SelectedIndex].tplFormat.ToLower() == "ci4" ||
images[0, cbBanner.SelectedIndex].tplFormat.ToLower() == "ci8" ||
images[0, cbBanner.SelectedIndex].tplFormat.ToLower() == "ci14x2")
lbNoPreview.Visible = true;
else lbNoPreview.Visible = false;
if (cbCheckerBoard.Checked) pbPic.BackgroundImage = images[0][cbBanner.SelectedIndex].checkerBoard;
cbIcon.SelectedIndex = -1;
}
@ -159,68 +150,61 @@ namespace CustomizeMii
{
if (cbIcon.SelectedIndex != -1)
{
if (images[1, cbIcon.SelectedIndex].tplImage == null)
{
byte[] tpl;
pbPic.Image = images[1][cbIcon.SelectedIndex].tplImage;
lbFormat.Text = images[1][cbIcon.SelectedIndex].tplFormat;
lbSize.Text = string.Format("{0} x {1}", images[1][cbIcon.SelectedIndex].tplImage.Width, images[1][cbIcon.SelectedIndex].tplImage.Height);
if (string.IsNullOrEmpty(CustomizeMii_Main.IconReplace))
tpl = Wii.Tools.LoadFileToByteArray(CustomizeMii_Main.TempUnpackIconTplPath + cbIcon.SelectedItem.ToString() + ".tpl");
else tpl = Wii.Tools.LoadFileToByteArray(CustomizeMii_Main.IconTplPath + cbIcon.SelectedItem.ToString() + ".tpl");
lbSize.Text = Wii.TPL.GetTextureWidth(tpl).ToString() + " x " + Wii.TPL.GetTextureHeight(tpl).ToString();
images[1, cbIcon.SelectedIndex].tplFormat = Wii.TPL.GetTextureFormatName(tpl);
lbFormat.Text = images[1, cbIcon.SelectedIndex].tplFormat;
if (images[1, cbIcon.SelectedIndex].tplFormat.ToLower() == "ci4" ||
images[1, cbIcon.SelectedIndex].tplFormat.ToLower() == "ci8" ||
images[1, cbIcon.SelectedIndex].tplFormat.ToLower() == "ci14x2")
{
int tempW = Wii.TPL.GetTextureWidth(tpl);
int tempH = Wii.TPL.GetTextureHeight(tpl);
images[1, cbIcon.SelectedIndex].tplImage = new Bitmap(tempW, tempH);
}
else
{
images[1, cbIcon.SelectedIndex].tplImage = Wii.TPL.ConvertFromTPL(tpl);
}
tpl = null;
}
pbPic.Image = images[1, cbIcon.SelectedIndex].tplImage;
lbFormat.Text = images[1, cbIcon.SelectedIndex].tplFormat;
lbSize.Text = string.Format("{0} x {1}", images[1, cbIcon.SelectedIndex].tplImage.Width, images[1, cbIcon.SelectedIndex].tplImage.Height);
if (images[1, cbIcon.SelectedIndex].tplFormat.ToLower() == "ci4" ||
images[1, cbIcon.SelectedIndex].tplFormat.ToLower() == "ci8" ||
images[1, cbIcon.SelectedIndex].tplFormat.ToLower() == "ci14x2")
lbNoPreview.Visible = true;
else lbNoPreview.Visible = false;
if (cbCheckerBoard.Checked) pbPic.BackgroundImage = images[1][cbIcon.SelectedIndex].checkerBoard;
cbBanner.SelectedIndex = -1;
}
}
private void cmSave_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = pbPic.ImageLocation.Remove(0, pbPic.ImageLocation.LastIndexOf('\\') + 1);
sfd.Filter = "PNG|*.png";
if (sfd.ShowDialog() == DialogResult.OK)
File.Copy(pbPic.ImageLocation, sfd.FileName);
}
private Image ResizeImage(Image img, int x, int y)
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 Image createCheckerBoard(int w, int h)
{
Color darkColor = Color.DarkGray;
Color lightColor = Color.White;
int tileSize = 10;
Bitmap img = new Bitmap(w, h);
using (Graphics g = Graphics.FromImage(img))
{
g.Clear(lightColor);
for (int col = 0; col < w; col += tileSize)
{
for (int row = 0; row < h; row += tileSize)
{
Color curColor;
if ((col / tileSize) % 2 == 0)
curColor = (row / tileSize) % 2 == 0 ? darkColor : lightColor;
else
curColor = (row / tileSize) % 2 == 0 ? lightColor : darkColor;
if (curColor == lightColor) continue;
Rectangle rect = new Rectangle(col, row, tileSize, tileSize);
g.FillRectangle(new SolidBrush(darkColor), rect);
}
}
}
return (Image)img;
}
private void btnReplace_Click(object sender, EventArgs e)
{
cmFormat.Show(MousePosition);
@ -236,79 +220,83 @@ namespace CustomizeMii
{
try
{
string Tpl;
string tplName;
TPL tmpTpl = new TPL();
Image newImg;
if (cbBanner.SelectedIndex != -1) { Tpl = CustomizeMii_Main.BannerTplPath + cbBanner.SelectedItem + ".tpl"; }
else { Tpl = CustomizeMii_Main.IconTplPath + cbIcon.SelectedItem + ".tpl"; }
byte[] TplArray = Wii.Tools.LoadFileToByteArray(Tpl);
Image Img;
if (!ofd.FileName.ToLower().EndsWith(".tpl")) Img = Image.FromFile(ofd.FileName);
else Img = Wii.TPL.ConvertFromTPL(ofd.FileName);
int TplFormat;
int X = Wii.TPL.GetTextureWidth(TplArray);
int Y = Wii.TPL.GetTextureHeight(TplArray);
if (X != Img.Width ||
Y != Img.Height)
if (cbIcon.SelectedIndex == -1)
{
Img = ResizeImage(Img, X, Y);
tplName = cbBanner.SelectedItem.ToString().ToLower();
tmpTpl.LoadFile(bannerBin.Data[bannerBin.GetNodeIndex(tplName)]);
}
else
{
tplName = cbIcon.SelectedItem.ToString().ToLower();
tmpTpl.LoadFile(iconBin.Data[iconBin.GetNodeIndex(tplName)]);
}
if (!ofd.FileName.ToLower().EndsWith(".tpl")) newImg = Image.FromFile(ofd.FileName);
else
{
TPL newTpl = TPL.Load(ofd.FileName);
newImg = newTpl.ExtractTexture();
}
Size tplSize = tmpTpl.GetTextureSize(0);
TPL_Format tplFormat;
if (newImg.Width != tplSize.Width ||
newImg.Height != tplSize.Height)
newImg = resizeImage(newImg, tplSize.Width, tplSize.Height);
ToolStripMenuItem cmSender = sender as ToolStripMenuItem;
switch (cmSender.Tag.ToString().ToLower())
{
case "i4":
TplFormat = 0;
lbFormat.Text = "I4";
tplFormat = TPL_Format.I4;
break;
case "i8":
TplFormat = 1;
lbFormat.Text = "I8";
tplFormat = TPL_Format.I8;
break;
case "ia4":
TplFormat = 2;
lbFormat.Text = "IA4";
tplFormat = TPL_Format.IA4;
break;
case "ia8":
TplFormat = 3;
lbFormat.Text = "IA8";
tplFormat = TPL_Format.IA8;
break;
case "rgb565":
TplFormat = 4;
lbFormat.Text = "RGB565";
tplFormat = TPL_Format.RGB565;
break;
case "rgb5a3":
TplFormat = 5;
lbFormat.Text = "RGB5A3";
tplFormat = TPL_Format.RGB5A3;
break;
default:
TplFormat = 6;
lbFormat.Text = "RGBA8";
tplFormat = TPL_Format.RGBA8;
break;
}
Wii.TPL.ConvertToTPL(Img, Tpl, TplFormat);
tmpTpl.RemoveTexture(0);
tmpTpl.AddTexture(newImg, tplFormat);
if (cbBanner.SelectedIndex != -1)
{
images[0, cbBanner.SelectedIndex].tplImage = Wii.TPL.ConvertFromTPL(Tpl);
images[0, cbBanner.SelectedIndex].tplFormat = Wii.TPL.GetTextureFormatName(File.ReadAllBytes(Tpl));
bannerBin.ReplaceFile(bannerBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
images[0][cbBanner.SelectedIndex].tplImage = tmpTpl.ExtractTexture();
images[0][cbBanner.SelectedIndex].tplFormat = tmpTpl.GetTextureFormat(0).ToString();
pbPic.Image = images[0, cbBanner.SelectedIndex].tplImage;
lbFormat.Text = images[0, cbBanner.SelectedIndex].tplFormat;
lbSize.Text = string.Format("{0} x {1}", images[0, cbBanner.SelectedIndex].tplImage.Width, images[0, cbBanner.SelectedIndex].tplImage.Height);
pbPic.Image = images[0][cbBanner.SelectedIndex].tplImage;
lbFormat.Text = images[0][cbBanner.SelectedIndex].tplFormat;
lbSize.Text = string.Format("{0} x {1}", images[0][cbBanner.SelectedIndex].tplImage.Width, images[0][cbBanner.SelectedIndex].tplImage.Height);
}
else
{
images[1, cbIcon.SelectedIndex].tplImage = Wii.TPL.ConvertFromTPL(Tpl);
images[1, cbIcon.SelectedIndex].tplFormat = Wii.TPL.GetTextureFormatName(File.ReadAllBytes(Tpl));
iconBin.ReplaceFile(iconBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
images[1][cbIcon.SelectedIndex].tplImage = tmpTpl.ExtractTexture();
images[1][cbIcon.SelectedIndex].tplFormat = tmpTpl.GetTextureFormat(0).ToString();
pbPic.Image = images[1, cbIcon.SelectedIndex].tplImage;
lbFormat.Text = images[1, cbIcon.SelectedIndex].tplFormat;
lbSize.Text = string.Format("{0} x {1}", images[1, cbIcon.SelectedIndex].tplImage.Width, images[1, cbIcon.SelectedIndex].tplImage.Height);
pbPic.Image = images[1][cbIcon.SelectedIndex].tplImage;
lbFormat.Text = images[1][cbIcon.SelectedIndex].tplFormat;
lbSize.Text = string.Format("{0} x {1}", images[1][cbIcon.SelectedIndex].tplImage.Width, images[1][cbIcon.SelectedIndex].tplImage.Height);
}
if (cbBanner.SelectedIndex != -1) cbBanner.Select();
@ -318,5 +306,104 @@ namespace CustomizeMii
{ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
}
private void cmChangeFormat_Click(object sender, EventArgs e)
{
try
{
string tplName;
TPL tmpTpl = new TPL();
Image newImg;
if (cbIcon.SelectedIndex == -1)
{
tplName = cbBanner.SelectedItem.ToString().ToLower();
tmpTpl.LoadFile(bannerBin.Data[bannerBin.GetNodeIndex(tplName)]);
}
else
{
tplName = cbIcon.SelectedItem.ToString().ToLower();
tmpTpl.LoadFile(iconBin.Data[iconBin.GetNodeIndex(tplName)]);
}
newImg = tmpTpl.ExtractTexture();
TPL_Format tplFormat;
ToolStripMenuItem cmSender = sender as ToolStripMenuItem;
switch (cmSender.Tag.ToString().ToLower())
{
case "i4":
tplFormat = TPL_Format.I4;
break;
case "i8":
tplFormat = TPL_Format.I8;
break;
case "ia4":
tplFormat = TPL_Format.IA4;
break;
case "ia8":
tplFormat = TPL_Format.IA8;
break;
case "rgb565":
tplFormat = TPL_Format.RGB565;
break;
case "rgb5a3":
tplFormat = TPL_Format.RGB5A3;
break;
default:
tplFormat = TPL_Format.RGBA8;
break;
}
if (tmpTpl.GetTextureFormat(0) == tplFormat) return;
tmpTpl.RemoveTexture(0);
tmpTpl.AddTexture(newImg, tplFormat);
if (cbBanner.SelectedIndex != -1)
{
bannerBin.ReplaceFile(bannerBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
images[0][cbBanner.SelectedIndex].tplImage = tmpTpl.ExtractTexture();
images[0][cbBanner.SelectedIndex].tplFormat = tmpTpl.GetTextureFormat(0).ToString();
pbPic.Image = images[0][cbBanner.SelectedIndex].tplImage;
lbFormat.Text = images[0][cbBanner.SelectedIndex].tplFormat;
lbSize.Text = string.Format("{0} x {1}", images[0][cbBanner.SelectedIndex].tplImage.Width, images[0][cbBanner.SelectedIndex].tplImage.Height);
}
else
{
iconBin.ReplaceFile(iconBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
images[1][cbIcon.SelectedIndex].tplImage = tmpTpl.ExtractTexture();
images[1][cbIcon.SelectedIndex].tplFormat = tmpTpl.GetTextureFormat(0).ToString();
pbPic.Image = images[1][cbIcon.SelectedIndex].tplImage;
lbFormat.Text = images[1][cbIcon.SelectedIndex].tplFormat;
lbSize.Text = string.Format("{0} x {1}", images[1][cbIcon.SelectedIndex].tplImage.Width, images[1][cbIcon.SelectedIndex].tplImage.Height);
}
if (cbBanner.SelectedIndex != -1) cbBanner.Select();
else if (cbIcon.SelectedIndex != -1) cbIcon.Select();
}
catch (Exception ex)
{ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
private void cbCheckerBoard_CheckedChanged(object sender, EventArgs e)
{
if (cbCheckerBoard.Checked)
{
if (cbBanner.SelectedIndex != -1)
pbPic.BackgroundImage = images[0][cbBanner.SelectedIndex].checkerBoard;
else
pbPic.BackgroundImage = images[1][cbIcon.SelectedIndex].checkerBoard;
}
else pbPic.BackgroundImage = null;
if (cbBanner.SelectedIndex != -1)
cbBanner.Focus();
else
cbIcon.Focus();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -20,23 +20,18 @@ namespace CustomizeMii
public struct TplImage
{
public System.Drawing.Image tplImage;
public System.Drawing.Image checkerBoard;
public string tplFormat;
public string fileName;
}
public struct TransmitInfo
{
public bool usedCompression;
public double compressionRatio;
public double transmittedLength;
public int timeElapsed;
}
public enum TransmitProtocol : int
{
JODI = 0,
HAXX = 1
}
public struct BnsConversionInfo
{
public enum LoopType
@ -46,10 +41,10 @@ namespace CustomizeMii
Manual
}
public LoopType Loop;
public int LoopStartSample;
public string AudioFile;
public bool StereoToMono;
public LoopType loopType;
public int loopStartSample;
public string audioFile;
public bool stereoToMono;
}
public struct WadCreationInfo
@ -57,23 +52,26 @@ namespace CustomizeMii
public enum NandLoader : int
{
comex = 0,
Waninkoko = 1
Waninkoko = 1,
}
public string titleId;
public string[] titles;
public string allLangTitle;
public int requiredIos;
public int startupIos;
public string sound;
public string dol;
public string outFile;
public NandLoader nandLoader;
public bool sendToWii;
public TransmitProtocol transmitProtocol;
public libWiiSharp.Protocol transmitProtocol;
public string transmitIp;
public int transmitIos;
public bool saveAfterTransmit;
public bool success;
public bool sendWadReady;
public byte[] wadFile;
public bool lz77;
}
public struct Progress

View File

@ -24,33 +24,21 @@ namespace CustomizeMii
{
static class Program
{
static Mutex mtx;
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
static void Main(string[] args)
{
CleanupRemains();
if (!File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "libWiiSharp.dll"))
{
MessageBox.Show("libWiiSharp.dll wasn't found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(-1);
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new CustomizeMii_Main());
}
static void CleanupRemains()
{
bool firstInstance = false;
mtx = new System.Threading.Mutex(false, "CustomizeMii", out firstInstance);
if (firstInstance)
{
if (Directory.Exists(Path.GetTempPath() + "CustomizeMii_Temp"))
Directory.Delete(Path.GetTempPath() + "CustomizeMii_Temp", true);
if (Directory.Exists(Path.GetTempPath() + "ForwardMii_Temp"))
Directory.Delete(Path.GetTempPath() + "ForwardMii_Temp", true);
}
Application.Run(new CustomizeMii_Main(args));
}
}
}

View File

@ -50,6 +50,6 @@ using System.Resources;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.1.0")]
[assembly: AssemblyFileVersion("2.3.1.0")]
[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: NeutralResourcesLanguageAttribute("en")]

View File

@ -1,21 +1,4 @@
/* 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/>.
*/
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:2.0.50727.4927
@ -91,6 +74,13 @@ namespace CustomizeMii.Properties {
}
}
internal static byte[] comex {
get {
object obj = ResourceManager.GetObject("comex", resourceCulture);
return ((byte[])(obj));
}
}
internal static System.Drawing.Icon CustomizeMii {
get {
object obj = ResourceManager.GetObject("CustomizeMii", resourceCulture);
@ -113,5 +103,12 @@ namespace CustomizeMii.Properties {
return ResourceManager.GetString("Instructions", resourceCulture);
}
}
internal static byte[] Waninkoko {
get {
object obj = ResourceManager.GetObject("Waninkoko", resourceCulture);
return ((byte[])(obj));
}
}
}
}

View File

@ -118,16 +118,22 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="CustomizeMii" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CustomizeMii.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Instructions" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\instructions.rtf;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="btnCreate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\btnCreate.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="btnSend" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\btnSend.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="comex" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\comex.app;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="CustomizeMii" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CustomizeMii.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Instructions" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\instructions.rtf;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="Waninkoko" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\waninkoko.app;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

View File

@ -2,13 +2,24 @@ CustomizeMii is a custom channel creator for the Wii.
The .NET Framework 2.0 is required to run this application!
For any further information, see: http://customizemii.googlecode.com
Please use the Issue Tracker there to report any occuring bugs.
Please use the issue tracker there to report any occuring bugs.
Thanks to icefire / Xuzz for the basic idea of this Application!
Thanks to icefire / Xuzz for the basic idea of this application!
-----------------------------------------------------------------------------------------
Changelog:
Version 3.0
- Switched backend to libWiiSharp (http://libwiisharp.googlecode.com)
- Speed improvements through using RAM instead of temp files on HDD
- No separate Mono version anymore, the normal version works with Mono (even compiling forwarders!)
- Fixed complex forwarder loading screen to be fullscreen (thanks wilsoff / tantric!)
- Fixed bug where startup IOS was set to 0 when sending channel to Wii
- Doesn't require common-key.bin anymore
- Added checkerboard for transparent areas in images (preview window)
- Added ability to change a TPLs format (preview window)
- Added ability to rename and resize TPLs (right click on listbox)
Version 2.31
- Fixed sending to Wii
@ -105,6 +116,7 @@ Andre Perrot for gbalzss
comex and Waninkoko for both their NAND Loader
djdynamite123 for the forwarder base files
The USB Loader GX Team for their forwarder source
wilsoff for helping me debugging 3.0
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------

View File

@ -1,372 +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 <http://www.gnu.org/licenses/>.
*/
using System;
using System.IO;
namespace WaveFile
{
/// <summary>
/// A class for RIFF Wave files
/// </summary>
public class Wave
{
//Private Variables
private int fmtOffset;
private int dataOffset;
private int smplOffset;
private byte[] waveFile;
//Public Variables
/// <summary>
/// The Samplerate of the Wave file
/// </summary>
public int SampleRate { get { return GetSampleRate(); } }
/// <summary>
/// The Bitdepth of the Wave file
/// </summary>
public int BitDepth { get { return GetBitDepth(); } }
/// <summary>
/// The number of channels of the Wave file
/// </summary>
public int ChannelCount { get { return GetChannelCount(); } }
/// <summary>
/// The format of the Wave file's data. 1 = PCM
/// </summary>
public int DataFormat { get { return GetDataFormat(); } }
/// <summary>
/// The number of Loops in the Wave file
/// </summary>
public int LoopCount { get { return GetLoopCount(); } }
/// <summary>
/// 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(); } }
//Public Functions
public Wave(string waveFile)
{
using (FileStream fs = new FileStream(waveFile, FileMode.Open))
{
byte[] temp = new byte[fs.Length];
fs.Read(temp, 0, temp.Length);
this.waveFile = temp;
}
if (!CheckWave()) throw new Exception("This is not a supported PCM Wave File!");
if (!GetFmtOffset()) throw new Exception("The format section couldn't be found!");
if (!GetDataOffset()) throw new Exception("The data section couldn't be found!");
GetSmplOffset();
}
public Wave(byte[] waveFile)
{
this.waveFile = waveFile;
if (!CheckWave()) throw new Exception("This is not a supported PCM Wave File!");
if (!GetFmtOffset()) throw new Exception("The format section couldn't be found!");
if (!GetDataOffset()) throw new Exception("The data section couldn't be found!");
GetSmplOffset();
}
/// <summary>
/// Returns the Wave file as a Byte Array
/// </summary>
/// <returns></returns>
public byte[] ToByteArray()
{
return waveFile;
}
/// <summary>
/// Returns the Wave file as a Memory Stream
/// </summary>
/// <returns></returns>
public MemoryStream ToMemoryStream()
{
return new MemoryStream(waveFile);
}
/// <summary>
/// Returns only the audio data of the Wave file (No header or anything else)
/// </summary>
/// <returns></returns>
public byte[] GetAllFrames()
{
int dataLength = GetDataLength();
MemoryStream ms = new MemoryStream();
ms.Write(waveFile, dataOffset, dataLength);
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>
public void Close()
{
waveFile = null;
}
//Private Functions
private int GetFrameCount()
{
int dataLength = GetDataLength();
return (dataLength / (this.ChannelCount * 2));
}
private int GetLoopStart()
{
if (smplOffset == -1) return 0;
byte[] temp = new byte[4];
temp[0] = waveFile[smplOffset + 52];
temp[1] = waveFile[smplOffset + 53];
temp[2] = waveFile[smplOffset + 54];
temp[3] = waveFile[smplOffset + 55];
return BitConverter.ToInt32(temp, 0);
}
private int GetLoopCount()
{
if (smplOffset == -1) return 0;
byte[] temp = new byte[4];
temp[0] = waveFile[smplOffset + 36];
temp[1] = waveFile[smplOffset + 37];
temp[2] = waveFile[smplOffset + 38];
temp[3] = waveFile[smplOffset + 39];
return BitConverter.ToInt32(temp, 0);
}
private bool GetSmplOffset()
{
try
{
int length = (waveFile.Length > 5004 ? (waveFile.Length - 5000) : 0);
for (int i = waveFile.Length - 4; i > length; i--)
{
if (waveFile[i] == 's' &&
waveFile[i + 1] == 'm' &&
waveFile[i + 2] == 'p' &&
waveFile[i + 3] == 'l')
{
this.smplOffset = i;
return true;
}
}
}
catch { }
for (int i = 0; i < waveFile.Length - 4; i++)
{
if (waveFile[i] == 's' &&
waveFile[i + 1] == 'm' &&
waveFile[i + 2] == 'p' &&
waveFile[i + 3] == 'l')
{
this.smplOffset = i;
return true;
}
}
this.smplOffset = -1;
return false;
}
private bool GetFmtOffset()
{
if (waveFile[12] == 'f' &&
waveFile[13] == 'm' &&
waveFile[14] == 't' &&
waveFile[15] == ' ')
{
this.fmtOffset = 12;
return true;
}
int length = (waveFile.Length > 5004 ? 5000 : waveFile.Length - 4);
for (int i = 0; i < length; i++)
{
if (waveFile[i] == 'f' &&
waveFile[i + 1] == 'm' &&
waveFile[i + 2] == 't' &&
waveFile[i + 3] == ' ')
{
this.fmtOffset = i;
return true;
}
}
this.fmtOffset = -1;
return false;
}
private int GetDataLength()
{
byte[] temp = new byte[4];
temp[0] = waveFile[dataOffset + 4];
temp[1] = waveFile[dataOffset + 5];
temp[2] = waveFile[dataOffset + 6];
temp[3] = waveFile[dataOffset + 7];
return BitConverter.ToInt32(temp, 0);
}
private bool GetDataOffset()
{
if (waveFile[40] == 'd' &&
waveFile[41] == 'a' &&
waveFile[42] == 't' &&
waveFile[43] == 'a')
{
this.dataOffset = 40;
return true;
}
for (int i = 0; i < waveFile.Length - 4; i++)
{
if (waveFile[i] == 'd' &&
waveFile[i + 1] == 'a' &&
waveFile[i + 2] == 't' &&
waveFile[i + 3] == 'a')
{
this.dataOffset = i;
return true;
}
}
this.dataOffset = -1;
return false;
}
private int GetSampleRate()
{
byte[] temp = new byte[4];
temp[0] = waveFile[fmtOffset + 12];
temp[1] = waveFile[fmtOffset + 13];
temp[2] = waveFile[fmtOffset + 14];
temp[3] = waveFile[fmtOffset + 15];
return BitConverter.ToInt32(temp, 0);
}
private int GetBitDepth()
{
byte[] temp = new byte[2];
temp[0] = waveFile[fmtOffset + 22];
temp[1] = waveFile[fmtOffset + 23];
return BitConverter.ToInt16(temp, 0);
}
private int GetChannelCount()
{
byte[] temp = new byte[2];
temp[0] = waveFile[fmtOffset + 10];
temp[1] = waveFile[fmtOffset + 11];
return BitConverter.ToInt16(temp, 0);
}
private int GetDataFormat()
{
byte[] temp = new byte[2];
temp[0] = waveFile[fmtOffset + 8];
temp[1] = waveFile[fmtOffset + 9];
return BitConverter.ToInt16(temp, 0);
}
private bool CheckWave()
{
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') return false;
return true;
}
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -35,17 +35,21 @@ namespace CustomizeMiiInstaller
public class InstallerHelper
{
public static MemoryStream CreateInstaller(string wadFile, byte iosToUse)
{
return CreateInstaller(File.ReadAllBytes(wadFile), iosToUse);
}
public static MemoryStream CreateInstaller(byte[] wadFileBytes, byte iosToUse)
{
const int injectionPosition = 0x5A74C;
const int maxAllowedSizeForWads = 4 * 1024 * 1024 - 32; //(Max 4MB-32bytes )
//0. Read length of the wad to ensure it has an allowed size
byte[] wadFileBytes = File.ReadAllBytes(wadFile);
uint wadLength = (uint)wadFileBytes.Length;
if (wadLength > maxAllowedSizeForWads)
{
throw new ArgumentException(String.Format("The file {0} is sized above the max allowed limit of {1} for network installation.", wadFile, maxAllowedSizeForWads));
throw new ArgumentException(String.Format("The file is sized above the max allowed limit of {1} for network installation.", maxAllowedSizeForWads));
}
//1. Open the stub installer from resources

View File

@ -33,7 +33,10 @@ namespace ForwardMii
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DEVKITPRO")) ||
string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DEVKITPPC"))) return false;
if (!System.IO.Directory.Exists(Environment.GetEnvironmentVariable("DEVKITPRO").Remove(0, 1).Insert(1, ":") + "/libogc")) return false;
if (Environment.OSVersion.VersionString.ToLower().Contains("windows"))
{ if (!System.IO.Directory.Exists(Environment.GetEnvironmentVariable("DEVKITPRO").Remove(0, 1).Insert(1, ":") + "/libogc")) return false; }
else
{ if (!System.IO.Directory.Exists(Environment.GetEnvironmentVariable("DEVKITPRO") + "/libogc")) return false; }
return true;
}

View File

@ -28,7 +28,7 @@ namespace ForwardMii
{
public class GXForwarder
{
private readonly string TempDir = Path.GetTempPath() + "ForwardMii_Temp\\" + Guid.NewGuid() + "\\";
private readonly string TempDir = Path.GetTempPath() + "ForwardMii_Temp" + Path.DirectorySeparatorChar + Guid.NewGuid() + Path.DirectorySeparatorChar;
private bool[] packs = new bool[] { false, false, false };
private string[] paths = new string[16]; //Maximum 16 Paths
private string image43;
@ -180,18 +180,18 @@ namespace ForwardMii
Image img = Image.FromFile(image43);
if (img.Width != 640 || img.Height != 480)
img = ResizeImage(img, 640, 480);
img.Save(TempDir + "\\source\\images\\background.png", System.Drawing.Imaging.ImageFormat.Png);
img.Save(TempDir + Path.DirectorySeparatorChar + "source" + Path.DirectorySeparatorChar + "images" + Path.DirectorySeparatorChar + "background.png", System.Drawing.Imaging.ImageFormat.Png);
}
catch
{
Bitmap img = new Bitmap(640, 480);
img.Save(TempDir + "\\source\\images\\background.png", System.Drawing.Imaging.ImageFormat.Png);
img.Save(TempDir + Path.DirectorySeparatorChar + "source" + Path.DirectorySeparatorChar + "images" + Path.DirectorySeparatorChar + "background.png", System.Drawing.Imaging.ImageFormat.Png);
}
}
else
{
Bitmap img = new Bitmap(640, 480);
img.Save(TempDir + "\\source\\images\\background.png", System.Drawing.Imaging.ImageFormat.Png);
img.Save(TempDir + Path.DirectorySeparatorChar + "source" + Path.DirectorySeparatorChar + "images" + Path.DirectorySeparatorChar + "background.png", System.Drawing.Imaging.ImageFormat.Png);
}
if (!string.IsNullOrEmpty(image169) && File.Exists(image169))
@ -201,18 +201,18 @@ namespace ForwardMii
Image img = Image.FromFile(image169);
if (img.Width != 640 || img.Height != 480)
img = ResizeImage(img, 640, 480);
img.Save(TempDir + "\\source\\images\\background169.png", System.Drawing.Imaging.ImageFormat.Png);
img.Save(TempDir + Path.DirectorySeparatorChar + "source" + Path.DirectorySeparatorChar + "images" + Path.DirectorySeparatorChar + "background169.png", System.Drawing.Imaging.ImageFormat.Png);
}
catch
{
Bitmap img = new Bitmap(640, 480);
img.Save(TempDir + "\\source\\images\\background169.png", System.Drawing.Imaging.ImageFormat.Png);
img.Save(TempDir + Path.DirectorySeparatorChar + "source" + Path.DirectorySeparatorChar + "images" + Path.DirectorySeparatorChar + "background169.png", System.Drawing.Imaging.ImageFormat.Png);
}
}
else
{
Bitmap img = new Bitmap(640, 480);
img.Save(TempDir + "\\source\\images\\background169.png", System.Drawing.Imaging.ImageFormat.Png);
img.Save(TempDir + Path.DirectorySeparatorChar + "source" + Path.DirectorySeparatorChar + "images" + Path.DirectorySeparatorChar + "background169.png", System.Drawing.Imaging.ImageFormat.Png);
}
}
@ -304,7 +304,7 @@ namespace ForwardMii
}
}
using (FileStream fs = new FileStream(TempDir + "source\\main.cpp", FileMode.Create))
using (FileStream fs = new FileStream(TempDir + "source" + Path.DirectorySeparatorChar + "main.cpp", FileMode.Create))
{
using (StreamWriter writer = new StreamWriter(fs))
{
@ -319,14 +319,14 @@ namespace ForwardMii
private void CopyResources()
{
if (Directory.Exists(TempDir)) Directory.Delete(TempDir, true);
Directory.CreateDirectory(TempDir + "source\\images");
Directory.CreateDirectory(TempDir + "source" + Path.DirectorySeparatorChar + "images");
string[] Resources = new string[] { "dolloader.c", "dolloader.h", "elf_abi.h", "elfloader.c",
"elfloader.h", "fatmounter.c", "fatmounter.h", "filelist.h", "video.cpp", "video.h" };
foreach (string thisResource in Resources)
{
Stream tempStream = GetReourceStream(thisResource);
StreamToFile(tempStream, TempDir + "source\\" + thisResource);
StreamToFile(tempStream, TempDir + "source" + Path.DirectorySeparatorChar + thisResource);
}
Stream makefile = GetReourceStream("Makefile");

View File

@ -127,6 +127,10 @@ InitVideo ()
VIDEO_Init();
vmode = VIDEO_GetPreferredMode(NULL); // get default video mode
//Widescreen loading image fix...
vmode->viWidth = 678;
vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 678) / 2;
VIDEO_Configure (vmode);
// Allocate the video buffers