Search in sources :

Example 21 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project MinecraftForge by MinecraftForge.

the class GuiIngameForge method renderGameOverlay.

@Override
public void renderGameOverlay(float partialTicks) {
    res = new ScaledResolution(mc);
    eventParent = new RenderGameOverlayEvent(partialTicks, res);
    int width = res.getScaledWidth();
    int height = res.getScaledHeight();
    renderHealthMount = mc.player.getRidingEntity() instanceof EntityLivingBase;
    renderFood = mc.player.getRidingEntity() == null;
    renderJumpBar = mc.player.isRidingHorse();
    right_height = 39;
    left_height = 39;
    if (pre(ALL))
        return;
    fontrenderer = mc.fontRendererObj;
    mc.entityRenderer.setupOverlayRendering();
    GlStateManager.enableBlend();
    if (Minecraft.isFancyGraphicsEnabled()) {
        renderVignette(mc.player.getBrightness(partialTicks), res);
    } else {
        GlStateManager.enableDepth();
        GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    }
    if (renderHelmet)
        renderHelmet(res, partialTicks);
    if (renderPortal && !mc.player.isPotionActive(MobEffects.NAUSEA)) {
        renderPortal(res, partialTicks);
    }
    if (renderHotbar)
        renderHotbar(res, partialTicks);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    zLevel = -90.0F;
    rand.setSeed((long) (updateCounter * 312871));
    if (renderCrosshairs)
        renderCrosshairs(partialTicks);
    if (renderBossHealth)
        renderBossHealth();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    if (this.mc.playerController.shouldDrawHUD() && this.mc.getRenderViewEntity() instanceof EntityPlayer) {
        if (renderHealth)
            renderHealth(width, height);
        if (renderArmor)
            renderArmor(width, height);
        if (renderFood)
            renderFood(width, height);
        if (renderHealthMount)
            renderHealthMount(width, height);
        if (renderAir)
            renderAir(width, height);
    }
    renderSleepFade(width, height);
    if (renderJumpBar) {
        renderJumpBar(width, height);
    } else if (renderExperiance) {
        renderExperience(width, height);
    }
    renderToolHighlight(res);
    renderHUDText(width, height);
    renderFPSGraph();
    renderPotionIcons(res);
    renderRecordOverlay(width, height, partialTicks);
    renderSubtitles(res);
    renderTitle(width, height, partialTicks);
    Scoreboard scoreboard = this.mc.world.getScoreboard();
    ScoreObjective objective = null;
    ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(mc.player.getName());
    if (scoreplayerteam != null) {
        int slot = scoreplayerteam.getChatFormat().getColorIndex();
        if (slot >= 0)
            objective = scoreboard.getObjectiveInDisplaySlot(3 + slot);
    }
    ScoreObjective scoreobjective1 = objective != null ? objective : scoreboard.getObjectiveInDisplaySlot(1);
    if (renderObjective && scoreobjective1 != null) {
        this.renderScoreboard(scoreobjective1, res);
    }
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
    GlStateManager.disableAlpha();
    renderChat(width, height);
    renderPlayerList(width, height);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableLighting();
    GlStateManager.enableAlpha();
    post(ALL);
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) ScoreObjective(net.minecraft.scoreboard.ScoreObjective) Scoreboard(net.minecraft.scoreboard.Scoreboard) RenderGameOverlayEvent(net.minecraftforge.client.event.RenderGameOverlayEvent) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ScorePlayerTeam(net.minecraft.scoreboard.ScorePlayerTeam)

Example 22 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project MinecraftForge by MinecraftForge.

the class GuiScrollingList method drawScreen.

public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    this.mouseX = mouseX;
    this.mouseY = mouseY;
    this.drawBackground();
    boolean isHovering = mouseX >= this.left && mouseX <= this.left + this.listWidth && mouseY >= this.top && mouseY <= this.bottom;
    int listLength = this.getSize();
    int scrollBarWidth = 6;
    int scrollBarRight = this.left + this.listWidth;
    int scrollBarLeft = scrollBarRight - scrollBarWidth;
    int entryLeft = this.left;
    int entryRight = scrollBarLeft - 1;
    int viewHeight = this.bottom - this.top;
    int border = 4;
    if (Mouse.isButtonDown(0)) {
        if (this.initialMouseClickY == -1.0F) {
            if (isHovering) {
                int mouseListY = mouseY - this.top - this.headerHeight + (int) this.scrollDistance - border;
                int slotIndex = mouseListY / this.slotHeight;
                if (mouseX >= entryLeft && mouseX <= entryRight && slotIndex >= 0 && mouseListY >= 0 && slotIndex < listLength) {
                    this.elementClicked(slotIndex, slotIndex == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L);
                    this.selectedIndex = slotIndex;
                    this.lastClickTime = System.currentTimeMillis();
                } else if (mouseX >= entryLeft && mouseX <= entryRight && mouseListY < 0) {
                    this.clickHeader(mouseX - entryLeft, mouseY - this.top + (int) this.scrollDistance - border);
                }
                if (mouseX >= scrollBarLeft && mouseX <= scrollBarRight) {
                    this.scrollFactor = -1.0F;
                    int scrollHeight = this.getContentHeight() - viewHeight - border;
                    if (scrollHeight < 1)
                        scrollHeight = 1;
                    int var13 = (int) ((float) (viewHeight * viewHeight) / (float) this.getContentHeight());
                    if (var13 < 32)
                        var13 = 32;
                    if (var13 > viewHeight - border * 2)
                        var13 = viewHeight - border * 2;
                    this.scrollFactor /= (float) (viewHeight - var13) / (float) scrollHeight;
                } else {
                    this.scrollFactor = 1.0F;
                }
                this.initialMouseClickY = mouseY;
            } else {
                this.initialMouseClickY = -2.0F;
            }
        } else if (this.initialMouseClickY >= 0.0F) {
            this.scrollDistance -= ((float) mouseY - this.initialMouseClickY) * this.scrollFactor;
            this.initialMouseClickY = (float) mouseY;
        }
    } else {
        this.initialMouseClickY = -1.0F;
    }
    this.applyScrollLimits();
    Tessellator tess = Tessellator.getInstance();
    VertexBuffer worldr = tess.getBuffer();
    ScaledResolution res = new ScaledResolution(client);
    double scaleW = client.displayWidth / res.getScaledWidth_double();
    double scaleH = client.displayHeight / res.getScaledHeight_double();
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor((int) (left * scaleW), (int) (client.displayHeight - (bottom * scaleH)), (int) (listWidth * scaleW), (int) (viewHeight * scaleH));
    if (this.client.world != null) {
        this.drawGradientRect(this.left, this.top, this.right, this.bottom, 0xC0101010, 0xD0101010);
    } else // Draw dark dirt background
    {
        GlStateManager.disableLighting();
        GlStateManager.disableFog();
        this.client.renderEngine.bindTexture(Gui.OPTIONS_BACKGROUND);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        float scale = 32.0F;
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(this.left, this.bottom, 0.0D).tex(this.left / scale, (this.bottom + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
        worldr.pos(this.right, this.bottom, 0.0D).tex(this.right / scale, (this.bottom + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
        worldr.pos(this.right, this.top, 0.0D).tex(this.right / scale, (this.top + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
        worldr.pos(this.left, this.top, 0.0D).tex(this.left / scale, (this.top + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
        tess.draw();
    }
    int baseY = this.top + border - (int) this.scrollDistance;
    if (this.hasHeader) {
        this.drawHeader(entryRight, baseY, tess);
    }
    for (int slotIdx = 0; slotIdx < listLength; ++slotIdx) {
        int slotTop = baseY + slotIdx * this.slotHeight + this.headerHeight;
        int slotBuffer = this.slotHeight - border;
        if (slotTop <= this.bottom && slotTop + slotBuffer >= this.top) {
            if (this.highlightSelected && this.isSelected(slotIdx)) {
                int min = this.left;
                int max = entryRight;
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                GlStateManager.disableTexture2D();
                worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
                worldr.pos(min, slotTop + slotBuffer + 2, 0).tex(0, 1).color(0x80, 0x80, 0x80, 0xFF).endVertex();
                worldr.pos(max, slotTop + slotBuffer + 2, 0).tex(1, 1).color(0x80, 0x80, 0x80, 0xFF).endVertex();
                worldr.pos(max, slotTop - 2, 0).tex(1, 0).color(0x80, 0x80, 0x80, 0xFF).endVertex();
                worldr.pos(min, slotTop - 2, 0).tex(0, 0).color(0x80, 0x80, 0x80, 0xFF).endVertex();
                worldr.pos(min + 1, slotTop + slotBuffer + 1, 0).tex(0, 1).color(0x00, 0x00, 0x00, 0xFF).endVertex();
                worldr.pos(max - 1, slotTop + slotBuffer + 1, 0).tex(1, 1).color(0x00, 0x00, 0x00, 0xFF).endVertex();
                worldr.pos(max - 1, slotTop - 1, 0).tex(1, 0).color(0x00, 0x00, 0x00, 0xFF).endVertex();
                worldr.pos(min + 1, slotTop - 1, 0).tex(0, 0).color(0x00, 0x00, 0x00, 0xFF).endVertex();
                tess.draw();
                GlStateManager.enableTexture2D();
            }
            this.drawSlot(slotIdx, entryRight, slotTop, slotBuffer, tess);
        }
    }
    GlStateManager.disableDepth();
    int extraHeight = (this.getContentHeight() + border) - viewHeight;
    if (extraHeight > 0) {
        int height = (viewHeight * viewHeight) / this.getContentHeight();
        if (height < 32)
            height = 32;
        if (height > viewHeight - border * 2)
            height = viewHeight - border * 2;
        int barTop = (int) this.scrollDistance * (viewHeight - height) / extraHeight + this.top;
        if (barTop < this.top) {
            barTop = this.top;
        }
        GlStateManager.disableTexture2D();
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(scrollBarLeft, this.bottom, 0.0D).tex(0.0D, 1.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex();
        worldr.pos(scrollBarRight, this.bottom, 0.0D).tex(1.0D, 1.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex();
        worldr.pos(scrollBarRight, this.top, 0.0D).tex(1.0D, 0.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex();
        worldr.pos(scrollBarLeft, this.top, 0.0D).tex(0.0D, 0.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex();
        tess.draw();
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(scrollBarLeft, barTop + height, 0.0D).tex(0.0D, 1.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex();
        worldr.pos(scrollBarRight, barTop + height, 0.0D).tex(1.0D, 1.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex();
        worldr.pos(scrollBarRight, barTop, 0.0D).tex(1.0D, 0.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex();
        worldr.pos(scrollBarLeft, barTop, 0.0D).tex(0.0D, 0.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex();
        tess.draw();
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(scrollBarLeft, barTop + height - 1, 0.0D).tex(0.0D, 1.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
        worldr.pos(scrollBarRight - 1, barTop + height - 1, 0.0D).tex(1.0D, 1.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
        worldr.pos(scrollBarRight - 1, barTop, 0.0D).tex(1.0D, 0.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
        worldr.pos(scrollBarLeft, barTop, 0.0D).tex(0.0D, 0.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
        tess.draw();
    }
    this.drawScreen(mouseX, mouseY);
    GlStateManager.enableTexture2D();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.enableAlpha();
    GlStateManager.disableBlend();
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 23 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project LogisticsPipes by RS485.

the class SideConfigDisplay method renderOverlay.

private void renderOverlay(int mx, int my) {
    Rectangle vp = camera.getViewport();
    ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    int vpx = vp.x / scaledresolution.getScaleFactor();
    int vph = vp.height / scaledresolution.getScaleFactor();
    int vpw = vp.width / scaledresolution.getScaleFactor();
    int vpy = (int) ((float) (vp.y + vp.height - 4) / (float) scaledresolution.getScaleFactor());
    GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(vpx, vpy, -2000.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) Rectangle(java.awt.Rectangle)

Example 24 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project MineFactoryReloaded by powercrystals.

the class RenderTickHandler method renderHUD.

private void renderHUD(float partialTicks) {
    Minecraft mc = Minecraft.getMinecraft();
    if (!mc.isGamePaused && mc.currentScreen == null && mc.thePlayer != null && mc.thePlayer.inventory.getCurrentItem() != null && mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemRocketLauncher) {
        ScaledResolution sr = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
        Point center = new Point(sr.getScaledWidth() / 2, sr.getScaledHeight() / 2);
        if (MineFactoryReloadedClient.instance.getLockedEntity() != Integer.MIN_VALUE) {
            mc.renderEngine.bindTexture("/powercrystals/minefactoryreloaded/textures/hud/lockon_blue.png");
        } else {
            mc.renderEngine.bindTexture("/powercrystals/minefactoryreloaded/textures/hud/lockon_red.png");
        }
        GL11.glPushMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef(center.getX(), center.getY(), 0);
        GL11.glRotatef((mc.theWorld.getWorldTime() * 4) % 360 + partialTicks, 0, 0, 1);
        float distance = MineFactoryReloadedClient.instance.getLockTimeRemaining();
        drawLockonPart(center, distance, 0);
        drawLockonPart(center, distance, 90);
        drawLockonPart(center, distance, 180);
        drawLockonPart(center, distance, 270);
        GL11.glPopMatrix();
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) ItemRocketLauncher(powercrystals.minefactoryreloaded.item.ItemRocketLauncher) Point(org.lwjgl.util.Point) Minecraft(net.minecraft.client.Minecraft)

Example 25 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project CodeChickenLib by Chicken-Bones.

the class GuiDraw method displaySize.

public static Dimension displaySize() {
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution res = new ScaledResolution(mc);
    return new Dimension(res.getScaledWidth(), res.getScaledHeight());
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) Minecraft(net.minecraft.client.Minecraft)

Aggregations

ScaledResolution (net.minecraft.client.gui.ScaledResolution)29 Minecraft (net.minecraft.client.Minecraft)15 ItemStack (net.minecraft.item.ItemStack)8 GuiAnimatedStat (pneumaticCraft.client.gui.widget.GuiAnimatedStat)5 Rectangle (java.awt.Rectangle)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 FontRenderer (net.minecraft.client.gui.FontRenderer)3 Tessellator (net.minecraft.client.renderer.Tessellator)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 IGuiAnimatedStat (pneumaticCraft.api.client.IGuiAnimatedStat)3 ArrayList (java.util.ArrayList)2 AMVector2 (am2.api.math.AMVector2)1 IBoundItem (am2.items.IBoundItem)1 ItemSpellBook (am2.items.ItemSpellBook)1 IGuideItem (amerifrance.guideapi.api.IGuideItem)1 IGuideLinked (amerifrance.guideapi.api.IGuideLinked)1 IInfoRenderer (amerifrance.guideapi.api.IInfoRenderer)1 Book (amerifrance.guideapi.api.impl.Book)1 CategoryAbstract (amerifrance.guideapi.api.impl.abstraction.CategoryAbstract)1