3855 lines
131 KiB
C++
3855 lines
131 KiB
C++
/*=========================================================================
|
|
*
|
|
* SECTint.hpp : Sector DLL Interface - implementation
|
|
*
|
|
*
|
|
* Version 1.0
|
|
* Creation date
|
|
* Revision date
|
|
*
|
|
* Shaitan
|
|
*=======================================================================*/
|
|
|
|
#include <direct.h>
|
|
|
|
#include "stdafx.h"
|
|
#include "acp_base.h"
|
|
|
|
#include "SECTint.hpp"
|
|
|
|
#include "SECmodif.hpp"
|
|
|
|
#include "SECdSel.hpp"
|
|
#include "SECdEdit.hpp"
|
|
#include "SECdMode.hpp"
|
|
//Shaitan Clean Env
|
|
//#include "SECdEnv.hpp"
|
|
//#include "SECdMec.hpp"
|
|
//#include "SECdVis.hpp"
|
|
#include "SEClDias.hpp"
|
|
//Shaitan Clean Env
|
|
//#include "SEClEnvs.hpp"
|
|
//#include "SECdEnvs.hpp"
|
|
//#include "SECdSrfs.hpp"
|
|
#include "SECdDist.hpp"
|
|
|
|
#include "OGD.h"
|
|
|
|
#include "DPT.h"
|
|
//Shaitan Clean Env
|
|
/*
|
|
#define SRF_MAIN
|
|
#include "SRF.h"
|
|
#undef SRF_MAIN
|
|
*/
|
|
|
|
#include "..\Main\Inc\_EditID.h"
|
|
#include "TUT.h"
|
|
|
|
|
|
BOOL g_bCanSave = FALSE;
|
|
BOOL g_bFirstCall = TRUE;
|
|
|
|
//#################################################################################
|
|
// Defines
|
|
//#################################################################################
|
|
|
|
#define C_uiOpenID 1
|
|
#define C_uiCloseID 2
|
|
#define C_ui_SaveDialogsID 3
|
|
#define C_uiUpdateVirtuals 5
|
|
#define C_uiAutoAffect 6
|
|
|
|
#define C_uiDisplayBorders 100
|
|
|
|
// the Keyboard configuration
|
|
#define KA_ID_DELETEELEM 9
|
|
|
|
static tdstKeyboardActionDef g_SectorKeyboard[] =
|
|
{
|
|
{ "Delete Element In List", KA_ID_DELETEELEM },
|
|
{ NULL, 0 },
|
|
};
|
|
|
|
// infos
|
|
static CString g_csSECTName = "Sector";
|
|
static CString g_csSECTAuthor = "Chantal Oury";
|
|
static CString g_csSECTVersion = "V 6.0.4 18/03/98";
|
|
static CString g_csSECTFrenchHelpFile = "Secteur.hlp";
|
|
static CString g_csSECTEnglishHelpFile = "";
|
|
|
|
BOOL g_bTipFirstTime = TRUE;
|
|
|
|
// the DLL global definition
|
|
tdstDLLIdentity g_stSectorIdentity;
|
|
|
|
#define C_szSectorIniFile "Sector\\Sectors.ini"
|
|
|
|
|
|
//#################################################################################
|
|
// Constructor / Destructor
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Constructor
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
Sector_Interface::Sector_Interface(void)
|
|
{
|
|
// ************************** private internal
|
|
m_p_stDLLIdentity = &g_stSectorIdentity;
|
|
|
|
// Does your DLL can output in main game view ?
|
|
m_stBaseDLLDefinition.bCanOutputIn3DView = FALSE;
|
|
|
|
// Does your DLL can be refresh by engine ?
|
|
m_stBaseDLLDefinition.bCanBeRefreshedByEngine = TRUE;
|
|
|
|
// init infos
|
|
SetEditorInfo(g_csSECTName, g_csSECTAuthor, g_csSECTVersion, g_csSECTFrenchHelpFile, g_csSECTEnglishHelpFile);
|
|
// init parameters
|
|
SetCurrent(FALSE);
|
|
m_pEditedSector = NULL;
|
|
m_pSelectedSector = NULL;
|
|
// frames & dialog (Sector)
|
|
m_pSectorLeftFrame = NULL;
|
|
m_pSectorBottomFrame = NULL;
|
|
m_pSectorDialogList = NULL;
|
|
m_pSectorDialogEdit = NULL;
|
|
m_pSectorDialogMode = NULL;
|
|
m_pDialogSel = NULL;
|
|
m_pDialogGraph = NULL;
|
|
m_pDialogColls = NULL;
|
|
m_pDialogActiv = NULL;
|
|
m_pDialogSound = NULL;
|
|
m_pDialogSoundEvent = NULL;
|
|
//Shaitan Clean Env
|
|
/*
|
|
// frames & dialog (Env)
|
|
m_pEnvLeftFrame = NULL;
|
|
m_pEnvBottomFrame = NULL;
|
|
m_pEnvDialogList = NULL;
|
|
m_pEnvDialogEdit = NULL;
|
|
m_pEnvDialogMode = NULL;
|
|
m_pDialogEnvList = NULL;
|
|
m_pDialogEnv = NULL;
|
|
m_pDialogMec = NULL;
|
|
m_pDialogVis = NULL;
|
|
*/
|
|
// frames & dialog (Current)
|
|
m_pCurrentLeftFrame = NULL;
|
|
m_pCurrentBottomFrame = NULL;
|
|
m_pCurrentDialogList = NULL;
|
|
m_pCurrentDialogEdit = NULL;
|
|
m_pCurrentDialogMode = NULL;
|
|
// mode
|
|
m_eEditMode = E_em_EditSector;
|
|
for (int eList = 0; eList < C_NumberOfLists; eList++)
|
|
m_aListActivity[eList] = 0;
|
|
|
|
// sound
|
|
m_pSoundEventList = NULL;
|
|
//Shaitan Clean Env
|
|
// m_pSoundEnvList = NULL;
|
|
m_bAllInitialised = FALSE;
|
|
// surface
|
|
//Shaitan Clean Env
|
|
// m_pSurfaceToDraw = NULL;
|
|
// mode
|
|
m_bSymetricMode = FALSE;
|
|
// borders
|
|
m_bDisplayBorders = FALSE;
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Destructor
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
Sector_Interface::~Sector_Interface (void)
|
|
{
|
|
// keyboard
|
|
delete m_pKeyboard;
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// INITS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Inits for Scripts
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vJustAfterRegistered (void)
|
|
{
|
|
Sector_Object::StaticInit();
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Init Editor
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vConstruct()
|
|
{
|
|
CString csFileName;
|
|
|
|
CString types[] = { C_szSectorTypeName,
|
|
C_szEnvironmentTypeName,
|
|
C_szMecEnvironmentTypeName,
|
|
C_szVisEnvironmentTypeName,
|
|
C_szSurfaceTypeName,
|
|
};
|
|
|
|
fn_vRegisterObjectsType(types,5);
|
|
|
|
// Keys
|
|
m_pKeyboard = new CPA_KeyActionConfiguration(C_szSectorIniFile, g_SectorKeyboard);
|
|
m_pKeyboard->mfn_vSetObjectName("Sector Editor");
|
|
|
|
csFileName = M_GetMainApp()->m_csEditorDataPath + "Objects\\" + C_szSectorIniFile;
|
|
|
|
// icons for list
|
|
m_oStateIconList.Create(16, 16, ILC_MASK, 0, 4);
|
|
m_oStateIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(SECT_IDI_SECTOR)));
|
|
m_oStateIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(SECT_IDI_SECTOR)));
|
|
m_oStateIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(SECT_IDI_VIRTUAL)));
|
|
|
|
#ifndef __INACTIVE_INTERFACE__
|
|
|
|
// init all dialogs
|
|
fn_vCreateSectorDialogs(csFileName);
|
|
//Shaitan Clean Env
|
|
// fn_vCreateEnvironmentDialogs(csFileName);
|
|
// create modal dialog
|
|
HINSTANCE hOldInst = AfxGetResourceHandle();
|
|
AfxSetResourceHandle (GetDLLIdentity()->hModule);
|
|
|
|
m_pDialogDistance = new SECT_DialogDistance();
|
|
m_pDialogDistance->fn_vInitSectorInterface(this);
|
|
|
|
AfxSetResourceHandle(hOldInst);
|
|
|
|
// Modes
|
|
SetEditMode(E_em_EditSector, FALSE);
|
|
m_csSaveSelectMode = "";
|
|
|
|
// current state
|
|
m_pCurrentDialogList = m_pSectorDialogList;
|
|
m_pCurrentDialogEdit = m_pSectorDialogEdit;
|
|
m_pCurrentDialogMode = m_pSectorDialogMode;
|
|
|
|
m_pCurrentLeftFrame = m_pSectorLeftFrame;
|
|
m_pCurrentBottomFrame = m_pSectorBottomFrame;
|
|
|
|
// visual
|
|
//Shaitan Clean Env
|
|
// m_pCurrentVisual = NULL;
|
|
|
|
#endif // __INACTIVE_INTERFACE__
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Init lists for hierarchy editor
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vInitListByType (CPA_World *pWorld)
|
|
{
|
|
pWorld->fn_vAddANewListByType (C_szSectorTypeName, this);
|
|
pWorld->fn_vAddANewListByType (C_szSurfaceTypeName, this);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Create Dialogs for Sector & List Modes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vCreateSectorDialogs (CString csFileName)
|
|
{
|
|
char szDimension[256];
|
|
int iDim;
|
|
|
|
// left frame width
|
|
GetPrivateProfileString ("Preference", "Sector Left Frame Width", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Left Frame Window
|
|
m_pSectorLeftFrame = new CSplitFrame;
|
|
m_pSectorLeftFrame->CreateBase("LIST", 1, 2, GetMainWorld());
|
|
m_pSectorLeftFrame->m_iInitWidth = (iDim > 0) ? iDim : 180;
|
|
m_pSectorLeftFrame->mfn_vEnableCaption(FALSE);
|
|
m_pSectorLeftFrame->m_stWinBottom.cLinkSame = FRM_C_MoveRight;
|
|
m_pSectorLeftFrame->CreateSplitter(C_cVerticalSplitter, 4);
|
|
|
|
|
|
// DialogList Dimension
|
|
GetPrivateProfileString ("Preference", "Sector DialogList Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Dialog List
|
|
m_pSectorDialogList = new CPA_DialogList;
|
|
m_pSectorDialogList->fn_vInitDialog(this, m_pSectorLeftFrame);
|
|
// FOR TUTORIAL
|
|
TUT_M_vGetTutDll();
|
|
|
|
TUT_M_vRegisterControl (m_pSectorDialogList->GetComboHandle(), "OSC_DLSECT_COMBO_CHOICE", TUT_e_ComboBox);
|
|
TUT_M_vRegisterControl (m_pSectorDialogList->GetListHandle(), "OSC_DLSECT_LIST_SECTORS", TUT_e_ListBox);
|
|
TUT_M_vRegisterControl (m_pSectorDialogList->GetTreeHandle(), "OSC_DLSECT_TREE_SECTORS", TUT_e_TreeCtrl);
|
|
// END TUTORIAL
|
|
m_pSectorLeftFrame->SetPaneView(0, m_pSectorDialogList, "SECTORS", (iDim > 0) ? iDim : 240);
|
|
|
|
// resources
|
|
HINSTANCE hOldInst = AfxGetResourceHandle();
|
|
AfxSetResourceHandle (GetDLLIdentity()->hModule);
|
|
|
|
// SelectMode Dimension
|
|
GetPrivateProfileString ("Preference", "Sector SelectMode Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Select Mode
|
|
m_pSectorDialogMode = new SECT_DialogMode;
|
|
m_pSectorDialogMode->fn_vInitDialog(this, m_pSectorLeftFrame, TRUE, "SECT");
|
|
m_pSectorLeftFrame->SetPaneView(1, m_pSectorDialogMode, "SELECT MODE", (iDim > 0) ? iDim : 60);
|
|
|
|
// EditedSector Dimension
|
|
GetPrivateProfileString ("Preference", "Sector EditedSector Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Edited Sector
|
|
m_pSectorDialogEdit = new SECT_DialogEdit;
|
|
m_pSectorDialogEdit->fn_vInitDialog(this, m_pSectorLeftFrame, "SECT");
|
|
m_pSectorLeftFrame->SetPaneView(2, m_pSectorDialogEdit, "EDITED SECTOR", (iDim > 0) ? iDim : 180);
|
|
|
|
// SelectedSector Dimension
|
|
GetPrivateProfileString ("Preference", "SelectedSector Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Sector Dialog
|
|
m_pDialogSel = new SECT_DialogSel;
|
|
m_pDialogSel->fn_vInitDialog(this, m_pSectorLeftFrame);
|
|
m_pSectorLeftFrame->SetPaneView(3, m_pDialogSel, "SELECTED SECTOR", (iDim > 0) ? iDim : 100);
|
|
|
|
// Bottom Frame Dimension
|
|
GetPrivateProfileString ("Preference", "Sector Bottom Frame Height", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Bottom Frame Window
|
|
m_pSectorBottomFrame = new CSplitFrame;
|
|
m_pSectorBottomFrame->CreateBase("LIST", 2, 3, GetMainWorld());
|
|
m_pSectorBottomFrame->m_iInitHeight = (iDim > 0) ? iDim : 120;
|
|
m_pSectorBottomFrame->mfn_vEnableCaption(FALSE);
|
|
m_pSectorBottomFrame->CreateSplitter(C_cHorizontalSplitter, 5);
|
|
|
|
// GraphicList Dimension
|
|
GetPrivateProfileString ("Preference", "GraphicList Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Graphic List
|
|
m_pDialogGraph = new SECT_DialogGraph;
|
|
m_pDialogGraph->fn_vInitDialog(this, m_pSectorBottomFrame, "GRAPHIC");
|
|
m_pSectorBottomFrame->SetPaneView(0, m_pDialogGraph, "GRAPHIC", (iDim > 0) ? iDim : 0);
|
|
|
|
// CollisionList Dimension
|
|
GetPrivateProfileString ("Preference", "CollisionList Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Collision List
|
|
m_pDialogColls = new SECT_DialogColls;
|
|
m_pDialogColls->fn_vInitDialog(this, m_pSectorBottomFrame, "COLLISION");
|
|
m_pSectorBottomFrame->SetPaneView(1, m_pDialogColls, "COLLISION", (iDim > 0) ? iDim : 0);
|
|
|
|
// ActivityList Dimension
|
|
GetPrivateProfileString ("Preference", "ActivityList Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Activity List
|
|
m_pDialogActiv = new SECT_DialogActiv;
|
|
m_pDialogActiv->fn_vInitDialog(this, m_pSectorBottomFrame, "ACTIVITY");
|
|
m_pSectorBottomFrame->SetPaneView(2, m_pDialogActiv, "ACTIVITY", (iDim > 0) ? iDim : 0);
|
|
|
|
// SoundList Dimension
|
|
GetPrivateProfileString ("Preference", "SoundList Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Sound List
|
|
m_pDialogSound = new SECT_DialogSound;
|
|
m_pDialogSound->fn_vInitDialog(this, m_pSectorBottomFrame, "SOUND");
|
|
m_pSectorBottomFrame->SetPaneView(3, m_pDialogSound, "SOUND", (iDim > 0) ? iDim : 0);
|
|
|
|
// SoundEvent Dimension
|
|
GetPrivateProfileString ("Preference", "SoundEvent Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Sound List
|
|
m_pDialogSoundEvent = new SECT_DialogSoundEvent;
|
|
m_pDialogSoundEvent->fn_vInitDialog(this, m_pSectorBottomFrame, "SOUND EVENT", TRUE);
|
|
m_pSectorBottomFrame->SetPaneView(4, m_pDialogSoundEvent, "SOUND EVENT", (iDim > 0) ? iDim : 100);
|
|
|
|
// resources
|
|
AfxSetResourceHandle(hOldInst);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Create Dialogs for Environment Modes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::fn_vCreateEnvironmentDialogs (CString csFileName)
|
|
{
|
|
char szDimension[256];
|
|
int iDim;
|
|
|
|
// left frame width
|
|
GetPrivateProfileString ("Preference", "Env Left Frame Width", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Left Frame Window
|
|
m_pEnvLeftFrame = new CSplitFrame;
|
|
m_pEnvLeftFrame->CreateBase("LIST", 1, 2, GetMainWorld());
|
|
m_pEnvLeftFrame->m_iInitWidth = (iDim > 0) ? iDim : 180;
|
|
m_pEnvLeftFrame->mfn_vEnableCaption(FALSE);
|
|
m_pEnvLeftFrame->m_stWinBottom.cLinkSame = FRM_C_MoveRight;
|
|
m_pEnvLeftFrame->CreateSplitter(C_cVerticalSplitter, 4);
|
|
|
|
|
|
// DialogList Dimension
|
|
GetPrivateProfileString ("Preference", "Env DialogList Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Dialog List
|
|
m_pEnvDialogList = new CPA_DialogList;
|
|
m_pEnvDialogList->fn_vInitDialog(this, m_pEnvLeftFrame);
|
|
// FOR TUTORIAL
|
|
TUT_M_vGetTutDll();
|
|
|
|
TUT_M_vRegisterControl (m_pEnvDialogList->GetComboHandle(), "OSC_DLENV_COMBO_CHOICE", TUT_e_ComboBox);
|
|
TUT_M_vRegisterControl (m_pEnvDialogList->GetListHandle(), "OSC_DLENV_LIST_SECTORS", TUT_e_ListBox);
|
|
TUT_M_vRegisterControl (m_pEnvDialogList->GetTreeHandle(), "OSC_DLENV_TREE_SECTORS", TUT_e_TreeCtrl);
|
|
// END TUTORIAL
|
|
m_pEnvLeftFrame->SetPaneView(0, m_pEnvDialogList, "SECTORS", (iDim > 0) ? iDim : 240);
|
|
|
|
// resource
|
|
HINSTANCE hOldInst = AfxGetResourceHandle();
|
|
AfxSetResourceHandle (GetDLLIdentity()->hModule);
|
|
|
|
// SelectMode Dimension
|
|
GetPrivateProfileString ("Preference", "Env SelectMode Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Select Mode
|
|
m_pEnvDialogMode = new SECT_DialogMode;
|
|
m_pEnvDialogMode->fn_vInitDialog(this, m_pEnvLeftFrame, FALSE, "ENV");
|
|
m_pEnvLeftFrame->SetPaneView(1, m_pEnvDialogMode, "SELECT MODE", (iDim > 0) ? iDim : 60);
|
|
|
|
// EditedSector Dimension
|
|
GetPrivateProfileString ("Preference", "Env EditedSector Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Edited Sector
|
|
m_pEnvDialogEdit = new SECT_DialogEdit;
|
|
m_pEnvDialogEdit->fn_vInitDialog(this, m_pEnvLeftFrame, "ENV");
|
|
m_pEnvLeftFrame->SetPaneView(2, m_pEnvDialogEdit, "EDITED SECTOR", (iDim > 0) ? iDim : 180);
|
|
|
|
// EnvironmentList Dimension
|
|
GetPrivateProfileString ("Preference", "EnvironmentList Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Edited Sector
|
|
m_pDialogEnvList = new SECT_DialogEnvList;
|
|
m_pDialogEnvList->fn_vInitDialog(this, m_pEnvLeftFrame);
|
|
m_pEnvLeftFrame->SetPaneView(3, m_pDialogEnvList, "ENVIRONMENT LIST", (iDim > 0) ? iDim : 180);
|
|
|
|
|
|
// Bottom Frame Dimension
|
|
GetPrivateProfileString ("Preference", "Env Bottom Frame Height", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Bottom Frame Window
|
|
m_pEnvBottomFrame = new CSplitFrame;
|
|
m_pEnvBottomFrame->CreateBase("LIST", 2, 3, GetMainWorld());
|
|
m_pEnvBottomFrame->m_iInitHeight = (iDim > 0) ? iDim : 200;
|
|
m_pEnvBottomFrame->mfn_vEnableCaption(FALSE);
|
|
m_pEnvBottomFrame->CreateSplitter(C_cHorizontalSplitter, 5);
|
|
|
|
// Surfaces Dimension
|
|
GetPrivateProfileString ("Preference", "Surfaces Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Surfaces
|
|
m_pDialogSrf = new SECT_DialogSrf;
|
|
m_pDialogSrf->fn_vInitDialog(this, m_pEnvBottomFrame);
|
|
m_pEnvBottomFrame->SetPaneView(0, m_pDialogSrf, "ENVIRONMENT ELEMENT", (iDim > 0) ? iDim : 180);
|
|
|
|
// Environments Dimension
|
|
GetPrivateProfileString ("Preference", "Environments Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Environments
|
|
m_pDialogEnvs = new SECT_DialogEnvs;
|
|
m_pDialogEnvs->fn_vInitDialog(this, m_pEnvBottomFrame);
|
|
m_pEnvBottomFrame->SetPaneView(1, m_pDialogEnvs, "ENVIRONMENT ELEMENT", (iDim > 0) ? iDim : 180);
|
|
|
|
// Environment Dimension
|
|
GetPrivateProfileString ("Preference", "Environment Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Environment
|
|
m_pDialogEnv = new SECT_DialogEnv;
|
|
m_pDialogEnv->fn_vInitDialog(this, m_pEnvBottomFrame);
|
|
m_pEnvBottomFrame->SetPaneView(2, m_pDialogEnv, "ENVIRONMENT", (iDim > 0) ? iDim : 180);
|
|
|
|
// Environment Dimension
|
|
GetPrivateProfileString ("Preference", "MecEnvironment Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// mec Environment
|
|
m_pDialogMec = new SECT_DialogMec;
|
|
m_pDialogMec->fn_vInitDialog(this, m_pEnvBottomFrame);
|
|
m_pEnvBottomFrame->SetPaneView(3, m_pDialogMec, "MECHANIC", (iDim > 0) ? iDim : 180);
|
|
|
|
// Visual Dimension
|
|
GetPrivateProfileString ("Preference", "VisEnvironment Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Visual Environment
|
|
m_pDialogVis = new SECT_DialogVis;
|
|
m_pDialogVis->fn_vInitDialog(this, m_pEnvBottomFrame);
|
|
m_pEnvBottomFrame->SetPaneView(4, m_pDialogVis, "VISUAL", 60);
|
|
|
|
// resource
|
|
AfxSetResourceHandle(hOldInst);
|
|
}
|
|
*/
|
|
|
|
//#################################################################################
|
|
// EDITOR - ENGINE
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Inits for Engine Loop
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vBeforeEngine (void)
|
|
{
|
|
// current editor
|
|
if (fn_bIsCurrentEditor())
|
|
{
|
|
// disactivate dialogs
|
|
g_oFrameGest.mfn_vDisactivateWindow(m_pCurrentLeftFrame);
|
|
g_oFrameGest.mfn_vDisactivateWindow(m_pCurrentBottomFrame);
|
|
// RAZ display
|
|
fn_vSetRecursiveColor(M_GetWorld()->GetRoot(), C_NoColor);
|
|
// update list of surfaces
|
|
//Shaitan Clean Env
|
|
// fn_vUpdateSurfaceList();
|
|
}
|
|
// update borders
|
|
if (m_bDisplayBorders)
|
|
{
|
|
fn_vDisplayBorders(FALSE);
|
|
m_bDisplayBorders = TRUE;
|
|
}
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Inits for Editor Mode
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vBeforeEditor (void)
|
|
{
|
|
// update borders
|
|
if (m_bDisplayBorders)
|
|
{
|
|
m_bDisplayBorders = FALSE;
|
|
fn_vDisplayBorders(TRUE);
|
|
}
|
|
// current editor
|
|
if (fn_bIsCurrentEditor())
|
|
{
|
|
// reinit dialogs
|
|
g_oFrameGest.mfn_vActivateWindow(m_pCurrentBottomFrame);
|
|
g_oFrameGest.mfn_vActivateWindow(m_pCurrentLeftFrame);
|
|
// reinit selection
|
|
fn_vReinitEditor(m_pEditedSector);
|
|
//Shaitan Clean Env
|
|
/*
|
|
// surfaces
|
|
fn_vUpdateSurfaceList(FALSE);
|
|
if (m_pCurrentVisual)
|
|
fn_vSetRecursiveColor(m_pCurrentVisual, C_ColorSurf);
|
|
*/
|
|
}
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Inits for New Level
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vLevelChanges (void)
|
|
{
|
|
CString csLevel;
|
|
CString csEnvs;
|
|
|
|
// first init
|
|
if (!m_bAllInitialised)
|
|
{
|
|
// Reference Path
|
|
csLevel = fn_szGetLevelsDataPath();
|
|
m_csSECTRefPath= csLevel + "\\";
|
|
//Shaitan Clean Env
|
|
/*
|
|
m_csSURFRefPath = csLevel + "\\";
|
|
csEnvs = fn_szGetEnvironmentDataPath();
|
|
m_csENVRefPath = csEnvs + "\\";
|
|
m_csMECRefPath = csEnvs + "\\";
|
|
m_csVISRefPath = csEnvs + "\\";
|
|
*/
|
|
// reinit sounds
|
|
m_pSoundEventList = GetMainWorld()->fn_p_oGetOriginalObjectList(C_szSoundEventTypeName);
|
|
//Shaitan Clean Env
|
|
// m_pSoundEnvList = GetMainWorld()->fn_p_oGetOriginalObjectList(C_szSoundInfoEnvironmentTypeName);
|
|
// temp => for save
|
|
g_bCanSave = ((m_pSoundEventList != NULL)/*&&(m_pSoundEnvList != NULL)*/);
|
|
//Shaitan Clean Env
|
|
/*
|
|
// Files
|
|
fn_vInitEnvironmentFiles();
|
|
// reinit envs
|
|
// M_GetMainWnd()->UpdateStatus("Loading Environments and Surfaces", C_STATUSPANE_INFOS, C_STATUS_NORMAL);
|
|
fn_vLoadMecEnvironments();
|
|
fn_vLoadVisEnvironments();
|
|
g_oBaseFrame.mfnv_UpdateTitle("Load Environments");
|
|
fn_vLoadEnvironments();
|
|
// M_GetMainWnd()->UpdateStatus("Load Environments >>> 100% Completed", C_STATUSPANE_INFOS, C_STATUS_NORMAL);
|
|
g_oBaseFrame.mfnv_UpdateTitle("Load Surfaces");
|
|
fn_vLoadSurfaces();
|
|
// M_GetMainWnd()->UpdateStatus("Load Surfaces >>> 100% Completed", C_STATUSPANE_INFOS, C_STATUS_NORMAL);
|
|
*/
|
|
}
|
|
// copy /paste
|
|
m_oCopyOfSectorList.RemoveAll();
|
|
// update flag
|
|
m_bAllInitialised = TRUE;
|
|
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Update for New Level
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vLevelHasChanged (void)
|
|
{
|
|
CPA_BaseObjectList *pListObject;
|
|
CPA_SuperObject *pSectorSObj;
|
|
CPA_SuperObject *pSectorChild;
|
|
CPA_BaseObject *pElem;
|
|
Sector_Object *pSector;
|
|
Position pos;
|
|
|
|
// init sector lists
|
|
m_pSectorDialogList->fn_vInitAllLists();
|
|
//Shaitan Clean Env
|
|
// m_pEnvDialogList->fn_vInitAllLists();
|
|
// get sector list
|
|
pListObject = GetBaseObjectList(C_szSectorTypeName);
|
|
// update each sector
|
|
for (pElem = pListObject->GetHeadElement(pos); pElem;
|
|
pElem = pListObject->GetNextElement(pos))
|
|
{
|
|
pSector = (Sector_Object *) pElem;
|
|
pSector->fn_vInitSortedLists();
|
|
//Shaitan Clean Env
|
|
// pSector->fn_vInitEnvironments();
|
|
// pSector->fn_vInitSurfaces();
|
|
pSector->fn_vInitBorder();
|
|
|
|
// protect all direct childs of the sector
|
|
pSectorSObj = pSector->GetSuperObject();
|
|
// first level of sectors => IPOs are protected childs
|
|
for (pSectorChild = pSectorSObj->GetSuperObjectFirstChild(); pSectorChild;
|
|
pSectorChild = pSectorSObj->GetSuperObjectNextChild(pSectorChild))
|
|
{
|
|
if (pSectorChild->GetRealTypeName() == C_szInstanciatedPhysicalObjectTypeName)
|
|
{
|
|
pSectorChild->SetEditProtected(TRUE);
|
|
pSectorChild->SetSuperObjectOwner(pSectorSObj);
|
|
}
|
|
}
|
|
}
|
|
//Shaitan Clean Env
|
|
// fn_vUpdateSurfaceList();
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// HIERARCHY FUNCTIONS OVERLOADED
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Engine Type
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bCanHandleThisType (long lEngineType)
|
|
{
|
|
return (lEngineType == HIE_C_ulSector);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Load editor sector from engine and link tables
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vBuildNewEditorInstance (CPA_SuperObject *pEditorInstance, HIE_tdxHandleToSuperObject hEngineInstance)
|
|
{
|
|
SECT_tdxHandleOfSectorObject hEngineObject;
|
|
SCR_tdst_Link_Value *pLinkValue;
|
|
Sector_Object *pEdObj;
|
|
CString csSectionName, csFileName;
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
int iPos;
|
|
|
|
hEngineObject = (SECT_tdxHandleOfSectorObject) HIE_fn_hGetSuperObjectObject(hEngineInstance);
|
|
// search link table for engine struct
|
|
pLinkValue = SCR_fnp_st_Link_SearchValue(SECT_fn_pGetLinkTable(), (unsigned long) hEngineObject);
|
|
if ((pLinkValue)&&(SCR_M_e_Link_GetState(pLinkValue) == SCR_ELS_Link_Initialized))
|
|
csSectionName = SCR_M_p_sz_Link_GetKey(pLinkValue);
|
|
// get parameters
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
csSectionName = szFileName;
|
|
// compute minimal file name
|
|
iPos = csSectionName.Find(m_csSECTRefPath);
|
|
if (iPos != -1)
|
|
csFileName = csSectionName.Mid(m_csSECTRefPath.GetLength());
|
|
// create object
|
|
pEdObj = new Sector_Object(this, hEngineObject, szName, csFileName);
|
|
pEdObj->SetSuperObject(pEditorInstance);
|
|
// set object in pEdObj
|
|
pEditorInstance->SetObject(pEdObj);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Update instance
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vUpdateEditorInstance (CPA_SuperObject *pEditorInstance, HIE_tdxHandleToSuperObject pEngineInstance)
|
|
{
|
|
Sector_Object *pSector;
|
|
if (pEditorInstance->GetObjectDLL() != this)
|
|
return;
|
|
// init all lists
|
|
pSector = (Sector_Object *) pEditorInstance->GetObject();
|
|
}
|
|
|
|
|
|
|
|
//#################################################################################
|
|
// EDITOR FUNCTIONS OVERLOADED
|
|
//#################################################################################
|
|
|
|
//**************************************************************************************
|
|
//Begin Mircea Dunka 3 Sept 1998 - DialogBar interface
|
|
void Sector_Interface::fn_vDefineDlgBarBtnIcon (tde_DlgBarCategory wCategory, tds_DlgBarBtn *_pDlgBarBtn)
|
|
{
|
|
if(wCategory == C_DlgBarCategoryEditor)
|
|
{
|
|
_pDlgBarBtn->hIcon = ::LoadIcon((HINSTANCE)(GetDLLIdentity()->hModule), MAKEINTRESOURCE(IDI_OSC_DLGBAR_ICON));
|
|
CString oCst;
|
|
oCst = "Sector";
|
|
if( (M_GetMainApp()) && (M_GetMainApp()->mp_oAppKeyboard) )
|
|
{
|
|
oCst += " (";
|
|
oCst += M_GetMainApp()->mp_oAppKeyboard->mfn_oConvertIniStringToKeyString((const CString*)&CString("Activate Sector Editor"));
|
|
oCst += ")";
|
|
}
|
|
strcpy(_pDlgBarBtn->szToolTip, (char*)(LPCTSTR)oCst);
|
|
_pDlgBarBtn->uID = (UINT)this;
|
|
}
|
|
}
|
|
//end Mircea Dunka 3 Sept 1998
|
|
|
|
/*===========================================================================
|
|
* Description: Add entries in submenus
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bDefineSubMenu(EDT_SubMenu *p_oEDTSubMenu)
|
|
{
|
|
CString csEntry;
|
|
|
|
// submenu "Editor"
|
|
if (p_oEDTSubMenu->GetSubMenuType() == C_SubMenuEditor)
|
|
{
|
|
csEntry = "Sector";
|
|
csEntry += "\t";
|
|
csEntry += M_GetMainApp()->mp_oAppKeyboard->mfn_oConvertIniStringToKeyString((const CString*)&CString("Activate Sector Editor"));;
|
|
|
|
if (!fn_bIsCurrentEditor())
|
|
p_oEDTSubMenu->AddAnEntry(this, (char*)(LPCTSTR)csEntry, C_uiOpenID, FALSE);
|
|
else
|
|
p_oEDTSubMenu->AddAnEntry(this, (char*)(LPCTSTR)csEntry, C_uiCloseID, TRUE);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// submenu "3DView"
|
|
if (p_oEDTSubMenu->GetSubMenuType() == C_SubMenu3DView)
|
|
{
|
|
if (g_bFirstCall)
|
|
g_bFirstCall = FALSE;
|
|
else
|
|
{
|
|
csEntry = m_bDisplayBorders ? "Hide Borders" : "Display Borders";
|
|
csEntry += "\t";
|
|
csEntry += M_GetMainApp()->mp_oDevKeyboard->mfn_oConvertIniStringToKeyString((const CString*)&CString("Show Borders"));;
|
|
|
|
p_oEDTSubMenu->AddAnEntry(this, (char*)(LPCTSTR)csEntry, C_uiDisplayBorders, FALSE);
|
|
g_bFirstCall = TRUE;
|
|
}
|
|
return g_bFirstCall;
|
|
}
|
|
|
|
// submenu "Preference"
|
|
else if (p_oEDTSubMenu->GetSubMenuType() == C_SubMenuPreference)
|
|
{
|
|
// preferences
|
|
p_oEDTSubMenu->AddAnEntry(this, "Save Dialogs Dimensions", C_ui_SaveDialogsID, FALSE, TRUE);
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Answer to submenu commands
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::_OnSubMenuCommand(EDT_SubMenu *p_oEDTSubMenu,UINT uiMsgID)
|
|
{
|
|
switch (uiMsgID)
|
|
{
|
|
case C_uiOpenID:
|
|
if (!fn_bIsCurrentEditor())
|
|
GetMainWorld()->fn_bActivateEditor(this, NULL);
|
|
break;
|
|
|
|
case C_uiCloseID:
|
|
if (fn_bIsCurrentEditor())
|
|
GetMainWorld()->fn_bCloseEditor(this);
|
|
break;
|
|
|
|
// preference => dialogs
|
|
case C_ui_SaveDialogsID:
|
|
fn_vSaveDialogsPreferences();
|
|
break;
|
|
|
|
case C_uiDisplayBorders:
|
|
fn_vDisplayBorders(!m_bDisplayBorders);
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Add entries in popup menu
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bDefinePopupMenu (EDT_PopUpMenu *pPopup, CPA_List<CPA_SuperObject> *pSelection, BOOL bAsCurrentEditor)
|
|
{
|
|
if (bAsCurrentEditor)
|
|
{
|
|
pPopup->AddAnEntry(this, "Exit Sector editor", C_uiCloseID, FALSE);
|
|
|
|
pPopup->AddAnEntry(this, "Update all Virtuals", C_uiUpdateVirtuals);
|
|
if ((m_pEditedSector) &&
|
|
((Sector_Object *) m_pEditedSector->GetObject())->GetBorder() &&
|
|
(m_eEditMode == E_em_EditList) &&
|
|
(GetFirstActiveList() != E_NoActiveList))
|
|
pPopup->AddAnEntry(this, "Link Nearest Sectors", C_uiAutoAffect);
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Answer to popup menu commands
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::_OnPopUpMenuCommand (UINT m_IDCmdMsg)
|
|
{
|
|
switch (m_IDCmdMsg)
|
|
{
|
|
case C_uiCloseID:
|
|
if (fn_bIsCurrentEditor())
|
|
GetMainWorld()->fn_bCloseEditor(this);
|
|
break;
|
|
|
|
case C_uiUpdateVirtuals:
|
|
fn_vUpdateAllVirtuals();
|
|
break;
|
|
|
|
case C_uiAutoAffect:
|
|
fn_vLinkNearestSectors();
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Activate editor
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bCanActivateEditor (CPA_List<CPA_BaseObject> *pParams)
|
|
{
|
|
#ifdef __INACTIVE_INTERFACE__
|
|
return FALSE;
|
|
#endif
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Activate editor
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vOnActivateEditor (CPA_List<CPA_BaseObject> *pParam, BOOL bBackActivated)
|
|
{
|
|
CPA_SuperObject *pSector;
|
|
|
|
// saves
|
|
if (!g_bCanSave)
|
|
{
|
|
M_GetMainWnd()->UpdateStatus("No Sound DLL : your changes in this editor will not be saved", C_STATUSPANE_INFOS, C_STATUS_WARNING);
|
|
MessageBox (AfxGetMainWnd()->m_hWnd, "There is no Sound DLL : \nyour changes in Sector Editor will not be saved", "WARNING !", MB_OK|MB_ICONEXCLAMATION);
|
|
}
|
|
|
|
// inits for sound
|
|
fn_vReinitSoundParameters();
|
|
m_pDialogSel->fn_vInitSoundEventList();
|
|
|
|
// Get sector from param
|
|
pSector = GetSectorToEdit(pParam);
|
|
// reinit editor according to activation parameters
|
|
if ((!pSector)&&(!m_pEditedSector))
|
|
{
|
|
SetEditMode(E_em_EditSector, FALSE);
|
|
SetCurrentFrame(E_em_EditSector);
|
|
}
|
|
// reinit dialog list
|
|
m_pSectorDialogList->fn_vReinitDialog();
|
|
//Shaitan Clean Env
|
|
/*
|
|
m_pEnvDialogList->fn_vReinitDialog();
|
|
// reinit env dialogs
|
|
m_pDialogEnvs->fn_vReinitDialog();
|
|
m_pDialogSrf->fn_vReinitDialog();
|
|
m_pDialogEnv->fn_vReinitDialog();
|
|
m_pDialogMec->fn_vReinitDialog();
|
|
m_pDialogVis->fn_vReinitDialog();
|
|
*/
|
|
fn_vReinitEditor((pSector) ? pSector : m_pEditedSector);
|
|
// activate windows
|
|
g_oFrameGest.mfn_vActivateWindow(m_pCurrentLeftFrame);
|
|
g_oFrameGest.mfn_vActivateWindow(m_pCurrentBottomFrame);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Close editor
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vOnCloseEditor (void)
|
|
{
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Gain focus
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bHasGainedFocus (void)
|
|
{
|
|
// select mode
|
|
m_csSaveSelectMode = GetInterface()->GetSelectMode();
|
|
m_bPreviousState = GetInterface()->GetComboSelectMode()->IsWindowEnabled();
|
|
m_bPreviousLinkMode = GetInterface()->GetLinkMode();
|
|
|
|
// reinit
|
|
//Shaitan Clean Env
|
|
// fn_vUpdateSurfaceList(FALSE);
|
|
fn_vReinitEditor(m_pEditedSector);
|
|
fn_vUpdateEditMode();
|
|
|
|
// display Tip of the Day
|
|
GetInterface()->fn_vDisplayTipOfDay("Sectors", "OSC", g_bTipFirstTime);
|
|
g_bTipFirstTime = FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Loose focus
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vHasLostFocus (void)
|
|
{
|
|
CPA_List<CPA_SuperObject> *pListSelect;
|
|
CPA_SuperObject *pNextElem;
|
|
CPA_SuperObject *pElem;
|
|
|
|
// update list of surfaces
|
|
//Shaitan Clean Env
|
|
// fn_vUpdateSurfaceList();
|
|
// sector mode
|
|
fn_vSetRecursiveColor(M_GetWorld()->GetRoot(), C_NoColor);
|
|
// unselect all sectors
|
|
pListSelect = GetInterface()->GetSelectedObjects(this);
|
|
pElem = pListSelect->GetHeadElement();
|
|
while (pElem)
|
|
{
|
|
pNextElem = pListSelect->GetNextElement(pElem);
|
|
GetInterface()->fn_vRemoveSelectedObject(pElem);
|
|
fn_vSetRecursiveColor(pElem, C_NoColor);
|
|
pElem = pNextElem;
|
|
}
|
|
// redraw world & dialogs
|
|
fn_vUpdateEditMode(TRUE);
|
|
GLI_vSetWaterplaneOff();
|
|
GetInterface()->GetSpecificInterface()->fn_vUpdateSurfaces(FALSE);
|
|
//Shaitan Clean Env
|
|
// GetInterface()->fn_vReinitWaterEffect();
|
|
// GetInterface()->fn_vEnableWaterEffect(GetInterface()->fn_bWaterEffectEnabled());
|
|
GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// PERMISSIONS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Selection => only sectors
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
tdeTypeAnswer Sector_Interface::fn_bAcceptSelect (CPA_SuperObject *pEdObj, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking, tdeStatus eStatus)
|
|
{
|
|
tdeTypeAnswer eAnswer = C_Refuse;
|
|
|
|
// default handling => no selection as concerned DLL or child owner
|
|
if (!fn_bIsCurrentEditor())
|
|
{
|
|
// current editor
|
|
if (pEdObj->GetObjectDLL() == this)
|
|
return C_Refuse;
|
|
else
|
|
return C_Accept;
|
|
}
|
|
|
|
// current editor
|
|
if (pEdObj->GetObjectDLL() == this)
|
|
return C_Accept;
|
|
else
|
|
return C_Refuse;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Changes in hierarchy
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
|
|
BOOL Sector_Interface::fn_bAcceptModifDelete (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)
|
|
{
|
|
CPA_SuperObject *pSupObj;
|
|
CPA_SuperObject *pOwner;
|
|
Sector_Object *pSector;
|
|
POSITION pos;
|
|
|
|
if (eStatus == C_AsChildOwner)
|
|
{
|
|
for (pSupObj = pListObjects->GetHeadElement(pos); pSupObj;
|
|
pSupObj = pListObjects->GetNextElement(pos))
|
|
{
|
|
pOwner = pSupObj->GetSuperObjectOwner();
|
|
// accept only the border as direct child
|
|
pSector = (Sector_Object *) pOwner->GetObject();
|
|
if (pSupObj == pSector->GetBorder())
|
|
return TRUE;
|
|
}
|
|
}
|
|
|
|
return fn_bAcceptModifHierarchy(eStatus);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::fn_bAcceptModifParent (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)
|
|
{
|
|
return fn_bAcceptModifHierarchy(eStatus);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::fn_bAcceptModifCopy (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)
|
|
{
|
|
return fn_bAcceptModifHierarchy(eStatus);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::fn_bAcceptModifTranslate (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)
|
|
{
|
|
return fn_bAcceptModifHierarchy(eStatus);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::fn_bAcceptModifRotate (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)
|
|
{
|
|
return fn_bAcceptModifHierarchy(eStatus);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::fn_bAcceptModifScale (CPA_SuperObject *pEdObj, tdeStatus eStatus)
|
|
{
|
|
return fn_bAcceptModifHierarchy(eStatus);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::fn_bAcceptModifInsert (CPA_SuperObject *pEdObj, CPA_SuperObject *pParent, tdeStatus eStatus)
|
|
{
|
|
CPA_SuperObject *pOwner;
|
|
Sector_Object *pSector;
|
|
|
|
if (eStatus == C_AsChildOwner)
|
|
{
|
|
pOwner = pEdObj->GetSuperObjectOwner();
|
|
// accept only the border as direct child
|
|
pSector = (Sector_Object *) pOwner->GetObject();
|
|
if (pEdObj == pSector->GetBorder())
|
|
return TRUE;
|
|
}
|
|
|
|
return fn_bAcceptModifHierarchy(eStatus);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::fn_bAcceptAsParent (CPA_BaseObject *pChild, CPA_BaseObject *pParent)
|
|
{
|
|
// sectors cannot be inserted
|
|
return FALSE;
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::fn_bAcceptAsChild (CPA_BaseObject *pParent, CPA_BaseObject *pChild)
|
|
{
|
|
// insertion must be valid
|
|
if (!pParent || !pChild)
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
//#################################################################################
|
|
// MODIFS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Selection
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vOnSelect (CPA_SuperObject *pEdObj, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Changes in Hierarchy
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
|
|
void Sector_Interface::fn_vOnModifName (CPA_SuperObject *pEdObj, CString csInitalName, CString csFinalName, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
// default handling
|
|
fn_vOnModifHierarchy(eStatus);
|
|
|
|
// concerned DLL
|
|
if (eStatus == C_AsConcernedDLL)
|
|
m_pCurrentDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
|
|
}
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void Sector_Interface::fn_vOnModifDelete (CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
fn_vOnModifHierarchy (eStatus);
|
|
}
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void Sector_Interface::fn_vOnModifParent (CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
fn_vOnModifHierarchy (eStatus);
|
|
}
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void Sector_Interface::fn_vOnModifCopy (CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
fn_vOnModifHierarchy (eStatus);
|
|
}
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void Sector_Interface::fn_vOnModifInsert (CPA_SuperObject *pEdObj, CPA_SuperObject *pParent, tdstPosition *p_stPosition, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
fn_vOnModifHierarchy (eStatus);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Reinit World
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
|
|
void Sector_Interface::fn_vOnChangeRoot (void)
|
|
{
|
|
if (fn_bIsCurrentEditor())
|
|
fn_vReinitEditor(NULL);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void Sector_Interface::fn_vOnChangeWorld (void)
|
|
{
|
|
if (fn_bIsCurrentEditor())
|
|
fn_vReinitEditor(NULL);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void Sector_Interface::fn_vOnChangeDevice (void)
|
|
{
|
|
if (fn_bIsCurrentEditor())
|
|
fn_vReinitEditor(NULL);
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// MESSAGES
|
|
//#################################################################################
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::_OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags)
|
|
{
|
|
if (!fn_bIsCurrentEditor())
|
|
return FALSE;
|
|
//Shaitan Clean Env
|
|
/*
|
|
switch (m_pKeyboard->mfn_uwKeyToAction(nChar))
|
|
{
|
|
//CPA2 Corneliu Babiuc 26-05-98
|
|
// select mode
|
|
case KA_ID_SELECTSECTOR :
|
|
SetEditMode(E_em_EditSector);
|
|
return TRUE;
|
|
|
|
case KA_ID_SELECTLIST :
|
|
SetListActivity(E_NoActiveList, FALSE);
|
|
return TRUE;
|
|
|
|
case KA_ID_SELECTENV :
|
|
SetEditMode(E_em_EditEnv);
|
|
return TRUE;
|
|
|
|
// list mode
|
|
case KA_ID_LISTGRAPHIC :
|
|
SetListActivity(E_NoActiveList, FALSE, FALSE);
|
|
SetListActivity(E_Graphic, TRUE);
|
|
return TRUE;
|
|
|
|
case KA_ID_LISTCOLLISION :
|
|
SetListActivity(E_NoActiveList, FALSE, FALSE);
|
|
SetListActivity(E_Collision, TRUE);
|
|
return TRUE;
|
|
|
|
case KA_ID_LISTACTIVITY :
|
|
SetListActivity(E_NoActiveList, FALSE, FALSE);
|
|
SetListActivity(E_Activity, TRUE);
|
|
return TRUE;
|
|
|
|
case KA_ID_LISTSOUND :
|
|
SetListActivity(E_NoActiveList, FALSE, FALSE);
|
|
SetListActivity(E_Sound, TRUE);
|
|
return TRUE;
|
|
|
|
case KA_ID_LISTSOUNDEVENT :
|
|
SetListActivity(E_NoActiveList, FALSE, FALSE);
|
|
SetListActivity(E_SoundEvent, TRUE);
|
|
return TRUE;
|
|
default:
|
|
break;
|
|
//CPA2 Corneliu Babiuc 26-05-98
|
|
}
|
|
*/
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::_OnLButtonDown (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking)
|
|
{
|
|
CPA_SuperObject *pSelectedSector;
|
|
//Shaitan Clean Env
|
|
// CPA_SuperObject *pSelectedSurface;
|
|
|
|
if (!fn_bIsCurrentEditor())
|
|
return FALSE;
|
|
|
|
//Shaitan Clean Env
|
|
/*
|
|
// environment mode => can select surfaces
|
|
if ((m_eEditMode == E_em_EditEnv)&&(xIndex > 0))
|
|
{
|
|
pSelectedSurface = GetInterface()->GetFirstSelection(E_sm_SelectByType, xIndex, pPicking, C_szSurfaceTypeName);
|
|
if ((pSelectedSurface) &&
|
|
(GetInterface()->GetSpecificInterface()->fn_bIsSurfaceInList(pSelectedSurface)))
|
|
{
|
|
GetDialogSrf()->fn_vSelectSurf((SECT_Surface *) pSelectedSurface->GetObject());
|
|
return TRUE;
|
|
}
|
|
}
|
|
*/
|
|
// get corresponding sector
|
|
pSelectedSector = GetInterface()->GetFirstSelection(E_sm_SelectByType,xIndex, pPicking, C_szSectorTypeName);
|
|
|
|
// sector selection => select sector
|
|
if (m_eEditMode == E_em_EditSector)
|
|
fn_vSelectNewSector(pSelectedSector);
|
|
// other mode => sector must be valid
|
|
else if ((!pSelectedSector)||(pSelectedSector == m_pEditedSector))
|
|
return TRUE;
|
|
// list selection => update current list
|
|
else if (m_eEditMode == E_em_EditList)
|
|
fn_vUpdateActiveLists(pSelectedSector);
|
|
//Shaitan Clean Env
|
|
/*
|
|
// env selection => update selection
|
|
else if (m_eEditMode == E_em_EditEnv)
|
|
fn_vUpdateSelectList(pSelectedSector);
|
|
*/
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::_OnLButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking)
|
|
{
|
|
CPA_SuperObject *pSelectedSector;
|
|
|
|
if (!fn_bIsCurrentEditor())
|
|
return FALSE;
|
|
|
|
// get corresponding sector
|
|
pSelectedSector = GetInterface()->GetFirstSelection(E_sm_SelectByType, xIndex, pPicking, C_szSectorTypeName);
|
|
|
|
// select list => cancel simple click
|
|
if (m_eEditMode == E_em_EditList)
|
|
{
|
|
if ((pSelectedSector)&&(pSelectedSector != m_pEditedSector))
|
|
fn_vUpdateActiveLists(pSelectedSector);
|
|
}
|
|
|
|
//Shaitan Clean Env
|
|
/*
|
|
// select list => cancel simple click
|
|
if (m_eEditMode == E_em_EditEnv)
|
|
{
|
|
if ((pSelectedSector)&&(pSelectedSector != m_pEditedSector))
|
|
fn_vUpdateSelectList(pSelectedSector);
|
|
}
|
|
*/
|
|
// change edited sector
|
|
if (pSelectedSector)
|
|
fn_vReinitEditor(pSelectedSector);
|
|
else
|
|
fn_vReinitEditor(NULL);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL Sector_Interface::_OnRButtonDown (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking)
|
|
{
|
|
CPA_SuperObject *pSelectedSector;
|
|
|
|
if (!fn_bIsCurrentEditor())
|
|
return FALSE;
|
|
|
|
// to select an object
|
|
pSelectedSector = GetInterface()->GetFirstSelection(E_sm_SelectByType,xIndex, pPicking, C_szSectorTypeName);
|
|
// display popup
|
|
GetInterface()->fn_vDisplayPopupMenu(p_stPos);
|
|
|
|
// command processed
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// GET FUNCTIONS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Get corresponding dialog
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
SECT_DialogBase * Sector_Interface::GetSingleList (tdeTypeList eType)
|
|
{
|
|
switch (eType)
|
|
{
|
|
case E_Graphic:
|
|
return m_pDialogGraph;
|
|
case E_Collision:
|
|
return m_pDialogColls;
|
|
case E_Activity:
|
|
return m_pDialogActiv;
|
|
case E_Sound:
|
|
return m_pDialogSound;
|
|
case E_SoundEvent:
|
|
return m_pDialogSoundEvent;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Get current edited sector
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CPA_SuperObject * Sector_Interface::GetSectorToEdit (CPA_List<CPA_BaseObject> *pParam)
|
|
{
|
|
CPA_BaseObject *pEdObj;
|
|
POSITION pos;
|
|
|
|
// if there are parameters, find first sector
|
|
if (pParam)
|
|
{
|
|
for (pEdObj = pParam->GetHeadElement(pos); pEdObj; pEdObj = pParam->GetNextElement(pos))
|
|
{
|
|
if (((CPA_SuperObject *)pEdObj)->GetObjectDLL() == this)
|
|
return ((CPA_SuperObject *)pEdObj);
|
|
}
|
|
}
|
|
// else choose current sector
|
|
else
|
|
{
|
|
if (m_pEditedSector)
|
|
return m_pEditedSector;
|
|
else
|
|
return GetMainWorld()->GetInterface()->GetSpecificInterface()->GetCurrentSector();
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// SET FUNCTIONS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Change Edit Mode
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::SetEditMode (tdeEditMode eNewMode, BOOL bRedraw)
|
|
{
|
|
if (eNewMode == m_eEditMode)
|
|
return;
|
|
// set current mode
|
|
m_eEditMode = eNewMode;
|
|
// if necessary, update list
|
|
if (m_pSelectedSector != m_pEditedSector)
|
|
fn_vSelectNewSector(m_pEditedSector, FALSE, FALSE);
|
|
// default frame
|
|
SetCurrentFrame(eNewMode);
|
|
// cancel previous selection
|
|
if (!M_GetWorld()->GetRoot())
|
|
return;
|
|
fn_vSetRecursiveColor(M_GetWorld()->GetRoot(), C_NoColor);
|
|
// update current dialogs
|
|
if (m_pCurrentDialogMode)
|
|
m_pCurrentDialogMode->fn_vUpdateEditMode();
|
|
if (m_pCurrentDialogList)
|
|
m_pCurrentDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
|
|
if (m_pCurrentDialogEdit)
|
|
m_pCurrentDialogEdit->fn_vReinitDialog(m_pEditedSector);
|
|
// update sector dialogs
|
|
if (m_pDialogSel)
|
|
m_pDialogSel->fn_vReinitDialog(m_pSelectedSector, m_pEditedSector);
|
|
//Shaitan Clean Env
|
|
/*
|
|
// update env dialogs
|
|
if (m_pDialogEnvList)
|
|
m_pDialogEnvList->fn_vInitEnvList(m_pEditedSector);
|
|
*/
|
|
// selection
|
|
fn_vShowSelection(bRedraw);
|
|
|
|
if (fn_bIsCurrentEditor())
|
|
fn_vUpdateEditMode();
|
|
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Update editor when mode changes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vUpdateEditMode (BOOL bReinit)
|
|
{
|
|
CString csNewMode;
|
|
BOOL bNewState;
|
|
BOOL bLinkMode;
|
|
|
|
if (bReinit)
|
|
{
|
|
csNewMode = m_csSaveSelectMode;
|
|
bNewState = m_bPreviousState;
|
|
bLinkMode = m_bPreviousLinkMode;
|
|
}
|
|
else
|
|
{
|
|
csNewMode = C_szSectorTypeName;
|
|
bNewState = FALSE;
|
|
bLinkMode = FALSE;
|
|
}
|
|
|
|
// select mode
|
|
GetInterface()->GetComboSelectMode()->EnableWindow(bNewState);
|
|
GetInterface()->SetLinkMode(bLinkMode);
|
|
GetInterface()->SetSelectMode(csNewMode);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Set edited list
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::SetListActivity (tdeTypeList eNewList, BOOL bActive, BOOL bRedraw)
|
|
{
|
|
int eList;
|
|
|
|
// if necessary, update mode
|
|
SetEditMode(E_em_EditList, FALSE);
|
|
// disactivate all lists
|
|
if (eNewList == E_NoActiveList)
|
|
{
|
|
for (eList = 0; eList < C_NumberOfLists; eList++)
|
|
m_aListActivity[eList] = 0;
|
|
}
|
|
// update list activity
|
|
else
|
|
m_aListActivity[eNewList] = bActive;
|
|
|
|
// update dialogs
|
|
if (m_pDialogSel)
|
|
m_pDialogSel->fn_vUpdateCheck();
|
|
if (m_pCurrentDialogList)
|
|
m_pCurrentDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
|
|
// if necessary, update drawing
|
|
if (bRedraw)
|
|
fn_vShowAllSectors();
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Update editor dialogs when mode changes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::SetCurrentFrame (tdeEditMode eNewMode)
|
|
{
|
|
g_oFrameGest.mfn_vSetRefresh(FALSE);
|
|
|
|
switch (eNewMode)
|
|
{
|
|
// sector & list => sector dialogs
|
|
case E_em_EditSector:
|
|
case E_em_EditList:
|
|
// update bottom frame
|
|
if (m_pCurrentBottomFrame != m_pSectorBottomFrame)
|
|
{
|
|
m_pCurrentBottomFrame = m_pSectorBottomFrame;
|
|
if (fn_bIsCurrentEditor())
|
|
g_oFrameGest.mfn_vActivateWindow(m_pCurrentBottomFrame);
|
|
}
|
|
// update left frame
|
|
if (m_pCurrentLeftFrame != m_pSectorLeftFrame)
|
|
{
|
|
m_pCurrentLeftFrame = m_pSectorLeftFrame;
|
|
m_pCurrentDialogList = m_pSectorDialogList;
|
|
m_pCurrentDialogEdit = m_pSectorDialogEdit;
|
|
m_pCurrentDialogMode = m_pSectorDialogMode;
|
|
if (fn_bIsCurrentEditor())
|
|
g_oFrameGest.mfn_vActivateWindow(m_pCurrentLeftFrame);
|
|
}
|
|
break;
|
|
|
|
//Shaitan Clean Env
|
|
/*
|
|
// environment => env dialogs
|
|
case E_em_EditEnv:
|
|
// update bottom frame
|
|
if (m_pCurrentBottomFrame != m_pEnvBottomFrame)
|
|
{
|
|
m_pCurrentBottomFrame = m_pEnvBottomFrame;
|
|
if (fn_bIsCurrentEditor())
|
|
g_oFrameGest.mfn_vActivateWindow(m_pCurrentBottomFrame);
|
|
}
|
|
// update left frame
|
|
if (m_pCurrentLeftFrame != m_pEnvLeftFrame)
|
|
{
|
|
m_pCurrentLeftFrame = m_pEnvLeftFrame;
|
|
m_pCurrentDialogList = m_pEnvDialogList;
|
|
m_pCurrentDialogEdit = m_pEnvDialogEdit;
|
|
m_pCurrentDialogMode = m_pEnvDialogMode;
|
|
if (fn_bIsCurrentEditor())
|
|
g_oFrameGest.mfn_vActivateWindow(m_pCurrentLeftFrame);
|
|
}
|
|
break;
|
|
*/
|
|
}
|
|
g_oFrameGest.mfn_vSetRefresh(TRUE);
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// DIALOGS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: remove element from list when "Suppr"
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vOnKeyDownInSectorList (SECT_DialogBase *pDialog, UINT nChar)
|
|
{
|
|
SECT_ElementBase *pElem;
|
|
CPA_SuperObject *pSector;
|
|
SECT_ListBase *pCurrentList;
|
|
Sector_Object *pSectObj;
|
|
|
|
switch (m_pKeyboard->mfn_uwKeyToAction(nChar))
|
|
{
|
|
// Suppression
|
|
case KA_ID_DELETEELEM :
|
|
// get selected element
|
|
pElem = pDialog->GetSelectedElement();
|
|
if ((!pElem)||(!m_pEditedSector))
|
|
return;
|
|
// get current list
|
|
pSectObj = (Sector_Object *) m_pEditedSector->GetObject();
|
|
pCurrentList = pSectObj->GetCurrentList(pDialog->GetListType());
|
|
// remove element in current list
|
|
pSector = pElem->GetSector();
|
|
if (pCurrentList->GetElementWithSector(pSector))
|
|
M_GetEditManager()->AskFor(new SECT_ModifSectorLinks(this, E_mt_DelSectorInList,
|
|
m_pEditedSector, pSector, pDialog->GetListType()));
|
|
return;
|
|
}
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: remove element from list when "Suppr"
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::fn_vOnKeyDownInEnvList (CPA_SuperObject *pSector, long lNumEnvElem, UINT nKey)
|
|
{
|
|
SECT_ModifEnvAndSrf *pModif;
|
|
|
|
switch (m_pKeyboard->mfn_uwKeyToAction(nKey))
|
|
{
|
|
// Suppression
|
|
case KA_ID_DELETEELEM :
|
|
// del corresponding environment in sector list
|
|
pModif = new SECT_ModifEnvAndSrf(this, E_mt_DelEnvAndSrf,
|
|
m_pEditedSector, lNumEnvElem, NULL, NULL);
|
|
M_GetEditManager()->AskFor(pModif);
|
|
return;
|
|
}
|
|
}
|
|
*/
|
|
|
|
//#################################################################################
|
|
// PERMISSIONS & MODIFICATIONS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Current permission for Hierarchy Editor
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bAcceptModifHierarchy (tdeStatus eStatus)
|
|
{
|
|
// sectors cannot be modified
|
|
if (eStatus == C_AsConcernedDLL)
|
|
return FALSE;
|
|
// protected childs of sectors cannot be modified
|
|
if (eStatus == C_AsChildOwner)
|
|
return FALSE;
|
|
// other object : no objection
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Current update for Hierarchy Editor
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vOnModifHierarchy (tdeStatus eStatus)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// COLORS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Draw Edited Sector in Red
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vShowEditedSector (BOOL bUpdateDrawing, BOOL bAlone)
|
|
{
|
|
CPA_SuperObject *pEdObj;
|
|
|
|
|
|
// cancel other drawing
|
|
if (bAlone)
|
|
fn_vSetRecursiveColor(M_GetWorld()->GetRoot(), C_NoColor);
|
|
// set color to edited sector
|
|
pEdObj = m_pEditedSector;
|
|
fn_vSetRecursiveColor(pEdObj, C_ColorEdited);
|
|
|
|
// if necessary, update drawing
|
|
if (bUpdateDrawing)
|
|
GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Draw Sectors of Current LIst in Green
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vShowAllSectors (BOOL bUpdateDrawing)
|
|
{
|
|
CPA_List<CPA_SuperObject> oSectorList;
|
|
CPA_SuperObject *pSector;
|
|
POSITION pos;
|
|
|
|
if (!m_pEditedSector)
|
|
return;
|
|
|
|
// cancel other drawing
|
|
fn_vShowEditedSector(FALSE);
|
|
|
|
// find corresponding list
|
|
fn_vGetSectorsToDraw(&oSectorList);
|
|
// show all sectors in the list
|
|
for (pSector = oSectorList.GetHeadElement(pos); pSector;
|
|
pSector = oSectorList.GetNextElement(pos))
|
|
fn_vSetRecursiveColor(pSector, C_ColorShow);
|
|
|
|
// if necessary update drawing
|
|
if (bUpdateDrawing)
|
|
GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Draw Selected Sectors in blue
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vShowSelection (BOOL bUpdateDrawing)
|
|
{
|
|
//Shaitan Clean Env
|
|
/*
|
|
CPA_SuperObject *pSector;
|
|
POSITION pos;
|
|
*/
|
|
// cancel other drawing
|
|
fn_vShowEditedSector(FALSE);
|
|
// draw list selected
|
|
if (m_eEditMode == E_em_EditList)
|
|
fn_vShowAllSectors(FALSE);
|
|
//Shaitan Clean Env
|
|
/*
|
|
// draw select list
|
|
if (m_eEditMode == E_em_EditEnv)
|
|
{
|
|
// show all sectors in the list
|
|
for (pSector = m_oSelectList.GetHeadElement(pos); pSector;
|
|
pSector = m_oSelectList.GetNextElement(pos))
|
|
{
|
|
if (pSector != m_pEditedSector)
|
|
fn_vSetRecursiveColor(pSector, C_ColorSelected);
|
|
}
|
|
// show surface
|
|
if (m_pCurrentVisual)
|
|
fn_vSetRecursiveColor(m_pCurrentVisual, C_ColorSurf);
|
|
}
|
|
*/
|
|
// if necessary update drawing
|
|
if (bUpdateDrawing)
|
|
GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Set sector color
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vSetRecursiveColor (CPA_SuperObject *pEdObj, tdeLocalColor eColor)
|
|
{
|
|
CPA_SuperObject *pChild;
|
|
|
|
if (!pEdObj)
|
|
return;
|
|
|
|
// set super object color
|
|
pEdObj->SetLocalColor(eColor);
|
|
// next level of hierarchy
|
|
for (pChild = pEdObj->GetSuperObjectFirstChild(); pChild;
|
|
pChild = pEdObj->GetSuperObjectNextChild(pChild))
|
|
fn_vSetRecursiveColor(pChild, eColor);
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// SELECTION
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Reinit Editor when edition changes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vReinitEditor (CPA_SuperObject *pSectorToEdit)
|
|
{
|
|
Sector_Object *pSectObject;
|
|
|
|
// get current sector
|
|
m_pEditedSector = pSectorToEdit;
|
|
m_pSelectedSector = NULL;
|
|
// reinit current dialogs
|
|
m_pCurrentDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
|
|
m_pCurrentDialogEdit->fn_vReinitDialog(pSectorToEdit);
|
|
m_pCurrentDialogList->fn_vRedrawElement(pSectorToEdit, TRUE);
|
|
// reinit sector dialogs
|
|
m_pDialogSel->fn_vReinitDialog(pSectorToEdit, pSectorToEdit);
|
|
// reinit lists
|
|
if (pSectorToEdit)
|
|
{
|
|
pSectObject = (Sector_Object *) pSectorToEdit->GetObject();
|
|
m_pDialogSound->fn_vReinitDialog(pSectObject->GetCurrentList(E_Sound));
|
|
m_pDialogActiv->fn_vReinitDialog(pSectObject->GetCurrentList(E_Activity));
|
|
m_pDialogColls->fn_vReinitDialog(pSectObject->GetCurrentList(E_Collision));
|
|
m_pDialogGraph->fn_vReinitDialog(pSectObject->GetCurrentList(E_Graphic));
|
|
m_pDialogSoundEvent->fn_vReinitDialog(pSectObject->GetCurrentList(E_SoundEvent));
|
|
}
|
|
else
|
|
{
|
|
m_pDialogSound->fn_vReinitDialog(NULL);
|
|
m_pDialogActiv->fn_vReinitDialog(NULL);
|
|
m_pDialogColls->fn_vReinitDialog(NULL);
|
|
m_pDialogGraph->fn_vReinitDialog(NULL);
|
|
m_pDialogSoundEvent->fn_vReinitDialog(NULL);
|
|
}
|
|
// reinit current dialogs
|
|
//Shaitan Clean Env
|
|
// m_pDialogEnvList->fn_vInitEnvList(m_pEditedSector);
|
|
// show edited sector
|
|
fn_vShowSelection(TRUE);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Update editor when selection changes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vSelectNewSector (CPA_SuperObject *pSector, BOOL bCenterOnSector, BOOL bUpdateDrawing)
|
|
{
|
|
POS_tdstCompletePosition stCameraMatrix;
|
|
CPA_CameraDLLBase *p_oCameraInterface;
|
|
CPA_CameraCoords oCoords;
|
|
MTH3D_tdstVector stCenter, stCameraPosition, stDistance;
|
|
CPA_SuperObject *pOldSelection;
|
|
DEV_ViewPort3D *pCurViewport;
|
|
CPA_BaseObject *p_oCamera;
|
|
Sector_Object *pSectObj;
|
|
MTH_tdxReal xDistance;
|
|
BOOL bTarget;
|
|
|
|
// unselect previous sector
|
|
if ((m_pSelectedSector)&&(pSector != m_pSelectedSector))
|
|
fn_vSetRecursiveColor(m_pSelectedSector, C_NoColor);
|
|
// select new sector
|
|
pOldSelection = m_pSelectedSector;
|
|
m_pSelectedSector = pSector;
|
|
if ((pSector)&&(pSector != m_pEditedSector))
|
|
fn_vSetRecursiveColor(pSector, C_ColorSelected);
|
|
// show edited sector
|
|
if (m_pEditedSector)
|
|
fn_vSetRecursiveColor(m_pEditedSector, C_ColorEdited);
|
|
|
|
// get camera
|
|
pCurViewport = (DEV_ViewPort3D *) M_GetMultiDevice3D()->GetFocusDevice()->GetViewPort();
|
|
p_oCameraInterface = pCurViewport->GetCameraInterface();
|
|
p_oCamera = pCurViewport->GetCamera();
|
|
|
|
bTarget = GetInterface()->fn_bAutoTarget();
|
|
|
|
// if necessary, center the object on the screen
|
|
if ((pSector)&&(bCenterOnSector || bTarget))
|
|
{
|
|
// find center of sector
|
|
pSectObj = (Sector_Object *) pSector->GetObject();
|
|
pSectObj->GetCenterInBorder(&stCenter);
|
|
oCoords.SetCoords(&stCenter);
|
|
// target camera on this point
|
|
p_oCameraInterface->SetTargetPoint(p_oCamera, &oCoords);
|
|
p_oCameraInterface->SetTargetType(p_oCamera,tPoint);
|
|
p_oCameraInterface->Update(p_oCamera);
|
|
// get distance to sector
|
|
p_oCameraInterface->GetMatrix(p_oCamera, &stCameraMatrix);
|
|
POS_fn_vGetTranslationVector(&stCameraMatrix, &stCameraPosition);
|
|
MTH3D_M_vSubVector(&stDistance, &stCenter, &stCameraPosition);
|
|
p_oCameraInterface->WorldToCameraCoordinates_Vector(p_oCamera, stDistance);
|
|
// get max of bounding box
|
|
xDistance = pSectObj->GetMaxDimension();
|
|
stDistance.xZ -= 2*xDistance;
|
|
// translate camera
|
|
oCoords.SetAxisSystem(CameraCoordinates);
|
|
oCoords.SetCoords(&stDistance);
|
|
p_oCameraInterface->Translate(p_oCamera, &oCoords);
|
|
// restore target type
|
|
if (!bTarget)
|
|
p_oCameraInterface->SetTargetType(p_oCamera,tNone);
|
|
p_oCameraInterface->Update(p_oCamera);
|
|
}
|
|
|
|
// if necessary, update drawing
|
|
if (bUpdateDrawing)
|
|
GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
|
|
|
|
// update dialog list
|
|
m_pCurrentDialogList->fn_vRedrawElement(pOldSelection, FALSE);
|
|
m_pCurrentDialogList->fn_vRedrawElement(m_pSelectedSector, TRUE);
|
|
// update dialog sector
|
|
m_pDialogSel->fn_vReinitDialog(pSector, m_pEditedSector);
|
|
// update all lists
|
|
m_pDialogSoundEvent->fn_vUpdateSelection(pSector);
|
|
m_pDialogSound->fn_vUpdateSelection(pSector);
|
|
m_pDialogColls->fn_vUpdateSelection(pSector);
|
|
m_pDialogActiv->fn_vUpdateSelection(pSector);
|
|
m_pDialogGraph->fn_vUpdateSelection(pSector);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Update current list when selection changes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vUpdateActiveLists (CPA_SuperObject *pSector)
|
|
{
|
|
SECT_ModifSectorLinks *pModif;
|
|
|
|
if (pSector == m_pEditedSector)
|
|
return;
|
|
|
|
if ((m_pEditedSector) && (GetFirstActiveList() != E_NoActiveList))
|
|
{
|
|
// if already in lists, remove and update drawing
|
|
if (fn_bIsInActiveLists(pSector))
|
|
pModif = new SECT_ModifSectorLinks(this, E_mt_DelSectorInList, m_pEditedSector, pSector, E_NoActiveList);
|
|
// else add to the list and update drawing
|
|
else
|
|
pModif = new SECT_ModifSectorLinks(this, E_mt_AddSectorInList, m_pEditedSector, pSector, E_NoActiveList);
|
|
// update drawing and dialog
|
|
M_GetEditManager()->AskFor(pModif);
|
|
m_pCurrentDialogList->fn_vRedrawElement(pSector, TRUE);
|
|
}
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Update select list when selection changes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vUpdateSelectList (CPA_SuperObject *pSector)
|
|
{
|
|
// POSITION pos;
|
|
|
|
if (pSector == m_pEditedSector)
|
|
return;
|
|
|
|
//Shaitan Clean Env
|
|
/*
|
|
if (m_eEditMode == E_em_EditEnv)
|
|
{
|
|
pos = m_oSelectList.Find(pSector, NULL);
|
|
// if already in list, remove and update drawing
|
|
if (pos)
|
|
{
|
|
m_oSelectList.RemoveAt(pos);
|
|
fn_vSetRecursiveColor(pSector, C_NoColor);
|
|
}
|
|
// else add to the list and update drawing
|
|
else
|
|
{
|
|
m_oSelectList.AddTail(pSector);
|
|
fn_vSetRecursiveColor(pSector, C_ColorSelected);
|
|
}
|
|
// update drawing and dialog
|
|
GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
|
|
if (m_pCurrentDialogList)
|
|
m_pCurrentDialogList->fn_vRedrawElement(pSector, TRUE);
|
|
}
|
|
*/
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// ENVIRONMENT
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: find editor env from engine env
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_Environment * Sector_Interface::GetOrBuildEnvironment (ENV_tdxHandleToEnvironment hEnvironment)
|
|
{
|
|
SECT_Environment *pEnv;
|
|
CString csSectionName, csFileName;
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
int iPos;
|
|
|
|
pEnv = (SECT_Environment *) GetBaseObject(hEnvironment, C_szEnvironmentTypeName, NULL);
|
|
if (!pEnv)
|
|
{
|
|
// get parameters in linktable
|
|
csSectionName = DNM_fn_p_cSearchValueInLinkTableOfEnvironment((unsigned long) hEnvironment);
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
csSectionName = szFileName;
|
|
// compute minimal file name
|
|
iPos = csSectionName.Find(m_csENVRefPath);
|
|
if (iPos != -1)
|
|
csFileName = csSectionName.Mid(m_csENVRefPath.GetLength());
|
|
// create environment
|
|
pEnv = new SECT_Environment(this, hEnvironment, TRUE, szName, csFileName);
|
|
}
|
|
return pEnv;
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: find editor env from name
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_Environment * Sector_Interface::GetEnvironmentWithName (CString csName)
|
|
{
|
|
SECT_Environment *pEnv;
|
|
|
|
pEnv = (SECT_Environment *) GetBaseObject(csName, C_szEnvironmentTypeName, NULL);
|
|
return pEnv;
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: find default env
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_Environment * Sector_Interface::GetDefaultEnvironment (void)
|
|
{
|
|
CPA_BaseObjectList *pListObject;
|
|
CPA_BaseObject *pElem;
|
|
|
|
// reinit combo
|
|
pListObject = GetBaseObjectList(C_szEnvironmentTypeName);
|
|
pElem = pListObject->GetHead();
|
|
|
|
if (!pElem)
|
|
return NULL;
|
|
else
|
|
return (SECT_Environment *) pElem;
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: find editor mec env from engine mec env
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_MecEnvironment * Sector_Interface::GetOrBuildMecEnvironment (DNM_tdxHandleToMecEnvironment hMecEnv)
|
|
{
|
|
SECT_MecEnvironment *pMecEnv;
|
|
CString csSectionName, csFileName;
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
int iPos;
|
|
|
|
pMecEnv = (SECT_MecEnvironment *) GetBaseObject(hMecEnv, C_szMecEnvironmentTypeName, NULL);
|
|
if (!pMecEnv)
|
|
{
|
|
// get parameters in linktable
|
|
csSectionName = DNM_fn_p_cSearchValueInLinkTableOfMecEnvironment((unsigned long) hMecEnv);
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
csSectionName = szFileName;
|
|
// compute minimal file name
|
|
iPos = csSectionName.Find(m_csMECRefPath);
|
|
if (iPos != -1)
|
|
csFileName = csSectionName.Mid(m_csMECRefPath.GetLength());
|
|
// create environment
|
|
pMecEnv = new SECT_MecEnvironment(this, hMecEnv, TRUE, szName, csFileName, TRUE);
|
|
}
|
|
|
|
return pMecEnv;
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: find default mec env
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_MecEnvironment * Sector_Interface::GetDefaultMecEnvironment (void)
|
|
{
|
|
CPA_BaseObjectList *pListObject;
|
|
CPA_BaseObject *pElem;
|
|
|
|
// reinit combo
|
|
pListObject = GetBaseObjectList(C_szMecEnvironmentTypeName);
|
|
pElem = pListObject->GetHead();
|
|
|
|
if (!pElem)
|
|
return NULL;
|
|
else
|
|
return (SECT_MecEnvironment *) pElem;
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: find editor vis env from engine vis env
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_VisEnvironment * Sector_Interface::GetOrBuildVisEnvironment (ACP_tdxHandleToVisualEnvironment hVisEnv)
|
|
{
|
|
SECT_VisEnvironment *pVisEnv;
|
|
SCR_tdst_Link_Value *pLinkValue;
|
|
CString csSectionName, csFileName;
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
int iPos;
|
|
|
|
if (!hVisEnv)
|
|
return NULL;
|
|
|
|
pVisEnv = (SECT_VisEnvironment *) GetBaseObject(hVisEnv, C_szVisEnvironmentTypeName, NULL);
|
|
if (!pVisEnv)
|
|
{
|
|
// get parameters in linktable
|
|
pLinkValue = SCR_fnp_st_Link_SearchValue(GLI_fn_p_stGetVisualEnvironementLinkTable(), (unsigned long) hVisEnv);
|
|
if ((pLinkValue)&&(SCR_M_e_Link_GetState(pLinkValue) == SCR_ELS_Link_Initialized))
|
|
csSectionName = SCR_M_p_sz_Link_GetKey(pLinkValue);
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
csSectionName = szFileName;
|
|
// compute minimal file name
|
|
iPos = csSectionName.Find(m_csVISRefPath);
|
|
if (iPos != -1)
|
|
csFileName = csSectionName.Mid(m_csVISRefPath.GetLength());
|
|
// create environment
|
|
pVisEnv = new SECT_VisEnvironment(this, hVisEnv, TRUE, szName, csFileName, TRUE);
|
|
}
|
|
|
|
return pVisEnv;
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: get default vis env
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_VisEnvironment * Sector_Interface::GetDefaultVisEnvironment (void)
|
|
{
|
|
CPA_BaseObjectList *pListObject;
|
|
CPA_BaseObject *pElem;
|
|
|
|
// reinit combo
|
|
pListObject = GetBaseObjectList(C_szVisEnvironmentTypeName);
|
|
pElem = pListObject->GetHead();
|
|
|
|
if (!pElem)
|
|
return NULL;
|
|
else
|
|
return (SECT_VisEnvironment *) pElem;
|
|
}
|
|
*/
|
|
|
|
//#################################################################################
|
|
// SOUND
|
|
//#################################################################################
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: reinit all sound parameters
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vReinitSoundParameters (void)
|
|
{
|
|
SECT_SndEvtEngineElem *pSndEvtElem;
|
|
CPA_BaseObjectList *pListObject;
|
|
// SECT_Environment *pEnvironment;
|
|
CPA_BaseObject *pElem;
|
|
Sector_Object *pSector;
|
|
Position pos;
|
|
POSITION pos1;
|
|
|
|
// get sector list
|
|
pListObject = GetBaseObjectList(C_szSectorTypeName);
|
|
// update each sector
|
|
for (pElem = pListObject->GetHeadElement(pos); pElem;
|
|
pElem = pListObject->GetNextElement(pos))
|
|
{
|
|
pSector = (Sector_Object *) pElem;
|
|
// update sound events
|
|
for (pSndEvtElem = pSector->GetSoundEventList()->GetHeadElement(pos1); pSndEvtElem;
|
|
pSndEvtElem = pSector->GetSoundEventList()->GetNextElement(pos1))
|
|
pSndEvtElem->fn_vInitSoundEvent();
|
|
}
|
|
//Shaitan Clean Env
|
|
/*
|
|
// get environment list
|
|
pListObject = GetBaseObjectList(C_szEnvironmentTypeName);
|
|
// update each environment
|
|
for (pElem = pListObject->GetHeadElement(pos); pElem;
|
|
pElem = pListObject->GetNextElement(pos))
|
|
{
|
|
pEnvironment = (SECT_Environment *) pElem;
|
|
// update sound environments
|
|
pEnvironment->fn_vInitSndEnvironment();
|
|
}
|
|
*/
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: find editor sound env from engine sound env
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_SndEnvironment * Sector_Interface::GetOrNullSndEnvironment (SND_tdxHandleToSoundInfo hSndEnv)
|
|
{
|
|
// no Sound DLL => no sound environment
|
|
if (!m_pSoundEnvList)
|
|
return NULL;
|
|
// look for object in the list
|
|
return (SECT_SndEnvironment *) m_pSoundEnvList->fn_p_oFindObjectWithdData((void *) hSndEnv);
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: find default editor sound env
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_SndEnvironment * Sector_Interface::GetDefaultSndEnvironment (void)
|
|
{
|
|
SECT_SndEnvironment *pElem;
|
|
|
|
// no Sound DLL => no sound environment
|
|
if ((!m_pSoundEnvList)||(m_pSoundEnvList->GetCount() == 0 ))
|
|
return NULL;
|
|
|
|
// get first element in sound env list
|
|
pElem = (SECT_SndEnvironment *) m_pSoundEnvList->GetHead();
|
|
return pElem;
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: find editor sound event from engine sound event
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
SECT_SoundEvent * Sector_Interface::GetOrNullSoundEvent (SND_tdxHandleToSoundEvent hSoundEvent)
|
|
{
|
|
// no Sound DLL => no sound environment
|
|
if ((!m_pSoundEventList)||(m_pSoundEventList->GetCount() == 0))
|
|
return NULL;
|
|
// look for object in the list
|
|
return (SECT_SoundEvent *) m_pSoundEventList->fn_p_oFindObjectWithdData((void *) hSoundEvent);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: find default editor sound event
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
SECT_SoundEvent * Sector_Interface::GetDefaultSoundEvent (void)
|
|
{
|
|
SECT_SoundEvent *pElem;
|
|
|
|
// no Sound DLL => no sound environment
|
|
if ((!m_pSoundEventList)||(m_pSoundEventList->GetCount() == 0))
|
|
return NULL;
|
|
|
|
// get first element in sound env list
|
|
pElem = (SECT_SoundEvent *) m_pSoundEventList->GetHead();
|
|
return pElem;
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// SURFACE
|
|
//#################################################################################
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: find editor surface from engine surface
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_Surface * Sector_Interface::GetOrBuildSurface (SRF_tdxHandleToSurface hSurface)
|
|
{
|
|
SCR_tdst_Link_Value *pLinkValue;
|
|
SECT_Surface *pSurface;
|
|
CString csSectionName, csFileName;
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
int iPos;
|
|
|
|
pSurface = (SECT_Surface *) GetBaseObject(hSurface, C_szSurfaceTypeName, NULL);
|
|
if (!pSurface)
|
|
{
|
|
// search link table for engine struct
|
|
pLinkValue = SCR_fnp_st_Link_SearchValue(SRF_GetSurfaceLinkTable(), (unsigned long) hSurface);
|
|
if ((pLinkValue)&&(SCR_M_e_Link_GetState(pLinkValue) == SCR_ELS_Link_Initialized))
|
|
csSectionName = SCR_M_p_sz_Link_GetKey(pLinkValue);
|
|
// get parameters
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
csSectionName = szFileName;
|
|
// compute minimal file name
|
|
iPos = csSectionName.Find(m_csSURFRefPath);
|
|
if (iPos != -1)
|
|
csFileName = csSectionName.Mid(m_csSURFRefPath.GetLength());
|
|
// create environment
|
|
pSurface = new SECT_Surface(this, hSurface, TRUE, szName, csFileName);
|
|
}
|
|
return pSurface;
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: find default editor surf
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_Surface * Sector_Interface::GetDefaultSurface (Sector_Object *pSector)
|
|
{
|
|
CPA_BaseObjectList *pListObject;
|
|
CPA_BaseObject *pElem;
|
|
SECT_SurfElem *pSurfElem;
|
|
SECT_Surface *pSurface;
|
|
Position pos;
|
|
|
|
// get surface list
|
|
pListObject = GetBaseObjectList(C_szSurfaceTypeName);
|
|
|
|
// check sector surface list to get available surfaces
|
|
for (pElem = pListObject->GetHeadElement(pos); pElem;
|
|
pElem = pListObject->GetNextElement(pos))
|
|
{
|
|
pSurface = (SECT_Surface *) pElem;
|
|
pSurfElem = pSector->GetSurfaceList()->GetElementWithSurface(pSurface);
|
|
// return first unused surface
|
|
if (!pSurfElem)
|
|
return pSurface;
|
|
}
|
|
// all surfaces are already used
|
|
return FALSE;
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: set surface to draw and update drawing
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::SetSurfaceToDraw (SECT_Surface *pSurface)
|
|
{
|
|
// update surface
|
|
if (m_pSurfaceToDraw == pSurface)
|
|
return;
|
|
|
|
// update previous visual
|
|
if (m_pCurrentVisual)
|
|
fn_vSetRecursiveColor(m_pCurrentVisual, C_NoColor);
|
|
|
|
// update surface
|
|
m_pSurfaceToDraw = pSurface;
|
|
// add corresponding visual surface
|
|
if (m_pSurfaceToDraw)
|
|
{
|
|
// set visual object in current visual
|
|
m_pCurrentVisual = m_pSurfaceToDraw->GetVisualSuperObject();
|
|
// if necessary, set current visual in world
|
|
fn_vSetRecursiveColor(m_pCurrentVisual, C_ColorSurf);
|
|
}
|
|
// remove corresponding visual surface
|
|
else
|
|
m_pCurrentVisual = NULL;
|
|
// update drawing
|
|
GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: get edited index from surface height
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
long Sector_Interface::GetSurfaceHeightIndex (SECT_Surface *pSurface, long lPrevIndex)
|
|
{
|
|
CPA_BaseObjectList *pListObject;
|
|
CPA_BaseObject *pElem;
|
|
SECT_Surface *pSurf;
|
|
long lIndex;
|
|
|
|
// get surface list
|
|
pListObject = GetBaseObjectList(C_szSurfaceTypeName);
|
|
|
|
// get real height index
|
|
for (lIndex = 0; lIndex < pListObject->GetCount(); lIndex++)
|
|
{
|
|
pElem = pListObject->GetObjectWithIndex(lIndex, E_lo_Edited);
|
|
pSurf = (SECT_Surface *) pElem;
|
|
// test function
|
|
if ((pSurf->GetHeight() <= pSurface->GetHeight())&&(pSurf != pSurface))
|
|
{
|
|
if (lIndex < lPrevIndex)
|
|
return lIndex;
|
|
else
|
|
return lIndex - 1;
|
|
}
|
|
}
|
|
// last index
|
|
return -1;
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: update edited index from surface height
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::fn_vUpdateHeightIndex (SECT_Surface *pSurface)
|
|
{
|
|
CPA_BaseObjectList *pListObject;
|
|
long lRealIndex, lPrevIndex;
|
|
|
|
// get surface list & element
|
|
pListObject = GetBaseObjectList(C_szSurfaceTypeName);
|
|
lPrevIndex = pListObject->GetIndexOfObject(pSurface, E_lo_Edited);
|
|
|
|
// get index from surface height
|
|
lRealIndex = GetSurfaceHeightIndex(pSurface, lPrevIndex);
|
|
if (lRealIndex == -1)
|
|
lRealIndex = pListObject->GetCount() - 1;
|
|
|
|
// if necessary, update edited index
|
|
if (lPrevIndex != lRealIndex)
|
|
pListObject->fn_vChangeObjectOrder(lPrevIndex, lRealIndex, E_lo_Edited);
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: update all surface list in all sectors
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::fn_vUpdateAllSurfaceList (SECT_Surface *pSurface)
|
|
{
|
|
CPA_BaseObjectList *pListObject;
|
|
CPA_BaseObject *pElem;
|
|
SECT_SurfElem *pSurfElem;
|
|
Sector_Object *pSector;
|
|
Position pos;
|
|
long lNumEnvElem;
|
|
|
|
// get sector list
|
|
pListObject = GetBaseObjectList(C_szSectorTypeName);
|
|
// check all sectors
|
|
for (pElem = pListObject->GetHeadElement(pos); pElem;
|
|
pElem = pListObject->GetNextElement(pos))
|
|
{
|
|
pSector = (Sector_Object *) pElem;
|
|
// get corresponding surface element
|
|
pSurfElem = pSector->GetSurfaceList()->GetElementWithSurface(pSurface);
|
|
if (pSurfElem)
|
|
{
|
|
lNumEnvElem = pSector->GetSurfaceList()->GetCurrentPosition(pSurfElem);
|
|
pSector->fn_lUpdateEnvironmentElement(lNumEnvElem);
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
|
|
//#################################################################################
|
|
// SECTOR
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Get Sector from Name
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CPA_SuperObject * Sector_Interface::GetSectorWithName (CString csName)
|
|
{
|
|
CPA_SuperObject *pSector;
|
|
Sector_Object *pSectObj;
|
|
|
|
pSectObj = (Sector_Object *) GetBaseObject(csName, C_szSectorTypeName, NULL);
|
|
pSector = pSectObj ? pSectObj->GetSuperObject() : NULL;
|
|
return pSector;
|
|
}
|
|
|
|
//#################################################################################
|
|
// LOADS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: load base objects
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bLoadBaseObject(CPA_BaseObject *p_oObject)
|
|
{
|
|
//Shaitan Clean Env
|
|
/*
|
|
SECT_Environment *pEnv;
|
|
|
|
// environment
|
|
if (p_oObject->GetType() == C_szEnvironmentTypeName)
|
|
{
|
|
// update flag
|
|
pEnv = (SECT_Environment *) p_oObject;
|
|
pEnv->SetAvailable(TRUE);
|
|
// if necessary, update associated mechanic environment
|
|
if ((pEnv->GetMecEnvironment())&&(!pEnv->GetMecEnvironment()->fn_bIsAvailable()))
|
|
pEnv->GetMecEnvironment()->SetAvailable(TRUE);
|
|
// if necessary, update associated visual environment
|
|
if ((pEnv->GetVisEnvironment())&&(!pEnv->GetVisEnvironment()->fn_bIsAvailable()))
|
|
pEnv->GetVisEnvironment()->SetAvailable(TRUE);
|
|
// update dialog
|
|
m_pDialogEnvs->fn_vSelectEnv(pEnv);
|
|
return TRUE;
|
|
}
|
|
|
|
// mec environment
|
|
if (p_oObject->GetType() == C_szMecEnvironmentTypeName)
|
|
{
|
|
// update flag
|
|
p_oObject->SetAvailable(TRUE);
|
|
// update dialog
|
|
m_pDialogEnv->fn_vSelectMechanic((SECT_MecEnvironment *)p_oObject);
|
|
return TRUE;
|
|
}
|
|
|
|
// vis environment
|
|
if (p_oObject->GetType() == C_szVisEnvironmentTypeName)
|
|
{
|
|
// update flag
|
|
p_oObject->SetAvailable(TRUE);
|
|
// update dialog
|
|
m_pDialogEnv->fn_vSelectVisual((SECT_VisEnvironment *)p_oObject);
|
|
return TRUE;
|
|
}
|
|
|
|
// surface
|
|
if (p_oObject->GetType() == C_szSurfaceTypeName)
|
|
{
|
|
// update flag
|
|
p_oObject->SetAvailable(TRUE);
|
|
// update dialog
|
|
m_pDialogSrf->fn_vSelectSurf((SECT_Surface *)p_oObject);
|
|
return TRUE;
|
|
}
|
|
|
|
*/
|
|
// other type => not concerned
|
|
return FALSE;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: get file names for env & mec env & vis env
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::fn_vInitEnvironmentFiles (void)
|
|
{
|
|
CString csFileName;
|
|
char szFileName[256];
|
|
|
|
csFileName = M_GetMainApp()->m_csEditorDataPath + "Objects\\" + C_szSectorIniFile;
|
|
|
|
if (m_csEnvFileName.IsEmpty())
|
|
{
|
|
GetPrivateProfileString ("Files", "Environment File", "", szFileName, 256, (char*)(LPCSTR)csFileName);
|
|
m_csEnvFileName = szFileName;
|
|
}
|
|
|
|
|
|
if (m_csMecEnvFileName.IsEmpty())
|
|
{
|
|
GetPrivateProfileString ("Files", "MecEnvironment File", "", szFileName, 256, (char*)(LPCSTR)csFileName);
|
|
m_csMecEnvFileName = szFileName;
|
|
}
|
|
|
|
if (m_csVisEnvFileName.IsEmpty())
|
|
{
|
|
GetPrivateProfileString ("Files", "VisEnvironment File", "", szFileName, 256, (char*)(LPCSTR)csFileName);
|
|
m_csVisEnvFileName = szFileName;
|
|
}
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: load all environments in file
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::fn_vLoadEnvironments (void)
|
|
{
|
|
ENV_tdxHandleToEnvironment hEnv = NULL;
|
|
SCR_tdst_Anl_SectionDes *pSectionDes;
|
|
SCR_tdst_Cxt_Values *p_stValues;
|
|
SCR_tdst_File_Open *pFile;
|
|
SCR_tdst_Sect_Open *pSectOpen;
|
|
SECT_Environment *pEnv = NULL;
|
|
CString csSectionName, csCompleteSectionName;
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
UINT iPos;
|
|
|
|
// parse mec environment file
|
|
SCR_fn_v_RdL0_OpenFile((char*)(LPCSTR) m_csEnvFileName);
|
|
|
|
// get open file
|
|
pFile = SCR_fnp_st_RdL0_GetOpenFile((char*)(LPCSTR) m_csEnvFileName);
|
|
|
|
// get all existing sections
|
|
iPos = 0;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_SectionDes, iPos, pSectionDes, pFile->stSectionsDes);
|
|
while (pSectionDes)
|
|
{
|
|
// get corresponding section name
|
|
csSectionName = pSectionDes->stBuffers.p_szBufferCompleteName;
|
|
// is section already loaded ?
|
|
pSectOpen = SCR_fnp_st_RdL0_GetOpenSection((char*)(LPCSTR) csSectionName, 0);
|
|
if (pSectOpen)
|
|
{
|
|
csCompleteSectionName = m_csENVRefPath + csSectionName;
|
|
hEnv = (ENV_tdxHandleToEnvironment) DNM_fn_ulLink_SearchKeyInLinkTableOfEnvironment((char *)(LPCSTR) csCompleteSectionName);
|
|
pEnv = GetOrBuildEnvironment(hEnv);
|
|
}
|
|
// section not loaded => load it
|
|
else
|
|
{
|
|
// load engine struct
|
|
p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char*)(LPCSTR) csSectionName, SCR_CDF_uw_Anl_Normal);
|
|
hEnv = (ENV_tdxHandleToEnvironment) SCR_M_ul_RdL0_ExtractLongValue(p_stValues, 0);
|
|
// get parameters
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
// create environment
|
|
pEnv = new SECT_Environment(this, hEnv, FALSE, szName, szFileName);
|
|
}
|
|
// next section
|
|
iPos +=1;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_SectionDes, iPos, pSectionDes, pFile->stSectionsDes);
|
|
}
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: load all mechanic environments in file
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::fn_vLoadMecEnvironments (void)
|
|
{
|
|
DNM_tdxHandleToMecEnvironment hMecEnv = NULL;
|
|
SCR_tdst_Anl_SectionDes *pSectionDes;
|
|
SCR_tdst_Cxt_Values *p_stValues;
|
|
SECT_MecEnvironment *pMecEnv = NULL;
|
|
SCR_tdst_File_Open *pFile;
|
|
SCR_tdst_Sect_Open *pSectOpen;
|
|
CString csSectionName, csCompleteSectionName;
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
UINT iPos;
|
|
|
|
// parse mec environment file
|
|
SCR_fn_v_RdL0_OpenFile((char*)(LPCSTR) m_csMecEnvFileName);
|
|
|
|
// get open file
|
|
pFile = SCR_fnp_st_RdL0_GetOpenFile((char*)(LPCSTR) m_csMecEnvFileName);
|
|
|
|
// get all existing sections
|
|
iPos = 0;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_SectionDes, iPos, pSectionDes, pFile->stSectionsDes);
|
|
while (pSectionDes)
|
|
{
|
|
// get corresponding section name
|
|
csSectionName = pSectionDes->stBuffers.p_szBufferCompleteName;
|
|
// is section already loaded ?
|
|
pSectOpen = SCR_fnp_st_RdL0_GetOpenSection((char*)(LPCSTR) csSectionName, 0);
|
|
if (pSectOpen)
|
|
{
|
|
csCompleteSectionName = m_csMECRefPath + csSectionName;
|
|
hMecEnv = (DNM_tdxHandleToMecEnvironment) DNM_fn_ulLink_SearchKeyInLinkTableOfMecEnvironment((char *)(LPCSTR) csCompleteSectionName);
|
|
pMecEnv = GetOrBuildMecEnvironment(hMecEnv);
|
|
}
|
|
// section not loaded => load it
|
|
else
|
|
{
|
|
// load engine struct
|
|
p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char*)(LPCSTR) csSectionName, SCR_CDF_uw_Anl_Normal);
|
|
hMecEnv = (DNM_tdxHandleToMecEnvironment) SCR_M_ul_RdL0_ExtractLongValue(p_stValues, 0);
|
|
// get parameters
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
// create environment
|
|
pMecEnv = new SECT_MecEnvironment(this, hMecEnv, FALSE, szName, szFileName, TRUE);
|
|
}
|
|
// next section
|
|
iPos +=1;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_SectionDes, iPos, pSectionDes, pFile->stSectionsDes);
|
|
}
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: load all visual environments in file
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::fn_vLoadVisEnvironments (void)
|
|
{
|
|
ACP_tdxHandleToVisualEnvironment hVisEnv = NULL;
|
|
SCR_tdst_Anl_SectionDes *pSectionDes;
|
|
SCR_tdst_Cxt_Values *p_stValues;
|
|
SCR_tdst_Link_Value *pLinkValue;
|
|
SECT_VisEnvironment *pVisEnv = NULL;
|
|
SCR_tdst_File_Open *pFile;
|
|
SCR_tdst_Sect_Open *pSectOpen;
|
|
CString csSectionName, csCompleteSectionName, csActionName;
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
UINT iPos;
|
|
|
|
// parse mec environment file
|
|
SCR_fn_v_RdL0_OpenFile((char*)(LPCSTR) m_csVisEnvFileName);
|
|
|
|
// get open file
|
|
pFile = SCR_fnp_st_RdL0_GetOpenFile((char*)(LPCSTR) m_csVisEnvFileName);
|
|
|
|
// get all existing sections
|
|
iPos = 0;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_SectionDes, iPos, pSectionDes, pFile->stSectionsDes);
|
|
while (pSectionDes)
|
|
{
|
|
// get corresponding section name
|
|
csSectionName = pSectionDes->stBuffers.p_szBufferCompleteName;
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
csActionName = szActionName;
|
|
if (csActionName == "VisualEnv")
|
|
{
|
|
// is section already loaded ?
|
|
pSectOpen = SCR_fnp_st_RdL0_GetOpenSection((char*)(LPCSTR) csSectionName, 0);
|
|
if (pSectOpen)
|
|
{
|
|
csCompleteSectionName = m_csMECRefPath + csSectionName;
|
|
pLinkValue = SCR_fnp_st_Link_SearchKey(GLI_fn_p_stGetVisualEnvironementLinkTable(), (char *)(LPCSTR) csCompleteSectionName);
|
|
if ((pLinkValue)&&(SCR_M_e_Link_GetState(pLinkValue) == SCR_ELS_Link_Initialized))
|
|
hVisEnv = (ACP_tdxHandleToVisualEnvironment) SCR_M_ul_Link_GetValue(pLinkValue);
|
|
pVisEnv = GetOrBuildVisEnvironment(hVisEnv);
|
|
}
|
|
// section not loaded => load it
|
|
else
|
|
{
|
|
// load engine struct
|
|
p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char*)(LPCSTR) csSectionName, SCR_CDF_uw_Anl_Normal);
|
|
hVisEnv = (ACP_tdxHandleToVisualEnvironment) SCR_M_ul_RdL0_ExtractLongValue(p_stValues, 0);
|
|
// get parameters
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
// create environment
|
|
pVisEnv = new SECT_VisEnvironment(this, hVisEnv, FALSE, szName, szFileName, TRUE);
|
|
}
|
|
}
|
|
// next section
|
|
iPos +=1;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_SectionDes, iPos, pSectionDes, pFile->stSectionsDes);
|
|
}
|
|
}
|
|
*/
|
|
|
|
/*===========================================================================
|
|
* Description: load all surfaces in file
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::fn_vLoadSurfaces (void)
|
|
{
|
|
SCR_tdst_Anl_SectionDes *pSectionDes;
|
|
SRF_tdxHandleToSurface hSurf = NULL;
|
|
SCR_tdst_Link_Value *pLinkValue;
|
|
SCR_tdst_Cxt_Values *p_stValues;
|
|
SCR_tdst_File_Open *pFile;
|
|
SCR_tdst_Sect_Open *pSectOpen;
|
|
WIN32_FIND_DATA stFindFileData;
|
|
SECT_Surface *pSurf = NULL;
|
|
CString csSectionName, csCompleteSectionName;
|
|
CString csSurfFileName, csFileName;
|
|
HANDLE hFind;
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szName[SCR_CV_ui_Cfg_MaxLenName];
|
|
UINT iPos;
|
|
|
|
// get surface filename
|
|
csFileName = fn_zsGetActualLevelFilename(szFileName, "srf");
|
|
csSurfFileName = csFileName.Mid(m_csSURFRefPath.GetLength());
|
|
// check if file exists
|
|
hFind = FindFirstFile((LPCSTR)csFileName, &stFindFileData);
|
|
if (hFind == INVALID_HANDLE_VALUE)
|
|
return;
|
|
|
|
// parse surface file
|
|
SCR_fn_v_RdL0_OpenFile((char*)(LPCSTR) csSurfFileName);
|
|
|
|
// get open file
|
|
pFile = SCR_fnp_st_RdL0_GetOpenFile((char*)(LPCSTR) csSurfFileName);
|
|
|
|
// get all existing sections
|
|
iPos = 0;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_SectionDes, iPos, pSectionDes, pFile->stSectionsDes);
|
|
while (pSectionDes)
|
|
{
|
|
// get corresponding section name
|
|
csSectionName = pSectionDes->stBuffers.p_szBufferCompleteName;
|
|
// check if this is a surface
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
if (!strcmp(szActionName, C_szSurfaceActionName))
|
|
{
|
|
// is section already loaded ?
|
|
pSectOpen = SCR_fnp_st_RdL0_GetOpenSection((char*)(LPCSTR) csSectionName, 0);
|
|
if (pSectOpen)
|
|
{
|
|
csCompleteSectionName = m_csSURFRefPath + csSectionName;
|
|
// search link table for engine struct
|
|
pLinkValue = SCR_fnp_st_Link_SearchKey(SRF_GetSurfaceLinkTable(), (char *)(LPCSTR) csCompleteSectionName);
|
|
if ((pLinkValue)&&(SCR_M_e_Link_GetState(pLinkValue) == SCR_ELS_Link_Initialized))
|
|
hSurf = (SRF_tdxHandleToSurface) SCR_M_ul_Link_GetValue(pLinkValue);
|
|
pSurf = GetOrBuildSurface(hSurf);
|
|
}
|
|
// section not loaded => load it
|
|
else
|
|
{
|
|
// load engine struct
|
|
p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char*)(LPCSTR) csSectionName, SCR_CDF_uw_Anl_Normal);
|
|
hSurf = (SRF_tdxHandleToSurface) SCR_M_ul_RdL0_ExtractLongValue(p_stValues, 0);
|
|
// get parameters
|
|
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, szFileName, szActionName, szName);
|
|
// create environment
|
|
pSurf = new SECT_Surface(this, hSurf, FALSE, szName, szFileName);
|
|
}
|
|
// update height index
|
|
fn_vUpdateHeightIndex(pSurf);
|
|
}
|
|
// next section
|
|
iPos +=1;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_SectionDes, iPos, pSectionDes, pFile->stSectionsDes);
|
|
}
|
|
}
|
|
*/
|
|
|
|
//#################################################################################
|
|
// PREFERENCES
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Save dialog dimensions
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vSaveDialogsPreferences (void)
|
|
{
|
|
CString csFileName;
|
|
CString csDimension;
|
|
BOOL bRes = TRUE;
|
|
|
|
csFileName = M_GetMainApp()->m_csEditorDataPath + "Objects\\" + C_szSectorIniFile;
|
|
// Sector Left Frame
|
|
if (m_pCurrentLeftFrame == m_pSectorLeftFrame)
|
|
{
|
|
// left frame width
|
|
csDimension.Format("%ld", m_pCurrentLeftFrame->m_oCurPos.right - m_pCurrentLeftFrame->m_oCurPos.left);
|
|
bRes &= WritePrivateProfileString ("Preference", "Sector Left Frame Width", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
// dialogs dimensions
|
|
csDimension.Format("%ld", m_pCurrentLeftFrame->GetPaneSize(0));
|
|
bRes &= WritePrivateProfileString ("Preference", "Sector DialogList Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentLeftFrame->GetPaneSize(1));
|
|
bRes &= WritePrivateProfileString ("Preference", "Sector SelectMode Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentLeftFrame->GetPaneSize(2));
|
|
bRes &= WritePrivateProfileString ("Preference", "Sector EditedSector Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentLeftFrame->GetPaneSize(3));
|
|
bRes &= WritePrivateProfileString ("Preference", "SelectedSector Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
}
|
|
//Shaitan Clean Env
|
|
/*
|
|
// Env Left Frame
|
|
else
|
|
{
|
|
// left frame width
|
|
csDimension.Format("%ld", m_pCurrentLeftFrame->m_oCurPos.right - m_pCurrentLeftFrame->m_oCurPos.left);
|
|
bRes &= WritePrivateProfileString ("Preference", "Env Left Frame Width", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
// dialogs dimensions
|
|
csDimension.Format("%ld", m_pCurrentLeftFrame->GetPaneSize(0));
|
|
bRes &= WritePrivateProfileString ("Preference", "Env DialogList Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentLeftFrame->GetPaneSize(1));
|
|
bRes &= WritePrivateProfileString ("Preference", "Env SelectMode Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentLeftFrame->GetPaneSize(2));
|
|
bRes &= WritePrivateProfileString ("Preference", "Env EditedSector Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentLeftFrame->GetPaneSize(3));
|
|
bRes &= WritePrivateProfileString ("Preference", "EnvironmentList Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
}
|
|
*/
|
|
// Sector Bottom Frame
|
|
if (m_pCurrentBottomFrame == m_pSectorBottomFrame)
|
|
{
|
|
// bottom frame width
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->m_oCurPos.bottom - m_pCurrentBottomFrame->m_oCurPos.top);
|
|
bRes &= WritePrivateProfileString ("Preference", "Sector Bottom Frame Height", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
// dialogs dimensions
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->GetPaneSize(0));
|
|
bRes &= WritePrivateProfileString ("Preference", "GraphicList Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->GetPaneSize(1));
|
|
bRes &= WritePrivateProfileString ("Preference", "CollisionList Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->GetPaneSize(2));
|
|
bRes &= WritePrivateProfileString ("Preference", "ActivityList Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->GetPaneSize(3));
|
|
bRes &= WritePrivateProfileString ("Preference", "SoundList Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->GetPaneSize(4));
|
|
bRes &= WritePrivateProfileString ("Preference", "SoundEvent Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
}
|
|
//Shaitan Clean Env
|
|
/*
|
|
// Env Bottom Frame
|
|
else
|
|
{
|
|
// bottom frame width
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->m_oCurPos.bottom - m_pCurrentBottomFrame->m_oCurPos.top);
|
|
bRes &= WritePrivateProfileString ("Preference", "Env Bottom Frame Height", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
// dialogs dimensions
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->GetPaneSize(0));
|
|
bRes &= WritePrivateProfileString ("Preference", "Surfaces Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->GetPaneSize(1));
|
|
bRes &= WritePrivateProfileString ("Preference", "Environments Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->GetPaneSize(2));
|
|
bRes &= WritePrivateProfileString ("Preference", "Environment Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->GetPaneSize(3));
|
|
bRes &= WritePrivateProfileString ("Preference", "MecEnvironment Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
csDimension.Format("%ld", m_pCurrentBottomFrame->GetPaneSize(4));
|
|
bRes &= WritePrivateProfileString ("Preference", "VisEnvironment Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
}
|
|
*/
|
|
// message
|
|
if (!bRes)
|
|
M_GetMainWnd()->UpdateStatus("Sector Editor cannot save your preferences. Sectors.ini may have a ReadOnly status ?", C_STATUSPANE_INFOS, C_STATUS_WARNING);
|
|
else
|
|
M_GetMainWnd()->UpdateStatus("Preferences saved", C_STATUSPANE_INFOS, C_STATUS_NORMAL);
|
|
}
|
|
|
|
|
|
|
|
//#################################################################################
|
|
// WATER EFFECT
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Reinit list of surface to draw
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//Shaitan Clean Env
|
|
/*
|
|
void Sector_Interface::fn_vUpdateSurfaceList (BOOL bOnlyCurrentSurfaces)
|
|
{
|
|
CPA_SpecificInterface *pEditor;
|
|
CPA_BaseObjectList *pListObject;
|
|
CPA_SuperObject *pSuperObject;
|
|
CPA_BaseObject *pElem;
|
|
SECT_SurfElem *pSurfElem;
|
|
SECT_Surface *pSurface;
|
|
Sector_Object *pSector;
|
|
Position pos;
|
|
POSITION pos1;
|
|
|
|
// reinit list
|
|
pEditor = GetInterface()->GetSpecificInterface();
|
|
pEditor->fn_vUpdateSurfaces(FALSE);
|
|
pEditor->fn_vReinitSurfaceList();
|
|
// get sector list
|
|
if (bOnlyCurrentSurfaces)
|
|
{
|
|
pListObject = GetBaseObjectList(C_szSectorTypeName);
|
|
// check each sector
|
|
for (pElem = pListObject->GetHeadElement(pos); pElem;
|
|
pElem = pListObject->GetNextElement(pos))
|
|
{
|
|
pSector = (Sector_Object *) pElem;
|
|
for (pSurfElem = pSector->GetSurfaceList()->GetHeadElement(pos1); pSurfElem;
|
|
pSurfElem = pSector->GetSurfaceList()->GetNextElement(pos1))
|
|
{
|
|
// check each surface
|
|
pSurface = pSurfElem->GetSurface();
|
|
pSuperObject = pSurface->GetSuperObject();
|
|
// update editor list
|
|
pEditor->fn_vAddSurfaceInList(pSuperObject);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pListObject = GetBaseObjectList(C_szSurfaceTypeName);
|
|
// check each sector
|
|
for (pElem = pListObject->GetHeadElement(pos); pElem;
|
|
pElem = pListObject->GetNextElement(pos))
|
|
{
|
|
pSurface = (SECT_Surface *) pElem;
|
|
pSuperObject = pSurface->GetSuperObject();
|
|
// update editor list
|
|
pEditor->fn_vAddSurfaceInList(pSuperObject);
|
|
}
|
|
}
|
|
|
|
pEditor->fn_vUpdateSurfaces(TRUE);
|
|
}
|
|
*/
|
|
|
|
//#################################################################################
|
|
// BORDERS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Hide or display one border
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface ::fn_vDisplayBorder (Sector_Object *pSector, BOOL bDisplay, BOOL bUpdate)
|
|
{
|
|
// check if there is a border
|
|
if (pSector->GetBorder())
|
|
{
|
|
if (bDisplay)
|
|
{
|
|
GetInterface()->fn_bInsertObjectInHierarchy(pSector->GetBorder(), pSector->GetSuperObject(), FALSE, FALSE, FALSE, FALSE);
|
|
pSector->GetBorder()->SetSuperObjectOwner(pSector->GetSuperObject());
|
|
}
|
|
else
|
|
GetInterface()->fn_bDeleteObjectInHierarchy(pSector->GetBorder(), FALSE, FALSE, FALSE, FALSE);
|
|
}
|
|
// update dialogs
|
|
if (bUpdate)
|
|
{
|
|
if (fn_bIsCurrentEditor())
|
|
fn_vReinitEditor(m_pEditedSector);
|
|
else
|
|
GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
|
|
}
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Hide or display borders
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface ::fn_vDisplayBorders (BOOL bDisplay)
|
|
{
|
|
CPA_BaseObjectList *pListObject;
|
|
CPA_BaseObject *pElem;
|
|
Sector_Object *pSector;
|
|
Position pos;
|
|
|
|
if (bDisplay == m_bDisplayBorders)
|
|
return;
|
|
|
|
// get sector list
|
|
pListObject = GetBaseObjectList(C_szSectorTypeName);
|
|
// update each sector
|
|
for (pElem = pListObject->GetHeadElement(pos); pElem;
|
|
pElem = pListObject->GetNextElement(pos))
|
|
{
|
|
pSector = (Sector_Object *) pElem;
|
|
fn_vDisplayBorder(pSector, bDisplay, FALSE);
|
|
}
|
|
// update flag
|
|
m_bDisplayBorders = bDisplay;
|
|
// update dialogs
|
|
if (fn_bIsCurrentEditor())
|
|
fn_vReinitEditor(m_pEditedSector);
|
|
else
|
|
GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
|
|
}
|
|
|
|
//#################################################################################
|
|
// VIRTUAL
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Check the virtual status of the sector can be changed
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bCanChangeVirtual (CPA_SuperObject *pSector, BOOL bVirtual)
|
|
{
|
|
Sector_Object *pSectObj;
|
|
|
|
pSectObj = (Sector_Object *) pSector->GetObject();
|
|
|
|
if (pSectObj->fn_bIsVirtual() == bVirtual)
|
|
return FALSE;
|
|
|
|
// if sector must become virtual => no test
|
|
if (bVirtual)
|
|
return TRUE;
|
|
|
|
// if sector must become non virtual => must have graphic child
|
|
else
|
|
return (pSector->GetSuperObjectFirstChild() != NULL);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Update the virtual status and the border of all sectors
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vUpdateAllVirtuals (void)
|
|
{
|
|
CPA_BaseObjectList *pListObject;
|
|
CPA_BaseObject *pElem;
|
|
Sector_Object *pSector;
|
|
Position pos;
|
|
|
|
// get sector list
|
|
pListObject = GetBaseObjectList(C_szSectorTypeName);
|
|
// update each sector
|
|
for (pElem = pListObject->GetHeadElement(pos); pElem;
|
|
pElem = pListObject->GetNextElement(pos))
|
|
{
|
|
pSector = (Sector_Object *) pElem;
|
|
// if a sector has graphic childs, it is not virtual
|
|
if (pSector->fn_bIsVirtual() && pSector->GetSuperObject()->GetSuperObjectFirstChild())
|
|
{
|
|
pSector->fn_vSetVirtual(FALSE);
|
|
if (m_bDisplayBorders)
|
|
fn_vDisplayBorder(pSector, TRUE, FALSE);
|
|
}
|
|
}
|
|
// update all
|
|
fn_vReinitEditor(m_pEditedSector);
|
|
}
|
|
|
|
//#################################################################################
|
|
// DIALOG LIST
|
|
//#################################################################################
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Give all the list to the dialog
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::GetListsForDialog (CPA_DialogList *pDialog)
|
|
{
|
|
// List All Types
|
|
pDialog->fn_vAddANewList("Sectors", GetInterface()->GetSortedListByType(C_szSectorTypeName, this),
|
|
NULL, &m_oStateIconList, E_lo_Alpha, FALSE,
|
|
C_lDrawState | C_lDrawName, FALSE);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Give the list by default
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vInitDefaultParameters (CPA_DialogList *pDialog)
|
|
{
|
|
pDialog->SetPermanentHeaders(FALSE);
|
|
pDialog->SetDefaultTypeName("Sectors");
|
|
pDialog->SetDefaultTestName("No Test");
|
|
pDialog->SetDefaultButtonState(FALSE);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Get state icon for list element
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
int Sector_Interface::GetStateForListItem (CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject)
|
|
{
|
|
CPA_SuperObject *pSupObj;
|
|
Sector_Object *pSector;
|
|
|
|
// find good icon
|
|
pSupObj = (CPA_SuperObject *) pObject;
|
|
pSector = (Sector_Object *) pSupObj->GetObject();
|
|
// check state
|
|
return ( (pSector->fn_bIsVirtual()) ? 2 : 1);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Get colors for list item
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::GetColorsForListItem (CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject,
|
|
COLORREF *pRectColor, COLORREF *pTextColor)
|
|
{
|
|
CPA_SuperObject *pSector;
|
|
|
|
// init parameters
|
|
pSector = (CPA_SuperObject *) pObject;
|
|
|
|
// edited sector => red rect
|
|
if (pSector == GetEditedSector())
|
|
{
|
|
*pRectColor = RGB (200, 0, 0);
|
|
*pTextColor = RGB (254, 254, 254);
|
|
}
|
|
// selected sector => blue rect
|
|
else if ((m_eEditMode == E_em_EditSector)&&(pSector == m_pSelectedSector))
|
|
{
|
|
*pRectColor = RGB (0, 0, 200);
|
|
*pTextColor = RGB (254, 254, 254);
|
|
}
|
|
// list sector => green text
|
|
else if ((m_eEditMode == E_em_EditList)&&(fn_bIsInActiveLists(pSector)))
|
|
{
|
|
*pRectColor = GetSysColor(COLOR_WINDOW);
|
|
*pTextColor = RGB (0, 200, 0);
|
|
}
|
|
//Shaitan Clean Env
|
|
/*
|
|
// env selected sector => blue text
|
|
else if ((m_eEditMode == E_em_EditEnv)&&(m_oSelectList.Find(pSector, NULL) != NULL))
|
|
{
|
|
*pRectColor = GetSysColor(COLOR_WINDOW);
|
|
*pTextColor = RGB (0, 0, 254);
|
|
}
|
|
*/
|
|
// virtual sector
|
|
else if (!fn_bIsAvailableForList(pSector))
|
|
{
|
|
*pRectColor = GetSysColor(COLOR_WINDOW);
|
|
*pTextColor = RGB (126, 126, 126);
|
|
}
|
|
// normal sector => black
|
|
else
|
|
{
|
|
*pRectColor = GetSysColor(COLOR_WINDOW);
|
|
*pTextColor = RGB (0, 0, 0);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Update Editor when selection changes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bOnSelChangeListObjects (CPA_DialogList *pDialog, CString csTypeName, CPA_BaseObject *pSelectedObject, BOOL bUnselect)
|
|
{
|
|
CPA_SuperObject *pSector;
|
|
|
|
// unselect => nothing
|
|
if (bUnselect)
|
|
return TRUE;
|
|
|
|
pSector = (CPA_SuperObject *) pSelectedObject;
|
|
|
|
// update selection
|
|
switch (m_eEditMode)
|
|
{
|
|
// sector mode => select or unselect
|
|
case E_em_EditSector:
|
|
fn_vSelectNewSector((pSector != m_pSelectedSector) ? pSector : NULL);
|
|
break;
|
|
// list mode => add or remove from list
|
|
case E_em_EditList:
|
|
if ((pSector)&&(pSector != m_pEditedSector)&&(fn_bIsAvailableForList(pSector)))
|
|
fn_vUpdateActiveLists(pSector);
|
|
break;
|
|
// env mode => no action
|
|
//Shaitan Clean Env
|
|
/*
|
|
case E_em_EditEnv:
|
|
if ((pSector)&&(pSector != m_pEditedSector))
|
|
fn_vUpdateSelectList(pSector);
|
|
break;
|
|
*/
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Update Editor when edition changes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bOnDblClkListObjects (CPA_DialogList *pDialog, CString csTypeName, CPA_BaseObject *pSelectedObject)
|
|
{
|
|
CPA_SuperObject *pSector;
|
|
|
|
pSector = (CPA_SuperObject *) pSelectedObject;
|
|
|
|
switch (m_eEditMode)
|
|
{
|
|
// sector mode => no update
|
|
case E_em_EditSector:
|
|
break;
|
|
// list mode => cancel simple click
|
|
case E_em_EditList:
|
|
if ((pSector)&&(pSector != m_pEditedSector)&&(fn_bIsAvailableForList(pSector)))
|
|
fn_vUpdateActiveLists(pSector);
|
|
break;
|
|
// env mode => update select list
|
|
//Shaitan Clean Env
|
|
/*
|
|
case E_em_EditEnv:
|
|
// update select list
|
|
if ((pSector)&&(pSector != m_pEditedSector))
|
|
fn_vUpdateSelectList(pSector);
|
|
break;
|
|
*/
|
|
}
|
|
|
|
// change edited sector
|
|
if (pSector != m_pEditedSector)
|
|
fn_vReinitEditor(pSector);
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Check if sector is in edited list
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bIsInActiveLists (CPA_SuperObject *pSector)
|
|
{
|
|
SECT_ListBase *pCurrentList;
|
|
Sector_Object *pSectObject;
|
|
tdeTypeList eList;
|
|
int iList;
|
|
int nActive = 0;
|
|
|
|
if ((!m_pEditedSector)||(pSector == m_pEditedSector))
|
|
return FALSE;
|
|
|
|
// get edited sector
|
|
pSectObject = (Sector_Object *) m_pEditedSector->GetObject();
|
|
|
|
// check each list
|
|
for (iList = 0; iList < C_NumberOfLists; iList++)
|
|
{
|
|
eList = (tdeTypeList) iList;
|
|
// check only active list
|
|
if (GetListActivity(eList))
|
|
{
|
|
nActive++;
|
|
pCurrentList = pSectObject->GetCurrentList(eList);
|
|
if (!pCurrentList->GetElementWithSector(pSector))
|
|
return FALSE;
|
|
}
|
|
}
|
|
// check if there is an active list
|
|
return (nActive > 0);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Check if sector is valid for edited list
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL Sector_Interface::fn_bIsAvailableForList (CPA_SuperObject *pSector)
|
|
{
|
|
Sector_Object *pSectObj;
|
|
|
|
// get sector object
|
|
pSectObj = (Sector_Object *)pSector->GetObject();
|
|
if (!pSectObj)
|
|
return FALSE;
|
|
|
|
// only in ListMode
|
|
if (m_eEditMode != E_em_EditList)
|
|
return TRUE;
|
|
|
|
// no objection
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Get the first active list
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
tdeTypeList Sector_Interface::GetFirstActiveList (void)
|
|
{
|
|
int iList = 0;
|
|
|
|
// get the first active list
|
|
while (iList < C_NumberOfLists)
|
|
{
|
|
if (m_aListActivity[iList++] != 0)
|
|
return ((tdeTypeList)(iList - 1));
|
|
}
|
|
// no list is active
|
|
return E_NoActiveList;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Get the sectors that are common to all active lists
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vGetSectorsToDraw (CPA_List<CPA_SuperObject> *pSectorList)
|
|
{
|
|
SECT_ElementBase *pElem;
|
|
SECT_ListBase *pCurrentList;
|
|
Sector_Object *pSectObject;
|
|
tdeTypeList eList;
|
|
POSITION pos;
|
|
|
|
// init the list
|
|
pSectorList->RemoveAll();
|
|
|
|
|
|
// check if there is an active list
|
|
eList = GetFirstActiveList();
|
|
if (eList == E_NoActiveList)
|
|
return;
|
|
|
|
// get the corresponding list
|
|
pSectObject = (Sector_Object *) m_pEditedSector->GetObject();
|
|
pCurrentList = pSectObject->GetCurrentList(eList);
|
|
// check all sectors of this list
|
|
for (pElem = pCurrentList->GetHeadElementBase(pos); pElem;
|
|
pElem = pCurrentList->GetNextElementBase(pos))
|
|
{
|
|
if (fn_bIsInActiveLists(pElem->GetSector()))
|
|
pSectorList->AddTail(pElem->GetSector());
|
|
}
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: update the copy list with all the sectors of the list
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vCopySectorList (CPA_SuperObject *pSector, tdeTypeList eList)
|
|
{
|
|
SECT_ElementBase *pElem;
|
|
SECT_ListBase *pCurrentList;
|
|
Sector_Object *pSectObject;
|
|
POSITION pos;
|
|
|
|
// RAZ
|
|
m_oCopyOfSectorList.RemoveAll();
|
|
|
|
// get current list
|
|
if (eList != E_NoActiveList)
|
|
{
|
|
// get the corresponding list
|
|
pSectObject = (Sector_Object *) pSector->GetObject();
|
|
pCurrentList = pSectObject->GetCurrentList(eList);
|
|
// check all sectors of this list
|
|
for (pElem = pCurrentList->GetHeadElementBase(pos); pElem;
|
|
pElem = pCurrentList->GetNextElementBase(pos))
|
|
m_oCopyOfSectorList.AddTail(pElem->GetSector());
|
|
}
|
|
// get multi list
|
|
else if (pSector == m_pEditedSector)
|
|
fn_vGetSectorsToDraw(&m_oCopyOfSectorList);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: paste the copied list
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vPasteSectorList (CPA_SuperObject *pSector, tdeTypeList eList)
|
|
{
|
|
SECT_ModifCopyList *pModif;
|
|
|
|
pModif = new SECT_ModifCopyList(this, E_tm_CopyList, &m_oCopyOfSectorList, eList);
|
|
|
|
M_GetEditManager()->AskFor(pModif);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: paste the copied list
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void Sector_Interface::fn_vLinkNearestSectors (void)
|
|
{
|
|
CPA_List<CPA_SuperObject> oSectorList;
|
|
SECT_ModifCopyList *pModif;
|
|
CPA_BaseObjectList *pListObject;
|
|
MTH3D_tdstVector stMinPoint, stMaxPoint;
|
|
MTH3D_tdstVector stMin, stMax;
|
|
CPA_BaseObject *pElem;
|
|
Sector_Object *pSector;
|
|
MTH_tdxReal xDistance;
|
|
Position pos;
|
|
|
|
// resources
|
|
HINSTANCE hOldInst = AfxGetResourceHandle();
|
|
AfxSetResourceHandle (GetDLLIdentity()->hModule);
|
|
|
|
// init list
|
|
oSectorList.RemoveAll();
|
|
|
|
// call distance dialog
|
|
if (m_pDialogDistance->DoModal() == IDOK)
|
|
{
|
|
// get min and max point of edited sector
|
|
pSector = (Sector_Object *) m_pEditedSector->GetObject();
|
|
pSector->GetMinPointInBorder(&stMinPoint);
|
|
pSector->GetMaxPointInBorder(&stMaxPoint);
|
|
// add distance given by dialog
|
|
xDistance = (MTH_tdxReal) m_pDialogDistance->GetLinkDistance();
|
|
MTH3D_M_vAddScalarVector(&stMinPoint, - xDistance, &stMinPoint);
|
|
MTH3D_M_vAddScalarVector(&stMaxPoint, xDistance, &stMaxPoint);
|
|
// check all sectors in the list
|
|
pListObject = GetBaseObjectList(C_szSectorTypeName);
|
|
// check each sector
|
|
for (pElem = pListObject->GetHeadElement(pos); pElem;
|
|
pElem = pListObject->GetNextElement(pos))
|
|
{
|
|
pSector = (Sector_Object *) pElem;
|
|
//check if sector is already linked
|
|
if (!fn_bIsInActiveLists(pSector->GetSuperObject()) &&
|
|
(pSector->GetSuperObject() != m_pEditedSector) &&
|
|
(pSector->GetBorder() != NULL))
|
|
{
|
|
// get sector border
|
|
pSector->GetMinPointInBorder(&stMin);
|
|
pSector->GetMaxPointInBorder(&stMax);
|
|
// test intersection
|
|
if ((stMin.xX < stMaxPoint.xX) &&
|
|
(stMin.xY < stMaxPoint.xY) &&
|
|
(stMin.xZ < stMaxPoint.xZ) &&
|
|
(stMax.xX > stMinPoint.xX) &&
|
|
(stMax.xY > stMinPoint.xY) &&
|
|
(stMax.xZ > stMinPoint.xZ))
|
|
oSectorList.AddTail(pSector->GetSuperObject());
|
|
}
|
|
}
|
|
// modify links
|
|
if (oSectorList.GetCount() > 0)
|
|
{
|
|
pModif = new SECT_ModifCopyList(this, E_tm_CopyList, &oSectorList, E_NoActiveList);
|
|
M_GetEditManager()->AskFor(pModif);
|
|
}
|
|
}
|
|
|
|
AfxSetResourceHandle(hOldInst);
|
|
}
|