Search in sources :

Example 6 with Point

use of binnie.core.gui.geometry.Point 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 7 with Point

use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.

the class WindowFieldKit method onUpdateClient.

@Override
@SideOnly(Side.CLIENT)
public void onUpdateClient() {
    super.onUpdateClient();
    if (this.isAnalysing) {
        this.analyseProgress += 0.01f;
        if (this.analyseProgress >= 1) {
            this.isAnalysing = false;
            this.analyseProgress = 1;
            final ItemStack stack = this.getWindowInventory().getStackInSlot(INDIVIDUAL_SLOT);
            if (!stack.isEmpty()) {
                this.sendClientAction("analyse", new NBTTagCompound());
            }
            this.refreshSpecies();
        }
    }
    this.glassVX += this.glassRand.nextFloat() - 2.5f - this.glassOffsetX * 1f;
    this.glassVY += this.glassRand.nextFloat() - 2.5f - this.glassOffsetY * 1f;
    this.glassOffsetX += this.glassVX;
    this.glassOffsetX *= 1 - this.analyseProgress;
    this.glassOffsetY += this.glassVY;
    this.glassOffsetY *= 1 - this.analyseProgress;
    this.GlassControl.setOffset(new Point((int) this.glassOffsetX, (int) this.glassOffsetY));
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Point(binnie.core.gui.geometry.Point) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with Point

use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.

the class ControlList method filterOptions.

public void filterOptions() {
    int height = 0;
    this.optionWidgets.clear();
    for (final Map.Entry<T, IWidget> entry : this.allOptions.entrySet()) {
        if (this.isValidOption(entry.getValue())) {
            entry.getValue().show();
            this.optionWidgets.put(entry.getKey(), entry.getValue());
            entry.getValue().setPosition(new Point(0, height));
            height += entry.getValue().getSize().yPos();
        } else {
            entry.getValue().hide();
        }
    }
    this.setValue(this.getValue());
    this.setSize(new Point(this.getSize().xPos(), height));
}
Also used : Point(binnie.core.gui.geometry.Point) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Point(binnie.core.gui.geometry.Point) IWidget(binnie.core.api.gui.IWidget)

Example 9 with Point

use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.

the class SearchDialog method updateSearch.

private void updateSearch() {
    Map<Integer, String> slotIds = new HashMap<>();
    final IInventory inv = windowCompartment.getInventory();
    for (int i = 0; i < inv.getSizeInventory(); ++i) {
        final ItemStack stack = inv.getStackInSlot(i);
        if (!stack.isEmpty()) {
            final String name = stack.getDisplayName().toLowerCase();
            if (this.textSearch == null || name.contains(this.textSearch)) {
                if (this.includeBlocks || Block.getBlockFromItem(stack.getItem()) == Blocks.AIR) {
                    if (this.includeItems || Block.getBlockFromItem(stack.getItem()) != Blocks.AIR) {
                        slotIds.put(i, name);
                    }
                }
            }
        }
    }
    if (this.sortByName) {
        final List<Map.Entry<Integer, String>> list = new LinkedList<>(slotIds.entrySet());
        list.sort((o1, o2) -> -o2.getValue().compareTo(o1.getValue()));
        final Map<Integer, String> result = new LinkedHashMap<>();
        for (final Map.Entry<Integer, String> entry : list) {
            result.put(entry.getKey(), entry.getValue());
        }
        slotIds = result;
    }
    int y = 0;
    int x = 0;
    final int width = 108;
    final int height = 2 + 18 * (1 + (slotIds.size() - 1) / 6);
    this.slotGrid.deleteAllChildren();
    this.slotGrid.setSize(new Point(width, height));
    for (final int k : slotIds.keySet()) {
        new ControlSlot.Builder(this.slotGrid, x, y).assign(k);
        x += 18;
        if (x >= 108) {
            x = 0;
            y += 18;
        }
    }
    while (y < 108 || x != 0) {
        // TODO: what was this supposed to do?
        new ControlSlot.Builder(this.slotGrid, x, y);
        x += 18;
        if (x >= 108) {
            x = 0;
            y += 18;
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Point(binnie.core.gui.geometry.Point) Point(binnie.core.gui.geometry.Point) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) ControlSlot(binnie.core.gui.minecraft.control.ControlSlot) ItemStack(net.minecraft.item.ItemStack) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 10 with Point

use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.

the class GuiCraftGUI method initGui.

@Override
public void initGui() {
    super.initGui();
    this.mc.player.openContainer = this.inventorySlots;
    this.guiLeft = (this.width - this.xSize) / 2;
    this.guiTop = (this.height - this.ySize) / 2;
    this.window.setSize(new Point(this.xSize, this.ySize));
    this.window.setPosition(new Point(this.guiLeft, this.guiTop));
    this.window.initGui();
}
Also used : IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point)

Aggregations

Point (binnie.core.gui.geometry.Point)46 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)25 IPoint (binnie.core.api.gui.IPoint)15 Area (binnie.core.gui.geometry.Area)13 ControlText (binnie.core.gui.controls.ControlText)10 ItemStack (net.minecraft.item.ItemStack)10 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)6 IArea (binnie.core.api.gui.IArea)5 Map (java.util.Map)5 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 ControlTextEdit (binnie.core.gui.controls.ControlTextEdit)4 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)4 ControlTabBar (binnie.core.gui.controls.tab.ControlTabBar)4 EventWidget (binnie.core.gui.events.EventWidget)4 Panel (binnie.core.gui.window.Panel)4 ArrayList (java.util.ArrayList)4 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)3 IWidget (binnie.core.api.gui.IWidget)3 Control (binnie.core.gui.controls.core.Control)3 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)3