/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014 Zoe Lee (Kihira)
 *
 * See LICENSE for full License
 */

package kihira.foxlib.client.gui;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;

import java.util.List;

public class GuiIconButton extends GuiButton implements ITooltip {

    public static final ResourceLocation iconsTextures = new ResourceLocation("foxlib", "textures/gui/icons.png");

    private final Icons icon;
    private final List<String> tooltip;

    public GuiIconButton(int id, int x, int y, Icons icon, List<String> tooltip) {
        super(id, x, y, 16 ,16, "");
        this.icon = icon;
        this.tooltip = tooltip;
    }

    public void drawButton(Minecraft minecraft, int mouseX, int mouseY) {
        if (visible) {
            minecraft.getTextureManager().bindTexture(iconsTextures);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            GL11.glEnable(GL11.GL_BLEND);
            OpenGlHelper.glBlendFunc(770, 771, 1, 0);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

            //Check mouse over
            field_146123_n = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height;
            int textureOffset = getHoverState(field_146123_n);

            drawTexturedModalRect(xPosition, yPosition, icon.u, icon.v + (textureOffset * 16), 16, 16);
        }
    }

    @Override
    public List<String> getTooltip(int mouseX, int mouseY) {
        return tooltip;
    }

    public enum Icons {
        UNDO(0, 0),
        QUESTION(16, 0),
        EYEDROPPER(32, 0);

        public final int u;
        public final int v;

        private Icons(int u, int v) {
            this.u = u;
            this.v = v;
        }
    }
}

@@ -344,16 +344,55 @@
 gl.GL11;
+%0Aimport scala.actors.threadpool.Arrays;
 %0A%0Aimport
@@ -723,36 +723,34 @@
 s icon, 
-List%3C
 String
-%3E
+ ...
  tooltip
 ) %7B%0A    
@@ -741,16 +741,17 @@
  tooltip
+s
 ) %7B%0A    
@@ -832,23 +832,39 @@
 oltip = 
+Arrays.asList(
 tooltip
+s)
 ;%0A    %7D%0A

Tidy up tooltips for icon buttons