use of java.util.function.DoubleSupplier in project GregTech by GregTechCE.
the class MetaTileEntityLockedSafe method createUI.
@Override
protected ModularUI createUI(EntityPlayer entityPlayer) {
DoubleSupplier supplier = () -> 0.2 + (unlockProgress / (MAX_UNLOCK_PROGRESS * 1.0)) * 0.8;
ModularUI.Builder builder = ModularUI.defaultBuilder().widget(new ProgressWidget(supplier, 5, 5, 166, 74, GuiTextures.PROGRESS_BAR_UNLOCK, MoveType.VERTICAL_INVERTED)).bindPlayerInventory(entityPlayer.inventory);
ServerWidgetGroup lockedGroup = new ServerWidgetGroup(() -> !isSafeUnlocked && unlockProgress < 0);
lockedGroup.addWidget(new LabelWidget(5, 20, "gregtech.machine.locked_safe.malfunctioning"));
lockedGroup.addWidget(new LabelWidget(5, 30, "gregtech.machine.locked_safe.requirements"));
lockedGroup.addWidget(new SlotWidget(unlockInventory, 0, 70, 40, false, true).setBackgroundTexture(GuiTextures.SLOT));
lockedGroup.addWidget(new SlotWidget(unlockInventory, 1, 70 + 18, 40, false, true).setBackgroundTexture(GuiTextures.SLOT));
lockedGroup.addWidget(new SlotWidget(unlockComponents, 0, 70, 58, false, false));
lockedGroup.addWidget(new SlotWidget(unlockComponents, 1, 70 + 18, 58, false, false));
ServerWidgetGroup unlockedGroup = new ServerWidgetGroup(() -> isSafeUnlocked);
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 9; col++) {
unlockedGroup.addWidget(new SlotWidget(safeLootInventory, col + row * 9, 8 + col * 18, 15 + row * 18, true, false));
}
}
return builder.widget(unlockedGroup).widget(lockedGroup).build(getHolder(), entityPlayer);
}
use of java.util.function.DoubleSupplier in project BuildCraft by BuildCraft.
the class GuiAbstractButton method createTextElement.
public GuiElementText createTextElement(Supplier<String> text) {
FontRenderer fr = gui.mc.fontRenderer;
DoubleSupplier x = () -> -fr.getStringWidth(text.get()) / 2;
DoubleSupplier y = () -> -fr.FONT_HEIGHT / 2;
IGuiPosition pos = getCenter().offset(x, y);
return new GuiElementText(gui, pos, text, this::getColourForText);
}
use of java.util.function.DoubleSupplier in project BuildCraft by BuildCraft.
the class GuiUtil method moveRectangleToCentre.
public static IGuiArea moveRectangleToCentre(GuiRectangle area) {
final double w = area.width;
final double h = area.height;
DoubleSupplier posX = () -> (AREA_WHOLE_SCREEN.getWidth() - w) / 2;
DoubleSupplier posY = () -> (AREA_WHOLE_SCREEN.getHeight() - h) / 2;
IGuiPosition position = IGuiPosition.create(posX, posY);
return IGuiArea.create(position, area.width, area.height);
}
use of java.util.function.DoubleSupplier in project BuildCraft by BuildCraft.
the class IGuiArea method getPosition.
/**
* @param partX -1, 0 or 1. -1 equals the start, 0 equals the centre and 1 equals the end
* @param partY -1, 0 or 1. -1 equals the start, 0 equals the centre and 1 equals the end
* @return
*/
default IGuiPosition getPosition(int partX, int partY) {
DoubleSupplier x = partX < 0 ? this::getX : partX > 0 ? this::getEndX : this::getCenterX;
DoubleSupplier y = partY < 0 ? this::getY : partY > 0 ? this::getEndY : this::getCenterY;
return new PositionCallable(x, y);
}
use of java.util.function.DoubleSupplier in project j2objc by google.
the class OptionalDoubleTest method testOrElseGet.
public void testOrElseGet() {
DoubleSupplier alwaysFails = () -> {
fail();
return 57.0;
};
assertEquals(56.0, OptionalDouble.of(56.0).orElseGet(alwaysFails));
DoubleSupplier supplies57 = () -> 57.0;
assertEquals(57.0, OptionalDouble.empty().orElseGet(supplies57));
}
Aggregations