Ejemplo n.º 1
0
CRadio::~CRadio()
{
	if (gEnv->pInput)
	{
		gEnv->pInput->RemoveEventListener(this);
	}

	CancelRadio();
}
Ejemplo n.º 2
0
void CRadio::CloseRadioMenu()
{
	PlaySound("sounds/interface:menu:close");
	CancelRadio();

	g_pGameActions->FilterMPRadio()->Enable(false);
#if !defined(CRY_USE_GCM_HUD)
	if (gEnv->pInput) gEnv->pInput->RemoveEventListener(this);
#endif

	m_menuOpenTime = 0.0f;
}
Ejemplo n.º 3
0
bool CRadio::OnInputEvent( const SInputEvent &event )
{
	if (event.deviceId != eDI_Keyboard)
	{
		return false;
	}

	if (!gEnv->bMultiplayer)
	{
		return false;
	}

	//CryLogAlways("RADIO: Input[%3.2f] %s %d", gEnv->pTimer->GetCurrTime(), event.keyName.c_str(), event.state);
	// Signal that input events have been processed and sent to all listeners.
	m_waitForInputEvents = false;
	const char *sKey = event.keyName.c_str();
	// nasty check, but fastest early out
	int iKey = -1;

	if(sKey != 0 && sKey[0] && !sKey[1])
	{
		iKey = atoi(sKey);

		if(iKey == 0 && sKey[0] != '0')
		{
			iKey = -1;
		}
	}

	if(iKey == -1)
	{
		return false;
	}

	if (event.state == eIS_Released)
	{
		m_keyState[iKey] = false;
	}

	bool pressed = false;

	if ((!m_keyState[iKey]) && ((event.state == eIS_Pressed) || (event.state == eIS_Down)))
	{
		pressed = true;
		m_keyState[iKey] = true;
	}

	if(gEnv->pConsole->GetStatus())
	{
		return false;
	}

	// ignore sub keys while menu is closed.
	bool menuOpen = (m_currentGroup != -1);

	if (!menuOpen)
	{
		return false;
	}

	// ignore this key, since it was pressed before or when menu opened.
	if (m_keyIgnored[iKey])
	{
		return false;
	}

	if (!pressed)
	{
		return false;
	}

	if(!GetRadioSoundName(m_pGameRules, m_TeamName, m_currentGroup + 1, iKey))
	{
		return false;
	}

	m_keyState[iKey] = false; // release will never come, since the input event listened is unregistered.
	m_inputEventConsumedKey = true; // next pending menu update, ignore menu change, since this key was used in the sublevel.

	// reset key ignorance.
	for (int i = 0; i < 10; ++i)
	{
		m_keyIgnored[i] = false;
	}

	// prevent spamming radio messages
	m_lastMessageTime = gEnv->pTimer->GetCurrTime();
	//PlayVoice(pSoundName);
	int id = (m_currentGroup * RADIO_GROUP_SIZE + iKey) - 1;
	m_pGameRules->SendRadioMessage(gEnv->pGame->GetIGameFramework()->GetClientActor()->GetEntityId(), id);
	CancelRadio();
	m_menuOpenTime = 0.0f;
	g_pGameActions->FilterMPRadio()->Enable(false);

	if (gEnv->pInput)
	{
		gEnv->pInput->RemoveEventListener(this);
	}

	return true;
}