Ejemplo 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;
	}
Ejemplo n.º 2
0
	bool HudInventory::onInput(const InputEvent &event) {
		if(event.isMouseOverEvent() && !isMouseOver(event))
			m_out_of_item_time = s_desc_visible_time;
		if(event.isMouseEvent())
			m_last_mouse_pos = event.mousePos();
		return false;
	}