// 分发控制命令 void DispatchControl(CTRL _ctrl) { switch(_ctrl) { case CTRL_ROTATE: OnRotate(); break; case CTRL_LEFT: OnLeft(); break; case CTRL_RIGHT: OnRight(); break; case CTRL_DOWN: OnDown(); break; case CTRL_SINK: OnSink(); break; case CTRL_QUIT: break; } }
LTBOOL CFolderAdvDisplay::OnLButtonUp(int x, int y) { int nControlIndex=0; if (GetControlUnderPoint(x, y, &nControlIndex)) { CLTGUICtrl* pCtrl = GetControl(nControlIndex); if (pCtrl == m_pLightMap) { return OnRight(); } } return CBaseFolder::OnLButtonUp(x, y); }
EVENT_RESULT CGUISelectButtonControl::OnMouseEvent(const CPoint &point, const CMouseEvent &event) { if (event.m_id == ACTION_MOUSE_LEFT_CLICK) { if (m_bShowSelect && m_imgLeft.HitTest(point)) OnLeft(); else if (m_bShowSelect && m_imgRight.HitTest(point)) OnRight(); else // normal select CGUIButtonControl::OnMouseEvent(point, event); return EVENT_RESULT_HANDLED; } else if (event.m_id == ACTION_MOUSE_WHEEL_UP) { OnLeft(); return EVENT_RESULT_HANDLED; } else if (event.m_id == ACTION_MOUSE_WHEEL_DOWN) { OnRight(); return EVENT_RESULT_HANDLED; } return EVENT_RESULT_UNHANDLED; }
LTBOOL CFolderDisplay::OnLButtonUp(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 "enter" message to the control. if (nControlIndex == m_nLMouseDownItemSel) { if (pCtrl->IsEnabled() ) { if (pCtrl == m_pRendererCtrl) { // Get the current resolution FolderDisplayResolution currentResolution=GetCurrentSelectedResolution(); LTBOOL handled = pCtrl->OnLButtonUp(x, y); if (handled) { SetupResolutionCtrl(); // Set the resolution for the control SetCurrentCtrlResolution(currentResolution); } return handled; } else if (pCtrl == m_pHardwareCursor) { return OnRight(); } else { SetSelection(nControlIndex); return CBaseFolder::OnLButtonUp(x,y); } } } } else { m_nLMouseDownItemSel= kNoSelection; } return LTFALSE; }
bool CGUIControl::OnAction(const CAction &action) { if (HasFocus()) { switch (action.GetID()) { case ACTION_MOVE_DOWN: OnDown(); return true; case ACTION_MOVE_UP: OnUp(); return true; case ACTION_MOVE_LEFT: OnLeft(); return true; case ACTION_MOVE_RIGHT: OnRight(); return true; case ACTION_SHOW_INFO: return OnInfo(); case ACTION_NAV_BACK: return OnBack(); case ACTION_NEXT_CONTROL: OnNextControl(); return true; case ACTION_PREV_CONTROL: OnPrevControl(); return true; } } return false; }
LTBOOL CLTGUISlider::OnLButtonUp(int x, int y) { if (m_bDisplayOnly) return LTFALSE; if (m_bOverLeft) return OnLeft(); if (m_bOverRight) return OnRight(); if (x >= m_rcBar.left && y >= m_rcBar.top && x <= m_rcBar.right && y <= m_rcBar.bottom) { float fPercent = (float)(x - m_rcBar.left) / (float)(m_rcBar.right - m_rcBar.left); int nPos = m_nSliderIncrement * (int)((fPercent * (float)(m_nMaxSlider - m_nMinSlider) / (float)m_nSliderIncrement) + 0.5f); if (nPos+m_nMinSlider != m_nSliderPos) { if (m_pCallback && !m_pCallback(this,(nPos+m_nMinSlider),m_nSliderPos)) return LTFALSE; SetSliderPos(nPos+m_nMinSlider); return LTTRUE; } } return LTFALSE; }
// Handles a key press. Returns FALSE if the key was not processed through this method. // Left, Up, Down, Right, and Enter are automatically passed through OnUp(), OnDown(), etc. DBOOL CMenuBase::HandleKeyDown(int key, int rep) { switch (key) { case VK_LEFT: { OnLeft(); break; } case VK_RIGHT: { OnRight(); break; } case VK_UP: { OnUp(); break; } case VK_DOWN: { OnDown(); break; } case VK_RETURN: { OnEnter(); break; } default: { return m_listOption.HandleKeyDown(key, rep); break; } } // Handled the key return DTRUE; }
LTBOOL CScreenDisplay::OnLButtonUp(int x, int y) { uint16 nControlIndex=0; if (GetControlUnderPoint(x, y, &nControlIndex)) { CLTGUICtrl* pCtrl = GetControl(nControlIndex); if (pCtrl == m_pHardwareCursor) { return OnRight(); } if (pCtrl == m_pGamma) { if (!pCtrl->OnLButtonUp(x,y)) return LTFALSE; pCtrl->UpdateData(); float fGamma = ConvertToGamma(m_nGamma); WriteConsoleFloat("GammaR",fGamma); WriteConsoleFloat("GammaG",fGamma); WriteConsoleFloat("GammaB",fGamma); return LTTRUE; } } return CBaseScreen::OnLButtonUp(x, y); }
EMenuAction CMenuBase::Update (void) { // Increase time elapsed in this menu mode m_MenuModeTime += m_pTimer->GetDeltaTime (); // If we don't have to exit this menu mode yet if (!m_HaveToExit) { // If NEXT control is pressed if (m_pInput->GetMainInput().TestNext()) { // Don't play menu next sound because the choices of the user // could not be correct and we may have to play an error sound instead. OnNext (); } // If PREVIOUS control is pressed else if (m_pInput->GetMainInput().TestPrevious()) { // Play the menu previous sound m_pSound->PlaySample (SAMPLE_MENU_PREVIOUS); OnPrevious (); } // If UP control is pressed else if (m_pInput->GetMainInput().TestUp()) { // Play the menu beep sound m_pSound->PlaySample (SAMPLE_MENU_BEEP); OnUp (); } // If DOWN control is pressed else if (m_pInput->GetMainInput().TestDown()) { // Play the menu beep sound m_pSound->PlaySample (SAMPLE_MENU_BEEP); OnDown (); } // If LEFT control is pressed else if (m_pInput->GetMainInput().TestLeft()) { // Play the menu beep sound m_pSound->PlaySample (SAMPLE_MENU_BEEP); OnLeft (); } // If RIGHT control is pressed else if (m_pInput->GetMainInput().TestRight()) { // Play the menu beep sound m_pSound->PlaySample (SAMPLE_MENU_BEEP); OnRight (); } // Update the menu screen OnUpdate (); } // If the transition has been entirely done (enough time has elapsed) else if (m_MenuModeTime >= m_ExitMenuModeTime + TRANSITION_DURATION) { // It's OK to exit now! // Ask for the menu action we saved return m_ExitMenuAction; } // Don't have to change menu mode nor game mode return MENUACTION_NONE; }