use of me.desht.pneumaticcraft.api.universalSensor.ISensorSetting in project pnc-repressurized by TeamPneumatic.
the class GuiUniversalSensor method updateButtons.
public void updateButtons() {
buttonList.clear();
buttonList.add(redstoneButton);
if (!te.getSensorSetting().equals("")) {
buttonList.add(new GuiButton(1, guiLeft + 70, guiTop + 18, 30, 20, "back"));
} else {
buttonList.add(new GuiButton(-1, guiLeft + 70, guiTop + 125, 98, 20, I18n.format("gui.universalSensor.button.showRange")));
}
String[] directories = SensorHandler.getInstance().getDirectoriesAtLocation(te.getSensorSetting());
maxPage = (directories.length - 1) / MAX_SENSORS_PER_PAGE + 1;
if (page > maxPage)
page = maxPage;
if (page < 1)
page = 1;
if (maxPage > 1) {
buttonList.add(new GuiButton(2, guiLeft + 70, guiTop + 40 + 22 * MAX_SENSORS_PER_PAGE, 30, 20, "<--"));
buttonList.add(new GuiButton(3, guiLeft + 138, guiTop + 40 + 22 * MAX_SENSORS_PER_PAGE, 30, 20, "-->"));
}
int buttonsOnPage = MAX_SENSORS_PER_PAGE;
if (page == maxPage && (directories.length % MAX_SENSORS_PER_PAGE > 0 || directories.length == 0)) {
buttonsOnPage = directories.length % MAX_SENSORS_PER_PAGE;
}
for (int i = 0; i < buttonsOnPage; i++) {
String buttonText = directories[i + (page - 1) * MAX_SENSORS_PER_PAGE];
if (SensorHandler.getInstance().getSensorFromPath(te.getSensorSetting() + "/" + buttonText) != null) {
buttonText = TextFormatting.YELLOW + buttonText;
}
int buttonID = i * 10 + 10 + (page - 1) * MAX_SENSORS_PER_PAGE * 10;
int buttonX = guiLeft + 70;
int buttonY = guiTop + 40 + i * 22;
int buttonWidth = 98;
int buttonHeight = 20;
if (te.getSensorSetting().equals("")) {
Set<Item> requiredItems = SensorHandler.getInstance().getRequiredStacksFromText(buttonText);
GuiButtonSpecial button = new GuiButtonSpecial(buttonID, buttonX, buttonY, buttonWidth, buttonHeight, "");
ItemStack[] requiredStacks = new ItemStack[requiredItems.size()];
Iterator<Item> iterator = requiredItems.iterator();
for (int j = 0; j < requiredStacks.length; j++) {
requiredStacks[j] = new ItemStack(iterator.next());
}
button.setRenderStacks(requiredStacks);
button.enabled = te.areGivenUpgradesInserted(requiredItems);
buttonList.add(button);
} else {
buttonList.add(new GuiButton(buttonID, buttonX, buttonY, buttonWidth, buttonHeight, buttonText));
}
}
sensorInfoStat.setText(getSensorInfo());
ISensorSetting sensor = SensorHandler.getInstance().getSensorFromPath(te.getSensorSetting());
boolean textboxEnabled = sensor != null && sensor.needsTextBox();
nameFilterField.setVisible(textboxEnabled);
if (!textboxEnabled)
nameFilterField.setFocused(false);
}
Aggregations