Search in sources :

Example 6 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project PneumaticCraft by MineMaarten.

the class GuiUnitProgrammer method render.

public void render(int x, int y, boolean showFlow, boolean showInfo, boolean translate) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int origX = x;
    int origY = y;
    x -= translatedX;
    y -= translatedY;
    float scale = getScale();
    x = (int) (x / scale);
    y = (int) (y / scale);
    if (scaleScroll.getState() != lastZoom) {
        float shift = SCALE_PER_STEP * (scaleScroll.getState() - lastZoom);
        if (new Rectangle(guiLeft + startX, guiTop + startY, areaWidth, areaHeight).contains(origX, origY)) {
            translatedX += shift * x;
            translatedY += shift * y;
        } else {
            translatedX += areaWidth / 2 * shift;
            translatedY += areaHeight / 2 * shift;
        }
    }
    lastZoom = scaleScroll.getState();
    ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
    GL11.glScissor((guiLeft + startX) * sr.getScaleFactor(), (sr.getScaledHeight() - areaHeight - (guiTop + startY)) * sr.getScaleFactor(), areaWidth * sr.getScaleFactor(), areaHeight * sr.getScaleFactor());
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glPushMatrix();
    GL11.glTranslated(translatedX, translatedY, 0);
    GL11.glScaled(scale, scale, 1);
    if (showFlow)
        showFlow();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    for (IProgWidget widget : progWidgets) {
        GL11.glPushMatrix();
        GL11.glTranslated(widget.getX() + guiLeft, widget.getY() + guiTop, 0);
        GL11.glScaled(0.5, 0.5, 1);
        widget.render();
        GL11.glPopMatrix();
    }
    for (IProgWidget widget : progWidgets) {
        List<String> errors = new ArrayList<String>();
        widget.addErrors(errors, progWidgets);
        if (errors.size() > 0) {
            drawBorder(widget, 0xFFFF0000);
        } else {
            List<String> warnings = new ArrayList<String>();
            widget.addWarnings(warnings, progWidgets);
            if (warnings.size() > 0) {
                drawBorder(widget, 0xFFFFFF00);
            }
        }
    }
    renderAdditionally();
    GL11.glColor4d(1, 1, 1, 1);
    if (showInfo) {
        for (IProgWidget widget : progWidgets) {
            GL11.glPushMatrix();
            GL11.glTranslated(widget.getX() + guiLeft, widget.getY() + guiTop, 0);
            GL11.glScaled(0.5, 0.5, 1);
            widget.renderExtraInfo();
            GL11.glPopMatrix();
        }
    }
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    boolean isLeftClicking = Mouse.isButtonDown(0);
    if (translate && isLeftClicking && wasClicking && new Rectangle(guiLeft + startX, guiTop + startY, areaWidth, areaHeight).contains(origX, origY)) {
        translatedX += origX - lastMouseX;
        translatedY += origY - lastMouseY;
    }
    wasClicking = isLeftClicking;
    lastMouseX = origX;
    lastMouseY = origY;
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) IProgWidget(pneumaticCraft.common.progwidgets.IProgWidget) Rectangle(java.awt.Rectangle) ArrayList(java.util.ArrayList)

Example 7 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project PneumaticCraft by MineMaarten.

the class HUDHandler method render2D.

private void render2D(float partialTicks) {
    Minecraft minecraft = FMLClientHandler.instance().getClient();
    EntityPlayer player = minecraft.thePlayer;
    ItemStack helmetStack = player.inventory.armorInventory[3];
    if (helmetStack != null && minecraft.inGameHasFocus && helmetStack.getItem() == Itemss.pneumaticHelmet) {
        ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight);
        GL11.glDepthMask(false);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glPushMatrix();
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glColor4d(0, 1, 0, 0.8D);
        CommonHUDHandler comHudHandler = CommonHUDHandler.getHandlerForPlayer(player);
        if (comHudHandler.ticksExisted <= comHudHandler.getStartupTime()) {
            // blockTrackInfo = null;
            gaveEmptyWarning = false;
            gaveNearlyEmptyWarning = false;
            RenderProgressBar.render(sr.getScaledWidth() / 2, 10, sr.getScaledWidth() - 10, 30, -90F, comHudHandler.ticksExisted * 100 / comHudHandler.getStartupTime());
        } else {
            if (comHudHandler.helmetPressure < 0.05F && !gaveEmptyWarning) {
                addMessage(new ArmorMessage("The helmet is out of air!", new ArrayList<String>(), 100, 0x70FF0000));
                gaveEmptyWarning = true;
            }
            if (comHudHandler.helmetPressure > 0.2F && comHudHandler.helmetPressure < 0.5F && !gaveNearlyEmptyWarning) {
                addMessage(new ArmorMessage("The helmet almost out of air!", new ArrayList<String>(), 60, 0x70FF0000));
                gaveNearlyEmptyWarning = true;
            }
            if (GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked) {
                for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
                    IUpgradeRenderHandler upgradeRenderHandler = UpgradeRenderHandlerList.instance().upgradeRenderers.get(i);
                    if (comHudHandler.upgradeRenderersInserted[i] && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + upgradeRenderHandler.getUpgradeName()).checked) {
                        IGuiAnimatedStat stat = upgradeRenderHandler.getAnimatedStat();
                        if (stat != null) {
                            stat.render(-1, -1, partialTicks);
                        }
                        upgradeRenderHandler.render2D(partialTicks, comHudHandler.helmetPressure > 0F);
                    }
                }
            }
        }
        // render every item in the list.
        for (ArmorMessage message : messageList) {
            message.renderMessage(minecraft.fontRenderer, partialTicks);
        }
        GL11.glPopMatrix();
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        if (comHudHandler.ticksExisted <= comHudHandler.getStartupTime())
            minecraft.fontRenderer.drawString(CommonHUDHandler.getHandlerForPlayer().ticksExisted * 100 / comHudHandler.getStartupTime() + "%", sr.getScaledWidth() * 3 / 4 - 8, 16, 0x000000);
    } else if (helmetStack == null) {
        messageList.clear();
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) IUpgradeRenderHandler(pneumaticCraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) CommonHUDHandler(pneumaticCraft.common.CommonHUDHandler) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) IGuiAnimatedStat(pneumaticCraft.api.client.IGuiAnimatedStat)

Example 8 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project PneumaticCraft by MineMaarten.

the class MainHelmetHandler method getAnimatedStat.

@Override
@SideOnly(Side.CLIENT)
public IGuiAnimatedStat getAnimatedStat() {
    if (powerStat == null) {
        Minecraft minecraft = Minecraft.getMinecraft();
        ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight);
        powerStat = new GuiAnimatedStat(null, "Helmet Pressure: ", "", powerStatX != -1 ? powerStatX : sr.getScaledWidth() - 2, powerStatY, 0x3000AA00, null, powerStatLeftSided);
        powerStat.setMinDimensionsAndReset(0, 0);
        powerStat.openWindow();
    }
    return powerStat;
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) GuiAnimatedStat(pneumaticCraft.client.gui.widget.GuiAnimatedStat) IGuiAnimatedStat(pneumaticCraft.api.client.IGuiAnimatedStat) Minecraft(net.minecraft.client.Minecraft) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 9 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project Minechem by iopleke.

the class RenderHelper method setScissor.

/**
     * Start a GL_SCISSOR_TEST
     *
     * @param guiWidth  {@link net.minecraft.client.gui.GuiScreen#width}
     * @param guiHeight {@link net.minecraft.client.gui.GuiScreen#height}
     * @param x         xPos to start scissor
     * @param y         yPos to start scissor
     * @param w         width of the scissor
     * @param h         height of the scissor
     */
public static void setScissor(int guiWidth, int guiHeight, float x, float y, int w, int h) {
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution scaledRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    int scale = scaledRes.getScaleFactor();
    x *= scale;
    y *= scale;
    w *= scale;
    h *= scale;
    float guiScaledWidth = (guiWidth * scale);
    float guiScaledHeight = (guiHeight * scale);
    float guiLeft = ((mc.displayWidth / 2) - guiScaledWidth / 2);
    float guiTop = ((mc.displayHeight / 2) + guiScaledHeight / 2);
    int scissorX = Math.round((guiLeft + x));
    int scissorY = Math.round(((guiTop - h) - y));
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor(scissorX, scissorY, w, h);
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) Minecraft(net.minecraft.client.Minecraft)

Example 10 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project ArsMagica2 by Mithion.

the class AMIngameGUI method renderGameOverlay.

public void renderGameOverlay() {
    ItemStack ci = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
    boolean drawAMHud = !AMCore.config.showHudMinimally() || (ci != null && (ci.getItem() == ItemsCommonProxy.spellBook || ci.getItem() == ItemsCommonProxy.spell || ci.getItem() == ItemsCommonProxy.arcaneSpellbook || ci.getItem() instanceof IBoundItem));
    ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    int i = scaledresolution.getScaledWidth();
    int j = scaledresolution.getScaledHeight();
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_TEXTURE_BIT);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    if (drawAMHud)
        RenderBuffs(i, j);
    mc.renderEngine.bindTexture(items);
    if (drawAMHud)
        RenderContingency(i, j);
    if (drawAMHud)
        RenderArsMagicaGUIItems(i, j, mc.fontRenderer);
    if (drawAMHud)
        RenderAffinity(i, j);
    RenderArmorStatus(i, j, mc, mc.fontRenderer);
    if (drawAMHud)
        RenderMagicXP(i, j);
    ItemStack item = mc.thePlayer.getCurrentEquippedItem();
    if (item != null && item.getItem() instanceof ItemSpellBook) {
        RenderSpellBookUI(i, j, mc.fontRenderer, mc.thePlayer.getCurrentEquippedItem());
    }
    GL11.glPopAttrib();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glColor4f(1, 1, 1, 1);
}
Also used : IBoundItem(am2.items.IBoundItem) ScaledResolution(net.minecraft.client.gui.ScaledResolution) ItemStack(net.minecraft.item.ItemStack) ItemSpellBook(am2.items.ItemSpellBook)

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