use of net.minecraft.client.gui.FontRenderer in project Galacticraft by micdoodle8.
the class GuiElementTexturedButton method drawButton.
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
if (this.visible) {
final FontRenderer var4 = par1Minecraft.fontRendererObj;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
this.getHoverState(this.hovered);
par1Minecraft.renderEngine.bindTexture(this.texture);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 0, this.bWidth, this.bHeight);
this.mouseDragged(par1Minecraft, par2, par3);
int var6 = 14737632;
if (!this.enabled) {
var6 = -6250336;
} else if (this.hovered) {
var6 = 16777120;
}
this.drawCenteredString(var4, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, var6);
}
}
use of net.minecraft.client.gui.FontRenderer in project Galacticraft by micdoodle8.
the class GuiElementGradientList method draw.
public void draw(int mousePosX, int mousePosY) {
if (this.sliderEnabled) {
if (this.sliderGrabbed || mousePosX >= this.xPosition + this.width - 9 && mousePosX < this.xPosition + this.width && mousePosY >= this.yPosition && mousePosY < this.yPosition + this.height) {
if (Mouse.isButtonDown(0)) {
this.sliderGrabbed = true;
if (this.lastMousePosY > 0) {
if (mousePosY >= this.sliderPos && mousePosY < this.sliderPos + 15) {
int deltaY = this.lastMousePosY - this.sliderPos;
this.sliderPos = mousePosY - deltaY;
} else {
this.sliderPos = mousePosY - 7;
}
}
this.lastMousePosY = mousePosY;
} else {
this.sliderGrabbed = false;
}
} else {
this.lastMousePosY = 0;
}
}
if (Mouse.isButtonDown(0)) {
if (mousePosX >= this.xPosition && mousePosX < this.xPosition + this.width - 10 && mousePosY >= this.yPosition && mousePosY < this.yPosition + this.height) {
int clickPosY = mousePosY - this.yPosition + (int) Math.floor((this.listContents.size() * GuiElementGradientList.BUTTON_HEIGHT - this.height) * this.getSliderPercentage());
this.selectedIndex = clickPosY / GuiElementGradientList.BUTTON_HEIGHT;
if (this.selectedIndex < 0 || this.selectedIndex >= this.listContents.size()) {
this.selectedIndex = -1;
}
}
}
this.sliderPos = Math.min(Math.max(this.yPosition, this.sliderPos), this.yPosition + this.height - 15);
this.drawGradientRect(this.xPosition, this.yPosition, this.xPosition + this.width - 10, this.yPosition + this.height, ColorUtil.to32BitColor(255, 30, 30, 30), ColorUtil.to32BitColor(255, 30, 30, 30));
this.drawGradientRect(this.xPosition + this.width - 9, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, ColorUtil.to32BitColor(255, 50, 50, 50), ColorUtil.to32BitColor(255, 50, 50, 50));
int sliderColor = this.sliderEnabled ? ColorUtil.to32BitColor(255, 90, 90, 90) : ColorUtil.to32BitColor(255, 40, 40, 40);
this.drawGradientRect(this.xPosition + this.width - 9, this.sliderPos, this.xPosition + this.width, this.sliderPos + 15, sliderColor, sliderColor);
Gui.drawRect(this.xPosition + this.width - 1, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, ColorUtil.to32BitColor(255, 0, 0, 0));
Gui.drawRect(this.xPosition + this.width - 10, this.yPosition, this.xPosition + this.width - 9, this.yPosition + this.height, ColorUtil.to32BitColor(255, 0, 0, 0));
Gui.drawRect(this.xPosition, this.yPosition, this.xPosition + 1, this.yPosition + this.height, ColorUtil.to32BitColor(255, 0, 0, 0));
Gui.drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + 1, ColorUtil.to32BitColor(255, 0, 0, 0));
Gui.drawRect(this.xPosition, this.yPosition + this.height - 1, this.xPosition + this.width, this.yPosition + this.height, ColorUtil.to32BitColor(255, 0, 0, 0));
sliderColor = this.sliderEnabled ? ColorUtil.to32BitColor(255, 120, 120, 120) : ColorUtil.to32BitColor(255, 60, 60, 60);
Gui.drawRect(this.xPosition + this.width - 9, this.sliderPos + 1, this.xPosition + this.width - 8, this.sliderPos + 14, sliderColor);
Gui.drawRect(this.xPosition + this.width - 2, this.sliderPos + 1, this.xPosition + this.width - 1, this.sliderPos + 14, sliderColor);
Gui.drawRect(this.xPosition + this.width - 9, this.sliderPos, this.xPosition + this.width - 1, this.sliderPos + 1, sliderColor);
Gui.drawRect(this.xPosition + this.width - 9, this.sliderPos + 15, this.xPosition + this.width - 1, this.sliderPos + 14, sliderColor);
int currentDrawHeight = this.yPosition + 1 - (int) Math.floor((this.listContents.size() * GuiElementGradientList.BUTTON_HEIGHT - this.height) * this.getSliderPercentage());
FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRendererObj;
for (int i = 0; i < this.listContents.size(); i++) {
ListElement displayButton = this.listContents.get(i);
if (displayButton != null && displayButton.value != null && !displayButton.value.isEmpty()) {
int yCoord0 = currentDrawHeight;
int yCoord1 = currentDrawHeight + GuiElementGradientList.BUTTON_HEIGHT - 1;
if (yCoord1 > this.yPosition && yCoord0 < this.yPosition + this.height) {
yCoord0 = Math.max(this.yPosition + 1, yCoord0);
yCoord1 = Math.min(this.yPosition + this.height - 1, yCoord1);
int color = i == this.selectedIndex ? ColorUtil.to32BitColor(255, 35, 35, 35) : ColorUtil.to32BitColor(255, 25, 25, 25);
Gui.drawRect(this.xPosition + 1, yCoord0, this.xPosition + this.width - 10, yCoord1, color);
if (currentDrawHeight + GuiElementGradientList.BUTTON_HEIGHT / 2 - fontRenderer.FONT_HEIGHT / 2 > this.yPosition && currentDrawHeight + GuiElementGradientList.BUTTON_HEIGHT / 2 + fontRenderer.FONT_HEIGHT / 2 < this.yPosition + this.height) {
fontRenderer.drawString(displayButton.value, this.xPosition + (this.width - 10) / 2 - fontRenderer.getStringWidth(displayButton.value) / 2, currentDrawHeight + GuiElementGradientList.BUTTON_HEIGHT / 2 - fontRenderer.FONT_HEIGHT / 2, displayButton.color);
}
}
currentDrawHeight += GuiElementGradientList.BUTTON_HEIGHT;
}
}
}
use of net.minecraft.client.gui.FontRenderer in project Wizardry by TeamWizardry.
the class RenderCodex method renderItemStack.
// Manually rendering itemstack overlays because mojang set all their states
// to disabled depth which doesn't work for us
public void renderItemStack(ItemStack stack) {
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.enableRescaleNormal();
GlStateManager.pushMatrix();
RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);
GlStateManager.translate(0, 0, 150);
FontRenderer font = stack.getItem().getFontRenderer(stack);
if (font == null)
font = Minecraft.getMinecraft().fontRenderer;
if (font != null && stack.getCount() != 1) {
GlStateManager.disableLighting();
GlStateManager.disableBlend();
font.drawStringWithShadow(stack.getCount() + "", 17F - font.getStringWidth(stack.getCount() + ""), 9F, 0xFFFFFF);
GlStateManager.enableDepth();
GlStateManager.enableBlend();
}
if (stack.getItem().showDurabilityBar(stack)) {
GlStateManager.disableLighting();
GlStateManager.disableTexture2D();
GlStateManager.disableAlpha();
GlStateManager.disableBlend();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
double health = stack.getItem().getDurabilityForDisplay(stack);
int rgbfordisplay = stack.getItem().getRGBDurabilityForDisplay(stack);
int i = Math.round(13.0F - (float) health * 13.0F);
draw(bufferbuilder, 2, 13, 13, 2, 0, 0, 0, 255);
draw(bufferbuilder, 2, 13, i, 1, rgbfordisplay >> 16 & 255, rgbfordisplay >> 8 & 255, rgbfordisplay & 255, 255);
GlStateManager.enableBlend();
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
}
EntityPlayerSP entityplayersp = Minecraft.getMinecraft().player;
float f3 = entityplayersp == null ? 0.0F : entityplayersp.getCooldownTracker().getCooldown(stack.getItem(), Minecraft.getMinecraft().getRenderPartialTicks());
if (f3 > 0.0F) {
GlStateManager.disableLighting();
GlStateManager.disableTexture2D();
Tessellator tessellator1 = Tessellator.getInstance();
BufferBuilder bufferbuilder1 = tessellator1.getBuffer();
this.draw(bufferbuilder1, 0, MathHelper.floor(16.0F * (1.0F - f3)), 16, MathHelper.ceil(16.0F * f3), 255, 255, 255, 127);
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
}
GlStateManager.popMatrix();
GlStateManager.enableLighting();
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.disableRescaleNormal();
}
use of net.minecraft.client.gui.FontRenderer in project DynamicSurroundings by OreCruncher.
the class CompassHUD method doRender.
@Override
public void doRender(@Nonnull final RenderGameOverlayEvent.Pre event) {
if (event.getType() != ElementType.CROSSHAIRS || !this.textPanel.hasText())
return;
final Minecraft mc = Minecraft.getMinecraft();
final FontRenderer font = mc.fontRenderer;
final ScaledResolution resolution = event.getResolution();
final int centerX = (resolution.getScaledWidth() + 1) / 2;
final int centerY = (resolution.getScaledHeight() + 1) / 2;
this.textPanel.setAlpha(ModOptions.compass.compassTransparency);
this.textPanel.render(centerX, centerY + (int) (font.FONT_HEIGHT * TEXT_LINE_START), Reference.TOP_CENTER);
final Style style = Style.getStyle(ModOptions.compass.compassStyle);
mc.getTextureManager().bindTexture(style.getTextureResource());
if (this.showCompass) {
GlStateManager.color(1F, 1F, 1F, ModOptions.compass.compassTransparency);
if (!style.isRose()) {
final int direction = MathStuff.floor(((mc.player.rotationYaw * 256F) / 360F) + 0.5D) & 255;
final int x = (resolution.getScaledWidth() - style.getWidth() + 1) / 2;
final int y = (resolution.getScaledHeight() - style.getHeight() + 1) / 2 - style.getHeight();
if (direction < 128)
drawTexturedModalRect(x, y, direction, (ModOptions.compass.compassStyle * (style.getHeight() * 2)), style.getWidth(), style.getHeight());
else
drawTexturedModalRect(x, y, direction - 128, (ModOptions.compass.compassStyle * (style.getHeight() * 2)) + style.getHeight(), style.getWidth(), style.getHeight());
} else {
GlStateManager.pushMatrix();
GlStateManager.translate(centerX, centerY - BAND_HEIGHT * 2.5F, 0);
GlStateManager.rotate(70, 1F, 0F, 0F);
GlStateManager.rotate(-MathStuff.wrapDegrees(mc.player.rotationYaw + 180F), 0F, 0F, 1F);
final int x = -(style.getWidth() + 1) / 2;
final int y = -(style.getHeight() + 1) / 2;
drawTexturedModalRect(x, y, 0, 0, style.getWidth(), style.getHeight());
GlStateManager.popMatrix();
}
}
GlStateManager.color(1F, 1F, 1F, 1F);
}
use of net.minecraft.client.gui.FontRenderer in project DynamicSurroundings by OreCruncher.
the class LightLevelTextureSheet method render.
@Override
public void render() {
final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
final int color = Color.WHITE.rgbWithAlpha(0.99F);
final int shadow = Color.MC_DARKGRAY.rgbWithAlpha(0.99F);
OpenGlUtil.setStandardBlend();
for (int i = 0; i < 15; i++) {
final String str = Integer.toString(i);
final double mid = TEXEL_PER_SIDE / 2D;
final double posX = i * TEXEL_PER_SIDE + mid;
final double posY = mid;
GlStateManager.pushMatrix();
GlStateManager.translate(posX, posY, 0);
// Render the string in the center
final int margin = -(font.getStringWidth(str) + 1) / 2;
final int height = -(font.FONT_HEIGHT) / 2;
GlStateManager.scale(SCALE, SCALE, 0);
GlStateManager.translate(0.3F, 0.3F, 0F);
font.drawString(str, margin, height, shadow);
GlStateManager.translate(-0.3F, -0.3F, -0.001F);
font.drawString(str, margin, height, color);
GlStateManager.popMatrix();
}
}
Aggregations