Пример #1
0
int KUiInit::OnKeyDown(unsigned int uKey)
{
	int	nRet = 1;
	KWndButton* pActive = NULL;
	KWndButton* pToActive = NULL;
	if (uKey == VK_RETURN)
	{
		if (pActive = GetActiveBtn())
			OnClickButton(pActive);
	}
	else if (uKey == VK_UP)
	{
		pActive = GetActiveBtn();
		if (pActive == &m_ExitGame)
			pToActive = &m_DesignerList;
		else if (pActive == &m_DesignerList)
			pToActive = &m_GameConfig;
		else if (pActive == &m_EnterGame)
			pToActive = &m_ExitGame;
		else
			pToActive = &m_EnterGame;
	}
	else if (uKey == VK_DOWN)
	{
		pActive = GetActiveBtn();
		if (pActive == &m_EnterGame)
			pToActive = &m_GameConfig;
		else if (pActive == &m_GameConfig)
			pToActive = &m_DesignerList;
		else if (pActive == &m_DesignerList)
			pToActive = &m_ExitGame;
		else
			pToActive = &m_EnterGame;
	}
	else
		nRet = 0;
	if (pToActive)
		pToActive->SetCursorAbove();
	return nRet;
}
Пример #2
0
int KUiSelPlayer::OnKeyDown(unsigned int uKey)
{
	int			nRet = 1;
	KWndWindow* pActive = NULL;
	KWndButton* pToActive = NULL;
	switch (uKey)
	{
	case VK_RETURN:
		pActive = GetActiveBtn();
		if (pActive == NULL && m_btnOk.IsDisable() == FALSE)
			pActive = &m_btnOk;
		OnClickButton((KWndButton*)pActive, false);
		break;
	case VK_ESCAPE:
		OnCancel();
		nRet = 1;
		break;
	case VK_UP:
		pActive = GetActiveBtn();
		if (pActive == &m_btnCancel)
			pToActive = &m_btnDel;
		else if (pActive == &m_btnDel)
			pToActive = &m_btnNew;
		else if (pActive == &m_btnOk)
			pToActive = &m_btnCancel;
		else
			pToActive = &m_btnOk;
		nRet = 1;
		break;
	case VK_DOWN:
		pActive = GetActiveBtn();
		if (pActive == &m_btnOk)
			pToActive = &m_btnNew;
		else if (pActive == &m_btnNew)
			pToActive = &m_btnDel;
		else if (pActive == &m_btnCancel)
			pToActive = &m_btnOk;
		else
			pToActive = &m_btnCancel;
		nRet = 1;
		break;
	case VK_LEFT:
		if (m_nSelPlayer > 0)
			OnSelectPlayer(m_nSelPlayer - 1);
		else if (m_nSelPlayer < 0 && m_nNumPlayer > 0)
			OnSelectPlayer(0);
		m_btnDel.Enable(m_nSelPlayer >= 0);
		nRet = 1;
		break;
	case VK_RIGHT:
	case VK_SPACE:
		if (m_nSelPlayer < m_nNumPlayer - 1)
			OnSelectPlayer(m_nSelPlayer + 1);
		else if (m_nNumPlayer < 0 && m_nNumPlayer > 0)
			OnSelectPlayer(0);
		m_btnDel.Enable(m_nSelPlayer >= 0);
		nRet = 1;
		break;
	default:
		nRet = 0;
	}
	if (pToActive)
		pToActive->SetCursorAbove();
	return nRet;
}
Пример #3
0
int KUiESCDlg::OnKeyDown(unsigned int uKey)
{
	int	nRet = 1;
	KWndButton* pActive = NULL;
	KWndButton* pToActive = NULL;
	if (uKey == VK_RETURN)
	{
		if (pActive = GetActiveBtn())
			OnClickButton(pActive);
	}
	else if (uKey == VK_ESCAPE)
		CloseWindow(false);
	else if (uKey == VK_UP)
	{
		pActive = GetActiveBtn();
		if (pActive == &m_ExitGameBtn)
			pToActive = &m_ContinueGameBtn;
		//else if (pActive == &m_ExitBtn)
		//	pToActive = &m_ExitGameBtn;
		else if (pActive == &m_HelpBtn)
			pToActive = &m_ExitGameBtn;
		//else if (pActive == &m_TaskBtn)
		//	pToActive = &m_HelpBtn;
		else if (pActive == &m_OptionsBtn)
			pToActive = &m_HelpBtn;
		else if (pActive == &m_ContinueGameBtn)
			pToActive = &m_OptionsBtn;
		else
			pToActive = &m_ExitGameBtn;
	}
	else if (uKey == VK_DOWN)
	{
		pActive = GetActiveBtn();
		if (pActive == &m_ExitGameBtn)
			pToActive = &m_HelpBtn;
		//else if (pActive == &m_ExitBtn)
		//	pToActive = &m_HelpBtn;
		else if (pActive == &m_HelpBtn)
			pToActive = &m_OptionsBtn;
		//else if (pActive == &m_TaskBtn)
		//	pToActive = &m_OptionsBtn;
		else if (pActive == &m_OptionsBtn)
			pToActive = &m_ContinueGameBtn;
		else if (pActive == &m_ContinueGameBtn)
			pToActive = &m_ExitGameBtn;
		else
			pToActive = &m_ExitGameBtn;
	}
	else
		nRet = 0;
	if (pToActive)
	{
		POINT		Pos;
		SIZE		Size;
		pToActive->GetAbsolutePos((int*)&Pos.x, (int*)&Pos.y);
		pToActive->GetSize((int*)&Size.cx, (int*)&Size.cy);
		Pos.x += Size.cx / 2;
		Pos.y += Size.cy / 2;
		Wnd_SetCursorPos(Pos.x, Pos.y);
	}
	return nRet;
}