@Override
 protected void renderComponent(Label label) {
   translateComponent(label, false);
   int x = 0, y = 0;
   switch (label.getHorizontalAlignment()) {
     case CENTER:
       x += label.getWidth() / 2 - theme.getFontRenderer().getStringWidth(label.getText()) / 2;
       break;
     case RIGHT:
       x += label.getWidth() - theme.getFontRenderer().getStringWidth(label.getText()) - 2;
       break;
     default:
       x += 2;
   }
   switch (label.getVerticalAlignment()) {
     case TOP:
       y += 2;
       break;
     case BOTTOM:
       y += label.getHeight() - theme.getFontRenderer().FONT_HEIGHT - 2;
       break;
     default:
       y += label.getHeight() / 2 - theme.getFontRenderer().FONT_HEIGHT / 2;
   }
   glEnable(GL_BLEND);
   glEnable(GL_TEXTURE_2D);
   glDisable(GL_CULL_FACE);
   theme
       .getFontRenderer()
       .drawString(label.getText(), x, y, RenderUtil.toRGBA(label.getForegroundColor()));
   glEnable(GL_CULL_FACE);
   glEnable(GL_TEXTURE_2D);
   glDisable(GL_BLEND);
   translateComponent(label, true);
 }
예제 #2
0
 @Override
 public void onRenderGUI() {
   if (target == null || velocity < 0.1) return;
   glEnable(GL_BLEND);
   glDisable(GL_CULL_FACE);
   glDisable(GL_TEXTURE_2D);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   RenderUtil.setColor(new Color(8, 8, 8, 128));
   ScaledResolution sr =
       new ScaledResolution(
           Minecraft.getMinecraft(),
           Minecraft.getMinecraft().displayWidth,
           Minecraft.getMinecraft().displayHeight);
   int width = sr.getScaledWidth();
   int height = sr.getScaledHeight();
   String targetLocked = "Target locked";
   glBegin(GL_QUADS);
   {
     glVertex2d(width / 2 + 1, height / 2 + 1);
     glVertex2d(
         width / 2
             + ((WurstTheme) WurstClient.INSTANCE.gui.getTheme())
                 .getFontRenderer()
                 .getStringWidth(targetLocked)
             + 4,
         height / 2 + 1);
     glVertex2d(
         width / 2
             + ((WurstTheme) WurstClient.INSTANCE.gui.getTheme())
                 .getFontRenderer()
                 .getStringWidth(targetLocked)
             + 4,
         height / 2
             + ((WurstTheme) WurstClient.INSTANCE.gui.getTheme()).getFontRenderer().FONT_HEIGHT);
     glVertex2d(
         width / 2 + 1,
         height / 2
             + ((WurstTheme) WurstClient.INSTANCE.gui.getTheme()).getFontRenderer().FONT_HEIGHT);
   }
   glEnd();
   glEnable(GL_TEXTURE_2D);
   ((WurstTheme) WurstClient.INSTANCE.gui.getTheme())
       .getFontRenderer()
       .drawStringWithShadow(
           targetLocked, width / 2 + 2, height / 2, RenderUtil.toRGBA(Color.WHITE));
   glEnable(GL_CULL_FACE);
   glDisable(GL_BLEND);
 }
예제 #3
0
  @Override
  protected void renderComponent(Slider component) {
    translateComponent(component, false);

    // GL settings
    glEnable(GL_BLEND);
    glDisable(GL_CULL_FACE);

    // area & font
    Rectangle area = component.getArea();
    int fontSize = theme.getFontRenderer().FONT_HEIGHT;
    FontRenderer fontRenderer = theme.getFontRenderer();

    // text
    fontRenderer.drawString(
        component.getText(), 0, 0, RenderUtil.toRGBA(component.getForegroundColor()));

    // value
    String content = null;
    switch (component.getValueDisplay()) {
      case DECIMAL:
        content =
            Double.toString(
                (double)
                        (Math.round(component.getValue() / component.getIncrement())
                            * 1000000
                            * (long) (component.getIncrement() * 1000000))
                    / 1000000
                    / 1000000);
        break;
      case INTEGER:
        content = String.format("%,d", Long.valueOf(Math.round(component.getValue())));
        break;
      case PERCENTAGE:
        int percent =
            (int)
                Math.round(
                    (component.getValue() - component.getMinimumValue())
                        / (component.getMaximumValue() - component.getMinimumValue())
                        * 100D);
        content = String.format("%d%%", percent);
      default:
    }
    if (content != null) {
      String suffix = component.getContentSuffix();
      if (suffix != null && !suffix.trim().isEmpty()) content = content.concat(" ").concat(suffix);
      fontRenderer.drawString(
          content,
          component.getWidth() - fontRenderer.getStringWidth(content),
          0,
          RenderUtil.toRGBA(component.getForegroundColor()));
    }
    glDisable(GL_TEXTURE_2D);

    // line
    glColor4f(0.03125f, 0.03125f, 0.03125f, 0.25f);
    glBegin(GL_QUADS);
    {
      glVertex2d(1, fontSize + 4);
      glVertex2d(area.width - 1, fontSize + 4);
      glVertex2d(area.width - 1, area.height - 2);
      glVertex2d(1, area.height - 2);
    }
    glEnd();

    // line shadow
    glLineWidth(1.0f);
    glColor4f(0.125f, 0.125f, 0.125f, 0.5f);
    glBegin(GL_LINE_LOOP);
    {
      glVertex2d(1, fontSize + 4);
      glVertex2d(area.width - 1, fontSize + 4);
      glVertex2d(area.width - 1, area.height - 2);
      glVertex2d(1, area.height - 2);
    }
    glEnd();

    double sliderPercentage =
        (component.getValue() - component.getMinimumValue())
            / (component.getMaximumValue() - component.getMinimumValue());

    // slider
    glColor4f(0.0f + (float) sliderPercentage, 1.0f - (float) sliderPercentage, 0.0f, 0.5f);
    glBegin(GL_QUADS);
    {
      glVertex2d((area.width - 6) * sliderPercentage - 1, fontSize + 1);
      glVertex2d((area.width - 6) * sliderPercentage + 7, fontSize + 1);
      glVertex2d((area.width - 6) * sliderPercentage + 7, area.height + 1);
      glVertex2d((area.width - 6) * sliderPercentage - 1, area.height + 1);
    }
    glEnd();

    // slider shadow
    RenderUtil.boxShadow(
        (area.width - 6) * sliderPercentage - 1,
        fontSize + 1,
        (area.width - 6) * sliderPercentage + 7,
        area.height + 1);

    // GL resets
    glEnable(GL_CULL_FACE);
    glEnable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    translateComponent(component, true);
  }