use of me.desht.pneumaticcraft.common.network.PacketUpdateTextfield in project pnc-repressurized by TeamPneumatic.
the class GuiUniversalSensor method keyTyped.
@Override
protected void keyTyped(char par1, int par2) throws IOException {
if (nameFilterField.isFocused() && par2 != 1) {
nameFilterField.textboxKeyTyped(par1, par2);
te.setText(0, nameFilterField.getText());
NetworkHandler.sendToServer(new PacketUpdateTextfield(te, 0));
} else {
super.keyTyped(par1, par2);
}
}
use of me.desht.pneumaticcraft.common.network.PacketUpdateTextfield in project pnc-repressurized by TeamPneumatic.
the class GuiPressureChamberInterface method keyTyped.
@Override
protected void keyTyped(char par1, int par2) throws IOException {
if (nameFilterField.isFocused() && par2 != 1) {
nameFilterField.textboxKeyTyped(par1, par2);
te.itemNameFilter = nameFilterField.getText();
NetworkHandler.sendToServer(new PacketUpdateTextfield(te, 0));
} else {
super.keyTyped(par1, par2);
}
}
use of me.desht.pneumaticcraft.common.network.PacketUpdateTextfield in project pnc-repressurized by TeamPneumatic.
the class GuiElevator method onKeyTyped.
@Override
public void onKeyTyped(IGuiWidget widget) {
te.setFloorName(currentEditedFloor, floorNameField.getText());
NetworkHandler.sendToServer(new PacketUpdateTextfield(te, currentEditedFloor));
}
use of me.desht.pneumaticcraft.common.network.PacketUpdateTextfield in project pnc-repressurized by TeamPneumatic.
the class GuiProgrammer method updateScreen.
@Override
public void updateScreen() {
super.updateScreen();
undoButton.enabled = te.canUndo;
redoButton.enabled = te.canRedo;
updateConvertRelativeState();
ItemStack programmedItem = te.getIteminProgrammingSlot();
oldShowingWidgetProgress = showingWidgetProgress;
if (showingAllWidgets) {
int maxProgress = maxPage * WIDGET_X_SPACING;
if (showingWidgetProgress < maxProgress) {
showingWidgetProgress += 60;
if (showingWidgetProgress >= maxProgress) {
showingWidgetProgress = maxProgress;
updateVisibleProgWidgets();
}
}
} else {
showingWidgetProgress -= 60;
if (showingWidgetProgress < 0)
showingWidgetProgress = 0;
}
List<String> errors = new ArrayList<>();
List<String> warnings = new ArrayList<>();
for (IProgWidget w : te.progWidgets) {
w.addErrors(errors, te.progWidgets);
w.addWarnings(warnings, te.progWidgets);
}
boolean isDeviceInserted = !programmedItem.isEmpty();
importButton.enabled = isDeviceInserted;
exportButton.enabled = isDeviceInserted && errors.size() == 0;
List<String> exportButtonTooltip = new ArrayList<>();
exportButtonTooltip.add("Export program");
exportButtonTooltip.add(I18n.format("gui.programmer.button.export.programmingWhen", I18n.format("gui.programmer.button.export." + (te.redstoneMode == 0 ? "pressingButton" : "onItemInsert"))));
exportButtonTooltip.add(I18n.format("gui.programmer.button.export.pressRToChange"));
if (!programmedItem.isEmpty()) {
List<ItemStack> requiredPieces = te.getRequiredPuzzleStacks();
List<ItemStack> returnedPieces = te.getReturnedPuzzleStacks();
if (!requiredPieces.isEmpty() || !returnedPieces.isEmpty())
exportButtonTooltip.add("");
if (!requiredPieces.isEmpty()) {
exportButtonTooltip.add(I18n.format("gui.tooltip.programmable.requiredPieces"));
if (player.capabilities.isCreativeMode)
exportButtonTooltip.add("(Creative mode, so the following is free)");
for (ItemStack stack : requiredPieces) {
String prefix;
if (te.hasEnoughPuzzleStacks(player, stack)) {
prefix = TextFormatting.GREEN.toString();
} else {
prefix = TextFormatting.RED.toString();
exportButton.enabled = player.capabilities.isCreativeMode && errors.size() == 0;
}
exportButtonTooltip.add(prefix + "-" + stack.getCount() + "x " + stack.getDisplayName());
}
}
if (!returnedPieces.isEmpty()) {
exportButtonTooltip.add("Returned Programming Puzzles:");
if (player.capabilities.isCreativeMode)
exportButtonTooltip.add("(Creative mode, nothing's given)");
for (ItemStack stack : returnedPieces) {
exportButtonTooltip.add("-" + stack.getCount() + "x " + stack.getDisplayName());
}
}
} else {
exportButtonTooltip.add("No programmable item inserted.");
}
if (errors.size() > 0)
exportButtonTooltip.add(TextFormatting.RED + I18n.format("gui.programmer.errorCount", errors.size()));
if (warnings.size() > 0)
exportButtonTooltip.add(TextFormatting.YELLOW + I18n.format("gui.programmer.warningCount", warnings.size()));
exportButton.setTooltipText(exportButtonTooltip);
if (!programmedItem.isEmpty()) {
nameField.setEnabled(true);
if (!nameField.isFocused()) {
if (wasFocused) {
programmedItem.setStackDisplayName(nameField.getText());
NetworkHandler.sendToServer(new PacketUpdateTextfield(te, 0));
}
nameField.setText(programmedItem.getDisplayName());
wasFocused = false;
} else {
wasFocused = true;
}
} else {
nameField.setEnabled(false);
nameField.setText("");
wasFocused = false;
}
}
use of me.desht.pneumaticcraft.common.network.PacketUpdateTextfield in project pnc-repressurized by TeamPneumatic.
the class GuiProgrammer method mouseClicked.
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
ItemStack programmedItem = te.getIteminProgrammingSlot();
if (nameField.isFocused() && !programmedItem.isEmpty()) {
programmedItem.setStackDisplayName(nameField.getText());
NetworkHandler.sendToServer(new PacketUpdateTextfield(te, 0));
}
super.mouseClicked(mouseX, mouseY, mouseButton);
if (mouseButton == 1 && showingWidgetProgress == 0) {
IProgWidget widget = programmerUnit.getHoveredWidget(mouseX, mouseY);
if (widget != null) {
GuiScreen screen = widget.getOptionWindow(this);
if (screen != null)
mc.displayGuiScreen(screen);
}
}
}
Aggregations