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));
}
Aggregations