reman3/Rayman_X/cpa/tempgrp/OSC/Src/SEClEnvs.cpp

507 lines
14 KiB
C++

/*=========================================================================
*
* SEClEnvs.cpp : Environment List Sector Dialog - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
/*
#include "stdafx.h"
#include "acp_base.h"
#include "SECTint.hpp"
#include "SEClEnvs.hpp"
#include "SECdEnvs.hpp"
#include "SECdSrfs.hpp"
#include "SECmodif.hpp"
#include "SECdEnv.hpp"
//#include "SECdList.hpp"
#include "..\Main\Inc\_EditID.h"
#include "TUT.h"
*/
//#################################################################################
// SECT_DialogEdit dialog
//#################################################################################
/*----------------------------------------
----------------------------------------*/
/*
SECT_DialogEnvList::SECT_DialogEnvList(CWnd* pParent)
: CFormView(SECT_DialogEnvList::IDD)
{
//{{AFX_DATA_INIT(SECT_DialogEnvList)
//}}AFX_DATA_INIT
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnvList::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(SECT_DialogEnvList)
// env list
DDX_Control(pDX, SECT_IDC_ENVLIST, m_cEnvList);
DDX_Control(pDX, SECT_IDC_ADDENVELEM, m_cAddElem);
DDX_Control(pDX, SECT_IDC_DELENVELEM, m_cDelElem);
// apply controls
DDX_Control(pDX, SECT_IDC_APPLYALL, m_cApplyAll);
DDX_Control(pDX, SECT_IDC_APPLYSELECT, m_cApplySelect);
DDX_Control(pDX, SECT_IDC_CANCELSELECT, m_cCancelSelect);
//}}AFX_DATA_MAP
}
*/
/*----------------------------------------
----------------------------------------*/
/*
BEGIN_MESSAGE_MAP(SECT_DialogEnvList, CFormView)
//{{AFX_MSG_MAP(SECT_DialogEnvList)
ON_WM_SIZE()
ON_WM_DESTROY()
ON_WM_DRAWITEM()
// env list
ON_LBN_SELCHANGE(SECT_IDC_ENVLIST, OnSelChangeEnvList)
ON_BN_CLICKED(SECT_IDC_ADDENVELEM, OnAddElem)
ON_BN_CLICKED(SECT_IDC_DELENVELEM, OnDelElem)
// keydown
ON_WM_VKEYTOITEM()
// apply
ON_BN_CLICKED(SECT_IDC_APPLYALL, OnApplyAll)
ON_BN_CLICKED(SECT_IDC_APPLYSELECT, OnApplySelect)
ON_BN_CLICKED(SECT_IDC_CANCELSELECT, OnCancelSelect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
*/
//#################################################################################
// SECT_DialogEdit Inits
//#################################################################################
/*===========================================================================
* Description: Init dialog
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogEnvList::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);
// init all controls
fn_vInitEnvList(NULL);
// FOR TUTORIAL
TUT_M_vGetTutDll();
// envlist
TUT_M_vRegisterControl (m_cEnvList.m_hWnd, "OSC_DELEM_LIST_ENVELEMS", TUT_e_ListBox);
TUT_M_vRegisterControl (m_cAddElem.m_hWnd, "OSC_DELEM_BUTTON_ADDELEM", TUT_e_Button);
TUT_M_vRegisterControl (m_cDelElem.m_hWnd, "OSC_DELEM_BUTTON_DELELEM", TUT_e_Button);
// apply
TUT_M_vRegisterControl (m_cApplyAll.m_hWnd, "OSC_DELEM_BUTTON_APPLYALL", TUT_e_Button);
TUT_M_vRegisterControl (m_cApplySelect.m_hWnd, "OSC_DELEM_BUTTON_APPLYSEL", TUT_e_Button);
TUT_M_vRegisterControl (m_cCancelSelect.m_hWnd, "OSC_DELEM_BUTTON_CANCELSEL", TUT_e_Button);
// END TUTORIAL
m_bInitialised = TRUE;
}
*/
/*===========================================================================
* Description: Init controls state
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogEnvList::fn_vInitControls (BOOL bEnable)
{
m_cEnvList.EnableWindow(bEnable);
m_cAddElem.EnableWindow(bEnable);
m_cDelElem.EnableWindow(bEnable && (m_lEnvElem != -1));
}
*/
/*===========================================================================
* Description: Init environment list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogEnvList::fn_vInitEnvList (CPA_SuperObject *pEditedSector)
{
Sector_Object *pSector;
SECT_EnvElem *pEnvElem;
SECT_SurfElem *pSurfElem;
SECT_Surface *pSurface;
CString csName;
long lNumEnv = 0;
int iPos;
// update edited sector
m_pEditedSector = pEditedSector;
// reinit env list
m_cEnvList.ResetContent();
m_lEnvElem = -1;
// update controls
m_cEnvList.EnableWindow((m_pEditedSector != NULL));
m_cAddElem.EnableWindow((m_pEditedSector != NULL));
m_cDelElem.EnableWindow(FALSE);
// update apply
m_cApplyAll.EnableWindow((m_pEditedSector != NULL));
m_cApplySelect.EnableWindow((m_pEditedSector != NULL));
// no edited sector => no list
if (!m_pEditedSector)
return;
// fill env list
pSector = (Sector_Object *) m_pEditedSector->GetObject();
pEnvElem = pSector->GetEnvironment(lNumEnv);
pSurfElem = pSector->GetSurface(lNumEnv);
// fill list with all environments
while (pEnvElem)
{
if (pSurfElem)
{
pSurface = pSurfElem->GetSurface();
csName = pSurface->GetName();
}
else
csName ="NoSurface";
iPos = m_cEnvList.AddString(csName);
lNumEnv++;
pEnvElem = pSector->GetEnvironment(lNumEnv);
pSurfElem = pSector->GetSurface(lNumEnv);
}
// update controls
fn_vInitEnvElem(-1);
}
*/
/*===========================================================================
* Description: reinit environment list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogEnvList::fn_vInitEnvElem (long lEnvElem)
{
// update edited element
m_lEnvElem = lEnvElem;
// update selection
m_cEnvList.SetCurSel(m_lEnvElem);
// update env list controls
m_cDelElem.EnableWindow((m_lEnvElem != -1));
// update env elem controls
m_pSectorInterface->GetDialogEnvs()->fn_vInitEnvElem(m_lEnvElem);
m_pSectorInterface->GetDialogSrf()->fn_vInitEnvElem(m_lEnvElem);
}
*/
/*===========================================================================
* Description: reinit environment list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogEnvList::fn_vUpdateEnvElem (void)
{
// update selection
m_cEnvList.SetCurSel(m_lEnvElem);
}
*/
/*===========================================================================
* Description: draw item in envlist
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
/*
void SECT_DialogEnvList::fn_vDrawEnvListItem (int nIDCtl, LPDRAWITEMSTRUCT lpDIS)
{
// draw item
Sector_Object *pSector;
SECT_SurfElem *pSurfElem;
SECT_EnvElem *pEnvElem;
COLORREF cColor;
CString csText;
BOOL bSelected;
CDC *pDC;
long lWidth, lLeft;
// init parameters
pDC = CDC::FromHandle(lpDIS->hDC);
bSelected = (lpDIS->itemState & ODS_SELECTED);
lWidth = lpDIS->rcItem.right - lpDIS->rcItem.left - 2;
lLeft = lpDIS->rcItem.left;
// fill drawing rect
cColor = RGB (254, 254, 254);
pDC->FillSolidRect(&lpDIS->rcItem, cColor);
pSector = (Sector_Object *) m_pEditedSector->GetObject();
pEnvElem = pSector->GetEnvironment(lpDIS->itemID);
pSurfElem = pSector->GetSurface(lpDIS->itemID);
// draw env
lpDIS->rcItem.left += 1;
lpDIS->rcItem.right = lpDIS->rcItem.left + lWidth/2;
cColor = (m_cEnvList.IsWindowEnabled()) ? RGB (128, 0, 0) : RGB (128, 128, 128);
pDC->SetTextColor(cColor);
csText = pEnvElem->GetEnvironment()->GetNameToDraw();
pDC->DrawText(csText, &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER);
// draw surface
if (pSurfElem)
{
lpDIS->rcItem.left = lpDIS->rcItem.right + 1;
lpDIS->rcItem.right = lpDIS->rcItem.left + lWidth/2;
cColor = (m_cEnvList.IsWindowEnabled()) ? RGB (100, 0, 0) : RGB (128, 128, 128);
pDC->SetTextColor(cColor);
csText = pSurfElem->GetSurface()->GetNameToDraw();
pDC->DrawText(csText, &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER);
}
// selection
if (bSelected)
{
lpDIS->rcItem.left = lLeft;
lpDIS->rcItem.right = lLeft + lWidth + 2;
pDC->InvertRect(&lpDIS->rcItem);
}
}
*/
//#################################################################################
// SECT_DialogEdit Messages
//#################################################################################
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnvList::OnSize (UINT nFlags, int cx, int cy)
{
RECT WindowPosition;
int ecx, ecy;
if (!m_bInitialised)
return;
// calculate name position
GetWindowRect(&WindowPosition);
ecx = WindowPosition.right - WindowPosition.left - 20;
ecy = WindowPosition.bottom - WindowPosition.top - 105;
ecy = (ecy < 50) ? 50 : ecy;
ecx = (ecx < 80) ? 80 : ecx;
// move list
m_cEnvList.MoveWindow(10, 5, ecx, ecy);
// move list controls
m_cAddElem.MoveWindow(ecx/2 - 40, ecy+10, 30, 16);
m_cDelElem.MoveWindow(ecx/2 + 30, ecy+10, 30, 16);
// move apply controls
GetDlgItem(SECT_IDC_SEPARATOR)->MoveWindow(5, ecy+35, ecx+10, 5);
m_cApplyAll.MoveWindow(10, ecy+45, ecx, 15);
m_cApplySelect.MoveWindow(10, ecy+65, ecx, 15);
m_cCancelSelect.MoveWindow(10, ecy+85, ecx, 15);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnvList::OnDestroy (void)
{
// FOR TUTORIAL
TUT_M_vGetTutDll();
TUT_M_vUnregisterControl (m_cEnvList.m_hWnd);
TUT_M_vUnregisterControl (m_cAddElem.m_hWnd);
TUT_M_vUnregisterControl (m_cDelElem.m_hWnd);
// apply
TUT_M_vUnregisterControl (m_cApplyAll.m_hWnd);
TUT_M_vUnregisterControl (m_cApplySelect.m_hWnd);
TUT_M_vUnregisterControl (m_cCancelSelect.m_hWnd);
// END TUTORIAL
CFormView::OnDestroy();
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnvList::OnDrawItem (int nIDCtl, LPDRAWITEMSTRUCT lpDIS)
{
// invalid item => default handling
if (lpDIS->itemID == LB_ERR)
return;
// env list => draw item
if (nIDCtl == SECT_IDC_ENVLIST)
fn_vDrawEnvListItem(nIDCtl, lpDIS);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnvList::OnSelChangeEnvList()
{
SECT_EnvElem *pEnvElem = NULL;
int iInd;
// get corresponding element
iInd = m_cEnvList.GetCurSel();
// select it and update dialog
if (iInd != m_lEnvElem)
fn_vInitEnvElem(iInd);
else
fn_vInitEnvElem(-1);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnvList::OnAddElem()
{
SECT_ModifEnvAndSrf *pModif;
SECT_Environment *pDefaultEnv;
SECT_Surface *pDefaultSurf;
Sector_Object *pSector;
// no sector => no modif
if (!m_pEditedSector)
return;
pSector = (Sector_Object *) m_pEditedSector->GetObject();
// test if there is a surface available
pDefaultSurf = m_pSectorInterface->GetDefaultSurface(pSector);
if (!pDefaultSurf)
return;
// get default environment
pDefaultEnv = m_pSectorInterface->GetDefaultEnvironment();
// create new environment elements
pModif = new SECT_ModifEnvAndSrf(m_pSectorInterface, E_mt_AddEnvAndSrf,
m_pEditedSector, -1, pDefaultEnv, pDefaultSurf);
m_pSectorInterface->M_GetEditManager()->AskFor(pModif);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnvList::OnDelElem()
{
SECT_ModifEnvAndSrf *pModif;
// no sector or no environment => no modif
if ((!m_pEditedSector)||(m_lEnvElem == -1))
return;
// get parameters
pModif = new SECT_ModifEnvAndSrf(m_pSectorInterface, E_mt_DelEnvAndSrf,
m_pEditedSector, m_lEnvElem, NULL, NULL);
m_pSectorInterface->M_GetEditManager()->AskFor(pModif);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
int SECT_DialogEnvList::OnVKeyToItem (UINT nKey, CWnd *pListBox, UINT nIndex)
{
// no sector or no environment => no modif
if ((!m_pEditedSector)||(m_lEnvElem == -1))
return -2;
// interface handling
m_pSectorInterface->fn_vOnKeyDownInEnvList (m_pEditedSector, m_lEnvElem, nKey);
return -2;
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnvList::OnApplyAll()
{
SECT_ModifApplyToSectors *pModif;
pModif = new SECT_ModifApplyToSectors(m_pSectorInterface, E_tm_ApplyToSectors,
m_pEditedSector, NULL);
m_pSectorInterface->M_GetEditManager()->AskFor(pModif);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnvList::OnApplySelect()
{
SECT_ModifApplyToSectors *pModif;
pModif = new SECT_ModifApplyToSectors(m_pSectorInterface, E_tm_ApplyToSectors,
m_pEditedSector, m_pSectorInterface->GetSelectList());
m_pSectorInterface->M_GetEditManager()->AskFor(pModif);
}
*/
/*----------------------------------------
----------------------------------------*/
/*
void SECT_DialogEnvList::OnCancelSelect()
{
// remove all selected sectors
m_pSectorInterface->GetSelectList()->RemoveAll();
// update drawing
m_pSectorInterface->fn_vShowSelection();
// udpate sector list
// m_pSectorInterface->GetDialogList()->fn_vReinitSectorList();
m_pSectorInterface->GetDialogList()->fn_vUpdateSelection(E_lrm_ReinitList);
}
*/