use of me.desht.pneumaticcraft.common.progwidgets.IProgWidget in project pnc-repressurized by TeamPneumatic.
the class GuiProgrammer method deleteConnectingWidgets.
private void deleteConnectingWidgets(IProgWidget widget) {
te.progWidgets.remove(widget);
IProgWidget[] connectingWidgets = widget.getConnectedParameters();
if (connectingWidgets != null) {
for (IProgWidget widg : connectingWidgets) {
if (widg != null)
deleteConnectingWidgets(widg);
}
}
IProgWidget outputWidget = widget.getOutputWidget();
if (outputWidget != null)
deleteConnectingWidgets(outputWidget);
}
use of me.desht.pneumaticcraft.common.progwidgets.IProgWidget in project pnc-repressurized by TeamPneumatic.
the class GuiProgrammer method updateConvertRelativeState.
private void updateConvertRelativeState() {
convertToRelativeButton.enabled = false;
List<String> tooltip = new ArrayList<>();
tooltip.add("gui.programmer.button.convertToRelative.desc");
boolean startFound = false;
for (IProgWidget startWidget : te.progWidgets) {
if (startWidget instanceof ProgWidgetStart) {
startFound = true;
IProgWidget widget = startWidget.getOutputWidget();
if (widget instanceof ProgWidgetCoordinateOperator) {
ProgWidgetCoordinateOperator operatorWidget = (ProgWidgetCoordinateOperator) widget;
if (!operatorWidget.getVariable().equals("")) {
try {
if (generateRelativeOperators(operatorWidget, tooltip, true)) {
convertToRelativeButton.enabled = true;
} else {
tooltip.add("gui.programmer.button.convertToRelative.notEnoughRoom");
}
} catch (NullPointerException e) {
tooltip.add("gui.programmer.button.convertToRelative.cantHaveVariables");
}
} else {
tooltip.add("gui.programmer.button.convertToRelative.noVariableName");
}
} else {
tooltip.add("gui.programmer.button.convertToRelative.noBaseCoordinate");
}
}
}
if (!startFound)
tooltip.add("gui.programmer.button.convertToRelative.noStartPiece");
List<String> localizedTooltip = new ArrayList<>();
for (String s : tooltip) {
localizedTooltip.addAll(PneumaticCraftUtils.convertStringIntoList(I18n.format(s), 40));
}
convertToRelativeButton.setTooltipText(localizedTooltip);
}
use of me.desht.pneumaticcraft.common.progwidgets.IProgWidget in project pnc-repressurized by TeamPneumatic.
the class GuiProgrammer method keyTyped.
@Override
protected void keyTyped(char key, int keyCode) throws IOException {
super.keyTyped(key, keyCode);
if (nameField.isFocused() || filterField.isFocused() && keyCode != Keyboard.KEY_TAB) {
return;
}
if (Keyboard.KEY_I == keyCode && Loader.isModLoaded(ModIds.IGWMOD)) {
onIGWAction();
}
if (Keyboard.KEY_R == keyCode) {
if (exportButton.getBounds().contains(lastMouseX, lastMouseY)) {
NetworkHandler.sendToServer(new PacketGuiButton(0));
}
}
if (Keyboard.KEY_SPACE == keyCode || Keyboard.KEY_TAB == keyCode) {
toggleShowWidgets();
}
if (Keyboard.KEY_DELETE == keyCode) {
IProgWidget widget = programmerUnit.getHoveredWidget(lastMouseX, lastMouseY);
if (widget != null) {
te.progWidgets.remove(widget);
NetworkHandler.sendToServer(new PacketProgrammerUpdate(te));
}
}
if (Keyboard.KEY_Z == keyCode) {
NetworkHandler.sendToServer(new PacketGuiButton(undoButton.id));
}
if (Keyboard.KEY_Y == keyCode) {
NetworkHandler.sendToServer(new PacketGuiButton(redoButton.id));
}
}
use of me.desht.pneumaticcraft.common.progwidgets.IProgWidget 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.progwidgets.IProgWidget 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