/*=========================================================================
* 
* SECTdEnv.cpp :  Environment dialog - Implementation file
* 
*
* Version			1.0
* Creation date		
* Revision date
*
* Shaitan
*=======================================================================*/
/*
#include "stdafx.h"
#include "acp_base.h"
#include "SECTint.hpp"

#include "SECdEnv.hpp"

#include "SECmodif.hpp"
#include "SECdMec.hpp"
#include "SECdVis.hpp"
#include "SEClEnvs.hpp"
#include "SECdEnvs.hpp"
#include "SECdSrfs.hpp"

#include "..\Main\Inc\_EditID.h"
#include "TUT.h"


SECT_MecEnvironment	*g_pClickedMecEnv;
SECT_VisEnvironment	*g_pClickedVisEnv;


//#################################################################################
// SECT_DialogEnv dialog
//#################################################################################

/*----------------------------------------
----------------------------------------*/
/*
SECT_DialogEnv::SECT_DialogEnv(CWnd* pParent)
	: CFormView(SECT_DialogEnv::IDD)
{
	//{{AFX_DATA_INIT(SECT_DialogEnv)
	//}}AFX_DATA_INIT
}
*/


/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(SECT_DialogEnv)
	DDX_Control(pDX, SECT_IDC_ENVNAME, m_cName);
	DDX_Control(pDX, SECT_IDC_ENVDEFAULT, m_cDefault);

	DDX_Control(pDX, SECT_IDC_ENVCANCEL, m_cCancel);
	DDX_Control(pDX, SECT_IDC_ENVSAVE, m_cSave);

    DDX_Control(pDX, SECT_IDC_MECLISTBOX, m_cMecListBox);
	DDX_Control(pDX, SECT_IDC_EDITMEC, m_cEditMec);
	DDX_Control(pDX, SECT_IDC_NEWMEC, m_cNewMec);

	DDX_Control(pDX, SECT_IDC_VISLISTBOX, m_cVisListBox);
	DDX_Control(pDX, SECT_IDC_EDITVIS, m_cEditVis);
	DDX_Control(pDX, SECT_IDC_NEWVIS, m_cNewVis);

    DDX_Control(pDX, SECT_IDC_SOUNDLIST, m_cSndListBox);
	//}}AFX_DATA_MAP
}
*/

/*----------------------------------------
----------------------------------------*/
/*
BEGIN_MESSAGE_MAP(SECT_DialogEnv, CFormView)
	//{{AFX_MSG_MAP(SECT_DialogEnv)
	ON_WM_SIZE()
	ON_WM_DESTROY()

	ON_EN_KILLFOCUS(SECT_IDC_ENVNAME, OnChangeName)
	ON_BN_CLICKED(SECT_IDC_ENVDEFAULT, OnDefault)

	ON_BN_CLICKED(SECT_IDC_ENVCANCEL, OnCancel)
	ON_BN_CLICKED(SECT_IDC_ENVSAVE, OnSave)

	ON_NOTIFY(LVN_ITEMCHANGED, SECT_IDC_MECLISTBOX, OnSelChangeMecListBox)
	ON_NOTIFY(NM_DBLCLK, SECT_IDC_MECLISTBOX, OnDblClkMecListBox)
	ON_BN_CLICKED(SECT_IDC_EDITMEC, OnEditMec)
	ON_BN_CLICKED(SECT_IDC_NEWMEC, OnNewMec)

	ON_NOTIFY(LVN_ITEMCHANGED, SECT_IDC_VISLISTBOX, OnSelChangeVisListBox)
	ON_NOTIFY(NM_DBLCLK, SECT_IDC_VISLISTBOX, OnDblClkVisListBox)
	ON_BN_CLICKED(SECT_IDC_EDITVIS, OnEditVis)
	ON_BN_CLICKED(SECT_IDC_NEWVIS, OnNewVis)

	ON_CBN_SELCHANGE(SECT_IDC_SOUNDLIST, OnSelChangeSndListBox)

	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
*/

//#################################################################################
// SECT_DialogEnv Inits
//#################################################################################

/*===========================================================================
*		Description:	Init dialog
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/
/*
void SECT_DialogEnv::fn_vInitDialog (Sector_Interface *p_oDLL, CWnd *pParent)
{
	// create the dialog
	m_bInitialised = FALSE;
	m_pSectorInterface = p_oDLL;
	CFormView::Create(NULL, "", AFX_WS_DEFAULT_VIEW, CRect(0,0,120,180), pParent, AFX_IDW_PANE_FIRST, NULL);

	// init data for dialog
	CFormView::UpdateData(FALSE);

// FOR TUTORIAL
	TUT_M_vGetTutDll();
    // environment
	TUT_M_vRegisterControl(m_cName.m_hWnd,			"OSC_DENV_EDIT_NAME",		TUT_e_TextEdit);
    TUT_M_vRegisterControl(m_cDefault.m_hWnd,		"OSC_DENV_BUTTON_DEFAULT",	TUT_e_Button);
    TUT_M_vRegisterControl(m_cCancel.m_hWnd,		"OSC_DENV_BUTTON_CANCEL",	TUT_e_Button);
    TUT_M_vRegisterControl(m_cSave.m_hWnd,			"OSC_DENV_BUTTON_SAVE",		TUT_e_Button);
	// mechanic environment
    TUT_M_vRegisterControl(m_cMecListBox.m_hWnd,	"OSC_DENV_LIST_MECENVS",	TUT_e_ListBox);
    TUT_M_vRegisterControl(m_cEditMec.m_hWnd,		"OSC_DENV_BUTTON_EDITMEC",	TUT_e_Button);
    TUT_M_vRegisterControl(m_cNewMec.m_hWnd,		"OSC_DENV_BUTTON_NEWMEC",	TUT_e_Button);
	// visual environment
    TUT_M_vRegisterControl(m_cVisListBox.m_hWnd,	"OSC_DENV_LIST_VISENVS",	TUT_e_ListBox);
    TUT_M_vRegisterControl(m_cEditVis.m_hWnd,		"OSC_DENV_BUTTON_EDITVIS",	TUT_e_Button);
    TUT_M_vRegisterControl(m_cNewVis.m_hWnd,		"OSC_DENV_BUTTON_NEWVIS",	TUT_e_Button);
	// sound environment
    TUT_M_vRegisterControl(m_cSndListBox.m_hWnd,	"OSC_DENV_LIST_SOUNDENVS",	TUT_e_ListBox);
// END TUTORIAL

	// init all controls
	m_pDefaultEnv = NULL;
	fn_vInitEnvironment(NULL, FALSE);

    // init lists
	m_cMecListBox.fn_vInitParameters(this, m_pSectorInterface, E_te_MecEnvironment);
	m_cVisListBox.fn_vInitParameters(this, m_pSectorInterface, E_te_VisEnvironment);

    m_bInitialised = TRUE;
}
*/

/*===========================================================================
*		Description:	Init environment and controls
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/
/*
void SECT_DialogEnv::fn_vInitEnvironment (SECT_Environment *pEnv, BOOL bNewEnv)
{
	// no environment and controls enabled => new environment
	if ((!pEnv) && bNewEnv)
		m_pEnvironment = m_pDefaultEnv;
	else
		m_pEnvironment = pEnv;

	// update controls state
	fn_vInitControls(TRUE);

	// update parameters
	m_csName = (m_pEnvironment) ? m_pEnvironment->GetName() : "";
	// update controls
	m_cName.SetWindowText(m_csName);

	fn_vSelectMechanic((m_pEnvironment) ? m_pEnvironment->GetMecEnvironment() : NULL);
	fn_vSelectVisual((m_pEnvironment) ? m_pEnvironment->GetVisEnvironment() : NULL);
	fn_vSelectSound((m_pEnvironment) ? m_pEnvironment->GetSndEnvironment() : NULL);
	// sound
	m_cSndListBox.EnableWindow((m_pEnvironment != NULL));
}
*/

/*===========================================================================
*		Description:	Init controls
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/
/*
void SECT_DialogEnv::fn_vInitControls (BOOL bEnable)
{
	m_cCancel.EnableWindow(bEnable&&(m_pEnvironment == m_pDefaultEnv));
	m_cSave.EnableWindow(bEnable&&(m_pEnvironment == m_pDefaultEnv));
	m_cName.EnableWindow(bEnable&&(m_pEnvironment != NULL));
	m_cDefault.EnableWindow(bEnable&&(m_pEnvironment != NULL));

	// mec
	m_cMecListBox.EnableWindow(bEnable);
	m_cEditMec.EnableWindow(bEnable);
	m_cNewMec.EnableWindow(bEnable);
	// vis
	m_cVisListBox.EnableWindow(bEnable);
	m_cEditVis.EnableWindow(bEnable);
	m_cNewVis.EnableWindow(bEnable);
	// snd => only if Sound DLL present
	if (m_pSectorInterface->GetSoundEnvList())
		m_cSndListBox.EnableWindow(bEnable);
	else
		m_cSndListBox.EnableWindow(FALSE);
}
*/
/*===========================================================================
*		Description:	Reinit dialog
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/
/*
void SECT_DialogEnv::fn_vReinitDialog (void)
{
	// init default environment
	if (!m_pDefaultEnv)
	{
		m_pDefaultEnv = new SECT_Environment(m_pSectorInterface, NULL, NULL, NULL, "");
		m_pDefaultEnv->fn_bUnValidate();
		m_pDefaultEnv->fn_vNotifyUnSave();
	}

	// init mechanic
	fn_vInitMecListBox();
	// init mechanic
	fn_vInitVisListBox();
	// init sound
	fn_vInitSndListBox();
}
*/

/*===========================================================================
*		Description:	Init mechanic listbox
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/
/*
void SECT_DialogEnv::fn_vInitMecListBox	(void)
{
	// init style
	m_cMecListBox.SetOrder(E_lo_Alpha, FALSE, FALSE);
	// reinit list
	m_cMecListBox.SetSortedList(m_pSectorInterface->GetBaseObjectList(C_szMecEnvironmentTypeName));
	// current selection => none
	m_cMecListBox.SetSelectedItem(-1);
}
*/

/*===========================================================================
*		Description:	update mechanic selection
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/
/*
void SECT_DialogEnv::fn_vSelectMechanic	(SECT_MecEnvironment *pMecEnv, BOOL bUpdateEnv)
{
	SECT_MecEnvironment *pOldSelect, *pOldCurrent = NULL;
	SECT_ModifEnvParams *pModif;
	int					iInd;

	// update mechanic
	pOldSelect = m_pMecEnvironment;
	m_pMecEnvironment = pMecEnv;
	
	// update mechanic dialog
	if (m_pSectorInterface->GetDialogMec())
		m_pSectorInterface->GetDialogMec()->fn_vInitMecEnvironment(m_pMecEnvironment, FALSE);

	// update environment
	if ((bUpdateEnv)&&(m_pEnvironment))
	{
		pOldCurrent = m_pEnvironment->GetMecEnvironment();
		if ((m_pMecEnvironment)&&(m_pMecEnvironment != pOldCurrent))
		{
			if (m_pEnvironment != m_pDefaultEnv)
			{
				pModif = new SECT_ModifEnvParams(m_pSectorInterface, E_mt_ChangeMecEnv,
												 m_pEnvironment, m_pMecEnvironment, NULL, NULL);
				m_pSectorInterface->M_GetEditManager()->AskFor(pModif);
			}
			else
				m_pEnvironment->SetMecEnvironment(m_pMecEnvironment, FALSE);
		}
	}
	// redraw previous element
	if (pOldSelect != m_pMecEnvironment)
	{
		iInd = m_cMecListBox.GetCorrespondingIndex((DWORD) pOldSelect);
		m_cMecListBox.RedrawItems(iInd, iInd);
	}

	// redraw previous element
	if ((pOldCurrent)&&(pOldCurrent != pOldSelect))
	{
		iInd = m_cMecListBox.GetCorrespondingIndex((DWORD) pOldCurrent);
		m_cMecListBox.RedrawItems(iInd, iInd);
	}

	// update selection
	iInd = m_cMecListBox.GetCorrespondingIndex((DWORD) m_pMecEnvironment);
	m_cMecListBox.RedrawItems(iInd, iInd);

	// update button
	m_cEditMec.EnableWindow(m_pMecEnvironment != NULL);

	m_cMecListBox.UpdateWindow();
}
*/

/*===========================================================================
*		Description:	Init visual listbox
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/
/*
void SECT_DialogEnv::fn_vInitVisListBox	(void)
{
	// init style
	m_cVisListBox.SetOrder(E_lo_Alpha, FALSE, FALSE);
	// reinit list
	m_cVisListBox.SetSortedList(m_pSectorInterface->GetBaseObjectList(C_szVisEnvironmentTypeName));
	// m_cVisListBox selection => none
	m_cVisListBox.SetSelectedItem(-1);
}
*/
/*===========================================================================
*		Description:	update visual selection
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/
/*
void SECT_DialogEnv::fn_vSelectVisual (SECT_VisEnvironment *pVisEnv, BOOL bUpdateEnv)
{
	SECT_VisEnvironment *pOldSelect, *pOldCurrent = NULL;
	SECT_ModifEnvParams *pModif;
	int					iInd;

	// update mechanic
	pOldSelect = m_pVisEnvironment;
	m_pVisEnvironment = pVisEnv;
	
	// update mechanic dialog
	if (m_pSectorInterface->GetDialogVis())
		m_pSectorInterface->GetDialogVis()->fn_vInitVisEnvironment(m_pVisEnvironment, FALSE);

	// update environment
	if ((bUpdateEnv)&&(m_pEnvironment))
	{
		pOldCurrent = m_pEnvironment->GetVisEnvironment();
		if (m_pVisEnvironment != pOldCurrent)
		{
			if (m_pEnvironment != m_pDefaultEnv)
			{
				pModif = new SECT_ModifEnvParams(m_pSectorInterface, E_mt_ChangeVisEnv,
												 m_pEnvironment, NULL, m_pVisEnvironment, NULL);
				m_pSectorInterface->M_GetEditManager()->AskFor(pModif);
			}
			else
				m_pEnvironment->SetVisEnvironment(m_pVisEnvironment, FALSE);
		}
	}
	// redraw previous element
	if (pOldSelect != m_pVisEnvironment)
	{
		iInd = m_cVisListBox.GetCorrespondingIndex((DWORD) pOldSelect);
		m_cVisListBox.RedrawItems(iInd, iInd);
	}

	// redraw previous element
	if ((pOldCurrent)&&(pOldCurrent != pOldSelect))
	{
		iInd = m_cVisListBox.GetCorrespondingIndex((DWORD) pOldCurrent);
		m_cVisListBox.RedrawItems(iInd, iInd);
	}

	// update selection
	iInd = m_cVisListBox.GetCorrespondingIndex((DWORD) m_pVisEnvironment);
	m_cVisListBox.RedrawItems(iInd, iInd);

	// update button
	m_cEditVis.EnableWindow(m_pVisEnvironment != NULL);

	m_cVisListBox.UpdateWindow();
}
*/
/*===========================================================================
*		Description:	Init sound listbox
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/
/*
void SECT_DialogEnv::fn_vInitSndListBox	(void)
{
	CPA_BaseObjectList	*pListObject;
	CPA_BaseObject		*pElem;
	Position			pos;
	int					iInd;
	
	// RAZ
	m_cSndListBox.ResetContent();
	
	pListObject = m_pSectorInterface->GetSoundEnvList();
	if (!pListObject)
		return;
	
	// init content
	for (pElem = pListObject->GetHeadElement(pos); pElem;
		 pElem = pListObject->GetNextElement(pos))
	{
		// reinit list
		iInd = m_cSndListBox.AddString(pElem->GetName());
		m_cSndListBox.SetItemData(iInd, (DWORD) pElem);
	}
	// current selection => none
	m_cSndListBox.SetCurSel(-1);
}
*/

/*===========================================================================
*		Description:	update sound selection
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/
/*
void SECT_DialogEnv::fn_vSelectSound (SECT_SndEnvironment *pSndEnv, BOOL bUpdateEnv)
{
	SECT_SndEnvironment *pOldSelect, *pOldCurrent = NULL;
	SECT_ModifEnvParams *pModif;
	int					iInd;

	// update mechanic
	pOldSelect = m_pSndEnvironment;
	m_pSndEnvironment = pSndEnv;
	
	// update sound
	if ((bUpdateEnv)&&(m_pEnvironment)&&(m_pEnvironment != m_pDefaultEnv))
	{
		pOldCurrent = m_pEnvironment->GetSndEnvironment();
		if ((m_pSndEnvironment)&&(m_pSndEnvironment != pOldCurrent))
		{
			pModif = new SECT_ModifEnvParams(m_pSectorInterface, E_mt_ChangeSndEnv,
											 m_pEnvironment, NULL, NULL, m_pSndEnvironment);
			m_pSectorInterface->M_GetEditManager()->AskFor(pModif);
		}
	}
	// update selection
	iInd = GetSoundIndex((DWORD) m_pSndEnvironment);
	m_cSndListBox.SetCurSel(iInd);

}
*/

/*----------------------------------------
----------------------------------------*/
/*
int SECT_DialogEnv::GetSoundIndex (DWORD pElem)
{
	DWORD	pData;
	int		iIndex;

	for (iIndex = 0; iIndex < m_cSndListBox.GetCount(); iIndex++)
	{
		pData = m_cSndListBox.GetItemData(iIndex);
		if (pData == pElem)
			return iIndex;
	}
	return -1;
}
*/
//#################################################################################
// Messages
//#################################################################################

/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnSize(UINT, int, int)
{

	RECT WindowPosition;
	int ecx, ecy;

	if (!m_bInitialised)
		return;
	
	// calculate name position
	GetWindowRect(&WindowPosition);
	ecx = WindowPosition.right - WindowPosition.left - 10;
	ecx = (ecx < 100) ? 100 : ecx;
	ecy = WindowPosition.bottom - WindowPosition.top - 10;
	ecy = (ecy < 140) ? 140 : ecy;

	// buttons
	m_cCancel.MoveWindow(5, 7, 40, 16);
	m_cSave.MoveWindow(ecx-35, 7, 40, 16);
	// save
	m_cName.MoveWindow(50, 5, ecx-90, 20);
	// mechanic
	GetDlgItem(SECT_IDC_STATICMEC)->MoveWindow(5, 30, ecx/3, ecy-25);
	m_cMecListBox.MoveWindow(10, 45, ecx/3-10, ecy-75);
	m_cEditMec.MoveWindow(15, ecy-20, 25, 18);
	m_cNewMec.MoveWindow(ecx/3-30, ecy-20, 25, 18);
	// visual
	GetDlgItem(SECT_IDC_STATICVIS)->MoveWindow(ecx/3+5, 30, ecx/3, ecy-25);
	m_cVisListBox.MoveWindow(ecx/3+10, 45, ecx/3-10, ecy-75);
	m_cEditVis.MoveWindow(ecx/3+15, ecy-20, 25, 18);
	m_cNewVis.MoveWindow(2*ecx/3-30, ecy-20, 25, 18);
	// sound
	GetDlgItem(SECT_IDC_STATICSOUND)->MoveWindow(2*ecx/3+5, 30, ecx/3, ecy-25);
	m_cSndListBox.MoveWindow(2*ecx/3+10, 45, ecx/3-10, ecy-45);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnDestroy (void)
{
// FOR TUTORIAL
	TUT_M_vGetTutDll();
    // environment
	TUT_M_vUnregisterControl(m_cName.m_hWnd);
    TUT_M_vUnregisterControl(m_cDefault.m_hWnd);
    TUT_M_vUnregisterControl(m_cCancel.m_hWnd);
    TUT_M_vUnregisterControl(m_cSave.m_hWnd);
	// mechanic environment
    TUT_M_vUnregisterControl(m_cMecListBox.m_hWnd);
    TUT_M_vUnregisterControl(m_cEditMec.m_hWnd);
    TUT_M_vUnregisterControl(m_cNewMec.m_hWnd);
	// visual environment
    TUT_M_vUnregisterControl(m_cVisListBox.m_hWnd);
    TUT_M_vUnregisterControl(m_cEditVis.m_hWnd);
    TUT_M_vUnregisterControl(m_cNewVis.m_hWnd);
	// sound environment
    TUT_M_vUnregisterControl(m_cSndListBox.m_hWnd);
// END TUTORIAL

	CFormView::OnDestroy();
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnChangeName()
{
	CString	csFinalName;
	char	szNewName[256];
	
	// no environment => no modif
	if ((!m_pEnvironment)||(!m_cName.GetModify()))
		return;
	
	// get corresponding name
	m_cName.GetWindowText(szNewName, 255);
	if (!strcmp(szNewName, ""))
	{
		m_cName.SetWindowText(m_csName);
		return;
	}
	// get prefixed name
	csFinalName = m_pSectorInterface->GetInterface()->GetPrefixedName(szNewName);
	// check name validity
	if (m_pEnvironment->fn_eCheckValidity(csFinalName) == E_mc_None)
		m_csName = csFinalName;
	// update window
	m_cName.SetWindowText(m_csName);

	// update name
	if ((m_pEnvironment != m_pDefaultEnv)&&(m_csName != m_pEnvironment->GetName()))
	{
		m_pEnvironment->fn_eRename(m_csName);
		m_pSectorInterface->GetDialogEnvs()->fn_vInitEnvListBox();
	}
	// update flag
	m_cName.SetModify(FALSE);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnDefault()
{
	if (m_cName.GetModify())
	{
		OnChangeName();
		m_cName.SetFocus();
	}
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnCancel()
{
	// default env => cancel
	if (m_pEnvironment == m_pDefaultEnv)
		m_pEnvironment = NULL;

	// reinit controls
	fn_vInitEnvironment(m_pEnvironment, FALSE);
	// enable previous dialog
	m_pSectorInterface->GetDialogEnvs()->fn_vInitControls(TRUE);
	m_pSectorInterface->GetDialogSrf()->fn_vInitControls(TRUE);
	m_pSectorInterface->GetDialogEnvList()->fn_vInitControls(TRUE);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnSave()
{
	// default env => create it
	if (m_pEnvironment == m_pDefaultEnv)
	{
		m_pEnvironment = new SECT_Environment(m_pSectorInterface, m_pMecEnvironment, 
											  m_pVisEnvironment, m_pSndEnvironment, m_csName);
		m_pEnvironment->fn_vNotifySave();
		m_pSectorInterface->GetDialogEnvs()->fn_vInitEnvListBox();
	}
	// enable previous dialog
	m_pSectorInterface->GetDialogEnvList()->fn_vInitControls(TRUE);
	m_pSectorInterface->GetDialogSrf()->fn_vInitControls(TRUE);
	m_pSectorInterface->GetDialogEnvs()->fn_vInitControls(TRUE);
	m_pSectorInterface->GetDialogEnvs()->fn_vSelectEnv(m_pEnvironment);
}
*/

/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnSelChangeMecListBox(NMHDR* pNMHDR, LRESULT* pResult)
{
	SECT_MecEnvironment	*pMecEnv = NULL;
	LPNM_LISTVIEW		pNMListView = (LPNM_LISTVIEW)pNMHDR;
	BOOL				bOldSelect, bNewSelect;
	int					iIndex;
	
	// update param
	*pResult = 0;

	if ((pNMListView->uChanged != LVIF_STATE)||(m_cMecListBox.fn_bIsSelecting()))
		return;

	bOldSelect = (pNMListView->uOldState & LVIS_SELECTED);
	bNewSelect = (pNMListView->uNewState & LVIS_SELECTED);

	// get corresponding sector
	iIndex = pNMListView->iItem;
	pMecEnv = (SECT_MecEnvironment *) m_cMecListBox.GetItemData(iIndex);
	g_pClickedMecEnv = pMecEnv;

	m_cMecListBox.SetSelectedItem(-1);

	if (bOldSelect != bNewSelect)
	{
		// no env or unavailable env => invalid
		if ((!pMecEnv)||(!pMecEnv->fn_bIsAvailable()))
			fn_vSelectMechanic(m_pMecEnvironment, FALSE);
		else if (pMecEnv != m_pMecEnvironment)
			fn_vSelectMechanic(pMecEnv, FALSE);
	}
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnDblClkMecListBox(NMHDR* pNMHDR, LRESULT* pResult)
{
	SECT_MecEnvironment	*pMecEnv = NULL;

	// update param
	*pResult = 0;

	// get corresponding sector
	pMecEnv = g_pClickedMecEnv;
	g_pClickedMecEnv = NULL;

	// no env or unavailable env => invalid
	if ((!pMecEnv)||(!pMecEnv->fn_bIsAvailable()))
		fn_vSelectMechanic(m_pMecEnvironment);
	else 
		fn_vSelectMechanic(pMecEnv);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnEditMec()
{
	// no mecenv => no edition
	if (!m_pMecEnvironment)
		return;
	
	// disable dialog
	fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogSrf()->fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogEnvs()->fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogEnvList()->fn_vInitControls(FALSE);
	// update mechanic dialog
	m_pSectorInterface->GetDialogMec()->fn_vInitMecEnvironment(m_pMecEnvironment, TRUE);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnNewMec()
{
	// disable dialog
	fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogSrf()->fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogEnvs()->fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogEnvList()->fn_vInitControls(FALSE);
	
	// set selection
	m_cMecListBox.SetSelectedItem(-1);
	m_pSectorInterface->GetDialogMec()->fn_vInitMecEnvironment(NULL, TRUE);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnSelChangeVisListBox(NMHDR* pNMHDR, LRESULT* pResult)
{
	SECT_VisEnvironment	*pVisEnv = NULL;
	LPNM_LISTVIEW		pNMListView = (LPNM_LISTVIEW)pNMHDR;
	BOOL				bOldSelect, bNewSelect;
	int					iIndex;
	
	// update param
	*pResult = 0;

	if ((pNMListView->uChanged != LVIF_STATE)||(m_cVisListBox.fn_bIsSelecting()))
		return;

	bOldSelect = (pNMListView->uOldState & LVIS_SELECTED);
	bNewSelect = (pNMListView->uNewState & LVIS_SELECTED);

	// get corresponding sector
	iIndex = pNMListView->iItem;
	pVisEnv = (SECT_VisEnvironment *) m_cVisListBox.GetItemData(iIndex);
	g_pClickedVisEnv = pVisEnv;

	m_cVisListBox.SetSelectedItem(-1);

	if (bOldSelect != bNewSelect)
	{
		// no env or unavailable env => invalid
		if ((!pVisEnv)||(!pVisEnv->fn_bIsAvailable()))
			fn_vSelectVisual(m_pVisEnvironment, FALSE);
		else if (pVisEnv != m_pVisEnvironment)
			fn_vSelectVisual(pVisEnv, FALSE);
	}
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnDblClkVisListBox(NMHDR* pNMHDR, LRESULT* pResult)
{
	SECT_VisEnvironment	*pVisEnv = NULL;

	// update param
	*pResult = 0;

	// get corresponding sector
	pVisEnv = g_pClickedVisEnv;
	g_pClickedVisEnv = NULL;

	// no env or unavailable env => invalid
	if ((pVisEnv)&&(!pVisEnv->fn_bIsAvailable()))
		fn_vSelectVisual(m_pVisEnvironment);
	else 
		fn_vSelectVisual(pVisEnv);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnEditVis()
{
	// no visenv => no edition
	if (!m_pVisEnvironment)
		return;
	
	// disable dialog
	fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogSrf()->fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogEnvs()->fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogEnvList()->fn_vInitControls(FALSE);
	// update mechanic dialog
	m_pSectorInterface->GetDialogVis()->fn_vInitVisEnvironment(m_pVisEnvironment, TRUE);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnNewVis()
{
	// disable dialog
	fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogSrf()->fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogEnvs()->fn_vInitControls(FALSE);
	m_pSectorInterface->GetDialogEnvList()->fn_vInitControls(FALSE);
	
	// set selection
	m_cVisListBox.SetSelectedItem(-1);
	m_pSectorInterface->GetDialogVis()->fn_vInitVisEnvironment(NULL, TRUE);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnv::OnSelChangeSndListBox()
{
	SECT_SndEnvironment *pSndEnv = NULL;
	int					iInd;

	// no sound DLL => no change in sound environment
	if (!m_pSectorInterface->GetSoundEnvList())
		return;

	// get corresponding element
	iInd = m_cSndListBox.GetCurSel();
	if (iInd !=-1)
		pSndEnv = (SECT_SndEnvironment *) m_cSndListBox.GetItemData(iInd);

	// no env or unavailable env => invalid
	if ((pSndEnv)&&(!pSndEnv->fn_bIsAvailable()))
		fn_vSelectSound(m_pSndEnvironment);
	else if (pSndEnv != m_pSndEnvironment)
		fn_vSelectSound(pSndEnv);
}
*/

//#################################################################################
// SECT_EnvParamListBox 
//#################################################################################
/*----------------------------------------
----------------------------------------*/
/*
SECT_EnvParamListBox::SECT_EnvParamListBox (void)
{
}
*/

/*----------------------------------------
----------------------------------------*/
/*
SECT_EnvParamListBox::~SECT_EnvParamListBox (void)
{

}
*/

/*----------------------------------------
----------------------------------------*/
/*
BOOL SECT_EnvParamListBox::fn_bIsCurrentElement (CPA_BaseObject *pElem)
{
	SECT_Environment *pEnv;
	
	// no dialog => no current element
	if (!m_pDialog)
		return FALSE;
	
	// init parameters
	pEnv = ((SECT_DialogEnv *) m_pDialog)->GetCurrentEnv();
	
	switch (m_eType)
	{
		case E_te_MecEnvironment:
			return ((pEnv)&&(pElem == pEnv->GetMecEnvironment()));
		case E_te_VisEnvironment:
			return ((pEnv)&&(pElem == pEnv->GetVisEnvironment()));
		case E_te_SndEnvironment:
			return ((pEnv)&&(pElem == pEnv->GetSndEnvironment()));
		case E_te_NoType:
			return FALSE;
	}

	return FALSE;
}
*/

/*----------------------------------------
----------------------------------------*/
/*
BOOL SECT_EnvParamListBox::fn_bIsSelectedElement (CPA_BaseObject *pElem)
{
	// no dialog => no selected element
	if (!m_pDialog)
		return FALSE;
		
	switch (m_eType)
	{
		case E_te_MecEnvironment:
			return (pElem == ((SECT_DialogEnv *) m_pDialog)->GetSelectedMecEnv());
		case E_te_VisEnvironment:
			return (pElem == ((SECT_DialogEnv *) m_pDialog)->GetSelectedVisEnv());
		case E_te_SndEnvironment:
			return (pElem == ((SECT_DialogEnv *) m_pDialog)->GetSelectedSndEnv());
		case E_te_NoType:
			return FALSE;
	}

	return FALSE;
}
*/

/*----------------------------------------
----------------------------------------*/
/*
BOOL SECT_EnvParamListBox::fn_bIsAlreadyUsed (CPA_BaseObject *pElem)
{
	return FALSE;
}
*/


