Search in sources :

Example 1 with ScaledResolution

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

the class LogisticsHUDRenderer method renderPlayerDisplay.

public void renderPlayerDisplay(long renderTicks) {
    if (!displayRenderer()) {
        return;
    }
    Minecraft mc = FMLClientHandler.instance().getClient();
    if (displayHUD() && displayCross) {
        ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
        int width = res.getScaledWidth();
        int height = res.getScaledHeight();
        if (GuiIngameForge.renderCrosshairs && mc.ingameGUI != null) {
            mc.renderEngine.bindTexture(LogisticsHUDRenderer.TEXTURE);
            GL11.glColor4d(0.0D, 0.0D, 0.0D, 1.0D);
            GL11.glDisable(GL11.GL_BLEND);
            mc.ingameGUI.drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16);
        }
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) Minecraft(net.minecraft.client.Minecraft)

Example 2 with ScaledResolution

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

the class ItemDisplay method renderItemArea.

public void renderItemArea(double zLevel) {
    GL11.glPushMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    screen.drawRect(left, top, left + width, top + height, Color.GREY);
    tooltip = null;
    int ppi = 0;
    int panelxSize = 20;
    int panelySize = 20;
    int x = 2;
    int y = 2;
    ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    int scaleX = scaledresolution.getScaledWidth();
    int scaleY = scaledresolution.getScaledHeight();
    int mouseX = Mouse.getX() * scaleX / mc.displayWidth - left;
    int mouseY = scaleY - Mouse.getY() * scaleY / mc.displayHeight - top;
    GL11.glTranslatef(left, top, 0.0F);
    if (!listbyserver) {
        int graphic = ((int) (System.currentTimeMillis() / 250) % 5);
        // GL11.glBindTexture(GL11.GL_TEXTURE_2D,
        // this.mc.renderEngine.getTexture());
        screen.getMC().renderEngine.bindTexture(ItemDisplay.TEXTURE);
        Tessellator tesselator = Tessellator.instance;
        tesselator.startDrawingQuads();
        int xPosition = (width / 2) - 50;
        int yPosition = 40;
        tesselator.addVertexWithUV(xPosition, yPosition + 100, zLevel, 0.04, 0.72 + (graphic * 0.03125));
        tesselator.addVertexWithUV(xPosition + 100, yPosition + 100, zLevel, 0.08, 0.72 + (graphic * 0.03125));
        tesselator.addVertexWithUV(xPosition + 100, yPosition, zLevel, 0.08, 0.69 + (graphic * 0.03125));
        tesselator.addVertexWithUV(xPosition, yPosition, zLevel, 0.04, 0.69 + (graphic * 0.03125));
        tesselator.draw();
    } else {
        RenderHelper.enableGUIStandardItemLighting();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_LIGHTING);
        for (ItemIdentifierStack itemIdentifierStack : _allItems) {
            ItemIdentifier item = itemIdentifierStack.getItem();
            if (search != null && !search.itemSearched(item)) {
                continue;
            }
            ppi++;
            if (ppi <= itemsPerPage * page) {
                continue;
            }
            if (ppi > itemsPerPage * (page + 1)) {
                break;
            }
            ItemStack itemstack = itemIdentifierStack.unsafeMakeNormalStack();
            // -2 on both, because field starts there (see black rect below)
            int realX = x - 2;
            int realY = y - 2;
            Pair<Integer, Integer> pair = new Pair<>(realX, realY);
            if (map.get(pair) != itemIdentifierStack) {
                map.put(pair, itemIdentifierStack);
            }
            if (mouseX >= realX && mouseX < realX + panelxSize && mouseY >= realY && mouseY < realY + panelySize) {
                screen.drawRect(x - 2, y - 2, x + panelxSize - 2, y + panelySize - 2, Color.BLACK);
                screen.drawRect(x - 1, y - 1, x + panelxSize - 3, y + panelySize - 3, Color.DARKER_GREY);
                tooltip = new Object[] { mouseX + left, mouseY + top, itemstack };
            }
            /*if (lastClickedx >= realX && lastClickedx < realX + panelxSize && lastClickedy >= realY && lastClickedy < realY + panelySize) {
					selectedItem = itemIdentifierStack;
					screen.drawRect(x - 2, y - 2, x + panelxSize - 2, y + panelySize - 2, Color.BLACK);
					screen.drawRect(x - 1, y - 1, x + panelxSize - 3, y + panelySize - 3, Color.LIGHTER_GREY);
					screen.drawRect(x, y, x + panelxSize - 4, y + panelySize - 4, Color.DARKER_GREY);
				}
				 */
            if (selectedItem == itemIdentifierStack) {
                screen.drawRect(x - 2, y - 2, x + panelxSize - 2, y + panelySize - 2, Color.BLACK);
                screen.drawRect(x - 1, y - 1, x + panelxSize - 3, y + panelySize - 3, Color.LIGHTER_GREY);
                screen.drawRect(x, y, x + panelxSize - 4, y + panelySize - 4, Color.DARKER_GREY);
                if (renderer != null) {
                    renderer.specialItemRendering(itemIdentifierStack.getItem(), x, y);
                }
            }
            // use GuiGraphics to render the ItemStacks
            ItemStackRenderer itemstackRenderer = new ItemStackRenderer(x, y, 100.0F, true, false, true);
            itemstackRenderer.setItemstack(itemstack).setDisplayAmount(DisplayAmount.HIDE_ONE);
            itemstackRenderer.renderInGui();
            x += panelxSize;
            if (x > width) {
                x = 2;
                y += panelySize;
            }
        }
        GL11.glEnable(GL11.GL_DEPTH_TEST);
    }
    GL11.glPopMatrix();
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Tessellator(net.minecraft.client.renderer.Tessellator) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemStack(net.minecraft.item.ItemStack) Pair(logisticspipes.utils.tuples.Pair) ItemStackRenderer(logisticspipes.utils.item.ItemStackRenderer)

Example 3 with ScaledResolution

use of net.minecraft.client.gui.ScaledResolution in project SimplyJetpacks by Tonius.

the class RenderUtils method drawStringAtHUDPosition.

public static void drawStringAtHUDPosition(String string, HUDPositions position, FontRenderer fontRenderer, int xOffset, int yOffset, double scale, int color, boolean shadow, int lineOffset) {
    ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    int screenWidth = res.getScaledWidth();
    screenWidth /= scale;
    int screenHeight = res.getScaledHeight();
    screenHeight /= scale;
    switch(position) {
        case TOP_LEFT:
            yOffset += lineOffset * 9;
            drawStringLeft(string, fontRenderer, 2 + xOffset, 2 + yOffset, color, shadow);
            break;
        case TOP_CENTER:
            yOffset += lineOffset * 9;
            drawStringCenter(string, fontRenderer, screenWidth / 2 + xOffset, 2 + yOffset, color, shadow);
            break;
        case TOP_RIGHT:
            yOffset += lineOffset * 9;
            drawStringRight(string, fontRenderer, screenWidth - 2 + xOffset, 2 + yOffset, color, shadow);
            break;
        case LEFT:
            yOffset += lineOffset * 9;
            drawStringLeft(string, fontRenderer, 2 + xOffset, screenHeight / 2 + yOffset, color, shadow);
            break;
        case RIGHT:
            yOffset += lineOffset * 9;
            drawStringRight(string, fontRenderer, screenWidth - 2 + xOffset, screenHeight / 2 + yOffset, color, shadow);
            break;
        case BOTTOM_LEFT:
            yOffset -= lineOffset * 9;
            drawStringLeft(string, fontRenderer, 2 + xOffset, screenHeight - 9 + yOffset, color, shadow);
            break;
        case BOTTOM_RIGHT:
            yOffset -= lineOffset * 9;
            drawStringRight(string, fontRenderer, screenWidth - 2 + xOffset, screenHeight - 9 + yOffset, color, shadow);
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution)

Example 4 with ScaledResolution

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

the class GuiPneumaticContainerBase method refreshScreen.

protected void refreshScreen() {
    ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
    int i = scaledresolution.getScaledWidth();
    int j = scaledresolution.getScaledHeight();
    setWorldAndResolution(Minecraft.getMinecraft(), i, j);
    for (IGuiWidget widget : widgets) {
        if (widget instanceof GuiAnimatedStat) {
            widget.update();
        }
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) IGuiWidget(pneumaticCraft.client.gui.widget.IGuiWidget) GuiAnimatedStat(pneumaticCraft.client.gui.widget.GuiAnimatedStat) IGuiAnimatedStat(pneumaticCraft.api.client.IGuiAnimatedStat) Point(java.awt.Point)

Example 5 with ScaledResolution

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

the class ClientEventHandler method tickEnd.

@SubscribeEvent
public void tickEnd(TickEvent.RenderTickEvent event) {
    if (event.phase == TickEvent.Phase.END && FMLClientHandler.instance().getClient().inGameHasFocus && PneumaticCraft.proxy.getPlayer().worldObj != null && (ModuleRegulatorTube.inverted || !ModuleRegulatorTube.inLine)) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
        FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer;
        String warning = EnumChatFormatting.RED + I18n.format("gui.regulatorTube.hudMessage." + (ModuleRegulatorTube.inverted ? "inverted" : "notInLine"));
        fontRenderer.drawStringWithShadow(warning, sr.getScaledWidth() / 2 - fontRenderer.getStringWidth(warning) / 2, sr.getScaledHeight() / 2 + 30, 0xFFFFFFFF);
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

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