Search in sources :

Example 1 with TextFieldWidget

use of net.minecraft.client.gui.widget.TextFieldWidget in project MCMOD-Industria by M-Marvin.

the class ScreenNComputer method renderBg.

@SuppressWarnings("deprecation")
@Override
protected void renderBg(MatrixStack matrixStack, float partialTicks, int x, int y) {
    RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.minecraft.getTextureManager().bind(COMPUTER_GUI_TEXTURES);
    int i = this.leftPos;
    int j = (this.height - this.imageHeight) / 2;
    this.blit(matrixStack, i, j, 0, 0, this.imageWidth, this.imageHeight);
    for (TextFieldWidget field : this.codeFields) {
        field.render(matrixStack, x, y, partialTicks);
    }
    this.consoleLine.render(matrixStack, x, y, partialTicks);
}
Also used : TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget)

Example 2 with TextFieldWidget

use of net.minecraft.client.gui.widget.TextFieldWidget in project MCMOD-Industria by M-Marvin.

the class ScreenNComputer method handleMultiLine.

protected boolean handleMultiLine(int scanCode) {
    TextFieldWidget currentLine = getCurrentLine();
    if (currentLine != null) {
        if (scanCode == 28) {
            for (int i = 0; i < this.codeFields.length; i++) {
                if (this.codeFields[i].isFocused() && i + 1 < this.codeFields.length) {
                    this.codeFields[i].changeFocus(false);
                    int coursorPos = Math.min(this.codeFields[i].getCursorPosition(), this.codeFields[+1].getValue().length());
                    this.codeFields[i + 1].setEditable(true);
                    this.codeFields[i + 1].changeFocus(true);
                    this.codeFields[i + 1].moveCursorTo(coursorPos);
                    return false;
                }
            }
        } else if (scanCode == 14 && getCurrentLine().getCursorPosition() == 0) {
            for (int i = 0; i < this.codeFields.length; i++) {
                if (this.codeFields[i].isFocused() && i - 1 >= 0) {
                    this.codeFields[i].changeFocus(false);
                    this.codeFields[i - 1].changeFocus(true);
                    this.codeFields[i - 1].moveCursorToEnd();
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget)

Example 3 with TextFieldWidget

use of net.minecraft.client.gui.widget.TextFieldWidget in project MCMOD-Industria by M-Marvin.

the class ScreenNameBlueprint method init.

@Override
protected void init() {
    this.minecraft.keyboardHandler.setSendRepeatsToGui(true);
    int i = this.width / 2;
    this.nameField = new TextFieldWidget(this.font, i + -60, 100, 120, 20, new TranslationTextComponent("industria.blueprint.structureName"));
    this.nameField.setMaxLength(25);
    this.nameField.setResponder(this::onChangeIP);
    this.nameValid = true;
    this.children.add(nameField);
    this.buttonConfirm = this.addButton(new Button(i + -61, 130, 60, 20, DialogTexts.GUI_DONE, this::onConfirm));
    this.buttonAbbort = this.addButton(new Button(i + 1, 130, 60, 20, DialogTexts.GUI_CANCEL, this::onCancel));
    BlockPos cornerA = ItemEmptyBlueprint.getPositionA(this.menu.blueprintItem);
    BlockPos cornerB = ItemEmptyBlueprint.getPositionB(this.menu.blueprintItem);
    int sizeX = Math.max(cornerA.getX(), cornerB.getX()) - Math.min(cornerA.getX(), cornerB.getX());
    int sizeY = Math.max(cornerA.getY(), cornerB.getY()) - Math.min(cornerA.getY(), cornerB.getY());
    int sizeZ = Math.max(cornerA.getZ(), cornerB.getZ()) - Math.min(cornerA.getZ(), cornerB.getZ());
    this.structureSize = (sizeX + 1) + "x" + (sizeY + 1) + "x" + (sizeZ + 1);
    super.init();
}
Also used : Button(net.minecraft.client.gui.widget.button.Button) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) BlockPos(net.minecraft.util.math.BlockPos) ItemEmptyBlueprint(de.industria.items.ItemEmptyBlueprint) CSaveBlueprint(de.industria.packet.CSaveBlueprint)

Example 4 with TextFieldWidget

use of net.minecraft.client.gui.widget.TextFieldWidget in project MCMOD-Industria by M-Marvin.

the class ScreenRProcessor method renderBg.

@SuppressWarnings("deprecation")
@Override
protected void renderBg(MatrixStack matrixStack, float partialTicks, int x, int y) {
    RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.minecraft.getTextureManager().bind(PROCESSOR_GUI_TEXTURES);
    int i = this.leftPos;
    int j = (this.height - this.imageHeight) / 2;
    this.blit(matrixStack, i, j, 0, 0, this.imageWidth, this.imageHeight);
    for (TextFieldWidget field : this.codeFields) {
        field.render(matrixStack, x, y, partialTicks);
        ;
    }
}
Also used : TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget)

Example 5 with TextFieldWidget

use of net.minecraft.client.gui.widget.TextFieldWidget in project FabricWaystones by LordDeatHunter.

the class WaystoneBlockScreen method init.

@Override
protected void init() {
    super.init();
    this.nameField = new TextFieldWidget(this.textRenderer, this.x + 28, this.y + 106, 93, 10, new LiteralText("")) {

        @Override
        public boolean mouseClicked(double mouseX, double mouseY, int button) {
            boolean bl = mouseX >= (double) this.x && mouseX < (double) (this.x + this.width) && mouseY >= (double) this.y && mouseY < (double) (this.y + this.height);
            if (bl && button == 1) {
                this.setText("");
            }
            return super.mouseClicked(mouseX, mouseY, button);
        }

        @Override
        public boolean isVisible() {
            return canEdit() && page == Page.CONFIG;
        }

        @Override
        public boolean changeFocus(boolean lookForwards) {
            return isVisible() && super.changeFocus(lookForwards);
        }

        @Override
        public boolean isMouseOver(double mouseX, double mouseY) {
            return isVisible() && mouseX >= (double) this.x && mouseX < (double) (this.x + this.width) && mouseY >= (double) this.y && mouseY < (double) (this.y + this.height);
        }
    };
    this.nameField.setMaxLength(16);
    this.nameField.setEditableColor(0xFFFFFF);
    this.nameField.setDrawsBackground(false);
    this.nameField.setFocusUnlocked(true);
    String waystone = Waystones.WAYSTONE_STORAGE.getName(((WaystoneBlockScreenHandler) handler).getWaystone());
    this.nameField.setText(waystone == null ? "" : waystone);
    this.nameField.setChangedListener((s) -> {
        boolean settable = !((WaystoneBlockScreenHandler) handler).getName().equals(s);
        ToggleableButton button = ((ToggleableButton) buttons.get(4));
        if (button.isToggled() == settable) {
            button.toggle();
        }
    });
    this.addDrawableChild(this.nameField);
}
Also used : TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) LiteralText(net.minecraft.text.LiteralText)

Aggregations

TextFieldWidget (net.minecraft.client.gui.widget.TextFieldWidget)42 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)10 Screen (net.minecraft.client.gui.screen.Screen)9 Button (net.minecraft.client.gui.widget.button.Button)8 MatrixStack (net.minecraft.client.util.math.MatrixStack)7 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)6 MinecraftClient (net.minecraft.client.MinecraftClient)6 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)6 LiteralText (net.minecraft.text.LiteralText)6 StringTextComponent (net.minecraft.util.text.StringTextComponent)5 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)4 GuiCheckBox (net.minecraftforge.fml.client.config.GuiCheckBox)4 ImageExporter (com.glisco.isometricrenders.client.ImageExporter)3 RuntimeConfig (com.glisco.isometricrenders.client.RuntimeConfig)3 ColorUtils (dev.hypnotic.utils.ColorUtils)3 RenderUtils (dev.hypnotic.utils.render.RenderUtils)3 Minecraft (net.minecraft.client.Minecraft)3 MinecraftClientAccessor (com.glisco.isometricrenders.mixin.MinecraftClientAccessor)2 Accounts (dev.hypnotic.ui.altmanager.account.Accounts)2 MicrosoftLogin (dev.hypnotic.ui.altmanager.account.MicrosoftLogin)2