Search in sources :

Example 61 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project Wurst-MC-1.12 by Wurst-Imperium.

the class ComboBox2 method render.

@Override
public void render(int mouseX, int mouseY) {
    ClickGui gui = WurstClient.INSTANCE.getGui();
    float[] bgColor = gui.getBgColor();
    float[] acColor = gui.getAcColor();
    int x1 = getX();
    int x2 = x1 + getWidth();
    int x3 = x2 - 11;
    int x4 = x3 - popupWidth - 4;
    int y1 = getY();
    int y2 = y1 + getHeight();
    int scroll = getParent().isScrollingEnabled() ? getParent().getScrollOffset() : 0;
    boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2 && mouseY < y2 && mouseY >= -scroll && mouseY < getParent().getHeight() - 13 - scroll;
    boolean hText = hovering && mouseX < x4;
    boolean hBox = hovering && mouseX >= x4;
    // tooltip
    if (hText)
        gui.setTooltip(setting.getDescription());
    // background
    GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], 0.5F);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2i(x1, y1);
    GL11.glVertex2i(x1, y2);
    GL11.glVertex2i(x4, y2);
    GL11.glVertex2i(x4, y1);
    GL11.glEnd();
    // box
    GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], hBox ? 0.75F : 0.5F);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2i(x4, y1);
    GL11.glVertex2i(x4, y2);
    GL11.glVertex2i(x2, y2);
    GL11.glVertex2i(x2, y1);
    GL11.glEnd();
    GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2i(x4, y1);
    GL11.glVertex2i(x4, y2);
    GL11.glVertex2i(x2, y2);
    GL11.glVertex2i(x2, y1);
    GL11.glEnd();
    // separator
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2i(x3, y1);
    GL11.glVertex2i(x3, y2);
    GL11.glEnd();
    double xa1 = x3 + 1;
    double xa2 = (x3 + x2) / 2.0;
    double xa3 = x2 - 1;
    double ya1;
    double ya2;
    if (popup != null && !popup.isClosing()) {
        ya1 = y2 - 3.5;
        ya2 = y1 + 3;
        GL11.glColor4f(hBox ? 1 : 0.85F, 0, 0, 1);
    } else {
        ya1 = y1 + 3.5;
        ya2 = y2 - 3;
        GL11.glColor4f(0, hBox ? 1 : 0.85F, 0, 1);
    }
    // arrow
    GL11.glBegin(GL11.GL_TRIANGLES);
    GL11.glVertex2d(xa1, ya1);
    GL11.glVertex2d(xa3, ya1);
    GL11.glVertex2d(xa2, ya2);
    GL11.glEnd();
    // outline
    GL11.glColor4f(0.0625F, 0.0625F, 0.0625F, 0.5F);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2d(xa1, ya1);
    GL11.glVertex2d(xa3, ya1);
    GL11.glVertex2d(xa2, ya2);
    GL11.glEnd();
    // setting name
    GL11.glColor4f(1, 1, 1, 1);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    FontRenderer fr = Fonts.segoe18;
    fr.drawString(setting.getName(), x1, y1 - 1, 0xf0f0f0);
    fr.drawString(setting.getSelectedMode(), x4 + 2, y1 - 1, 0xf0f0f0);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 62 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project Binnie by ForestryMC.

the class TextureRenderer method textHeight.

public int textHeight(final String text, final int width) {
    Minecraft minecraft = Minecraft.getMinecraft();
    FontRenderer fontRenderer = minecraft.fontRenderer;
    return fontRenderer.listFormattedStringToWidth(text, width).size() * RenderUtil.getTextHeight();
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft)

Example 63 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project ChatTweaks by blay09.

the class BottomChatRenderer method onDrawOverlayChat.

@SubscribeEvent
@SuppressWarnings("unused")
public void onDrawOverlayChat(RenderGameOverlayEvent.Post event) {
    if (chatMessage == null || event.getType() != RenderGameOverlayEvent.ElementType.ALL) {
        return;
    }
    timeLeft -= event.getPartialTicks();
    int alpha = (int) (255f * (timeLeft / MESSAGE_TIME));
    if (timeLeft <= 0) {
        chatMessage = null;
        return;
    }
    GlStateManager.pushMatrix();
    GlStateManager.translate(event.getResolution().getScaledWidth() / 2, event.getResolution().getScaledHeight() - 64, 0f);
    GlStateManager.scale(SCALE, SCALE, 1f);
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    String formattedText = chatMessage.getTextComponent().getFormattedText();
    int textWidth = fontRenderer.getStringWidth(formattedText);
    int boxMarginX = 4;
    int boxMarginY = 3;
    int x = -textWidth / 2;
    int y = 0;
    int backgroundColor = 0x110111 + (alpha << 24);
    int borderColor2 = 0x28007F + (alpha << 24);
    Gui.drawRect(x - boxMarginX - 1, y - boxMarginY - 1, x + textWidth + boxMarginX + 1, y - boxMarginY, borderColor2);
    Gui.drawRect(x - boxMarginX - 1, y + fontRenderer.FONT_HEIGHT + boxMarginY, x + textWidth + boxMarginX + 1, y + fontRenderer.FONT_HEIGHT + boxMarginY + 1, borderColor2);
    Gui.drawRect(x - boxMarginX - 1, y - boxMarginY, x - boxMarginX, y + fontRenderer.FONT_HEIGHT + boxMarginY, borderColor2);
    Gui.drawRect(x + textWidth + boxMarginX, y - boxMarginY, x + textWidth + boxMarginX + 1, y + fontRenderer.FONT_HEIGHT + boxMarginY, borderColor2);
    Gui.drawRect(x - boxMarginX, y - boxMarginY, x + textWidth + boxMarginX, y + fontRenderer.FONT_HEIGHT + boxMarginY, backgroundColor);
    if (alpha > 12) {
        GlStateManager.enableBlend();
        fontRenderer.drawString(formattedText, x, y, 0xFFFFFF + (alpha << 24), true);
    }
    GlStateManager.popMatrix();
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 64 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project ChatTweaks by blay09.

the class GuiButtonChatView method drawButton.

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
    if (visible) {
        FontRenderer fondRenderer = mc.fontRenderer;
        this.hovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
        mouseDragged(mc, mouseX, mouseY);
        boolean isActiveChannel = (view == ChatViewManager.getActiveView());
        boolean hasNewMessages = view.hasUnreadMessages();
        int hoverState = getHoverState(hovered);
        int textColor = isActiveChannel ? 0xFFFFFFFF : 0xFF999999;
        if (hasNewMessages && !view.isMuted()) {
            textColor = 0xFFFF0000;
        } else if (hoverState == 2 && !isActiveChannel) {
            textColor = 0xFFCCCCCC;
        }
        drawCenteredString(fondRenderer, displayString, x + width / 2, y + (height - 8) / 2, textColor);
    }
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 65 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project ChatTweaks by blay09.

the class GuiButtonSettings method drawButton.

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
    if (visible) {
        FontRenderer fondRenderer = mc.fontRenderer;
        this.hovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
        int hoverState = getHoverState(hovered);
        mouseDragged(mc, mouseX, mouseY);
        int j = 0xE0E0E0;
        if (packedFGColour != 0) {
            j = packedFGColour;
        } else if (!enabled) {
            j = 0xA0A0A0;
        } else if (hovered) {
            j = 0xFFFFA0;
        }
        Gui.drawRect(x, y, x + width, y + height, (hoverState == 2) ? 0x44333333 : 0x44000000);
        drawCenteredString(fondRenderer, displayString, x + width / 2, y + (height - 8) / 2, j);
    }
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer)

Aggregations

FontRenderer (net.minecraft.client.gui.FontRenderer)266 ScaledResolution (net.minecraft.client.gui.ScaledResolution)45 Minecraft (net.minecraft.client.Minecraft)39 ItemStack (net.minecraft.item.ItemStack)30 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)13 ArrayList (java.util.ArrayList)12 Tessellator (net.minecraft.client.renderer.Tessellator)11 RenderItem (net.minecraft.client.renderer.RenderItem)10 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)10 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)7 IBlockState (net.minecraft.block.state.IBlockState)6 Block (net.minecraft.block.Block)5 GuiButton (net.minecraft.client.gui.GuiButton)5 List (java.util.List)4 RenderManager (net.minecraft.client.renderer.entity.RenderManager)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 IGuiRect (betterquesting.api2.client.gui.misc.IGuiRect)3 Bounds (ivorius.reccomplex.gui.table.Bounds)3 Item (net.minecraft.item.Item)3