Search in sources :

Example 21 with Point

use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.

the class ControlGeneScroll method refresh.

public void refresh() {
    if (system == null) {
        return;
    }
    this.deleteAllChildren();
    final GeneTracker tracker = GeneTracker.getTracker(Window.get(this).getWorld(), Window.get(this).getUsername());
    final Map<IChromosomeType, List<IAllele>> genes = Binnie.GENETICS.getChromosomeMap(this.system.getSpeciesRoot());
    int x = 0;
    int y = 0;
    final boolean master = ((WindowGeneBank) Window.get(this)).isMaster();
    for (final Map.Entry<IChromosomeType, List<IAllele>> entry : genes.entrySet()) {
        final List<IAllele> discovered = new ArrayList<>();
        for (final IAllele allele : entry.getValue()) {
            final Gene gene = new Gene(allele, entry.getKey(), this.system.getSpeciesRoot());
            if ((master || tracker.isSequenced(new Gene(allele, entry.getKey(), this.system.getSpeciesRoot()))) && gene.getName().toLowerCase().contains(this.filter)) {
                discovered.add(allele);
            }
        }
        if (discovered.size() == 0) {
            continue;
        }
        x = 0;
        new ControlText(this, new Point(x, y), this.system.getChromosomeName(entry.getKey()));
        y += 12;
        for (final IAllele allele : discovered) {
            if (x + 18 > this.getSize().xPos()) {
                y += 20;
                x = 0;
            }
            new ControlGene(this, x, y, new Gene(allele, entry.getKey(), this.system.getSpeciesRoot()));
            x += 18;
        }
        y += 24;
    }
    this.setSize(new Point(this.getSize().xPos(), y));
}
Also used : ControlText(binnie.core.gui.controls.ControlText) ArrayList(java.util.ArrayList) Point(binnie.core.gui.geometry.Point) Point(binnie.core.gui.geometry.Point) IAllele(forestry.api.genetics.IAllele) Gene(binnie.core.genetics.Gene) ArrayList(java.util.ArrayList) List(java.util.List) IChromosomeType(forestry.api.genetics.IChromosomeType) GeneTracker(binnie.genetics.genetics.GeneTracker) Map(java.util.Map)

Example 22 with Point

use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.

the class ControlEnergyBar method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    CraftGUI.RENDER.texture(CraftGUITexture.ENERGY_BAR_BACK, this.getArea());
    final float percentage = this.getPercentage() / 100.0f;
    int colourFromPercentage = this.getColourFromPercentage(percentage);
    RenderUtil.setColour(colourFromPercentage);
    final IArea area = this.getArea();
    switch(this.direction) {
        case TOP:
        case BOTTOM:
            {
                IPoint fullSize = area.size();
                final int height = Math.round(fullSize.yPos() * percentage);
                area.setSize(new Point(fullSize.xPos(), height));
                area.setYPos(fullSize.yPos() - height);
                break;
            }
        case LEFT:
        case RIGHT:
            {
                final int width = Math.round(area.size().xPos() * percentage);
                area.setSize(new Point(width, area.size().yPos()));
                break;
            }
    }
    if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) {
        final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.HELP);
        RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
    } else if (ControlEnergyBar.isError) {
        final int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.ERROR);
        RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
    }
    CraftGUI.RENDER.texture(CraftGUITexture.ENERGY_BAR_GLOW, area);
    GlStateManager.color(1, 1, 1, 1);
    CraftGUI.RENDER.texture(CraftGUITexture.ENERGY_BAR_GLASS, this.getArea());
}
Also used : IArea(binnie.core.api.gui.IArea) IPoint(binnie.core.api.gui.IPoint) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 23 with Point

use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.

the class ControlSlot method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    CraftGUI.RENDER.texture(CraftGUITexture.SLOT, Point.ZERO);
    final InventorySlot islot = this.getInventorySlot();
    if (islot != null) {
        SlotValidator validator = islot.getValidator();
        if (validator != null) {
            final TextureAtlasSprite icon = validator.getIcon(!islot.getInputSides().isEmpty());
            if (icon != null && icon != Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite()) {
                GlStateManager.enableBlend();
                RenderUtil.drawSprite(new Point(1, 1), icon);
                GlStateManager.disableBlend();
            }
        }
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) InventorySlot(binnie.core.machines.inventory.InventorySlot) Point(binnie.core.gui.geometry.Point) SlotValidator(binnie.core.machines.inventory.SlotValidator) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 24 with Point

use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.

the class ControlSlotBase method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    CraftGUI.RENDER.texture(CraftGUITexture.SLOT, this.getArea());
    if (this.getTopParent().getMousedOverWidget() == this) {
        Area area = new Area(new Point(1, 1), this.getArea().size().sub(new Point(2, 2)));
        RenderUtil.drawGradientRect(area, -2130706433, -2130706433);
    }
}
Also used : Area(binnie.core.gui.geometry.Area) Point(binnie.core.gui.geometry.Point) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 25 with Point

use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.

the class WindowFieldKit method initialiseClient.

@Override
@SideOnly(Side.CLIENT)
public void initialiseClient() {
    this.setTitle(I18N.localise("binniecore.gui.fieldkit.title"));
    CraftGUI.RENDER.setStyleSheet(StyleSheetManager.getSheet(StyleSheetManager.PUNNETT_SHEET));
    WindowInventory inventory = this.getWindowInventory();
    inventory.createSlot(INDIVIDUAL_SLOT);
    inventory.createSlot(PAPER_SLOT);
    this.setupValidators();
    new ControlPlayerInventory(this);
    final Point handGlass = new Point(16, 32);
    this.GlassControl = new ControlImage(this, handGlass.xPos(), handGlass.yPos(), new StandardTexture(0, 160, 96, 96, BinnieCoreTexture.GUI_PUNNETT));
    new ControlSlot.Builder(this, handGlass.xPos() + 54, handGlass.yPos() + 26).assign(InventoryType.WINDOW, 0);
    new ControlSlot.Builder(this, 208, 8).assign(InventoryType.WINDOW, 1);
    (this.text = new ControlText(this, new Point(232, 13), I18N.localise("binniecore.gui.fieldkit.paper"))).setColor(2236962);
    (this.text = new ControlText(this, new Area(0, 120, this.getWidth(), 24), "", TextJustification.MIDDLE_CENTER)).setColor(2236962);
    this.chromo = new ControlChromosome(this, 150, 24);
    this.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, this.chromo, event -> {
        final IChromosomeType type = (IChromosomeType) event.getValue();
        if (type != null && WindowFieldKit.this.info.containsKey(type)) {
            final String t = WindowFieldKit.this.info.get(type);
            WindowFieldKit.this.text.setValue(t);
        } else {
            WindowFieldKit.this.text.setValue("");
        }
    });
}
Also used : StandardTexture(binnie.core.gui.resource.textures.StandardTexture) Area(binnie.core.gui.geometry.Area) WindowInventory(binnie.core.gui.minecraft.WindowInventory) ControlPlayerInventory(binnie.core.gui.minecraft.control.ControlPlayerInventory) ControlText(binnie.core.gui.controls.ControlText) ControlSlot(binnie.core.gui.minecraft.control.ControlSlot) Point(binnie.core.gui.geometry.Point) ControlImage(binnie.core.gui.minecraft.control.ControlImage) IChromosomeType(forestry.api.genetics.IChromosomeType) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Point (binnie.core.gui.geometry.Point)46 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)25 IPoint (binnie.core.api.gui.IPoint)15 Area (binnie.core.gui.geometry.Area)13 ControlText (binnie.core.gui.controls.ControlText)10 ItemStack (net.minecraft.item.ItemStack)10 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)6 IArea (binnie.core.api.gui.IArea)5 Map (java.util.Map)5 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 ControlTextEdit (binnie.core.gui.controls.ControlTextEdit)4 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)4 ControlTabBar (binnie.core.gui.controls.tab.ControlTabBar)4 EventWidget (binnie.core.gui.events.EventWidget)4 Panel (binnie.core.gui.window.Panel)4 ArrayList (java.util.ArrayList)4 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)3 IWidget (binnie.core.api.gui.IWidget)3 Control (binnie.core.gui.controls.core.Control)3 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)3