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);
}
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;
}
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();
}
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);
;
}
}
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);
}
Aggregations