Search in sources :

Example 1 with GeneTracker

use of binnie.genetics.genetics.GeneTracker in project Binnie by ForestryMC.

the class WindowGeneBank method initialiseClient.

@Override
@SideOnly(Side.CLIENT)
public void initialiseClient() {
    super.initialiseClient();
    this.addEventHandler(EventValueChanged.class, event -> {
        if (event.getValue() instanceof BreedingSystem) {
            WindowGeneBank.this.genes.setValue((IBreedingSystem) event.getValue());
        }
    });
    int x = 16;
    final int y = 32;
    new ControlPlayerInventory(this, x, y);
    x += 124;
    int boxX = x;
    final int geneBoxWidth = 120;
    new Panel(this, boxX + 24, 32, geneBoxWidth, 120, MinecraftGUI.PanelType.BLACK);
    new Panel(this, boxX + 24 + geneBoxWidth, 32, 14, 120, MinecraftGUI.PanelType.GRAY);
    final ControlScrollableContent<ControlGeneScroll> scroll = new ControlScrollableContent<>(this, boxX + 24 + 2, 34, geneBoxWidth + 10, 116, 12);
    final ControlTextEdit edit = new ControlTextEdit(this, boxX + 27 + geneBoxWidth - 70, 18, 80, 12);
    this.addEventHandler(EventTextEdit.class, EventHandlerOrigin.SELF, edit, event -> {
        String value = event.getValue();
        if (value == null) {
            value = "";
        }
        WindowGeneBank.this.genes.setFilter(value);
    });
    this.genes = new ControlGeneScroll(scroll, 1, 1, geneBoxWidth, 116);
    scroll.setScrollableContent(this.genes);
    this.genes.setGenes(Binnie.GENETICS.getFirstActiveSystem());
    final ControlTabBar<IBreedingSystem> tabBar = new GeneBankTabBar(this, boxX);
    tabBar.setValue(Binnie.GENETICS.getFirstActiveSystem());
    boxX -= 8;
    final ControlTabBar<String> infoTabs = new ControlTabBar<>(this, boxX + 8, 160, 16, 50, Alignment.LEFT, Arrays.asList("Info", "Stats", "Ranking"));
    final Panel panelProject = new Panel(this, boxX + 24, 160, geneBoxWidth + 20, 50, MinecraftGUI.PanelType.BLACK);
    int totalGenes = 0;
    int seqGenes = 0;
    for (final IBreedingSystem system : Binnie.GENETICS.getActiveSystems()) {
        final GeneTracker tracker = GeneTracker.getTracker(this.getWorld(), this.getUsername());
        final Map<IChromosomeType, List<IAllele>> genes = Binnie.GENETICS.getChromosomeMap(system.getSpeciesRoot());
        for (final Map.Entry<IChromosomeType, List<IAllele>> entry : genes.entrySet()) {
            totalGenes += entry.getValue().size();
            for (final IAllele allele : entry.getValue()) {
                final Gene gene = new Gene(allele, entry.getKey(), system.getSpeciesRoot());
                if (tracker.isSequenced(gene)) {
                    ++seqGenes;
                }
            }
        }
    }
    new ControlText(panelProject, new Point(4, 4), "§nFull Genome Project");
    new ControlText(panelProject, new Point(4, 18), "§oSequenced §r" + seqGenes + '/' + totalGenes + " §oGenes");
}
Also used : BreedingSystem(binnie.core.genetics.BreedingSystem) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) ControlTextEdit(binnie.core.gui.controls.ControlTextEdit) ControlText(binnie.core.gui.controls.ControlText) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) Point(binnie.core.gui.geometry.Point) Point(binnie.core.gui.geometry.Point) ControlTabBar(binnie.core.gui.controls.tab.ControlTabBar) IAllele(forestry.api.genetics.IAllele) Panel(binnie.core.gui.window.Panel) Gene(binnie.core.genetics.Gene) ControlPlayerInventory(binnie.core.gui.minecraft.control.ControlPlayerInventory) List(java.util.List) IChromosomeType(forestry.api.genetics.IChromosomeType) GeneTracker(binnie.genetics.genetics.GeneTracker) Map(java.util.Map) ControlScrollableContent(binnie.core.gui.controls.scroll.ControlScrollableContent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with GeneTracker

use of binnie.genetics.genetics.GeneTracker 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)

Aggregations

Gene (binnie.core.genetics.Gene)2 ControlText (binnie.core.gui.controls.ControlText)2 Point (binnie.core.gui.geometry.Point)2 GeneTracker (binnie.genetics.genetics.GeneTracker)2 IAllele (forestry.api.genetics.IAllele)2 IChromosomeType (forestry.api.genetics.IChromosomeType)2 List (java.util.List)2 Map (java.util.Map)2 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)1 BreedingSystem (binnie.core.genetics.BreedingSystem)1 ControlTextEdit (binnie.core.gui.controls.ControlTextEdit)1 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)1 ControlTabBar (binnie.core.gui.controls.tab.ControlTabBar)1 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)1 Panel (binnie.core.gui.window.Panel)1 ArrayList (java.util.ArrayList)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1