2009-11-08 23:53:22 +01:00
/ * This file is part of CustomizeMii
* Copyright ( C ) 2009 Leathl
*
2009-11-24 01:09:42 +01:00
* 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
2009-11-08 23:53:22 +01:00
* GNU General Public License for more details .
2009-11-24 01:09:42 +01:00
*
2009-11-08 23:53:22 +01:00
* You should have received a copy of the GNU General Public License
2009-11-24 01:09:42 +01:00
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
2009-11-08 23:53:22 +01:00
* /
2009-11-24 01:09:42 +01:00
2009-11-08 23:53:22 +01:00
using System ;
2009-11-24 01:09:42 +01:00
using System.Collections.Generic ;
2009-11-08 23:53:22 +01:00
using System.ComponentModel ;
using System.Diagnostics ;
using System.Drawing ;
using System.IO ;
using System.Net ;
using System.Windows.Forms ;
2009-12-05 02:12:28 +01:00
using ForwardMii ;
2010-03-28 20:29:30 +02:00
using libWiiSharp ;
2009-11-08 23:53:22 +01:00
namespace CustomizeMii
{
public partial class CustomizeMii_Main : Form
{
2009-12-31 04:34:47 +01:00
#region Constants
2015-12-11 15:21:20 +01:00
private const string version = "3.11.1" ; //Hint for myself: Never use a char in the Version (UpdateCheck)!
2010-03-28 20:29:30 +02:00
private const int soundMaxLength = 40 ; //In seconds
private const int soundWarningLength = 25 ; //In seconds
private const int bnsWarningLength = 45 ; //In seconds
private const int creditsScrollSpeed = 75 ; //Timer Intervall for the scrolling Credits
private const int creditsReturnValue = - 150 ; //Need to change this when the credits label gets longer
2009-12-31 04:34:47 +01:00
#endregion
#region Variables
2009-12-30 18:39:41 +01:00
public static string [ ] SourceWadUrls = new string [ ] { "StaticBase.wad" , "MPlayer_CE_Short.wad" , "MPlayer_CE_Long.wad" , "Snes9xGX.wad" , "FCE_Ultra_wilsoff.wad" , "FCE_Ultra_Leathl.wad" , "Wii64.wad" , "WiiSX_Full.wad" , "WiiSX_Retro.wad" , "WADder_Base_1.wad" , "WADder_Base_2.wad" , "WADder_Base_3.wad" , "UniiLoader.wad" , "Backup_Channel.wad" } ;
public static string [ ] SourceWadPreviewUrls = new string [ ] { "http://www.youtube.com/watch?v=pFNKldTYQq0" , "http://www.youtube.com/watch?v=Up1RZebUc_U" , "http://www.youtube.com/watch?v=Up1RZebUc_U" , "http://www.youtube.com/watch?v=P-Mxd6DMvFY" , "http://www.youtube.com/watch?v=wrbrg-DH_h4" , "http://www.youtube.com/watch?v=MfiVbQaiXw8" , "http://www.youtube.com/watch?v=krCQ2J7ZH8Y" , "http://www.youtube.com/watch?v=rZC1DKUM6QI" , "http://www.youtube.com/watch?v=Uiy8w-bp1kI" , "http://www.youtube.com/watch?v=BbSYCSI8tz8" , "http://www.youtube.com/watch?v=PIFZevHQ8lQ" , "http://www.youtube.com/watch?v=OIhvDNjphhc" , "http://www.youtube.com/watch?v=KLcncEArQLY&NR=1" , "http://www.youtube.com/watch?v=xE_EgdCRV1I" } ;
2010-03-28 20:29:30 +02:00
private bool brlytChanged = false ;
private bool brlanChanged = false ;
2009-12-22 00:58:53 +01:00
private Progress currentProgress ;
2009-11-24 01:09:42 +01:00
private EventHandler ProgressUpdate ;
2010-03-28 20:29:30 +02:00
private List < string > bannerTransparents = new List < string > ( ) ;
private List < string > iconTransparents = new List < string > ( ) ;
2009-12-31 04:34:47 +01:00
private double separatorBtn ;
private Timer tmrCredits = new Timer ( ) ;
private ToolTip tTip = new ToolTip ( ) ;
#endregion
2010-03-28 20:29:30 +02:00
public CustomizeMii_Main ( string [ ] args )
2009-11-08 23:53:22 +01:00
{
InitializeComponent ( ) ;
this . Icon = global :: CustomizeMii . Properties . Resources . CustomizeMii ;
2010-03-28 20:29:30 +02:00
if ( args . Length > 0 & & File . Exists ( args [ 0 ] ) & & args [ 0 ] . ToLower ( ) . EndsWith ( ".wad" ) )
{
loadChannel ( args [ 0 ] ) ;
}
2009-11-08 23:53:22 +01:00
}
private void CustomizeMii_Main_Load ( object sender , EventArgs e )
{
2010-02-24 22:41:37 +01:00
this . Text = this . Text . Replace ( "X" , version ) ;
this . lbCreditVersion . Text = this . lbCreditVersion . Text . Replace ( "X" , version ) ;
2010-03-28 20:29:30 +02:00
if ( ! Environment . OSVersion . VersionString . ToLower ( ) . Contains ( "windows" ) )
{
//TextBox.MaxLength is not implemented in Mono, so don't use it
for ( int i = 0 ; i < tabControl . TabPages . Count ; i + + )
for ( int j = 0 ; j < tabControl . TabPages [ i ] . Controls . Count ; j + + )
if ( tabControl . TabPages [ i ] . Controls [ j ] is TextBox ) ( ( TextBox ) tabControl . TabPages [ i ] . Controls [ j ] ) . MaxLength = 32000 ;
}
if ( File . Exists ( Application . StartupPath + Path . DirectorySeparatorChar + "CustomizeMiiInstaller.dll" ) )
this . lbCreditInstaller . Text = this . lbCreditInstaller . Text . Replace ( "X" , getInstallerVersion ( ) ) ;
2010-02-24 22:41:37 +01:00
else this . lbCreditInstaller . Text = this . lbCreditInstaller . Text . Replace ( " X" , string . Empty ) ;
2010-03-28 20:29:30 +02:00
if ( ! version . ToLower ( ) . Contains ( "beta" ) )
{
MethodInvoker Update = new MethodInvoker ( updateCheck ) ;
Update . BeginInvoke ( null , null ) ;
}
byte [ ] t = new byte [ 45 ] ;
2010-02-24 22:41:37 +01:00
2010-03-28 20:29:30 +02:00
initialize ( ) ;
2009-11-08 23:53:22 +01:00
}
private void CustomizeMii_Main_FormClosing ( object sender , FormClosingEventArgs e )
{
2009-12-22 00:58:53 +01:00
Environment . Exit ( 0 ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
private void sourceWad_Warning ( object sender , MessageEventArgs e )
2009-12-05 02:12:28 +01:00
{
2010-03-28 20:29:30 +02:00
MessageBox . Show ( e . Message , "Warning" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
2009-12-05 02:12:28 +01:00
}
2010-03-28 20:29:30 +02:00
private void initialize ( )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
if ( this . InvokeRequired )
{
this . Invoke ( new MethodInvoker ( initialize ) ) ;
return ;
}
drawCreateButton ( ) ;
setToolTips ( ) ;
ProgressUpdate = new EventHandler ( this . updateProgress ) ;
tmrCredits . Tick + = new EventHandler ( tmrCredits_Tick ) ;
rtbInstructions . LinkClicked + = new LinkClickedEventHandler ( rtbInstructions_LinkClicked ) ;
2009-11-08 23:53:22 +01:00
cmbNandLoader . SelectedIndex = 0 ;
cmbFormatBanner . SelectedIndex = 0 ;
cmbFormatIcon . SelectedIndex = 0 ;
cmbReplace . SelectedIndex = 0 ;
2010-03-28 20:29:30 +02:00
2009-11-08 23:53:22 +01:00
pbProgress . Value = 100 ;
2010-03-28 20:29:30 +02:00
tmrCredits . Interval = creditsScrollSpeed ;
2009-12-30 18:57:38 +01:00
2010-03-28 20:29:30 +02:00
brlanChanged = false ;
brlytChanged = false ;
2009-11-24 01:09:42 +01:00
2010-03-28 20:29:30 +02:00
btnBrowseSource . Text = "Browse..." ;
btnBrowseDol . Text = "Browse..." ;
btnBrowseSound . Text = "Browse..." ;
2009-11-08 23:53:22 +01:00
2010-03-28 20:29:30 +02:00
rtbInstructions . Rtf = Properties . Resources . Instructions ;
2009-11-08 23:53:22 +01:00
2010-03-28 20:29:30 +02:00
clearAll ( ) ;
disableControls ( ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
private void clearAll ( )
2009-11-08 23:53:22 +01:00
{
tbAllLanguages . Text = string . Empty ;
tbDol . Text = string . Empty ;
tbDutch . Text = string . Empty ;
tbEnglish . Text = string . Empty ;
tbFrench . Text = string . Empty ;
tbGerman . Text = string . Empty ;
tbItalian . Text = string . Empty ;
2010-02-24 22:41:37 +01:00
tbKorean . Text = string . Empty ;
2009-11-08 23:53:22 +01:00
tbJapanese . Text = string . Empty ;
tbReplace . Text = string . Empty ;
tbSound . Text = string . Empty ;
tbSourceWad . Text = string . Empty ;
tbSpanish . Text = string . Empty ;
tbTitleID . Text = string . Empty ;
2010-02-24 22:41:37 +01:00
tbStartupIos . Text = string . Empty ;
2009-11-08 23:53:22 +01:00
2010-03-28 20:29:30 +02:00
lbCreatedValue . Text = string . Empty ;
2009-11-24 01:09:42 +01:00
lbxBannerTpls . Items . Clear ( ) ;
lbxBrlanBanner . Items . Clear ( ) ;
lbxBrlanIcon . Items . Clear ( ) ;
lbxBrlytBanner . Items . Clear ( ) ;
lbxBrlytIcon . Items . Clear ( ) ;
lbxIconTpls . Items . Clear ( ) ;
2010-03-28 20:29:30 +02:00
replacedBanner = string . Empty ;
replacedIcon = string . Empty ;
replacedSound = string . Empty ;
sourceWad = new WAD ( ) ;
bannerBin = new U8 ( ) ;
newBannerBin = new U8 ( ) ;
iconBin = new U8 ( ) ;
newIconBin = new U8 ( ) ;
newSoundBin = new byte [ 0 ] ;
newDol = new byte [ 0 ] ;
sourceWad . Warning + = new EventHandler < MessageEventArgs > ( sourceWad_Warning ) ;
2009-12-22 00:58:53 +01:00
cbLz77 . Checked = true ;
2009-11-24 01:09:42 +01:00
cbIconMakeTransparent . Checked = false ;
cbBannerMakeTransparent . Checked = false ;
2009-12-22 00:58:53 +01:00
2010-03-28 20:29:30 +02:00
bannerTransparents . Clear ( ) ;
iconTransparents . Clear ( ) ;
2009-12-22 00:58:53 +01:00
2010-03-28 20:29:30 +02:00
simpleForwarder . Clear ( ) ;
complexForwarder . Clear ( ) ;
2009-11-24 01:09:42 +01:00
}
2010-03-28 20:29:30 +02:00
private void setToolTips ( )
2009-11-24 01:09:42 +01:00
{
2009-12-31 04:34:47 +01:00
tTip . SetToolTip ( btnCreateWad , "Create and save the WAD or send it directly to the Wii...\nBe sure the Homebrew Channel is running and connected if you want to send the WAD..." ) ;
tTip . SetToolTip ( btnBrowseSource , "Browse for a WAD that is used as a Base..." ) ;
tTip . SetToolTip ( btnLoadBaseWad , "Load the selected Base WAD..." ) ;
tTip . SetToolTip ( btnPreviewBaseWad , "Preview the selected Base WAD, a Browserwindow will be opened..." ) ;
tTip . SetToolTip ( btnSaveBaseWad , "Download and save the selected Base WAD to your HDD..." ) ;
tTip . SetToolTip ( btnBrowseReplace , "Browse for a Banner / Icon / Sound to use instead of the one within the Base WAD...\nWAD's, 00000000.app's and banner.bin's / icon.bin's / sound.bin's can be loaded..." ) ;
//TTip.SetToolTip(btnClearReplace, "Clear the replaced Banner / Icon / Sound and use the one within the Base WAD...");
tTip . SetToolTip ( btnBrowseDol , "Browse for a DOL file that will be inserted into the WAD\nor choose the DOL form the source WAD to switch the NAND Loader..." ) ;
tTip . SetToolTip ( btnBrowseSound , "Browse for a sound that will be inserted into the WAD\nor convert a sound to BNS format..." ) ;
tTip . SetToolTip ( btnAddBanner , "Add an image or TPL to the Banner..." ) ;
tTip . SetToolTip ( btnAddIcon , "Add an image or TPL to the Icon..." ) ;
tTip . SetToolTip ( btnDeleteBanner , "Delete the selected TPL...\nRequired TPLs can't be deleted..." ) ;
tTip . SetToolTip ( btnDeleteIcon , "Delete the selected TPL...\nRequired TPLs can't be deleted..." ) ;
tTip . SetToolTip ( btnReplaceBanner , "Replace the selected TPL with any image...\nThe image wil be stretched to fit the size of the TPL..." ) ;
tTip . SetToolTip ( btnReplaceIcon , "Replace the selected TPL with any image...\nThe image wil be stretched to fit the size of the TPL..." ) ;
tTip . SetToolTip ( btnExtractBanner , "Extract the selected TPL as an image..." ) ;
tTip . SetToolTip ( btnExtractIcon , "Extract the selected TPL as an image..." ) ;
tTip . SetToolTip ( btnPreviewBanner , "Preview the selected TPL..." ) ;
tTip . SetToolTip ( btnPreviewIcon , "Preview the selected TPL..." ) ;
tTip . SetToolTip ( btnBrlytReplace , "Replace the selected brlyt with any other...\nThis is for advanced users only!" ) ;
tTip . SetToolTip ( btnBrlytExtract , "Extract the selected brlyt..." ) ;
tTip . SetToolTip ( btnBrlytListTpls , "List the TPLs required by the selected brlyt..." ) ;
tTip . SetToolTip ( btnBrlanAdd , "Add a brlan file...\nThis is for advanced users only!" ) ;
tTip . SetToolTip ( btnBrlanDelete , "Delete the selected brlan file...\nThis is for advanced users only!" ) ;
tTip . SetToolTip ( btnBrlanReplace , "Replace the selected brlan file...\nThis is for advanced users only!" ) ;
tTip . SetToolTip ( btnBrlanExtract , "Extract the selected brlan file..." ) ;
tTip . SetToolTip ( btnOptionsExtract , "Extract contents of the WAD..." ) ;
tTip . SetToolTip ( btnForwarder , "Create a forwarder that will be inserted as a DOL..." ) ;
2010-01-12 18:03:46 +01:00
tTip . SetToolTip ( llbTranslateChannel , "Translates the word \"Channel\" to each language..." ) ;
2009-12-31 04:34:47 +01:00
tTip . SetToolTip ( cbLz77 , "Use Lz77 compression for the banner.bin and icon.bin...\nIf the created WAD does not work, try it without compression first..." ) ;
2010-03-28 20:29:30 +02:00
tTip . SetToolTip ( cbSecurityChecksOff , "Turn off the security checks...\nNot recommended, you may get a bricking WAD..." ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
private bool checkForForwardMii ( )
2009-12-05 02:12:28 +01:00
{
2010-03-28 20:29:30 +02:00
if ( File . Exists ( Application . StartupPath + Path . DirectorySeparatorChar + "ForwardMii.dll" ) )
2009-12-05 02:12:28 +01:00
return true ;
else
return false ;
}
2010-01-12 18:03:46 +01:00
private void rtbInstructions_LinkClicked ( object sender , LinkClickedEventArgs e )
2009-12-31 04:34:47 +01:00
{
try
{
Process . Start ( e . LinkText ) ;
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-12-31 04:34:47 +01:00
}
2010-03-28 20:29:30 +02:00
private bool checkDevKit ( )
2009-12-05 02:12:28 +01:00
{
return ForwardMii_Plugin . CheckDevKit ( ) ;
}
2010-03-28 20:29:30 +02:00
private byte [ ] createForwarderSimple ( )
2009-12-05 02:12:28 +01:00
{
2010-03-28 20:29:30 +02:00
return simpleForwarder . ToByteArray ( ) ;
2009-12-05 02:12:28 +01:00
}
2010-03-28 20:29:30 +02:00
private byte [ ] createForwarderComplex ( )
2009-12-05 02:12:28 +01:00
{
2010-03-28 20:29:30 +02:00
return complexForwarder . ToByteArray ( ) ;
2009-12-05 02:12:28 +01:00
}
2010-03-28 20:29:30 +02:00
private void convertMp3ToWave ( string mp3File )
2009-12-05 02:12:28 +01:00
{
2010-03-28 20:29:30 +02:00
if ( File . Exists ( Application . StartupPath + Path . DirectorySeparatorChar + "lame.exe" ) )
2009-12-05 02:12:28 +01:00
{
try
{
BackgroundWorker bwConvertMp3 = new BackgroundWorker ( ) ;
bwConvertMp3 . DoWork + = new DoWorkEventHandler ( bwConvertMp3_DoWork ) ;
bwConvertMp3 . RunWorkerCompleted + = new RunWorkerCompletedEventHandler ( bwConvertMp3_RunWorkerCompleted ) ;
bwConvertMp3 . ProgressChanged + = new ProgressChangedEventHandler ( bwConvertMp3_ProgressChanged ) ;
bwConvertMp3 . WorkerReportsProgress = true ;
bwConvertMp3 . RunWorkerAsync ( mp3File ) ;
}
catch ( Exception ex )
{
2010-03-28 20:29:30 +02:00
errorBox ( ex . Message ) ;
2009-12-05 02:12:28 +01:00
}
}
}
2010-03-28 20:29:30 +02:00
private void drawCreateButton ( )
2009-12-05 02:12:28 +01:00
{
2009-12-30 18:57:38 +01:00
btnCreateWad . Text = string . Empty ;
Image tmpImg = new Bitmap ( btnCreateWad . Width , btnCreateWad . Height ) ;
2009-12-31 04:34:47 +01:00
using ( Graphics gImg = Graphics . FromImage ( tmpImg ) )
{
gImg . Clear ( Color . Transparent ) ;
2009-12-30 18:57:38 +01:00
2009-12-31 04:34:47 +01:00
separatorBtn = btnCreateWad . Width * 0.5 ;
2009-12-30 18:57:38 +01:00
2009-12-31 04:34:47 +01:00
gImg . DrawLine ( Pens . Gray , new Point ( ( int ) separatorBtn , 0 ) , new Point ( ( int ) separatorBtn , btnCreateWad . Height ) ) ;
2009-12-30 18:57:38 +01:00
2009-12-31 04:34:47 +01:00
Image tmpCreate = Properties . Resources . btnCreate ;
Image tmpSend = Properties . Resources . btnSend ;
2010-03-28 20:29:30 +02:00
gImg . DrawImage ( resizeImage ( tmpCreate , tmpCreate . Width , tmpCreate . Height ) , new Point ( 280 , 0 ) ) ;
gImg . DrawImage ( resizeImage ( tmpSend , tmpSend . Width , tmpSend . Height ) , new Point ( 55 , 0 ) ) ;
2009-12-30 18:57:38 +01:00
2009-12-31 04:34:47 +01:00
btnCreateWad . Image = tmpImg ;
}
2009-12-05 02:12:28 +01:00
}
2010-03-28 20:29:30 +02:00
private bool checkInet ( )
2009-11-08 23:53:22 +01:00
{
try
{
2010-01-12 18:03:46 +01:00
System . Net . IPHostEntry ipHost = System . Net . Dns . GetHostEntry ( "www.google.com" ) ;
2009-11-08 23:53:22 +01:00
return true ;
}
2010-03-28 20:29:30 +02:00
catch { return false ; }
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
private void updateProgress ( object sender , EventArgs e )
2009-11-24 01:09:42 +01:00
{
2009-12-22 00:58:53 +01:00
pbProgress . Value = currentProgress . progressValue ;
2009-11-24 01:09:42 +01:00
2009-12-22 00:58:53 +01:00
if ( ! string . IsNullOrEmpty ( currentProgress . progressState ) )
{
lbStatusText . Text = currentProgress . progressState ;
currentProgress . progressState = string . Empty ;
}
2009-11-24 01:09:42 +01:00
}
2009-11-08 23:53:22 +01:00
private void tabControl_Selecting ( object sender , TabControlCancelEventArgs e )
{
2009-12-30 18:57:38 +01:00
tmrCredits . Stop ( ) ;
2009-11-08 23:53:22 +01:00
if ( tabControl . SelectedTab = = tabBanner )
2009-11-24 01:09:42 +01:00
{
lbxBannerTpls . SelectedIndex = - 1 ;
cbBannerMakeTransparent . Checked = false ;
cbBannerMakeTransparent . Enabled = false ;
2010-03-28 20:29:30 +02:00
try { addTpls ( ) ; }
catch { }
2009-11-24 01:09:42 +01:00
}
else if ( tabControl . SelectedTab = = tabIcon )
{
lbxIconTpls . SelectedIndex = - 1 ;
cbIconMakeTransparent . Checked = false ;
cbIconMakeTransparent . Enabled = false ;
2010-03-28 20:29:30 +02:00
try { addTpls ( ) ; }
catch { }
2009-11-24 01:09:42 +01:00
}
else if ( tabControl . SelectedTab = = tabBrlyt )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
try { addBrlyts ( ) ; }
catch { }
2009-11-08 23:53:22 +01:00
}
2009-11-24 01:09:42 +01:00
else if ( tabControl . SelectedTab = = tabBrlan )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
try { addBrlans ( ) ; }
catch { }
2009-11-08 23:53:22 +01:00
}
2009-12-30 18:57:38 +01:00
else if ( tabControl . SelectedTab = = tabCredits )
{
lbCreditThanks . Location = new Point ( lbCreditThanks . Location . X , panCredits . Height ) ;
tmrCredits . Start ( ) ;
}
}
2010-01-12 18:03:46 +01:00
private void tmrCredits_Tick ( object sender , EventArgs e )
2009-12-30 18:57:38 +01:00
{
2010-03-28 20:29:30 +02:00
if ( lbCreditThanks . Location . Y = = creditsReturnValue ) lbCreditThanks . Location = new Point ( lbCreditThanks . Location . X , panCredits . Height ) ;
2009-12-30 18:57:38 +01:00
lbCreditThanks . Location = new Point ( lbCreditThanks . Location . X , lbCreditThanks . Location . Y - 1 ) ;
2009-11-08 23:53:22 +01:00
}
private void lbStatusText_TextChanged ( object sender , EventArgs e )
{
if ( string . IsNullOrEmpty ( lbStatusText . Text ) & & pbProgress . Value = = 100 )
{
2010-03-28 20:29:30 +02:00
if ( tabControl . SelectedTab = = tabBanner | |
tabControl . SelectedTab = = tabIcon )
addTpls ( ) ;
2009-11-24 01:09:42 +01:00
else if ( tabControl . SelectedTab = = tabBrlyt )
2010-03-28 20:29:30 +02:00
addBrlyts ( ) ;
2009-11-24 01:09:42 +01:00
else if ( tabControl . SelectedTab = = tabBrlan )
2010-03-28 20:29:30 +02:00
addBrlans ( ) ;
2009-11-08 23:53:22 +01:00
}
}
2010-03-28 20:29:30 +02:00
private void updateCheck ( )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
if ( checkInet ( ) = = true )
2009-11-24 01:09:42 +01:00
{
try
{
WebClient GetVersion = new WebClient ( ) ;
2015-12-11 15:38:55 +01:00
string NewVersion = GetVersion . DownloadString ( "https://raw.githubusercontent.com/Brawl345/customizemii/master/version.txt" ) ;
2010-03-28 20:29:30 +02:00
2009-11-24 01:09:42 +01:00
int newVersion = Convert . ToInt32 ( NewVersion . Replace ( "." , string . Empty ) . Length = = 2 ? ( NewVersion . Replace ( "." , string . Empty ) + "0" ) : NewVersion . Replace ( "." , string . Empty ) ) ;
2009-12-05 02:12:28 +01:00
int thisVersion = Convert . ToInt32 ( version . Replace ( "." , string . Empty ) . Length = = 2 ? ( version . Replace ( "." , string . Empty ) + "0" ) : version . Replace ( "." , string . Empty ) ) ;
2009-11-24 01:09:42 +01:00
if ( newVersion > thisVersion )
{
2010-01-18 21:13:32 +01:00
llbUpdateAvailable . Text = llbUpdateAvailable . Text . Replace ( "X" , NewVersion ) ;
llbUpdateAvailable . Visible = true ;
2009-11-24 01:09:42 +01:00
if ( MessageBox . Show ( "Version " + NewVersion +
2010-01-18 21:13:32 +01:00
" is available.\nDo you want the download page to be opened?" ,
"Update available" , MessageBoxButtons . YesNo , MessageBoxIcon . Information ) = =
2009-11-24 01:09:42 +01:00
DialogResult . Yes )
{
2015-12-11 15:38:55 +01:00
Process . Start ( "https://github.com/Brawl345/customizemii/releases" ) ;
2009-11-24 01:09:42 +01:00
}
}
}
catch { }
}
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
private string getInstallerVersion ( )
2010-01-18 21:13:32 +01:00
{
return CustomizeMiiInstaller . CustomizeMiiInstaller_Plugin . GetVersion ( ) ;
}
2010-03-28 20:29:30 +02:00
private string getForwardMiiVersion ( )
2009-12-05 02:12:28 +01:00
{
return ForwardMii_Plugin . GetVersion ( ) ;
}
2009-11-08 23:53:22 +01:00
private void llbSite_LinkClicked ( object sender , LinkLabelLinkClickedEventArgs e )
{
try
{
llbSite . LinkVisited = true ;
2015-12-11 15:38:55 +01:00
Process . Start ( "https://github.com/Brawl345/customizemii/" ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-08 23:53:22 +01:00
}
private void btnBrowseSource_Click ( object sender , EventArgs e )
{
2010-03-28 20:29:30 +02:00
if ( btnBrowseSource . Text . ToLower ( ) = = "clear" ) { initialize ( ) ; }
else loadChannel ( ) ;
2009-11-08 23:53:22 +01:00
}
private void btnLoadBaseWad_Click ( object sender , EventArgs e )
{
2009-11-24 01:09:42 +01:00
if ( lbxBaseWads . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
2010-01-12 18:03:46 +01:00
if ( pbProgress . Value = = 100 )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
if ( checkInet ( ) = = true )
2009-11-08 23:53:22 +01:00
{
2009-12-22 00:58:53 +01:00
if ( tbSourceWad . Text ! = SourceWadUrls [ lbxBaseWads . SelectedIndex ] )
2009-11-08 23:53:22 +01:00
{
2015-12-11 15:38:55 +01:00
tbSourceWad . Text = "https://raw.githubusercontent.com/Brawl345/customizemii/master/Base_WADs/" + SourceWadUrls [ lbxBaseWads . SelectedIndex ] ;
2010-01-18 21:13:32 +01:00
2010-03-28 20:29:30 +02:00
System . Threading . Thread dlThread = new System . Threading . Thread ( new System . Threading . ParameterizedThreadStart ( downloadBaseWad ) ) ;
dlThread . Start ( tbSourceWad . Text ) ;
2009-11-08 23:53:22 +01:00
}
}
2010-01-12 18:03:46 +01:00
else
{
2010-03-28 20:29:30 +02:00
errorBox ( "You're not connected to the Internet!" ) ;
2010-01-12 18:03:46 +01:00
}
2009-11-08 23:53:22 +01:00
}
}
}
2010-03-28 20:29:30 +02:00
private void downloadBaseWad ( object uri )
2010-01-18 21:13:32 +01:00
{
try
{
2010-03-28 20:29:30 +02:00
WebClient client = new WebClient ( ) ;
client . DownloadProgressChanged + = new DownloadProgressChangedEventHandler ( client_DownloadProgressChanged ) ;
client . DownloadDataCompleted + = new DownloadDataCompletedEventHandler ( client_DownloadDataCompleted ) ;
2010-01-18 21:13:32 +01:00
currentProgress . progressState = "Downloading Base WAD..." ;
2010-03-28 20:29:30 +02:00
currentProgress . progressValue = 0 ;
2010-01-18 21:13:32 +01:00
this . Invoke ( ProgressUpdate ) ;
2010-03-28 20:29:30 +02:00
client . DownloadDataAsync ( new Uri ( ( string ) uri ) , uri ) ;
2010-01-18 21:13:32 +01:00
}
catch ( Exception ex )
{
2010-03-28 20:29:30 +02:00
setControlText ( tbSourceWad , string . Empty ) ;
errorBox ( ex . Message ) ;
2010-01-18 21:13:32 +01:00
}
}
2010-03-28 20:29:30 +02:00
void client_DownloadProgressChanged ( object sender , DownloadProgressChangedEventArgs e )
2009-11-08 23:53:22 +01:00
{
2010-01-18 21:13:32 +01:00
currentProgress . progressValue = e . ProgressPercentage ;
currentProgress . progressState = "Downloading Base WAD..." ;
this . Invoke ( ProgressUpdate ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
void client_DownloadDataCompleted ( object sender , DownloadDataCompletedEventArgs e )
2009-11-08 23:53:22 +01:00
{
2010-01-18 21:13:32 +01:00
currentProgress . progressValue = 0 ;
currentProgress . progressState = string . Empty ;
this . Invoke ( ProgressUpdate ) ;
2009-12-22 00:58:53 +01:00
2010-03-28 20:29:30 +02:00
if ( e . Error ! = null )
2009-12-22 00:58:53 +01:00
{
2010-03-28 20:29:30 +02:00
setControlText ( tbSourceWad , string . Empty ) ;
errorBox ( "The requested file couldn't be downloaded: " + e . Error . Message ) ;
}
else
{
BackgroundWorker bwLoadChannel = new BackgroundWorker ( ) ;
bwLoadChannel . DoWork + = new DoWorkEventHandler ( bwLoadChannel_DoWork ) ;
bwLoadChannel . ProgressChanged + = new ProgressChangedEventHandler ( bwLoadChannel_ProgressChanged ) ;
bwLoadChannel . RunWorkerCompleted + = new RunWorkerCompletedEventHandler ( bwLoadChannel_RunWorkerCompleted ) ;
bwLoadChannel . WorkerReportsProgress = true ;
bwLoadChannel . RunWorkerAsync ( e ) ;
2009-12-22 00:58:53 +01:00
}
2009-11-08 23:53:22 +01:00
}
private void btnPreviewBaseWad_Click ( object sender , EventArgs e )
{
2009-11-24 01:09:42 +01:00
if ( lbxBaseWads . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
if ( checkInet ( ) = = true )
2009-11-08 23:53:22 +01:00
{
2009-11-24 01:09:42 +01:00
if ( ! string . IsNullOrEmpty ( SourceWadPreviewUrls [ lbxBaseWads . SelectedIndex ] ) )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
try { Process . Start ( SourceWadPreviewUrls [ lbxBaseWads . SelectedIndex ] ) ; }
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
else infoBox ( "There's no preview of this channel available, sorry!" ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
else errorBox ( "You're not connected to the Internet!" ) ;
2009-11-08 23:53:22 +01:00
}
}
private void btnSaveBaseWad_Click ( object sender , EventArgs e )
{
2009-11-24 01:09:42 +01:00
if ( lbxBaseWads . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
if ( checkInet ( ) = = true )
2009-11-08 23:53:22 +01:00
{
if ( pbProgress . Value = = 100 )
{
2015-12-11 15:38:55 +01:00
string Url = "https://raw.githubusercontent.com/Brawl345/customizemii/master/Base_WADs/" + SourceWadUrls [ lbxBaseWads . SelectedIndex ] ;
2009-11-08 23:53:22 +01:00
SaveFileDialog sfd = new SaveFileDialog ( ) ;
sfd . Filter = "Wii Channels|*.wad" ;
sfd . FileName = Url . Remove ( 0 , Url . LastIndexOf ( '/' ) + 1 ) ;
if ( sfd . ShowDialog ( ) = = DialogResult . OK )
{
2010-03-28 20:29:30 +02:00
if ( tbSourceWad . Text = = Url )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
sourceWad . Save ( sfd . FileName ) ;
infoBox ( string . Format ( "Saved channel as {0}" , Path . GetFileName ( sfd . FileName ) ) ) ;
2009-11-08 23:53:22 +01:00
}
2009-12-22 00:58:53 +01:00
else
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
System . Threading . Thread saveThread = new System . Threading . Thread ( new System . Threading . ParameterizedThreadStart ( saveBaseWad ) ) ;
saveThread . Start ( ( object ) new string [ ] { Url , sfd . FileName } ) ;
2009-11-08 23:53:22 +01:00
}
}
}
}
2010-03-28 20:29:30 +02:00
else errorBox ( "You're not connected to the Internet!" ) ;
2009-11-08 23:53:22 +01:00
}
}
2010-03-28 20:29:30 +02:00
private void saveBaseWad ( object urlAndSavePath )
2010-02-06 00:09:36 +01:00
{
try
{
2010-03-28 20:29:30 +02:00
WebClient saveClient = new WebClient ( ) ;
saveClient . DownloadProgressChanged + = new DownloadProgressChangedEventHandler ( saveClient_DownloadProgressChanged ) ;
saveClient . DownloadFileCompleted + = new AsyncCompletedEventHandler ( saveClient_DownloadFileCompleted ) ;
2010-02-06 00:09:36 +01:00
currentProgress . progressValue = 0 ;
currentProgress . progressState = "Downloading Base WAD..." ;
this . Invoke ( ProgressUpdate ) ;
2010-03-28 20:29:30 +02:00
saveClient . DownloadFileAsync ( new Uri ( ( ( string [ ] ) urlAndSavePath ) [ 0 ] ) , ( ( string [ ] ) urlAndSavePath ) [ 1 ] ) ;
2010-02-06 00:09:36 +01:00
}
catch ( Exception ex )
{
2010-03-28 20:29:30 +02:00
errorBox ( ex . Message ) ;
2010-02-06 00:09:36 +01:00
}
}
2010-03-28 20:29:30 +02:00
void saveClient_DownloadProgressChanged ( object sender , DownloadProgressChangedEventArgs e )
2009-11-08 23:53:22 +01:00
{
2010-02-06 00:09:36 +01:00
currentProgress . progressValue = e . ProgressPercentage ;
currentProgress . progressState = "Downloading Base WAD..." ;
this . Invoke ( ProgressUpdate ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
void saveClient_DownloadFileCompleted ( object sender , AsyncCompletedEventArgs e )
2009-11-08 23:53:22 +01:00
{
2010-02-06 00:09:36 +01:00
currentProgress . progressValue = 100 ;
currentProgress . progressState = " " ;
this . Invoke ( ProgressUpdate ) ;
2009-11-08 23:53:22 +01:00
}
private void cmbReplace_SelectedIndexChanged ( object sender , EventArgs e )
{
switch ( cmbReplace . SelectedIndex )
{
case 1 :
2010-03-28 20:29:30 +02:00
tbReplace . Text = replacedIcon ;
2009-11-08 23:53:22 +01:00
break ;
case 2 :
2010-03-28 20:29:30 +02:00
if ( replacedSound . ToLower ( ) . EndsWith ( ".wad" ) | |
replacedSound . ToLower ( ) . EndsWith ( ".app" ) | |
replacedSound . ToLower ( ) . EndsWith ( ".bin" ) )
tbReplace . Text = replacedSound ;
else tbReplace . Text = string . Empty ;
2009-11-08 23:53:22 +01:00
break ;
default :
2010-03-28 20:29:30 +02:00
tbReplace . Text = replacedBanner ;
2009-11-08 23:53:22 +01:00
break ;
}
}
2009-12-31 04:34:47 +01:00
private void tbReplace_TextChanged ( object sender , EventArgs e )
{
if ( string . IsNullOrEmpty ( tbReplace . Text ) )
{
btnBrowseReplace . Text = "Browse..." ;
tTip . SetToolTip ( btnBrowseReplace , "Browse for a Banner / Icon / Sound to use instead of the one within the Base WAD...\nWAD's, 00000000.app's and banner.bin's / icon.bin's / sound.bin's can be loaded..." ) ;
}
else
{
btnBrowseReplace . Text = "Clear" ;
tTip . SetToolTip ( btnBrowseReplace , "Clear the replaced Banner / Icon / Sound and use the one within the Base WAD..." ) ;
}
}
2009-11-08 23:53:22 +01:00
private void btnBrowseReplace_Click ( object sender , EventArgs e )
{
2010-03-28 20:29:30 +02:00
if ( btnBrowseReplace . Text . ToLower ( ) = = "clear" )
2009-12-31 04:34:47 +01:00
{
if ( cmbReplace . SelectedIndex = = 2 ) //sound
{
2010-03-28 20:29:30 +02:00
replacedSound = string . Empty ;
setControlText ( tbReplace , string . Empty ) ;
newSoundBin = new byte [ 0 ] ;
2009-12-31 04:34:47 +01:00
}
else if ( cmbReplace . SelectedIndex = = 1 ) //icon
{
2010-03-28 20:29:30 +02:00
replacedIcon = string . Empty ;
setControlText ( tbReplace , string . Empty ) ;
newIconBin = new U8 ( ) ;
iconTransparents . Clear ( ) ;
addTpls ( ) ;
addBrlans ( ) ;
addBrlyts ( ) ;
2009-12-31 04:34:47 +01:00
}
else //banner
{
2010-03-28 20:29:30 +02:00
replacedBanner = string . Empty ;
setControlText ( tbReplace , string . Empty ) ;
newBannerBin = new U8 ( ) ;
bannerTransparents . Clear ( ) ;
addTpls ( ) ;
addBrlans ( ) ;
addBrlyts ( ) ;
2009-12-31 04:34:47 +01:00
}
}
2010-03-28 20:29:30 +02:00
else replacePart ( ) ;
2009-11-08 23:53:22 +01:00
}
private void btnBrowseDol_Click ( object sender , EventArgs e )
{
2010-03-28 20:29:30 +02:00
if ( btnBrowseDol . Text . ToLower ( ) = = "clear" )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
setControlText ( tbDol , string . Empty ) ;
2009-11-08 23:53:22 +01:00
btnBrowseDol . Text = "Browse..." ;
2010-03-28 20:29:30 +02:00
newDol = new byte [ 0 ] ;
2009-12-05 02:12:28 +01:00
2010-03-28 20:29:30 +02:00
simpleForwarder . Clear ( ) ;
complexForwarder . Clear ( ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
else cmDol . Show ( MousePosition ) ;
2009-11-08 23:53:22 +01:00
}
private void btnBrowseSound_Click ( object sender , EventArgs e )
{
2010-03-28 20:29:30 +02:00
if ( btnBrowseSound . Text . ToLower ( ) = = "clear" )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
setControlText ( tbSound , string . Empty ) ;
2009-11-08 23:53:22 +01:00
btnBrowseSound . Text = "Browse..." ;
2010-03-28 20:29:30 +02:00
newSoundBin = new byte [ 0 ] ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
else cmSound . Show ( MousePosition ) ;
2009-12-22 00:58:53 +01:00
}
2009-11-08 23:53:22 +01:00
2009-11-24 01:09:42 +01:00
private void lbxBannerTpls_SelectedIndexChanged ( object sender , EventArgs e )
2009-11-08 23:53:22 +01:00
{
2009-11-24 01:09:42 +01:00
if ( lbxBannerTpls . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
cbBannerMakeTransparent . Enabled = true ;
cbBannerMakeTransparent . Checked = lbxBannerTpls . SelectedItem . ToString ( ) . EndsWith ( "(Transparent)" ) ;
if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(RGBA8" ) )
{ cmbFormatBanner . SelectedIndex = 0 ; }
else if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(RGB565" ) )
{ cmbFormatBanner . SelectedIndex = 1 ; }
else if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(RGB5A3" ) )
{ cmbFormatBanner . SelectedIndex = 2 ; }
else if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(IA8" ) )
{ cmbFormatBanner . SelectedIndex = 3 ; }
else if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(IA4" ) )
{ cmbFormatBanner . SelectedIndex = 4 ; }
else if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(I8" ) )
{ cmbFormatBanner . SelectedIndex = 5 ; }
else if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(I4" ) )
{ cmbFormatBanner . SelectedIndex = 6 ; }
else if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(CI4" ) )
{ cmbFormatBanner . SelectedIndex = 7 ; }
else if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(CI8" ) )
{ cmbFormatBanner . SelectedIndex = 8 ; }
else if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(CI14X2" ) )
{ cmbFormatBanner . SelectedIndex = 9 ; }
else if ( lbxBannerTpls . SelectedItem . ToString ( ) . Substring ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(CMP" ) )
{ cmbFormatBanner . SelectedIndex = 10 ; }
}
else cbBannerMakeTransparent . Enabled = false ;
2009-11-08 23:53:22 +01:00
}
2009-11-24 01:09:42 +01:00
private void lbxIconTpls_SelectedIndexChanged ( object sender , EventArgs e )
2009-11-08 23:53:22 +01:00
{
2009-11-24 01:09:42 +01:00
if ( lbxIconTpls . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
cbIconMakeTransparent . Enabled = true ;
cbIconMakeTransparent . Checked = lbxIconTpls . SelectedItem . ToString ( ) . EndsWith ( "(Transparent)" ) ;
if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(RGBA8" ) )
{ cmbFormatIcon . SelectedIndex = 0 ; }
else if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(RGB565" ) )
{ cmbFormatIcon . SelectedIndex = 1 ; }
else if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(RGB5A3" ) )
{ cmbFormatIcon . SelectedIndex = 2 ; }
else if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(IA8" ) )
{ cmbFormatIcon . SelectedIndex = 3 ; }
else if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(IA4" ) )
{ cmbFormatIcon . SelectedIndex = 4 ; }
else if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(I8" ) )
{ cmbFormatIcon . SelectedIndex = 5 ; }
else if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(I4" ) )
{ cmbFormatIcon . SelectedIndex = 6 ; }
else if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(CI4" ) )
{ cmbFormatIcon . SelectedIndex = 7 ; }
else if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(CI8" ) )
{ cmbFormatIcon . SelectedIndex = 8 ; }
else if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(CI14X2" ) )
{ cmbFormatIcon . SelectedIndex = 9 ; }
else if ( lbxIconTpls . SelectedItem . ToString ( ) . Substring ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' ) ) . ToUpper ( ) . Contains ( "(CMP" ) )
{ cmbFormatIcon . SelectedIndex = 10 ; }
}
else cbIconMakeTransparent . Enabled = false ;
2009-11-08 23:53:22 +01:00
}
private void btnReplaceBanner_Click ( object sender , EventArgs e )
{
2009-11-24 01:09:42 +01:00
if ( lbxBannerTpls . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
int format = cmbFormatBanner . SelectedIndex ;
2009-11-08 23:53:22 +01:00
2010-04-20 21:54:36 +02:00
if ( format < 9 )
2009-11-08 23:53:22 +01:00
{
OpenFileDialog ofd = new OpenFileDialog ( ) ;
2009-12-05 02:12:28 +01:00
ofd . Filter = "PNG|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TPL|*.tpl|All|*.png;*.jpg;*.gif;*.bmp;*.tpl" ;
2009-11-24 01:09:42 +01:00
ofd . FilterIndex = 6 ;
2009-11-08 23:53:22 +01:00
if ( ofd . ShowDialog ( ) = = DialogResult . OK )
{
try
{
2010-03-28 20:29:30 +02:00
string tplName = lbxBannerTpls . SelectedItem . ToString ( ) . Remove ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' , 0 ) - 3 ) ;
TPL tmpTpl ;
Image img ;
2009-11-24 01:09:42 +01:00
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
tmpTpl = TPL . Load ( bannerBin . Data [ bannerBin . GetNodeIndex ( tplName ) ] ) ;
else tmpTpl = TPL . Load ( newBannerBin . Data [ newBannerBin . GetNodeIndex ( tplName ) ] ) ;
2009-11-08 23:53:22 +01:00
2010-03-28 20:29:30 +02:00
if ( ! ofd . FileName . ToLower ( ) . EndsWith ( ".tpl" ) ) img = Image . FromFile ( ofd . FileName ) ;
else
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
TPL newTpl = TPL . Load ( ofd . FileName ) ;
img = newTpl . ExtractTexture ( ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
if ( img . Width ! = tmpTpl . GetTextureSize ( 0 ) . Width | |
img . Height ! = tmpTpl . GetTextureSize ( 0 ) . Height )
img = resizeImage ( img , tmpTpl . GetTextureSize ( 0 ) . Width , tmpTpl . GetTextureSize ( 0 ) . Height ) ;
2010-04-20 21:54:36 +02:00
TPL_PaletteFormat pFormat = TPL_PaletteFormat . RGB5A3 ;
2010-03-28 20:29:30 +02:00
switch ( format )
2009-11-08 23:53:22 +01:00
{
2010-04-20 21:54:36 +02:00
case 6 :
format = ( int ) TPL_TextureFormat . I4 ;
2010-02-06 00:09:36 +01:00
break ;
2010-04-20 21:54:36 +02:00
case 5 :
format = ( int ) TPL_TextureFormat . I8 ;
2010-02-06 00:09:36 +01:00
break ;
2010-04-20 21:54:36 +02:00
case 4 :
format = ( int ) TPL_TextureFormat . IA4 ;
2010-02-06 00:09:36 +01:00
break ;
2010-04-20 21:54:36 +02:00
case 3 :
format = ( int ) TPL_TextureFormat . IA8 ;
2010-02-06 00:09:36 +01:00
break ;
2009-11-08 23:53:22 +01:00
case 1 :
2010-04-20 21:54:36 +02:00
format = ( int ) TPL_TextureFormat . RGB565 ;
2009-11-08 23:53:22 +01:00
break ;
case 2 :
2010-04-20 21:54:36 +02:00
format = ( int ) TPL_TextureFormat . RGB5A3 ;
break ;
case 7 :
format = ( int ) TPL_TextureFormat . CI4 ;
CustomizeMii_PaletteFormatBox pfb = new CustomizeMii_PaletteFormatBox ( ) ;
pfb . ShowDialog ( ) ;
pFormat = pfb . PaletteFormat ;
break ;
case 8 :
format = ( int ) TPL_TextureFormat . CI8 ;
CustomizeMii_PaletteFormatBox pfb2 = new CustomizeMii_PaletteFormatBox ( ) ;
pfb2 . ShowDialog ( ) ;
pFormat = pfb2 . PaletteFormat ;
break ;
case 9 :
format = ( int ) TPL_TextureFormat . CI14X2 ;
CustomizeMii_PaletteFormatBox pfb3 = new CustomizeMii_PaletteFormatBox ( ) ;
pfb3 . ShowDialog ( ) ;
pFormat = pfb3 . PaletteFormat ;
2009-11-08 23:53:22 +01:00
break ;
default :
2010-04-20 21:54:36 +02:00
format = ( int ) TPL_TextureFormat . RGBA8 ;
2009-11-08 23:53:22 +01:00
break ;
}
2010-03-28 20:29:30 +02:00
tmpTpl . RemoveTexture ( 0 ) ;
2010-04-20 21:54:36 +02:00
tmpTpl . AddTexture ( img , ( TPL_TextureFormat ) format , pFormat ) ;
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
bannerBin . ReplaceFile ( bannerBin . GetNodeIndex ( tplName ) , tmpTpl . ToByteArray ( ) ) ;
else newBannerBin . ReplaceFile ( newBannerBin . GetNodeIndex ( tplName ) , tmpTpl . ToByteArray ( ) ) ;
addTpls ( ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-08 23:53:22 +01:00
}
}
2010-03-28 20:29:30 +02:00
else { errorBox ( "This format is not supported, you must choose a different one!" ) ; }
2009-11-08 23:53:22 +01:00
}
}
private void btnExtractBanner_Click ( object sender , EventArgs e )
{
2009-11-24 01:09:42 +01:00
if ( lbxBannerTpls . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
SaveFileDialog sfd = new SaveFileDialog ( ) ;
2009-12-05 02:12:28 +01:00
sfd . Filter = "PNG|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TPL|*.tpl|All|*.png;*.jpg;*.gif;*.bmp;*.tpl" ;
2009-11-24 01:09:42 +01:00
sfd . FilterIndex = 6 ;
2010-03-28 20:29:30 +02:00
sfd . FileName = lbxBannerTpls . SelectedItem . ToString ( ) . Remove ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' , 0 ) - 3 ) . Replace ( ".tpl" , string . Empty ) ;
2009-11-08 23:53:22 +01:00
if ( sfd . ShowDialog ( ) = = DialogResult . OK )
{
try
{
2010-03-28 20:29:30 +02:00
string tplName = lbxBannerTpls . SelectedItem . ToString ( ) . Remove ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' , 0 ) - 3 ) ;
TPL tmpTpl ;
if ( string . IsNullOrEmpty ( replacedBanner ) )
tmpTpl = TPL . Load ( bannerBin . Data [ bannerBin . GetNodeIndex ( tplName ) ] ) ;
else tmpTpl = TPL . Load ( newBannerBin . Data [ newBannerBin . GetNodeIndex ( tplName ) ] ) ;
if ( File . Exists ( sfd . FileName ) ) File . Delete ( sfd . FileName ) ;
2009-12-22 00:58:53 +01:00
if ( ! sfd . FileName . ToLower ( ) . EndsWith ( ".tpl" ) )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
Image img = tmpTpl . ExtractTexture ( ) ;
2009-11-08 23:53:22 +01:00
2009-11-24 01:09:42 +01:00
switch ( sfd . FileName . Remove ( 0 , sfd . FileName . LastIndexOf ( '.' ) ) )
{
case ".jpg" :
2010-03-28 20:29:30 +02:00
img . Save ( sfd . FileName , System . Drawing . Imaging . ImageFormat . Jpeg ) ;
2009-11-24 01:09:42 +01:00
break ;
case ".gif" :
2010-03-28 20:29:30 +02:00
img . Save ( sfd . FileName , System . Drawing . Imaging . ImageFormat . Gif ) ;
2009-11-24 01:09:42 +01:00
break ;
case ".bmp" :
2010-03-28 20:29:30 +02:00
img . Save ( sfd . FileName , System . Drawing . Imaging . ImageFormat . Bmp ) ;
2009-11-24 01:09:42 +01:00
break ;
default :
2010-03-28 20:29:30 +02:00
img . Save ( sfd . FileName , System . Drawing . Imaging . ImageFormat . Png ) ;
2009-11-24 01:09:42 +01:00
break ;
}
}
2010-03-28 20:29:30 +02:00
else tmpTpl . Save ( sfd . FileName ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-08 23:53:22 +01:00
}
}
}
private void btnPreviewBanner_Click ( object sender , EventArgs e )
{
2009-11-24 01:09:42 +01:00
if ( lbxBannerTpls . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
try
{
2009-12-31 04:34:47 +01:00
CustomizeMii_Preview pvw = new CustomizeMii_Preview ( ) ;
2010-03-28 20:29:30 +02:00
pvw . StartTPL = lbxBannerTpls . SelectedItem . ToString ( ) . Remove ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' , 0 ) - 3 ) ;
if ( string . IsNullOrEmpty ( replacedBanner ) ) pvw . BannerBin = bannerBin ;
else pvw . BannerBin = newBannerBin ;
if ( string . IsNullOrEmpty ( replacedIcon ) ) pvw . IconBin = iconBin ;
else pvw . IconBin = newIconBin ;
2009-11-08 23:53:22 +01:00
pvw . ShowDialog ( ) ;
2010-02-06 00:09:36 +01:00
pvw = null ;
2010-03-28 20:29:30 +02:00
addTpls ( ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-12-22 00:58:53 +01:00
lbxBannerTpls . Focus ( ) ;
2009-11-08 23:53:22 +01:00
}
}
private void btnReplaceIcon_Click ( object sender , EventArgs e )
{
2009-11-24 01:09:42 +01:00
if ( lbxIconTpls . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
int format = cmbFormatIcon . SelectedIndex ;
2009-11-08 23:53:22 +01:00
2010-04-20 21:54:36 +02:00
if ( format < 9 )
2009-11-08 23:53:22 +01:00
{
OpenFileDialog ofd = new OpenFileDialog ( ) ;
2009-12-05 02:12:28 +01:00
ofd . Filter = "PNG|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TPL|*.tpl|All|*.png;*.jpg;*.gif;*.bmp;*.tpl" ;
2009-11-24 01:09:42 +01:00
ofd . FilterIndex = 6 ;
2009-11-08 23:53:22 +01:00
if ( ofd . ShowDialog ( ) = = DialogResult . OK )
{
try
{
2010-03-28 20:29:30 +02:00
string tplName = lbxIconTpls . SelectedItem . ToString ( ) . Remove ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' , 0 ) - 3 ) ;
TPL tmpTpl ;
Image img ;
2009-11-24 01:09:42 +01:00
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
tmpTpl = TPL . Load ( iconBin . Data [ iconBin . GetNodeIndex ( tplName ) ] ) ;
else tmpTpl = TPL . Load ( newIconBin . Data [ newIconBin . GetNodeIndex ( tplName ) ] ) ;
2009-11-08 23:53:22 +01:00
2010-03-28 20:29:30 +02:00
if ( ! ofd . FileName . ToLower ( ) . EndsWith ( ".tpl" ) ) img = Image . FromFile ( ofd . FileName ) ;
else
2009-11-08 23:53:22 +01:00
{
2010-03-28 20:29:30 +02:00
TPL newTpl = TPL . Load ( ofd . FileName ) ;
img = newTpl . ExtractTexture ( ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
if ( img . Width ! = tmpTpl . GetTextureSize ( 0 ) . Width | |
img . Height ! = tmpTpl . GetTextureSize ( 0 ) . Height )
img = resizeImage ( img , tmpTpl . GetTextureSize ( 0 ) . Width , tmpTpl . GetTextureSize ( 0 ) . Height ) ;
2010-04-20 21:54:36 +02:00
TPL_PaletteFormat pFormat = TPL_PaletteFormat . RGB5A3 ;
2010-03-28 20:29:30 +02:00
switch ( format )
2009-11-08 23:53:22 +01:00
{
2010-04-20 21:54:36 +02:00
case 6 :
format = ( int ) TPL_TextureFormat . I4 ;
2010-02-06 00:09:36 +01:00
break ;
2010-04-20 21:54:36 +02:00
case 5 :
format = ( int ) TPL_TextureFormat . I8 ;
2010-02-06 00:09:36 +01:00
break ;
2010-04-20 21:54:36 +02:00
case 4 :
format = ( int ) TPL_TextureFormat . IA4 ;
2010-02-06 00:09:36 +01:00
break ;
2010-04-20 21:54:36 +02:00
case 3 :
format = ( int ) TPL_TextureFormat . IA8 ;
2010-02-06 00:09:36 +01:00
break ;
2009-11-08 23:53:22 +01:00
case 1 :
2010-04-20 21:54:36 +02:00
format = ( int ) TPL_TextureFormat . RGB565 ;
2009-11-08 23:53:22 +01:00
break ;
case 2 :
2010-04-20 21:54:36 +02:00
format = ( int ) TPL_TextureFormat . RGB5A3 ;
break ;
case 7 :
format = ( int ) TPL_TextureFormat . CI4 ;
CustomizeMii_PaletteFormatBox pfb = new CustomizeMii_PaletteFormatBox ( ) ;
pfb . ShowDialog ( ) ;
pFormat = pfb . PaletteFormat ;
break ;
case 8 :
format = ( int ) TPL_TextureFormat . CI8 ;
CustomizeMii_PaletteFormatBox pfb2 = new CustomizeMii_PaletteFormatBox ( ) ;
pfb2 . ShowDialog ( ) ;
pFormat = pfb2 . PaletteFormat ;
break ;
case 9 :
format = ( int ) TPL_TextureFormat . CI14X2 ;
CustomizeMii_PaletteFormatBox pfb3 = new CustomizeMii_PaletteFormatBox ( ) ;
pfb3 . ShowDialog ( ) ;
pFormat = pfb3 . PaletteFormat ;
2009-11-08 23:53:22 +01:00
break ;
default :
2010-04-20 21:54:36 +02:00
format = ( int ) TPL_TextureFormat . RGBA8 ;
2009-11-08 23:53:22 +01:00
break ;
}
2010-03-28 20:29:30 +02:00
tmpTpl . RemoveTexture ( 0 ) ;
2010-04-20 21:54:36 +02:00
tmpTpl . AddTexture ( img , ( TPL_TextureFormat ) format , pFormat ) ;
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
iconBin . ReplaceFile ( iconBin . GetNodeIndex ( tplName ) , tmpTpl . ToByteArray ( ) ) ;
else newIconBin . ReplaceFile ( newIconBin . GetNodeIndex ( tplName ) , tmpTpl . ToByteArray ( ) ) ;
addTpls ( ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-08 23:53:22 +01:00
}
}
2010-03-28 20:29:30 +02:00
else errorBox ( "This format is not supported, you must choose a different one!" ) ;
2009-11-08 23:53:22 +01:00
}
}
private void btnExtractIcon_Click ( object sender , EventArgs e )
{
2009-11-24 01:09:42 +01:00
if ( lbxIconTpls . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
SaveFileDialog sfd = new SaveFileDialog ( ) ;
2009-12-05 02:12:28 +01:00
sfd . Filter = "PNG|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TPL|*.tpl|All|*.png;*.jpg;*.gif;*.bmp;*.tpl" ;
2009-11-24 01:09:42 +01:00
sfd . FilterIndex = 6 ;
2010-03-28 20:29:30 +02:00
sfd . FileName = lbxIconTpls . SelectedItem . ToString ( ) . Remove ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' , 0 ) - 3 ) . Replace ( ".tpl" , string . Empty ) ;
2009-11-08 23:53:22 +01:00
if ( sfd . ShowDialog ( ) = = DialogResult . OK )
{
try
{
2010-03-28 20:29:30 +02:00
string tplName = lbxIconTpls . SelectedItem . ToString ( ) . Remove ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' , 0 ) - 3 ) ;
TPL tmpTpl ;
if ( string . IsNullOrEmpty ( replacedIcon ) )
tmpTpl = TPL . Load ( iconBin . Data [ iconBin . GetNodeIndex ( tplName ) ] ) ;
else tmpTpl = TPL . Load ( newIconBin . Data [ newIconBin . GetNodeIndex ( tplName ) ] ) ;
if ( File . Exists ( sfd . FileName ) ) File . Delete ( sfd . FileName ) ;
2009-12-22 00:58:53 +01:00
if ( ! sfd . FileName . ToLower ( ) . EndsWith ( ".tpl" ) )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
Image img = tmpTpl . ExtractTexture ( ) ;
2009-11-08 23:53:22 +01:00
2009-11-24 01:09:42 +01:00
switch ( sfd . FileName . Remove ( 0 , sfd . FileName . LastIndexOf ( '.' ) ) )
{
case ".jpg" :
2010-03-28 20:29:30 +02:00
img . Save ( sfd . FileName , System . Drawing . Imaging . ImageFormat . Jpeg ) ;
2009-11-24 01:09:42 +01:00
break ;
case ".gif" :
2010-03-28 20:29:30 +02:00
img . Save ( sfd . FileName , System . Drawing . Imaging . ImageFormat . Gif ) ;
2009-11-24 01:09:42 +01:00
break ;
case ".bmp" :
2010-03-28 20:29:30 +02:00
img . Save ( sfd . FileName , System . Drawing . Imaging . ImageFormat . Bmp ) ;
2009-11-24 01:09:42 +01:00
break ;
default :
2010-03-28 20:29:30 +02:00
img . Save ( sfd . FileName , System . Drawing . Imaging . ImageFormat . Png ) ;
2009-11-24 01:09:42 +01:00
break ;
}
}
2010-03-28 20:29:30 +02:00
else tmpTpl . Save ( sfd . FileName ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-08 23:53:22 +01:00
}
}
}
private void btnPreviewIcon_Click ( object sender , EventArgs e )
{
2009-11-24 01:09:42 +01:00
if ( lbxIconTpls . SelectedIndex ! = - 1 )
2009-11-08 23:53:22 +01:00
{
try
{
2009-12-31 04:34:47 +01:00
CustomizeMii_Preview pvw = new CustomizeMii_Preview ( ) ;
2010-03-28 20:29:30 +02:00
pvw . StartIcon = true ;
pvw . StartTPL = lbxIconTpls . SelectedItem . ToString ( ) . Remove ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' , 0 ) - 3 ) ;
if ( string . IsNullOrEmpty ( replacedBanner ) ) pvw . BannerBin = bannerBin ;
else pvw . BannerBin = newBannerBin ;
if ( string . IsNullOrEmpty ( replacedIcon ) ) pvw . IconBin = iconBin ;
else pvw . IconBin = newIconBin ;
2009-11-08 23:53:22 +01:00
pvw . ShowDialog ( ) ;
2010-02-06 00:09:36 +01:00
pvw = null ;
2010-03-28 20:29:30 +02:00
addTpls ( ) ;
2009-11-08 23:53:22 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-12-22 00:58:53 +01:00
lbxIconTpls . Focus ( ) ;
2009-11-08 23:53:22 +01:00
}
}
2009-11-24 01:09:42 +01:00
private void btnCreateWad_Click ( object sender , EventArgs e )
{
2009-12-30 18:57:38 +01:00
Point mousePos = MousePosition ;
if ( mousePos . X < ( this . Location . X + btnCreateWad . Location . X + Math . Ceiling ( separatorBtn ) + 3 ) )
2009-11-24 01:09:42 +01:00
{
2010-02-24 22:41:37 +01:00
//SEND WAD
2009-12-30 18:57:38 +01:00
if ( pbProgress . Value = = 100 )
2009-11-24 01:09:42 +01:00
{
2009-12-30 18:57:38 +01:00
if ( ! string . IsNullOrEmpty ( tbSourceWad . Text ) )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
if ( ! File . Exists ( Application . StartupPath + Path . DirectorySeparatorChar + "CustomizeMiiInstaller.dll" ) )
errorBox ( "CustomizeMiiInstaller.dll wasn't found!" ) ;
2010-01-12 18:03:46 +01:00
else
{
2010-03-28 20:29:30 +02:00
if ( cbSecurityChecksOff . Checked = = true | | securityChecks ( ) = = true )
2009-11-08 23:53:22 +01:00
{
2010-01-12 18:03:46 +01:00
CustomizeMii_Transmit cmt = new CustomizeMii_Transmit ( ) ;
2010-01-09 23:50:06 +01:00
2010-01-12 18:03:46 +01:00
if ( cmt . ShowDialog ( ) = = DialogResult . OK )
{
try
{
WadCreationInfo wadInfo = new WadCreationInfo ( ) ;
2010-03-28 20:29:30 +02:00
if ( ! int . TryParse ( tbStartupIos . Text , out wadInfo . startupIos ) ) { errorBox ( "Please enter a valid startup IOS! (0 - 255)" ) ; return ; }
2010-02-25 01:08:01 +01:00
wadInfo . titles = new string [ ] { tbJapanese . Text , tbEnglish . Text , tbGerman . Text , tbFrench . Text , tbSpanish . Text , tbItalian . Text , tbDutch . Text , tbKorean . Text } ;
wadInfo . allLangTitle = tbAllLanguages . Text ;
2010-01-12 18:03:46 +01:00
wadInfo . nandLoader = ( WadCreationInfo . NandLoader ) cmbNandLoader . SelectedIndex ;
wadInfo . sendToWii = true ;
2010-03-28 20:29:30 +02:00
wadInfo . transmitProtocol = ( cmt . Protocol = = 1 ) ? Protocol . HAXX : Protocol . JODI ;
2010-01-12 18:03:46 +01:00
wadInfo . transmitIp = cmt . IPAddress ;
wadInfo . transmitIos = int . Parse ( cmt . IOS ) ;
2010-02-25 01:08:01 +01:00
wadInfo . titleId = tbTitleID . Text ;
wadInfo . sound = tbSound . Text ;
wadInfo . dol = tbDol . Text ;
2010-03-28 20:29:30 +02:00
wadInfo . lz77 = cbLz77 . Checked ;
2010-01-12 18:03:46 +01:00
BackgroundWorker bwCreateWad = new BackgroundWorker ( ) ;
bwCreateWad . DoWork + = new DoWorkEventHandler ( bwCreateWad_DoWork ) ;
bwCreateWad . ProgressChanged + = new ProgressChangedEventHandler ( bwCreateWad_ProgressChanged ) ;
bwCreateWad . RunWorkerCompleted + = new RunWorkerCompletedEventHandler ( bwCreateWad_RunWorkerCompleted ) ;
bwCreateWad . WorkerReportsProgress = true ;
bwCreateWad . RunWorkerAsync ( wadInfo ) ;
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2010-01-12 18:03:46 +01:00
}
2009-11-08 23:53:22 +01:00
}
}
}
}
}
2009-12-30 18:57:38 +01:00
else
{
2010-02-24 22:41:37 +01:00
//CREATE WAD
2009-12-30 18:57:38 +01:00
if ( pbProgress . Value = = 100 )
{
if ( ! string . IsNullOrEmpty ( tbSourceWad . Text ) )
{
2010-03-28 20:29:30 +02:00
if ( cbSecurityChecksOff . Checked = = true | | securityChecks ( ) = = true )
2009-12-30 18:57:38 +01:00
{
SaveFileDialog sfd = new SaveFileDialog ( ) ;
sfd . Filter = "Wii Channels|*.wad" ;
2010-03-28 20:29:30 +02:00
string fileName ;
2009-12-30 18:57:38 +01:00
if ( ! string . IsNullOrEmpty ( tbAllLanguages . Text ) )
2010-03-28 20:29:30 +02:00
fileName = tbAllLanguages . Text + " - " + tbTitleID . Text . ToUpper ( ) + ".wad" ;
2009-12-30 18:57:38 +01:00
else
2010-03-28 20:29:30 +02:00
fileName = tbEnglish . Text + " - " + tbTitleID . Text . ToUpper ( ) + ".wad" ;
foreach ( char invalidChar in Path . GetInvalidFileNameChars ( ) )
fileName = fileName . Replace ( invalidChar . ToString ( ) , string . Empty ) ;
sfd . FileName = fileName ;
2009-12-30 18:57:38 +01:00
if ( sfd . ShowDialog ( ) = = DialogResult . OK )
{
try
{
WadCreationInfo wadInfo = new WadCreationInfo ( ) ;
2010-02-24 22:41:37 +01:00
2010-03-28 20:29:30 +02:00
if ( ! int . TryParse ( tbStartupIos . Text , out wadInfo . startupIos ) ) { errorBox ( "Please enter a valid startup IOS! (0 - 255)" ) ; return ; }
2010-02-24 22:41:37 +01:00
wadInfo . titles = new string [ ] { tbJapanese . Text , tbEnglish . Text , tbGerman . Text , tbFrench . Text , tbSpanish . Text , tbItalian . Text , tbDutch . Text , tbKorean . Text } ;
wadInfo . allLangTitle = tbAllLanguages . Text ;
wadInfo . titleId = tbTitleID . Text ;
wadInfo . sound = tbSound . Text ;
wadInfo . dol = tbDol . Text ;
2010-03-28 20:29:30 +02:00
wadInfo . lz77 = cbLz77 . Checked ;
2010-02-24 22:41:37 +01:00
2009-12-30 18:57:38 +01:00
wadInfo . outFile = sfd . FileName ;
wadInfo . nandLoader = ( WadCreationInfo . NandLoader ) cmbNandLoader . SelectedIndex ;
BackgroundWorker bwCreateWad = new BackgroundWorker ( ) ;
bwCreateWad . DoWork + = new DoWorkEventHandler ( bwCreateWad_DoWork ) ;
bwCreateWad . ProgressChanged + = new ProgressChangedEventHandler ( bwCreateWad_ProgressChanged ) ;
bwCreateWad . RunWorkerCompleted + = new RunWorkerCompletedEventHandler ( bwCreateWad_RunWorkerCompleted ) ;
bwCreateWad . WorkerReportsProgress = true ;
bwCreateWad . RunWorkerAsync ( wadInfo ) ;
2010-02-24 22:41:37 +01:00
return ;
2009-12-30 18:57:38 +01:00
}
catch ( Exception ex )
{
2010-03-28 20:29:30 +02:00
errorBox ( ex . Message ) ;
2009-12-30 18:57:38 +01:00
}
}
}
}
}
2010-02-24 22:41:37 +01:00
currentProgress . progressValue = 100 ;
currentProgress . progressState = " " ;
this . Invoke ( ProgressUpdate ) ;
2009-12-30 18:57:38 +01:00
}
2009-11-08 23:53:22 +01:00
}
2009-11-24 01:09:42 +01:00
private void lbxBrlytBanner_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( lbxBrlytBanner . SelectedIndex ! = - 1 )
lbxBrlytIcon . SelectedIndex = - 1 ;
if ( lbxBrlytIcon . SelectedIndex = = - 1 )
lbBrlytActions . Text = "Banner" ;
else
lbBrlytActions . Text = "Icon" ;
}
private void lbxBrlytIcon_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( lbxBrlytIcon . SelectedIndex ! = - 1 )
lbxBrlytBanner . SelectedIndex = - 1 ;
if ( lbxBrlytIcon . SelectedIndex = = - 1 )
lbBrlytActions . Text = "Banner" ;
else
lbBrlytActions . Text = "Icon" ;
}
private void lbxBrlanBanner_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( lbxBrlanBanner . SelectedIndex ! = - 1 )
lbxBrlanIcon . SelectedIndex = - 1 ;
if ( lbxBrlanIcon . SelectedIndex = = - 1 )
lbBrlanActions . Text = "Banner" ;
else
lbBrlanActions . Text = "Icon" ;
}
private void lbxBrlanIcon_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( lbxBrlanIcon . SelectedIndex ! = - 1 )
lbxBrlanBanner . SelectedIndex = - 1 ;
if ( lbxBrlanIcon . SelectedIndex = = - 1 )
lbBrlanActions . Text = "Banner" ;
else
lbBrlanActions . Text = "Icon" ;
}
private void btnBrlanAdd_Click ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( lbBrlanActions . Text ) )
{
OpenFileDialog ofd = new OpenFileDialog ( ) ;
ofd . Filter = "brlan Files|*.brlan" ;
if ( ofd . ShowDialog ( ) = = DialogResult . OK )
{
try
{
2010-03-28 20:29:30 +02:00
if ( lbBrlanActions . Text . ToLower ( ) = = "banner" )
2009-11-24 01:09:42 +01:00
{
for ( int i = 0 ; i < lbxBrlanBanner . Items . Count ; i + + )
2010-03-28 20:29:30 +02:00
if ( lbxBrlanBanner . Items [ i ] . ToString ( ) . ToLower ( ) = = Path . GetFileName ( ofd . FileName ) . ToLower ( ) )
{ errorBox ( "This file already exists, use the Replace button!" ) ; return ; }
2009-11-24 01:09:42 +01:00
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
{
bannerBin . AddFile ( "/arc/anim/" + Path . GetFileName ( ofd . FileName ) , File . ReadAllBytes ( ofd . FileName ) ) ;
}
2009-11-24 01:09:42 +01:00
else
{
2010-03-28 20:29:30 +02:00
newBannerBin . AddFile ( "/arc/anim/" + Path . GetFileName ( ofd . FileName ) , File . ReadAllBytes ( ofd . FileName ) ) ;
2009-11-24 01:09:42 +01:00
}
2010-03-28 20:29:30 +02:00
brlanChanged = true ;
addBrlans ( ) ;
2009-11-24 01:09:42 +01:00
}
else
{
for ( int i = 0 ; i < lbxBrlanIcon . Items . Count ; i + + )
2010-03-28 20:29:30 +02:00
if ( lbxBrlanIcon . Items [ i ] . ToString ( ) . ToLower ( ) = = Path . GetFileName ( ofd . FileName ) . ToLower ( ) )
{ errorBox ( "This file already exists, use the Replace button!" ) ; return ; }
2009-11-24 01:09:42 +01:00
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
{
iconBin . AddFile ( "/arc/anim/" + Path . GetFileName ( ofd . FileName ) , File . ReadAllBytes ( ofd . FileName ) ) ;
}
2009-11-24 01:09:42 +01:00
else
{
2010-03-28 20:29:30 +02:00
newIconBin . AddFile ( "/arc/anim/" + Path . GetFileName ( ofd . FileName ) , File . ReadAllBytes ( ofd . FileName ) ) ; ;
2009-11-24 01:09:42 +01:00
}
2010-03-28 20:29:30 +02:00
brlanChanged = true ;
addBrlans ( ) ;
2009-11-24 01:09:42 +01:00
}
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-24 01:09:42 +01:00
}
}
}
private void btnBrlytExtract_Click ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( lbBrlytActions . Text ) )
{
SaveFileDialog sfd = new SaveFileDialog ( ) ;
sfd . Filter = "brlyt Files|*.brlyt" ;
2010-03-28 20:29:30 +02:00
if ( lbBrlytActions . Text . ToLower ( ) = = "banner" )
2009-11-24 01:09:42 +01:00
sfd . FileName = lbxBrlytBanner . SelectedItem . ToString ( ) ;
else
sfd . FileName = lbxBrlytIcon . SelectedItem . ToString ( ) ;
if ( sfd . ShowDialog ( ) = = DialogResult . OK )
{
try
{
2010-03-28 20:29:30 +02:00
if ( lbBrlytActions . Text . ToLower ( ) = = "banner" )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
File . WriteAllBytes ( sfd . FileName , bannerBin . Data [ bannerBin . GetNodeIndex ( lbxBrlytBanner . SelectedItem . ToString ( ) ) ] ) ;
2009-11-24 01:09:42 +01:00
else
2010-03-28 20:29:30 +02:00
File . WriteAllBytes ( sfd . FileName , newBannerBin . Data [ newBannerBin . GetNodeIndex ( lbxBrlytBanner . SelectedItem . ToString ( ) ) ] ) ;
2009-11-24 01:09:42 +01:00
}
else
{
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
File . WriteAllBytes ( sfd . FileName , iconBin . Data [ iconBin . GetNodeIndex ( lbxBrlytIcon . SelectedItem . ToString ( ) ) ] ) ;
2009-11-24 01:09:42 +01:00
else
2010-03-28 20:29:30 +02:00
File . WriteAllBytes ( sfd . FileName , newIconBin . Data [ newIconBin . GetNodeIndex ( lbxBrlytIcon . SelectedItem . ToString ( ) ) ] ) ;
2009-11-24 01:09:42 +01:00
}
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-24 01:09:42 +01:00
}
}
}
private void btnBrlanExtract_Click ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( lbBrlanActions . Text ) )
{
SaveFileDialog sfd = new SaveFileDialog ( ) ;
sfd . Filter = "brlan Files|*.brlan" ;
2010-03-28 20:29:30 +02:00
if ( lbBrlanActions . Text . ToLower ( ) = = "banner" )
2009-11-24 01:09:42 +01:00
sfd . FileName = lbxBrlanBanner . SelectedItem . ToString ( ) ;
else
sfd . FileName = lbxBrlanIcon . SelectedItem . ToString ( ) ;
if ( sfd . ShowDialog ( ) = = DialogResult . OK )
{
try
{
2010-03-28 20:29:30 +02:00
if ( lbBrlanActions . Text . ToLower ( ) = = "banner" )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
File . WriteAllBytes ( sfd . FileName , bannerBin . Data [ bannerBin . GetNodeIndex ( lbxBrlanBanner . SelectedItem . ToString ( ) ) ] ) ;
2009-11-24 01:09:42 +01:00
else
2010-03-28 20:29:30 +02:00
File . WriteAllBytes ( sfd . FileName , newBannerBin . Data [ newBannerBin . GetNodeIndex ( lbxBrlanBanner . SelectedItem . ToString ( ) ) ] ) ;
2009-11-24 01:09:42 +01:00
}
else
{
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
File . WriteAllBytes ( sfd . FileName , iconBin . Data [ iconBin . GetNodeIndex ( lbxBrlanIcon . SelectedItem . ToString ( ) ) ] ) ;
2009-11-24 01:09:42 +01:00
else
2010-03-28 20:29:30 +02:00
File . WriteAllBytes ( sfd . FileName , newIconBin . Data [ newIconBin . GetNodeIndex ( lbxBrlanIcon . SelectedItem . ToString ( ) ) ] ) ;
2009-11-24 01:09:42 +01:00
}
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-24 01:09:42 +01:00
}
}
}
private void btnBrlanDelete_Click ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( lbBrlanActions . Text ) )
{
try
{
2010-03-28 20:29:30 +02:00
if ( lbBrlanActions . Text . ToLower ( ) = = "banner" )
2009-11-24 01:09:42 +01:00
{
if ( lbxBrlanBanner . Items . Count > 1 )
{
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
{
bannerBin . RemoveFile ( "/arc/anim/" + lbxBrlanBanner . SelectedItem . ToString ( ) ) ;
}
2009-11-24 01:09:42 +01:00
else
2010-03-28 20:29:30 +02:00
{
newBannerBin . RemoveFile ( "/arc/anim/" + lbxBrlanBanner . SelectedItem . ToString ( ) ) ;
}
2009-11-24 01:09:42 +01:00
2010-03-28 20:29:30 +02:00
brlanChanged = true ;
addBrlans ( ) ;
2009-11-24 01:09:42 +01:00
}
else
2010-03-28 20:29:30 +02:00
errorBox ( "You can't delete the last file.\nAdd a new one first in order to delete this one." ) ;
2009-11-24 01:09:42 +01:00
}
else
{
if ( lbxBrlanIcon . Items . Count > 1 )
{
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
{
iconBin . RemoveFile ( "/arc/anim/" + lbxBrlanBanner . SelectedItem . ToString ( ) ) ;
}
2009-11-24 01:09:42 +01:00
else
2010-03-28 20:29:30 +02:00
{
newIconBin . RemoveFile ( "/arc/anim/" + lbxBrlanBanner . SelectedItem . ToString ( ) ) ;
}
2009-11-24 01:09:42 +01:00
2010-03-28 20:29:30 +02:00
brlanChanged = true ;
addBrlans ( ) ;
2009-11-24 01:09:42 +01:00
}
else
2010-03-28 20:29:30 +02:00
errorBox ( "You can't delete the last file.\nAdd a new one first in order to delete this one." ) ;
2009-11-24 01:09:42 +01:00
}
}
catch { }
}
}
private void btnBrlytReplace_Click ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( lbBrlytActions . Text ) )
{
OpenFileDialog ofd = new OpenFileDialog ( ) ;
ofd . Filter = "brlyt Files|*.brlyt" ;
if ( ofd . ShowDialog ( ) = = DialogResult . OK )
{
try
{
2010-03-28 20:29:30 +02:00
if ( lbBrlytActions . Text . ToLower ( ) = = "banner" )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
bannerBin . ReplaceFile ( bannerBin . GetNodeIndex ( lbxBrlytBanner . SelectedItem . ToString ( ) ) , File . ReadAllBytes ( ofd . FileName ) ) ;
2009-11-24 01:09:42 +01:00
else
2010-03-28 20:29:30 +02:00
newBannerBin . ReplaceFile ( newBannerBin . GetNodeIndex ( lbxBrlytBanner . SelectedItem . ToString ( ) ) , File . ReadAllBytes ( ofd . FileName ) ) ;
brlytChanged = true ;
2009-11-24 01:09:42 +01:00
}
else
{
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
iconBin . ReplaceFile ( iconBin . GetNodeIndex ( lbxBrlytIcon . SelectedItem . ToString ( ) ) , File . ReadAllBytes ( ofd . FileName ) ) ;
2009-11-24 01:09:42 +01:00
else
2010-03-28 20:29:30 +02:00
newIconBin . ReplaceFile ( newIconBin . GetNodeIndex ( lbxBrlytIcon . SelectedItem . ToString ( ) ) , File . ReadAllBytes ( ofd . FileName ) ) ;
brlytChanged = true ;
2009-11-24 01:09:42 +01:00
}
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-24 01:09:42 +01:00
}
}
}
private void btnBrlanReplace_Click ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( lbBrlanActions . Text ) )
{
OpenFileDialog ofd = new OpenFileDialog ( ) ;
ofd . Filter = "brlan Files|*.brlan" ;
if ( ofd . ShowDialog ( ) = = DialogResult . OK )
{
try
{
2010-03-28 20:29:30 +02:00
if ( lbBrlanActions . Text . ToLower ( ) = = "banner" )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
bannerBin . ReplaceFile ( bannerBin . GetNodeIndex ( lbxBrlanBanner . SelectedItem . ToString ( ) ) , File . ReadAllBytes ( ofd . FileName ) ) ;
2009-11-24 01:09:42 +01:00
else
2010-03-28 20:29:30 +02:00
newBannerBin . ReplaceFile ( newBannerBin . GetNodeIndex ( lbxBrlanBanner . SelectedItem . ToString ( ) ) , File . ReadAllBytes ( ofd . FileName ) ) ;
brlanChanged = true ;
2009-11-24 01:09:42 +01:00
}
else
{
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
iconBin . ReplaceFile ( iconBin . GetNodeIndex ( lbxBrlanIcon . SelectedItem . ToString ( ) ) , File . ReadAllBytes ( ofd . FileName ) ) ;
2009-11-24 01:09:42 +01:00
else
2010-03-28 20:29:30 +02:00
newIconBin . ReplaceFile ( newIconBin . GetNodeIndex ( lbxBrlanIcon . SelectedItem . ToString ( ) ) , File . ReadAllBytes ( ofd . FileName ) ) ;
brlanChanged = true ;
2009-11-24 01:09:42 +01:00
}
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-24 01:09:42 +01:00
}
}
}
2010-01-18 21:13:32 +01:00
private void llbUpdateAvailable_LinkClicked ( object sender , LinkLabelLinkClickedEventArgs e )
2009-11-24 01:09:42 +01:00
{
try
{
2010-01-18 21:13:32 +01:00
llbUpdateAvailable . LinkVisited = true ;
2015-12-11 15:38:55 +01:00
Process . Start ( "https://github.com/Brawl345/customizemii/releases" ) ;
2009-11-24 01:09:42 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-24 01:09:42 +01:00
}
private void btnDeleteBanner_Click ( object sender , EventArgs e )
{
2010-01-08 23:10:02 +01:00
if ( lbxBannerTpls . SelectedIndex ! = - 1 )
2009-11-24 01:09:42 +01:00
{
2010-01-08 23:10:02 +01:00
int idx = lbxBannerTpls . SelectedIndex ;
2009-11-24 01:09:42 +01:00
2010-01-08 23:10:02 +01:00
try
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
string tplName = lbxBannerTpls . SelectedItem . ToString ( ) . Remove ( lbxBannerTpls . SelectedItem . ToString ( ) . IndexOf ( '(' , 0 ) - 3 ) ;
string [ ] requiredTpls = new string [ 0 ] ;
2009-11-24 01:09:42 +01:00
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
for ( int i = 0 ; i < bannerBin . NumOfNodes ; i + + )
{
if ( bannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlyt . GetBrlytTpls ( bannerBin . Data [ i ] ) ) ; }
else if ( bannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlan . GetBrlanTpls ( bannerBin . Data [ i ] ) ) ; }
}
2009-11-24 01:09:42 +01:00
}
2010-01-08 23:10:02 +01:00
else
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
for ( int i = 0 ; i < newBannerBin . NumOfNodes ; i + + )
{
if ( newBannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlyt . GetBrlytTpls ( newBannerBin . Data [ i ] ) ) ; }
else if ( newBannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlan . GetBrlanTpls ( newBannerBin . Data [ i ] ) ) ; }
}
2009-11-24 01:09:42 +01:00
}
2010-03-28 20:29:30 +02:00
if ( ! Array . Exists ( requiredTpls , thisTpl = > thisTpl . ToLower ( ) = = tplName . ToLower ( ) ) | | cbSecurityChecksOff . Checked )
{
if ( string . IsNullOrEmpty ( replacedBanner ) )
{
bannerBin . RemoveFile ( "/arc/timg/" + tplName ) ;
}
else
{
newBannerBin . RemoveFile ( "/arc/timg/" + tplName ) ;
}
addTpls ( ) ;
}
else
errorBox ( "This TPL is required by your banner.brlyt and thus can't be deleted!\nYou can still replace the image using the Replace button!" ) ;
2010-01-08 23:10:02 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-24 01:09:42 +01:00
2010-01-08 23:10:02 +01:00
for ( ; ; )
{
try
2009-11-24 01:09:42 +01:00
{
2010-01-08 23:10:02 +01:00
lbxBannerTpls . SelectedIndex = idx ;
break ;
2009-11-24 01:09:42 +01:00
}
2010-01-08 23:10:02 +01:00
catch { idx - - ; }
2010-03-28 20:29:30 +02:00
if ( idx < - 1 ) break ;
2009-11-24 01:09:42 +01:00
}
}
2010-01-08 23:10:02 +01:00
lbxBannerTpls . Select ( ) ;
2009-11-24 01:09:42 +01:00
}
2010-01-08 23:10:02 +01:00
private void btnDeleteIcon_Click ( object sender , EventArgs e )
2009-11-24 01:09:42 +01:00
{
2010-01-08 23:10:02 +01:00
if ( lbxIconTpls . SelectedIndex ! = - 1 )
2009-11-24 01:09:42 +01:00
{
2010-01-08 23:10:02 +01:00
int idx = lbxIconTpls . SelectedIndex ;
2009-11-24 01:09:42 +01:00
2010-01-08 23:10:02 +01:00
try
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
string tplName = lbxIconTpls . SelectedItem . ToString ( ) . Remove ( lbxIconTpls . SelectedItem . ToString ( ) . IndexOf ( '(' , 0 ) - 3 ) ;
string [ ] requiredTpls = new string [ 0 ] ;
2009-11-24 01:09:42 +01:00
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
for ( int i = 0 ; i < iconBin . NumOfNodes ; i + + )
{
if ( iconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlyt . GetBrlytTpls ( iconBin . Data [ i ] ) ) ; }
else if ( iconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlan . GetBrlanTpls ( iconBin . Data [ i ] ) ) ; }
}
2009-11-24 01:09:42 +01:00
}
2010-01-08 23:10:02 +01:00
else
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
for ( int i = 0 ; i < newIconBin . NumOfNodes ; i + + )
{
if ( newIconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlyt . GetBrlytTpls ( newIconBin . Data [ i ] ) ) ; }
else if ( newIconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlan . GetBrlanTpls ( newIconBin . Data [ i ] ) ) ; }
}
2009-11-24 01:09:42 +01:00
}
2010-03-28 20:29:30 +02:00
if ( ! Array . Exists ( requiredTpls , thisTpl = > thisTpl . ToLower ( ) = = tplName . ToLower ( ) ) | | cbSecurityChecksOff . Checked )
{
if ( string . IsNullOrEmpty ( replacedIcon ) )
{
iconBin . RemoveFile ( "/arc/timg/" + tplName ) ;
}
else
{
newIconBin . RemoveFile ( "/arc/timg/" + tplName ) ;
}
addTpls ( ) ;
}
else
errorBox ( "This TPL is required by your icon.brlyt and thus can't be deleted!\nYou can still replace the image using the Replace button!" ) ;
2010-01-08 23:10:02 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-24 01:09:42 +01:00
2010-01-08 23:10:02 +01:00
for ( ; ; )
{
try
2009-11-24 01:09:42 +01:00
{
2010-01-08 23:10:02 +01:00
lbxIconTpls . SelectedIndex = idx ;
break ;
2009-11-24 01:09:42 +01:00
}
2010-01-08 23:10:02 +01:00
catch { idx - - ; }
2010-03-28 20:29:30 +02:00
if ( idx < - 1 ) break ;
2009-11-24 01:09:42 +01:00
}
}
2010-01-08 23:10:02 +01:00
lbxIconTpls . Select ( ) ;
}
private void btnAddBanner_Click ( object sender , EventArgs e )
{
2010-03-28 20:29:30 +02:00
try { addTpl ( lbxBannerTpls ) ; }
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2010-01-08 23:10:02 +01:00
}
private void btnAddIcon_Click ( object sender , EventArgs e )
{
2010-03-28 20:29:30 +02:00
try { addTpl ( lbxIconTpls ) ; }
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-11-24 01:09:42 +01:00
}
private void btnBrlytListTpls_Click ( object sender , EventArgs e )
{
2010-03-28 20:29:30 +02:00
if ( lbBrlytActions . Text . ToLower ( ) = = "banner" )
2009-11-24 01:09:42 +01:00
{
2010-03-28 20:29:30 +02:00
string [ ] requiredTpls = new string [ 0 ] ;
if ( string . IsNullOrEmpty ( replacedBanner ) )
{
for ( int i = 0 ; i < bannerBin . NumOfNodes ; i + + )
{
if ( bannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlyt . GetBrlytTpls ( bannerBin . Data [ i ] ) ) ; }
else if ( bannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlan . GetBrlanTpls ( bannerBin . Data [ i ] ) ) ; }
}
}
else
{
for ( int i = 0 ; i < newBannerBin . NumOfNodes ; i + + )
{
if ( newBannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlyt . GetBrlytTpls ( newBannerBin . Data [ i ] ) ) ; }
else if ( newBannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlan . GetBrlanTpls ( newBannerBin . Data [ i ] ) ) ; }
}
}
2009-11-24 01:09:42 +01:00
MessageBox . Show ( "These are the TPLs required by your banner.brlyt:\n\n" +
2010-03-28 20:29:30 +02:00
string . Join ( "\n" , requiredTpls ) , "TPLs specified in banner.brlyt" , MessageBoxButtons . OK ,
2009-11-24 01:09:42 +01:00
MessageBoxIcon . Information ) ;
}
else
{
2010-03-28 20:29:30 +02:00
string [ ] requiredTpls = new string [ 0 ] ;
if ( string . IsNullOrEmpty ( replacedIcon ) )
{
for ( int i = 0 ; i < iconBin . NumOfNodes ; i + + )
{
if ( iconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlyt . GetBrlytTpls ( iconBin . Data [ i ] ) ) ; }
else if ( iconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlan . GetBrlanTpls ( iconBin . Data [ i ] ) ) ; }
}
}
else
{
for ( int i = 0 ; i < newIconBin . NumOfNodes ; i + + )
{
if ( newIconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlyt . GetBrlytTpls ( newIconBin . Data [ i ] ) ) ; }
else if ( newIconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ requiredTpls = Shared . MergeStringArrays ( requiredTpls , Brlan . GetBrlanTpls ( newIconBin . Data [ i ] ) ) ; }
}
}
2009-11-24 01:09:42 +01:00
MessageBox . Show ( "These are the TPLs required by your icon.brlyt:\n\n" +
2010-03-28 20:29:30 +02:00
string . Join ( "\n" , requiredTpls ) , "TPLs specified in icon.brlyt" , MessageBoxButtons . OK ,
2009-11-24 01:09:42 +01:00
MessageBoxIcon . Information ) ;
}
}
private void cbBannerMakeTransparent_CheckedChanged ( object sender , EventArgs e )
{
if ( lbxBannerTpls . SelectedIndex ! = - 1 )
{
if ( cbBannerMakeTransparent . Checked = = true )
{
try
{
if ( ! lbxBannerTpls . SelectedItem . ToString ( ) . EndsWith ( "(Transparent)" ) )
{
2010-02-24 22:41:37 +01:00
string thisItem = lbxBannerTpls . SelectedItem . ToString ( ) ;
2009-11-24 01:09:42 +01:00
lbxBannerTpls . Items . Remove ( lbxBannerTpls . SelectedItem ) ;
lbxBannerTpls . Items . Add ( thisItem + " (Transparent)" ) ;
lbxBannerTpls . SelectedItem = thisItem + " (Transparent)" ;
2010-03-28 20:29:30 +02:00
bannerTransparents . Add ( thisItem . Remove ( thisItem . IndexOf ( '(' , 0 ) - 3 ) ) ;
2009-11-24 01:09:42 +01:00
}
}
catch { }
}
else
{
try
{
2010-02-24 22:41:37 +01:00
string thisItem = lbxBannerTpls . SelectedItem . ToString ( ) ;
2009-11-24 01:09:42 +01:00
lbxBannerTpls . Items . Remove ( lbxBannerTpls . SelectedItem ) ;
lbxBannerTpls . Items . Add ( thisItem . Replace ( " (Transparent)" , string . Empty ) ) ;
lbxBannerTpls . SelectedItem = thisItem . Replace ( " (Transparent)" , string . Empty ) ;
2010-03-28 20:29:30 +02:00
bannerTransparents . Remove ( thisItem . Remove ( thisItem . IndexOf ( '(' , 0 ) - 3 ) ) ;
2009-11-24 01:09:42 +01:00
}
catch { }
}
2009-12-22 00:58:53 +01:00
lbxBannerTpls . Focus ( ) ;
2009-11-24 01:09:42 +01:00
}
}
private void cbIconMakeTransparent_CheckedChanged ( object sender , EventArgs e )
{
if ( lbxIconTpls . SelectedIndex ! = - 1 )
{
if ( cbIconMakeTransparent . Checked = = true )
{
try
{
if ( ! lbxIconTpls . SelectedItem . ToString ( ) . EndsWith ( "(Transparent)" ) )
{
2010-02-24 22:41:37 +01:00
string thisItem = lbxIconTpls . SelectedItem . ToString ( ) ;
2009-11-24 01:09:42 +01:00
lbxIconTpls . Items . Remove ( lbxIconTpls . SelectedItem ) ;
lbxIconTpls . Items . Add ( thisItem + " (Transparent)" ) ;
lbxIconTpls . SelectedItem = thisItem + " (Transparent)" ;
2010-03-28 20:29:30 +02:00
iconTransparents . Add ( thisItem . Remove ( thisItem . IndexOf ( '(' , 0 ) - 3 ) ) ;
2009-11-24 01:09:42 +01:00
}
}
catch { }
}
else
{
try
{
2010-02-24 22:41:37 +01:00
string thisItem = lbxIconTpls . SelectedItem . ToString ( ) ;
2009-11-24 01:09:42 +01:00
lbxIconTpls . Items . Remove ( lbxIconTpls . SelectedItem ) ;
lbxIconTpls . Items . Add ( thisItem . Replace ( " (Transparent)" , string . Empty ) ) ;
lbxIconTpls . SelectedItem = thisItem . Replace ( " (Transparent)" , string . Empty ) ;
2010-03-28 20:29:30 +02:00
iconTransparents . Remove ( thisItem . Remove ( thisItem . IndexOf ( '(' , 0 ) - 3 ) ) ;
2009-11-24 01:09:42 +01:00
}
catch { }
}
2009-12-22 00:58:53 +01:00
lbxIconTpls . Focus ( ) ;
2009-11-24 01:09:42 +01:00
}
}
2009-12-05 02:12:28 +01:00
private void btnForwarder_Click ( object sender , EventArgs e )
{
2010-03-28 20:29:30 +02:00
if ( checkForForwardMii ( ) = = true )
2009-12-05 02:12:28 +01:00
{
2010-03-28 20:29:30 +02:00
if ( checkDevKit ( ) = = false )
forwarderDialogSimple ( ) ;
2009-12-05 02:12:28 +01:00
else
cmForwarder . Show ( MousePosition ) ;
}
2010-03-28 20:29:30 +02:00
else errorBox ( "ForwardMii.dll wasn't found!" ) ;
2009-12-05 02:12:28 +01:00
}
private void cmForwarderItem_Click ( object sender , EventArgs e )
{
ToolStripMenuItem cmSender = sender as ToolStripMenuItem ;
if ( cmSender = = cmSimpleForwarder )
2010-03-28 20:29:30 +02:00
forwarderDialogSimple ( ) ;
2009-12-05 02:12:28 +01:00
else
2010-01-18 21:13:32 +01:00
{
2010-03-28 20:29:30 +02:00
try { forwarderDialogComplex ( ) ; }
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2010-01-18 21:13:32 +01:00
}
2009-12-05 02:12:28 +01:00
}
2009-12-22 00:58:53 +01:00
private void btnOptionsExtract_Click ( object sender , EventArgs e )
{
cmOptionsExtract . Show ( MousePosition ) ;
}
private void cmOptionsExtract_MouseClick ( object sender , EventArgs e )
{
ToolStripMenuItem cmSender = sender as ToolStripMenuItem ;
if ( cmSender . OwnerItem = = tsExtractImages )
{
try
{
FolderBrowserDialog fbd = new FolderBrowserDialog ( ) ;
if ( cmSender . Text . ToLower ( ) = = "both" ) { fbd . Description = "Select the path where the images will be extracted to. Two folders \"Banner\" and \"Icon\" will be created." ; }
else { fbd . Description = "Select the path where the images will be extracted to." ; }
if ( fbd . ShowDialog ( ) = = DialogResult . OK )
{
string bannerPath ;
string iconPath ;
switch ( cmSender . Text . ToLower ( ) )
{
case "banner" :
bannerPath = fbd . SelectedPath ;
iconPath = string . Empty ;
break ;
case "icon" :
bannerPath = string . Empty ;
iconPath = fbd . SelectedPath ;
break ;
default : //both
2010-03-28 20:29:30 +02:00
bannerPath = fbd . SelectedPath + Path . DirectorySeparatorChar + "Banner" ;
iconPath = fbd . SelectedPath + Path . DirectorySeparatorChar + "Icon" ;
2009-12-22 00:58:53 +01:00
break ;
}
if ( ! string . IsNullOrEmpty ( bannerPath ) )
{
if ( ! Directory . Exists ( bannerPath ) ) Directory . CreateDirectory ( bannerPath ) ;
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
{
for ( int i = 0 ; i < bannerBin . NumOfNodes ; i + + )
{
if ( bannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".tpl" ) )
{
Image img = TPL . Load ( bannerBin . Data [ i ] ) . ExtractTexture ( ) ;
img . Save ( bannerPath + Path . DirectorySeparatorChar + Path . GetFileNameWithoutExtension ( bannerBin . StringTable [ i ] ) + ".png" ) ;
}
}
}
else
2009-12-22 00:58:53 +01:00
{
2010-03-28 20:29:30 +02:00
for ( int i = 0 ; i < newBannerBin . NumOfNodes ; i + + )
{
if ( newBannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".tpl" ) )
{
Image img = TPL . Load ( newBannerBin . Data [ i ] ) . ExtractTexture ( ) ;
img . Save ( bannerPath + Path . DirectorySeparatorChar + Path . GetFileNameWithoutExtension ( newBannerBin . StringTable [ i ] ) + ".png" ) ;
}
}
2009-12-22 00:58:53 +01:00
}
}
2010-03-28 20:29:30 +02:00
2009-12-22 00:58:53 +01:00
if ( ! string . IsNullOrEmpty ( iconPath ) )
{
if ( ! Directory . Exists ( iconPath ) ) Directory . CreateDirectory ( iconPath ) ;
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
2009-12-22 00:58:53 +01:00
{
2010-03-28 20:29:30 +02:00
for ( int i = 0 ; i < iconBin . NumOfNodes ; i + + )
{
if ( iconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".tpl" ) )
{
Image img = TPL . Load ( iconBin . Data [ i ] ) . ExtractTexture ( ) ;
img . Save ( iconPath + Path . DirectorySeparatorChar + Path . GetFileNameWithoutExtension ( iconBin . StringTable [ i ] ) + ".png" ) ;
}
}
}
else
{
for ( int i = 0 ; i < newIconBin . NumOfNodes ; i + + )
{
if ( newIconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".tpl" ) )
{
Image img = TPL . Load ( newIconBin . Data [ i ] ) . ExtractTexture ( ) ;
img . Save ( iconPath + Path . DirectorySeparatorChar + Path . GetFileNameWithoutExtension ( newIconBin . StringTable [ i ] ) + ".png" ) ;
}
}
2009-12-22 00:58:53 +01:00
}
}
2010-03-28 20:29:30 +02:00
infoBox ( "Extracted images successfully!" ) ;
2009-12-22 00:58:53 +01:00
}
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-12-22 00:58:53 +01:00
}
else if ( cmSender . OwnerItem = = tsExtractSound )
{
try
{
2010-03-28 20:29:30 +02:00
byte [ ] soundFile = new byte [ 0 ] ;
if ( string . IsNullOrEmpty ( replacedSound ) )
{
for ( int i = 0 ; i < sourceWad . BannerApp . NumOfNodes ; i + + )
{
if ( sourceWad . BannerApp . StringTable [ i ] . ToLower ( ) = = "sound.bin" )
soundFile = sourceWad . BannerApp . Data [ i ] ;
}
}
else
{ soundFile = newSoundBin ; }
SaveFileDialog sfd = new SaveFileDialog ( ) ;
if ( cmSender . Name . ToLower ( ) = = "cmextractsoundasbin" ) { sfd . Filter = "BIN|*.bin" ; sfd . FileName = "sound.bin" ; }
else if ( cmSender . Name . ToLower ( ) = = "cmextractsoundasaudio" )
2009-12-22 00:58:53 +01:00
{
2010-04-20 21:54:36 +02:00
if ( soundFile [ 32 ] = = 'R' & & soundFile [ 33 ] = = 'I' & & soundFile [ 34 ] = = 'F' & & soundFile [ 35 ] = = 'F' )
2009-12-22 00:58:53 +01:00
{ sfd . Filter = "Wave|*.wav" ; sfd . FileName = "sound.wav" ; }
2010-04-20 21:54:36 +02:00
else if ( soundFile [ 32 ] = = 'B' & & soundFile [ 33 ] = = 'N' & & soundFile [ 34 ] = = 'S' & & soundFile [ 35 ] = = ' ' )
{ sfd . Filter = "Wave|*.wav" ; sfd . FileName = "sound.wav" ; }
else if ( soundFile [ 32 ] = = 'F' & & soundFile [ 33 ] = = 'O' & & soundFile [ 34 ] = = 'R' & & soundFile [ 35 ] = = 'M' )
2009-12-22 00:58:53 +01:00
{ sfd . Filter = "AIFF|*.aif;*.aiff" ; sfd . FileName = "sound.aif" ; }
2010-04-20 21:54:36 +02:00
else if ( soundFile [ 32 ] = = 'L' & & soundFile [ 33 ] = = 'Z' & & soundFile [ 34 ] = = '7' & & soundFile [ 35 ] = = '7' )
2010-03-28 20:29:30 +02:00
{
2010-04-20 21:54:36 +02:00
if ( soundFile [ 41 ] = = 'R' & & soundFile [ 42 ] = = 'I' & & soundFile [ 43 ] = = 'F' & & soundFile [ 44 ] = = 'F' )
2010-03-28 20:29:30 +02:00
{ sfd . Filter = "Wave|*.wav" ; sfd . FileName = "sound.wav" ; }
2010-04-20 21:54:36 +02:00
else if ( soundFile [ 41 ] = = 'B' & & soundFile [ 42 ] = = 'N' & & soundFile [ 43 ] = = 'S' & & soundFile [ 44 ] = = ' ' )
{ sfd . Filter = "Wave|*.wav" ; sfd . FileName = "sound.wave" ; }
else if ( soundFile [ 41 ] = = 'F' & & soundFile [ 42 ] = = 'O' & & soundFile [ 43 ] = = 'R' & & soundFile [ 44 ] = = 'M' )
2010-03-28 20:29:30 +02:00
{ sfd . Filter = "AIFF|*.aif;*.aiff" ; sfd . FileName = "sound.aif" ; }
else throw new Exception ( "Unsupported Audio Format!" ) ;
}
2009-12-22 00:58:53 +01:00
else throw new Exception ( "Unsupported Audio Format!" ) ;
}
2010-03-28 20:29:30 +02:00
if ( sfd . ShowDialog ( ) = = DialogResult . OK )
2009-12-22 00:58:53 +01:00
{
2010-03-28 20:29:30 +02:00
if ( File . Exists ( sfd . FileName ) ) File . Delete ( sfd . FileName ) ;
if ( sfd . FileName . ToLower ( ) . EndsWith ( ".bin" ) )
{
File . WriteAllBytes ( sfd . FileName , soundFile ) ;
infoBox ( "The sound.bin was successfully extraced!" ) ;
}
else
{
soundFile = Headers . IMD5 . RemoveHeader ( soundFile ) ;
if ( Lz77 . IsLz77Compressed ( soundFile ) )
{ Lz77 l = new Lz77 ( ) ; soundFile = l . Decompress ( soundFile ) ; }
2010-04-20 21:54:36 +02:00
if ( soundFile [ 0 ] = = 'B' & & soundFile [ 1 ] = = 'N' & & soundFile [ 2 ] = = 'S' & & soundFile [ 3 ] = = ' ' )
{
Wave w = BNS . BnsToWave ( soundFile ) ;
w . Save ( sfd . FileName ) ;
w . Dispose ( ) ;
}
else
File . WriteAllBytes ( sfd . FileName , soundFile ) ;
2010-03-28 20:29:30 +02:00
infoBox ( string . Format ( "The sound.bin was successfully converted to {0}!" , Path . GetFileName ( sfd . FileName ) ) ) ;
}
2009-12-22 00:58:53 +01:00
}
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-12-22 00:58:53 +01:00
}
2010-01-12 18:03:46 +01:00
else if ( cmSender . OwnerItem = = tsExtractBrl )
{
try
{
FolderBrowserDialog fbd = new FolderBrowserDialog ( ) ;
fbd . Description = "Select the path where the files will be extracted to." ;
if ( fbd . ShowDialog ( ) = = DialogResult . OK )
{
if ( cmSender = = cmExtractBrlyt | | cmSender = = cmExtractBothBrl )
{
//Extract brlyts
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
{
for ( int i = 0 ; i < bannerBin . NumOfNodes ; i + + )
{
if ( bannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ File . WriteAllBytes ( fbd . SelectedPath + Path . DirectorySeparatorChar + bannerBin . StringTable [ i ] , bannerBin . Data [ i ] ) ; }
}
}
else
{
for ( int i = 0 ; i < newBannerBin . NumOfNodes ; i + + )
{
if ( newBannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ File . WriteAllBytes ( fbd . SelectedPath + Path . DirectorySeparatorChar + newBannerBin . StringTable [ i ] , newBannerBin . Data [ i ] ) ; }
}
}
2010-01-12 18:03:46 +01:00
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
{
for ( int i = 0 ; i < iconBin . NumOfNodes ; i + + )
{
if ( iconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ File . WriteAllBytes ( fbd . SelectedPath + Path . DirectorySeparatorChar + iconBin . StringTable [ i ] , iconBin . Data [ i ] ) ; }
}
}
else
{
for ( int i = 0 ; i < newIconBin . NumOfNodes ; i + + )
{
if ( newIconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlyt" ) )
{ File . WriteAllBytes ( fbd . SelectedPath + Path . DirectorySeparatorChar + newIconBin . StringTable [ i ] , newIconBin . Data [ i ] ) ; }
}
}
2010-01-12 18:03:46 +01:00
}
if ( cmSender = = cmExtractBothBrl | | cmSender = = cmExtractBrlan )
{
//Extract brlans
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedBanner ) )
{
for ( int i = 0 ; i < bannerBin . NumOfNodes ; i + + )
{
if ( bannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ File . WriteAllBytes ( fbd . SelectedPath + Path . DirectorySeparatorChar + bannerBin . StringTable [ i ] , bannerBin . Data [ i ] ) ; }
}
}
else
{
for ( int i = 0 ; i < newBannerBin . NumOfNodes ; i + + )
{
if ( newBannerBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ File . WriteAllBytes ( fbd . SelectedPath + Path . DirectorySeparatorChar + newBannerBin . StringTable [ i ] , newBannerBin . Data [ i ] ) ; }
}
}
2010-01-12 18:03:46 +01:00
2010-03-28 20:29:30 +02:00
if ( string . IsNullOrEmpty ( replacedIcon ) )
{
for ( int i = 0 ; i < iconBin . NumOfNodes ; i + + )
{
if ( iconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ File . WriteAllBytes ( fbd . SelectedPath + Path . DirectorySeparatorChar + iconBin . StringTable [ i ] , iconBin . Data [ i ] ) ; }
}
}
else
{
for ( int i = 0 ; i < newIconBin . NumOfNodes ; i + + )
{
if ( newIconBin . StringTable [ i ] . ToLower ( ) . EndsWith ( ".brlan" ) )
{ File . WriteAllBytes ( fbd . SelectedPath + Path . DirectorySeparatorChar + newIconBin . StringTable [ i ] , newIconBin . Data [ i ] ) ; }
}
}
2010-01-12 18:03:46 +01:00
}
2010-03-28 20:29:30 +02:00
infoBox ( "Extracted files successfully!" ) ;
2010-01-12 18:03:46 +01:00
}
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2010-01-12 18:03:46 +01:00
}
2009-12-22 00:58:53 +01:00
else //DOL
{
try
{
2010-03-28 20:29:30 +02:00
if ( sourceWad . NumOfContents = = 3 )
2009-12-22 00:58:53 +01:00
{
2010-03-28 20:29:30 +02:00
int appIndex = 0 ;
if ( sourceWad . BootIndex = = 1 ) appIndex = 2 ;
else if ( sourceWad . BootIndex = = 2 ) appIndex = 1 ;
2009-12-22 00:58:53 +01:00
2010-03-28 20:29:30 +02:00
if ( appIndex > 0 )
2009-12-22 00:58:53 +01:00
{
SaveFileDialog sfd = new SaveFileDialog ( ) ;
sfd . Filter = "Wii Executables|*.dol" ; sfd . FileName = ( string . IsNullOrEmpty ( tbAllLanguages . Text ) ? tbEnglish . Text : tbAllLanguages . Text ) + ".dol" ;
if ( sfd . ShowDialog ( ) = = DialogResult . OK )
{
2010-03-28 20:29:30 +02:00
if ( File . Exists ( sfd . FileName ) ) File . Delete ( sfd . FileName ) ;
File . WriteAllBytes ( sfd . FileName , sourceWad . Contents [ appIndex ] ) ;
infoBox ( string . Format ( "The DOL file was successfully extracted to {0}!" , Path . GetFileName ( sfd . FileName ) ) ) ;
2009-12-22 00:58:53 +01:00
}
}
2010-03-28 20:29:30 +02:00
else errorBox ( "The DOL file couldn't be found!" ) ;
2009-12-22 00:58:53 +01:00
}
2010-03-28 20:29:30 +02:00
else errorBox ( "The DOL file couldn't be found!" ) ;
2009-12-22 00:58:53 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2009-12-22 00:58:53 +01:00
}
}
private void cmLoadAudioFile_Click ( object sender , EventArgs e )
{
if ( pbProgress . Value = = 100 )
{
OpenFileDialog ofd = new OpenFileDialog ( ) ;
2010-03-28 20:29:30 +02:00
if ( File . Exists ( Application . StartupPath + Path . DirectorySeparatorChar + "lame.exe" ) )
2009-12-22 00:58:53 +01:00
{
ofd . Filter = "Wave Files|*.wav|Mp3 Files|*.mp3|BNS Files|*.bns|All|*.wav;*.mp3;*.bns" ;
ofd . FilterIndex = 4 ;
}
else
{
ofd . Filter = "Wave Files|*.wav|BNS Files|*.bns|All|*.wav;*.bns" ;
ofd . FilterIndex = 3 ;
}
if ( ofd . ShowDialog ( ) = = DialogResult . OK )
{
if ( ofd . FileName . ToLower ( ) . EndsWith ( ".mp3" ) )
{
2010-03-28 20:29:30 +02:00
convertMp3ToWave ( ofd . FileName ) ;
2009-12-22 00:58:53 +01:00
}
else
{
2010-03-28 20:29:30 +02:00
replacedSound = ofd . FileName ;
setControlText ( tbSound , ofd . FileName ) ;
2009-12-22 00:58:53 +01:00
btnBrowseSound . Text = "Clear" ;
2010-03-28 20:29:30 +02:00
newSoundBin = Headers . IMD5 . AddHeader ( File . ReadAllBytes ( ofd . FileName ) ) ;
if ( cmbReplace . SelectedIndex = = 2 ) setControlText ( tbReplace , string . Empty ) ;
2009-12-22 00:58:53 +01:00
}
}
}
}
private void cmConvertToBns_Click ( object sender , EventArgs e )
{
if ( pbProgress . Value = = 100 )
{
2010-03-28 20:29:30 +02:00
CustomizeMii_BnsConvert bnsConvert = new CustomizeMii_BnsConvert ( File . Exists ( Application . StartupPath + Path . DirectorySeparatorChar + "lame.exe" ) ) ;
for ( int i = 0 ; i < sourceWad . BannerApp . NumOfNodes ; i + + )
{
if ( sourceWad . BannerApp . StringTable [ i ] . ToLower ( ) = = "sound.bin" )
bnsConvert . SourceSound = Headers . IMD5 . RemoveHeader ( sourceWad . BannerApp . Data [ i ] ) ;
}
2009-12-22 00:58:53 +01:00
if ( bnsConvert . ShowDialog ( ) = = DialogResult . OK )
{
BnsConversionInfo bnsInfo = new BnsConversionInfo ( ) ;
2010-03-28 20:29:30 +02:00
bnsInfo . audioFile = bnsConvert . AudioFile ;
bnsInfo . stereoToMono = false ;
2009-12-22 00:58:53 +01:00
if ( bnsConvert . ChannelCount = = 2 )
{
if ( MessageBox . Show ( "Do you want to convert the stereo Wave file to a mono BNS file?\nOnly the left channel will be taken." ,
"Convert to Mono?" , MessageBoxButtons . YesNo , MessageBoxIcon . Question ) = = DialogResult . Yes )
2010-03-28 20:29:30 +02:00
bnsInfo . stereoToMono = true ;
2009-12-22 00:58:53 +01:00
}
if ( bnsConvert . LoopFromAudio )
2010-03-28 20:29:30 +02:00
{ bnsInfo . loopType = BnsConversionInfo . LoopType . FromWave ; }
2009-12-22 00:58:53 +01:00
else if ( bnsConvert . LoopManually )
2010-03-28 20:29:30 +02:00
{ bnsInfo . loopStartSample = bnsConvert . LoopStartSample ; bnsInfo . loopType = BnsConversionInfo . LoopType . Manual ; }
else bnsInfo . loopType = BnsConversionInfo . LoopType . None ;
2009-12-22 00:58:53 +01:00
BackgroundWorker bwConvertToBns = new BackgroundWorker ( ) ;
bwConvertToBns . WorkerReportsProgress = true ;
bwConvertToBns . DoWork + = new DoWorkEventHandler ( bwConvertToBns_DoWork ) ;
bwConvertToBns . ProgressChanged + = new ProgressChangedEventHandler ( bwConvertToBns_ProgressChanged ) ;
bwConvertToBns . RunWorkerCompleted + = new RunWorkerCompletedEventHandler ( bwConvertToBns_RunWorkerCompleted ) ;
bwConvertToBns . RunWorkerAsync ( bnsInfo ) ;
}
}
}
private void cmExtractWad_Click ( object sender , EventArgs e )
{
2010-03-28 20:29:30 +02:00
string unpackDir = string . Format ( "{0} - {1}" , sourceWad . ChannelTitles [ 1 ] , sourceWad . UpperTitleID ) ;
2009-12-22 00:58:53 +01:00
FolderBrowserDialog fbd = new FolderBrowserDialog ( ) ;
fbd . Description = string . Format ( "Choose the path where the WAD will be extracted to. A folder called \"{0}\" containing the contents will be created!" , unpackDir ) ;
if ( fbd . ShowDialog ( ) = = DialogResult . OK )
{
2010-03-28 20:29:30 +02:00
if ( ! Directory . Exists ( fbd . SelectedPath + Path . DirectorySeparatorChar + unpackDir ) ) Directory . CreateDirectory ( fbd . SelectedPath + Path . DirectorySeparatorChar + unpackDir ) ;
sourceWad . Unpack ( fbd . SelectedPath + Path . DirectorySeparatorChar + unpackDir , false ) ;
2009-12-22 00:58:53 +01:00
2010-03-28 20:29:30 +02:00
infoBox ( "Successfully extracted WAD file!" ) ;
2009-12-22 00:58:53 +01:00
}
}
private void cmLoadDol_Click ( object sender , EventArgs e )
{
OpenFileDialog ofd = new OpenFileDialog ( ) ;
ofd . Filter = "Wii Executables|*.dol|Wii Channels|*.wad|All|*.dol;*.wad" ;
ofd . FilterIndex = 3 ;
if ( ofd . ShowDialog ( ) = = DialogResult . OK )
{
2010-01-08 23:10:02 +01:00
if ( ofd . FileName . ToLower ( ) . EndsWith ( ".wad" ) )
2009-12-22 00:58:53 +01:00
{
try
{
2010-03-28 20:29:30 +02:00
WAD tmpWad = WAD . Load ( ofd . FileName ) ;
2009-12-22 00:58:53 +01:00
2010-03-28 20:29:30 +02:00
if ( tmpWad . NumOfContents = = 3 )
2009-12-22 00:58:53 +01:00
{
2010-03-28 20:29:30 +02:00
int appIndex = 0 ;
if ( tmpWad . BootIndex = = 1 ) appIndex = 2 ;
else if ( tmpWad . BootIndex = = 2 ) appIndex = 1 ;
2009-12-22 00:58:53 +01:00
2010-03-28 20:29:30 +02:00
if ( appIndex > 0 )
2009-12-22 00:58:53 +01:00
{
2010-03-28 20:29:30 +02:00
newDol = tmpWad . Contents [ appIndex ] ;
setControlText ( tbDol , ofd . FileName ) ;
2009-12-22 00:58:53 +01:00
btnBrowseDol . Text = "Clear" ;
}
2010-03-28 20:29:30 +02:00
else errorBox ( "The DOL file couldn't be found!" ) ;
2009-12-22 00:58:53 +01:00
}
2010-03-28 20:29:30 +02:00
else errorBox ( "The DOL file couldn't be found!" ) ;
2009-12-22 00:58:53 +01:00
}
catch ( Exception ex )
{
2010-03-28 20:29:30 +02:00
setControlText ( tbDol , string . Empty ) ;
btnBrowseDol . Text = "Browse..." ;
errorBox ( ex . Message ) ;
2009-12-22 00:58:53 +01:00
}
}
else
{
2010-03-28 20:29:30 +02:00
newDol = File . ReadAllBytes ( ofd . FileName ) ;
setControlText ( tbDol , ofd . FileName ) ;
2009-12-22 00:58:53 +01:00
btnBrowseDol . Text = "Clear" ;
}
}
}
private void cmDolFromSource_Click ( object sender , EventArgs e )
{
try
{
2010-03-28 20:29:30 +02:00
if ( sourceWad . NumOfContents = = 3 )
2009-12-22 00:58:53 +01:00
{
2010-03-28 20:29:30 +02:00
int appIndex = 0 ;
if ( sourceWad . BootIndex = = 1 ) appIndex = 2 ;
else if ( sourceWad . BootIndex = = 2 ) appIndex = 1 ;
2009-12-22 00:58:53 +01:00
2010-03-28 20:29:30 +02:00
if ( appIndex > 0 )
2009-12-22 00:58:53 +01:00
{
2010-03-28 20:29:30 +02:00
newDol = sourceWad . Contents [ appIndex ] ;
setControlText ( tbDol , "Internal" ) ;
2009-12-22 00:58:53 +01:00
btnBrowseDol . Text = "Clear" ;
}
2010-03-28 20:29:30 +02:00
else errorBox ( "The DOL file couldn't be found!" ) ;
2009-12-22 00:58:53 +01:00
}
2010-03-28 20:29:30 +02:00
else errorBox ( "The DOL file couldn't be found!" ) ;
2009-12-22 00:58:53 +01:00
}
2010-03-28 20:29:30 +02:00
catch ( Exception ex )
2009-12-22 00:58:53 +01:00
{
2010-03-28 20:29:30 +02:00
setControlText ( tbDol , string . Empty ) ;
2009-12-22 00:58:53 +01:00
btnBrowseDol . Text = "Browse..." ;
2010-03-28 20:29:30 +02:00
errorBox ( ex . Message ) ;
2009-12-22 00:58:53 +01:00
}
}
2010-01-12 18:03:46 +01:00
private void llbTranslateChannel_LinkClicked ( object sender , LinkLabelLinkClickedEventArgs e )
{
if ( ! tbAllLanguages . Text . ToLower ( ) . Contains ( "channel" ) )
{
tbAllLanguages . Focus ( ) ;
tbAllLanguages . SelectAll ( ) ;
return ;
}
string tempText = tbAllLanguages . Text ;
int startIndex = tempText . ToLower ( ) . IndexOf ( "channel" ) ;
try
{
tbEnglish . Text = tempText . Remove ( startIndex , 7 ) . Insert ( startIndex , "Channel" ) ;
tbJapanese . Text = tempText . Remove ( startIndex , 7 ) . Insert ( startIndex , "チャンネル" ) ;
tbGerman . Text = tempText . Remove ( startIndex , 7 ) . Insert ( startIndex , "Kanal" ) ;
tbDutch . Text = tempText . Remove ( startIndex , 7 ) . Insert ( startIndex , "Kanaal" ) ;
2010-02-24 22:41:37 +01:00
tbKorean . Text = tempText . Remove ( startIndex , 7 ) . Insert ( startIndex , "채널" ) ;
2010-01-12 18:03:46 +01:00
2010-01-18 21:13:32 +01:00
try
{
if ( tempText [ startIndex - 1 ] ! = ' ' ) tbFrench . Text = tempText . Remove ( startIndex , 7 ) . Insert ( 0 , "Chaîne " ) ;
else tbFrench . Text = tempText . Remove ( startIndex - 1 , 8 ) . Insert ( 0 , "Chaîne " ) ;
}
catch { tbFrench . Text = tempText . Remove ( startIndex , 7 ) . Insert ( 0 , "Chaîne" ) ; }
try
{
if ( tempText [ startIndex - 1 ] ! = ' ' ) tbSpanish . Text = tempText . Remove ( startIndex , 7 ) . Insert ( 0 , "Canal " ) ;
else tbSpanish . Text = tempText . Remove ( startIndex - 1 , 8 ) . Insert ( 0 , "Canal " ) ;
}
catch { tbSpanish . Text = tempText . Remove ( startIndex , 7 ) . Insert ( 0 , "Canal" ) ; }
try
{
if ( tempText [ startIndex - 1 ] ! = ' ' ) tbItalian . Text = tempText . Remove ( startIndex , 7 ) . Insert ( 0 , "Canale " ) ;
else tbItalian . Text = tempText . Remove ( startIndex - 1 , 8 ) . Insert ( 0 , "Canale " ) ;
}
catch { tbItalian . Text = tempText . Remove ( startIndex , 7 ) . Insert ( 0 , "Canale" ) ; }
2010-01-12 18:03:46 +01:00
tbAllLanguages . Text = string . Empty ;
}
catch ( Exception ex )
{
tbAllLanguages . Text = tempText ;
tbEnglish . Text = string . Empty ;
tbJapanese . Text = string . Empty ;
tbGerman . Text = string . Empty ;
tbFrench . Text = string . Empty ;
tbSpanish . Text = string . Empty ;
tbItalian . Text = string . Empty ;
tbDutch . Text = string . Empty ;
2010-02-24 22:41:37 +01:00
tbKorean . Text = string . Empty ;
2010-01-12 18:03:46 +01:00
2010-03-28 20:29:30 +02:00
errorBox ( ex . Message ) ;
2010-01-12 18:03:46 +01:00
}
}
2010-01-18 21:13:32 +01:00
private void tbAllLanguages_TextChanged ( object sender , EventArgs e )
{
llbTranslateChannel . Enabled = tbAllLanguages . Text . ToLower ( ) . Contains ( "channel" ) ;
}
2010-02-24 22:41:37 +01:00
private void tbStartupIos_KeyPress ( object sender , KeyPressEventArgs e )
{
e . Handled = ! char . IsDigit ( e . KeyChar ) & & e . KeyChar ! = '\b' ;
}
private void llbMultiReplace_LinkClicked ( object sender , LinkLabelLinkClickedEventArgs e )
{
2010-03-28 20:29:30 +02:00
multiReplace ( sender = = llbBannerMultiReplace ) ;
}
private void lbxBannerTpls_MouseUp ( object sender , MouseEventArgs e )
{
if ( e . Button = = MouseButtons . Right )
{
lbxBannerTpls . SelectedIndex = lbxBannerTpls . IndexFromPoint ( e . X , e . Y ) ;
cmTpls . Tag = "banner" ;
cmTpls . Show ( MousePosition ) ;
}
}
private void lbxIconTpls_MouseUp ( object sender , MouseEventArgs e )
{
if ( e . Button = = MouseButtons . Right )
{
lbxIconTpls . SelectedIndex = lbxIconTpls . IndexFromPoint ( e . X , e . Y ) ;
cmTpls . Tag = "icon" ;
cmTpls . Show ( MousePosition ) ;
}
}
private void cmRename_Click ( object sender , EventArgs e )
{
try
{
ListBox lbx = ( ( ( ToolStripMenuItem ) sender ) . Owner . Tag . ToString ( ) . ToLower ( ) . Contains ( "banner" ) ) ? lbxBannerTpls : lbxIconTpls ;
string oldNameFull = lbx . SelectedItem . ToString ( ) ;
string oldName = lbx . SelectedItem . ToString ( ) . Remove ( lbx . SelectedItem . ToString ( ) . IndexOf ( '(' ) - 3 ) ;
CustomizeMii_InputBox ib = new CustomizeMii_InputBox ( ) ;
ib . Description = "Please enter a new name:" ;
ib . Input = oldName ;
ib . CommonKeyMode = false ;
ib . tbInput . MaxLength = 127 ;
ib . btnExit . Text = "Close" ;
if ( ib . ShowDialog ( ) = = DialogResult . OK & & oldName ! = ib . Input & & ! string . IsNullOrEmpty ( ib . Input ) )
{
string newName = ib . Input ;
if ( ! newName . ToLower ( ) . EndsWith ( ".tpl" ) ) newName + = ".tpl" ;
foreach ( char thisChar in Path . GetInvalidFileNameChars ( ) )
if ( newName . Contains ( thisChar . ToString ( ) ) )
throw new Exception ( string . Format ( "Invalid path char \"{0}\" found in new name!" , thisChar ) ) ;
if ( lbx = = lbxBannerTpls )
if ( string . IsNullOrEmpty ( replacedBanner ) )
bannerBin . RenameNode ( oldName , newName ) ;
else
newBannerBin . RenameNode ( oldName , newName ) ;
else
if ( string . IsNullOrEmpty ( replacedIcon ) )
iconBin . RenameNode ( oldName , newName ) ;
else
newIconBin . RenameNode ( oldName , newName ) ;
addTpls ( ) ;
try { lbx . SelectedItem = oldNameFull . Replace ( oldName , newName ) ; }
catch { }
}
}
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
}
private void cmResize_Click ( object sender , EventArgs e )
{
try
{
ListBox lbx = ( ( ( ToolStripMenuItem ) sender ) . Owner . Tag . ToString ( ) . ToLower ( ) . Contains ( "banner" ) ) ? lbxBannerTpls : lbxIconTpls ;
int selectedIndex = lbx . SelectedIndex ;
string tplName = lbx . SelectedItem . ToString ( ) . Remove ( lbx . SelectedItem . ToString ( ) . IndexOf ( '(' ) - 3 ) ;
Size oldSize ;
if ( lbx = = lbxBannerTpls )
if ( string . IsNullOrEmpty ( replacedBanner ) )
{ oldSize = TPL . Load ( bannerBin . Data [ bannerBin . GetNodeIndex ( tplName ) ] ) . GetTextureSize ( 0 ) ; }
else
{ oldSize = TPL . Load ( newBannerBin . Data [ newBannerBin . GetNodeIndex ( tplName ) ] ) . GetTextureSize ( 0 ) ; }
else
if ( string . IsNullOrEmpty ( replacedIcon ) )
{ oldSize = TPL . Load ( iconBin . Data [ iconBin . GetNodeIndex ( tplName ) ] ) . GetTextureSize ( 0 ) ; }
else
{ oldSize = TPL . Load ( newIconBin . Data [ newIconBin . GetNodeIndex ( tplName ) ] ) . GetTextureSize ( 0 ) ; }
CustomizeMii_InputBox ib = new CustomizeMii_InputBox ( ) ;
ib . Description = "Please enter a new size:" ;
ib . tbInput . Size = new Size ( ib . btnExit . Width , ib . tbInput . Height ) ;
ib . tbInput2 . Visible = true ;
ib . CommonKeyMode = false ;
ib . tbInput . MaxLength = 127 ;
ib . btnExit . Text = "Close" ;
ib . Input = oldSize . Width . ToString ( ) ;
ib . Input2 = oldSize . Height . ToString ( ) ;
if ( ib . ShowDialog ( ) = = DialogResult . OK )
{
Size newSize = new Size ( int . Parse ( ib . Input ) , int . Parse ( ib . Input2 ) ) ;
if ( newSize = = oldSize ) return ;
TPL tmpTpl ;
if ( lbx = = lbxBannerTpls )
if ( string . IsNullOrEmpty ( replacedBanner ) )
tmpTpl = TPL . Load ( bannerBin . Data [ bannerBin . GetNodeIndex ( tplName ) ] ) ;
else
tmpTpl = TPL . Load ( newBannerBin . Data [ newBannerBin . GetNodeIndex ( tplName ) ] ) ;
else
if ( string . IsNullOrEmpty ( replacedIcon ) )
tmpTpl = TPL . Load ( iconBin . Data [ iconBin . GetNodeIndex ( tplName ) ] ) ;
else
tmpTpl = TPL . Load ( newIconBin . Data [ newIconBin . GetNodeIndex ( tplName ) ] ) ;
2010-04-20 21:54:36 +02:00
TPL_TextureFormat tplFormat = tmpTpl . GetTextureFormat ( 0 ) ;
2010-03-28 20:29:30 +02:00
Image newImg = resizeImage ( tmpTpl . ExtractTexture ( 0 ) , newSize . Width , newSize . Height ) ;
tmpTpl . RemoveTexture ( 0 ) ;
tmpTpl . AddTexture ( newImg , tplFormat ) ;
if ( lbx = = lbxBannerTpls )
if ( string . IsNullOrEmpty ( replacedBanner ) )
bannerBin . ReplaceFile ( bannerBin . GetNodeIndex ( tplName ) , tmpTpl . ToByteArray ( ) ) ;
else
newBannerBin . ReplaceFile ( newBannerBin . GetNodeIndex ( tplName ) , tmpTpl . ToByteArray ( ) ) ;
else
if ( string . IsNullOrEmpty ( replacedIcon ) )
iconBin . ReplaceFile ( iconBin . GetNodeIndex ( tplName ) , tmpTpl . ToByteArray ( ) ) ;
else
newIconBin . ReplaceFile ( newIconBin . GetNodeIndex ( tplName ) , tmpTpl . ToByteArray ( ) ) ;
addTpls ( ) ;
try { lbx . SelectedIndex = selectedIndex ; }
catch { }
}
}
catch ( Exception ex ) { errorBox ( ex . Message ) ; }
2010-02-24 22:41:37 +01:00
}
2010-04-20 21:54:36 +02:00
private void cmMakeSilent_Click ( object sender , EventArgs e )
{
Wave w = new Wave ( 1 , 8 , 500 , new byte [ ] { 0x80 , 0x80 , 0x80 , 0x80 , 0x80 } ) ;
newSoundBin = Headers . IMD5 . AddHeader ( w . ToByteArray ( ) ) ;
w . Dispose ( ) ;
replacedSound = "Silence" ;
setControlText ( tbSound , "Silence" ) ;
btnBrowseSound . Text = "Clear" ;
if ( cmbReplace . SelectedIndex = = 2 ) setControlText ( tbReplace , string . Empty ) ;
}
2015-12-11 15:21:20 +01:00
private void lbxBaseWads_SelectedIndexChanged ( object sender , EventArgs e )
{
}
2015-12-11 15:38:55 +01:00
private void tabCredits_Click ( object sender , EventArgs e )
{
}
2009-11-08 23:53:22 +01:00
}
}