Search in sources :

Example 1 with ControlItemDisplay

use of binnie.core.gui.minecraft.control.ControlItemDisplay 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 ControlItemDisplay

use of binnie.core.gui.minecraft.control.ControlItemDisplay in project Binnie by ForestryMC.

the class WindowGenesis method refreshPickup.

private void refreshPickup() {
    this.panelPickup.deleteAllChildren();
    int i = 0;
    IBreedingSystem system = Binnie.GENETICS.getSystem(this.root);
    for (ISpeciesType type : system.getActiveTypes()) {
        IIndividual ind = this.root.templateAsIndividual(this.template);
        ind.analyze();
        ItemStack stack = this.root.getMemberStack(ind, type);
        ControlItemDisplay display = new ControlItemDisplay(this.panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18);
        display.setItemStack(stack);
        display.setTooltip();
        display.addEventHandler(EventMouse.Down.class, EventHandlerOrigin.SELF, display, event -> {
            NBTTagCompound nbt = new NBTTagCompound();
            stack.writeToNBT(nbt);
            Window.get(event.getOrigin()).sendClientAction(ACTION_GENESIS, nbt);
        });
        ++i;
    }
}
Also used : ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType) EventMouse(binnie.core.gui.events.EventMouse) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ControlItemDisplay

use of binnie.core.gui.minecraft.control.ControlItemDisplay in project Binnie by ForestryMC.

the class AnalystManager method drawRefined.

@Override
@SideOnly(Side.CLIENT)
public int drawRefined(IWidget parent, String string, int y, Collection<ItemStack> products) {
    new ControlTextCentered(parent, y, string).setColor(parent.getColor());
    y += 10;
    int maxBiomePerLine = (parent.getWidth() + 2 - 16) / 18;
    int biomeListX = (parent.getWidth() - (Math.min(maxBiomePerLine, products.size()) * 18 - 2)) / 2;
    int dx = 0;
    int dy = 0;
    for (ItemStack soilStack : products) {
        if (dx >= 18 * maxBiomePerLine) {
            dx = 0;
            dy += 18;
        }
        FluidStack fluid = FluidUtil.getFluidContained(soilStack);
        soilStack.setCount(1);
        ControlItemDisplay display = new ControlItemDisplay(parent, biomeListX + dx, y + dy, soilStack, fluid == null);
        if (fluid != null) {
            display.addTooltip(fluid.getLocalizedName());
        }
        dx += 18;
    }
    if (dx != 0) {
        dy += 18;
    }
    y += dy;
    return y;
}
Also used : ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) FluidStack(net.minecraftforge.fluids.FluidStack) ControlTextCentered(binnie.core.gui.controls.ControlTextCentered) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with ControlItemDisplay

use of binnie.core.gui.minecraft.control.ControlItemDisplay 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)

Example 5 with ControlItemDisplay

use of binnie.core.gui.minecraft.control.ControlItemDisplay in project Binnie by ForestryMC.

the class AnalystPageBeeProducts method createProductEntry.

private void createProductEntry(ItemStack key, Float value, int y, float speed) {
    ControlItemDisplay item = new BeeProductItem(this, y, key);
    item.setTooltip();
    ControlText textWidget = new ControlTextCentered(this, y + 4, "");
    textWidget.setColor(getColor());
    CraftGUIUtil.moveWidget(textWidget, new Point(12, 0));
    item.setItemStack(key);
    int time = (int) (ModuleApiculture.ticksPerBeeWorkCycle * 100.0 / (speed * value));
    textWidget.setValue(I18N.localise(AnalystConstants.PRODUCTS_KEY + ".every") + ' ' + TimeUtil.getTimeString(time));
}
Also used : ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) ControlText(binnie.core.gui.controls.ControlText) ControlTextCentered(binnie.core.gui.controls.ControlTextCentered) Point(binnie.core.gui.geometry.Point) Point(binnie.core.gui.geometry.Point)

Aggregations

ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)8 Point (binnie.core.gui.geometry.Point)6 ItemStack (net.minecraft.item.ItemStack)6 ControlText (binnie.core.gui.controls.ControlText)5 Control (binnie.core.gui.controls.core.Control)3 Area (binnie.core.gui.geometry.Area)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)2 ControlTextCentered (binnie.core.gui.controls.ControlTextCentered)2 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)2 EventMouse (binnie.core.gui.events.EventMouse)2 IAllele (forestry.api.genetics.IAllele)2 IIndividual (forestry.api.genetics.IIndividual)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 IAlleleFlowerSpecies (binnie.botany.api.genetics.IAlleleFlowerSpecies)1 IFlower (binnie.botany.api.genetics.IFlower)1 IFlowerGenome (binnie.botany.api.genetics.IFlowerGenome)1 Alignment (binnie.core.api.gui.Alignment)1 IArea (binnie.core.api.gui.IArea)1 IPoint (binnie.core.api.gui.IPoint)1