Search in sources :

Example 16 with IconButton

use of com.simibubi.create.foundation.gui.widget.IconButton 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)

Example 17 with IconButton

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

the class SchematicPromptScreen method init.

@Override
public void init() {
    setWindowSize(background.width, background.height);
    super.init();
    int x = guiLeft;
    int y = guiTop;
    nameField = new EditBox(font, x + 49, y + 26, 131, 10, TextComponent.EMPTY);
    nameField.setTextColor(-1);
    nameField.setTextColorUneditable(-1);
    nameField.setBordered(false);
    nameField.setMaxLength(35);
    nameField.changeFocus(true);
    setFocused(nameField);
    addRenderableWidget(nameField);
    abort = new IconButton(x + 7, y + 53, AllIcons.I_TRASH);
    abort.withCallback(() -> {
        CreateClient.SCHEMATIC_AND_QUILL_HANDLER.discard();
        onClose();
    });
    abort.setToolTip(abortLabel);
    addRenderableWidget(abort);
    confirm = new IconButton(x + 158, y + 53, AllIcons.I_CONFIRM);
    confirm.withCallback(() -> {
        confirm(false);
    });
    confirm.setToolTip(confirmLabel);
    addRenderableWidget(confirm);
    convert = new IconButton(x + 180, y + 53, AllIcons.I_SCHEMATIC);
    convert.withCallback(() -> {
        confirm(true);
    });
    convert.setToolTip(convertLabel);
    addRenderableWidget(convert);
}
Also used : IconButton(com.simibubi.create.foundation.gui.widget.IconButton) EditBox(net.minecraft.client.gui.components.EditBox)

Example 18 with IconButton

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

the class SchematicannonScreen method init.

@Override
protected void init() {
    setWindowSize(BG_TOP.width, BG_TOP.height + BG_BOTTOM.height + 2 + AllGuiTextures.PLAYER_INVENTORY.height);
    setWindowOffset(-11, 0);
    super.init();
    int x = leftPos;
    int y = topPos;
    // Play Pause Stop
    playButton = new IconButton(x + 75, y + 86, AllIcons.I_PLAY);
    playButton.withCallback(() -> {
        sendOptionUpdate(Option.PLAY, true);
    });
    playIndicator = new Indicator(x + 75, y + 79, TextComponent.EMPTY);
    pauseButton = new IconButton(x + 93, y + 86, AllIcons.I_PAUSE);
    pauseButton.withCallback(() -> {
        sendOptionUpdate(Option.PAUSE, true);
    });
    pauseIndicator = new Indicator(x + 93, y + 79, TextComponent.EMPTY);
    resetButton = new IconButton(x + 111, y + 86, AllIcons.I_STOP);
    resetButton.withCallback(() -> {
        sendOptionUpdate(Option.STOP, true);
    });
    resetIndicator = new Indicator(x + 111, y + 79, TextComponent.EMPTY);
    resetIndicator.state = State.RED;
    addRenderableWidgets(playButton, playIndicator, pauseButton, pauseIndicator, resetButton, resetIndicator);
    confirmButton = new IconButton(x + 180, y + 117, AllIcons.I_CONFIRM);
    confirmButton.withCallback(() -> {
        minecraft.player.closeContainer();
    });
    addRenderableWidget(confirmButton);
    showSettingsButton = new IconButton(x + 9, y + 117, AllIcons.I_PLACEMENT_SETTINGS);
    showSettingsButton.withCallback(() -> {
        showSettingsIndicator.state = placementSettingsHidden() ? State.GREEN : State.OFF;
        initPlacementSettings();
    });
    showSettingsButton.setToolTip(Lang.translate(_showSettings));
    addRenderableWidget(showSettingsButton);
    showSettingsIndicator = new Indicator(x + 9, y + 111, TextComponent.EMPTY);
    addRenderableWidget(showSettingsIndicator);
    extraAreas = ImmutableList.of(new Rect2i(x + BG_TOP.width, y + BG_TOP.height + BG_BOTTOM.height - 62, 84, 92));
    tick();
}
Also used : Rect2i(net.minecraft.client.renderer.Rect2i) IconButton(com.simibubi.create.foundation.gui.widget.IconButton) Indicator(com.simibubi.create.foundation.gui.widget.Indicator)

Aggregations

IconButton (com.simibubi.create.foundation.gui.widget.IconButton)18 Rect2i (net.minecraft.client.renderer.Rect2i)6 Indicator (com.simibubi.create.foundation.gui.widget.Indicator)5 Label (com.simibubi.create.foundation.gui.widget.Label)5 SelectionScrollInput (com.simibubi.create.foundation.gui.widget.SelectionScrollInput)5 TextComponent (net.minecraft.network.chat.TextComponent)3 ScrollInput (com.simibubi.create.foundation.gui.widget.ScrollInput)2 EditBox (net.minecraft.client.gui.components.EditBox)2 Component (net.minecraft.network.chat.Component)2 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 ClientSchematicLoader (com.simibubi.create.content.schematics.ClientSchematicLoader)1 AllIcons (com.simibubi.create.foundation.gui.AllIcons)1 Vector (java.util.Vector)1 AbstractWidget (net.minecraft.client.gui.components.AbstractWidget)1 BlockPos (net.minecraft.core.BlockPos)1 MutableComponent (net.minecraft.network.chat.MutableComponent)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 StructurePlaceSettings (net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings)1