Package net.minecraft.src

Examples of net.minecraft.src.FontRenderer


    int marginleft = 29;

    int ping = getPing();

    FontRenderer font = SpoutClient.getHandle().fontRenderer;

    int margin1 = 0;
    int margin2 = 0;

    if (getPing() > 0 && (!isPolling() || showPingWhilePolling)) {
      if (isShowPing()) {
        String sping = getPing() + " ms";
        int pingwidth = font.getStringWidth(sping);
        margin1 = pingwidth + 14;
        font.drawStringWithShadow(sping, x + width - pingwidth - 14, y + 2, 0xaaaaaa);
      }
      String sPlayers = getPlayers() + " / " + getMaxPlayers() + " players";
      int playerswidth = font.getStringWidth(sPlayers);
      margin2 = playerswidth;
      font.drawStringWithShadow(sPlayers, x + width - playerswidth - 2, y + 11, 0xaaaaaa);
    }

    font.drawStringWithShadow(r.getFittingText(title, width - margin1 - marginleft), x + marginleft, y + 2, 0xffffff);
    String sMotd = "";
    if ((getPing() == PollResult.PING_POLLING || isPolling()) && !showPingWhilePolling) {
      sMotd = showPing ? "Polling ..." : "Retrieving MOTD";
    } else if (!showPingWhilePolling) {
      switch (getPing()) {
        case PollResult.PING_UNKNOWN:
          sMotd = ChatColor.RED + "Unknown Host!";
          break;
        case PollResult.PING_TIMEOUT:
          sMotd = ChatColor.RED + "Operation timed out!";
          break;
        case PollResult.PING_BAD_MESSAGE:
          sMotd = ChatColor.RED + "Bad Message (Server version likely outdated)!";
          break;
        default:
          sMotd = ChatColor.GREEN + getMotd();
          break;
      }
    }

    int color = 0xffffff;
    if ((getPing() == PollResult.PING_POLLING || isPolling()) && !showPingWhilePolling) {
      Color c1 = new Color(0, 0, 0);
      double darkness = 0;
      long t = System.currentTimeMillis() % 1000;
      darkness = Math.cos(t * 2 * Math.PI / 1000) * 0.2 + 0.2;
      c1.setBlue(1f - (float)darkness);
      color = c1.toInt();
    }

    font.drawStringWithShadow(r.getFittingText(sMotd, width - 10 - margin2 - marginleft), x + marginleft, y + 11, color);

    GL11.glColor4f(1f, 1f, 1f, 1f);

    // Fancy icons
    int xOffset = 0;
    int yOffset = 0;
    if (isPolling() && isShowPing()) {
      xOffset = 1;
      yOffset = (int)(System.currentTimeMillis() / 100L & 7L);
      if (yOffset > 4) {
        yOffset = 8 - yOffset;
      }
    } else if (isShowPing()) {
      xOffset = 0;
      if (ping < 0L) {
        yOffset = 5;
      } else if (ping < 150L) {
        yOffset = 0;
      } else if (ping < 300L) {
        yOffset = 1;
      } else if (ping < 600L) {
        yOffset = 2;
      } else if (ping < 1000L) {
        yOffset = 3;
      } else {
        yOffset = 4;
      }
    }
    if (isShowPing()) {
      Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/gui/icons.png"));     
      RenderUtil.drawTexturedModalRectangle(x + width - 2 - 10, y + 2, 0 + xOffset * 10, 176 + yOffset * 8, 10, 8, 0f);
    }
    if (port != DEFAULT_PORT) {
      font.drawStringWithShadow(ip + ":" +port, x+marginleft, y+20, 0xaaaaaa);
    } else {
      font.drawStringWithShadow(ip, x+marginleft, y+20, 0xaaaaaa);
    }

    // Icon drawing
    int iconMargin = 2;

    if (country != null) {
      String url = "http://cdn.spout.org/img/flag/" + country.toLowerCase() + ".png";
      Texture icon = CustomTextureManager.getTextureFromUrl("Spoutcraft", url);
      if (icon != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(x + width - iconMargin - 16, y + 20, 0);
        r.drawTexture(icon, 16, 11);
        GL11.glPopMatrix();
        iconMargin += 5 + 16;
      } else {
        CustomTextureManager.downloadTexture("Spoutcraft", url);
      }
    }

    if (accessType != OPEN) {
      String name = "lock";
      switch(accessType) {
      case WHITELIST:
        name = "whitelist";
        break;
      case GRAYLIST:
        name = "graylist";
        break;
      case BLACKLIST:
        name = "blacklist";
        break;
      }
      Texture lockIcon = CustomTextureManager.getTextureFromPath(FileUtil.getAssetsDir().getPath()+"/" + name + ".png");
      GL11.glPushMatrix();
      GL11.glTranslatef(x + width - iconMargin - 7, y + 20, 0);
      r.drawTexture(lockIcon, 7, 11);
      GL11.glPopMatrix();
      iconMargin += 5 + 7;
    }

    if (pollResult.getVersion() != null) {
      GL11.glPushMatrix();
      versionWidth = font.getStringWidth("1.0.0");
        if (isCompatible(SpoutClient.spoutcraftVersion)) {
          font.drawStringWithShadow(pollResult.getVersion(), x + width - versionWidth - 20, y + 21, 0x00FF00);
        } else {
          font.drawStringWithShadow(pollResult.getVersion(), x + width - versionWidth - 20, y + 21, 0xF44607);
        }
      GL11.glPopMatrix();
    } else {
      GL11.glPushMatrix();
      versionWidth = font.getStringWidth("Unknown");
      font.drawStringWithShadow("Unknown", x + width - versionWidth - 20, y + 21, 0xFF0000);
      GL11.glPopMatrix();
    }
  }
View Full Code Here


  public void afterChange() {
    Iterator i$ = FontUtils.access$000().iterator();

    while (i$.hasNext()) {
      FontRenderer renderer = (FontRenderer)i$.next();
      renderer.readFontTexture();
    }
  }
View Full Code Here

  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

    }
    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

    }
  }

  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

    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

      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

      }

      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

      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

    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

TOP

Related Classes of net.minecraft.src.FontRenderer

Copyright © 2018 www.massapicom. 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.