//! sends the UI event
	void VKButton::SendUIEvent()
	{
		UIEvent* pEvent = snew UIEvent();
		pEvent->m_Sender = this;
		pEvent->m_Command = std::string("VK ") + m_Letter;
		EventManager::Instance()->SendEvent(pEvent);
	}
void UIToolbarItem::Tick(const FrameTime& time, UIManager* manager, UIScene* scene)
{
	Input*		input	 = Input::Get();
	MouseState* mouse	 = input->Get_Mouse_State();
	Point		position = mouse->Get_Position();

	// Menu item selected?
	if (m_seperator == false && m_enabled == true)
	{
		if (m_screen_box.Intersects(position))
		{
			if (mouse->Was_Button_Clicked(MouseButton::Left))
			{
				scene->Dispatch_Event(UIEvent(UIEventType::ToolbarItem_Click, this));
			}
			else if (mouse->Is_Button_Down(MouseButton::Left))
			{
				m_state = UIToolbarItemState::Pressed;
			}
			else
			{
				m_state = UIToolbarItemState::Hover;
			}
		}
		else
		{
			m_state = UIToolbarItemState::Normal;
		}
	}

	// Update children.
	UIElement::Tick(time, manager, scene);
}
Example #3
0
	//! sends the UI event
	void Button::SendUIEvent()
	{
		UIEvent* pEvent = snew UIEvent();
		pEvent->m_Sender = this;
		pEvent->m_Command = m_Command;
		pEvent->m_bChecked = m_bChecked;
		EventManager::Instance()->SendEvent(pEvent);
	}
Example #4
0
	//! called during the update of the entity
	void MenuContext::Update()
	{
		if(!m_bTransitionInitialized)		
			InitTransition();		

		switch(m_eState)
		{
		case S_Init:
		{
			m_Timer = 0.2f;
			m_eState = S_Transition;

			if (m_bTransitionIn)
			{
				OnEnter();

				if (FadeRenderer::Instance()->GetDestColor() != Color::Zero)
					FadeRenderer::Instance()->StartFade(Color::Black, Color::Zero, m_Timer, false, false);
				else
					m_Timer = -1.0f;
			}
			else
			{
				OnExit();

				if (FadeRenderer::Instance()->GetDestColor() != Color::Black)
					FadeRenderer::Instance()->StartFade(Color::Zero, Color::Black, m_Timer, false, true);
				else
					m_Timer = -1.0f;
			}
		}			
			break;

		case S_Transition:
			if (m_Timer > 0.0f)
			{
				m_Timer -= g_fDeltaTime;
			}
			else
			{
				m_eState = S_Idle;
				if(!m_ContextToSwitchTo.empty())
				{
					auto nextContext = m_ContextToSwitchTo;
					m_ContextToSwitchTo.clear();
					m_bTransitionInitialized = false;
					super::Switch(nextContext.c_str());
					return;
				}
				else if (m_bPopRequested)
				{
					super::Pop();

					UIEvent* pEvent = snew UIEvent();
					pEvent->m_Command = "POPPED";
					EventManager::Instance()->SendEvent(pEvent);
				}
			}			
			break;

		default:
			super::Update();
		}
	}