Java Code Examples for net.minecraft.client.gui.Gui#drawRect()

The following examples show how to use net.minecraft.client.gui.Gui#drawRect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LabelComponent.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void render(int x, int y, int width, int mouseX, int mouseY) {
    HyperiumFontRenderer font = tab.gui.getFont();
    lines.clear();
    lines = font.splitString(label, (width + 25) / 2); //16 for icon, 3 for render offset and then some more

    GlStateManager.pushMatrix();
    if (hover) Gui.drawRect(x, y, x + width, y + 18 * lines.size(), 0xa0000000);
    GlStateManager.popMatrix();

    int line1 = 0;
    for (String line : lines) {
        font.drawString(line.toUpperCase(), x + 3, y + 5 + 17 * line1, 0xffffff);
        line1++;
    }
}
 
Example 2
Source File: ProgWidget.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderExtraInfo(){
    if(getExtraStringInfo() != null) {
        GL11.glPushMatrix();
        GL11.glScaled(0.5, 0.5, 0.5);
        FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
        String[] splittedInfo = WordUtils.wrap(getExtraStringInfo(), 40).split(System.getProperty("line.separator"));
        for(int i = 0; i < splittedInfo.length; i++) {
            int stringLength = fr.getStringWidth(splittedInfo[i]);
            int startX = getWidth() / 2 - stringLength / 4;
            int startY = getHeight() / 2 - (fr.FONT_HEIGHT + 1) * (splittedInfo.length - 1) / 4 + (fr.FONT_HEIGHT + 1) * i / 2 - fr.FONT_HEIGHT / 4;
            Gui.drawRect(startX * 2 - 1, startY * 2 - 1, startX * 2 + stringLength + 1, startY * 2 + fr.FONT_HEIGHT + 1, 0xFFFFFFFF);
            fr.drawString(splittedInfo[i], startX * 2, startY * 2, 0xFF000000);
        }
        GL11.glPopMatrix();
        GL11.glColor4d(1, 1, 1, 1);
    }
}
 
Example 3
Source File: MixinGuiChat.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    Gui.drawRect(2, this.height - (int) fade, this.width - 2, this.height, Integer.MIN_VALUE);
    this.inputField.drawTextBox();

    if (LiquidBounce.commandManager.getLatestAutoComplete().length > 0 && !inputField.getText().isEmpty() && inputField.getText().startsWith(String.valueOf(LiquidBounce.commandManager.getPrefix()))) {
        String[] latestAutoComplete = LiquidBounce.commandManager.getLatestAutoComplete();
        String[] textArray = inputField.getText().split(" ");
        String trimmedString = latestAutoComplete[0].replaceFirst("(?i)" + textArray[textArray.length - 1], "");

        mc.fontRendererObj.drawStringWithShadow(trimmedString, inputField.xPosition + mc.fontRendererObj.getStringWidth(inputField.getText()), inputField.yPosition, new Color(165, 165, 165).getRGB());
    }

    IChatComponent ichatcomponent =
            this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());

    if (ichatcomponent != null)
        this.handleComponentHover(ichatcomponent, mouseX, mouseY);
}
 
Example 4
Source File: BW_GUIContainer_RadLevel.java    From bartworks with MIT License 5 votes vote down vote up
@Override
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
    int y = 51 + (this.container.coverage / 2 - 3);
    int x = -63;
    if (this.container.coverage != 100 && this.container.coverage != 0)
        Gui.drawRect(x, y, x + 51, y + 1, 0xFF60D82E);
    Gui.drawRect(x, 48, x + 51, y, 0xFF8B8B8B);
    this.fontRendererObj.drawString(Byte.toString(this.container.coverage), 88 - 79, 50, 16448255);
}
 
Example 5
Source File: MixinGuiChat.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    Gui.drawRect(2, this.height - (int) fade, this.width - 2, this.height, Integer.MIN_VALUE);
    this.inputField.drawTextBox();

    IChatComponent ichatcomponent =
            this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());

    if (ichatcomponent != null)
        this.handleComponentHover(ichatcomponent, mouseX, mouseY);
}
 
Example 6
Source File: SlowlyStyle.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawButtonElement(int mouseX, int mouseY, ButtonElement buttonElement) {
    Gui.drawRect(buttonElement.getX() - 1, buttonElement.getY() - 1, buttonElement.getX() + buttonElement.getWidth() + 1, buttonElement.getY() + buttonElement.getHeight() + 1, hoverColor(buttonElement.getColor() != Integer.MAX_VALUE ? new Color(7, 152, 252) : new Color(54, 71, 96), buttonElement.hoverTime).getRGB());

    GlStateManager.resetColor();

    Fonts.font35.drawString(buttonElement.getDisplayName(), buttonElement.getX() + 5, buttonElement.getY() + 5, Color.WHITE.getRGB());
}
 
Example 7
Source File: HyperiumOverlay.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void render(int mouseX, int mouseY, int w, int h) {
    // HyperiumGui.drawChromaBox(0, 0, w, h, 0.2F); // bg
    Gui.drawRect(w / 6 * 2, h / 4, w / 6 * 4, h / 4 * 3, new Color(30, 30, 30).getRGB());

    Integer[] counter = new Integer[]{0};

    components.forEach(c -> c.render(mouseX, mouseY, w / 6 * 2, h / 4 + 20 * counter[0]++ + offsetY, w / 6 * 2, 20, h));
}
 
Example 8
Source File: GLUtils.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public static void drawButton(int x, int y, int x2, int y2, int borderC, int topgradient, int bottomgradient) {

        GLUtils.drawBorderedRect(x, y, x2, y2, borderC, 16777215);
        Gui.drawRect((x2 - 2), y, (x2 - 1), y2, -16172197);
        Gui.drawRect((x + 1), (y + 1), (x2 - 1), (y + 2), -15050626);
        Gui.drawRect((x + 1), (y + 1), (x + 2), (y2 - 1), -15050626);
        Gui.drawRect(x, (y2 - 2), x2, (y2 - 1), -16172197);
        GLUtils.drawGradientRect(x + 2, y + 2, x2 - 2, y2 - 2, topgradient, bottomgradient);
    }
 
Example 9
Source File: GLUtils.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public static void drawBorderRect(int x, int y, int x1, int y1, int color, int bcolor) {

        float rs = 2.0f;
        x = (int) (x * rs);
        y = (int) (y * rs);
        x1 = (int) (x1 * rs);
        y1 = (int) (y1 * rs);
        GL11.glScalef(0.5f, 0.5f, 0.5f);
        Gui.drawRect((x + 1), (y + 1), (x1 - 1), (y1 - 1), color);
        Gui.drawRect(x, y, (x + 1), y1, bcolor);
        Gui.drawRect((x1 - 1), y, x1, y1, bcolor);
        Gui.drawRect(x, y, x1, (y + 1), bcolor);
        Gui.drawRect(x, (y1 - 1), x1, y1, bcolor);
        GL11.glScalef(rs, rs, rs);
    }
 
Example 10
Source File: GuiCharacterButton.java    From NBTEdit with GNU General Public License v3.0 5 votes vote down vote up
public void draw(int mx, int my){
	mc.renderEngine.bindTexture(GuiNBTNode.WIDGET_TEXTURE);
	
	if(inBounds(mx,my))
		Gui.drawRect(x, y, x+WIDTH, y+HEIGHT, 0x80ffffff);
	
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	drawTexturedModalRect(x, y, id * WIDTH, 27, WIDTH, HEIGHT);
	if (!enabled){
		drawRect(x, y, x+WIDTH, y+HEIGHT, 0xc0222222);
	}
}
 
Example 11
Source File: AbstractTabComponent.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void render(int x, int y, int width, int mouseX, int mouseY) {
    GlStateManager.pushMatrix();
    if (hover) Gui.drawRect(x, y, x + width, y + 18, 0xa0000000);
    GlStateManager.popMatrix();
}
 
Example 12
Source File: SurfaceHelper.java    From ForgeHax with MIT License 4 votes vote down vote up
public static void drawRect(int x, int y, int w, int h, int color) {
  GL11.glLineWidth(1.0f);
  Gui.drawRect(x, y, x + w, y + h, color);
}
 
Example 13
Source File: NotificationCenter.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Render this notification
 */
void render() {
    if (ticksLeft <= 0) return;
    if (!Settings.SHOW_INGAME_NOTIFICATION_CENTER) return;
    setDefaultFontRenderer();

    ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());

    // Update percentage -- Called in getX()
    // updatePercentage();
    int x = getX(sr);
    int y = getY(sr);

    int alpha = (int) clamp(percentComplete * 255, 127, 255);

    // Background
    Gui.drawRect(x, y, x + width, y + height, new Color(30, 30, 30, alpha).getRGB());
    GlStateManager.enableBlend();

    // Highlight color
    setHighlightColor(highlightColor); // Anti-NPE
    drawRect(x, y, x + highlightBarWidth, y + height, highlightColor.getRGB() | alpha << 24);
    GlStateManager.enableBlend();

    // Title Text
    fontRenderer.drawString(trimString(String.valueOf(title), width - rightMargins,
        null, true), x + highlightBarWidth + highlightBarMargins, y + topPadding, 0xFFFFFF | alpha << 24);

    // Description text
    if (descriptionColor == null) descriptionColor = new Color(80, 80, 80); // Anti-NPE
    // Don't draw if no lines
    int wrapWidth = getWrapWidth();
    // Trim & split into multiple lines
    List<String> lines = fontRenderer.listFormattedStringToWidth(String.valueOf(description), wrapWidth);
    if (lines.size() > maxDescriptionLines) { // Trim size & last line if overflow
        String nextLine = lines.get(maxDescriptionLines); // The line that would appear after the last one
        lines = lines.subList(0, maxDescriptionLines);
        // Next line is appended to guarantee three ellipsis on the end of the string
        lines.set(lines.size() - 1, trimString(lines.get(lines.size() - 1) + " " + nextLine,
            wrapWidth, null, true));
    }

    // Draw lines
    int currentLine = 0;
    for (String line : lines) {
        fontRenderer.drawString(String.valueOf(line),
            x + highlightBarWidth + highlightBarMargins,
            y + topPadding + fontRenderer.FONT_HEIGHT + lineSpacing + fontRenderer.FONT_HEIGHT * currentLine,
            descriptionColor.getRGB() | alpha << 24);

        if (++currentLine >= maxDescriptionLines) break; // stop if too many lines have gone by
    }

    // Notification Image
    if (img != null) {
        imgScale = (double) (height - topPadding - fontRenderer.FONT_HEIGHT - imgTopMargins) / imgSize;

        if (imgScale * imgSize > (double) width / 4) {
            imgScale = ((double) width / 4) / imgSize; // Limit to 25% of width
        }

        GlStateManager.color(1, 1, 1, 1);
        GlStateManager.scale(imgScale, imgScale, imgScale);
        GlStateManager.bindTexture(img.getGlTextureId());
        GlStateManager.enableTexture2D();
        drawTexturedModalRect(
            (float) ((x + width - rightMargins) / imgScale - imgSize),
            (float) (y / imgScale + (((height + fontRenderer.FONT_HEIGHT) / imgScale) - imgSize) / 2),
            0,
            0,
            imgSize,
            imgSize);
        GlStateManager.scale(1 / imgScale, 1 / imgScale, 1 / imgScale);
    } else {
        imgScale = 0;
    }
}
 
Example 14
Source File: MixinGuiButton.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
   if (visible) {
      final FontRenderer fontRenderer =
         mc.getLanguageManager().isCurrentLocaleUnicode() ? mc.fontRendererObj : Fonts.font35;
      hovered = (mouseX >= this.xPosition && mouseY >= this.yPosition &&
                 mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height);

      final int delta = RenderUtils.deltaTime;

      if (enabled && hovered) {
         cut += 0.05F * delta;

         if (cut >= 4) cut = 4;

         alpha += 0.3F * delta;

         if (alpha >= 210) alpha = 210;
      } else {
         cut -= 0.05F * delta;

         if (cut <= 0) cut = 0;

         alpha -= 0.3F * delta;

         if (alpha <= 120) alpha = 120;
      }

      Gui.drawRect(this.xPosition + (int) this.cut, this.yPosition,
              this.xPosition + this.width - (int) this.cut, this.yPosition + this.height,
              this.enabled ? new Color(0F, 0F, 0F, this.alpha / 255F).getRGB() :
                      new Color(0.5F, 0.5F, 0.5F, 0.5F).getRGB());

      mc.getTextureManager().bindTexture(buttonTextures);
      mouseDragged(mc, mouseX, mouseY);

      net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.setAssumeNonVolatile(true);

      fontRenderer.drawStringWithShadow(displayString,
              (float) ((this.xPosition + this.width / 2) -
                      fontRenderer.getStringWidth(displayString) / 2),
              this.yPosition + (this.height - 5) / 2F, 14737632);

      net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.setAssumeNonVolatile(false);

      GlStateManager.resetColor();
   }
}
 
Example 15
Source File: CustomKey.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void renderKey(int x, int y) {
    Keyboard.poll();
    boolean pressed = isButtonDown(key);
    String name = (type == 0) ? (mod.getSettings().isChroma() ? "------" : (ChatColor.STRIKETHROUGH.toString() + "------")) : getKeyOrMouseName(key);

    if (pressed != wasPressed) {
        wasPressed = pressed;
        lastPress = System.currentTimeMillis();
    }

    int textColor = getColor();
    int pressedColor = getPressedColor();
    int color;
    double textBrightness;

    if (pressed) {
        color = Math.min(255, (int) (mod.getSettings().getFadeTime() * 5.0 * (System.currentTimeMillis() - lastPress)));
        textBrightness = Math.max(0.0, 1.0 - (System.currentTimeMillis() - lastPress) / (mod.getSettings().getFadeTime() * 2.0));
    } else {
        color = Math.max(0, 255 - (int) (mod.getSettings().getFadeTime() * 5.0 * (System.currentTimeMillis() - lastPress)));
        textBrightness = Math.min(1.0, (System.currentTimeMillis() - lastPress) / (mod.getSettings().getFadeTime() * 2.0));
    }

    int left = x + xOffset;
    int top = y + yOffset;
    int right;
    int bottom;

    if (type == 0 || type == 1) {
        right = x + xOffset + 70;
        bottom = y + yOffset + 16;
    } else {
        right = x + xOffset + 22;
        bottom = y + yOffset + 22;
    }

    if (mod.getSettings().isKeyBackgroundEnabled()) {
        if (mod.getSettings().getKeyBackgroundRed() == 0 && mod.getSettings().getKeyBackgroundGreen() == 0 && mod.getSettings().getKeyBackgroundBlue() == 0) {
            Gui.drawRect(left, top, right, bottom,
                new Color(mod.getSettings().getKeyBackgroundRed(), mod.getSettings().getKeyBackgroundGreen(), mod.getSettings().getKeyBackgroundBlue(),
                    mod.getSettings().getKeyBackgroundOpacity()).getRGB() + (color << 16) + (color << 8) + color);
        } else {
            Gui.drawRect(left, top, right, bottom,
                new Color(mod.getSettings().getKeyBackgroundRed(), mod.getSettings().getKeyBackgroundGreen(), mod.getSettings().getKeyBackgroundBlue(),
                    mod.getSettings().getKeyBackgroundOpacity()).getRGB());
        }
    }

    hitbox.setLeft(left);
    hitbox.setTop(top);
    hitbox.setRight(right);
    hitbox.setBottom(bottom);

    int red = textColor >> 16 & 0xFF;
    int green = textColor >> 8 & 0xFF;
    int blue = textColor & 0xFF;
    int colorN = new Color(0, 0, 0).getRGB() + ((int) (red * textBrightness) << 16) + ((int) (green * textBrightness) << 8) + (int) (blue * textBrightness);
    final float yPos = y + yOffset + 8;
    final FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
    if (mod.getSettings().isChroma()) {
        if (type == 0) {
            int xIn = x + (xOffset + 76) / 4;
            int y2 = y + yOffset + 9;
            GlStateManager.pushMatrix();
            GlStateManager.translate((float) xIn, (float) y2, 0.0f);
            GlStateManager.rotate(-90.0f, 0.0f, 0.0f, 1.0f);
            drawGradientRect(0, 0, 2, 35, Color.HSBtoRGB((System.currentTimeMillis() - xIn * 10 - y2 * 10) %
                2000L / 2000.0f, 0.8f, 0.8f), Color.HSBtoRGB((System.currentTimeMillis() - (xIn + 35) * 10 - y2 * 10) %
                2000L / 2000.0f, 0.8f, 0.8f));
            GlStateManager.popMatrix();
        } else if (type == 1) {
            drawChromaString(name, x + ((xOffset + 70) / 2) - fontRendererObj.getStringWidth(name) / 2, y + yOffset + 5, 1.0F);
        } else {
            drawChromaString(name, (left + right) / 2 - fontRendererObj.getStringWidth(name) / 2, (int) yPos, 1.0);
        }
    } else if (type == 0 || type == 1) {
        drawCenteredString(name, x + (xOffset + 70) / 2, y + yOffset + 5, pressed ? pressedColor : colorN);
    } else {
        mc.fontRendererObj.drawString(name, (left + right) / 2 - fontRendererObj.getStringWidth(name) / 2, (int) yPos, pressed ? pressedColor : colorN);
    }
}
 
Example 16
Source File: Widget.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SideOnly(Side.CLIENT)
protected static void drawSolidRect(int x, int y, int width, int height, int color) {
    Gui.drawRect(x, y, x + width, y + height, color);
    GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
    GlStateManager.enableBlend();
}
 
Example 17
Source File: MixinLoadingScreenRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @author ConorTheDev
 * @reason Custom screen when loading to a new world
 */
@Inject(method = "setLoadingProgress", at = @At("HEAD"), cancellable = true)
private void setLoadingProgress(CallbackInfo ci) {
    if (Settings.HYPERIUM_LOADING_SCREEN) {
        long nanoTime = Minecraft.getSystemTime();

        if (nanoTime - systemTime >= 100L) {
            systemTime = nanoTime;
            ScaledResolution scaledresolution = new ScaledResolution(mc);
            int scaleFactor = scaledresolution.getScaleFactor();
            int scaledWidth = scaledresolution.getScaledWidth();
            int scaledHeight = scaledresolution.getScaledHeight();

            if (OpenGlHelper.isFramebufferEnabled()) {
                framebuffer.framebufferClear();
            } else {
                GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
            }

            framebuffer.bindFramebuffer(false);
            GlStateManager.matrixMode(GL11.GL_PROJECTION);
            GlStateManager.loadIdentity();
            GlStateManager.ortho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 100.0D, 300.0D);
            GlStateManager.matrixMode(GL11.GL_MODELVIEW);
            GlStateManager.loadIdentity();
            GlStateManager.translate(0.0F, 0.0F, -200.0F);

            if (!OpenGlHelper.isFramebufferEnabled()) GlStateManager.clear(16640);

            Tessellator tessellator = Tessellator.getInstance();
            WorldRenderer worldrenderer = tessellator.getWorldRenderer();
            mc.getTextureManager().bindTexture(new ResourceLocation("textures/world-loading.png"));

            Gui.drawModalRectWithCustomSizedTexture(0, 0, 0.0f, 0.0f, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight());

            int progress;
            if ("Loading world".equals(currentlyDisplayedText)) {
                if (message.isEmpty()) {
                    progress = 33;
                } else if (message.equals("Converting world")) {
                    progress = 66;
                } else if (message.equals("Building terrain")) {
                    progress = 90;
                } else {
                    progress = 100;
                }
            } else {
                progress = -1;
            }

            if (progress >= 0) {
                int maxProgress = 100;
                int barTop = 2;
                int barHeight = scaledResolution.getScaledHeight() - 15;
                GlStateManager.disableTexture2D();
                worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
                worldrenderer.pos(maxProgress, barHeight, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress, barHeight + barTop, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + maxProgress, barHeight + barTop, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + maxProgress, barHeight, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress, barHeight, 0.0D).color(128, 255, 128, 255).endVertex();
                worldrenderer.pos(maxProgress, barHeight + barTop, 0.0D).color(128, 255, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + progress, barHeight + barTop, 0.0D).color(128, 255, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + progress, barHeight, 0.0D).color(128, 255, 128, 255).endVertex();
                tessellator.draw();
                GlStateManager.enableAlpha();
                GlStateManager.enableBlend();
                Gui.drawRect(0, scaledResolution.getScaledHeight() - 35, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(),
                    new Color(0, 0, 0, 50).getRGB());
                GlStateManager.disableAlpha();
                GlStateManager.disableBlend();
                GlStateManager.enableTexture2D();
            }

            GlStateManager.enableBlend();
            GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
            mc.fontRendererObj.drawString(currentlyDisplayedText, 5, scaledResolution.getScaledHeight() - 30, -1);
            mc.fontRendererObj.drawString(message, 5, scaledResolution.getScaledHeight() - 15, -1);
            framebuffer.unbindFramebuffer();

            if (OpenGlHelper.isFramebufferEnabled()) {
                framebuffer.framebufferRender(scaledWidth * scaleFactor, scaledHeight * scaleFactor);
            }

            mc.updateDisplay();

            try {
                Thread.yield();
            } catch (Exception ignored) {
            }
        }

        ci.cancel();
    }
}
 
Example 18
Source File: ScoreboardDisplay.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void draw(int starX, double startY, boolean config) {
    if (objective != null) {
        boolean guiF = false;

        Scoreboard scoreboard = objective.getScoreboard();
        Collection<Score> collection = scoreboard.getSortedScores(objective);
        List<Score> list = collection.stream().filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null &&
            !p_apply_1_.getPlayerName().startsWith("#")).collect(Collectors.toList());

        collection = list.size() > 15 ? Lists.newArrayList(Iterables.skip(list, collection.size() - 15)) : list;

        int i = Minecraft.getMinecraft().fontRendererObj.getStringWidth(objective.getDisplayName());

        for (Score score : collection) {
            ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(score.getPlayerName());
            String s = ScorePlayerTeam.formatPlayerName(scoreplayerteam, score.getPlayerName()) + ": " + EnumChatFormatting.RED + score.getScorePoints();
            i = Math.max(i, Minecraft.getMinecraft().fontRendererObj.getStringWidth(s));
        }

        int i1 = collection.size() * Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT;
        int l1 = starX;
        if (ElementRenderer.getCurrent().isRightSided()) l1 -= i;
        int j = 0;

        int k;
        for (Score score1 : collection) {
            ++j;
            ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score1.getPlayerName());
            String s1 = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score1.getPlayerName());
            String s2 = EnumChatFormatting.RED + "" + score1.getScorePoints();
            k = ((int) startY) + (collection.size() - j + 1) * Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT;

            if (ElementRenderer.getCurrent().isHighlighted()) {
                if (guiF) {
                    Gui.drawRect(l1 - 2, k, l1 + i, k + Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT, 1342177280);
                } else {
                    RenderUtils.drawRect(l1 - 2, k, l1 + i, k + Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT, 1342177280);
                }
            }

            Minecraft.getMinecraft().fontRendererObj.drawString(s1, l1, k, Color.WHITE.getRGB());
            if (data.optBoolean("numbers")) {
                Minecraft.getMinecraft().fontRendererObj.drawString(s2, l1 + i - Minecraft.getMinecraft().fontRendererObj.getStringWidth(s2), k, Color.WHITE.getRGB());
            }

            if (j == collection.size()) {
                String s3 = objective.getDisplayName();
                if (ElementRenderer.getCurrent().isHighlighted()) {
                    if (guiF) {
                        Gui.drawRect(l1 - 2, k - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT - 1, l1 + i, k - 1, 1610612736);
                        Gui.drawRect(l1 - 2, k - 1, l1 + i, k, 1342177280);
                    } else {
                        RenderUtils.drawRect(l1 - 2, k - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT - 1, l1 + i, k - 1, 1610612736);
                        RenderUtils.drawRect(l1 - 2, k - 1, l1 + i, k, 1342177280);
                    }
                }

                Minecraft.getMinecraft().fontRendererObj.drawString(s3, l1 + i / 2 - Minecraft.getMinecraft().fontRendererObj.getStringWidth(s3) / 2, k - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT, Color.WHITE.getRGB());
            }
        }

        width = i - (data.optBoolean("numbers") ? 0 : 10);
        height = i1 + 10;
    }
}
 
Example 19
Source File: DisplayElementConfig.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    ScaledResolution current = ResolutionUtil.current();
    mouseLock = mouseLock && Mouse.isButtonDown(0);
    drawRect(0, 0, current.getScaledWidth(), current.getScaledHeight(), new Color(0, 0, 0, 150).getRGB());
    super.drawScreen(mouseX, mouseY, partialTicks);

    ElementRenderer.startDrawing(element);
    element.renderEditView();
    ElementRenderer.endDrawing(element);
    int left = posX(1);
    int top = posY(2);
    int right = posX(2);
    int size = right - left;

    if (element.isRGB()) {
        int start_y = Math.max((int) (current.getScaledHeight_double() * .1) - 20, 5) + 22 * 8 + 25;
        int left1 = current.getScaledWidth() / 2 - 100;
        int right1 = current.getScaledWidth() / 2 + 100;
        Gui.drawRect(left1, start_y, right1, right1 - left1 + 200, element.getColor());
    }

    if (!element.isColorPallet()) return;

    apply(mouseX, mouseY);
    GlStateManager.bindTexture(texture.getGlTextureId());
    GlStateManager.enableTexture2D();
    GL11.glPushMatrix();
    GL11.glTranslatef(left, top, 0);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);//
    GlStateManager.scale(size / 285F, size / 285F, 0);
    drawTexturedModalRect(0, 0, 0, 0, 256, 256);

    if (texture2 != null) {
        GlStateManager.bindTexture(texture2.getGlTextureId());
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef(256 + 15, 0, 0);
        drawTexturedModalRect(0, 0, 0, 0, 15, 256);
    }

    GlStateManager.scale(285F / size, 285F / size, 0);
    GL11.glPopMatrix();
    if (lastX != 0 && lastY != 0) drawCircle(lastX, lastY);
}
 
Example 20
Source File: OverlayComponent.java    From Hyperium with GNU Lesser General Public License v3.0 3 votes vote down vote up
/**
 * Renders this component
 *
 * @param mouseX   the current X position of the mouse
 * @param mouseY   the current Y position of the mouse
 * @param overlayX the current X of the overlay
 * @param overlayY the current Y of the overlay
 * @param w        the width of this item
 * @param h        the height of this item
 * @param overlayH the height of the overlay
 * @return if the item got rendered
 */
public boolean render(int mouseX, int mouseY, int overlayX, int overlayY, int w, int h, int overlayH) {
    int textY = (overlayY + (h - fr.FONT_HEIGHT) / 2);
    if (textY < (overlayH / 4) || (textY + h) > (overlayH / 4 * 3)) return false;

    if (mouseX >= overlayX && mouseX <= overlayX + w && mouseY >= overlayY && mouseY <= overlayY + h) {
        Gui.drawRect(overlayX, overlayY, overlayX + w, overlayY + h, 0x1e000000);
    }

    fr.drawString(label, overlayX + 4, (overlayY + (h - fr.FONT_HEIGHT) / 2f), enabled ? -1 : new Color(169, 169, 169).getRGB());
    return true;
}