// Path: src/main/java/net/mcft/copy/backpacks/client/GuiTextureResource.java
// @SideOnly(Side.CLIENT)
// public class GuiTextureResource extends ResourceLocation {
// 	
// 	public final int defaultWidth;
// 	public final int defaultHeight;
// 	
// 	public GuiTextureResource(String location, int defaultWidth, int defaultHeight) {
// 		super(WearableBackpacks.MOD_ID, "textures/gui/" + location + ".png");
// 		this.defaultWidth = defaultWidth;
// 		this.defaultHeight = defaultHeight;
// 	}
// 	
// 	public void bind() {
// 		Minecraft.getMinecraft().getTextureManager().bindTexture(this);
// 	}
// 	
// 	/** Draws part of the texture to the screen. */
// 	public void drawQuad(int x, int y, int u, int v, int w, int h, float zLevel) {
// 		float scaleX = 1.0F / defaultWidth;
// 		float scaleY = 1.0F / defaultHeight;
// 		Tessellator tess = Tessellator.getInstance();
// 		BufferBuilder vb = tess.getBuffer();
// 		vb.begin(7, DefaultVertexFormats.POSITION_TEX);
// 		vb.pos(x + 0, y + h, zLevel).tex((u + 0) * scaleX, (v + h) * scaleY).endVertex();
// 		vb.pos(x + w, y + h, zLevel).tex((u + w) * scaleX, (v + h) * scaleY).endVertex();
// 		vb.pos(x + w, y + 0, zLevel).tex((u + w) * scaleX, (v + 0) * scaleY).endVertex();
// 		vb.pos(x + 0, y + 0, zLevel).tex((u + 0) * scaleX, (v + 0) * scaleY).endVertex();
// 		tess.draw();
// 	}
// 	
// 	/** Draws part of the texture to the screen. */
// 	public void drawQuad(int x, int y, int u, int v, int w, int h) {
// 		drawQuad(x, y, u, v, w, h, 0);
// 	}
// 	
// }


import net.minecraft.client.gui.FontRenderer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.client.GuiTextureResource;
	
	
	@Override
	protected void drawButtonForeground(boolean isHighlighted, float partialTicks) {
		String text = getText();
		FontRenderer fontRenderer = getFontRenderer();
		
		int contentWidth = _icon.width;
		if (!text.isEmpty()) {
			int textWidth = fontRenderer.getStringWidth(text);
			int maxTextWidth = getWidth() - _icon.width - ICON_SPACING - MIN_TEXT_PADDING;
			if ((textWidth > maxTextWidth) && (textWidth > ELLIPSIS_WIDTH)) {
				text = fontRenderer.trimStringToWidth(text, maxTextWidth - ELLIPSIS_WIDTH).trim() + ELLIPSIS;
				textWidth = fontRenderer.getStringWidth(text);
			}
			contentWidth += ICON_SPACING + textWidth;
		}
		
		int x = (getWidth() - contentWidth) / 2;
		int y = (getHeight() - _icon.height) / 2;
		_icon.texture.bind();
		_icon.texture.drawQuad(x, y, _icon.u, _icon.v, _icon.width, _icon.height);
		
		if (!text.isEmpty())
			fontRenderer.drawStringWithShadow(text,
				x + _icon.width + ICON_SPACING,
				(getHeight() - 8) / 2, getTextColor(isHighlighted));
	}
	
	public static final class Icon {
// Path: src/main/java/net/mcft/copy/backpacks/client/GuiTextureResource.java
// @SideOnly(Side.CLIENT)
// public class GuiTextureResource extends ResourceLocation {
// 	
// 	public final int defaultWidth;
// 	public final int defaultHeight;
// 	
// 	public GuiTextureResource(String location, int defaultWidth, int defaultHeight) {
// 		super(WearableBackpacks.MOD_ID, "textures/gui/" + location + ".png");
// 		this.defaultWidth = defaultWidth;
// 		this.defaultHeight = defaultHeight;
// 	}
// 	
// 	public void bind() {
// 		Minecraft.getMinecraft().getTextureManager().bindTexture(this);
// 	}
// 	
// 	/** Draws part of the texture to the screen. */
// 	public void drawQuad(int x, int y, int u, int v, int w, int h, float zLevel) {
// 		float scaleX = 1.0F / defaultWidth;
// 		float scaleY = 1.0F / defaultHeight;
// 		Tessellator tess = Tessellator.getInstance();
// 		BufferBuilder vb = tess.getBuffer();
// 		vb.begin(7, DefaultVertexFormats.POSITION_TEX);
// 		vb.pos(x + 0, y + h, zLevel).tex((u + 0) * scaleX, (v + h) * scaleY).endVertex();
// 		vb.pos(x + w, y + h, zLevel).tex((u + w) * scaleX, (v + h) * scaleY).endVertex();
// 		vb.pos(x + w, y + 0, zLevel).tex((u + w) * scaleX, (v + 0) * scaleY).endVertex();
// 		vb.pos(x + 0, y + 0, zLevel).tex((u + 0) * scaleX, (v + 0) * scaleY).endVertex();
// 		tess.draw();
// 	}
// 	
// 	/** Draws part of the texture to the screen. */
// 	public void drawQuad(int x, int y, int u, int v, int w, int h) {
// 		drawQuad(x, y, u, v, w, h, 0);
// 	}
// 	
// }


// Path: src/main/java/net/mcft/copy/backpacks/client/gui/control/GuiButtonIcon.java
import net.minecraft.client.gui.FontRenderer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.client.GuiTextureResource;

	
	
	@Override
	protected void drawButtonForeground(boolean isHighlighted, float partialTicks) {
		String text = getText();
		FontRenderer fontRenderer = getFontRenderer();
		
		int contentWidth = _icon.width;
		if (!text.isEmpty()) {
			int textWidth = fontRenderer.getStringWidth(text);
			int maxTextWidth = getWidth() - _icon.width - ICON_SPACING - MIN_TEXT_PADDING;
			if ((textWidth > maxTextWidth) && (textWidth > ELLIPSIS_WIDTH)) {
				text = fontRenderer.trimStringToWidth(text, maxTextWidth - ELLIPSIS_WIDTH).trim() + ELLIPSIS;
				textWidth = fontRenderer.getStringWidth(text);
			}
			contentWidth += ICON_SPACING + textWidth;
		}
		
		int x = (getWidth() - contentWidth) / 2;
		int y = (getHeight() - _icon.height) / 2;
		_icon.texture.bind();
		_icon.texture.drawQuad(x, y, _icon.u, _icon.v, _icon.width, _icon.height);
		
		if (!text.isEmpty())
			fontRenderer.drawStringWithShadow(text,
				x + _icon.width + ICON_SPACING,
				(getHeight() - 8) / 2, getTextColor(isHighlighted));
	}
	
	public static final class Icon {
		public final GuiTextureResource texture;