Search in sources :

Example 6 with DoubleSupplier

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);
}
Also used : SlotWidget(gregtech.api.gui.widgets.SlotWidget) ModularUI(gregtech.api.gui.ModularUI) DoubleSupplier(java.util.function.DoubleSupplier) ProgressWidget(gregtech.api.gui.widgets.ProgressWidget) ServerWidgetGroup(gregtech.api.gui.widgets.ServerWidgetGroup) LabelWidget(gregtech.api.gui.widgets.LabelWidget)

Example 7 with DoubleSupplier

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);
}
Also used : DoubleSupplier(java.util.function.DoubleSupplier) GuiElementText(buildcraft.lib.gui.elem.GuiElementText) FontRenderer(net.minecraft.client.gui.FontRenderer) IGuiPosition(buildcraft.lib.gui.pos.IGuiPosition)

Example 8 with DoubleSupplier

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);
}
Also used : DoubleSupplier(java.util.function.DoubleSupplier) IGuiPosition(buildcraft.lib.gui.pos.IGuiPosition)

Example 9 with DoubleSupplier

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);
}
Also used : DoubleSupplier(java.util.function.DoubleSupplier)

Example 10 with DoubleSupplier

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));
}
Also used : DoubleSupplier(java.util.function.DoubleSupplier)

Aggregations

DoubleSupplier (java.util.function.DoubleSupplier)10 IGuiPosition (buildcraft.lib.gui.pos.IGuiPosition)2 IConstantNode (buildcraft.lib.expression.api.IConstantNode)1 GuiElementText (buildcraft.lib.gui.elem.GuiElementText)1 GuiRectangle (buildcraft.lib.gui.pos.GuiRectangle)1 ActivationLayer (com.simiacryptus.mindseye.layers.cudnn.ActivationLayer)1 ConvolutionLayer (com.simiacryptus.mindseye.layers.cudnn.ConvolutionLayer)1 ImgBandBiasLayer (com.simiacryptus.mindseye.layers.cudnn.ImgBandBiasLayer)1 PoolingLayer (com.simiacryptus.mindseye.layers.cudnn.PoolingLayer)1 BiasLayer (com.simiacryptus.mindseye.layers.java.BiasLayer)1 FullyConnectedLayer (com.simiacryptus.mindseye.layers.java.FullyConnectedLayer)1 SoftmaxActivationLayer (com.simiacryptus.mindseye.layers.java.SoftmaxActivationLayer)1 PipelineNetwork (com.simiacryptus.mindseye.network.PipelineNetwork)1 ModularUI (gregtech.api.gui.ModularUI)1 LabelWidget (gregtech.api.gui.widgets.LabelWidget)1 ProgressWidget (gregtech.api.gui.widgets.ProgressWidget)1 ServerWidgetGroup (gregtech.api.gui.widgets.ServerWidgetGroup)1 SlotWidget (gregtech.api.gui.widgets.SlotWidget)1 Random (java.util.Random)1 IntSupplier (java.util.function.IntSupplier)1