1203 lines
38 KiB
C++
1203 lines
38 KiB
C++
/*=========================================================================
|
|
*
|
|
* SECTenv.cpp : Implementation of Editor Environments
|
|
*
|
|
*
|
|
* Version 1.0
|
|
* Creation date
|
|
* Revision date
|
|
*
|
|
* Shaitan
|
|
*=======================================================================*/
|
|
|
|
/*
|
|
#include "stdafx.h"
|
|
#include "acp_base.h"
|
|
|
|
#include "SECTint.hpp"
|
|
|
|
#include "DPT.h"
|
|
|
|
|
|
#define C_szEnvActionName "Environment"
|
|
#define C_szMecEnvActionName "MechanicalEnvironment"
|
|
#define C_szVisEnvActionName "VisualEnv"
|
|
|
|
|
|
DeclareTemplateStatic(SECT_tdxHandleOfElementLstEnvironment);
|
|
DeclareTemplateStatic(DNM_tdxHandleToMecEnvironment);
|
|
DeclareTemplateStatic(ACP_tdxHandleToVisualEnvironment);
|
|
DeclareTemplateStatic(ENV_tdxHandleToEnvironment);
|
|
|
|
static long NbEnv = 0;
|
|
|
|
|
|
//#################################################################################
|
|
// Mechanic Environment
|
|
//#################################################################################
|
|
|
|
/===========================================================================
|
|
Default Constructor
|
|
===========================================================================/
|
|
SECT_MecEnvironment::SECT_MecEnvironment (Sector_Interface *p_oDLL,
|
|
DNM_tdxHandleToMecEnvironment hMecEnv, BOOL bAvailable,
|
|
CString csName, CString csFileName, BOOL bSectionExists)
|
|
: CPA_SaveObject(p_oDLL, C_szMecEnvironmentTypeName, E_ss_Responsible, NULL, bAvailable,
|
|
fn_szGetEnvironmentDataPath(), SECT_MecEnvironment::CallBackSaveMecEnvironment),
|
|
CPA_EdMot<DNM_tdxHandleToMecEnvironment>(hMecEnv)
|
|
{
|
|
char szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// section object
|
|
SetSectionData(this);
|
|
// section name
|
|
SCR_fn_v_RdL0_ComputeSectionName(szSectionName, (char *)(LPCSTR)csFileName, C_szMecEnvActionName, " ");
|
|
SetReferencedSectionName(szSectionName);
|
|
|
|
// name
|
|
if (fn_eRename(csName ) != E_mc_None)
|
|
SetDefaultValidName();
|
|
fn_vUpdateSectionName();
|
|
|
|
// existence
|
|
SetExistingSection(bSectionExists);
|
|
|
|
// if necessary, notify
|
|
if (fn_bCanBeNotified() && !fn_bSectionExists())
|
|
fn_vNotifySave() ;
|
|
}
|
|
|
|
/===========================================================================
|
|
New Constructor
|
|
===========================================================================/
|
|
SECT_MecEnvironment::SECT_MecEnvironment (Sector_Interface *p_oDLL, CString csName)
|
|
: CPA_SaveObject(p_oDLL, C_szMecEnvironmentTypeName, E_ss_Responsible, NULL, TRUE,
|
|
fn_szGetEnvironmentDataPath(), SECT_MecEnvironment::CallBackSaveMecEnvironment),
|
|
CPA_EdMot<DNM_tdxHandleToMecEnvironment>()
|
|
{
|
|
CString csFileName;
|
|
char szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// section object
|
|
SetSectionData(this);
|
|
// section name
|
|
csFileName = p_oDLL->GetMecEnvFileName();
|
|
SCR_fn_v_RdL0_ComputeSectionName(szSectionName, (char *)(LPCSTR)csFileName, C_szMecEnvActionName, " ");
|
|
SetReferencedSectionName(szSectionName);
|
|
|
|
// name
|
|
if (fn_eRename(csName ) != E_mc_None)
|
|
SetDefaultValidName();
|
|
fn_vUpdateSectionName();
|
|
|
|
// existence
|
|
SetExistingSection(FALSE);
|
|
|
|
// init all parameters
|
|
fn_vSetDefaultValues();
|
|
|
|
// if necessary, notify
|
|
if (fn_bCanBeNotified() && !fn_bSectionExists())
|
|
fn_vNotifySave() ;
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Destructor
|
|
===========================================================================/
|
|
SECT_MecEnvironment::~SECT_MecEnvironment (void)
|
|
{
|
|
|
|
}
|
|
|
|
/===========================================================================
|
|
Semantic
|
|
===========================================================================/
|
|
DNM_stMecEnvironment * SECT_MecEnvironment::GetMecStruct (void)
|
|
{
|
|
return ((DNM_stMecEnvironment *) GetStruct());
|
|
}
|
|
|
|
/===========================================================================
|
|
Default Values
|
|
===========================================================================/
|
|
void SECT_MecEnvironment::fn_vSetDefaultValues (void)
|
|
{
|
|
DNM_tdstVector *pVector;
|
|
|
|
// gravity
|
|
SetGravity((float) 9.81, FALSE);
|
|
// vertical
|
|
pVector = GetVertical();
|
|
pVector->m_xX = (float) 0.0;
|
|
pVector->m_xY = (float) 0.0;
|
|
pVector->m_xZ = (float) 1.0;
|
|
|
|
// fluid
|
|
SetFluidViscosity((float) 1.0, FALSE);
|
|
SetFluidDensity((float) 1.0, FALSE);
|
|
SetFluidLevel((float) 0.0, FALSE);
|
|
// stream
|
|
pVector = GetFluidStream();
|
|
pVector->m_xX = (float) 0.0;
|
|
pVector->m_xY = (float) 0.0;
|
|
pVector->m_xZ = (float) 0.0;
|
|
|
|
// volumic
|
|
SetVolumicEnvironment(C_EntryVolumicAir, FALSE);
|
|
}
|
|
|
|
/===========================================================================
|
|
Gravity Coefficient
|
|
===========================================================================/
|
|
DNM_tdxReal SECT_MecEnvironment::GetGravity (void)
|
|
{
|
|
return DNM_M_xEnvironmentGetGravity(GetMecStruct());
|
|
}
|
|
|
|
void SECT_MecEnvironment::SetGravity (MTH_tdxReal tdxNewGravity, BOOL bNotify)
|
|
{
|
|
DNM_M_xEnvironmentSetGravity(GetMecStruct(), tdxNewGravity);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Vertical
|
|
===========================================================================/
|
|
DNM_tdstVector * SECT_MecEnvironment::GetVertical (void)
|
|
{
|
|
return DNM_M_p_stEnvironmentGetVertical(GetMecStruct());
|
|
}
|
|
|
|
void SECT_MecEnvironment::SetVertical (DNM_tdstVector *tdstNewVertical, BOOL bNotify)
|
|
{
|
|
DNM_M_EnvironmentSetVertical(GetMecStruct(), tdstNewVertical);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
/===========================================================================
|
|
Fluid Density
|
|
===========================================================================/
|
|
DNM_tdxReal SECT_MecEnvironment::GetFluidDensity (void)
|
|
{
|
|
return DNM_M_xEnvironmentGetLiquidDensity(GetMecStruct());
|
|
}
|
|
|
|
void SECT_MecEnvironment::SetFluidDensity (MTH_tdxReal tdxNewFluidDensity, BOOL bNotify)
|
|
{
|
|
DNM_M_xEnvironmentSetLiquidDensity(GetMecStruct(), tdxNewFluidDensity);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
/===========================================================================
|
|
Fluid Viscosity
|
|
===========================================================================/
|
|
DNM_tdxReal SECT_MecEnvironment::GetFluidViscosity (void)
|
|
{
|
|
return DNM_M_xEnvironmentGetCx(GetMecStruct());
|
|
}
|
|
|
|
void SECT_MecEnvironment::SetFluidViscosity (MTH_tdxReal tdxNewFluidViscosity, BOOL bNotify)
|
|
{
|
|
DNM_M_xEnvironmentSetCx(GetMecStruct(), tdxNewFluidViscosity);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
/===========================================================================
|
|
Fluid Level
|
|
===========================================================================/
|
|
DNM_tdxReal SECT_MecEnvironment::GetFluidLevel (void)
|
|
{
|
|
return DNM_M_xEnvironmentGetLiquidLevel(GetMecStruct());
|
|
}
|
|
|
|
void SECT_MecEnvironment::SetFluidLevel (MTH_tdxReal tdxNewFluidLevel, BOOL bNotify)
|
|
{
|
|
DNM_M_xEnvironmentSetLiquidLevel(GetMecStruct(), tdxNewFluidLevel);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
/===========================================================================
|
|
Fluid Stream
|
|
===========================================================================/
|
|
DNM_tdstVector * SECT_MecEnvironment::GetFluidStream (void)
|
|
{
|
|
return DNM_M_p_stEnvironmentGetCurrentInLiquid(GetMecStruct());
|
|
}
|
|
|
|
void SECT_MecEnvironment::SetFluidStream (DNM_tdstVector *tdstNewFluidStream, BOOL bNotify)
|
|
{
|
|
DNM_M_EnvironmentSetCurrentInLiquid(GetMecStruct(), tdstNewFluidStream);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Volumic Environment
|
|
===========================================================================/
|
|
CString SECT_MecEnvironment::GetVolumicEnvironment (void)
|
|
{
|
|
DNM_tdeFluidEnvironment eVolumic;
|
|
CString csVolumic;
|
|
|
|
eVolumic = DNM_M_eFluidEnvironmentGetVolumicEnvironment(GetMecStruct());
|
|
switch (eVolumic)
|
|
{
|
|
case DNM_Fluid_Lava:
|
|
csVolumic = C_EntryVolumicLava;
|
|
break;
|
|
case DNM_Fluid_Water:
|
|
csVolumic = C_EntryVolumicWater;
|
|
break;
|
|
case DNM_Fluid_Air:
|
|
csVolumic = C_EntryVolumicAir;
|
|
break;
|
|
}
|
|
return csVolumic;
|
|
}
|
|
|
|
|
|
void SECT_MecEnvironment::SetVolumicEnvironment (CString csVolumic, BOOL bNotify)
|
|
{
|
|
if (csVolumic == C_EntryVolumicLava)
|
|
DNM_M_eFluidEnvironmentSetVolumicEnvironment(GetMecStruct(), DNM_Fluid_Lava);
|
|
else if (csVolumic == C_EntryVolumicWater)
|
|
DNM_M_eFluidEnvironmentSetVolumicEnvironment(GetMecStruct(), DNM_Fluid_Water);
|
|
else if (csVolumic == C_EntryVolumicAir)
|
|
DNM_M_eFluidEnvironmentSetVolumicEnvironment(GetMecStruct(), DNM_Fluid_Air);
|
|
else
|
|
DNM_M_eFluidEnvironmentSetVolumicEnvironment(GetMecStruct(), DNM_Fluid_Error);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
|
|
|
|
/===========================================================================
|
|
Callback mechanic
|
|
===========================================================================/
|
|
void SECT_MecEnvironment::CallBackSaveMecEnvironment (SCR_tdst_File_Description *p_stFile, char *szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction)
|
|
{
|
|
SECT_MecEnvironment *pMecEnv;
|
|
char szNewSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// get environment
|
|
pMecEnv = (SECT_MecEnvironment *) p_vData;
|
|
|
|
switch (eAction)
|
|
{
|
|
case SCR_EA_Ntfy_AddSection:
|
|
// go to end of file (we need all file directive to load this section)
|
|
SCR_fn_v_SvL1_ToEndSection(p_stFile);
|
|
SCR_M_SvL0_SaveBlankLine (p_stFile);
|
|
|
|
case SCR_EA_Ntfy_RebuildSection:
|
|
// save begin section
|
|
SCR_fn_v_RdL0_SplitSectionName(szSectionName, NULL, szActionName, szName);
|
|
SCR_fn_v_RdL0_ComputeSectionName(szNewSectionName, NULL, C_szMecEnvActionName, szName);
|
|
SCR_M_SvL0_SaveBeginSection(p_stFile, szNewSectionName, SCR_CC_C_Cfg_EOL);
|
|
// save gravity
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "Gravity", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f",
|
|
GLI_M_ValueToFloat(pMecEnv->GetGravity()));
|
|
// save vertical
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "Vertical", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f,%f,%f",
|
|
GLI_M_ValueToFloat(pMecEnv->GetVertical()->m_xX),
|
|
GLI_M_ValueToFloat(pMecEnv->GetVertical()->m_xY),
|
|
GLI_M_ValueToFloat(pMecEnv->GetVertical()->m_xZ));
|
|
// save viscosity
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "Viscosity", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f",
|
|
GLI_M_ValueToFloat(pMecEnv->GetFluidViscosity()));
|
|
// save density
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "LiquidDensity", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f",
|
|
GLI_M_ValueToFloat(pMecEnv->GetFluidDensity()));
|
|
// save level
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "LiquidLevel", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f",
|
|
GLI_M_ValueToFloat(pMecEnv->GetFluidLevel()));
|
|
// save stream
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "MoveLiquid", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f,%f,%f",
|
|
GLI_M_ValueToFloat(pMecEnv->GetFluidStream()->m_xX),
|
|
GLI_M_ValueToFloat(pMecEnv->GetFluidStream()->m_xY),
|
|
GLI_M_ValueToFloat(pMecEnv->GetFluidStream()->m_xZ));
|
|
// save volumic environment
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "VolumicEnvironment", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1,
|
|
(char*)(LPCSTR)pMecEnv->GetVolumicEnvironment());
|
|
|
|
// end section
|
|
SCR_M_SvL0_SaveEndSection (p_stFile, SCR_CC_C_Cfg_EOL);
|
|
if (eAction == SCR_EA_Ntfy_AddSection)
|
|
SCR_M_SvL0_SaveBlankLine (p_stFile);
|
|
// existence
|
|
pMecEnv->fn_vSectionSaved();
|
|
break;
|
|
|
|
|
|
case SCR_EA_Ntfy_DeleteSection:
|
|
// existence
|
|
pMecEnv->fn_vSectionDeleted();
|
|
break;
|
|
}
|
|
}
|
|
|
|
//#################################################################################
|
|
// Visual Environment
|
|
//#################################################################################
|
|
|
|
/===========================================================================
|
|
Default Constructor
|
|
===========================================================================/
|
|
SECT_VisEnvironment::SECT_VisEnvironment (Sector_Interface *p_oDLL,
|
|
ACP_tdxHandleToVisualEnvironment hVisEnv, BOOL bAvailable,
|
|
CString csName, CString csFileName, BOOL bSectionExists)
|
|
: CPA_SaveObject(p_oDLL, C_szVisEnvironmentTypeName, E_ss_Responsible, NULL, bAvailable,
|
|
fn_szGetEnvironmentDataPath(), SECT_VisEnvironment::CallBackSaveVisEnvironment),
|
|
CPA_EdMot<ACP_tdxHandleToVisualEnvironment>(hVisEnv)
|
|
{
|
|
char szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// section object
|
|
SetSectionData(this);
|
|
// section name
|
|
SCR_fn_v_RdL0_ComputeSectionName(szSectionName, (char *)(LPCSTR)csFileName, C_szVisEnvActionName, " ");
|
|
SetReferencedSectionName(szSectionName);
|
|
|
|
// name
|
|
if (fn_eRename(csName ) != E_mc_None)
|
|
SetDefaultValidName();
|
|
fn_vUpdateSectionName();
|
|
|
|
// existence
|
|
SetExistingSection(bSectionExists);
|
|
|
|
// if necessary, notify
|
|
if (fn_bCanBeNotified() && !fn_bSectionExists())
|
|
fn_vNotifySave() ;
|
|
}
|
|
|
|
/===========================================================================
|
|
New Constructor
|
|
===========================================================================/
|
|
SECT_VisEnvironment::SECT_VisEnvironment (Sector_Interface *p_oDLL, CString csName)
|
|
: CPA_SaveObject(p_oDLL, C_szVisEnvironmentTypeName, E_ss_Responsible, NULL, TRUE,
|
|
fn_szGetEnvironmentDataPath(), SECT_VisEnvironment::CallBackSaveVisEnvironment),
|
|
CPA_EdMot<ACP_tdxHandleToVisualEnvironment>()
|
|
{
|
|
CString csFileName;
|
|
char szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// section object
|
|
SetSectionData(this);
|
|
// section name
|
|
csFileName = p_oDLL->GetVisEnvFileName();
|
|
SCR_fn_v_RdL0_ComputeSectionName(szSectionName, (char *)(LPCSTR)csFileName, C_szVisEnvActionName, " ");
|
|
SetReferencedSectionName(szSectionName);
|
|
|
|
// name
|
|
if (fn_eRename(csName ) != E_mc_None)
|
|
SetDefaultValidName();
|
|
fn_vUpdateSectionName();
|
|
|
|
// existence
|
|
SetExistingSection(FALSE);
|
|
|
|
// init all parameters
|
|
fn_vInitFog();
|
|
|
|
// if necessary, notify
|
|
if (fn_bCanBeNotified() && !fn_bSectionExists())
|
|
fn_vNotifySave() ;
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Destructor
|
|
===========================================================================/
|
|
SECT_VisEnvironment::~SECT_VisEnvironment (void)
|
|
{
|
|
|
|
}
|
|
|
|
/===========================================================================
|
|
Default Values
|
|
===========================================================================/
|
|
void SECT_VisEnvironment::fn_vInitFog (void)
|
|
{
|
|
GLI_tdstColor stColor;
|
|
|
|
// if there is no fog, create it
|
|
if (!fn_bHasFog())
|
|
GLI_fn_vCreateFogInVisualEnvironment(GetStruct());
|
|
|
|
// init values
|
|
SetFogNear(0, FALSE);
|
|
SetFogFar(5000, FALSE);
|
|
SetFogBlendNear(0, FALSE);
|
|
SetFogBlendFar(0, FALSE);
|
|
SetFogInfinite(5000, FALSE);
|
|
|
|
stColor.xR = 0.5;
|
|
stColor.xG = 0.5;
|
|
stColor.xB = 0.5;
|
|
SetFogColor(&stColor, FALSE);
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Fog
|
|
===========================================================================/
|
|
BOOL SECT_VisEnvironment::fn_bHasFog (void)
|
|
{
|
|
return GLI_fn_bVisualEnvironmentHasFog(GetStruct());
|
|
}
|
|
|
|
/===========================================================================
|
|
Fog Near
|
|
===========================================================================/
|
|
MTH_tdxReal SECT_VisEnvironment::GetFogNear (void)
|
|
{
|
|
return GLI_fn_xGetNearInFog(GetStruct());
|
|
}
|
|
|
|
void SECT_VisEnvironment::SetFogNear (MTH_tdxReal xNewNear, BOOL bNotify)
|
|
{
|
|
GLI_fn_vSetNearInFog(GetStruct(), xNewNear);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
/===========================================================================
|
|
Fog Far
|
|
===========================================================================/
|
|
MTH_tdxReal SECT_VisEnvironment::GetFogFar (void)
|
|
{
|
|
return GLI_fn_xGetFarInFog(GetStruct());
|
|
}
|
|
|
|
void SECT_VisEnvironment::SetFogFar (MTH_tdxReal xNewFar, BOOL bNotify)
|
|
{
|
|
GLI_fn_vSetFarInFog(GetStruct(), xNewFar);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
/===========================================================================
|
|
Fog Near
|
|
===========================================================================/
|
|
MTH_tdxReal SECT_VisEnvironment::GetFogBlendNear (void)
|
|
{
|
|
return GLI_fn_xGetBlendNearInFog(GetStruct());
|
|
}
|
|
|
|
void SECT_VisEnvironment::SetFogBlendNear (MTH_tdxReal xNewNear, BOOL bNotify)
|
|
{
|
|
GLI_fn_vSetBlendNearInFog(GetStruct(), xNewNear);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
/===========================================================================
|
|
Fog Far
|
|
===========================================================================/
|
|
MTH_tdxReal SECT_VisEnvironment::GetFogBlendFar (void)
|
|
{
|
|
return GLI_fn_xGetBlendFarInFog(GetStruct());
|
|
}
|
|
|
|
void SECT_VisEnvironment::SetFogBlendFar (MTH_tdxReal xNewFar, BOOL bNotify)
|
|
{
|
|
GLI_fn_vSetBlendFarInFog(GetStruct(), xNewFar);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Fog Infinite
|
|
===========================================================================/
|
|
MTH_tdxReal SECT_VisEnvironment::GetFogInfinite (void)
|
|
{
|
|
return GLI_fn_xGetInfiniteInFog(GetStruct());
|
|
}
|
|
|
|
void SECT_VisEnvironment::SetFogInfinite (MTH_tdxReal xNewInfinite, BOOL bNotify)
|
|
{
|
|
GLI_fn_vSetInfiniteInFog(GetStruct(), xNewInfinite);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Fog Color
|
|
===========================================================================/
|
|
GLI_tdstColor * SECT_VisEnvironment::GetFogColor (void)
|
|
{
|
|
return GLI_fn_pGetColorInFog(GetStruct());
|
|
}
|
|
|
|
void SECT_VisEnvironment::SetFogColor (GLI_tdstColor *pNewColor, BOOL bNotify)
|
|
{
|
|
GLI_fn_vSetColorInFog(GetStruct(), pNewColor);
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Callback mechanic
|
|
===========================================================================/
|
|
void SECT_VisEnvironment::CallBackSaveVisEnvironment (SCR_tdst_File_Description *p_stFile, char *szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction)
|
|
{
|
|
SECT_VisEnvironment *pVisEnv;
|
|
char szNewSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// get environment
|
|
pVisEnv = (SECT_VisEnvironment *) p_vData;
|
|
|
|
switch (eAction)
|
|
{
|
|
case SCR_EA_Ntfy_AddSection:
|
|
// go to end of file (we need all file directive to load this section)
|
|
SCR_fn_v_SvL1_ToEndSection(p_stFile);
|
|
SCR_M_SvL0_SaveBlankLine (p_stFile);
|
|
|
|
case SCR_EA_Ntfy_RebuildSection:
|
|
// save begin section
|
|
SCR_fn_v_RdL0_SplitSectionName(szSectionName, NULL, szActionName, szName);
|
|
SCR_fn_v_RdL0_ComputeSectionName(szNewSectionName, NULL, C_szVisEnvActionName, szName);
|
|
SCR_M_SvL0_SaveBeginSection(p_stFile, szNewSectionName, SCR_CC_C_Cfg_EOL);
|
|
|
|
// save fog subsection
|
|
if (pVisEnv->fn_bHasFog())
|
|
{
|
|
// begin subsection
|
|
SCR_fn_v_RdL0_ComputeSectionName(szNewSectionName, NULL, "Fog", " ");
|
|
SCR_M_SvL0_SaveBeginSection(p_stFile, szNewSectionName, SCR_CC_C_Cfg_EOL);
|
|
// save near
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "Near", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f",
|
|
GLI_M_ValueToFloat(pVisEnv->GetFogNear()));
|
|
// save far
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "Far", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f",
|
|
GLI_M_ValueToFloat(pVisEnv->GetFogFar()));
|
|
// save blend near
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "BlendNear", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f",
|
|
GLI_M_ValueToFloat(pVisEnv->GetFogBlendNear()));
|
|
// save blend far
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "BlendFar", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f",
|
|
GLI_M_ValueToFloat(pVisEnv->GetFogBlendFar()));
|
|
// save infinite
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "Infinite", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f",
|
|
GLI_M_ValueToFloat(pVisEnv->GetFogInfinite()));
|
|
// save color
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "Color", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f,%f,%f",
|
|
GLI_M_ValueToFloat(pVisEnv->GetFogColor()->xR),
|
|
GLI_M_ValueToFloat(pVisEnv->GetFogColor()->xG),
|
|
GLI_M_ValueToFloat(pVisEnv->GetFogColor()->xB));
|
|
// end section
|
|
SCR_M_SvL0_SaveEndSection (p_stFile, SCR_CC_C_Cfg_EOL);
|
|
}
|
|
|
|
// end section
|
|
SCR_M_SvL0_SaveEndSection (p_stFile, SCR_CC_C_Cfg_EOL);
|
|
if (eAction == SCR_EA_Ntfy_AddSection)
|
|
SCR_M_SvL0_SaveBlankLine (p_stFile);
|
|
// existence
|
|
pVisEnv->fn_vSectionSaved();
|
|
break;
|
|
|
|
|
|
case SCR_EA_Ntfy_DeleteSection:
|
|
// existence
|
|
pVisEnv->fn_vSectionDeleted();
|
|
break;
|
|
}
|
|
}
|
|
|
|
//#################################################################################
|
|
// Environment
|
|
//#################################################################################
|
|
|
|
/===========================================================================
|
|
Default Constructor
|
|
===========================================================================/
|
|
SECT_Environment::SECT_Environment (Sector_Interface *p_oDLL,
|
|
ENV_tdxHandleToEnvironment hEnvironment, BOOL bAvailable,
|
|
CString csName, CString csFileName)
|
|
: CPA_SaveObject(p_oDLL, C_szEnvironmentTypeName, E_ss_Responsible, NULL, bAvailable,
|
|
fn_szGetEnvironmentDataPath(), SECT_Environment::CallBackSaveEnvironment),
|
|
CPA_EdMot<ENV_tdxHandleToEnvironment>(hEnvironment)
|
|
{
|
|
ACP_tdxHandleToVisualEnvironment hVisEnv;
|
|
DNM_tdxHandleToMecEnvironment hMecEnv;
|
|
SND_tdxHandleToSoundInfo hSndEnv;
|
|
SECT_MecEnvironment *pMecEnv;
|
|
SECT_VisEnvironment *pVisEnv;
|
|
SECT_SndEnvironment *pSndEnv;
|
|
char szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// section object
|
|
SetSectionData(this);
|
|
// section name
|
|
SCR_fn_v_RdL0_ComputeSectionName(szSectionName, (char *)(LPCSTR)csFileName, C_szEnvActionName, " ");
|
|
SetReferencedSectionName(szSectionName);
|
|
|
|
// name
|
|
if (fn_eRename(csName ) != E_mc_None)
|
|
SetDefaultValidName();
|
|
fn_vUpdateSectionName();
|
|
|
|
// existence
|
|
SetExistingSection(TRUE);
|
|
|
|
// get mechanic environment
|
|
hMecEnv = ENV_fn_hGetMechanicsEnvironment(GetStruct());
|
|
pMecEnv = p_oDLL->GetOrBuildMecEnvironment(hMecEnv);
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vAddALink(this, pMecEnv);
|
|
m_pMecEnvironment = pMecEnv;
|
|
|
|
// get visual environment
|
|
hVisEnv = ENV_M_hGetVisualEnvironment(GetStruct());
|
|
pVisEnv = p_oDLL->GetOrBuildVisEnvironment(hVisEnv);
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vAddALink(this, pVisEnv);
|
|
m_pVisEnvironment = pVisEnv;
|
|
|
|
// get sound environment
|
|
hSndEnv = ENV_fn_vGetSoundEnvironment(GetStruct());
|
|
pSndEnv = p_oDLL->GetOrNullSndEnvironment(hSndEnv);
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vAddALink(this, pSndEnv);
|
|
m_pSndEnvironment = pSndEnv;
|
|
|
|
// if necessary, notify
|
|
if (fn_bCanBeNotified() && !fn_bSectionExists())
|
|
fn_vNotifySave() ;
|
|
}
|
|
|
|
/===========================================================================
|
|
New Constructor
|
|
===========================================================================/
|
|
SECT_Environment::SECT_Environment (Sector_Interface *p_oDLL,
|
|
SECT_MecEnvironment *pMecEnvironment,
|
|
SECT_VisEnvironment *pVisEnvironment,
|
|
SECT_SndEnvironment *pSndEnvironment,
|
|
CString csName)
|
|
: CPA_SaveObject(p_oDLL, C_szEnvironmentTypeName, E_ss_Responsible, NULL, TRUE,
|
|
fn_szGetEnvironmentDataPath(), SECT_Environment::CallBackSaveEnvironment),
|
|
CPA_EdMot<ENV_tdxHandleToEnvironment>()
|
|
{
|
|
CString csFileName;
|
|
char szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// section object
|
|
SetSectionData(this);
|
|
// section name
|
|
csFileName = p_oDLL->GetEnvFileName();
|
|
SCR_fn_v_RdL0_ComputeSectionName(szSectionName, (char *)(LPCSTR)csFileName, C_szEnvActionName, " ");
|
|
SetReferencedSectionName(szSectionName);
|
|
|
|
// name
|
|
if (fn_eRename(csName ) != E_mc_None)
|
|
SetDefaultValidName();
|
|
fn_vUpdateSectionName();
|
|
|
|
// existence
|
|
SetExistingSection(FALSE);
|
|
|
|
// associate mechanic environment
|
|
if (pMecEnvironment)
|
|
SetMecEnvironment(pMecEnvironment, FALSE);
|
|
else
|
|
SetMecEnvironment(p_oDLL->GetDefaultMecEnvironment(), FALSE);
|
|
|
|
// associate visual environment
|
|
if (pVisEnvironment)
|
|
SetVisEnvironment(pVisEnvironment, FALSE);
|
|
else
|
|
SetVisEnvironment(p_oDLL->GetDefaultVisEnvironment(), FALSE);
|
|
|
|
// associate sound environment
|
|
if (pSndEnvironment)
|
|
SetSndEnvironment(pSndEnvironment, FALSE);
|
|
else
|
|
SetSndEnvironment(p_oDLL->GetDefaultSndEnvironment(), FALSE);
|
|
|
|
// if necessary, notify
|
|
if (fn_bCanBeNotified() && !fn_bSectionExists())
|
|
fn_vNotifySave() ;
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Destructor
|
|
===========================================================================/
|
|
SECT_Environment::~SECT_Environment (void)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Mec Environment
|
|
===========================================================================/
|
|
|
|
void SECT_Environment::SetMecEnvironment (SECT_MecEnvironment *pMecEnv, BOOL bNotify)
|
|
{
|
|
// if there was a mechanic environment, warn coherence manager
|
|
if (m_pMecEnvironment)
|
|
g_oCoherenceManager.m_fn_vRemoveALink(this, m_pMecEnvironment);
|
|
|
|
// set editor mechanic environment
|
|
m_pMecEnvironment = pMecEnv;
|
|
// set engine mechanic environment
|
|
ENV_fn_vSetMechanicsEnvironment(GetStruct(), m_pMecEnvironment->GetStruct());
|
|
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vAddALink(this, m_pMecEnvironment);
|
|
// save
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
/===========================================================================
|
|
Vis Environment
|
|
===========================================================================/
|
|
void SECT_Environment::SetVisEnvironment (SECT_VisEnvironment *pVisEnv, BOOL bNotify)
|
|
{
|
|
// if there was a mechanic environment, warn coherence manager
|
|
if (m_pVisEnvironment)
|
|
g_oCoherenceManager.m_fn_vRemoveALink(this, m_pVisEnvironment);
|
|
|
|
// set editor mechanic environment
|
|
m_pVisEnvironment = pVisEnv;
|
|
// set engine mechanic environment
|
|
ENV_fn_vSetVisualEnvironment(GetStruct(), (m_pVisEnvironment) ? m_pVisEnvironment->GetStruct() : NULL);
|
|
|
|
// warn coherence manager
|
|
if (m_pVisEnvironment)
|
|
g_oCoherenceManager.m_fn_vAddALink(this, m_pVisEnvironment);
|
|
// save
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Snd Environment
|
|
===========================================================================/
|
|
void SECT_Environment::SetSndEnvironment (SECT_SndEnvironment * pSndEnv, BOOL bNotify)
|
|
{
|
|
// if there was a mechanic environment, warn coherence manager
|
|
if (m_pSndEnvironment)
|
|
g_oCoherenceManager.m_fn_vRemoveALink(this, m_pSndEnvironment);
|
|
|
|
// set editor sound evironment
|
|
m_pSndEnvironment = pSndEnv;
|
|
// set engine mechanic environment
|
|
ENV_fn_vSetSoundEnvironment(GetStruct(), (pSndEnv) ? (long) pSndEnv->GetData() : NULL);
|
|
|
|
// warn coherence manager
|
|
if (pSndEnv)
|
|
g_oCoherenceManager.m_fn_vAddALink(this, m_pSndEnvironment);
|
|
// save
|
|
if (bNotify)
|
|
fn_vNotifySave();
|
|
}
|
|
|
|
/===========================================================================
|
|
Init Snd Environment
|
|
===========================================================================/
|
|
void SECT_Environment::fn_vInitSndEnvironment (void)
|
|
{
|
|
SND_tdxHandleToSoundInfo hSndEnv;
|
|
|
|
// already initialised => no change
|
|
if (m_pSndEnvironment)
|
|
return;
|
|
|
|
// get sound environment
|
|
hSndEnv = ENV_fn_vGetSoundEnvironment(GetStruct());
|
|
m_pSndEnvironment = GetSectorInterface()->GetOrNullSndEnvironment(hSndEnv);
|
|
}
|
|
|
|
/===========================================================================
|
|
Snd Environment Reference
|
|
===========================================================================/
|
|
CString SECT_Environment::GetSndEnvironmentReference (void)
|
|
{
|
|
SND_tdxHandleToSoundInfo hSndEnv;
|
|
CString csSoundEnv;
|
|
|
|
// get sound environment
|
|
hSndEnv = ENV_fn_vGetSoundEnvironment(GetStruct());
|
|
csSoundEnv.Format("%ld", hSndEnv);
|
|
return csSoundEnv;
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// Save
|
|
//#################################################################################
|
|
|
|
/===========================================================================
|
|
Callback
|
|
===========================================================================/
|
|
void SECT_Environment::CallBackSaveEnvironment (SCR_tdst_File_Description *p_stFile, char *szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction)
|
|
{
|
|
SECT_Environment *pEnvironment;
|
|
CString csNewSectionName;
|
|
char szNewSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// get environment
|
|
pEnvironment = (SECT_Environment *) p_vData;
|
|
|
|
switch (eAction)
|
|
{
|
|
case SCR_EA_Ntfy_AddSection:
|
|
// go to end of file (we need all file directive to load this section)
|
|
SCR_fn_v_SvL1_ToEndSection(p_stFile);
|
|
SCR_M_SvL0_SaveBlankLine (p_stFile);
|
|
|
|
case SCR_EA_Ntfy_RebuildSection:
|
|
// save begin section
|
|
SCR_fn_v_RdL0_ComputeSectionName(szNewSectionName, NULL, C_szEnvActionName, (char *)(LPCSTR) pEnvironment->GetName());
|
|
SCR_M_SvL0_SaveBeginSection(p_stFile, szNewSectionName, SCR_CC_C_Cfg_EOL);
|
|
// save mechanical environment
|
|
if (pEnvironment->GetMecEnvironment())
|
|
{
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "MecaEnvironment", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1,
|
|
(char *) (LPCSTR) pEnvironment->GetMecEnvironment()->GetReferencedSectionName());
|
|
}
|
|
// save visual environment
|
|
if (pEnvironment->GetVisEnvironment())
|
|
{
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "VisualEnvironment", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1,
|
|
(char *) (LPCSTR) pEnvironment->GetVisEnvironment()->GetReferencedSectionName());
|
|
}
|
|
// save sound environment
|
|
if (pEnvironment->GetSndEnvironment())
|
|
{
|
|
SCR_M_SvL0_SaveEntry(p_stFile, "SoundEnvironment", SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1,
|
|
(char *) (LPCSTR) pEnvironment->GetSndEnvironmentReference());
|
|
}
|
|
// end section
|
|
SCR_M_SvL0_SaveEndSection (p_stFile, SCR_CC_C_Cfg_EOL);
|
|
if (eAction == SCR_EA_Ntfy_AddSection)
|
|
SCR_M_SvL0_SaveBlankLine (p_stFile);
|
|
// update section
|
|
pEnvironment->fn_vSectionSaved();
|
|
break;
|
|
|
|
case SCR_EA_Ntfy_DeleteSection:
|
|
// update section
|
|
pEnvironment->fn_vSectionDeleted();
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// Environment Element
|
|
//#################################################################################
|
|
|
|
/===========================================================================
|
|
Default Constructor
|
|
===========================================================================/
|
|
SECT_EnvElem::SECT_EnvElem (SECT_tdxHandleOfElementLstEnvironment hEnvElem, Sector_Object *pOwnerSector)
|
|
: CPA_EdMot<SECT_tdxHandleOfElementLstEnvironment>(hEnvElem),
|
|
SECT_EnvElementBase (pOwnerSector)
|
|
{
|
|
ENV_tdxHandleToEnvironment hEnv;
|
|
|
|
// init environment
|
|
hEnv = SECT_GetEnvironmentInList(hEnvElem);
|
|
m_pEnvironment = pOwnerSector->GetSectorInterface()->GetOrBuildEnvironment(hEnv);
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
New Constructor
|
|
===========================================================================/
|
|
SECT_EnvElem::SECT_EnvElem (SECT_Environment *pEnvironment, Sector_Object *pOwnerSector)
|
|
: CPA_EdMot<SECT_tdxHandleOfElementLstEnvironment>(),
|
|
SECT_EnvElementBase (pOwnerSector)
|
|
{
|
|
// init environment
|
|
m_pEnvironment = pEnvironment;
|
|
SECT_fn_vSetHandleOfEnvironmentInEnvironmentList(GetStruct(), pEnvironment->GetStruct());
|
|
}
|
|
|
|
/===========================================================================
|
|
Destructor
|
|
===========================================================================/
|
|
SECT_EnvElem::~SECT_EnvElem (void)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Environment
|
|
===========================================================================/
|
|
void SECT_EnvElem::SetEnvironment (SECT_Environment *pEnvironment)
|
|
{
|
|
// if there was an environment, warn coherence manager
|
|
if ((m_pEnvironment)&&(m_pOwnerSector))
|
|
g_oCoherenceManager.m_fn_vRemoveALink(m_pOwnerSector, m_pEnvironment);
|
|
|
|
// set environment
|
|
m_pEnvironment = pEnvironment;
|
|
// update engine element
|
|
SECT_fn_vSetHandleOfEnvironmentInEnvironmentList(GetStruct(), pEnvironment->GetStruct());
|
|
|
|
// warn coherence manager
|
|
if (m_pOwnerSector)
|
|
g_oCoherenceManager.m_fn_vAddALink(m_pOwnerSector, m_pEnvironment);
|
|
// notify modif
|
|
if (g_bCanSave)
|
|
fn_vWriteSection();
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// Environment List
|
|
//#################################################################################
|
|
|
|
/===========================================================================
|
|
Add Environment
|
|
===========================================================================/
|
|
BOOL SECT_EnvironmentList::fn_bAddAnElement (SECT_EnvElem *pNewElem, SECT_EnvElem *pPreviousElem, BOOL bUpdateEngine)
|
|
{
|
|
POSITION pos;
|
|
|
|
// check element
|
|
if (pNewElem->GetOwnerSector() != m_pOwnerSector)
|
|
return FALSE;
|
|
|
|
// no previous element => add head
|
|
if (!pPreviousElem)
|
|
AddHead(pNewElem, bUpdateEngine);
|
|
// previous element => add at corresponding position
|
|
else
|
|
{
|
|
pos = Find(pPreviousElem, NULL);
|
|
InsertAfter(pos, pNewElem, bUpdateEngine);
|
|
}
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vAddALink(m_pOwnerSector, pNewElem->GetEnvironment());
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/===========================================================================
|
|
Remove Environment
|
|
===========================================================================/
|
|
void SECT_EnvironmentList::fn_vRemoveAnElement (SECT_EnvElem *pOldElem, BOOL bUpdateEngine)
|
|
{
|
|
POSITION pos;
|
|
|
|
// add element to the list
|
|
pos = Find(pOldElem, NULL);
|
|
if (pos)
|
|
RemoveAt(pos, bUpdateEngine);
|
|
// warn coherence manager
|
|
g_oCoherenceManager.m_fn_vRemoveALink(m_pOwnerSector, pOldElem->GetEnvironment());
|
|
}
|
|
|
|
/===========================================================================
|
|
Remove All Elements
|
|
===========================================================================/
|
|
void SECT_EnvironmentList::fn_vRemoveAllElements (BOOL bUpdateEngine)
|
|
{
|
|
SECT_EnvElem *pElem;
|
|
|
|
while (GetCount() > 0)
|
|
{
|
|
pElem = RemoveTail(bUpdateEngine);
|
|
g_oCoherenceManager.m_fn_vRemoveALink(m_pOwnerSector, pElem->GetEnvironment());
|
|
}
|
|
}
|
|
|
|
/===========================================================================
|
|
Find Environment Element
|
|
===========================================================================/
|
|
SECT_EnvElem * SECT_EnvironmentList::GetElementWithEnvironment (SECT_Environment *pEnvironment)
|
|
{
|
|
SECT_EnvElem *pElem;
|
|
POSITION pos;
|
|
|
|
// check every element
|
|
for (pElem = GetHeadElement(pos); pElem; pElem = GetNextElement(pos))
|
|
{
|
|
if (pElem->GetEnvironment() == pEnvironment)
|
|
return pElem;
|
|
}
|
|
// element was not found
|
|
return NULL;
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// SECT_EnvListBox
|
|
//#################################################################################
|
|
/----------------------------------------
|
|
----------------------------------------/
|
|
SECT_EnvListBox::SECT_EnvListBox (void)
|
|
{
|
|
// init parameters
|
|
m_pSectorInterface = NULL;
|
|
m_pDialog = NULL;
|
|
m_eType = E_te_NoType;
|
|
}
|
|
|
|
/----------------------------------------
|
|
----------------------------------------/
|
|
SECT_EnvListBox::~SECT_EnvListBox (void)
|
|
{
|
|
|
|
}
|
|
|
|
/----------------------------------------
|
|
----------------------------------------/
|
|
void SECT_EnvListBox::fn_vInitParameters (CFormView *pDialog, Sector_Interface *pSectorInterface, tdeTypeElem eType)
|
|
{
|
|
m_pDialog = pDialog;
|
|
m_pSectorInterface = pSectorInterface;
|
|
m_eType = eType;
|
|
|
|
// set list style
|
|
SetDrawStyle(C_lDrawName, FALSE, FALSE);
|
|
// set parameters
|
|
SetOwnerEditor(m_pSectorInterface);
|
|
}
|
|
|
|
/----------------------------------------
|
|
----------------------------------------/
|
|
void SECT_EnvListBox::DrawItem (LPDRAWITEMSTRUCT lpDIS)
|
|
{
|
|
CPA_BaseObject *pObject;
|
|
COLORREF cTextColor;
|
|
COLORREF cRectColor;
|
|
CString csText;
|
|
CDC *pDC;
|
|
|
|
if (!m_pDialog)
|
|
return;
|
|
|
|
// init parameters
|
|
pObject = (CPA_BaseObject *) GetItemData(lpDIS->itemID);
|
|
|
|
// drawing rect
|
|
pDC = CDC::FromHandle(lpDIS->hDC);
|
|
|
|
|
|
// current element => red rectangle
|
|
if (fn_bIsCurrentElement(pObject))
|
|
{
|
|
// selected => full red rectangle
|
|
if (fn_bIsSelectedElement(pObject))
|
|
{
|
|
cRectColor = RGB (200, 0, 0);
|
|
cTextColor = RGB (254, 254, 254);
|
|
}
|
|
// not selected => violet rectangle
|
|
else
|
|
{
|
|
cRectColor = RGB (200, 100, 100);
|
|
cTextColor = RGB (100, 0, 0);
|
|
}
|
|
}
|
|
// element used => blue
|
|
else if (fn_bIsAlreadyUsed(pObject))
|
|
{
|
|
// selected => selected blue text
|
|
if (fn_bIsSelectedElement(pObject))
|
|
{
|
|
cRectColor = RGB (0, 0, 0);
|
|
cTextColor = RGB (254, 104, 54);
|
|
}
|
|
// not selected => blue text
|
|
else
|
|
{
|
|
cRectColor = RGB (254, 254, 254);
|
|
cTextColor = RGB (0, 50, 200);
|
|
}
|
|
}
|
|
// selected element => black rect
|
|
else if (fn_bIsSelectedElement(pObject))
|
|
{
|
|
cRectColor = RGB (0, 0, 0);
|
|
cTextColor = RGB (126, 254, 254);
|
|
}
|
|
// non available element => gray
|
|
else if (!pObject->fn_bIsAvailable())
|
|
{
|
|
cRectColor = RGB (254, 254, 254);
|
|
cTextColor = RGB (128, 128, 128);
|
|
}
|
|
// normal element => black
|
|
else
|
|
{
|
|
cRectColor = RGB (254, 254, 254);
|
|
cTextColor = RGB (128, 0, 0);
|
|
}
|
|
|
|
// draw item
|
|
pDC->FillSolidRect(&lpDIS->rcItem, cRectColor);
|
|
pDC->SetBkMode(TRANSPARENT);
|
|
lpDIS->rcItem.left += 2;
|
|
pDC->SetTextColor(cTextColor);
|
|
pDC->DrawText(pObject->GetNameToDraw(), &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER);
|
|
}
|
|
|
|
|
|
/----------------------------------------
|
|
----------------------------------------/
|
|
BOOL SECT_EnvListBox::fn_bIsCurrentElement (CPA_BaseObject *pElem)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
/----------------------------------------
|
|
----------------------------------------/
|
|
BOOL SECT_EnvListBox::fn_bIsSelectedElement (CPA_BaseObject *pElem)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
/----------------------------------------
|
|
----------------------------------------/
|
|
BOOL SECT_EnvListBox::fn_bIsAlreadyUsed (CPA_BaseObject *pElem)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
*/ |