Examples of FontRenderer


Examples of net.minecraft.src.FontRenderer

  public float getScale() {
    return scale;
  }

  private void updateGeometry() {
    FontRenderer font = SpoutClient.getHandle().fontRenderer;
    this.width = (float) font.getStringWidth(text) * 0.0139F * scale;
    this.height = 0.124F * scale;
  }
 
View Full Code Here

Examples of net.minecraft.src.FontRenderer

    }
    int hash = (new HashCodeBuilder()).append(text).append(width).toHashCode();
    if (optimalWidth.contains(hash)) {
      return optimalWidth.get(hash);
    }
    FontRenderer font = SpoutClient.getHandle().fontRenderer;
    String t = new String(text);
    int remove = 0;
    while (font.getStringWidth(t) > width) {
      remove++;
      t = text.substring(0, Math.max(0, text.length() - 1 - remove)) + "...";
    }
    optimalWidth.put(hash, t);
    return t;
View Full Code Here

Examples of net.minecraft.src.FontRenderer

    }
  }

  public void render(GenericButton button) {
    if (button.isVisible()) {
      FontRenderer font = Minecraft.getMinecraft().fontRenderer;
      Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("textures/gui/widgets.png"));     
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glTranslatef((float) Math.floor(button.getScreenX()), (float) Math.floor(button.getScreenY()), 0);
      float width = (float) (button.getWidth() < 200 ? button.getWidth() : 200);
      GL11.glScalef((float) button.getWidth() / width, (float) button.getHeight() / 20f, 1);

      String text = getFittingText(button.getText(), (int) button.getInnerWidth());

      int hoverState = getHoverState(button, isHovering(button));
      RenderUtil.drawTexturedModalRectangle(0, 0, 0, 46 + hoverState * 20, (int) Math.ceil(width / 2), 20, 0f);
      RenderUtil.drawTexturedModalRectangle((int) Math.floor(width / 2), 0, 200 - (int) Math.ceil(width / 2), 46 + hoverState * 20, (int) Math.ceil(width / 2), 20, 0f);
      Color color = getColor(button);

      int left = 5;
      WidgetAnchor align = button.getAlign();
      if (align == WidgetAnchor.TOP_CENTER || align == WidgetAnchor.CENTER_CENTER || align == WidgetAnchor.BOTTOM_CENTER) {
        left = (int) ((width / 2) - (font.getStringWidth(text) / 2));
      } else if (align == WidgetAnchor.TOP_RIGHT || align == WidgetAnchor.CENTER_RIGHT || align == WidgetAnchor.BOTTOM_RIGHT) {
        left = (int) (width - font.getStringWidth(text)) - 5;
      }

      GL11.glPushMatrix();
      float scale = button.getScale();
      GL11.glScalef(scale, scale, scale);
      font.drawStringWithShadow(text, left, 6, color.toInt());
      GL11.glPopMatrix();
    }
  }
View Full Code Here

Examples of net.minecraft.src.FontRenderer

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    RenderHelper.disableStandardItemLighting();
  }

  public void render(GenericLabel label) {
    FontRenderer font = SpoutClient.getHandle().fontRenderer;
    String lines[] = label.getLines();

    double swidth = label.getTextWidth();
    double sheight = label.getTextHeight();

    GL11.glPushMatrix();

    double top = label.getScreenY();

    WidgetAnchor align = label.getAlign();
    if (align == WidgetAnchor.CENTER_LEFT || align == WidgetAnchor.CENTER_CENTER || align == WidgetAnchor.CENTER_RIGHT) {
      top -= (int) (label.isAuto() ? label.getActualHeight() : label.getHeight()) / 2;
    } else if (align == WidgetAnchor.BOTTOM_LEFT || align == WidgetAnchor.BOTTOM_CENTER || align == WidgetAnchor.BOTTOM_RIGHT) {
      top -= (int) (label.isAuto() ? label.getActualHeight() : label.getHeight());
    }

    double aleft = label.getScreenX();
    if (align == WidgetAnchor.TOP_CENTER || align == WidgetAnchor.CENTER_CENTER || align == WidgetAnchor.BOTTOM_CENTER) {
      aleft -= (int) (label.isAuto() ? label.getActualWidth() : label.getWidth()) / 2;
    } else if (align == WidgetAnchor.TOP_RIGHT || align == WidgetAnchor.CENTER_RIGHT || align == WidgetAnchor.BOTTOM_RIGHT) {
      aleft -= (int) (label.isAuto() ? label.getActualWidth() : label.getWidth());
    }

    GL11.glTranslatef((float) Math.floor(aleft), (float) Math.floor(top), 0);
    if (!label.isAuto()) {
      GL11.glScalef((float) (label.getWidth() / swidth), (float) (label.getHeight() / sheight), 1);
    } else if (label.getAnchor() == WidgetAnchor.SCALE) {
      GL11.glScalef((float) (label.getScreen().getWidth() / 427f), (float) (label.getScreen().getHeight() / 240f), 1);
    }

    for (int i = 0; i < lines.length; i++) {
      double left = 0;

      if (align == WidgetAnchor.TOP_CENTER || align == WidgetAnchor.CENTER_CENTER || align == WidgetAnchor.BOTTOM_CENTER) {
        left = (swidth / 2) - (font.getStringWidth(lines[i]) / 2);
      } else if (align == WidgetAnchor.TOP_RIGHT || align == WidgetAnchor.CENTER_RIGHT || align == WidgetAnchor.BOTTOM_RIGHT) {
        left = swidth - font.getStringWidth(lines[i]);
      }

      float scale = label.getScale();
      float reset = 1 / scale;
      GL11.glScalef(scale, scale, scale);
      if (label.hasShadow()) {
        font.drawStringWithShadow(lines[i], (int) left, i * 10, label.getTextColor().toInt());
      } else {
        font.drawString(lines[i], (int) left, i * 10, label.getTextColor().toInt());
      }
      GL11.glScalef(reset, reset, reset);
    }
    GL11.glPopMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
View Full Code Here

Examples of net.minecraft.src.FontRenderer

      GL11.glPopMatrix();
    }
  }

  public void render(GenericTextField textField) {
    FontRenderer font = SpoutClient.getHandle().fontRenderer;
    RenderUtil.drawRectangle((int) (textField.getScreenX() - 1), (int) (textField.getScreenY() - 1), (int) (textField.getScreenX() + textField.getWidth() + 1), (int) (textField.getScreenY() + textField.getHeight() + 1), textField.getBorderColor().toInt());
    RenderUtil.drawRectangle((int) textField.getScreenX(), (int) textField.getScreenY(), (int) (textField.getScreenX() + textField.getWidth()), (int) (textField.getScreenY() + textField.getHeight()), textField.getFieldColor().toInt());

    int x = (int) (textField.getScreenX() + GenericTextField.PADDING);
    int y = (int) (textField.getScreenY() + GenericTextField.PADDING);
    int color = textField.isEnabled() ? textField.getColor().toInt() : textField.getDisabledColor().toInt();
    int[] cursor = textField.getTextProcessor().getCursor2D();
    int lineNum = 0;
    int cursorOffset = 0;
    if (textField.getText().length() != 0) {
      String line;
      Iterator<String> iter = textField.getTextProcessor().iterator();

      while (iter.hasNext()) {
        line = iter.next();
        if (lineNum == cursor[0]) {
          cursorOffset = font.getStringWidth(line.substring(0, cursor[1]));
        }
        font.drawStringWithShadow(line, x, y + (GenericTextField.LINE_HEIGHT + GenericTextField.LINE_SPACING) * lineNum++, color);
      }
    } else if (!textField.isFocus()) {
      font.drawStringWithShadow(textField.getPlaceholder(), x, y, color);
    }
    boolean showCursor = textField.isEnabled() && textField.isFocus() && shouldRenderCursor;
    if (showCursor) {
      font.drawStringWithShadow("_", x + cursorOffset, y + (GenericTextField.LINE_HEIGHT + GenericTextField.LINE_SPACING) * cursor[0] + 1, color);
    }

  }
View Full Code Here

Examples of net.minecraft.src.FontRenderer

      }

      if (Minecraft.getMinecraft().playerController.func_78763_f() && Minecraft.getMinecraft().thePlayer.experienceLevel > 0) {
        int color = 8453920;
        String level = "" + Minecraft.getMinecraft().thePlayer.experienceLevel;
        FontRenderer font = SpoutClient.getHandle().fontRenderer;
        int x = (int) (bar.getScreenX() + (183 / 2) - (font.getStringWidth(level) / 2));
        int y = (int) bar.getScreenY() - 6;
        font.drawString(level, x + 1, y, 0);
        font.drawString(level, x - 1, y, 0);
        font.drawString(level, x, y + 1, 0);
        font.drawString(level, x, y - 1, 0);
        font.drawString(level, x, y, color);
      }
    }
  }
View Full Code Here

Examples of net.minecraft.src.FontRenderer

      GL11.glAlphaFunc(GL11.GL_GREATER, 0.01F);
      Texture checkBoxCross = CustomTextureManager.getTextureFromPath(FileUtil.getAssetsDir().getPath()+"/ui/box_check.png");
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glTranslatef((float) Math.floor(checkBox.getScreenX()), (float) Math.floor(checkBox.getScreenY()), 0);
      renderBaseBox(checkBox, true);
      FontRenderer font = SpoutClient.getHandle().fontRenderer;
      Color color = getColor(checkBox);
      if (!checkBox.isChecked()) {
        color.setAlpha(0.2F);
      } else {
        color.setRed(0).setGreen(1).setBlue(0);
      }
      drawTexture(checkBoxCross, 20, 20, color, true);
      font.drawString(checkBox.getText(), 22, 7, getColor(checkBox).toInt());
    }
  }
View Full Code Here

Examples of net.minecraft.src.FontRenderer

    if (radioButton.isVisible()) {
      Texture radio = CustomTextureManager.getTextureFromPath(FileUtil.getAssetsDir().getPath()+"/ui/box_radio.png");
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glTranslatef((float) Math.floor(radioButton.getScreenX()), (float) Math.floor(radioButton.getScreenY()), 0);
      renderBaseBox(radioButton, true);
      FontRenderer font = SpoutClient.getHandle().fontRenderer;
      Color color = getColor(radioButton);
      if (!radioButton.isSelected()) {
        color.setAlpha(0.2F);
      }
      drawTexture(radio, 20, 20, color, true);
      font.drawString(radioButton.getText(), 22, 7, getColor(radioButton).toInt());
    }
  }
View Full Code Here

Examples of net.minecraft.src.FontRenderer

        GL11.glTranslated(-6, (-(y+2)), 0);

        x += 2 + w;
      }
    }
    FontRenderer font = SpoutClient.getHandle().fontRenderer;
    font.drawString(lwi.getTitle(), x + 2, y + 2, new Color(1.0F, 1.0F, 1.0F).toInt());
    font.drawString(lwi.getText(), x + 2, y + 2 + 8, new Color(0.8F, 0.8F, 0.8F).toInt());
  }
View Full Code Here

Examples of net.minecraft.src.FontRenderer

  public int getHeight() {
    return 11;
  }

  public void render(int x, int y, int width, int height) {
    FontRenderer font = SpoutClient.getHandle().fontRenderer;
    font.drawStringWithShadow("S", x + 2, y + 2, 0xffff0000);
    int w = font.getStringWidth("S");
    font.drawStringWithShadow(getName(), x + w + 4, y + 2, !isConflicting() ? 0xffffffff:0xffff0000);
    String keyString = parent.getEditingItem() == this ? "> <" : getDisplayKey();
    w = font.getStringWidth(keyString);
    font.drawStringWithShadow(keyString, width - w, y + 2, 0xffcccccc);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.