use of binnie.core.gui.geometry.Point 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));
}
use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.
the class ControlEnergyBar method onRenderBackground.
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
CraftGUI.RENDER.texture(CraftGUITexture.ENERGY_BAR_BACK, this.getArea());
final float percentage = this.getPercentage() / 100.0f;
int colourFromPercentage = this.getColourFromPercentage(percentage);
RenderUtil.setColour(colourFromPercentage);
final IArea area = this.getArea();
switch(this.direction) {
case TOP:
case BOTTOM:
{
IPoint fullSize = area.size();
final int height = Math.round(fullSize.yPos() * percentage);
area.setSize(new Point(fullSize.xPos(), height));
area.setYPos(fullSize.yPos() - height);
break;
}
case LEFT:
case RIGHT:
{
final int width = Math.round(area.size().xPos() * percentage);
area.setSize(new Point(width, area.size().yPos()));
break;
}
}
if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) {
final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.HELP);
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
} else if (ControlEnergyBar.isError) {
final int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.ERROR);
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
}
CraftGUI.RENDER.texture(CraftGUITexture.ENERGY_BAR_GLOW, area);
GlStateManager.color(1, 1, 1, 1);
CraftGUI.RENDER.texture(CraftGUITexture.ENERGY_BAR_GLASS, this.getArea());
}
use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.
the class ControlSlot method onRenderBackground.
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
CraftGUI.RENDER.texture(CraftGUITexture.SLOT, Point.ZERO);
final InventorySlot islot = this.getInventorySlot();
if (islot != null) {
SlotValidator validator = islot.getValidator();
if (validator != null) {
final TextureAtlasSprite icon = validator.getIcon(!islot.getInputSides().isEmpty());
if (icon != null && icon != Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite()) {
GlStateManager.enableBlend();
RenderUtil.drawSprite(new Point(1, 1), icon);
GlStateManager.disableBlend();
}
}
}
}
use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.
the class ControlSlotBase method onRenderBackground.
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
CraftGUI.RENDER.texture(CraftGUITexture.SLOT, this.getArea());
if (this.getTopParent().getMousedOverWidget() == this) {
Area area = new Area(new Point(1, 1), this.getArea().size().sub(new Point(2, 2)));
RenderUtil.drawGradientRect(area, -2130706433, -2130706433);
}
}
use of binnie.core.gui.geometry.Point in project Binnie by ForestryMC.
the class WindowFieldKit method initialiseClient.
@Override
@SideOnly(Side.CLIENT)
public void initialiseClient() {
this.setTitle(I18N.localise("binniecore.gui.fieldkit.title"));
CraftGUI.RENDER.setStyleSheet(StyleSheetManager.getSheet(StyleSheetManager.PUNNETT_SHEET));
WindowInventory inventory = this.getWindowInventory();
inventory.createSlot(INDIVIDUAL_SLOT);
inventory.createSlot(PAPER_SLOT);
this.setupValidators();
new ControlPlayerInventory(this);
final Point handGlass = new Point(16, 32);
this.GlassControl = new ControlImage(this, handGlass.xPos(), handGlass.yPos(), new StandardTexture(0, 160, 96, 96, BinnieCoreTexture.GUI_PUNNETT));
new ControlSlot.Builder(this, handGlass.xPos() + 54, handGlass.yPos() + 26).assign(InventoryType.WINDOW, 0);
new ControlSlot.Builder(this, 208, 8).assign(InventoryType.WINDOW, 1);
(this.text = new ControlText(this, new Point(232, 13), I18N.localise("binniecore.gui.fieldkit.paper"))).setColor(2236962);
(this.text = new ControlText(this, new Area(0, 120, this.getWidth(), 24), "", TextJustification.MIDDLE_CENTER)).setColor(2236962);
this.chromo = new ControlChromosome(this, 150, 24);
this.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, this.chromo, event -> {
final IChromosomeType type = (IChromosomeType) event.getValue();
if (type != null && WindowFieldKit.this.info.containsKey(type)) {
final String t = WindowFieldKit.this.info.get(type);
WindowFieldKit.this.text.setValue(t);
} else {
WindowFieldKit.this.text.setValue("");
}
});
}
Aggregations