summaryrefslogtreecommitdiff
path: root/src/main/java/net/tylermurphy/Minecraft/UI/UIImage.java
blob: 7e772ab6d3c85c7322553ee5340509b70e68ce2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package net.tylermurphy.Minecraft.UI;

import org.joml.Vector2f;

import net.tylermurphy.Minecraft.Render.Data.Display;

public class UIImage extends UIComponent {

	private int texture;
	
	public void setTexture(int texture) {
		this.texture = texture;
	}
	
	public int getTexture() {
		return texture;
	}
	
	public boolean clicked() {
		Vector2f pos = Display.getCursorPos();
		float x1 = super.getConvertedPosition().x*Display.getWidth();
		float y1 = super.getConvertedPosition().y*Display.getHeight();
		float x2 = super.getConvertedPosition().x*Display.getWidth()+super.getConvertedSize().x*Display.getWidth();
		float y2 = super.getConvertedPosition().y*Display.getHeight()+super.getConvertedSize().y*Display.getHeight();
		if(pos.x >= x1 && pos.x <= x2 && pos.y >= y1 && pos.y <= y2)
			return true;
		return false;
	}
	
}