package org.cyclops.cyclopscore.client.gui.component.button;

import net.minecraft.client.Minecraft;
import org.cyclops.cyclopscore.client.gui.image.IImage;

/**
 * A button with an image.
 * @author rubensworks
 *
 */
public class GuiButtonImage extends GuiButtonExtended {

    private IImage image;
    private final int offsetX, offsetY;

	/**
	 * Make a new instance.
	 * @param id The ID.
	 * @param x X
	 * @param y Y
	 * @param width Width
	 * @param height Height
	 * @param image The image to render
     * @param offsetX The x coordinate for the image inside the button.
     * @param offsetY The y coordinate for the image inside the button.
     * @param background If the button background should be rendered.
	 */
	public GuiButtonImage(int id, int x, int y,
                          int width, int height,
                          IImage image, int offsetX, int offsetY,
                          boolean background) {
		super(id, x, y, width, height, "", background);
        this.image = image;
        this.offsetX = offsetX;
        this.offsetY = offsetY;
	}

	/**
	 * Make a new instance.
	 * @param id The ID.
	 * @param x X
	 * @param y Y
	 * @param image The image to render
	 */
	public GuiButtonImage(int id, int x, int y, IImage image) {
		this(id, x, y, image.getWidth(), image.getHeight(), image, 0, 0, false);
	}

	protected void drawButtonInner(Minecraft minecraft, int i, int j, boolean mouseOver) {
        image.draw(this, x + offsetX, y + offsetY);
    }

	public void setImage(IImage image) {
		this.image = image;
	}
}

@@ -287,22 +287,25 @@
 e IImage
+%5B%5D
  image
+s
 ;%0A    pr
@@ -339,16 +339,1009 @@
 fsetY;%0A%0A
+%09/**%0A%09 * Make a new instance.%0A%09 * @param id The ID.%0A%09 * @param x X%0A%09 * @param y Y%0A%09 * @param width Width%0A%09 * @param height Height%0A%09 * @param images The images to render. First images are rendered behind later images.%0A%09 * @param offsetX The x coordinate for the image inside the button.%0A%09 * @param offsetY The y coordinate for the image inside the button.%0A%09 * @param background If the button background should be rendered.%0A%09 */%0A%09public GuiButtonImage(int id, int x, int y,%0A%09%09%09%09%09%09  int width, int height,%0A%09%09%09%09%09%09  IImage%5B%5D images, int offsetX, int offsetY,%0A%09%09%09%09%09%09  boolean background) %7B%0A%09%09super(id, x, y, width, height, %22%22, background);%0A%09%09this.images = images;%0A%09%09this.offsetX = offsetX;%0A%09%09this.offsetY = offsetY;%0A%09%7D%0A%0A%09/**%0A%09 * Make a new instance.%0A%09 * @param id The ID.%0A%09 * @param x X%0A%09 * @param y Y%0A%09 * @param images The images to render%0A%09 */%0A%09public GuiButtonImage(int id, int x, int y, IImage... images) %7B%0A%09%09this(id, x, y, images%5B0%5D.getWidth(), images%5B0%5D.getHeight(), images, 0, 0, false);%0A%09%7D%0A%0A
 %09/**%0A%09 *
@@ -1920,37 +1920,36 @@
 background) %7B%0A%09%09
-super
+this
 (id, x, y, width
@@ -1962,115 +1962,58 @@
 ht, 
-%22%22, background);%0A        this.i
+new II
 mage
- = 
+%5B%5D%7B
 image
-;%0A        this.
+%7D, 
 offsetX
- =
+,
  offset
-X;%0A        this.offsetY = offsetY
+Y, background)
 ;%0A%09%7D
@@ -2366,24 +2366,56 @@
 Over) %7B%0A
-        
+%09%09for (IImage image : this.images) %7B%0A%09%09%09
 image.dr
@@ -2450,16 +2450,20 @@
 fsetY);%0A
+%09%09%7D%0A
     %7D%0A%0A%09
@@ -2511,16 +2511,20 @@
 is.image
+s%5B0%5D
  = image
@@ -2527,11 +2527,81 @@
 mage;%0A%09%7D
+%0A%0A%09public void setImages(IImage%5B%5D images) %7B%0A%09%09this.images = images;%0A%09%7D
 %0A%7D%0A

Allow GuiButtonImage to have multiple layers