Search in sources :

Example 1 with IClassification

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

the class AlleleRegistry method initialize.

public void initialize() {
    createAndRegisterClassification(EnumClassLevel.DOMAIN, "archaea", "Archaea");
    createAndRegisterClassification(EnumClassLevel.DOMAIN, "bacteria", "Bacteria");
    IClassification eukarya = createAndRegisterClassification(EnumClassLevel.DOMAIN, "eukarya", "Eukarya");
    eukarya.addMemberGroup(createAndRegisterClassification(EnumClassLevel.KINGDOM, "animalia", "Animalia"));
    eukarya.addMemberGroup(createAndRegisterClassification(EnumClassLevel.KINGDOM, "plantae", "Plantae"));
    eukarya.addMemberGroup(createAndRegisterClassification(EnumClassLevel.KINGDOM, "fungi", "Fungi"));
    eukarya.addMemberGroup(createAndRegisterClassification(EnumClassLevel.KINGDOM, "protista", "Protista"));
    getClassification("kingdom.animalia").addMemberGroup(createAndRegisterClassification(EnumClassLevel.PHYLUM, "arthropoda", "Arthropoda"));
    // Animalia
    getClassification("phylum.arthropoda").addMemberGroup(createAndRegisterClassification(EnumClassLevel.CLASS, "insecta", "Insecta"));
}
Also used : IClassification(forestry.api.genetics.IClassification)

Example 2 with IClassification

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

the class ModuleApiculture method createAlleles.

private static void createAlleles() {
    IClassification hymnoptera = AlleleManager.alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "hymnoptera", "Hymnoptera");
    AlleleManager.alleleRegistry.getClassification("class.insecta").addMemberGroup(hymnoptera);
    IClassification apidae = AlleleManager.alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "apidae", "Apidae");
    hymnoptera.addMemberGroup(apidae);
    for (BeeBranchDefinition beeBranch : BeeBranchDefinition.values()) {
        apidae.addMemberGroup(beeBranch.getBranch());
    }
    AlleleEffects.registerAlleles();
}
Also used : BeeBranchDefinition(forestry.apiculture.genetics.BeeBranchDefinition) IClassification(forestry.api.genetics.IClassification)

Example 3 with IClassification

use of forestry.api.genetics.IClassification in project Binnie by ForestryMC.

the class PageSpeciesClassification method onValueChanged.

@Override
public void onValueChanged(final IAlleleSpecies species) {
    if (species != null) {
        for (ControlText control : this.levels.values()) {
            control.setValue("- - -");
        }
        this.genus.setValue(species.getBinomial());
        for (IClassification classification = species.getBranch(); classification != null; classification = classification.getParent()) {
            IClassification.EnumClassLevel level = classification.getLevel();
            String text = classification.getScientific();
            this.levels.get(level).setValue(text);
        }
    }
}
Also used : ControlText(binnie.core.gui.controls.ControlText) IClassification(forestry.api.genetics.IClassification)

Example 4 with IClassification

use of forestry.api.genetics.IClassification in project Binnie by ForestryMC.

the class WindowAbstractDatabase method initialiseClient.

@Override
@SideOnly(Side.CLIENT)
public void initialiseClient() {
    this.setSize(new Point(176 + this.selectionBoxWidth + 22 + 8, 208));
    this.addEventHandler(EventValueChanged.class, event -> {
        Object value = event.getValue();
        IWidget eventOriginParent = event.getOrigin().getParent();
        if (eventOriginParent instanceof ControlPage && !(value instanceof DatabaseTab)) {
            ControlPage parent = (ControlPage) eventOriginParent;
            if (parent.getValue() instanceof IDatabaseMode) {
                for (IWidget child : parent.getChildren()) {
                    if (child instanceof ControlPages) {
                        if (value == null) {
                            child.hide();
                        } else {
                            child.show();
                            for (IWidget widget : child.getChildren()) {
                                if (widget instanceof PageAbstract) {
                                    PageAbstract pageAbstract = (PageAbstract) widget;
                                    pageAbstract.onValueChanged(value);
                                }
                            }
                        }
                    }
                }
            }
        }
    });
    this.addEventHandler(EventTextEdit.class, EventHandlerOrigin.DIRECT_CHILD, this, event -> {
        for (final ModeWidgets widgets : WindowAbstractDatabase.this.modes.values()) {
            widgets.getListBox().setValidator(object -> {
                if (Objects.equals(event.getValue(), "")) {
                    return true;
                }
                ControlTextOption controlTextOption = (ControlTextOption) object;
                return controlTextOption.getText().toLowerCase().contains(event.getValue().toLowerCase());
            });
        }
    });
    new ControlHelp(this, 4, 4);
    (this.panelInformation = new Panel(this, 24, 24, 144, 176, MinecraftGUI.PanelType.BLACK)).setColor(860416);
    (this.panelSearch = new Panel(this, 176, 24, this.selectionBoxWidth, 160, MinecraftGUI.PanelType.BLACK)).setColor(860416);
    this.modePages = new ControlPages<>(this, 0, 0, this.getSize().xPos(), this.getSize().yPos());
    new ControlTextEdit(this, 176, 184, this.selectionBoxWidth, 16);
    this.createMode(Mode.SPECIES, new ModeWidgets(Mode.SPECIES, this, (area, modePage) -> {
        final GameProfile playerName = this.getUsername();
        final Collection<IAlleleSpecies> speciesList = this.master ? this.system.getAllSpecies() : this.system.getDiscoveredSpecies(this.getWorld(), playerName);
        ControlSpeciesBox controlSpeciesBox = new ControlSpeciesBox(modePage, area.xPos(), area.yPos(), area.width(), area.height());
        controlSpeciesBox.setOptions(speciesList);
        return controlSpeciesBox;
    }));
    this.createMode(Mode.BRANCHES, new ModeWidgets(Mode.BRANCHES, this, (area, modePage) -> {
        final EntityPlayer player = this.getPlayer();
        final GameProfile playerName = player.getGameProfile();
        final Collection<IClassification> speciesList = this.master ? this.system.getAllBranches() : this.system.getDiscoveredBranches(this.getWorld(), playerName);
        ControlBranchBox controlBranchBox = new ControlBranchBox(modePage, area.xPos(), area.yPos(), area.width(), area.height());
        controlBranchBox.setOptions(speciesList);
        return controlBranchBox;
    }));
    this.createMode(Mode.BREEDER, new ModeWidgets(Mode.BREEDER, this, (area, modePage) -> {
        return new ControlListBox(modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12);
    }));
    this.addTabs();
    final ControlTabBar<IDatabaseMode> tab = new ControlTabBar<>(this, 176 + this.selectionBoxWidth, 24, 22, 176, Alignment.RIGHT, this.modePages.getValues(), DatabaseControlTab::new);
    CraftGUIUtil.linkWidgets(tab, this.modePages);
    this.changeMode(Mode.SPECIES);
    for (final IDatabaseMode mode : this.modes.keySet()) {
        ModeWidgets modeWidgets = this.modes.get(mode);
        modeWidgets.setInfoTabs(new ControlTabBar<>(modeWidgets.getModePage(), 8, 24, 16, 176, Alignment.LEFT, modeWidgets.getInfoPages().getValues()));
        CraftGUIUtil.linkWidgets(modeWidgets.getInfoTabs(), modeWidgets.getInfoPages());
    }
}
Also used : IBreedingTracker(forestry.api.genetics.IBreedingTracker) ControlTextOption(binnie.core.gui.controls.listbox.ControlTextOption) GameProfile(com.mojang.authlib.GameProfile) HashMap(java.util.HashMap) ControlListBox(binnie.core.gui.controls.listbox.ControlListBox) ControlTabBar(binnie.core.gui.controls.tab.ControlTabBar) Panel(binnie.core.gui.window.Panel) Side(net.minecraftforge.fml.relauncher.Side) Map(java.util.Map) IWidget(binnie.core.api.gui.IWidget) ControlTextEdit(binnie.core.gui.controls.ControlTextEdit) CraftGUIUtil(binnie.core.gui.geometry.CraftGUIUtil) MinecraftGUI(binnie.core.gui.minecraft.MinecraftGUI) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nullable(javax.annotation.Nullable) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) ControlPages(binnie.core.gui.controls.page.ControlPages) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) Collection(java.util.Collection) EventTextEdit(binnie.core.gui.events.EventTextEdit) ControlTab(binnie.core.gui.controls.tab.ControlTab) EventValueChanged(binnie.core.gui.events.EventValueChanged) ControlHelp(binnie.core.gui.minecraft.control.ControlHelp) I18N(binnie.core.util.I18N) Objects(java.util.Objects) Alignment(binnie.core.api.gui.Alignment) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EventHandlerOrigin(binnie.core.api.gui.events.EventHandlerOrigin) ControlPage(binnie.core.gui.controls.page.ControlPage) IClassification(forestry.api.genetics.IClassification) Point(binnie.core.gui.geometry.Point) Window(binnie.core.gui.minecraft.Window) ControlPage(binnie.core.gui.controls.page.ControlPage) ControlTextEdit(binnie.core.gui.controls.ControlTextEdit) ControlListBox(binnie.core.gui.controls.listbox.ControlListBox) ControlTextOption(binnie.core.gui.controls.listbox.ControlTextOption) Point(binnie.core.gui.geometry.Point) ControlTabBar(binnie.core.gui.controls.tab.ControlTabBar) Panel(binnie.core.gui.window.Panel) ControlPages(binnie.core.gui.controls.page.ControlPages) GameProfile(com.mojang.authlib.GameProfile) ControlHelp(binnie.core.gui.minecraft.control.ControlHelp) Collection(java.util.Collection) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IWidget(binnie.core.api.gui.IWidget) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with IClassification

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

the class AlleleRegistry method registerAllele.

@Override
public void registerAllele(IAllele allele, IChromosomeType... chromosomeTypes) {
    addValidAlleleTypes(allele, chromosomeTypes);
    alleleMap.put(allele.getUID(), allele);
    if (allele instanceof IAlleleSpecies) {
        IClassification branch = ((IAlleleSpecies) allele).getBranch();
        branch.addMemberSpecies((IAlleleSpecies) allele);
    }
    for (IAlleleHandler handler : this.alleleHandlers) {
        handler.onRegisterAllele(allele);
    }
}
Also used : IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) IAlleleHandler(forestry.api.genetics.IAlleleHandler) IClassification(forestry.api.genetics.IClassification)

Aggregations

IClassification (forestry.api.genetics.IClassification)8 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)1 Alignment (binnie.core.api.gui.Alignment)1 IWidget (binnie.core.api.gui.IWidget)1 EventHandlerOrigin (binnie.core.api.gui.events.EventHandlerOrigin)1 ControlText (binnie.core.gui.controls.ControlText)1 ControlTextEdit (binnie.core.gui.controls.ControlTextEdit)1 ControlListBox (binnie.core.gui.controls.listbox.ControlListBox)1 ControlTextOption (binnie.core.gui.controls.listbox.ControlTextOption)1 ControlPage (binnie.core.gui.controls.page.ControlPage)1 ControlPages (binnie.core.gui.controls.page.ControlPages)1 ControlTab (binnie.core.gui.controls.tab.ControlTab)1 ControlTabBar (binnie.core.gui.controls.tab.ControlTabBar)1 EventTextEdit (binnie.core.gui.events.EventTextEdit)1 EventValueChanged (binnie.core.gui.events.EventValueChanged)1 CraftGUIUtil (binnie.core.gui.geometry.CraftGUIUtil)1 Point (binnie.core.gui.geometry.Point)1 MinecraftGUI (binnie.core.gui.minecraft.MinecraftGUI)1 Window (binnie.core.gui.minecraft.Window)1