use of pneumaticCraft.common.network.PacketUpdateTextfield in project PneumaticCraft by MineMaarten.
the class GuiProgrammer method updateScreen.
@Override
public void updateScreen() {
super.updateScreen();
undoButton.enabled = te.canUndo;
redoButton.enabled = te.canRedo;
updateConvertRelativeState();
ItemStack programmedItem = te.getStackInSlot(TileEntityProgrammer.PROGRAM_SLOT);
oldShowingWidgetProgress = showingWidgetProgress;
if (showingAllWidgets) {
int maxProgress = maxPage * 22;
if (showingWidgetProgress < maxProgress) {
showingWidgetProgress += 30;
if (showingWidgetProgress >= maxProgress) {
showingWidgetProgress = maxProgress;
updateVisibleProgWidgets();
}
}
} else {
showingWidgetProgress -= 30;
if (showingWidgetProgress < 0)
showingWidgetProgress = 0;
}
List<String> errors = new ArrayList<String>();
List<String> warnings = new ArrayList<String>();
for (IProgWidget w : te.progWidgets) {
w.addErrors(errors, te.progWidgets);
w.addWarnings(warnings, te.progWidgets);
}
boolean isDeviceInserted = programmedItem != null;
importButton.enabled = isDeviceInserted;
exportButton.enabled = isDeviceInserted && errors.size() == 0;
List<String> exportButtonTooltip = new ArrayList<String>();
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 != null) {
List<ItemStack> requiredPieces = te.getRequiredPuzzleStacks();
List<ItemStack> returnedPieces = te.getReturnedPuzzleStacks();
if (!requiredPieces.isEmpty() || !returnedPieces.isEmpty())
exportButtonTooltip.add("");
if (!requiredPieces.isEmpty()) {
exportButtonTooltip.add("Required Programming Puzzles:");
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 = EnumChatFormatting.GREEN.toString();
} else {
prefix = EnumChatFormatting.RED.toString();
exportButton.enabled = player.capabilities.isCreativeMode && errors.size() == 0;
}
exportButtonTooltip.add(prefix + "-" + stack.stackSize + "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.stackSize + "x " + stack.getDisplayName());
}
}
} else {
exportButtonTooltip.add("No programmable item inserted.");
}
if (errors.size() > 0)
exportButtonTooltip.add(EnumChatFormatting.RED + I18n.format("gui.programmer.errorCount", errors.size()));
if (warnings.size() > 0)
exportButtonTooltip.add(EnumChatFormatting.YELLOW + I18n.format("gui.programmer.warningCount", warnings.size()));
exportButton.setTooltipText(exportButtonTooltip);
if (programmedItem != null) {
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 pneumaticCraft.common.network.PacketUpdateTextfield in project PneumaticCraft by MineMaarten.
the class GuiSentryTurret method mouseClicked.
@Override
protected void mouseClicked(int par1, int par2, int par3) {
super.mouseClicked(par1, par2, par3);
if (!entityFilter.isFocused()) {
te.setText(0, entityFilter.getText());
NetworkHandler.sendToServer(new PacketUpdateTextfield(te, 0));
}
}
use of pneumaticCraft.common.network.PacketUpdateTextfield in project PneumaticCraft by MineMaarten.
the class GuiSentryTurret method onGuiClosed.
@Override
public void onGuiClosed() {
super.onGuiClosed();
te.setText(0, entityFilter.getText());
NetworkHandler.sendToServer(new PacketUpdateTextfield(te, 0));
}
Aggregations