Search in sources :

Example 6 with IFruitFamily

use of forestry.api.genetics.IFruitFamily in project ForestryMC by ForestryMC.

the class TreeAlyzerPlugin method drawAnalyticsPage2.

@SideOnly(Side.CLIENT)
@Override
public void drawAnalyticsPage2(GuiScreen gui, ItemStack itemStack) {
    if (gui instanceof GuiAlyzer) {
        GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
        ITree tree = TreeManager.treeRoot.getMember(itemStack);
        if (tree == null) {
            return;
        }
        TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
        textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
        int speciesDominance0 = guiAlyzer.getColorCoding(tree.getGenome().getPrimary().isDominant());
        int speciesDominance1 = guiAlyzer.getColorCoding(tree.getGenome().getSecondary().isDominant());
        textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
        textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
        textLayout.newLine();
        textLayout.newLine();
        String yes = Translator.translateToLocal("for.yes");
        String no = Translator.translateToLocal("for.no");
        String fireproofActive = StringUtil.readableBoolean(tree.getGenome().getFireproof(), yes, no);
        String fireproofInactive = StringUtil.readableBoolean(((AlleleBoolean) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FIREPROOF)).getValue(), yes, no);
        guiAlyzer.drawRow(Translator.translateToLocal("for.gui.fireproof"), fireproofActive, fireproofInactive, tree, EnumTreeChromosome.FIREPROOF);
        textLayout.newLine();
        textLayout.drawLine(Translator.translateToLocal("for.gui.native"), GuiAlyzer.COLUMN_0);
        textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_1, speciesDominance0);
        textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getSecondary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_2, speciesDominance1);
        textLayout.newLine();
        // FRUITS
        textLayout.drawLine(Translator.translateToLocal("for.gui.supports"), GuiAlyzer.COLUMN_0);
        List<IFruitFamily> families0 = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit());
        List<IFruitFamily> families1 = new ArrayList<>(tree.getGenome().getSecondary().getSuitableFruit());
        int max = Math.max(families0.size(), families1.size());
        for (int i = 0; i < max; i++) {
            if (i > 0) {
                textLayout.newLineCompressed();
            }
            if (families0.size() > i) {
                textLayout.drawLine(families0.get(i).getName(), GuiAlyzer.COLUMN_1, speciesDominance0);
            }
            if (families1.size() > i) {
                textLayout.drawLine(families1.get(i).getName(), GuiAlyzer.COLUMN_2, speciesDominance1);
            }
        }
        textLayout.newLine();
        int fruitDominance0 = guiAlyzer.getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant());
        int fruitDominance1 = guiAlyzer.getColorCoding(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS).isDominant());
        textLayout.drawLine(Translator.translateToLocal("for.gui.fruits"), GuiAlyzer.COLUMN_0);
        String strike = "";
        IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS);
        if (!tree.canBearFruit() && fruit0 != AlleleFruits.fruitNone) {
            strike = TextFormatting.STRIKETHROUGH.toString();
        }
        textLayout.drawLine(strike + tree.getGenome().getFruitProvider().getDescription(), GuiAlyzer.COLUMN_1, fruitDominance0);
        strike = "";
        IAlleleFruit fruit1 = (IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS);
        if (!tree.getGenome().getSecondary().getSuitableFruit().contains(fruit1.getProvider().getFamily()) && fruit1 != AlleleFruits.fruitNone) {
            strike = TextFormatting.STRIKETHROUGH.toString();
        }
        textLayout.drawLine(strike + fruit1.getProvider().getDescription(), GuiAlyzer.COLUMN_2, fruitDominance1);
        textLayout.newLine();
        textLayout.drawLine(Translator.translateToLocal("for.gui.family"), GuiAlyzer.COLUMN_0);
        IFruitFamily primary = tree.getGenome().getFruitProvider().getFamily();
        IFruitFamily secondary = ((IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS)).getProvider().getFamily();
        if (primary != null && !primary.getUID().equals(EnumFruitFamily.NONE.getUID())) {
            textLayout.drawLine(primary.getName(), GuiAlyzer.COLUMN_1, fruitDominance0);
        }
        if (secondary != null && !secondary.getUID().equals(EnumFruitFamily.NONE.getUID())) {
            textLayout.drawLine(secondary.getName(), GuiAlyzer.COLUMN_2, fruitDominance1);
        }
        textLayout.endPage();
    }
}
Also used : TextLayoutHelper(forestry.core.gui.TextLayoutHelper) IAllele(forestry.api.genetics.IAllele) IFruitFamily(forestry.api.genetics.IFruitFamily) ArrayList(java.util.ArrayList) ITree(forestry.api.arboriculture.ITree) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit) GuiAlyzer(forestry.core.gui.GuiAlyzer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IFruitFamily (forestry.api.genetics.IFruitFamily)6 IFruitProvider (forestry.api.arboriculture.IFruitProvider)3 ArrayList (java.util.ArrayList)3 IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)2 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)2 ItemStack (net.minecraft.item.ItemStack)2 ITree (forestry.api.arboriculture.ITree)1 ITreeGenome (forestry.api.arboriculture.ITreeGenome)1 IAllele (forestry.api.genetics.IAllele)1 IAlleleInteger (forestry.api.genetics.IAlleleInteger)1 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)1 GuiAlyzer (forestry.core.gui.GuiAlyzer)1 TextLayoutHelper (forestry.core.gui.TextLayoutHelper)1 HashSet (java.util.HashSet)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1