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) {