Search in sources :

Example 1 with IPoint

use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.

the class ControlItemDisplay method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    if (this.itemStack.isEmpty()) {
        return;
    }
    final IPoint relativeToWindow = this.getAbsolutePosition().sub(this.getTopParent().getPosition());
    if (relativeToWindow.xPos() > Window.get(this).getSize().xPos() + 100 || relativeToWindow.yPos() > Window.get(this).getSize().yPos() + 100) {
        return;
    }
    GlStateManager.enableDepth();
    if (this.getSize().xPos() != 16) {
        GlStateManager.pushMatrix();
        final float scale = this.getSize().xPos() / 16.0f;
        GlStateManager.scale(scale, scale, 1);
        RenderUtil.drawItem(Point.ZERO, this.itemStack, this.rotating);
        GlStateManager.popMatrix();
    } else {
        RenderUtil.drawItem(Point.ZERO, this.itemStack, this.rotating);
    }
    GlStateManager.enableAlpha();
}
Also used : IPoint(binnie.core.api.gui.IPoint) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with IPoint

use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.

the class ControlChromosome method setSystem.

public void setSystem(@Nullable IBreedingSystem breedingSystem) {
    if (this.breedingSystem != breedingSystem) {
        this.breedingSystem = breedingSystem;
        deleteAllChildren();
        if (breedingSystem != null) {
            IFieldKitPlugin fieldKitPlugin = breedingSystem.getFieldKitPlugin();
            fieldKitPlugin.getChromosomePickerPositions();
            for (Map.Entry<IChromosomeType, IPoint> entry : fieldKitPlugin.getChromosomePickerPositions().entrySet()) {
                IChromosomeType chromosomeType = entry.getKey();
                IPoint position = entry.getValue();
                new ControlChromoPicker(this, position.xPos(), position.yPos(), chromosomeType);
            }
        }
    }
}
Also used : IFieldKitPlugin(binnie.core.api.genetics.IFieldKitPlugin) IPoint(binnie.core.api.gui.IPoint) IChromosomeType(forestry.api.genetics.IChromosomeType) Map(java.util.Map)

Example 3 with IPoint

use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.

the class TextureRenderer method texture.

public void texture(@Nullable final ITexture texture, final IArea area) {
    if (texture == null) {
        return;
    }
    this.setTexture(texture);
    final IArea textureArea = texture.getArea().outset(texture.getBorder());
    final IArea targetArea = area.outset(texture.getBorder());
    if (textureArea.width() == targetArea.width() && textureArea.height() == targetArea.height()) {
        final IPoint position = targetArea.pos();
        GuiUtils.drawTexturedModalRect(position.xPos(), position.yPos(), textureArea.pos().xPos(), textureArea.pos().yPos(), textureArea.size().xPos(), textureArea.size().yPos(), 0);
    } else {
        renderTexturePadded(targetArea, textureArea, texture.getTotalPadding());
    }
}
Also used : IArea(binnie.core.api.gui.IArea) IPoint(binnie.core.api.gui.IPoint)

Example 4 with IPoint

use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.

the class ControlLumbermillProgress method onRenderForeground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
    GlStateManager.disableLighting();
    final int sawX = (int) (63 * this.progress);
    CraftGUI.RENDER.texture(ControlLumbermillProgress.SAW, new Point(sawX, -8 + Math.round(6 * (float) Math.sin(this.animation))));
    final ItemStack item = Window.get(this).getInventory().getStackInSlot(LumbermillMachine.SLOT_LOG);
    if (item.isEmpty()) {
        return;
    }
    GlStateManager.disableLighting();
    Block block = null;
    if (item.getItem() instanceof ItemBlock) {
        block = ((ItemBlock) item.getItem()).getBlock();
    }
    if (block == null) {
        return;
    }
    // TODO RENDERING
    // final IIcon icon = block.getIcon(2, item.getItemDamage());
    TextureAtlasSprite icon = getWoodSprite(item);
    for (int i = 0; i < 4; ++i) {
        // CraftGUI.Render.iconBlock(new IPoint(1 + i * 16, 1), icon);
        RenderUtil.drawSprite(new Point(1 + i * 16, 1), icon);
    }
    final ItemStack result = LumbermillRecipeManager.getPlankProduct(item, Minecraft.getMinecraft().world);
    if (result.isEmpty()) {
        return;
    }
    Block block2 = null;
    if (result.getItem() instanceof ItemBlock) {
        block2 = ((ItemBlock) result.getItem()).getBlock();
    }
    if (block2 == null) {
        return;
    }
    // final IIcon icon2 = block2.getIcon(2, result.getItemDamage());
    TextureAtlasSprite sprite = getWoodSprite(result);
    final IPoint pos = this.getAbsolutePosition();
    CraftGUI.RENDER.limitArea(new Area(pos.add(Point.ZERO), new Point(Math.round(this.progress * 64) + 2, 18)), guiWidth, guiHeight);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    for (int j = 0; j < 4; ++j) {
        // TODO RENDERING
        RenderUtil.drawSprite(new Point(1 + j * 16, 1), sprite);
    }
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    CraftGUI.RENDER.texture(ControlLumbermillProgress.SAW, new Point(sawX, -8 + Math.round(6 * (float) Math.sin(this.animation))));
    CraftGUI.RENDER.texture(ControlLumbermillProgress.SAW_2, new Point(sawX + 2, -8 + Math.round(6 * (float) Math.sin(this.animation))));
}
Also used : Area(binnie.core.gui.geometry.Area) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) IPoint(binnie.core.api.gui.IPoint) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with IPoint

use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.

the class PagePlanksOverview method onValueChanged.

@Override
public void onValueChanged(final ItemStack species) {
    this.deleteAllChildren();
    final WindowAbstractDatabase database = Window.get(this);
    IPoint size = getSize();
    new ControlText(this, new Area(0, 0, size.xPos(), 24), species.getDisplayName(), TextJustification.MIDDLE_CENTER);
    new ControlText(this, new Area(12, 24, size.xPos() - 24, 24), I18N.localise(DatabaseConstants.EXTRATREES_KEY + ".planks.use"), TextJustification.MIDDLE_LEFT);
    final IPlankType type = WoodManager.getPlankType(species);
    int x = 12;
    if (type != null) {
        final ItemStack fence = WoodManager.getFence(type, new FenceType(0), 1);
        final ItemStack gate = WoodManager.getGate(type);
        final ItemStack door = WoodManager.getDoor(type);
        if (!fence.isEmpty()) {
            new ControlItemDisplay(this, x, 48).setItemStack(fence);
            x += 22;
        }
        if (!gate.isEmpty()) {
            new ControlItemDisplay(this, x, 48).setItemStack(gate);
            x += 22;
        }
        if (!door.isEmpty()) {
            new ControlItemDisplay(this, x, 48).setItemStack(door);
            x += 22;
        }
    }
    final ControlText controlDescription = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), "", TextJustification.MIDDLE_CENTER);
    final ControlText controlSignature = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), "", TextJustification.BOTTOM_RIGHT);
    String desc = "";
    if (type != null) {
        desc = type.getDescription();
    }
    StringBuilder descBody = new StringBuilder("§o");
    String descSig = "";
    if (desc == null || desc.length() == 0) {
        descBody.append(I18N.localise(DatabaseConstants.KEY + ".nodescription"));
    } else {
        final String[] descStrings = desc.split("\\|");
        descBody.append(descStrings[0]);
        for (int i = 1; i < descStrings.length - 1; ++i) {
            descBody.append(' ').append(descStrings[i]);
        }
        if (descStrings.length > 1) {
            descSig += descStrings[descStrings.length - 1];
        }
    }
    controlDescription.setValue(descBody + "§r");
    controlSignature.setValue(descSig + "§r");
    final int descHeight = CraftGUI.RENDER.textHeight(controlDescription.getValue(), controlDescription.getSize().xPos());
    controlSignature.setPosition(new Point(controlSignature.getPosition().xPos(), controlDescription.getPosition().yPos() + descHeight + 10));
}
Also used : ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) IPlankType(binnie.extratrees.wood.planks.IPlankType) ControlText(binnie.core.gui.controls.ControlText) IPoint(binnie.core.api.gui.IPoint) FenceType(binnie.extratrees.blocks.decor.FenceType) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) Area(binnie.core.gui.geometry.Area) WindowAbstractDatabase(binnie.core.gui.database.WindowAbstractDatabase) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IPoint (binnie.core.api.gui.IPoint)17 Point (binnie.core.gui.geometry.Point)10 IArea (binnie.core.api.gui.IArea)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 Area (binnie.core.gui.geometry.Area)4 EventWidget (binnie.core.gui.events.EventWidget)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 IWidget (binnie.core.api.gui.IWidget)2 ItemStack (net.minecraft.item.ItemStack)2 Fluid (net.minecraftforge.fluids.Fluid)2 IFieldKitPlugin (binnie.core.api.genetics.IFieldKitPlugin)1 ControlText (binnie.core.gui.controls.ControlText)1 WindowAbstractDatabase (binnie.core.gui.database.WindowAbstractDatabase)1 GuiCraftGUI (binnie.core.gui.minecraft.GuiCraftGUI)1 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)1 FenceType (binnie.extratrees.blocks.decor.FenceType)1 IPlankType (binnie.extratrees.wood.planks.IPlankType)1 IChromosomeType (forestry.api.genetics.IChromosomeType)1 Map (java.util.Map)1 Block (net.minecraft.block.Block)1