Search in sources :

Example 1 with IDesignCategory

use of binnie.design.api.IDesignCategory in project Binnie by ForestryMC.

the class ControlTileSelect method refresh.

public void refresh(final String filterText) {
    this.deleteAllChildren();
    int cx = 2;
    int cy = 2;
    final Map<IDesignCategory, List<IDesign>> designs = new HashMap<>();
    for (final IDesignCategory category : DesignAPI.manager.getAllDesignCategories()) {
        designs.put(category, new ArrayList<>());
        for (final IDesign tile : category.getDesigns()) {
            if (Objects.equals(filterText, "") || tile.getName().toLowerCase().contains(filterText)) {
                designs.get(category).add(tile);
            }
        }
        if (designs.get(category).isEmpty()) {
            designs.remove(category);
        }
    }
    for (final IDesignCategory category : designs.keySet()) {
        cx = 2;
        new ControlText(this, new Point(cx, cy + 3), category.getName());
        cy += 16;
        for (final IDesign tile : designs.get(category)) {
            if (cx > 90) {
                cx = 2;
                cy += 20;
            }
            new ControlTile(this, cx, cy, tile);
            cx += 20;
        }
        cy += 20;
    }
    final int height = cy;
    this.setSize(new Point(this.getSize().xPos(), height));
}
Also used : IDesign(binnie.design.api.IDesign) HashMap(java.util.HashMap) ControlText(binnie.core.gui.controls.ControlText) ArrayList(java.util.ArrayList) List(java.util.List) Point(binnie.core.gui.geometry.Point) IDesignCategory(binnie.design.api.IDesignCategory) Point(binnie.core.gui.geometry.Point)

Aggregations

ControlText (binnie.core.gui.controls.ControlText)1 Point (binnie.core.gui.geometry.Point)1 IDesign (binnie.design.api.IDesign)1 IDesignCategory (binnie.design.api.IDesignCategory)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1