Search in sources :

Example 1 with ControlListBox

use of binnie.core.gui.controls.listbox.ControlListBox 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 2 with ControlListBox

use of binnie.core.gui.controls.listbox.ControlListBox in project Binnie by ForestryMC.

the class WindowArboristDatabase method addTabs.

@Override
@SideOnly(Side.CLIENT)
protected void addTabs() {
    new PageSpeciesOverview(this.getInfoPages(Mode.SPECIES), new DatabaseTab(ExtraTrees.instance, "species.overview"));
    new PageSpeciesTreeGenome(this.getInfoPages(Mode.SPECIES), new DatabaseTab(ExtraTrees.instance, "species.genome"));
    new PageSpeciesClassification(this.getInfoPages(Mode.SPECIES), new DatabaseTab(ExtraTrees.instance, "species.classification"));
    new PageSpeciesResultant(this.getInfoPages(Mode.SPECIES), new DatabaseTab(ExtraTrees.instance, "species.resultant"));
    new PageSpeciesMutations(this.getInfoPages(Mode.SPECIES), new DatabaseTab(ExtraTrees.instance, "species.further"));
    new PageBranchOverview(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(ExtraTrees.instance, "branches.overview"));
    new PageBranchSpecies(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(ExtraTrees.instance, "branches.species"));
    new PageBreeder(this.getInfoPages(Mode.BREEDER), this.getUsername(), new DatabaseTab(ExtraTrees.instance, "breeder"));
    this.createMode(TreeMode.FRUIT, new ModeWidgets(TreeMode.FRUIT, this, (area, modePage) -> {
        ControlListBox<ItemStack> controlListBox = new ModeControlListBox(modePage, area);
        ITreeBreedingSystem breedingSystem = this.getBreedingSystem();
        controlListBox.setOptions(breedingSystem.getAllFruits());
        return controlListBox;
    }));
    this.createMode(TreeMode.WOOD, new ModeWidgets(TreeMode.WOOD, this, (area, modePage) -> {
        ControlListBox<ItemStack> controlListBox = new ModeControlListBox(modePage, area);
        ITreeBreedingSystem breedingSystem = this.getBreedingSystem();
        controlListBox.setOptions(breedingSystem.getAllWoods());
        return controlListBox;
    }));
    this.createMode(TreeMode.PLANKS, new ModeWidgets(TreeMode.PLANKS, this, (area, modePage) -> {
        ControlListBox<ItemStack> controlListBox = new ModeControlListBox(modePage, area);
        List<ItemStack> planks = WoodManager.getAllPlankTypes().stream().map(IDesignMaterial::getStack).collect(Collectors.toList());
        controlListBox.setOptions(planks);
        return controlListBox;
    }));
    new PageFruit(this.getInfoPages(TreeMode.FRUIT), new DatabaseTab(ExtraTrees.instance, "fruit.natural"), true);
    new PageFruit(this.getInfoPages(TreeMode.FRUIT), new DatabaseTab(ExtraTrees.instance, "fruit.potential"), false);
    new PageWood(this.getInfoPages(TreeMode.WOOD), new DatabaseTab(ExtraTrees.instance, "wood.natural"));
    new PagePlanksOverview(this.getInfoPages(TreeMode.PLANKS), new DatabaseTab(ExtraTrees.instance, "planks.overview"));
    new PagePlanksTrees(this.getInfoPages(TreeMode.PLANKS), new DatabaseTab(ExtraTrees.instance, "planks.natural"));
}
Also used : Binnie(binnie.core.Binnie) ITreeBreedingSystem(binnie.genetics.api.ITreeBreedingSystem) IDatabaseMode(binnie.core.gui.database.IDatabaseMode) ControlListBox(binnie.core.gui.controls.listbox.ControlListBox) ItemStack(net.minecraft.item.ItemStack) ExtraTrees(binnie.extratrees.ExtraTrees) Side(net.minecraftforge.fml.relauncher.Side) PageSpeciesOverview(binnie.core.gui.database.PageSpeciesOverview) WoodManager(binnie.extratrees.wood.WoodManager) PageSpeciesClassification(binnie.core.gui.database.PageSpeciesClassification) IWidget(binnie.core.api.gui.IWidget) ControlItemStackOption(binnie.core.gui.database.ControlItemStackOption) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ModeWidgets(binnie.core.gui.database.ModeWidgets) IArea(binnie.core.api.gui.IArea) PageBranchSpecies(binnie.core.gui.database.PageBranchSpecies) DatabaseTab(binnie.core.gui.database.DatabaseTab) TreeManager(forestry.api.arboriculture.TreeManager) PageSpeciesResultant(binnie.core.gui.database.PageSpeciesResultant) Collectors(java.util.stream.Collectors) I18N(binnie.core.util.I18N) List(java.util.List) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PageBranchOverview(binnie.core.gui.database.PageBranchOverview) PageBreeder(binnie.core.gui.database.PageBreeder) WindowAbstractDatabase(binnie.core.gui.database.WindowAbstractDatabase) ControlPage(binnie.core.gui.controls.page.ControlPage) IDesignMaterial(binnie.design.api.IDesignMaterial) PageSpeciesMutations(binnie.core.gui.database.PageSpeciesMutations) Window(binnie.core.gui.minecraft.Window) PageBranchSpecies(binnie.core.gui.database.PageBranchSpecies) IDesignMaterial(binnie.design.api.IDesignMaterial) DatabaseTab(binnie.core.gui.database.DatabaseTab) ITreeBreedingSystem(binnie.genetics.api.ITreeBreedingSystem) ControlListBox(binnie.core.gui.controls.listbox.ControlListBox) PageSpeciesMutations(binnie.core.gui.database.PageSpeciesMutations) PageSpeciesOverview(binnie.core.gui.database.PageSpeciesOverview) PageSpeciesClassification(binnie.core.gui.database.PageSpeciesClassification) List(java.util.List) PageSpeciesResultant(binnie.core.gui.database.PageSpeciesResultant) ModeWidgets(binnie.core.gui.database.ModeWidgets) PageBranchOverview(binnie.core.gui.database.PageBranchOverview) PageBreeder(binnie.core.gui.database.PageBreeder) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IWidget (binnie.core.api.gui.IWidget)2 ControlListBox (binnie.core.gui.controls.listbox.ControlListBox)2 ControlPage (binnie.core.gui.controls.page.ControlPage)2 Window (binnie.core.gui.minecraft.Window)2 I18N (binnie.core.util.I18N)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 Side (net.minecraftforge.fml.relauncher.Side)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 Binnie (binnie.core.Binnie)1 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)1 Alignment (binnie.core.api.gui.Alignment)1 IArea (binnie.core.api.gui.IArea)1 EventHandlerOrigin (binnie.core.api.gui.events.EventHandlerOrigin)1 ControlTextEdit (binnie.core.gui.controls.ControlTextEdit)1 ControlTextOption (binnie.core.gui.controls.listbox.ControlTextOption)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 ControlItemStackOption (binnie.core.gui.database.ControlItemStackOption)1 DatabaseTab (binnie.core.gui.database.DatabaseTab)1