Examples of MCRenderDelegate


Examples of org.spoutcraft.client.gui.MCRenderDelegate

  public int getHeight() {
    return 33;
  }

  public void render(int x, int y, int width, int height) {
    MCRenderDelegate r = (MCRenderDelegate) Spoutcraft.getRenderDelegate();
    if (databaseId != -1) {
      String iconUrl = "http://solder.inspirenxe.org/resources/spoutcraft/servers/images/" + databaseId + ".png";
      Texture icon = CustomTextureManager.getTextureFromUrl("Spoutcraft", iconUrl);
      if (icon == null) {
        CustomTextureManager.downloadTexture("Spoutcraft", iconUrl, true);
        icon = CustomTextureManager.getTextureFromPath(FileUtil.getAssetsDir().getPath()+"/icon/unknown_server.png");
      }
      GL11.glPushMatrix();
      GL11.glTranslated(x + 2, y + 2, 0);
      r.drawTexture(icon, 25, 25);
      GL11.glPopMatrix();
    }

    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) {
View Full Code Here

Examples of org.spoutcraft.client.gui.MCRenderDelegate

  @Override
  public void render() {
    if (!allowSorting) {
      super.render();
    } else {
      MCRenderDelegate r = (MCRenderDelegate) SpoutClient.getInstance().getRenderDelegate();
      String texture = "";
      if (isSelected() && topdown || !isSelected() && preferredOrder) {
        texture = "/ui/box_ascending.png";
      } else {
        texture = "/ui/box_descending.png";
      }
      Texture direction = CustomTextureManager.getTextureFromPath(FileUtil.getAssetsDir().getPath() + texture);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glTranslatef((float) getScreenX(), (float) getScreenY(), 0);
      r.renderBaseBox(this, true);
      FontRenderer font = SpoutClient.getHandle().fontRenderer;
      Color color = r.getColor(this);
      if (!isSelected()) {
        color.setAlpha(0.2F);
      }
      r.drawTexture(direction, 20, 20, color, true);
      font.drawString(getText(), 22, 7, r.getColor(this).toInt());
    }
  }
View Full Code Here

Examples of org.spoutcraft.client.gui.MCRenderDelegate

  public int getHeight() {
    return 11;
  }

  public void render(int x, int y, int width, int height) {
    MCRenderDelegate r = (MCRenderDelegate) SpoutClient.getInstance().getRenderDelegate();
    FontRenderer font = SpoutClient.getHandle().fontRenderer;
    font.drawStringWithShadow("S", x + 2, y + 2, 0xff00ff00);
    int w = font.getStringWidth("S");
    String keyString = parent.getEditingItem() == this ? "> <" : shortcut.toString();
    int w2 = font.getStringWidth(keyString);
    font.drawStringWithShadow(keyString, width - w2, y + 2, 0xffcccccc);
    String fitting = r.getFittingText(getName(), width - w - w2 - 4);
    font.drawStringWithShadow(fitting, x + w + 4, y + 2, !isConflicting() ? 0xffffffff:0xffff0000);
  }
View Full Code Here

Examples of org.spoutcraft.client.gui.MCRenderDelegate

  public int getHeight() {
    return 20;
  }

  public void render(int x, int y, int width, int height) {
    MCRenderDelegate r = (MCRenderDelegate) SpoutClient.getInstance().getRenderDelegate();
    FontRenderer font = SpoutClient.getHandle().fontRenderer;
    font.drawStringWithShadow("B", x + 2, y + 2, 0xff0000ff);
    int w = font.getStringWidth("B");
    String keyString = parent.getEditingItem() == this ? "> <" : binding.toString();
    int w2 = font.getStringWidth(keyString);
    font.drawStringWithShadow(keyString, width - w2, y + 2, 0xffcccccc);
    font.drawStringWithShadow(binding.getAddonName(), x + w + 4, y + 11, 0xffffffff);
    String fitting = r.getFittingText(getName(), width - w - w2 - 4);

    font.drawStringWithShadow(fitting, x + w + 4, y + 2, !isConflicting() ? 0xffffffff:0xffff0000);
  }
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.