use of net.minecraft.client.gui.FontRenderer in project LogisticsPipes by RS485.
the class SmallGuiButton method drawButton.
@Override
public void drawButton(Minecraft minecraft, int i, int j) {
if (!visible) {
return;
}
FontRenderer fontrenderer = minecraft.fontRenderer;
minecraft.renderEngine.bindTexture(GuiButton.buttonTextures);
// GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, minecraft.renderEngine.getTexture("/gui/gui.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
boolean flag = i >= xPosition && j >= yPosition && i < xPosition + width && j < yPosition + height;
int k = getHoverState(flag);
drawTexturedModalRect(xPosition, yPosition, 0, 46 + k * 20, width / 2, height / 2);
drawTexturedModalRect(xPosition + width / 2, yPosition, 200 - width / 2, 46 + k * 20, width / 2, height / 2);
drawTexturedModalRect(xPosition, yPosition + height / 2, 0, 46 + 25 - height + k * 20, width / 2, height / 2);
drawTexturedModalRect(xPosition + width / 2, yPosition + height / 2, 200 - width / 2, 46 + 25 - height + k * 20, width / 2, height / 2);
mouseDragged(minecraft, i, j);
int color = Color.getValue(Color.LIGHTER_GREY);
if (!enabled) {
color = Color.getValue(Color.GREY);
} else if (flag) {
color = Color.getValue(Color.LIGHT_YELLOW);
}
drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2 + stringOffset, color);
}
use of net.minecraft.client.gui.FontRenderer in project Railcraft by Railcraft.
the class GuiMultiButton method drawButton.
@Override
public void drawButton(Minecraft minecraft, int x, int y) {
if (!visible) {
return;
}
FontRenderer fontrenderer = minecraft.fontRendererObj;
bindButtonTextures(minecraft);
OpenGL.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
IMultiButtonState state = control.getButtonState();
IButtonTextureSet tex = state.getTextureSet();
int xOffset = tex.getX();
int yOffset = tex.getY();
int h = tex.getHeight();
int w = tex.getWidth();
boolean flag = x >= xPosition && y >= yPosition && x < xPosition + width && y < yPosition + h;
int hoverState = getHoverState(flag);
drawTexturedModalRect(xPosition, yPosition, xOffset, yOffset + hoverState * h, width / 2, h);
drawTexturedModalRect(xPosition + width / 2, yPosition, xOffset + w - width / 2, yOffset + hoverState * h, width / 2, h);
mouseDragged(minecraft, x, y);
displayString = state.getLabel();
if (!Strings.isEmpty(displayString)) {
if (!enabled) {
drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (h - 8) / 2, 0xffa0a0a0);
} else if (flag) {
drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (h - 8) / 2, 0xffffa0);
} else {
drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (h - 8) / 2, 0xe0e0e0);
}
}
}
use of net.minecraft.client.gui.FontRenderer in project ImmersiveEngineering by BluSunrize.
the class GuiButtonIE method drawButton.
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
ClientUtils.bindTexture(texture);
FontRenderer fontrenderer = mc.fontRendererObj;
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.blendFunc(770, 771);
if (hoverOffset != null && this.hovered)
this.drawTexturedModalRect(xPosition, yPosition, texU + hoverOffset[0], texV + hoverOffset[1], width, height);
else
this.drawTexturedModalRect(xPosition, yPosition, texU, texV, width, height);
this.mouseDragged(mc, mouseX, mouseY);
if (displayString != null && !displayString.isEmpty()) {
int txtCol = 0xE0E0E0;
if (!this.enabled)
txtCol = 0xA0A0A0;
else if (this.hovered)
txtCol = Lib.COLOUR_I_ImmersiveOrange;
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, txtCol);
}
}
}
use of net.minecraft.client.gui.FontRenderer in project ImmersiveEngineering by BluSunrize.
the class GuiButtonItem method drawButton.
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
ClientUtils.bindTexture("immersiveengineering:textures/gui/hudElements.png");
GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F);
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.blendFunc(770, 771);
this.drawTexturedModalRect(xPosition, yPosition, 24 + (state ? 18 : 0), 128, width, height);
this.mouseDragged(mc, mouseX, mouseY);
if (item != null) {
this.zLevel = 200.0F;
RenderItem itemRender = mc.getRenderItem();
itemRender.zLevel = 200.0F;
FontRenderer font = item.getItem().getFontRenderer(item);
if (font == null)
font = mc.fontRendererObj;
itemRender.renderItemAndEffectIntoGUI(item, xPosition + 1, yPosition + 1);
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
if (!state) {
RenderHelper.enableStandardItemLighting();
GlStateManager.disableLighting();
GlStateManager.disableDepth();
ClientUtils.drawColouredRect(xPosition + 1, yPosition + 1, 16, 16, 0x77444444);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
}
RenderHelper.disableStandardItemLighting();
}
}
}
use of net.minecraft.client.gui.FontRenderer in project ImmersiveEngineering by BluSunrize.
the class GuiReactiveList method drawButton.
@Override
public void drawButton(Minecraft mc, int mx, int my) {
FontRenderer fr = ClientUtils.mc().fontRendererObj;
boolean uni = fr.getUnicodeFlag();
fr.setUnicodeFlag(unicode);
int mmY = my - this.yPosition;
int strWidth = width - padding[2] - padding[3] - (needsSlider ? 6 : 0);
GlStateManager.color(1, 1, 1);
if (needsSlider) {
ClientUtils.bindTexture("immersiveengineering:textures/gui/hudElements.png");
this.drawTexturedModalRect(xPosition + width - 6, yPosition, 16, 136, 6, 4);
this.drawTexturedModalRect(xPosition + width - 6, yPosition + height - 4, 16, 144, 6, 4);
for (int i = 0; i < height - 8; i += 2) this.drawTexturedModalRect(xPosition + width - 6, yPosition + 4 + i, 16, 141, 6, 2);
int sliderSize = Math.max(6, height - maxOffset * fr.FONT_HEIGHT);
float silderShift = (height - sliderSize) / (float) maxOffset * offset;
this.drawTexturedModalRect(xPosition + width - 5, yPosition + silderShift + 1, 20, 129, 4, 2);
this.drawTexturedModalRect(xPosition + width - 5, yPosition + silderShift + sliderSize - 4, 20, 132, 4, 3);
for (int i = 0; i < sliderSize - 7; i++) this.drawTexturedModalRect(xPosition + width - 5, yPosition + silderShift + 3 + i, 20, 131, 4, 1);
}
GlStateManager.scale(textScale, textScale, 1);
this.hovered = mx >= xPosition && mx < xPosition + width && my >= yPosition && my < yPosition + height;
boolean hasTarget = false;
for (int i = 0; i < Math.min(perPage, entries.length); i++) {
int j = offset + i;
int col = 0xE0E0E0;
boolean selectionHover = hovered && mmY >= i * fr.FONT_HEIGHT && mmY < (i + 1) * fr.FONT_HEIGHT;
if (selectionHover) {
hasTarget = true;
if (targetEntry != j) {
targetEntry = j;
hoverTimer = 0;
} else
hoverTimer++;
col = Lib.COLOUR_I_ImmersiveOrange;
}
if (j > entries.length - 1)
j = entries.length - 1;
String s = translationFunction != null ? translationFunction.apply(entries[j]) : entries[j];
int overLength = s.length() - fr.sizeStringToWidth(s, strWidth);
if (//String is too long
overLength > 0) {
if (selectionHover && hoverTimer > 20) {
int textOffset = (hoverTimer / 10) % (s.length());
s = s.substring(textOffset) + " " + s.substring(0, textOffset);
}
s = fr.trimStringToWidth(s, strWidth);
}
float tx = ((xPosition + padding[2]) / textScale);
float ty = ((yPosition + padding[0] + (fr.FONT_HEIGHT * i)) / textScale);
GlStateManager.translate(tx, ty, 0);
fr.drawString(s, 0, 0, col, false);
GlStateManager.translate(-tx, -ty, 0);
}
GlStateManager.scale(1 / textScale, 1 / textScale, 1);
if (!hasTarget) {
targetEntry = -1;
hoverTimer = 0;
}
fr.setUnicodeFlag(uni);
//Handle DWheel
int mouseWheel = Mouse.getEventDWheel();
if (mouseWheel != 0 && maxOffset > 0 && Mouse.getEventNanoseconds() != prevWheelNano) {
prevWheelNano = Mouse.getEventNanoseconds();
if (mouseWheel < 0 && offset < maxOffset)
offset++;
if (mouseWheel > 0 && offset > 0)
offset--;
}
}
Aggregations