Esempio n. 1
0
bool MenuState::Update(Ndk::StateMachine& fsm, float /*elapsedTime*/)
{
	if (m_selectedNextState != -1) {
		fsm.ChangeState(StateFactory::Get(m_selectedNextState + 1));
	}

	return true;
}
Esempio n. 2
0
void KeyState::ManageInput(KeyStatus isKeyPressed, const Nz::WindowEvent::KeyEvent& key, Ndk::StateMachine& fsm)
{
	if (key.code == Nz::Keyboard::Key::M && key.shift)
		fsm.ChangeState(StateFactory::Get(EventStatus::Menu));
	else if (key.code == Nz::Keyboard::Key::N && key.shift)
	{
		if (m_keyStatus == KeyStatus::Pressed)
			m_keyStatus = KeyStatus::Released;
		else
			m_keyStatus = KeyStatus::Pressed;
	}
	else 
	{
		Nz::String content;
		if (m_keyStatus == KeyStatus::Pressed)
			content = "Pressed: ";
		else
			content = "Released: ";

		Nz::String keyName = Nz::Keyboard::GetKeyName(key.code);
		if (keyName.IsEmpty())
		{
			m_text.SetContent("Unknown\nM for Menu");
		}
		else
		{
			content += keyName;
			if (key.alt)
				content += " alt";
			if (key.control)
				content += " control";
			if (key.repeated)
				content += " repeated";
			if (key.shift)
				content += " shift";
			if (key.system)
				content += " system";
			
			m_text.SetContent(content + "\nM for Menu");
		}
	}
}
Esempio n. 3
0
void TextEnterState::Enter(Ndk::StateMachine& fsm)
{
	m_text.SetVisible(true);
	DrawMenu();

	Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
	m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
	{
		if (key.code == Nz::Keyboard::Key::M && key.shift)
		{
			fsm.ChangeState(StateFactory::Get(EventStatus::Menu));
		}
	});

	m_textEnteredSlot.Connect(eventHandler.OnTextEntered, [&] (const Nz::EventHandler*, const Nz::WindowEvent::TextEvent& event)
	{
		Nz::String content = "Character: " + Nz::String::Unicode(event.character);
		if (event.repeated)
			content += " repeated";
		m_text.SetContent(content + "\nM for Menu");
	});
}
void WindowModificationState::Enter(Ndk::StateMachine& fsm)
{
	BaseState::Enter(fsm);

	Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
	m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
	{
		if (key.code == Nz::Keyboard::Key::M && key.shift)
		{
			fsm.ChangeState(StateFactory::Get(EventStatus::Menu));
		}
	});

	m_movedSlot.Connect(eventHandler.OnMoved, [&] (const Nz::EventHandler*, const Nz::WindowEvent::PositionEvent& event)
	{
		m_text.SetContent("Position(" + Nz::String::Number(event.x) + ", " + Nz::String::Number(event.y) + ")\nM for Menu");
	});

	m_resizedSlot.Connect(eventHandler.OnResized, [&] (const Nz::EventHandler*, const Nz::WindowEvent::SizeEvent& event)
	{
		m_text.SetContent("Size(" + Nz::String::Number(event.width) + ", " + Nz::String::Number(event.height) + ")\nM for Menu");
	});
}
Esempio n. 5
0
void FocusState::Enter(Ndk::StateMachine& fsm)
{
	m_text.SetVisible(true);
	DrawMenu();

	Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
	m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
	{
		if (key.code == Nz::Keyboard::Key::M && key.shift)
		{
			fsm.ChangeState(StateFactory::Get(EventStatus::Menu));
		}
	});

	m_gainedFocusSlot.Connect(eventHandler.OnGainedFocus, [&] (const Nz::EventHandler*)
	{
		m_text.SetContent("GAINED\nM for Menu");
	});

	m_lostFocusSlot.Connect(eventHandler.OnLostFocus, [&] (const Nz::EventHandler*)
	{
		m_text.SetContent("LOST\nM for Menu");
	});
}