/*Copyright (C) 2007 Cassarin-Grand Arthur (Zoloom)

This program 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 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */

#include "POLSCapp.h" 
#include "Fenp.h"
#include "Fent.h"
#include "Fenconfig.h"
#include "Fennew.h"
#include "Fenupscript.h"

#define ID_ADDNEW 100
#define ID_PRESSTBUTTON 101
#define ID_CHECKCD 102
#define ID_CHECKNET 103
#define ID_CHECKLOCAL 104

#define ID_HELPNAME 105
#define ID_HELPEDITOR 106
#define ID_HELPWEBSITE 107
#define ID_HELPNICKNAME 108 
#define ID_HELPGAMENAME 109
#define ID_HELPGAMEDIRECTORY 110
#define ID_HELPGAMESTARTER 111
#define ID_HELPAUTORUNEXECD 112
#define ID_HELPURL 113
#define ID_HELPLOCALCLIENTPATH 114
#define ID_HELPSOUNDDRIVER 115
#define ID_HELPGLSL 116
#define ID_HELPDXGRAB 117
#define ID_HELPDESKTOP 118
#define ID_HELPMANAGED 119
#define ID_HELPOS 120
#define ID_HELPASSIGN 121
#define ID_HELPSESSION 122
#define ID_HELPATHDOWNLOAD 123

using namespace std;

Fennew::Fennew(wxWindow *parent) : wxFrame(parent, wxID_ANY, _("Nouveau script"), wxDefaultPosition, wxSize(520,400))
{
	SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
	wxIcon icoFenp(_T("images/document-new.png")); //declaration de l'icone
	SetIcon(icoFenp); //on le lie a la fenetre
	
	notebookFennew = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize);
	
	pageGeneral = new wxPanel(notebookFennew, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
	pageCD = new wxPanel(notebookFennew, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
	pageInternet = new wxPanel(notebookFennew, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
	pageLocal = new wxPanel(notebookFennew, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
	pageSound = new wxPanel(notebookFennew, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
	pageImage = new wxPanel(notebookFennew, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
	pageMisc = new wxPanel(notebookFennew, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
	
	//--------------------- GENERAL ----------------------
	
	txtstNameNew = new wxStaticText(pageGeneral, -1, _("Game's name :"), wxPoint(5,10), wxDefaultSize);
	txtcNameNew = new wxTextCtrl(pageGeneral, -1, _T(""), wxPoint(210,6), wxSize(200,27));
	buttonNameNew = new wxButton(pageGeneral, ID_HELPNAME, _("Help"), wxPoint(420,5), wxSize(60,29));
	
	txtstEditorNew = new wxStaticText(pageGeneral, -1, _("Game's editor :"), wxPoint(5,45), wxDefaultSize);
	txtcEditorNew = new wxTextCtrl(pageGeneral, -1, _T(""), wxPoint(210,41), wxSize(200,27));
	buttonEditorNew = new wxButton(pageGeneral, ID_HELPEDITOR, _("Help"), wxPoint(420,40), wxSize(60,29));
	
	txtstWebsiteNew = new wxStaticText(pageGeneral, -1, _("Game's web site :"), wxPoint(5,80), wxDefaultSize);
	txtcWebsiteNew = new wxTextCtrl(pageGeneral, -1, _T(""), wxPoint(210,76), wxSize(200,27));
	buttonWebsiteNew = new wxButton(pageGeneral, ID_HELPWEBSITE, _("Help"), wxPoint(420,75), wxSize(60,29));
	
	txtstNickNameNew= new wxStaticText(pageGeneral, -1, _("Your name :"), wxPoint(5,115), wxDefaultSize);
	txtcNickNameNew = new wxTextCtrl(pageGeneral, -1, _T(""), wxPoint(210,111), wxSize(200,27));
	buttonNickNameNew = new wxButton(pageGeneral, ID_HELPNICKNAME, _("Help"), wxPoint(420,110), wxSize(60,29));
	
	txtstGameNameNew = new wxStaticText(pageGeneral, -1, _("Prefix's name :"), wxPoint(5,150), wxDefaultSize);
	txtcGameNameNew = new wxTextCtrl(pageGeneral, -1, _T(""), wxPoint(210,146), wxSize(200,27));
	buttonGameNameNew = new wxButton(pageGeneral, ID_HELPGAMENAME, _("Help"), wxPoint(420,145), wxSize(60,29));
	
	txtstGameDirectoryNew = new wxStaticText(pageGeneral, -1, _("Game's data directory :"), wxPoint(5,185), wxDefaultSize);
	txtcGameDirectoryNew = new wxTextCtrl(pageGeneral, -1, _T(""), wxPoint(210,181), wxSize(200,27));
	buttonGameDirectoryNew = new wxButton(pageGeneral, ID_HELPGAMEDIRECTORY, _("Help"), wxPoint(420,180), wxSize(60,29));
	
	txtstGameStarterNew = new wxStaticText(pageGeneral, -1, _("Game's main executable :"), wxPoint(5,220), wxDefaultSize);
	txtcGameStarterNew = new wxTextCtrl(pageGeneral, -1, _T(""), wxPoint(210,216), wxSize(200,27));
	buttonGameStarterNew = new wxButton(pageGeneral, ID_HELPGAMESTARTER, _("Help"), wxPoint(420,215), wxSize(60,29));
	
	buttonAddNew = new wxButton(pageGeneral, ID_ADDNEW, _("Create the script"), wxPoint(180,310), wxSize(160,40));
	
	notebookFennew->AddPage(pageGeneral, _("General"), true, -1);
	
	//--------------------- CD ----------------------
	
	checkCDNew = new wxCheckBox(pageCD, ID_CHECKCD, _T("Check if your script need a CD-ROM support."), wxPoint(5,10), wxDefaultSize);
	
	txtstAutorunExeCDNew = new wxStaticText(pageCD, -1, _("Autorun's executable name :"), wxPoint(5,45), wxDefaultSize);
	txtcAutorunExeCDNew = new wxTextCtrl(pageCD, -1, _T(""), wxPoint(210, 41), wxSize(200,27));
	buttonAutorunExeCDNew = new wxButton(pageCD, ID_HELPAUTORUNEXECD, _("Help"), wxPoint(420,40), wxSize(60,29));
		
	txtstAutorunExeCDNew->Enable(false);
	txtcAutorunExeCDNew->Enable(false);
	buttonAutorunExeCDNew->Enable(false);
	
	notebookFennew->AddPage(pageCD, _("DVD/CD-ROM"), false, -1);
	
	//--------------------- CLIENT INTERNET ---------
	
	checkNetNew = new wxCheckBox(pageInternet, ID_CHECKNET, _T("Check if your script need a downloadable client"), wxPoint(5,10), wxDefaultSize);
	
	txtstUrlNew = new wxStaticText(pageInternet, -1, _("Client's URL :"), wxPoint(5,45), wxDefaultSize);
	txtcUrlNew = new wxTextCtrl(pageInternet, -1, _T(""), wxPoint(210,41), wxSize(200,27));
	buttonUrlNew = new wxButton(pageInternet, ID_HELPURL, _("Help"), wxPoint(420,40), wxSize(60,29));
	
	//txtstPathDownloadNew = new wxStaticText(pageInternet, -1, _("Destination path :"), wxPoint(5,80), wxDefaultSize);
	//txtcPathDownloadNew = new wxTextCtrl(pageInternet, -1, _T(""), wxPoint(210,76), wxSize(200,27));
	//buttonPathDownloadCDNew = new wxButton(pageInternet, ID_HELPATHDOWNLOAD, _("Help"), wxPoint(420,75), wxSize(60,29));
	
	txtstUrlNew->Enable(false);
	txtcUrlNew->Enable(false);
	buttonUrlNew->Enable(false);
	//txtstPathDownloadNew->Enable(false);
	//txtcPathDownloadNew->Enable(false);
	//buttonPathDownloadCDNew->Enable(false);
	
	notebookFennew->AddPage(pageInternet, _("Internet"), false, -1);
	
	//--------------------- CLIENT LOCAL ------------
	
	checkLocalNew = new wxCheckBox(pageLocal, ID_CHECKLOCAL, _T("Check if your script need to execute a client in user's hard disk"), wxPoint(5,10), wxDefaultSize);
	
	txtstLocalClientPathNew = new wxStaticText(pageLocal, -1, _("Client's path in hard disk :"), wxPoint(5,45), wxDefaultSize);
	txtcLocalClientPathNew = new wxTextCtrl(pageLocal, -1, _T(""), wxPoint(210, 41), wxSize(200,27));
	buttonLocalClientPathNew = new wxButton(pageLocal, ID_HELPLOCALCLIENTPATH, _("Help"), wxPoint(420,40), wxSize(60,29));
	
	txtstLocalClientPathNew->Enable(false);
	txtcLocalClientPathNew->Enable(false);
	buttonLocalClientPathNew->Enable(false);
	
	notebookFennew->AddPage(pageLocal, _("Hard disk"), false, -1);
	
	//--------------------- SOUND ------------------
	
	wxString stringChoicesSoundDriverNew[] = {_T("Default"),_T("alsa"),_T("oss"),_T("esd")};
	txtstSoundDriverNew = new wxStaticText(pageSound, -1, _("Sound driver :"), wxPoint(5,15), wxDefaultSize);
	comboSoundDriverNew = new wxComboBox(pageSound, -1, _T("Default"), wxPoint(210,11), wxSize(150,27), 4, stringChoicesSoundDriverNew, wxCB_READONLY | wxCB_SORT);
	buttonSoundDriverNew = new wxButton(pageSound, ID_HELPSOUNDDRIVER, _("Help"), wxPoint(370,10), wxSize(60,29));
	
	
	notebookFennew->AddPage(pageSound, _("Sound"), false, -1);
	
	//--------------------- IMAGE -----------------
	
	wxString stringChoicesGLSLNew[] = {_T("Off"),_T("On")};
	txtstGLSLNew = new wxStaticText(pageImage, -1, _("GLSL Support :"), wxPoint(5,15), wxDefaultSize);
	comboGLSLNew = new wxComboBox(pageImage, -1, _T("Off"), wxPoint(210,11), wxSize(150,27), 2, stringChoicesGLSLNew, wxCB_READONLY | wxCB_SORT);
	buttonGLSLNew = new wxButton(pageImage, ID_HELPGLSL, _("Help"), wxPoint(370,10), wxSize(60,29));
	
	wxString stringChoicesDesktopNew[] = {_T("Off"),_T("On")};
	txtstDesktopNew = new wxStaticText(pageImage, -1, _("Enable Virtual Wine's Desktop :"), wxPoint(5,50), wxDefaultSize);
	comboDesktopNew = new wxComboBox(pageImage, -1, _T("Off"), wxPoint(210,46), wxSize(150,27), 2, stringChoicesDesktopNew, wxCB_READONLY | wxCB_SORT);
	buttonDesktopNew = new wxButton(pageImage, ID_HELPDESKTOP, _("Help"), wxPoint(370,45), wxSize(60,29));
	
	notebookFennew->AddPage(pageImage, _("Image"), false, -1);
	
	//--------------------- MISC ------------------
	
	wxString stringChoicesDXGrabNew[] = {_T("Off"),_T("On")};
	txtstDXGrabNew = new wxStaticText(pageMisc, -1, _("Allow DirectX to control the mouse's pointer :"), wxPoint(5,15), wxDefaultSize);
	txtstDXGrabNew->Wrap(290);
	comboDXGrabNew = new wxComboBox(pageMisc, -1, _T("Off"), wxPoint(330,11), wxSize(100,27), 2, stringChoicesDXGrabNew, wxCB_READONLY | wxCB_SORT);
	buttonDXGrabNew = new wxButton(pageMisc, ID_HELPDXGRAB, _("Help"), wxPoint(432,10), wxSize(60,29));
	
	wxString stringChoicesManagedNew[] = {_T("Off"),_T("On")};
	txtstManagedNew = new wxStaticText(pageMisc, -1, _("Allow the window manager to control the window :"), wxPoint(5,47), wxDefaultSize);
	txtstManagedNew->Wrap(290);
	comboManagedNew = new wxComboBox(pageMisc, -1, _T("Off"), wxPoint(330,46), wxSize(100,27), 2, stringChoicesManagedNew, wxCB_READONLY | wxCB_SORT);
	buttonManagedNew = new wxButton(pageMisc, ID_HELPMANAGED, _("Help"), wxPoint(432,45), wxSize(60,29));

	wxString stringChoicesOSNew[] = {_T("Default"),_T("vista"),_T("win2003"),_T("winxp"),_T("win2k"),_T("winnt"),_T("winme"),_T("win98"),_T("win95"),_T("win31")};
	txtstOSNew = new wxStaticText(pageMisc, -1, _("Change the version of the operating system simulated by Wine :"), wxPoint(5,85), wxDefaultSize);
	txtstOSNew->Wrap(290);
	comboOSNew = new wxComboBox(pageMisc, -1, _T("Default"), wxPoint(330,85), wxSize(100,27), 10, stringChoicesOSNew, wxCB_READONLY | wxCB_SORT);
	buttonOSNew = new wxButton(pageMisc, ID_HELPOS, _("Help"), wxPoint(432,84), wxSize(60,29));
	
	txtstAssignNew = new wxStaticText(pageMisc, -1, _("Assign a Wine's version permanently :"), wxPoint(5,126), wxDefaultSize);
	txtstAssignNew->Wrap(290);
	txtcAssignNew = new wxTextCtrl(pageMisc, -1, _T(""), wxPoint(330, 120), wxSize(100,27));
	buttonAssignNew = new wxButton(pageMisc, ID_HELPASSIGN, _("Help"), wxPoint(432,119), wxSize(60,29));
	
	txtstSessionNew = new wxStaticText(pageMisc, -1, _("Assign a Wine's version for the installation :"), wxPoint(5,156), wxDefaultSize);
	txtstSessionNew->Wrap(290);
	txtcSessionNew = new wxTextCtrl(pageMisc, -1, _T(""), wxPoint(330, 153), wxSize(100,27));
	buttonSessionNew = new wxButton(pageMisc, ID_HELPSESSION, _("Help"), wxPoint(432,152), wxSize(60,29));	
		
	notebookFennew->AddPage(pageMisc, _("Miscellaneous"), false, -1);
	
	//----------------------------------------------
	
	boxMainNew = new wxBoxSizer(wxVERTICAL);
		boxMainNew->Add(notebookFennew, 0, wxEXPAND, 0);
}

Fennew::~Fennew()
{
	
}

void Fennew::OnCheckCD(wxCommandEvent& WXUNUSED(event))
{
	if (checkCDNew->GetValue() == false)
	{
		txtstAutorunExeCDNew->Enable(false);
		txtcAutorunExeCDNew->Enable(false);
		buttonAutorunExeCDNew->Enable(false);
		
		txtcUrlNew->SetValue(_T(""));
		//txtcPathDownloadNew->SetValue(_T(""));
		txtcAutorunExeCDNew->SetValue(_T(""));	
		txtcLocalClientPathNew->SetValue(_T(""));
	}
	
	if (checkCDNew->GetValue() == true)
	{
		checkNetNew->SetValue(false);
		checkLocalNew->SetValue(false);
		
		txtstAutorunExeCDNew->Enable(true);
		txtcAutorunExeCDNew->Enable(true);
		buttonAutorunExeCDNew->Enable(true);
		
		txtstLocalClientPathNew->Enable(false);
		txtcLocalClientPathNew->Enable(false);
		buttonLocalClientPathNew->Enable(false);
		
		txtstUrlNew->Enable(false);
		txtcUrlNew->Enable(false);
		buttonUrlNew->Enable(false);
		//txtstPathDownloadNew->Enable(false);
		//txtcPathDownloadNew->Enable(false);
		//buttonPathDownloadCDNew->Enable(false);
	}
}

void Fennew::OnCheckNet(wxCommandEvent& WXUNUSED(event))
{
	if (checkNetNew->GetValue() == false)
	{	
		txtstUrlNew->Enable(false);
		txtcUrlNew->Enable(false);
		buttonUrlNew->Enable(false);
		txtstPathDownloadNew->Enable(false);
		txtcPathDownloadNew->Enable(false);
		buttonPathDownloadCDNew->Enable(false);
		
		txtcUrlNew->SetValue(_T(""));
		//txtcPathDownloadNew->SetValue(_T(""));
		txtcAutorunExeCDNew->SetValue(_T(""));	
		txtcLocalClientPathNew->SetValue(_T(""));
	}
	
	if (checkNetNew->GetValue() == true)
	{
		checkCDNew->SetValue(false);
		checkLocalNew->SetValue(false);
		
		txtstAutorunExeCDNew->Enable(false);
		txtcAutorunExeCDNew->Enable(false);
		buttonAutorunExeCDNew->Enable(false);
		
		txtstLocalClientPathNew->Enable(false);
		txtcLocalClientPathNew->Enable(false);
		buttonLocalClientPathNew->Enable(false);
		
		txtstUrlNew->Enable(true);
		txtcUrlNew->Enable(true);
		buttonUrlNew->Enable(true);
		//txtstPathDownloadNew->Enable(true);
		//txtcPathDownloadNew->Enable(true);
		//buttonPathDownloadCDNew->Enable(true);
	}
}

void Fennew::OnCheckLocal(wxCommandEvent& WXUNUSED(event))
{
	if (checkLocalNew->GetValue() == false)
	{	
		txtstLocalClientPathNew->Enable(false);
		txtcLocalClientPathNew->Enable(false);
		buttonLocalClientPathNew->Enable(false);
			
		txtcUrlNew->SetValue(_T(""));
		//txtcPathDownloadNew->SetValue(_T(""));
		txtcAutorunExeCDNew->SetValue(_T(""));
		txtcLocalClientPathNew->SetValue(_T(""));
	}
	
	if (checkLocalNew->GetValue() == true)
	{
		checkCDNew->SetValue(false);
		checkNetNew->SetValue(false);
		
		txtstAutorunExeCDNew->Enable(false);
		txtcAutorunExeCDNew->Enable(false);
		buttonAutorunExeCDNew->Enable(false);
		
		txtstUrlNew->Enable(false);
		txtcUrlNew->Enable(false);
		buttonUrlNew->Enable(false);
		//txtstPathDownloadNew->Enable(false);
		//txtcPathDownloadNew->Enable(false);
		//buttonPathDownloadCDNew->Enable(false);
		
		txtstLocalClientPathNew->Enable(true);
		txtcLocalClientPathNew->Enable(true);
		buttonLocalClientPathNew->Enable(true);
	}
}

void Fennew::AddGeneralInformationsNew(wxCommandEvent& WXUNUSED(event))
{
	
		
	if (txtcNameNew->GetValue() == _T("") || txtcEditorNew->GetValue() == _T("") || txtcWebsiteNew->GetValue() == _T("") ||
			txtcNickNameNew->GetValue() == _T("") || txtcGameNameNew->GetValue() == _T("") || txtcGameDirectoryNew->GetValue() == _T("") || txtcGameStarterNew->GetValue() == _T(""))
	{
		wxString txtsErrorVoidNew = _("This field(s) must be completed :");
		
		if (txtcNameNew->GetValue() == _T(""))
			txtsErrorVoidNew = txtsErrorVoidNew + _T(" Game's name");
		if (txtcEditorNew->GetValue() == _T(""))
			txtsErrorVoidNew = txtsErrorVoidNew + _T(" Game's editor");
		if (txtcWebsiteNew->GetValue() == _T(""))
			txtsErrorVoidNew = txtsErrorVoidNew + _T(" Game's web site");
		if (txtcNickNameNew->GetValue() == _T(""))
			txtsErrorVoidNew = txtsErrorVoidNew + _T(" Your name");
		if (txtcGameNameNew->GetValue() == _T(""))
			txtsErrorVoidNew = txtsErrorVoidNew + _T(" Prefix's name");
		if (txtcGameDirectoryNew->GetValue() == _T(""))
			txtsErrorVoidNew = txtsErrorVoidNew + _T(" Game's data directory");
		if (txtcGameStarterNew->GetValue() == _T(""))
			txtsErrorVoidNew = txtsErrorVoidNew + _T(" Game's main executable");
			
		wxMessageBox(txtsErrorVoidNew, _T("POLSC Error") ,wxICON_ERROR);
		return;
	}
	
	wxString textsAddedBufferNew = _T("");
	wxString bufferTextNew = _T("");	
	wxString txtsNameGameNew = txtcNameNew->GetValue();
	wxString txtsEditorGameNew = txtcEditorNew->GetValue();
	wxString txtsWebsiteGameNew = txtcWebsiteNew->GetValue();
	wxString txtsNickNameGameNew = txtcNickNameNew->GetValue();
	wxString txtsPrefixNameNew = txtcGameNameNew->GetValue(); 
	wxString txtsGameDirectoryNew = txtcGameDirectoryNew->GetValue();
	wxString txtsGameStarterNew = txtcGameStarterNew->GetValue();
		
	wxString bufferFileNewBaseData;
	int readLinesNewBaseData = 0;
	wxTextFile fileNewData;
    fileNewData.Open(_T("data/new"));
	
	for (bufferFileNewBaseData = fileNewData.GetFirstLine(); !fileNewData.Eof(); bufferFileNewBaseData = fileNewData.GetNextLine())
	{
		if (readLinesNewBaseData == 0)
		{
				bufferTextNew = bufferTextNew + bufferFileNewBaseData;
				readLinesNewBaseData++;
		}
			
		else
		{
				bufferTextNew = bufferTextNew + _T("\n");
				bufferTextNew = bufferTextNew + bufferFileNewBaseData;
				readLinesNewBaseData++;
		}			
	}
				
	fileNewData.Close();	
		
	Fenp* parent=(Fenp*)GetParent();
	
	textsAddedBufferNew = bufferTextNew;
	textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_presentation ") + _T("\"") + txtsNameGameNew + _T("\" \"") + txtsEditorGameNew + _T("\" \"") + txtsWebsiteGameNew + _T("\" \"") + txtsNickNameGameNew + _T("\" \"") + txtsPrefixNameNew + _T("\"") + _T("\n") + _T("\n");
	textsAddedBufferNew = textsAddedBufferNew + _T("select_prefixe \"$REPERTOIRE/wineprefix/") + txtsPrefixNameNew + _T("\"") + _T("\n");
	textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_prefixcreate ") + _T("\n") + _T("\n");
	
	if (comboSoundDriverNew->GetValue() != _T("Default")) //son
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("Set_SoundDriver \"") + comboSoundDriverNew->GetValue() + _T("\"") + _T("\n");
	}
	
	if (comboGLSLNew->GetValue() != _T("Off")) //GLSL
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("Set_GLSL \"") + comboGLSLNew->GetValue() + _T("\"") + _T("\n");
	}
	
	if (comboDesktopNew->GetValue() != _T("Off")) //Desktop
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("Set_Desktop \"") + comboDesktopNew->GetValue() + _T("\"") + _T("\n");
	}
	
	if (comboDXGrabNew->GetValue() != _T("Off")) //DxGrab
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("Set_DXGrab \"") + comboDXGrabNew->GetValue() + _T("\"") + _T("\n");
	}
	
	if (comboManagedNew->GetValue() != _T("Off")) //Managed
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("Set_Managed \"") + comboManagedNew->GetValue() + _T("\"") + _T("\n");
	}
	
	if (comboOSNew->GetValue() != _T("Default")) //OS
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("Set_OS \"") + comboOSNew->GetValue() + _T("\"") + _T("\n");
	}
	
	if (txtcSessionNew->GetValue() != _T("")) //Wine Session
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("Set_WineVersion_Session \"") + txtcSessionNew->GetValue() + _T("\"") + _T("\n");
	}
	
	//------------------------------------------------
	
	//********************* CD ***********************
	
	if (checkCDNew->GetValue() == true)
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_cdrom") + _T("\n");
		textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_check_cdrom \"") + txtcAutorunExeCDNew->GetValue() + _T("\"") + _T("\n\n");
		textsAddedBufferNew = textsAddedBufferNew + _T("cd $CDROM") + _T("\n");
		textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_wait_next_signal ") + _T("\"Installation in progress...\" \"") + txtsNameGameNew + _T("\"") + _T("\n");
		textsAddedBufferNew = textsAddedBufferNew + _T("wine ") + _T("$CDROM/") + txtcAutorunExeCDNew->GetValue() + _T("\n");
		textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_detect_exit") + _T("\n"); 
	}
	
	//******************** NET **********************
	
	if (checkNetNew->GetValue() == true)
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("cd \"$REPERTOIRE/wineprefix/") + txtsPrefixNameNew + _T("/drive_c/") + _T("\"") + _T("\n");
		textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_download \"") + _T("Downloading ") + txtsNameGameNew + _T("'s client...\" \"") + _T("Downloading ") + txtsNameGameNew + _T("'s client...\" \"") + txtcUrlNew->GetValue() + _T("\"") + _T("\n");
		
		wxString txtsNameFileDownloaded;
		wxString txtsUrl = txtcUrlNew->GetValue();
		wxChar wxcharSlash[] = _T("/");
		txtsNameFileDownloaded = txtsUrl.AfterLast(*wxcharSlash);
		
		textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_wait_next_signal ") + _T("\"Installation in progress...\" \"") + txtsNameGameNew + _T("\"") + _T("\n");
		textsAddedBufferNew = textsAddedBufferNew + _T("wine \"") + _T("$REPERTOIRE/wineprefix/") + txtsPrefixNameNew + _T("/drive_c/") + txtsNameFileDownloaded + _T("\"") + _T("\n");
		textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_detect_exit") + _T("\n"); 
		
	}
	
	//******************** LOCAL *********************
	
	if (checkLocalNew->GetValue() == true)
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_wait_next_signal \"Installing ") + txtsNameGameNew + _T("...\" \"") + txtsNameGameNew + _T("\"") + _T("\n"); 
		textsAddedBufferNew = textsAddedBufferNew + _T("wine \"") + txtcLocalClientPathNew->GetValue() + _T("\"") + _T("\n");
		textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_detect_exit") + _T("\n"); 
	}
		
	//------------------------------------------------
		
	textsAddedBufferNew = textsAddedBufferNew + _T("\nPOL_SetupWindow_make_shortcut ") + _T("\"") + txtsPrefixNameNew +  _T("\" \"") + txtsGameDirectoryNew + _T("\" \"") + txtsGameStarterNew + _T("\" \"\" \"") + txtsNameGameNew + _T("\"") + _T("\n") + _T("\n");
	
	if (txtcAssignNew->GetValue() != _T("")) //Wine Version
	{
		textsAddedBufferNew = textsAddedBufferNew + _T("Set_WineVersion_Assign \"") + txtcAssignNew->GetValue() + _T("\" \"") + txtsNameGameNew + _T("\"") + _T("\n");
	}
	
	textsAddedBufferNew = textsAddedBufferNew + _T("POL_SetupWindow_reboot\nPOL_SetupWindow_Close\nexit");
	
	parent->CatchAddedFunctionFromFennew(textsAddedBufferNew, this);	
}



//-------------------------------

void Fennew::HelpName(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The name of the game scripted.\n\nFor example : Strarcraft"), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpEditor(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The Editor/Distributor of the game.\n\nFor example : Blizzard"), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpWebsite(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The officiel game's Website.\n\nFor example : http://www.editor.com"), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpNickName(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The name of the scriptor (your name so).\n\nFor example : Sam29"), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpGameName(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The name of the prefix, which is a new Wine directory with a specific configuration for the game. Space and special characters are forbidden.\n\nFor example : AgeOfWonders"), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpGameDirectory(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The path of the windows directory who contains game's data. It generaly begins by Programe Files/(...).\n\nFor example : Program Files/Steam/"), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpGameStarter(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The path of the main executable wich start the game in the game's directory.\n\nFor example : play.exe"), _("POLSC Help"), wxICON_INFORMATION);
}


//-------------------------------

void Fennew::HelpAutorunExeCD(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The name of the CD's autorun executable. It's the first executable who is started when Windows read the CD-ROM.\n\nFor example : autorun.exe or Setup.exe"), _("POLSC Help"), wxICON_INFORMATION);
}

//-------------------------------

void Fennew::HelpUrl(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The url you want to download.\n\nFor example : http://mysite/client.exe"), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpPathDownload(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The path when the file will be downloaded. Don't forget the name of the saved file.\n\nFor example : $TEMP/client.exe or $REPERTOIRE/tmp/client.exe"), _("POLSC Help"), wxICON_INFORMATION);
}

//-------------------------------

void Fennew::HelpLocalClientPath(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The path of the cilent wich must be started for the installation.\n\nFor example : $REPERTOIRE/client.exe"), _("POLSC Help"), wxICON_INFORMATION);
}

//-------------------------------

void Fennew::HelpSoundDriver(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("The sound driver which must be used with this game. Some games work better with alsa, oss, esd. You have to try them and choose the best one. By Default Alsa is selected."), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpGLSL(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("Activate or not (Default) the GLSL support. GLSL is a high level shading language based on the C programming language. It was created by the OpenGL ARB to give developers more direct control of the graphics pipeline without having to use assembly language or hardware-specific languages. You can have more information on Wikipedia."), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpDesktop(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("Activate or not (default) the Wine desktop. This function create a virtual desktop only use by Wine. He can be useful for some games."), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpDXGrab(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("Allow or not (default) DirectX to control the mouse. The mouse can't leave the game window for example."), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpManaged(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("Allow or not (default) your window manager (GNOME...) to control Wine's window."), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpOS(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("Define if Wine must emulate an OS version for Windows. Some games works better with some version.\n\nExample : Sometimes old games work faster with win98 configuration. "), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpAssign(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("Assign a Wine's Version to a prefix (game). A lot of applications work better with specific versions, you can find which are working at :\n\nhttp://appdb.winehq.org/ ."), _("POLSC Help"), wxICON_INFORMATION);
}

void Fennew::HelpSession(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(_("Assign a Wine's Version to a prefix (game) but just for the installation. Some applications have bugs with new versions, so you could assign a old version of Wine for the installation, and restore a new Wine version for playing for example."), _("POLSC Help"), wxICON_INFORMATION);
}

BEGIN_EVENT_TABLE( Fennew, wxFrame)

EVT_BUTTON(ID_ADDNEW, Fennew::AddGeneralInformationsNew)

EVT_CHECKBOX(ID_CHECKCD,Fennew::OnCheckCD)
EVT_CHECKBOX(ID_CHECKNET,Fennew::OnCheckNet)
EVT_CHECKBOX(ID_CHECKLOCAL,Fennew::OnCheckLocal)

EVT_BUTTON(ID_HELPNAME, Fennew::HelpName)
EVT_BUTTON(ID_HELPEDITOR, Fennew::HelpEditor)
EVT_BUTTON(ID_HELPWEBSITE, Fennew::HelpWebsite)
EVT_BUTTON(ID_HELPNICKNAME, Fennew::HelpNickName)
EVT_BUTTON(ID_HELPGAMENAME, Fennew::HelpGameName)
EVT_BUTTON(ID_HELPGAMEDIRECTORY, Fennew::HelpGameDirectory)
EVT_BUTTON(ID_HELPGAMESTARTER, Fennew::HelpGameStarter)
EVT_BUTTON(ID_HELPAUTORUNEXECD, Fennew::HelpAutorunExeCD)
EVT_BUTTON(ID_HELPURL, Fennew::HelpUrl)
EVT_BUTTON(ID_HELPATHDOWNLOAD, Fennew::HelpPathDownload)
EVT_BUTTON(ID_HELPLOCALCLIENTPATH, Fennew::HelpLocalClientPath)
EVT_BUTTON(ID_HELPSOUNDDRIVER, Fennew::HelpSoundDriver)
EVT_BUTTON(ID_HELPGLSL, Fennew::HelpGLSL)
EVT_BUTTON(ID_HELPDXGRAB, Fennew::HelpDXGrab)
EVT_BUTTON(ID_HELPDESKTOP, Fennew::HelpDesktop)
EVT_BUTTON(ID_HELPMANAGED, Fennew::HelpManaged)
EVT_BUTTON(ID_HELPOS, Fennew::HelpOS)
EVT_BUTTON(ID_HELPASSIGN, Fennew::HelpAssign)
EVT_BUTTON(ID_HELPSESSION, Fennew::HelpSession)

END_EVENT_TABLE()
