Exemplo n.º 1
0
	bool HudItemButton::onInput(const InputEvent &event) {
		bool is_mouse_over = isMouseOver(event);
		if(event.isMouseOverEvent()) {
			setHighlighted(is_mouse_over);
			if(is_mouse_over && isVisible())
				handleEvent(this, HudEvent::item_focused);


		}
		if(event.mouseButtonDown(InputButton::left) && is_mouse_over)
			handleEvent(this, isEnabled()? HudEvent::item_unequip : HudEvent::item_equip);

		if(event.mouseButtonDown(InputButton::right) && is_mouse_over) {
			if(isEnabled()) {
				handleEvent(this, HudEvent::item_unequip);
			}
			else {
				m_drop_count = 1.0;
				m_drop_start_pos = (float2)event.mousePos();
			}
		}

		if(event.mouseButtonPressed(InputButton::right) && isDropping())
			m_drop_diff = (event.mousePos().y - m_drop_start_pos.y) / 20.0f;
		if(event.mouseButtonUp(InputButton::right) && isDropping()) {
			if(dropCount() > 0)
				handleEvent(this, HudEvent::item_drop, dropCount());
			m_drop_count = -1.0f;
		}

		return false;
	}
Exemplo n.º 2
0
	bool HudConsole::onInput(const InputEvent &event) {
		if(event.keyDown('`') || (event.mouseButtonDown(InputButton::left) && !isMouseOver(event))) {
			setVisible(false);
			return true;
		}
		if(isVisible() && event.key() >= 32 && event.key() <= 127)
			return true;
		
		//TODO: fixme

		return false;
	}