Search in sources :

Example 1 with Point

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

the class PageSpeciesFlowerGenome method onValueChanged.

@Override
public void onValueChanged(IAlleleSpecies species) {
    deleteAllChildren();
    IAllele[] template = BotanyAPI.flowerRoot.getTemplate(species.getUID());
    if (template == null) {
        return;
    }
    IFlower flower = BotanyAPI.flowerRoot.templateAsIndividual(template);
    IFlowerGenome genome = flower.getGenome();
    IAlleleFlowerSpecies flowerSpecies = genome.getPrimary();
    int w = 144;
    int h = 176;
    new ControlText(this, new Area(0, 4, w, 16), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".title"), TextJustification.MIDDLE_CENTER);
    ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12);
    Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16);
    int tw = w - 8 - 12;
    int w2 = 55;
    int w3 = tw - 50;
    int y = 0;
    int th = 14;
    int th2 = 18;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".temp"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), flowerSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".moist"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), EnumHelper.getLocalisedName(flowerSpecies.getMoisture(), false), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".ph"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), EnumHelper.getLocalisedName(flowerSpecies.getPH(), false), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".fertility"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFT);
    y += th;
    float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f;
    String lifespanValue = String.format("%.2f", lifespan);
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".lifespan"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".lifespan.value", lifespanValue), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".nectar"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getAlleleName(), TextJustification.MIDDLE_LEFT);
    y += th;
    int x = w2;
    int tot = 0;
    for (IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
        if (vid.getGenome().getPrimary() == flowerSpecies) {
            if (tot > 0 && tot % 3 == 0) {
                x -= 54;
                y += 18;
            }
            ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack(vid, EnumFlowerStage.FLOWER);
            ControlItemDisplay display = new ControlItemDisplay(contents, x, y);
            display.setItemStack(stack);
            ++tot;
            x += 18;
        }
    }
    int numOfLines = 1 + (tot - 1) / 3;
    new ControlText(contents, new Area(0, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".varieties"), TextJustification.MIDDLE_RIGHT);
    y += th;
    contents.setSize(new Point(contents.getSize().xPos(), y));
    scrollable.setScrollableContent(contents);
}
Also used : IFlowerGenome(binnie.botany.api.genetics.IFlowerGenome) ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) IFlower(binnie.botany.api.genetics.IFlower) IIndividual(forestry.api.genetics.IIndividual) ControlText(binnie.core.gui.controls.ControlText) Point(binnie.core.gui.geometry.Point) IAlleleFlowerSpecies(binnie.botany.api.genetics.IAlleleFlowerSpecies) Point(binnie.core.gui.geometry.Point) IAllele(forestry.api.genetics.IAllele) Area(binnie.core.gui.geometry.Area) Control(binnie.core.gui.controls.core.Control) ItemStack(net.minecraft.item.ItemStack) ControlScrollableContent(binnie.core.gui.controls.scroll.ControlScrollableContent)

Example 2 with Point

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

the class ControlTabIcon method onUpdateClient.

@Override
@SideOnly(Side.CLIENT)
public void onUpdateClient() {
    super.onUpdateClient();
    this.item.setItemStack(this.getItemStack());
    ControlTabBar parent = (ControlTabBar) this.getParent();
    final int x = parent.getDirection().x();
    boolean selected = this.isCurrentSelection() || this.isMouseOver();
    int xOffset = selected ? 0 : (-4 * x);
    Point offset = new Point(xOffset, 0);
    this.item.setOffset(offset);
}
Also used : Point(binnie.core.gui.geometry.Point) ControlTabBar(binnie.core.gui.controls.tab.ControlTabBar) Point(binnie.core.gui.geometry.Point) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with Point

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

the class RenderUtil method drawFluid.

public static void drawFluid(Point pos, @Nullable FluidStack fluidStack) {
    GlStateManager.enableBlend();
    GlStateManager.enableAlpha();
    Minecraft minecraft = Minecraft.getMinecraft();
    if (fluidStack != null) {
        Fluid fluid = fluidStack.getFluid();
        if (fluid != null) {
            TextureAtlasSprite stillSprite = getStillFluidSprite(minecraft, fluid);
            int fluidColor = fluid.getColor(fluidStack);
            minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            setColour(fluidColor);
            drawTexture(pos.xPos(), pos.yPos(), stillSprite, 0, 0, 100);
        }
    }
    GlStateManager.color(1, 1, 1, 1);
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Fluid(net.minecraftforge.fluids.Fluid) Minecraft(net.minecraft.client.Minecraft) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point)

Example 4 with Point

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

the class Window method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    RenderUtil.setColour(0xffffff);
    if (this.getBackground1() != null) {
        CraftGUI.RENDER.texture(this.getBackground1(), Point.ZERO);
    }
    if (this.getBackground2() != null) {
        CraftGUI.RENDER.texture(this.getBackground2(), new Point(256, 0));
    }
    RenderUtil.setColour(this.getColor());
    CraftGUI.RENDER.texture(CraftGUITexture.WINDOW, this.getArea());
}
Also used : Point(binnie.core.gui.geometry.Point) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with Point

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

the class PageSpeciesOverview method onValueChanged.

@Override
public void onValueChanged(final IAlleleSpecies species) {
    this.controlInd1.setSpecies(species, EnumDiscoveryState.SHOW);
    this.controlInd2.setSpecies(species, EnumDiscoveryState.SHOW);
    final String branchBinomial = species.getBranch().getScientific();
    this.controlName.setValue(TextFormatting.UNDERLINE + species.getAlleleName());
    this.controlScientific.setValue(TextFormatting.ITALIC + branchBinomial + ' ' + species.getBinomial());
    this.controlAuthority.setValue(I18N.localise(DatabaseConstants.KEY + ".discovered") + ": " + TextFormatting.BOLD + species.getAuthority());
    this.controlComplexity.setValue(I18N.localise(DatabaseConstants.KEY + ".overview.complexity") + ": " + species.getComplexity());
    final String desc = species.getDescription();
    StringBuilder descBody = new StringBuilder(TextFormatting.ITALIC.toString());
    String descSig = "";
    if (desc == null || Objects.equals(desc, "") || desc.contains("for.description") || desc.contains(".desc")) {
        descBody.append(I18N.localise(DatabaseConstants.KEY + ".no.description"));
    } 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];
        }
    }
    this.controlDescription.setValue(descBody.toString() + TextFormatting.RESET);
    this.controlSignature.setValue(descSig);
    final int descHeight = CraftGUI.RENDER.textHeight(this.controlDescription.getValue(), this.controlDescription.getSize().xPos());
    this.controlSignature.setPosition(new Point(controlSignature.getPosition().xPos(), this.controlDescription.getPosition().yPos() + descHeight + 10));
}
Also used : Point(binnie.core.gui.geometry.Point) Point(binnie.core.gui.geometry.Point)

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