コード例 #1
0
ファイル: MainMenus.cpp プロジェクト: bsmr-games/Blood2
// Handle a key press
DBOOL CMainMenus::HandleKeyDown(int key, int rep)
{
	if (key == VK_SHIFT || key == VK_LSHIFT || key == VK_RSHIFT)
	{
		m_bShiftState = DTRUE;
		CLTGUICtrl::SetShiftState(m_bShiftState);
	}

	// Pass the key to the message box if we are in one
	if ( m_bInMessageBox )
	{
		return m_messageBox.HandleKeyDown(key, rep);		
	}

	if (!m_pCurrentMenu)
	{
		return DFALSE;
	}
	if (!m_pCurrentMenu->HandleKeyDown(key, rep))
	{
		switch ( key )
		{
		case VK_ESCAPE:
			{				
				if ( m_pCurrentMenu == m_pTopLevelMenu )
				{
					// Return to the game if we are in a world
					if ( g_pBloodClientShell->IsInWorld() )
					{
						g_pBloodClientShell->MenuReturnToGame();
					}
					else
					{
						// We better be at the main menu!
						assert(m_pCurrentMenu == &m_mainMenu);
					}
				}
				else
				{
					// Play the sound
					PlayEscSound();

					CMenuBase *pParentMenu;
					pParentMenu=m_pCurrentMenu->GetParentMenu();
					if ( pParentMenu )
					{
						assert(m_pTopLevelMenu);
						SetCurrentMenu(pParentMenu->GetMenuID(), m_pTopLevelMenu->GetMenuID());
					}
				}
				break;
			}						
		}
	}
	
	return DTRUE;
}
コード例 #2
0
ファイル: BaseMenu.cpp プロジェクト: Arc0re/lithtech
void CBaseMenu::Esc()
{
	if (!m_pClientDE || !m_pRiotMenu) return;

	CBaseMenu* pCurrentMenu = m_pRiotMenu->GetCurrentMenu();
	if (!pCurrentMenu) return;

	if (pCurrentMenu->m_pParent)
	{
		m_pRiotMenu->SetCurrentMenu (pCurrentMenu->m_pParent);
	}

	PlayEscSound();
}