/*========================================================================= * * SECdSel.cpp : Selected sector dialog - Implementation file * * * Version 1.0 * Creation date * Revision date * * Shaitan *=======================================================================*/ #include "stdafx.h" #include "acp_base.h" #include "SECTint.hpp" #include "SECdSel.hpp" #include "SECmodif.hpp" #include "SEClDias.hpp" #include "..\Main\Inc\_EditID.h" #include "TUT.h" #define C_MaxGraphicLevel 5 #define C_MinGraphicLevel 1 #define C_MaxSoundLevel 127 #define C_MinSoundLevel 0 #define C_uiCopyEntry 1 #define C_uiPasteEntry 2 //################################################################################# // SECT_DialogSel dialog //################################################################################# /*---------------------------------------- ----------------------------------------*/ SECT_DialogSel::SECT_DialogSel(CWnd* pParent) : CFormView(SECT_DialogSel::IDD) { //{{AFX_DATA_INIT(SECT_DialogSel) //}}AFX_DATA_INIT } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(SECT_DialogSel) DDX_Control(pDX, SECT_IDC_GRAPHIC, m_cGraphic); DDX_Control(pDX, SECT_IDC_GRAPHICLEVEL, m_cGraphicLevel); DDX_Control(pDX, SECT_IDC_GRAPHICSPIN, m_cGraphicSpin); DDX_Control(pDX, SECT_IDC_GRAPHICMODE, m_cGraphicMode); DDX_Control(pDX, SECT_IDC_COLLISION, m_cCollision); DDX_Control(pDX, SECT_IDC_ACTIVITY, m_cActivity); DDX_Control(pDX, SECT_IDC_SOUND, m_cSound); DDX_Control(pDX, SECT_IDC_SOUNDLEVEL, m_cSoundLevel); DDX_Control(pDX, SECT_IDC_SOUNDSPIN, m_cSoundSpin); DDX_Control(pDX, SECT_IDC_SOUNDEVENT, m_cSoundEvent); DDX_Control(pDX, SECT_IDC_SOUNDEVENTLIST, m_cSoundEventList); DDX_Control(pDX, SECT_IDC_SELECTEDSECTOR, m_cComboSector); DDX_Control(pDX, SECT_IDC_SYMETRIC, m_cSymetric); //}}AFX_DATA_MAP } /*---------------------------------------- ----------------------------------------*/ BEGIN_MESSAGE_MAP(SECT_DialogSel, CFormView) //{{AFX_MSG_MAP(SECT_DialogSel) ON_CBN_SELCHANGE(SECT_IDC_SELECTEDSECTOR, OnSelChangeComboSector) ON_BN_CLICKED(SECT_IDC_SYMETRIC, OnSymetric) ON_BN_CLICKED(SECT_IDC_GRAPHIC, OnGraphic) ON_NOTIFY(UDN_DELTAPOS, SECT_IDC_GRAPHICSPIN, OnGraphicSpin) ON_BN_CLICKED(SECT_IDC_GRAPHICMODE, OnGraphicMode) ON_BN_CLICKED(SECT_IDC_COLLISION, OnCollision) ON_BN_CLICKED(SECT_IDC_ACTIVITY, OnActivity) ON_BN_CLICKED(SECT_IDC_SOUND, OnSound) ON_NOTIFY(UDN_DELTAPOS, SECT_IDC_SOUNDSPIN, OnSoundSpin) ON_BN_CLICKED(SECT_IDC_SOUNDEVENT, OnSoundEvent) ON_NOTIFY(LVN_ITEMCHANGED, SECT_IDC_SOUNDEVENTLIST, OnSelChangeSoundEventList) ON_WM_SIZE() ON_WM_DESTROY() ON_WM_DRAWITEM() ON_WM_RBUTTONDOWN() //}}AFX_MSG_MAP END_MESSAGE_MAP() //################################################################################# // SECT_DialogSel Inits //################################################################################# /*=========================================================================== * Description: Init dialog * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void SECT_DialogSel::fn_vInitDialog (Sector_Interface *pOwnerDLL, CWnd *pParent) { // create the dialog m_bInitialised = FALSE; m_pSectorInterface = pOwnerDLL; CFormView::Create(NULL, "", AFX_WS_DEFAULT_VIEW, CRect(0,0,120,180), pParent, AFX_IDW_PANE_FIRST, NULL); // init data for dialog CFormView::UpdateData(FALSE); // FOR TUTORIAL TUT_M_vGetTutDll(); // mode TUT_M_vRegisterControl(m_cSymetric.m_hWnd, "OSC_DSEL_BUTTON_SYMETRIC", TUT_e_Button); // sector TUT_M_vRegisterControl(m_cComboSector.m_hWnd, "OSC_DSEL_COMBO_SECTOR", TUT_e_ComboBox); // graphic TUT_M_vRegisterControl(m_cGraphic.m_hWnd, "OSC_DSEL_BUTTON_GRAPHIC", TUT_e_Button); TUT_M_vRegisterControl(m_cGraphicSpin.m_hWnd, "OSC_DSEL_SPIN_GRAPHIC", TUT_e_Spin); TUT_M_vRegisterControl(m_cGraphicLevel.m_hWnd, "OSC_DSEL_EDIT_GRAPHIC", TUT_e_TextEdit); TUT_M_vRegisterControl(m_cGraphicMode.m_hWnd, "OSC_DSEL_MODE_GRAPHIC", TUT_e_Button); // collision TUT_M_vRegisterControl(m_cCollision.m_hWnd, "OSC_DSEL_BUTTON_COLLISION", TUT_e_Button); // activity TUT_M_vRegisterControl(m_cActivity.m_hWnd, "OSC_DSEL_BUTTON_ACTIVITY", TUT_e_Button); // sound TUT_M_vRegisterControl(m_cSound.m_hWnd, "OSC_DSEL_BUTTON_SOUND", TUT_e_Button); TUT_M_vRegisterControl(m_cSoundSpin.m_hWnd, "OSC_DSEL_SPIN_SOUND", TUT_e_Spin); TUT_M_vRegisterControl(m_cSoundLevel.m_hWnd, "OSC_DSEL_EDIT_SOUND", TUT_e_TextEdit); // sound event TUT_M_vRegisterControl(m_cSoundEvent.m_hWnd, "OSC_DSEL_BUTTON_SNDEVENT", TUT_e_Button); TUT_M_vRegisterControl(m_cSoundEventList.m_hWnd, "OSC_DSEL_LIST_SNDEVENT", TUT_e_ListBox); // END TUTORIAL // update sndevtlist m_cSoundEventList.fn_vInitDialogParameters(this); // update params m_cGraphicSpin.SetBuddy(&m_cGraphicLevel); m_cGraphicSpin.SetRange(C_MinGraphicLevel, C_MaxGraphicLevel); m_cGraphicSpin.SetPos(0); m_cSoundSpin.SetBuddy(&m_cSoundLevel); m_cSoundSpin.SetRange(C_MinSoundLevel, C_MaxSoundLevel); m_cSoundSpin.SetPos(0); // update mode m_cSymetric.EnableWindow(FALSE); // init datas fn_vReinitDialog(NULL, NULL); m_bInitialised = TRUE; } /*=========================================================================== * Description: init controls with default values * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void SECT_DialogSel::fn_vInitControls (BOOL bState) { Sector_Object *pSector; BOOL bShow; BOOL bVirtual = TRUE; int iInd; // virtual if (m_pEditedSector) bVirtual = ((Sector_Object *) m_pEditedSector->GetObject())->fn_bIsVirtual(); // name & virtual if (m_pSelectedSector) { // get parameters pSector = (Sector_Object *) m_pSelectedSector->GetObject(); strcpy(m_szName, pSector->GetName()); // set combo selection iInd = m_cComboSector.FindStringExact(-1,m_szName); m_cComboSector.SetCurSel(iInd); } else if (m_pEditedSector) { // from all sectors strcpy(m_szName, "All Sectors"); // set combo selection iInd = m_cComboSector.FindStringExact(-1,m_szName); m_cComboSector.SetCurSel(iInd); } else { strcpy(m_szName, ""); m_cComboSector.SetCurSel(-1); } // state m_cComboSector.EnableWindow(m_pSectorInterface->GetEditMode() == E_em_EditSector); // symetric m_cSymetric.EnableWindow((bState)&&(m_pSelectedSector != m_pEditedSector)); if (m_pSelectedSector && (m_pEditedSector != m_pSelectedSector)) bVirtual = (bVirtual || ((Sector_Object *) m_pSelectedSector->GetObject())->fn_bIsVirtual()); // disable m_cGraphic.EnableWindow(bState); m_cCollision.EnableWindow(bState); m_cActivity.EnableWindow(bState); m_cSound.EnableWindow(bState); m_cSoundEvent.EnableWindow(bState); // set state m_cGraphic.SetCheck(0); m_cCollision.SetCheck(0); m_cActivity.SetCheck(0); m_cSound.SetCheck(0); m_cSoundEvent.SetCheck(0); // set additionnal controls bShow = bState && (m_pSelectedSector != m_pEditedSector); // graphic controls m_cGraphicLevel.ShowWindow((bShow) ? SW_SHOW : SW_HIDE); m_cGraphicSpin.ShowWindow((bShow) ? SW_SHOW : SW_HIDE); m_cGraphicMode.ShowWindow((bShow) ? SW_SHOW : SW_HIDE); m_cGraphicLevel.EnableWindow(FALSE); m_cGraphicSpin.EnableWindow(FALSE); m_cGraphicMode.EnableWindow(FALSE); m_cGraphicSpin.SetPos(0); // sound controls m_cSoundLevel.ShowWindow((bShow) ? SW_SHOW : SW_HIDE); m_cSoundSpin.ShowWindow((bShow) ? SW_SHOW : SW_HIDE); m_cSoundLevel.EnableWindow(FALSE); m_cSoundSpin.EnableWindow(FALSE); m_cSoundSpin.SetPos(0); // sound event list m_cSoundEventList.ShowWindow((bShow) ? SW_SHOW : SW_HIDE); m_cSoundEventList.EnableWindow(FALSE); fn_vUpdateSoundEventList(NULL); } /*=========================================================================== * Description: update dialog when selection changes * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void SECT_DialogSel::fn_vReinitDialog (CPA_SuperObject *pSector, CPA_SuperObject *pEditedSector) { CPA_BaseObjectList *pListObject; SECT_SoundEventElement *pSoundEvent; SECT_GraphicElement *pGraphic; SECT_SoundElement *pSound; CPA_BaseObject *pElem; Sector_Object *pSectObj; Position pos; BOOL bVirtual; // init current sector m_pSelectedSector = pSector; m_pEditedSector = pEditedSector; // update mode m_cSymetric.SetCheck(m_pSectorInterface->fn_bSymetricMode()); // reinito combo m_cComboSector.ResetContent(); pListObject = m_pSectorInterface->GetBaseObjectList(C_szSectorTypeName); if (pListObject->GetCount() > 0) { // each sector of the list for (pElem = pListObject->GetHeadElement(pos); pElem; pElem = pListObject->GetNextElement(pos)) m_cComboSector.AddString(pElem->GetName()); // all sectors (sound events) m_cComboSector.AddString("All Sectors"); } // default => disable all controls if ((!pSector)||(!m_pEditedSector)) { // disable all controls fn_vInitControls(FALSE); if (!m_pEditedSector) return; pSectObj = (Sector_Object *) pEditedSector->GetObject(); bVirtual = pSectObj->fn_bIsVirtual(); // for graphics only : all sectors if (!pSector) { // enable graphic control m_cGraphic.EnableWindow(TRUE); m_cGraphic.SetCheck(pSectObj->fn_bHasFullLink(E_Graphic)); } // if necessary, enable sound events ("FromAllSectors") if (!pSector) { // enable collision control m_cCollision.EnableWindow(TRUE); m_cCollision.SetCheck(pSectObj->fn_bHasFullLink(E_Collision)); // enable activity control m_cActivity.EnableWindow(TRUE); m_cActivity.SetCheck(pSectObj->fn_bHasFullLink(E_Activity)); // enable sound control m_cSound.EnableWindow(TRUE); m_cSound.SetCheck(pSectObj->fn_bHasFullLink(E_Sound)); // sound event list m_cSoundEvent.EnableWindow(TRUE); m_cSoundEventList.ShowWindow(SW_SHOW); // get corresponding sound event pSoundEvent = (SECT_SoundEventElement *) pSectObj->GetSoundEventList()->GetElementWithSector(pSector); // set selection if (pSoundEvent) { m_cSoundEvent.SetCheck(1); m_cSoundEventList.EnableWindow(TRUE); fn_vUpdateSoundEventList(pSoundEvent); } } } // selection => edit corresponding sector else { pSectObj = (Sector_Object *) pEditedSector->GetObject(); // enable corresponding controls fn_vInitControls(TRUE); // check lists if (m_pSelectedSector != m_pEditedSector) { // graphic pGraphic = (SECT_GraphicElement *) pSectObj->GetGraphicList()->GetElementWithSector(pSector); if (pGraphic) { m_cGraphic.SetCheck(1); m_cGraphicSpin.EnableWindow(TRUE); m_cGraphicLevel.EnableWindow(TRUE); m_cGraphicMode.EnableWindow(TRUE); m_cGraphicSpin.SetPos(pGraphic->GetGraphicLevel()); m_cGraphicMode.SetCheck(pGraphic->GetGraphicMode() == C_SECT_ModeLookOnly); } // collision if (pSectObj->GetCollisionList()->GetElementWithSector(pSector)) m_cCollision.SetCheck(1); // activity if (pSectObj->GetActivityList()->GetElementWithSector(pSector)) m_cActivity.SetCheck(1); // sound pSound = (SECT_SoundElement *) pSectObj->GetSoundList()->GetElementWithSector(pSector); if (pSound) { m_cSound.SetCheck(1); m_cSoundSpin.EnableWindow(TRUE); m_cSoundLevel.EnableWindow(TRUE); m_cSoundSpin.SetPos(pSound->GetSoundLevel()); } // sound event pSoundEvent = (SECT_SoundEventElement *) pSectObj->GetSoundEventList()->GetElementWithSector(pSector); if (pSoundEvent) { m_cSoundEvent.SetCheck(1); m_cSoundEventList.EnableWindow(TRUE); fn_vUpdateSoundEventList(pSoundEvent); } } else fn_vUpdateCheck(); } } /*=========================================================================== * Description: update dialog when selection changes * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void SECT_DialogSel::fn_vUpdateCheck (void) { if (m_pSelectedSector != m_pEditedSector) return; // reinit controls if (m_pSectorInterface->GetEditMode() == E_em_EditList) { m_cGraphic.SetCheck(m_pSectorInterface->GetListActivity(E_Graphic)); m_cCollision.SetCheck(m_pSectorInterface->GetListActivity(E_Collision)); m_cActivity.SetCheck(m_pSectorInterface->GetListActivity(E_Activity)); m_cSound.SetCheck(m_pSectorInterface->GetListActivity(E_Sound)); m_cSoundEvent.SetCheck(m_pSectorInterface->GetListActivity(E_SoundEvent)); } else { m_cGraphic.SetCheck(FALSE); m_cCollision.SetCheck(FALSE); m_cActivity.SetCheck(FALSE); m_cSound.SetCheck(FALSE); m_cSoundEvent.SetCheck(FALSE); } } /*=========================================================================== * Description: update dialog when selected list changes * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void SECT_DialogSel::fn_vOnCheckList (CButton *pControl, tdeTypeList eType) { SECT_ModifSectorLinks *pModifLink; SECT_ModifFullLink *pModifFull; DEV_ViewPort3D *pViewport; // selected sector if (m_pSelectedSector != m_pEditedSector) { // no sector => full link if ((!m_pSelectedSector)&&(eType != E_SoundEvent)) { // create modif if (pControl->GetCheck()) pModifFull = new SECT_ModifFullLink(m_pSectorInterface, E_mt_AddFullLink, m_pEditedSector, eType); else pModifFull = new SECT_ModifFullLink(m_pSectorInterface, E_mt_DelFullLink, m_pEditedSector, eType); // do modif m_pSectorInterface->M_GetEditManager()->AskFor(pModifFull); } // else modif link else { // create modif if (pControl->GetCheck()) pModifLink = new SECT_ModifSectorLinks(m_pSectorInterface, E_mt_AddSectorInList, m_pEditedSector, m_pSelectedSector, eType); else pModifLink = new SECT_ModifSectorLinks(m_pSectorInterface, E_mt_DelSectorInList, m_pEditedSector, m_pSelectedSector, eType); // do modif m_pSectorInterface->M_GetEditManager()->AskFor(pModifLink); } } // edited sector else { // update list activity m_pSectorInterface->SetListActivity(eType, pControl->GetCheck()); // set focus to device pViewport = (DEV_ViewPort3D *) m_pSectorInterface->GetInterface()->GetMultiDevice()->GetFocusDevice()->GetViewPort(); pViewport->SetFocus(); } } /*=========================================================================== * Description: init list with all sound events * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void SECT_DialogSel::fn_vInitSoundEventList (void) { // reinit list m_cSoundEventList.SetSortedList(m_pSectorInterface->GetSoundEventList()); // current selection => none m_cSoundEventList.SetSelectedItem(-1); } /*=========================================================================== * Description: select sound event in list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void SECT_DialogSel::fn_vUpdateSoundEventList (SECT_SoundEventElement *pSoundEvent) { // redraw list items m_cSoundEventList.RedrawItems(0, m_cSoundEventList.GetItemCount() - 1); m_cSoundEventList.UpdateWindow(); // update dialog if (m_pSectorInterface->GetSingleList(E_SoundEvent)) m_pSectorInterface->GetSingleList(E_SoundEvent)->fn_vUpdateSelection(m_pSelectedSector); } //################################################################################# // SECT_DialogSel Messages //################################################################################# /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnSelChangeComboSector (void) { char szName[256]; if (!m_bInitialised) return; // name was changed ? m_cComboSector.GetLBText(m_cComboSector.GetCurSel(), szName); if (!strcmp(szName, "All Sectors")) m_pSelectedSector = NULL; else m_pSelectedSector = m_pSectorInterface->GetSectorWithName(szName); m_pSectorInterface->fn_vSelectNewSector(m_pSelectedSector); } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnGraphic() { SECT_GraphicElement *pGraphic; Sector_Object *pSectObj; // update lists fn_vOnCheckList(&m_cGraphic, E_Graphic); // update controls if ((m_pSelectedSector != m_pEditedSector)&&(m_pSelectedSector)) { // get parameters pSectObj = (Sector_Object *) m_pEditedSector->GetObject(); pGraphic = (SECT_GraphicElement *) pSectObj->GetGraphicList()->GetElementWithSector(m_pSelectedSector); // update controls m_cGraphicSpin.EnableWindow(m_cGraphic.GetCheck()); m_cGraphicLevel.EnableWindow(m_cGraphic.GetCheck()); m_cGraphicMode.EnableWindow(m_cGraphic.GetCheck()); m_cGraphicSpin.SetPos((m_cGraphic.GetCheck()) ? pGraphic->GetGraphicLevel() : 0); m_cGraphicMode.SetCheck((m_cGraphic.GetCheck()) ? (pGraphic->GetGraphicMode() == C_SECT_ModeLookOnly) : FALSE); } } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnCollision() { // update lists fn_vOnCheckList(&m_cCollision, E_Collision); } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnActivity() { // update lists fn_vOnCheckList(&m_cActivity, E_Activity); } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnSound() { SECT_SoundElement *pSound; Sector_Object *pSectObj; // update lists fn_vOnCheckList(&m_cSound, E_Sound); // update controls if ((m_pSelectedSector != m_pEditedSector)&&(m_pSelectedSector)) { // get parameters pSectObj = (Sector_Object *) m_pEditedSector->GetObject(); pSound = (SECT_SoundElement *) pSectObj->GetSoundList()->GetElementWithSector(m_pSelectedSector); // update controls m_cSoundSpin.EnableWindow(m_cSound.GetCheck()); m_cSoundLevel.EnableWindow(m_cSound.GetCheck()); m_cSoundSpin.SetPos((m_cSound.GetCheck()) ? pSound->GetSoundLevel() : 0); } } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnSoundEvent() { SECT_SoundEventElement *pSoundEvent; Sector_Object *pSectObj; // update lists fn_vOnCheckList(&m_cSoundEvent, E_SoundEvent); // update controls if (m_pSelectedSector != m_pEditedSector) { // get parameters pSectObj = (Sector_Object *) m_pEditedSector->GetObject(); pSoundEvent = (SECT_SoundEventElement *) pSectObj->GetSoundEventList()->GetElementWithSector(m_pSelectedSector); // update controls m_cSoundEventList.EnableWindow(m_cSoundEvent.GetCheck()); fn_vUpdateSoundEventList(pSoundEvent); } } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnDrawItem (int nIDCtl, LPDRAWITEMSTRUCT lpDIS) { // not interested => default handling if ((lpDIS->itemID == LB_ERR) || (nIDCtl != SECT_IDC_SOUNDEVENTLIST) || (!m_cSoundEventList.IsWindowEnabled())) return; // draw item m_cSoundEventList.DrawItem(lpDIS); } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnSize (UINT nFlags, int cx, int cy) { RECT WindowPosition; int ecx, ecy; if (!m_bInitialised) return; GetWindowRect(&WindowPosition); // calculate width ecx = WindowPosition.right - WindowPosition.left - 10; ecy = WindowPosition.bottom - WindowPosition.top - 160; ecx = (ecx < 60) ? 60 : ecx; ecy = (ecy < 0) ? 0 : ecy; m_cSymetric.MoveWindow(ecx-45, 2, 50, 18); m_cComboSector.MoveWindow(5, 5, ecx - 55, 20); m_cSoundEventList.MoveWindow(5, 155, ecx, ecy); } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnDestroy (void) { // FOR TUTORIAL TUT_M_vGetTutDll(); // mode TUT_M_vUnregisterControl(m_cSymetric.m_hWnd); // sector TUT_M_vUnregisterControl(m_cComboSector.m_hWnd); // graphic TUT_M_vUnregisterControl(m_cGraphic.m_hWnd); TUT_M_vUnregisterControl(m_cGraphicSpin.m_hWnd); TUT_M_vUnregisterControl(m_cGraphicLevel.m_hWnd); TUT_M_vUnregisterControl(m_cGraphicMode.m_hWnd); // collision TUT_M_vUnregisterControl(m_cCollision.m_hWnd); // activity TUT_M_vUnregisterControl(m_cActivity.m_hWnd); // sound TUT_M_vUnregisterControl(m_cSound.m_hWnd); TUT_M_vUnregisterControl(m_cSoundSpin.m_hWnd); TUT_M_vUnregisterControl(m_cSoundLevel.m_hWnd); // sound event TUT_M_vUnregisterControl(m_cSoundEvent.m_hWnd); TUT_M_vUnregisterControl(m_cSoundEventList.m_hWnd); // END TUTORIAL CFormView::OnDestroy(); } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnGraphicSpin (NMHDR * pNMHDR, LRESULT * pResult) { SECT_ModifSectorParams *pModif; SECT_GraphicElement *pGraphic = NULL; Sector_Object *pSectObj = NULL; LPNM_UPDOWN pUpDown; int iFinalPos; // get action code pUpDown = (LPNM_UPDOWN)pNMHDR; if (pUpDown->hdr.code != UDN_DELTAPOS) return; // get parameters pSectObj = (Sector_Object *) m_pEditedSector->GetObject(); if (pSectObj) pGraphic = (SECT_GraphicElement *) pSectObj->GetGraphicList()->GetElementWithSector(m_pSelectedSector); if (!pGraphic) return; // get final pos iFinalPos = pUpDown->iPos + pUpDown->iDelta; // update level if (iFinalPos > C_MaxGraphicLevel) pModif = new SECT_ModifSectorParams(m_pSectorInterface, E_mt_ChangeLevelOfDetail, E_Graphic, pGraphic, C_MinGraphicLevel, NULL); else if (iFinalPos < C_MinGraphicLevel) pModif = new SECT_ModifSectorParams(m_pSectorInterface, E_mt_ChangeLevelOfDetail, E_Graphic, pGraphic, C_MaxGraphicLevel, NULL); else pModif = new SECT_ModifSectorParams(m_pSectorInterface, E_mt_ChangeLevelOfDetail, E_Graphic, pGraphic, iFinalPos, NULL); // update dialog m_pSectorInterface->M_GetEditManager()->AskFor(pModif); } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnGraphicMode (void) { SECT_ModifSectorParams *pModif; SECT_GraphicElement *pGraphic = NULL; Sector_Object *pSectObj = NULL; char cNewMode; // get parameters pSectObj = (Sector_Object *) m_pEditedSector->GetObject(); if (pSectObj) pGraphic = (SECT_GraphicElement *) pSectObj->GetGraphicList()->GetElementWithSector(m_pSelectedSector); if (!pGraphic) return; // get final state cNewMode = (m_cGraphicMode.GetCheck()) ? C_SECT_ModeLookOnly : C_SECT_ModeNormal; // update mode pModif = new SECT_ModifSectorParams(m_pSectorInterface, E_mt_ChangeGraphicMode, E_Graphic, pGraphic, cNewMode, NULL); // update dialog m_pSectorInterface->M_GetEditManager()->AskFor(pModif); } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnSoundSpin (NMHDR * pNMHDR, LRESULT * pResult) { SECT_ModifSectorParams *pModif; SECT_SoundElement *pSound = NULL; Sector_Object *pSectObj = NULL; LPNM_UPDOWN pUpDown; int iFinalPos; // get action code pUpDown = (LPNM_UPDOWN)pNMHDR; if (pUpDown->hdr.code != UDN_DELTAPOS) return; // get parameters pSectObj = (Sector_Object *) m_pEditedSector->GetObject(); if (pSectObj) pSound = (SECT_SoundElement *) pSectObj->GetSoundList()->GetElementWithSector(m_pSelectedSector); if (!pSound) return; // get final pos iFinalPos = pUpDown->iPos + pUpDown->iDelta; // update level if (iFinalPos > C_MaxSoundLevel) pModif = new SECT_ModifSectorParams(m_pSectorInterface, E_mt_ChangeSoundVolume, E_Sound, pSound, C_MinSoundLevel, NULL); else if (iFinalPos < C_MinSoundLevel) pModif = new SECT_ModifSectorParams(m_pSectorInterface, E_mt_ChangeSoundVolume, E_Sound, pSound, C_MinSoundLevel, NULL); else pModif = new SECT_ModifSectorParams(m_pSectorInterface, E_mt_ChangeSoundVolume, E_Sound, pSound, iFinalPos, NULL); // update dialog m_pSectorInterface->M_GetEditManager()->AskFor(pModif); } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnSelChangeSoundEventList (NMHDR * pNMHDR, LRESULT * pResult) { SECT_ModifSectorParams *pModif; SECT_SoundEventElement *pSoundEventElem; SECT_ElementBase *pElem; SECT_SoundEvent *pSoundEvent = NULL; Sector_Object *pSectObj; LPNM_LISTVIEW pNMListView = (LPNM_LISTVIEW)pNMHDR; BOOL bOldSelect, bNewSelect; int iIndex; // update param *pResult = 0; // no sound DLL => no change in sound environment if (!m_pSectorInterface->GetSoundEventList()) return; // test selection if ((pNMListView->uChanged != LVIF_STATE)||(m_cSoundEventList.fn_bIsSelecting())) return; bOldSelect = (pNMListView->uOldState & LVIS_SELECTED); bNewSelect = (pNMListView->uNewState & LVIS_SELECTED); // get corresponding sector iIndex = pNMListView->iItem; pSoundEvent = (SECT_SoundEvent *) m_cSoundEventList.GetItemData(iIndex); m_cSoundEventList.SetSelectedItem(-1); if (!pSoundEvent) return; if (!pSoundEvent->fn_bIsAvailable()) { //try to load it once: pSoundEvent->GetEditor()->fn_bLoadBaseObject(pSoundEvent); if (!pSoundEvent->fn_bIsAvailable()) return; } if (bOldSelect != bNewSelect) { pSectObj = (Sector_Object *) m_pEditedSector->GetObject(); pElem = pSectObj->GetSoundEventList()->GetElementWithSector(m_pSelectedSector); if (!pElem) return; pSoundEventElem = (SECT_SoundEventElement *) pElem; // check if sound event already belongs to the list if (m_cSoundEventList.fn_bIsInCurrentList(pSoundEvent)) { pModif = new SECT_ModifSectorParams(m_pSectorInterface, E_mt_DelSoundEvent, E_SoundEvent, pSoundEventElem, -1, pSoundEvent); } else { pModif = new SECT_ModifSectorParams(m_pSectorInterface, E_mt_AddSoundEvent, E_SoundEvent, pSoundEventElem, -1, pSoundEvent); } // update selection m_pSectorInterface->M_GetEditManager()->AskFor(pModif); // redraw item m_cSoundEventList.RedrawItems(iIndex, iIndex); m_cSoundEventList.UpdateWindow(); // update dialog m_pSectorInterface->GetSingleList(E_SoundEvent)->fn_vUpdateSelection(m_pSelectedSector); } } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnSymetric (void) { SECT_ModifSymetricSelect *pModif; pModif = new SECT_ModifSymetricSelect(m_pSectorInterface, E_tm_SymetricSelect, m_pEditedSector, m_pSelectedSector); m_pSectorInterface->M_GetEditManager()->AskFor(pModif); } /*---------------------------------------- ----------------------------------------*/ void SECT_DialogSel::OnRButtonDown (UINT nFlags, CPoint point) { BOOL bCopy; ClientToScreen( &point ); // create popup menu CMenu oMenu; oMenu.CreatePopupMenu(); // check if there is already a copy bCopy = (m_pSectorInterface->GetCopyOfSectorList()->GetCount() > 0); // Add Entry oMenu.AppendMenu(MF_STRING | MF_ENABLED, C_uiCopyEntry, "Copy List"); oMenu.AppendMenu(MF_STRING | (bCopy) ? MF_ENABLED : MF_GRAYED, C_uiPasteEntry, "Paste List"); oMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); // destroy menus oMenu.DestroyMenu(); } /*---------------------------------------- ----------------------------------------*/ BOOL SECT_DialogSel::OnCommand (WPARAM wParam, LPARAM lParam) { // command from a menu ? if (HIWORD(wParam) == 0) { // ID of menu item ? switch (LOWORD(wParam)) { // column headers case C_uiCopyEntry: m_pSectorInterface->fn_vCopySectorList(m_pSectorInterface->GetEditedSector(), E_NoActiveList); break; case C_uiPasteEntry: m_pSectorInterface->fn_vPasteSectorList(m_pSectorInterface->GetEditedSector(), E_NoActiveList); break; } } return CWnd::OnCommand(wParam, lParam); } //################################################################################# // LIST BOX //################################################################################# /*---------------------------------------- ----------------------------------------*/ SECT_SndEvListBox::SECT_SndEvListBox (void) { // init dialog parameters m_pDialogSel = NULL; m_pSectorInterface = NULL; } /*---------------------------------------- ----------------------------------------*/ void SECT_SndEvListBox::fn_vInitDialogParameters (SECT_DialogSel *pDialogSel) { // init parameters m_pDialogSel = pDialogSel; m_pSectorInterface = m_pDialogSel->GetSectorInterface(); // set permanent style and display SetDrawStyle(C_lDrawName, FALSE, FALSE); SetDisplayGray(TRUE, TRUE, FALSE); // set parameters SetOwnerEditor(m_pSectorInterface); } /*---------------------------------------- ----------------------------------------*/ void SECT_SndEvListBox::DrawItem (LPDRAWITEMSTRUCT lpDIS) { SECT_SoundEvent *pSoundEvent; COLORREF cTextColor; COLORREF cRectColor; CString csText; CDC *pDC; if (!m_pDialogSel) return; // init parameters pSoundEvent = (SECT_SoundEvent *) GetItemData(lpDIS->itemID); // drawing rect pDC = CDC::FromHandle(lpDIS->hDC); // in current list => blue rect if (fn_bIsInCurrentList(pSoundEvent)) { cRectColor = RGB (0, 0, 0); cTextColor = RGB (254, 254, 254); } // normal sector => black else { cRectColor = GetSysColor(COLOR_WINDOW); cTextColor = RGB (128, 0, 0); } // draw item pDC->FillSolidRect(&lpDIS->rcItem, cRectColor); pDC->SetBkMode(TRANSPARENT); lpDIS->rcItem.left += 2; pDC->SetTextColor(cTextColor); pDC->DrawText(pSoundEvent->GetNameToDraw(), &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER); } /*---------------------------------------- ----------------------------------------*/ BOOL SECT_SndEvListBox::fn_bIsInCurrentList (CPA_SaveObject *pSoundEvent) { SECT_SoundEventElement *pSoundEventElem; SECT_SndEvtEngineElem *pSndEvElem; SECT_ElementBase *pElem; Sector_Object *pSectObj; if (!m_pDialogSel->GetEditedSector()) return FALSE; // get parameters pSectObj = (Sector_Object *) m_pDialogSel->GetEditedSector()->GetObject(); pElem = pSectObj->GetSoundEventList()->GetElementWithSector(m_pDialogSel->GetSelectedSector()); if (!pElem) return FALSE; // check if sound event already belongs to the list pSoundEventElem = (SECT_SoundEventElement *) pElem; pSndEvElem = pSoundEventElem->GetElementWithSoundEvent(pSoundEvent); return (pSndEvElem != NULL); }