void CMenuMgr::EnableMenuBar(bool bEnable/*=true*/, uint32 nMenuFlags/*=MB_ALL*/) { // Determine the state of each control based on the flags passed... uint32 MBCtrlFlags[MB_NUM_CTRLS] = { MB_SYSTEM, MB_MISSION, MB_INVENTORY, MB_KEYS, MB_INTEL, MB_PLAYER }; if (!IsCoopMultiplayerGameType()) { nMenuFlags &= ~(MB_MISSION & MB_KEYS & MB_INTEL & MB_PLAYER); } for (int i=0; i < MB_NUM_CTRLS; i++) { CLTGUICtrl* pCtrl = m_MenuBar.GetControl(i); if (pCtrl) { if (MBCtrlFlags[i] & nMenuFlags) { pCtrl->Enable(bEnable); } else { pCtrl->Enable(!bEnable); } // Okay this is pretty much a hack since we use the disabled state to // really specify a selected control (see CMenuMgr::SwitchToMenu()), but in the // case of Enable = true we really want the menu bar to be disabled, we'll handle // this here by changing the color of the disabled state... if (pCtrl->IsDisabled()) { pCtrl->SetColors(g_nSelectColor,argbBlack,argbGray); } else { // Control is enabled, so we'll set it's "disabled" color to white... pCtrl->SetColors(g_nSelectColor,argbBlack,argbWhite); // We need to disable the current menu control here using the new // color (i.e., it will appear white signifying it is actually // the current control)... if (i == m_nMenuIndex) { pCtrl->Enable(false); } } } } }
void CMenuMgr::SwitchToMenu(CBaseMenu *pNewMenu) { if (!pNewMenu || !pNewMenu->IsEnabled()) return; if (m_pSubMenu) { HideSubMenu(true); } // Tell the old menu that it is losing focus if (m_pCurrentMenu) { m_pCurrentMenu->OnFocus(LTFALSE); } m_pLastMenu = m_pCurrentMenu; m_pCurrentMenu=pNewMenu; // Tell the new menu that it is gaining focus if (pNewMenu) { LTIntPt tmp = pNewMenu->GetBasePos(); tmp.y = 0; pNewMenu->SetBasePos(tmp); pNewMenu->OnFocus(LTTRUE); m_MenuBar.SetScale(g_pInterfaceResMgr->GetXRatio()); for (uint8 i =0; i < m_MenuArray.size(); i++) { CLTGUICtrl* pCtrl = m_MenuBar.GetControl(i); pCtrl->Enable(i != m_nMenuIndex); } } }