void CScreenConfigure::AdjustControlFrame() { if (m_nType >= kNumCommandTypes) { m_pFrame->Show(LTFALSE); return; } uint16 nWd = m_nActionWidth + m_nEqualsWidth + m_nCommandWidth; m_pFrame->Show(LTTRUE); m_pList[m_nType]->CalculatePositions(); LTIntPt listpos = m_pList[m_nType]->GetBasePos(); uint16 i = m_pList[m_nType]->GetNumControls() - 1; CLTGUICtrl *pCtrl = m_pList[m_nType]->GetControl(i); if (pCtrl) { LTIntPt pos = pCtrl->GetBasePos(); uint16 nHt = (pos.y - listpos.y) + pCtrl->GetBaseHeight() + 4; m_pFrame->SetSize(nWd+8,nHt); m_pList[m_nType]->SetHeight(nHt); } }
LTBOOL CFolderWeaponControls::OnRButtonUp(int x, int y) { // Get the control that the click was on int nControlIndex=0; if (GetControlUnderPoint(x, y, &nControlIndex)) { CLTGUICtrl* pCtrl = GetControl(nControlIndex); if (pCtrl && pCtrl->GetParam1()) { CLTGUIColumnTextCtrl *pColumn=(CLTGUIColumnTextCtrl *)pCtrl; int nAct = pCtrl->GetParam1()-1; m_nActions[nAct] = GetPreviousCommand(m_nActions[nAct]); int nWeaponId = g_pWeaponMgr->GetWeaponId(m_nActions[nAct]); WEAPON *pWeapon = g_pWeaponMgr->GetWeapon(nWeaponId); if (pWeapon) pColumn->SetString(1,pWeapon->nNameId); else pColumn->SetString(1,IDS_CONTROL_UNASSIGNED); UpdateSelection(); return LTTRUE; } } return CBaseFolder::OnRButtonUp(x, y); }
// Override the left and right controls so that the volumes can be changed LTBOOL CScreenAudio::OnLeft() { LTBOOL handled = LTFALSE; CLTGUICtrl* pCtrl = GetSelectedControl(); if (pCtrl) handled = pCtrl->OnLeft(); if (handled) { if (pCtrl == m_pMusicVolumeCtrl) { UpdateData(LTTRUE); m_pMusicQualityCtrl->Enable(m_bMusicEnabled && m_nMusicVolume > MUSIC_MIN_VOL); SaveSoundSettings(); } else if (pCtrl == m_pMusicQualityCtrl) ConfirmQualityChange(true); else if (pCtrl == m_pSoundQualityCtrl) ConfirmQualityChange(false); else SaveSoundSettings(); g_pInterfaceMgr->RequestInterfaceSound(IS_SELECT); } return handled; }
LTBOOL CFolderIntel::UpdateSelection() { LTBOOL bChanged = CBaseSelectionFolder::UpdateSelection(); if (bChanged) { CLTGUICtrl *pCtrl = GetControl(m_nLastListItem); if (!pCtrl) return LTFALSE; int nIndex = pCtrl->GetParam1(); if (!nIndex) return LTFALSE; IntelItem *pItem = m_intelArray[nIndex-1]; HSTRING hStr = g_pLTClient->FormatString(pItem->nID); m_pDescription->SetString(hStr); g_pLTClient->FreeString(hStr); CScaleFX* pScaleFX = g_pFXButeMgr->GetScaleFX(pItem->nType); SAFE_STRCPY(m_szModel, pScaleFX->szFile); SAFE_STRCPY(m_szSkin, pScaleFX->szSkin); m_vScale = pScaleFX->vInitialScale; m_bChromakey = pScaleFX->bChromakey; if (pScaleFX->fDirOffset > 0.0f) { LTFLOAT fScaleMult = (100.0f/pScaleFX->fDirOffset); VEC_MULSCALAR(m_vScale, m_vScale, fScaleMult); } CreateModelSFX(); } return bChanged; }
LTBOOL CScreenDisplay::OnRight() { if (!CBaseScreen::OnRight()) return LTFALSE; CLTGUICtrl* pCtrl = GetSelectedControl(); if (pCtrl == m_pHardwareCursor) { m_pHardwareCursor->UpdateData(LTTRUE); if (m_bHardwareCursor) { MBCreate mb; mb.eType = LTMB_YESNO; mb.pFn = AreYouSureCallBack; mb.pData = this; g_pInterfaceMgr->ShowMessageBox(IDS_CONFIRM_CURSOR,&mb,0,LTFALSE); } else { g_pCursorMgr->UseHardwareCursor(LTFALSE); WriteConsoleInt("HardwareCursor",0); } } if (pCtrl == m_pGamma) { pCtrl->UpdateData(); float fGamma = ConvertToGamma(m_nGamma); WriteConsoleFloat("GammaR",fGamma); WriteConsoleFloat("GammaG",fGamma); WriteConsoleFloat("GammaB",fGamma); } return LTTRUE; }
void CFolderWeaponControls::UpdateSelection() { CLTGUICtrl *pCtrl = GetSelectedControl(); if (!pCtrl) return; int nComm = pCtrl->GetParam1(); if (!nComm) return; uint8 nWeaponId = g_pWeaponMgr->GetWeaponId(m_nActions[nComm-1]); if (nWeaponId != nLastId) { WEAPON* pWeapon = g_pWeaponMgr->GetWeapon(nWeaponId); if (pWeapon) { SAFE_STRCPY(m_szModel, pWeapon->szInterfaceModel); SAFE_STRCPY(m_szSkin, pWeapon->szInterfaceSkin); VEC_COPY(m_vOffset, pWeapon->vInterfaceOffset); m_fScale = pWeapon->fInterfaceScale; CreateModelSFX(); } nLastId = nWeaponId; } }
bool CScreenDisplay::OnRight() { if (!CBaseScreen::OnRight()) return false; CLTGUICtrl* pCtrl = GetSelectedControl(); if (pCtrl == m_pGamma) { pCtrl->UpdateData(); float fGamma = ConvertToGamma(m_nGamma); WriteConsoleFloat("GammaR",fGamma); WriteConsoleFloat("GammaG",fGamma); WriteConsoleFloat("GammaB",fGamma); } return true; }
LTBOOL CFolderDisplay::OnRButtonUp(int x, int y) { // Get the control that the click was on int nControlIndex=0; if (GetControlUnderPoint(x, y, &nControlIndex)) { CLTGUICtrl* pCtrl = GetControl(nControlIndex); if (m_pCaptureCtrl && pCtrl != m_pCaptureCtrl) return LTFALSE; // If the mouse is over the same control now as it was when the down message was called // then send the "left" message to the control. if (nControlIndex == m_nRMouseDownItemSel) { if (pCtrl->IsEnabled()) { if (GetSelectedControl() == m_pRendererCtrl) { // Get the current resolution FolderDisplayResolution currentResolution=GetCurrentSelectedResolution(); LTBOOL handled = pCtrl->OnRButtonUp(x,y); if (handled) { SetupResolutionCtrl(); // Set the resolution for the control SetCurrentCtrlResolution(currentResolution); } return handled; } else if (pCtrl == m_pHardwareCursor) { return OnLeft(); } else { SetSelection(nControlIndex); return CBaseFolder::OnRButtonUp(x,y); } } } } else { m_nRMouseDownItemSel= kNoSelection; } return LTFALSE; }
// Handle a keypress LTBOOL CScreenConfigure::HandleKeyDown(int key, int rep) { LTBOOL handled = LTFALSE; switch (key) { case VK_DELETE: { // Unassign the key if (!m_bWaitingForKey && !m_fInputPauseTimeLeft) { CLTGUICtrl *pCtrl = m_pList[m_nType]->GetSelectedControl(); int nCommand = pCtrl->GetParam1(); CBindingData* pData = m_pProfile->FindBinding(nCommand); UnBind( pData->nDeviceObjectId[0], NULL, DEVICETYPE_KEYBOARD); UnBind( 0, pData->strTriggerName[1], DEVICETYPE_MOUSE); if (g_pGameClientShell->HasGamepad()) UnBind( 0, pData->strTriggerName[2], DEVICETYPE_GAMEPAD); else if (g_pGameClientShell->HasJoystick()) UnBind(0, pData->strTriggerName[2], DEVICETYPE_JOYSTICK); else UnBind(0, pData->strTriggerName[2], DEVICETYPE_UNKNOWN); SetControlText(pCtrl); handled = LTTRUE; } break; } } // Check to see if the base class is handling this key if (m_bWaitingForKey || m_fInputPauseTimeLeft) return handled; if (!handled) { handled = CBaseScreen::HandleKeyDown(key, rep); } // Handled the key return handled; }
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); } } } } }
// Handles the mouse move message LTBOOL CListCtrl::OnMouseMove(int x, int y) { x += g_pInterfaceResMgr->GetXOffset(); y += g_pInterfaceResMgr->GetYOffset(); int nControlUnderPoint=0; CLTGUICtrl *pCtrl = GetControlUnderPoint(x, y, &nControlUnderPoint); if (m_pUp && CanScrollUp()) m_pUp->Select(pCtrl == m_pUp); if (m_pDown && CanScrollDown()) m_pDown->Select(pCtrl == m_pDown); // If m_bEnableMouseMoveSelect is TRUE then select the item that the mouse is over if (m_bEnableMouseMoveSelect) { if(pCtrl && nControlUnderPoint >= 0) { // Make sure we're enabled if(!pCtrl->IsEnabled()) return LTFALSE; if (GetSelectedItem() != nControlUnderPoint) { SelectItem(nControlUnderPoint); return LTTRUE; } } else { /* //if not on anything select nothing if ( m_nCurrentIndex < (int)m_controlArray.GetSize() ) { m_controlArray[m_nCurrentIndex]->Select(FALSE); } m_nCurrentIndex = kNoSelection; */ } } return LTFALSE; }
LTBOOL CFolderWeaponControls::OnRight() { CLTGUICtrl *pCtrl = GetSelectedControl(); if (pCtrl && pCtrl->GetParam1()) { CLTGUIColumnTextCtrl *pColumn=(CLTGUIColumnTextCtrl *)pCtrl; int nAct = pCtrl->GetParam1()-1; m_nActions[nAct] = GetNextCommand(m_nActions[nAct]); int nWeaponId = g_pWeaponMgr->GetWeaponId(m_nActions[nAct]); WEAPON *pWeapon = g_pWeaponMgr->GetWeapon(nWeaponId); if (pWeapon) pColumn->SetString(1,pWeapon->nNameId); else pColumn->SetString(1,IDS_CONTROL_UNASSIGNED); return LTTRUE; } return CBaseFolder::OnRight(); }
bool CScreenDisplay::OnRButtonUp(int x, int y) { uint16 nControlIndex=0; if (GetControlUnderPoint(x, y, &nControlIndex)) { CLTGUICtrl* pCtrl = GetControl(nControlIndex); if (pCtrl == m_pGamma) { if (!pCtrl->OnRButtonUp(x,y)) return false; pCtrl->UpdateData(); float fGamma = ConvertToGamma(m_nGamma); WriteConsoleFloat("GammaR",fGamma); WriteConsoleFloat("GammaG",fGamma); WriteConsoleFloat("GammaB",fGamma); return true; } } return CBaseScreen::OnRButtonUp(x, y); }
LTBOOL CListCtrl::OnLButtonDblClick(int x, int y) { x += g_pInterfaceResMgr->GetXOffset(); y += g_pInterfaceResMgr->GetYOffset(); m_fNextScrollTime = -1.0f; // Get the control that the click was on int nControlIndex=0; CLTGUICtrl *pCtrl = GetControlUnderPoint(x, y, &nControlIndex); if(pCtrl) { // Make sure we're enabled if(!pCtrl->IsEnabled()) return LTFALSE; // If the mouse is over the same control now as it was when the down message was called // then send the "enter" message to the control. if (nControlIndex == m_nMouseDownItemSel) { if (nControlIndex == kUpSel) { return (!CanScrollUp() || ScrollUp()); } else if (nControlIndex == kDownSel) { return (!CanScrollDown() || ScrollDown()); } else { return m_controlArray[nControlIndex]->OnLButtonDblClick( x, y); } } } else { m_nMouseDownItemSel=kNoSelection; } return LTFALSE; }
LTBOOL CScreenDisplay::OnRButtonUp(int x, int y) { uint16 nControlIndex=0; if (GetControlUnderPoint(x, y, &nControlIndex)) { CLTGUICtrl* pCtrl = GetControl(nControlIndex); if (pCtrl == m_pHardwareCursor) { return OnLeft(); } if (pCtrl == m_pGamma) { if (!pCtrl->OnRButtonUp(x,y)) return LTFALSE; pCtrl->UpdateData(); float fGamma = ConvertToGamma(m_nGamma); WriteConsoleFloat("GammaR",fGamma); WriteConsoleFloat("GammaG",fGamma); WriteConsoleFloat("GammaB",fGamma); return LTTRUE; } } return CBaseScreen::OnRButtonUp(x, y); }
// Handles the left button down message LTBOOL CListCtrl::OnLButtonDown(int x, int y) { x += g_pInterfaceResMgr->GetXOffset(); y += g_pInterfaceResMgr->GetYOffset(); // Get the control that the click was on int nControlIndex=0; CLTGUICtrl *pCtrl = GetControlUnderPoint(x, y, &nControlIndex); if(pCtrl) { // Make sure we're enabled if(!pCtrl->IsEnabled()) return LTFALSE; if (nControlIndex >= 0 && m_bEnableMouseClickSelect) { // Select the control SelectItem(nControlIndex); } if ((nControlIndex == kUpSel && CanScrollUp())|| (nControlIndex == kDownSel && CanScrollDown())) m_fNextScrollTime = g_pLTClient->GetTime()+m_fScrollFirstDelay; // Record this control as the one being selected from the mouse click. // If the mouse is still over it on the UP message, then the "enter" message will be sent. m_nMouseDownItemSel=nControlIndex; return LTTRUE; } else { // This clears the index for what item was selected from a mouse down message m_nMouseDownItemSel=kNoSelection; return LTFALSE; } }
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); } } }
bool CMessageBox::HandleKeyDown(int key, int rep) { // XENON: Currently disabled in Xenon builds #if !defined(PLATFORM_XENON) if (!m_bVisible) return false; if (m_eType == LTMB_EDIT) { //special handling for right and left arrows so that they may cycle through controls // when the edit box is not selected if (m_Dlg.GetSelectedControl() != m_pEdit) { if (key == VK_LEFT) return m_Dlg.OnUp(); if (key == VK_RIGHT) return m_Dlg.OnDown(); } if (m_pEdit->HandleKeyDown(key,rep)) { UpdateEditOK(); return true; } } bool handled = false; switch (key) { case VK_LEFT: case VK_UP: { handled = m_Dlg.OnUp(); break; } case VK_RIGHT: case VK_DOWN: { handled = m_Dlg.OnDown(); break; } case VK_RETURN: { handled = m_Dlg.OnEnter(); break; } case VK_ESCAPE: { if (!m_bIgnoreEsc) { Close(false); handled = true; } break; } default: { if (m_nHotKey > 0 && key == m_nHotKey) { Close(true); handled = true; } else { CLTGUICtrl* pCtrl = m_Dlg.GetSelectedControl(); if (pCtrl) handled = pCtrl->HandleKeyDown(key,rep); else handled = false; break; } } } // Handled the key return handled; #else // PLATFORM_XENON return false; #endif // PLATFORM_XENON }
LTBOOL CFolderJoin::Render(HSURFACE hDestSurf) { // There's no update pump, so we'll have to do it here... if (GetGameSpyClientMgr()->IsInitialized()) { Update(hDestSurf); } else { UpdateDummyStatus(hDestSurf); } int xo = g_pInterfaceResMgr->GetXOffset(); int yo = g_pInterfaceResMgr->GetYOffset(); //Draw server bar DrawBar(hDestSurf,&rcServerRect); if (m_pServerList->GetLastDisplayedIndex() >= 0) { if (m_pServerList->GetLastDisplayedIndex() != nOldIndex) { if (m_hServersShown) { g_pLTClient->FreeString(m_hServersShown); } //(servers %d-%d) m_hServersShown = g_pLTClient->FormatString(IDS_SERVERS_SHOWN,m_pServerList->GetStartIndex()+1,m_pServerList->GetLastDisplayedIndex()+1); nOldIndex = m_pServerList->GetLastDisplayedIndex(); } GetSmallFont()->Draw(m_hServersShown, hDestSurf, xo+rcServerRect.right-nIndent, yo+rcServerRect.top+nIndent, LTF_JUSTIFY_RIGHT, m_hNonSelectedColor); } CLTGUICtrl *pSortCtrl = LTNULL; switch (m_nServerSort) { case FSS_SORT_NAME: pSortCtrl = pServerNameCtrl; break; case FSS_SORT_PLAYERS: pSortCtrl = pServerPlayersCtrl; break; case FSS_SORT_PING: pSortCtrl = pServerPingCtrl; break; case FSS_SORT_GAME: pSortCtrl = pServerGameCtrl; break; case FSS_SORT_MAP: pSortCtrl = pServerMapCtrl; break; } if (pSortCtrl) { LTIntPt pos = pSortCtrl->GetPos(); pos.x += xo; pos.y += yo; LTRect rect(pos.x, (pos.y + pSortCtrl->GetHeight()) - 5, pos.x + pSortCtrl->GetWidth(), (pos.y + pSortCtrl->GetHeight()) - 3); g_pLTClient->FillRect(hDestSurf,&rect,m_hSelectedColor); } //Draw player bar DrawBar(hDestSurf,&rcPlayerRect); pSortCtrl = LTNULL; switch (m_nPlayerSort) { case FSS_SORT_NAME: pSortCtrl = pPlayerNameCtrl; break; case FSS_SORT_FRAGS: pSortCtrl = pPlayerFragCtrl; break; case FSS_SORT_PING: pSortCtrl = pPlayerPingCtrl; break; } if (pSortCtrl) { LTIntPt pos = pSortCtrl->GetPos(); pos.x += xo; pos.y += yo; LTRect rect(pos.x, (pos.y + pSortCtrl->GetHeight()) - 5, pos.x + pSortCtrl->GetWidth(), (pos.y + pSortCtrl->GetHeight()) - 3); g_pLTClient->FillRect(hDestSurf,&rect,m_hSelectedColor); } //Draw option bar DrawBar(hDestSurf,&rcOptionRect); //Draw option bar DrawBar(hDestSurf,&rcStatusRect); if (m_hStatus) { if (m_nState == FSS_IDLE) GetSmallFont()->Draw(m_hStatus, hDestSurf, xo+nIndent, yo+rcStatusRect.top+nIndent, LTF_JUSTIFY_LEFT, m_hNonSelectedColor); else GetSmallFont()->Draw(m_hStatus, hDestSurf, xo+nIndent, yo+rcStatusRect.top+nIndent, LTF_JUSTIFY_LEFT, m_hSelectedColor); } LTBOOL bOK = CBaseFolder::Render(hDestSurf); if (GetGameSpyClientMgr()->IsInitialized()) { // Let the GameSpy client manager do another update... // GetGameSpyClientMgr()->Update(); } else { if (bFrameDelay) { bFrameDelay = LTFALSE; } else { // Init the GameSpy client manager... BOOL bRet = GetGameSpyClientMgr()->Init(GAMESPY_GAME_NAME, GAMESPY_SECRET_KEY); if (!bRet) { return LTFALSE; } } } return bOK; }