Search in sources :

Example 6 with SelectionScrollInput

use of com.simibubi.create.foundation.gui.widget.SelectionScrollInput in project Create by Creators-of-Create.

the class SchematicEditScreen method init.

@Override
protected void init() {
    setWindowSize(background.width, background.height);
    setWindowOffset(-6, 0);
    super.init();
    int x = guiLeft;
    int y = guiTop;
    xInput = new EditBox(font, x + 50, y + 26, 34, 10, TextComponent.EMPTY);
    yInput = new EditBox(font, x + 90, y + 26, 34, 10, TextComponent.EMPTY);
    zInput = new EditBox(font, x + 130, y + 26, 34, 10, TextComponent.EMPTY);
    BlockPos anchor = handler.getTransformation().getAnchor();
    if (handler.isDeployed()) {
        xInput.setValue("" + anchor.getX());
        yInput.setValue("" + anchor.getY());
        zInput.setValue("" + anchor.getZ());
    } else {
        BlockPos alt = minecraft.player.blockPosition();
        xInput.setValue("" + alt.getX());
        yInput.setValue("" + alt.getY());
        zInput.setValue("" + alt.getZ());
    }
    for (EditBox widget : new EditBox[] { xInput, yInput, zInput }) {
        widget.setMaxLength(6);
        widget.setBordered(false);
        widget.setTextColor(0xFFFFFF);
        widget.changeFocus(false);
        widget.mouseClicked(0, 0, 0);
        widget.setFilter(s -> {
            if (s.isEmpty() || s.equals("-"))
                return true;
            try {
                Integer.parseInt(s);
                return true;
            } catch (NumberFormatException e) {
                return false;
            }
        });
    }
    StructurePlaceSettings settings = handler.getTransformation().toSettings();
    Label labelR = new Label(x + 50, y + 48, TextComponent.EMPTY).withShadow();
    rotationArea = new SelectionScrollInput(x + 45, y + 43, 118, 18).forOptions(rotationOptions).titled(rotationLabel.plainCopy()).setState(settings.getRotation().ordinal()).writingTo(labelR);
    Label labelM = new Label(x + 50, y + 70, TextComponent.EMPTY).withShadow();
    mirrorArea = new SelectionScrollInput(x + 45, y + 65, 118, 18).forOptions(mirrorOptions).titled(mirrorLabel.plainCopy()).setState(settings.getMirror().ordinal()).writingTo(labelM);
    addRenderableWidgets(xInput, yInput, zInput);
    addRenderableWidgets(labelR, labelM, rotationArea, mirrorArea);
    confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
    confirmButton.withCallback(() -> {
        onClose();
    });
    addRenderableWidget(confirmButton);
}
Also used : IconButton(com.simibubi.create.foundation.gui.widget.IconButton) Label(com.simibubi.create.foundation.gui.widget.Label) BlockPos(net.minecraft.core.BlockPos) StructurePlaceSettings(net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings) EditBox(net.minecraft.client.gui.components.EditBox) SelectionScrollInput(com.simibubi.create.foundation.gui.widget.SelectionScrollInput)

Aggregations

IconButton (com.simibubi.create.foundation.gui.widget.IconButton)6 SelectionScrollInput (com.simibubi.create.foundation.gui.widget.SelectionScrollInput)6 Label (com.simibubi.create.foundation.gui.widget.Label)5 TextComponent (net.minecraft.network.chat.TextComponent)4 BlockPos (net.minecraft.core.BlockPos)3 Component (net.minecraft.network.chat.Component)3 PoseStack (com.mojang.blaze3d.vertex.PoseStack)2 AllGuiTextures (com.simibubi.create.foundation.gui.AllGuiTextures)2 AllIcons (com.simibubi.create.foundation.gui.AllIcons)2 Indicator (com.simibubi.create.foundation.gui.widget.Indicator)2 ScrollInput (com.simibubi.create.foundation.gui.widget.ScrollInput)2 Lang (com.simibubi.create.foundation.utility.Lang)2 Vector (java.util.Vector)2 ItemStack (net.minecraft.world.item.ItemStack)2 AllBlocks (com.simibubi.create.AllBlocks)1 CrossPlaneMirror (com.simibubi.create.content.curiosities.symmetry.mirror.CrossPlaneMirror)1 PlaneMirror (com.simibubi.create.content.curiosities.symmetry.mirror.PlaneMirror)1 TriplePlaneMirror (com.simibubi.create.content.curiosities.symmetry.mirror.TriplePlaneMirror)1 ConfigureZapperPacket (com.simibubi.create.content.curiosities.zapper.ConfigureZapperPacket)1 ZapperScreen (com.simibubi.create.content.curiosities.zapper.ZapperScreen)1