1488 lines
52 KiB
C++
1488 lines
52 KiB
C++
/*=========================================================================
|
|
*
|
|
* TBKinter.hpp : Banks DLL Interface - implementation
|
|
*
|
|
*
|
|
* Version 1.0
|
|
* Creation date 10/06/99
|
|
* Revision date
|
|
*
|
|
* Shaitan
|
|
*=======================================================================*/
|
|
|
|
#include <direct.h>
|
|
|
|
#include "stdafx.h"
|
|
#include "acp_base.h"
|
|
|
|
#include "TBKinter.hpp"
|
|
#include "TBKobj.hpp"
|
|
#include "TBKdName.hpp"
|
|
|
|
#include "TBKres.h"
|
|
|
|
#include "_EditID.h"
|
|
#include "TUT.h"
|
|
|
|
#include "incGAM.h"
|
|
#include "DPT.h"
|
|
|
|
// infos
|
|
static CString TBK_g_csName = "Banks Editor";
|
|
static CString TBK_g_csAuthor = "Chantal Oury";
|
|
static CString TBK_g_csVersion = "V 1.0.0 10/06/99";
|
|
static CString TBK_g_csFrenchHelpFile = "";
|
|
static CString TBK_g_csEnglishHelpFile = "";
|
|
|
|
|
|
//#################################################################################
|
|
// Defines
|
|
//#################################################################################
|
|
|
|
// DLL global definition
|
|
tdstDLLIdentity TBK_g_stBanksIdentity;
|
|
|
|
// initialisation files
|
|
#define TBK_C_szBanksKeyIniFile "TBK\\TBKKeys.ini"
|
|
#define TBK_C_szBanksPrefIniFile "TBK\\TBKPref.ini"
|
|
|
|
// keyboard configuration
|
|
#define KA_ID_BANK1 1
|
|
#define KA_ID_BANK2 2
|
|
#define KA_ID_BANK3 3
|
|
#define KA_ID_BANK4 4
|
|
#define KA_ID_BANK5 5
|
|
#define KA_ID_BANK6 6
|
|
|
|
#define KA_ID_COMMON 10
|
|
|
|
#define KA_ID_DELETE 20
|
|
|
|
static tdstKeyboardActionDef TBK_g_Keyboard[] =
|
|
{
|
|
{ "Add To Bank 1", KA_ID_BANK1 },
|
|
{ "Add To Bank 2", KA_ID_BANK2 },
|
|
{ "Add To Bank 3", KA_ID_BANK3 },
|
|
{ "Add To Bank 4", KA_ID_BANK4 },
|
|
{ "Add To Bank 5", KA_ID_BANK5 },
|
|
{ "Add To Bank 6", KA_ID_BANK6 },
|
|
{ "Add To Common", KA_ID_COMMON },
|
|
{ "Delete Bank", KA_ID_DELETE },
|
|
{ NULL, 0 },
|
|
};
|
|
|
|
// menus
|
|
#define TBK_C_uiOpenID 1
|
|
#define TBK_C_uiCloseID 2
|
|
#define TBK_C_ui_SaveDialogsID 3
|
|
|
|
// banks
|
|
#define TBK_C_lMaxNumberOfBanks 7
|
|
|
|
|
|
|
|
//#################################################################################
|
|
// Constructor / Destructor
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Constructor
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
TBK_BanksInterface::TBK_BanksInterface (void)
|
|
{
|
|
// ************************** private internal
|
|
m_p_stDLLIdentity = &TBK_g_stBanksIdentity;
|
|
|
|
// 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(TBK_g_csName, TBK_g_csAuthor, TBK_g_csVersion, TBK_g_csFrenchHelpFile, TBK_g_csEnglishHelpFile);
|
|
// init parameters
|
|
SetCurrent(FALSE);
|
|
|
|
// init members
|
|
m_pSelectedSector = NULL;
|
|
m_pSelectedBank = NULL;
|
|
m_pCurrentBank = NULL;
|
|
m_pCommonBank = NULL;
|
|
m_lBankIndex = 1;
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Destructor
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
TBK_BanksInterface::~TBK_BanksInterface (void)
|
|
{
|
|
// keyboard
|
|
delete m_pKeyboard;
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// INITS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Inits for Scripts
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vJustAfterRegistered (void)
|
|
{
|
|
// register bank type
|
|
CString a_csType[] = { C_szBankTypeName };
|
|
fn_vRegisterObjectsType(a_csType, 1);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Init Editor
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vConstruct()
|
|
{
|
|
CString csFileName;
|
|
char szDimension[256];
|
|
int iDim;
|
|
|
|
// Keys
|
|
m_pKeyboard = new CPA_KeyActionConfiguration(TBK_C_szBanksKeyIniFile, TBK_g_Keyboard);
|
|
m_pKeyboard->mfn_vSetObjectName("Banks Editor");
|
|
|
|
// preference file
|
|
csFileName = M_GetMainApp()->m_csEditorDataPath + "Tools\\" + TBK_C_szBanksPrefIniFile;
|
|
|
|
// left frame width
|
|
GetPrivateProfileString ("Preference", "Banks Left Frame Width", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Left Frame Window
|
|
m_pLeftFrame = new CSplitFrame;
|
|
m_pLeftFrame->CreateBase("LIST", 1, 2, GetMainWorld());
|
|
m_pLeftFrame->m_iInitWidth = (iDim > 0) ? iDim : 180;
|
|
m_pLeftFrame->mfn_vEnableCaption(FALSE);
|
|
m_pLeftFrame->m_stWinBottom.cLinkSame = FRM_C_MoveRight;
|
|
m_pLeftFrame->CreateSplitter(C_cVerticalSplitter, 2);
|
|
|
|
// DialogList Dimension
|
|
GetPrivateProfileString ("Preference", "Banks DialogList Dimension", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
|
|
iDim = atoi(szDimension);
|
|
// Dialog List
|
|
m_pDialogList = new CPA_DialogList;
|
|
m_pDialogList->fn_vInitDialog(this, m_pLeftFrame);
|
|
m_pLeftFrame->SetPaneView(0, m_pDialogList, "BANKS", (iDim > 0) ? iDim : 240);
|
|
// register dialog list for tutorial
|
|
TUT_M_vGetTutDll();
|
|
TUT_M_vRegisterControl (m_pDialogList->GetComboHandle(), "TBK_DLSECT_COMBO_CHOICE", TUT_e_ComboBox);
|
|
TUT_M_vRegisterControl (m_pDialogList->GetListHandle(), "TBK_DLSECT_LIST_SECTORS", TUT_e_ListBox);
|
|
TUT_M_vRegisterControl (m_pDialogList->GetTreeHandle(), "TBK_DLSECT_TREE_SECTORS", TUT_e_TreeCtrl);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//#################################################################################
|
|
// EDITOR - ENGINE
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Inits for Engine Loop
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vBeforeEngine (void)
|
|
{
|
|
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Inits for Editor Mode
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vBeforeEditor (void)
|
|
{
|
|
m_pLeftFrame->SetActiveView(m_pDialogList, TRUE);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Inits for New Level
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vLevelChanges (void)
|
|
{
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Update for New Level
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vLevelHasChanged (void)
|
|
{
|
|
CPA_List<CPA_SuperObject> *pListOfSectors;
|
|
SCR_tdpfn_Anl_Callback pHeaderCallback;
|
|
SCR_tdpfn_Anl_Callback pCommonCallback;
|
|
SCR_tdpfn_Anl_Callback pBankCallback;
|
|
SCR_tdst_Anl_Callback *pCallback;
|
|
CPA_SuperObject *pSector;
|
|
POSITION pos;
|
|
BOOL bExist;
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// register bank callback
|
|
pCallback = SCR_fnp_st_RdL0_GetRegisterCallback(C_BankSectionName, SCR_CRC_c_RdL0_ForSection);
|
|
pBankCallback = pCallback->pfn_eCallback;
|
|
SCR_fn_v_RdL0_DeleteRegisterCallback(C_BankSectionName, SCR_CRC_c_RdL0_ForSection, SCR_CDR_c_RdL0_Match);
|
|
SCR_fn_v_RdL0_RegisterCallback(C_BankSectionName, TBK_fn_eCallBackLoadBank, SCR_CRC_c_RdL0_ForSection);
|
|
|
|
// register common callback
|
|
pCallback = SCR_fnp_st_RdL0_GetRegisterCallback(C_CommonSectionName, SCR_CRC_c_RdL0_ForSection);
|
|
pCommonCallback = pCallback->pfn_eCallback;
|
|
SCR_fn_v_RdL0_DeleteRegisterCallback(C_CommonSectionName, SCR_CRC_c_RdL0_ForSection, SCR_CDR_c_RdL0_Match);
|
|
SCR_fn_v_RdL0_RegisterCallback(C_CommonSectionName, TBK_fn_eCallBackLoadCommon, SCR_CRC_c_RdL0_ForSection);
|
|
|
|
// register header callback
|
|
pCallback = SCR_fnp_st_RdL0_GetRegisterCallback(C_HeaderSectionName, SCR_CRC_c_RdL0_ForSection);
|
|
pHeaderCallback = pCallback->pfn_eCallback;
|
|
SCR_fn_v_RdL0_DeleteRegisterCallback(C_HeaderSectionName, SCR_CRC_c_RdL0_ForSection, SCR_CDR_c_RdL0_Match);
|
|
SCR_fn_v_RdL0_RegisterCallback(C_HeaderSectionName, TBK_fn_eCallBackLoadHeader, SCR_CRC_c_RdL0_ForSection);
|
|
|
|
// create or reinit the common bank
|
|
sprintf(szFileName, "%s\\%s.bnk", fn_p_szGetLevelName(), fn_p_szGetLevelName());
|
|
bExist = SCR_fn_c_RdL0_IsSectionExists(szFileName);
|
|
if (!m_pCommonBank)
|
|
m_pCommonBank = new TBK_BankObject(this, TBK_E_bt_Common, "Common", bExist);
|
|
else
|
|
{
|
|
m_pCommonBank->m_fn_vReinitSectorList();
|
|
|
|
// delete all existing banks (except common one)
|
|
CPA_BaseObjectList *pBankList = GetMainWorld()->fn_p_oGetOriginalObjectList(C_szBankTypeName);
|
|
while (pBankList->GetTail() && (pBankList->GetTail() != m_pCommonBank))
|
|
{
|
|
delete pBankList->GetTail();
|
|
}
|
|
}
|
|
|
|
// load the existing banks
|
|
if (bExist)
|
|
{
|
|
SCR_M_RdL0_SetContextLong(1, 0, this);
|
|
SCR_fn_v_RdL0_ComputeSectionName (szSectionName, szFileName, C_HeaderSectionName, "");
|
|
SCR_fnp_st_RdL0_AnalyseSection(szSectionName, SCR_CDF_uw_Anl_ForceAnalyse);
|
|
}
|
|
|
|
// complete the common bank
|
|
pListOfSectors = GetInterface()->GetObjectListByType(C_szSectorTypeName);
|
|
pos = pListOfSectors->GetHeadPosition();
|
|
while (pos)
|
|
{
|
|
pSector = pListOfSectors->GetNext(pos);
|
|
if (!m_fn_pGetBankBySector(pSector))
|
|
m_pCommonBank->m_fn_bAddSectorToBank(pSector);
|
|
}
|
|
|
|
// restore callbacks
|
|
SCR_fn_v_RdL0_DeleteRegisterCallback(C_BankSectionName, SCR_CRC_c_RdL0_ForSection, SCR_CDR_c_RdL0_Match);
|
|
SCR_fn_v_RdL0_RegisterCallback(C_BankSectionName, pBankCallback, SCR_CRC_c_RdL0_ForSection);
|
|
SCR_fn_v_RdL0_DeleteRegisterCallback(C_CommonSectionName, SCR_CRC_c_RdL0_ForSection, SCR_CDR_c_RdL0_Match);
|
|
SCR_fn_v_RdL0_RegisterCallback(C_CommonSectionName, pCommonCallback, SCR_CRC_c_RdL0_ForSection);
|
|
SCR_fn_v_RdL0_DeleteRegisterCallback(C_HeaderSectionName, SCR_CRC_c_RdL0_ForSection, SCR_CDR_c_RdL0_Match);
|
|
SCR_fn_v_RdL0_RegisterCallback(C_HeaderSectionName, pHeaderCallback, SCR_CRC_c_RdL0_ForSection);
|
|
|
|
|
|
// init bank list
|
|
m_pDialogList->fn_vInitAllLists();
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// DIALOG BAR & MENUS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Add buttons to dialog bar
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vDefineDlgBarBtnIcon (tde_DlgBarCategory wCategory, tds_DlgBarBtn *_pDlgBarBtn)
|
|
{
|
|
// add editor button
|
|
if (wCategory == C_DlgBarCategoryEditor)
|
|
{
|
|
// load icon
|
|
_pDlgBarBtn->hIcon = ::LoadIcon((HINSTANCE)(GetDLLIdentity()->hModule), MAKEINTRESOURCE(TBK_IDI_DLGBAR_ICON));
|
|
|
|
// build tool tip
|
|
CString oCst;
|
|
oCst = "Banks Editor";
|
|
if ((M_GetMainApp()) && (M_GetMainApp()->mp_oAppKeyboard))
|
|
{
|
|
oCst += " (";
|
|
oCst += M_GetMainApp()->mp_oAppKeyboard->mfn_oConvertIniStringToKeyString((const CString*)&CString("Activate Banks Editor"));
|
|
oCst += ")";
|
|
}
|
|
strcpy(_pDlgBarBtn->szToolTip, (char*)(LPCTSTR)oCst);
|
|
|
|
// update ID
|
|
_pDlgBarBtn->uID = (UINT)this;
|
|
}
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Add entries in submenus
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bDefineSubMenu (EDT_SubMenu *p_oEDTSubMenu)
|
|
{
|
|
CString csEntry;
|
|
|
|
// submenu "Editor"
|
|
if (p_oEDTSubMenu->GetSubMenuType() == C_SubMenuEditor)
|
|
{
|
|
csEntry = "Banks Editor";
|
|
csEntry += "\t";
|
|
csEntry += M_GetMainApp()->mp_oAppKeyboard->mfn_oConvertIniStringToKeyString((const CString*)&CString("Activate Banks Editor"));;
|
|
|
|
if (!fn_bIsCurrentEditor())
|
|
p_oEDTSubMenu->AddAnEntry(this, (char*)(LPCTSTR)csEntry, TBK_C_uiOpenID, FALSE);
|
|
else
|
|
p_oEDTSubMenu->AddAnEntry(this, (char*)(LPCTSTR)csEntry, TBK_C_uiCloseID, TRUE);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// submenu "Preference"
|
|
else if (p_oEDTSubMenu->GetSubMenuType() == C_SubMenuPreference)
|
|
{
|
|
// preferences
|
|
p_oEDTSubMenu->AddAnEntry(this, "Save Dialogs Dimensions", TBK_C_ui_SaveDialogsID, FALSE, TRUE);
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Answer to submenu commands
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::_OnSubMenuCommand (EDT_SubMenu *p_oEDTSubMenu,UINT uiMsgID)
|
|
{
|
|
switch (uiMsgID)
|
|
{
|
|
case TBK_C_uiOpenID:
|
|
if (!fn_bIsCurrentEditor())
|
|
GetMainWorld()->fn_bActivateEditor(this, NULL);
|
|
break;
|
|
|
|
case TBK_C_uiCloseID:
|
|
if (fn_bIsCurrentEditor())
|
|
GetMainWorld()->fn_bCloseEditor(this);
|
|
break;
|
|
|
|
// preference => dialogs
|
|
case TBK_C_ui_SaveDialogsID:
|
|
m_fn_vSaveDialogsPreferences();
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Add entries in popup menu
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bDefinePopupMenu (EDT_PopUpMenu *pPopup, CPA_List<CPA_SuperObject> *pSelection, BOOL bAsCurrentEditor)
|
|
{
|
|
if (bAsCurrentEditor)
|
|
{
|
|
pPopup->AddAnEntry(this, "Exit Banks editor", TBK_C_uiCloseID, FALSE);
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Answer to popup menu commands
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::_OnPopUpMenuCommand (UINT m_IDCmdMsg)
|
|
{
|
|
switch (m_IDCmdMsg)
|
|
{
|
|
case TBK_C_uiCloseID:
|
|
if (fn_bIsCurrentEditor())
|
|
GetMainWorld()->fn_bCloseEditor(this);
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// EDITOR
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Check if the editor can be activated
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bCanActivateEditor (CPA_List<CPA_BaseObject> *pParams)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Activate editor
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vOnActivateEditor (CPA_List<CPA_BaseObject> *pParam, BOOL bBackActivated)
|
|
{
|
|
// reinit dialog list
|
|
m_pDialogList->fn_vReinitDialog();
|
|
|
|
// reinit sector colors
|
|
CPA_BaseObjectList *pBankList = GetMainWorld()->fn_p_oGetOriginalObjectList(C_szBankTypeName);
|
|
|
|
Position pos = pBankList->GetHeadPosition();
|
|
while (pos)
|
|
{
|
|
TBK_BankObject *pBank = (TBK_BankObject *) pBankList->GetNext(pos);
|
|
pBank->m_fn_vReinitSectorColors(TRUE);
|
|
}
|
|
|
|
// activate windows
|
|
g_oFrameGest.mfn_vActivateWindow(m_pLeftFrame);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Close editor
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vOnCloseEditor (void)
|
|
{
|
|
// reinit sector colors
|
|
CPA_BaseObjectList *pBankList = GetMainWorld()->fn_p_oGetOriginalObjectList(C_szBankTypeName);
|
|
|
|
Position pos = pBankList->GetHeadPosition();
|
|
while (pos)
|
|
{
|
|
TBK_BankObject *pBank = (TBK_BankObject *) pBankList->GetNext(pos);
|
|
pBank->m_fn_vReinitSectorColors(FALSE);
|
|
}
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Gain focus
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bHasGainedFocus (void)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Loose focus
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vHasLostFocus (void)
|
|
{
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// PERMISSIONS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Selection => ??
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
tdeTypeAnswer TBK_BanksInterface::fn_bAcceptSelect (CPA_SuperObject *pEdObj, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking, tdeStatus eStatus)
|
|
{
|
|
// default handling => no selection in the editor
|
|
return (fn_bIsCurrentEditor() ? C_Refuse : C_Accept);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Changes in hierarchy
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bAcceptModifDelete (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)
|
|
{
|
|
// default handling => no changes in the editor
|
|
return (fn_bIsCurrentEditor() ? FALSE : TRUE);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::fn_bAcceptModifParent (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)
|
|
{
|
|
// default handling => no changes in the editor
|
|
return (fn_bIsCurrentEditor() ? FALSE : TRUE);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::fn_bAcceptModifCopy (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)
|
|
{
|
|
// default handling => no changes in the editor
|
|
return (fn_bIsCurrentEditor() ? FALSE : TRUE);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::fn_bAcceptModifTranslate (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)
|
|
{
|
|
// default handling => no changes in the editor
|
|
return (fn_bIsCurrentEditor() ? FALSE : TRUE);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::fn_bAcceptModifRotate (CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)
|
|
{
|
|
// default handling => no changes in the editor
|
|
return (fn_bIsCurrentEditor() ? FALSE : TRUE);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::fn_bAcceptModifScale (CPA_SuperObject *pEdObj, tdeStatus eStatus)
|
|
{
|
|
// default handling => no changes in the editor
|
|
return (fn_bIsCurrentEditor() ? FALSE : TRUE);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::fn_bAcceptModifInsert (CPA_SuperObject *pEdObj, CPA_SuperObject *pParent, tdeStatus eStatus)
|
|
{
|
|
// default handling => no changes in the editor
|
|
return (fn_bIsCurrentEditor() ? FALSE : TRUE);
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// MODIFS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Selection
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vOnSelect (CPA_SuperObject *pEdObj, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Changes in Hierarchy
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vOnModifName (CPA_SuperObject *pEdObj, CString csInitalName, CString csFinalName, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
}
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void TBK_BanksInterface::fn_vOnModifDelete (CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
}
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void TBK_BanksInterface::fn_vOnModifParent (CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
}
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void TBK_BanksInterface::fn_vOnModifCopy (CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
}
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void TBK_BanksInterface::fn_vOnModifInsert (CPA_SuperObject *pEdObj, CPA_SuperObject *pParent, tdstPosition *p_stPosition, tdeTypeModif eType, tdeStatus eStatus)
|
|
{
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Reinit World
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vOnChangeRoot (void)
|
|
{
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void TBK_BanksInterface::fn_vOnChangeWorld (void)
|
|
{
|
|
}
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
void TBK_BanksInterface::fn_vOnChangeDevice (void)
|
|
{
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// MESSAGES
|
|
//#################################################################################
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::_OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags)
|
|
{
|
|
unsigned short uwKey = m_pKeyboard->mfn_uwKeyToAction(nChar);
|
|
|
|
if (!fn_bIsCurrentEditor())
|
|
return FALSE;
|
|
|
|
switch (uwKey)
|
|
{
|
|
case KA_ID_BANK1 :
|
|
case KA_ID_BANK2 :
|
|
case KA_ID_BANK3 :
|
|
case KA_ID_BANK4 :
|
|
case KA_ID_BANK5 :
|
|
case KA_ID_BANK6 :
|
|
m_pCurrentBank = m_fn_pGetBankByIndex(uwKey);
|
|
return TRUE;
|
|
|
|
case KA_ID_COMMON :
|
|
m_pCurrentBank = m_pCommonBank;
|
|
return TRUE;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
// command not processed
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::_OnKeyUp (UINT nChar, UINT nRepCnt, UINT nFlags)
|
|
{
|
|
if (!fn_bIsCurrentEditor())
|
|
return FALSE;
|
|
|
|
switch (m_pKeyboard->mfn_uwKeyToAction(nChar))
|
|
{
|
|
case KA_ID_BANK1 :
|
|
case KA_ID_BANK2 :
|
|
case KA_ID_BANK3 :
|
|
case KA_ID_BANK4 :
|
|
case KA_ID_BANK5 :
|
|
case KA_ID_BANK6 :
|
|
case KA_ID_COMMON :
|
|
m_pCurrentBank = NULL;
|
|
return TRUE;
|
|
default:
|
|
break;
|
|
}
|
|
// command not processed
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::_OnLButtonDown (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking)
|
|
{
|
|
CPA_SuperObject *pSector;
|
|
TBK_BankObject *pPreviousBank;
|
|
|
|
if (!fn_bIsCurrentEditor())
|
|
return FALSE;
|
|
|
|
// find clicked sector
|
|
pSector = GetInterface()->GetFirstSelection(E_sm_SelectByType, xIndex, pPicking, C_szSectorTypeName);
|
|
if (!pSector || !m_pCurrentBank)
|
|
return TRUE;
|
|
|
|
// if necessary add sector to bank
|
|
if (!m_pCurrentBank->m_fn_bIsSectorInBank(pSector))
|
|
{
|
|
pPreviousBank = m_fn_pGetBankBySector(pSector);
|
|
pPreviousBank->m_fn_bRemoveSectorFromBank(pSector);
|
|
m_pCurrentBank->m_fn_bAddSectorToBank(pSector);
|
|
}
|
|
// else if possible remove sector from bank
|
|
else if (m_pCurrentBank != m_pCommonBank)
|
|
{
|
|
m_pCurrentBank->m_fn_bRemoveSectorFromBank(pSector);
|
|
m_pCommonBank->m_fn_bAddSectorToBank(pSector);
|
|
}
|
|
|
|
m_pDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
|
|
|
|
// command processed
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::_OnLButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking)
|
|
{
|
|
if (!fn_bIsCurrentEditor())
|
|
return FALSE;
|
|
|
|
// command processed
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*---------------------------------------------------------------------
|
|
---------------------------------------------------------------------*/
|
|
BOOL TBK_BanksInterface::_OnRButtonDown (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking)
|
|
{
|
|
if (!fn_bIsCurrentEditor())
|
|
return FALSE;
|
|
|
|
// command processed
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// DIALOG LIST
|
|
//#################################################################################
|
|
/*===========================================================================
|
|
* Description: Give all the list to the dialog
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::GetListsForDialog (CPA_DialogList *pDialog)
|
|
{
|
|
// create the icon list
|
|
m_oIconList.Create(16, 16, ILC_MASK, 0, 10);
|
|
m_oIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(TBK_IDI_COMMON_ICON)));
|
|
m_oIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(TBK_IDI_BANK1_ICON)));
|
|
m_oIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(TBK_IDI_BANK2_ICON)));
|
|
m_oIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(TBK_IDI_BANK3_ICON)));
|
|
m_oIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(TBK_IDI_BANK4_ICON)));
|
|
m_oIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(TBK_IDI_BANK5_ICON)));
|
|
m_oIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(TBK_IDI_BANK6_ICON)));
|
|
m_oIconList.Add(LoadIcon(GetDLLIdentity()->hModule, MAKEINTRESOURCE(TBK_IDI_SECTOR_ICON)));
|
|
|
|
// tree
|
|
m_pTreeRoot = GetInterface()->GetNewSuperObject(E_ss_NoSave);
|
|
pDialog->fn_vAddANewTree("Banks Tree", m_pTreeRoot, &m_oIconList);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Give the list by default
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vInitDefaultParameters (CPA_DialogList *pDialog)
|
|
{
|
|
pDialog->SetPermanentHeaders(FALSE);
|
|
pDialog->SetDefaultTypeName("Banks Tree");
|
|
pDialog->SetDefaultTestName("Create New Test");
|
|
pDialog->SetDefaultButtonState(FALSE);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Set the button for create bank
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::fn_vSetANewTest (CPA_DialogList *pDialog, CString csCurrentType)
|
|
{
|
|
pDialog->fn_vInitButtonTest("Create New Bank", TRUE, FALSE);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Create new bank
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bOnButtonTest (CPA_DialogList *pDialog, CString csListName, tdeListDrawMode eDraw)
|
|
{
|
|
CString csName;
|
|
|
|
// check if a new bank can be created
|
|
if (m_lBankIndex >= TBK_C_lMaxNumberOfBanks)
|
|
return TRUE;
|
|
|
|
// build default name
|
|
csName.Format("Bank_%ld", m_lBankIndex);
|
|
TBK_DialogName oDialog(csName, &g_oBaseFrame);
|
|
|
|
if (oDialog.DoModal() == IDOK)
|
|
{
|
|
TBK_BankObject * pBank = new TBK_BankObject(this, TBK_E_bt_Bank, oDialog.m_csNewName, FALSE);
|
|
m_fn_vNotifyBankHeader();
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Get icon for list element
|
|
* Creation date: 11/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
int TBK_BanksInterface::GetIconForListItem (CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject)
|
|
{
|
|
// bank index
|
|
if (csListName == "Banks List")
|
|
return ((TBK_BankObject *)pObject)->m_fn_lGetBankIndex();
|
|
|
|
// default
|
|
return -1;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Get icon for tree element
|
|
* Creation date: 11/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
int TBK_BanksInterface::GetIconForTreeItem (CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject)
|
|
{
|
|
// bank index
|
|
if (csListName == "Banks Tree")
|
|
{
|
|
if (pObject->GetType() == C_szBankTypeName)
|
|
return ((TBK_BankObject *)pObject)->m_fn_lGetBankIndex();
|
|
|
|
else if ((pObject->GetType() == C_szSuperObjectTypeName) && (((CPA_SuperObject *)pObject)->GetRealTypeName() == C_szSectorTypeName))
|
|
return TBK_C_lMaxNumberOfBanks;
|
|
}
|
|
|
|
// default
|
|
return -1;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Build the tree
|
|
* Creation date: 11/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CPA_BaseObject * TBK_BanksInterface::GetTreeNodeNextChild (CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pParent, CPA_BaseObject *pCurrentChild)
|
|
{
|
|
// first level of hierarchy
|
|
if (pParent == m_pTreeRoot)
|
|
{
|
|
// first child
|
|
if (!pCurrentChild)
|
|
return m_pCommonBank;
|
|
|
|
// next childs
|
|
TBK_BankObject *pBank = (TBK_BankObject *) pCurrentChild;
|
|
long lIndex = pBank->m_fn_lGetBankIndex() + 1;
|
|
|
|
while (lIndex < TBK_C_lMaxNumberOfBanks)
|
|
{
|
|
pBank = m_fn_pGetBankByIndex(lIndex++);
|
|
if (pBank)
|
|
return pBank;
|
|
}
|
|
|
|
// last child
|
|
return NULL;
|
|
}
|
|
|
|
// second level of hierarchy
|
|
else if (pParent->GetType() == C_szBankTypeName)
|
|
{
|
|
return ((TBK_BankObject *) pParent)->m_fn_pGetNextSector((CPA_SuperObject *) pCurrentChild);
|
|
}
|
|
|
|
// default
|
|
return NULL;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Drag & drop management
|
|
* Creation date: 11/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CPA_BaseObject * TBK_BanksInterface::GetDialogSelection (CPA_DialogList *pDialog, CString csListName, tdeListDrawMode eDrawMode)
|
|
{
|
|
if (m_pSelectedSector)
|
|
return m_pSelectedSector;
|
|
else
|
|
return m_pSelectedBank;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Drag & drop management
|
|
* Creation date: 11/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bCanDragItemInHierarchyTree (CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObjectToDrag)
|
|
{
|
|
return ((pObjectToDrag->GetType() == C_szSuperObjectTypeName) && (((CPA_SuperObject *)pObjectToDrag)->GetRealTypeName() == C_szSectorTypeName));
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Drag & drop management
|
|
* Creation date: 11/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bCanDropItemInHierarchyTree (CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObjectToDrop, CPA_BaseObject *pTarget)
|
|
{
|
|
return ((pObjectToDrop->GetType() == C_szSuperObjectTypeName) &&
|
|
(((CPA_SuperObject *)pObjectToDrop)->GetRealTypeName() == C_szSectorTypeName) &&
|
|
(pTarget->GetType() == C_szBankTypeName));
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Drag & drop management
|
|
* Creation date: 11/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bOnDragDropInHierarchyTree (CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject, CPA_BaseObject *pTarget)
|
|
{
|
|
TBK_BankObject *pPreviousBank = (TBK_BankObject *) pDialog->GetSelectedParent();
|
|
TBK_BankObject *pNewBank = (TBK_BankObject *) pTarget;
|
|
|
|
// change sector's bank
|
|
pPreviousBank->m_fn_bRemoveSectorFromBank((CPA_SuperObject *)pObject);
|
|
pNewBank->m_fn_bAddSectorToBank((CPA_SuperObject *)pObject);
|
|
|
|
// redraw tree (previous bank expanded)
|
|
m_pSelectedSector = NULL;
|
|
m_pSelectedBank = pPreviousBank;
|
|
pDialog->fn_vUpdateSelection(E_lrm_ReinitList);
|
|
|
|
// expand current bank
|
|
m_pSelectedSector = (CPA_SuperObject *) pObject;
|
|
m_pSelectedBank = pNewBank;
|
|
pDialog->fn_vUpdateSelection(E_lrm_ChangeSelection);
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Key management
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bOnKeyDownInDialog (CPA_DialogList *pDialog, CString csListName, tdeListDrawMode eDraw, CPA_BaseObject *pSelectedObject, UINT nChar, UINT nRepCnt, UINT nFlags)
|
|
{
|
|
unsigned short uwKey = m_pKeyboard->mfn_uwKeyToAction(nChar);
|
|
TBK_BankObject *pNewBank = NULL;
|
|
|
|
switch (uwKey)
|
|
{
|
|
case KA_ID_DELETE :
|
|
if (pSelectedObject->GetType() == C_szBankTypeName)
|
|
{
|
|
// set all sectors into common bank
|
|
((TBK_BankObject *)pSelectedObject)->m_fn_bTransferAllSectors(m_pCommonBank);
|
|
// delete current bank
|
|
((TBK_BankObject *)pSelectedObject)->fn_vNotifyUnSave();
|
|
delete (pSelectedObject);
|
|
m_fn_vNotifyBankHeader();
|
|
// update dialog
|
|
m_pSelectedSector = NULL;
|
|
m_pSelectedBank = m_pCommonBank;
|
|
pDialog->fn_vUpdateSelection(E_lrm_ReinitList);
|
|
}
|
|
return TRUE;
|
|
|
|
|
|
case KA_ID_BANK1 :
|
|
case KA_ID_BANK2 :
|
|
case KA_ID_BANK3 :
|
|
case KA_ID_BANK4 :
|
|
case KA_ID_BANK5 :
|
|
case KA_ID_BANK6 :
|
|
pNewBank = m_fn_pGetBankByIndex(uwKey);
|
|
break;
|
|
|
|
case KA_ID_COMMON :
|
|
pNewBank = m_pCommonBank;
|
|
return TRUE;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
// bank selection
|
|
if (pSelectedObject->GetType() == C_szBankTypeName)
|
|
{
|
|
TBK_BankObject *pBank = (TBK_BankObject *) pSelectedObject;
|
|
|
|
// change bank
|
|
if (pNewBank && (pNewBank != pBank))
|
|
pBank->m_fn_bTransferAllSectors(pNewBank);
|
|
// redraw tree (previous bank expanded)
|
|
m_pSelectedSector = NULL;
|
|
m_pSelectedBank = pNewBank;
|
|
pDialog->fn_vUpdateSelection(E_lrm_ReinitList);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// sector object
|
|
if ((pSelectedObject->GetType() == C_szSuperObjectTypeName) && (((CPA_SuperObject *)pSelectedObject)->GetRealTypeName() == C_szSectorTypeName))
|
|
{
|
|
CPA_SuperObject *pSector = (CPA_SuperObject *) pSelectedObject;
|
|
TBK_BankObject *pOldBank = m_fn_pGetBankBySector(pSector);
|
|
|
|
// change bank
|
|
if (pNewBank && (pNewBank != pOldBank))
|
|
{
|
|
pOldBank->m_fn_bRemoveSectorFromBank(pSector);
|
|
pNewBank->m_fn_bAddSectorToBank(pSector);
|
|
}
|
|
|
|
// reinit dialog
|
|
m_pSelectedSector = NULL;
|
|
m_pSelectedBank = pOldBank;
|
|
pDialog->fn_vUpdateSelection(E_lrm_ReinitList);
|
|
|
|
// reinit selection
|
|
m_pSelectedSector = (CPA_SuperObject *) pSelectedObject;
|
|
m_pSelectedBank = pNewBank;
|
|
pDialog->fn_vUpdateSelection(E_lrm_ChangeSelection);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Selection management
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL TBK_BanksInterface::fn_bOnSelChangeHierarchyTree (CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pSelectedObject, CPA_BaseObject *pSelectedParent)
|
|
{
|
|
// bank selection
|
|
if (pSelectedObject->GetType() == C_szBankTypeName)
|
|
{
|
|
m_pSelectedSector = NULL;
|
|
m_pSelectedBank = (TBK_BankObject *) pSelectedObject;
|
|
}
|
|
|
|
// sector object
|
|
else if ((pSelectedObject->GetType() == C_szSuperObjectTypeName) && (((CPA_SuperObject *)pSelectedObject)->GetRealTypeName() == C_szSectorTypeName))
|
|
{
|
|
m_pSelectedSector = (CPA_SuperObject *) pSelectedObject;
|
|
m_pSelectedBank = m_fn_pGetBankBySector(m_pSelectedSector);
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// PREFERENCES
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: Save dialog dimensions
|
|
* Creation date: 10/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::m_fn_vSaveDialogsPreferences (void)
|
|
{
|
|
CString csFileName;
|
|
CString csDimension;
|
|
BOOL bRes = TRUE;
|
|
|
|
csFileName = M_GetMainApp()->m_csEditorDataPath + "Tools\\" + TBK_C_szBanksPrefIniFile;
|
|
|
|
// left frame width
|
|
csDimension.Format("%ld", m_pLeftFrame->m_oCurPos.right - m_pLeftFrame->m_oCurPos.left);
|
|
bRes &= WritePrivateProfileString ("Preference", "Banks Left Frame Width", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
// dialogs dimensions
|
|
csDimension.Format("%ld", m_pLeftFrame->GetPaneSize(0));
|
|
bRes &= WritePrivateProfileString ("Preference", "Banks DialogList Dimension", (char*)(LPCSTR)csDimension, (char*)(LPCSTR)csFileName);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Set sector color
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::m_fn_vSetSectorColor (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))
|
|
m_fn_vSetSectorColor(pChild, eColor);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: return the index of the next bank and update it
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
long TBK_BanksInterface::m_fn_lAddANewBank (void)
|
|
{
|
|
long lIndex;
|
|
|
|
for (lIndex = 1; lIndex < TBK_C_lMaxNumberOfBanks; lIndex++)
|
|
{
|
|
if (!m_fn_pGetBankByIndex(lIndex))
|
|
{
|
|
if (lIndex == m_lBankIndex)
|
|
m_lBankIndex++;
|
|
|
|
return lIndex;
|
|
}
|
|
}
|
|
|
|
return TBK_C_lMaxNumberOfBanks;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Get bank with the given index
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
TBK_BankObject * TBK_BanksInterface::m_fn_pGetBankByIndex (long lIndex)
|
|
{
|
|
CPA_BaseObjectList *pBankList = GetMainWorld()->fn_p_oGetOriginalObjectList(C_szBankTypeName);
|
|
|
|
Position pos = pBankList->GetHeadPosition();
|
|
while (pos)
|
|
{
|
|
TBK_BankObject *pBank = (TBK_BankObject *) pBankList->GetNext(pos);
|
|
if (pBank->m_fn_lGetBankIndex() == lIndex)
|
|
return pBank;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Get bank containing the given sector
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
TBK_BankObject * TBK_BanksInterface::m_fn_pGetBankBySector (CPA_SuperObject *pSector)
|
|
{
|
|
CPA_BaseObjectList *pBankList = GetMainWorld()->fn_p_oGetOriginalObjectList(C_szBankTypeName);
|
|
|
|
Position pos = pBankList->GetHeadPosition();
|
|
while (pos)
|
|
{
|
|
TBK_BankObject *pBank = (TBK_BankObject *) pBankList->GetNext(pos);
|
|
if (pBank->m_fn_bIsSectorInBank(pSector))
|
|
return pBank;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Notify bank header for save
|
|
* Creation date: 21/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::m_fn_vNotifyBankHeader (void)
|
|
{
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
|
|
// build section name
|
|
sprintf(szFileName, "%s\\%s\\%s.bnk", fn_szGetLevelsDataPath(), fn_p_szGetLevelName(), fn_p_szGetLevelName());
|
|
SCR_fn_v_RdL0_ComputeSectionName (szSectionName, szFileName, C_HeaderSectionName, "");
|
|
|
|
SCR_fn_v_SvL1_RegisterNotify(szSectionName, TBK_fn_eCallBackSaveBankHeader, this, SCR_EA_Ntfy_AddOrRebuildSection);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: save bank header
|
|
* Creation date: 21/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void TBK_BanksInterface::TBK_fn_eCallBackSaveBankHeader (SCR_tdst_File_Description *p_stFile, char *szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction)
|
|
{
|
|
TBK_BanksInterface *pBankInterface = (TBK_BanksInterface *) p_vData;
|
|
CPA_BaseObjectList *pBankList;
|
|
TBK_BankObject *pBankObject;
|
|
Position pos;
|
|
char szNewSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
switch (eAction)
|
|
{
|
|
case SCR_EA_Ntfy_AddSection:
|
|
case SCR_EA_Ntfy_RebuildSection:
|
|
|
|
// save section name
|
|
SCR_fn_v_RdL0_ComputeSectionName(szNewSectionName, NULL, C_HeaderSectionName, " ");
|
|
SCR_M_SvL0_SaveBeginSection(p_stFile, szNewSectionName, SCR_CC_C_Cfg_EOL);
|
|
|
|
// save number of banks
|
|
pBankList = pBankInterface->GetMainWorld()->fn_p_oGetOriginalObjectList(C_szBankTypeName);
|
|
SCR_M_SvL0_SaveEntry(p_stFile, C_HeaderNumberEntry, SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%ld", pBankList->GetCount() - 1);
|
|
|
|
// save list of banks
|
|
pos = pBankList->GetHeadPosition();
|
|
while (pos)
|
|
{
|
|
pBankObject = (TBK_BankObject *) pBankList->GetNext(pos);
|
|
|
|
SCR_M_SvL0_SaveEntry(p_stFile, (pBankObject->m_fn_eGetBankType() == TBK_E_bt_Common) ? C_HeaderCommonEntry : C_HeaderBankEntry, SCR_CC_C_Cfg_NoChar);
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, pBankObject->GetReferencedSectionName());
|
|
}
|
|
|
|
// end section
|
|
SCR_M_SvL0_SaveEndSection (p_stFile, SCR_CC_C_Cfg_EOL);
|
|
if (eAction == SCR_EA_Ntfy_AddSection)
|
|
SCR_M_SvL0_SaveBlankLine (p_stFile);
|
|
|
|
break;
|
|
|
|
case SCR_EA_Ntfy_DeleteSection:
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: Load bank file
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
SCR_tde_Anl_ReturnValue TBK_BanksInterface::TBK_fn_eCallBackLoadBank (SCR_tdst_File_Description *p_stFile, char *szName, char *p_szParams[], SCR_tde_Anl_Action eAction)
|
|
{
|
|
HIE_tdxHandleToSuperObject hSector;
|
|
SCR_tdst_Cxt_Values *p_stValues;
|
|
TBK_BanksInterface *pBanksInterface;
|
|
CPA_SuperObject *pSector;
|
|
TBK_BankObject *pBank;
|
|
|
|
// get interface
|
|
SCR_M_RdL0_GetContextLong(0, 0, TBK_BanksInterface *, pBanksInterface);
|
|
|
|
switch (eAction)
|
|
{
|
|
case SCR_EA_Anl_BeginSection :
|
|
// create bank
|
|
pBank = new TBK_BankObject(pBanksInterface, TBK_E_bt_Bank, szName, TRUE);
|
|
// register it for loading
|
|
SCR_M_RdL0_SetSectionLong(0, 0, pBank);
|
|
SCR_M_RdL0_SetContextLong(1, 0, pBanksInterface);
|
|
break;
|
|
|
|
case SCR_EA_Anl_Entry:
|
|
// get current bank
|
|
SCR_M_RdL0_GetSectionLong(0, 0, TBK_BankObject *, pBank);
|
|
|
|
// add sector
|
|
if (!strcmpi(szName, C_BankSectorEntry))
|
|
{
|
|
if (SCR_fn_c_RdL0_IsSectionExists(p_szParams[0]))
|
|
{
|
|
// get corresponding sector
|
|
p_stValues = SCR_fnp_st_RdL0_AnalyseSection(p_szParams[0], SCR_CDF_uw_Anl_Normal);
|
|
hSector = (HIE_tdxHandleToSuperObject) SCR_M_ul_RdL0_ExtractLongValue(p_stValues, 0);
|
|
pSector = (CPA_SuperObject *) pBanksInterface->GetMainWorld()->fn_p_oFindObjectWithEngine(hSector, C_szSuperObjectTypeName);
|
|
// add it to the bank
|
|
pBank->m_fn_bAddSectorToBank(pSector);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case SCR_EA_Anl_EndSection:
|
|
break;
|
|
}
|
|
|
|
return SCR_ERV_Anl_NormalReturn;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Load bank file
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
SCR_tde_Anl_ReturnValue TBK_BanksInterface::TBK_fn_eCallBackLoadCommon (SCR_tdst_File_Description *p_stFile, char *szName, char *p_szParams[], SCR_tde_Anl_Action eAction)
|
|
{
|
|
return SCR_ERV_Anl_NormalReturn;
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: Load bank file
|
|
* Creation date: 16/06/99
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
SCR_tde_Anl_ReturnValue TBK_BanksInterface::TBK_fn_eCallBackLoadHeader (SCR_tdst_File_Description *p_stFile, char *szName, char *p_szParams[], SCR_tde_Anl_Action eAction)
|
|
{
|
|
TBK_BanksInterface *pBanksInterface;
|
|
|
|
switch (eAction)
|
|
{
|
|
case SCR_EA_Anl_BeginSection :
|
|
// set section long
|
|
SCR_M_RdL0_GetContextLong(0, 0, TBK_BanksInterface *, pBanksInterface);
|
|
SCR_M_RdL0_SetSectionLong(0, 0, pBanksInterface);
|
|
break;
|
|
|
|
case SCR_EA_Anl_Entry:
|
|
// get section long
|
|
SCR_M_RdL0_GetSectionLong(0, 0, TBK_BanksInterface *, pBanksInterface);
|
|
// add sector
|
|
if (!strcmpi(szName, C_HeaderCommonEntry))
|
|
{
|
|
SCR_M_RdL0_SetContextLong(1, 0, pBanksInterface);
|
|
SCR_fnp_st_RdL0_AnalyseSection(p_szParams[0], SCR_CDF_uw_Anl_ForceAnalyse);
|
|
}
|
|
else if (!strcmpi(szName, C_HeaderBankEntry))
|
|
{
|
|
SCR_M_RdL0_SetContextLong(1, 0, pBanksInterface);
|
|
SCR_fnp_st_RdL0_AnalyseSection(p_szParams[0], SCR_CDF_uw_Anl_ForceAnalyse);
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return SCR_ERV_Anl_NormalReturn;
|
|
}
|