Search in sources :

Example 1 with AreaType

use of me.desht.pneumaticcraft.common.progwidgets.area.AreaType in project pnc-repressurized by TeamPneumatic.

the class GuiProgWidgetArea method actionPerformed.

@Override
public void actionPerformed(IGuiWidget guiWidget) {
    if (guiWidget instanceof GuiRadioButton) {
        AreaType areaType = allAreaTypes.get(guiWidget.getID());
        widget.type = areaType;
        switchToWidgets(areaType);
    }
    super.actionPerformed(guiWidget);
}
Also used : GuiRadioButton(me.desht.pneumaticcraft.client.gui.widget.GuiRadioButton) AreaType(me.desht.pneumaticcraft.common.progwidgets.area.AreaType)

Example 2 with AreaType

use of me.desht.pneumaticcraft.common.progwidgets.area.AreaType in project pnc-repressurized by TeamPneumatic.

the class GuiProgWidgetArea method initGui.

@Override
public void initGui() {
    super.initGui();
    addLabel(I18n.format("gui.progWidget.area.point1"), guiLeft + 50, guiTop + 10);
    addLabel(I18n.format("gui.progWidget.area.point2"), guiLeft + 177, guiTop + 10);
    addLabel(I18n.format("gui.progWidget.area.type"), guiLeft + 4, guiTop + 50);
    boolean advancedMode = ConfigHandler.getProgrammerDifficulty() == 2;
    GuiButtonSpecial gpsButton1 = new GuiButtonSpecial(0, guiLeft + (advancedMode ? 6 : 55), guiTop + 20, 20, 20, "");
    GuiButtonSpecial gpsButton2 = new GuiButtonSpecial(1, guiLeft + (advancedMode ? 133 : 182), guiTop + 20, 20, 20, "");
    gpsButton1.setRenderStacks(new ItemStack(Itemss.GPS_TOOL));
    gpsButton2.setRenderStacks(new ItemStack(Itemss.GPS_TOOL));
    buttonList.add(gpsButton1);
    buttonList.add(gpsButton2);
    variableField1 = new WidgetComboBox(fontRenderer, guiLeft + 28, guiTop + 25, 88, fontRenderer.FONT_HEIGHT + 1);
    variableField2 = new WidgetComboBox(fontRenderer, guiLeft + 155, guiTop + 25, 88, fontRenderer.FONT_HEIGHT + 1);
    Set<String> variables = guiProgrammer == null ? Collections.emptySet() : guiProgrammer.te.getAllVariables();
    variableField1.setElements(variables);
    variableField2.setElements(variables);
    variableField1.setText(widget.getCoord1Variable());
    variableField2.setText(widget.getCoord2Variable());
    if (advancedMode) {
        addWidget(variableField1);
        addWidget(variableField2);
    }
    final int widgetsPerColumn = 5;
    List<GuiRadioButton> radioButtons = new ArrayList<>();
    for (int i = 0; i < allAreaTypes.size(); i++) {
        AreaType areaType = allAreaTypes.get(i);
        GuiRadioButton radioButton = new GuiRadioButton(i, guiLeft + widgetsPerColumn + i / widgetsPerColumn * 80, guiTop + 60 + i % widgetsPerColumn * 12, 0xFF404040, areaType.getName());
        if (widget.type.getClass() == areaType.getClass()) {
            allAreaTypes.set(i, widget.type);
            radioButton.checked = true;
        }
        addWidget(radioButton);
        radioButtons.add(radioButton);
        radioButton.otherChoices = radioButtons;
    }
    // typeInfoField.setTooltip(I18n.format("gui.progWidget.area.extraInfo.tooltip"));
    // addWidget(new WidgetLabel(guiLeft + 160, guiTop + 100, I18n.format("gui.progWidget.area.extraInfo")));
    switchToWidgets(widget.type);
    if (invSearchGui != null) {
        BlockPos pos = !invSearchGui.getSearchStack().isEmpty() ? ItemGPSTool.getGPSLocation(invSearchGui.getSearchStack()) : null;
        if (pos != null) {
            if (pointSearched == 0) {
                widget.x1 = pos.getX();
                widget.y1 = pos.getY();
                widget.z1 = pos.getZ();
            } else {
                widget.x2 = pos.getX();
                widget.y2 = pos.getY();
                widget.z2 = pos.getZ();
            }
        } else {
            if (pointSearched == 0) {
                widget.x1 = widget.y1 = widget.z1 = 0;
            } else {
                widget.x2 = widget.y2 = widget.z2 = 0;
            }
        }
    }
    List<String> b1List = Lists.newArrayList(I18n.format("gui.progWidget.area.selectGPS1"));
    if (widget.x1 != 0 || widget.y1 != 0 || widget.z1 != 0) {
        b1List.add(String.format(TextFormatting.GRAY + "[Current] %d, %d, %d", widget.x1, widget.y1, widget.z1));
    }
    gpsButton1.setTooltipText(b1List);
    List<String> b2List = Lists.newArrayList(I18n.format("gui.progWidget.area.selectGPS2"));
    if (widget.x2 != 0 || widget.y2 != 0 || widget.z2 != 0) {
        b2List.add(String.format(TextFormatting.GRAY + "[Current] %d, %d, %d", widget.x2, widget.y2, widget.z2));
    }
    gpsButton2.setTooltipText(b2List);
}
Also used : ArrayList(java.util.ArrayList) AreaType(me.desht.pneumaticcraft.common.progwidgets.area.AreaType) GuiButtonSpecial(me.desht.pneumaticcraft.client.gui.GuiButtonSpecial) GuiRadioButton(me.desht.pneumaticcraft.client.gui.widget.GuiRadioButton) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) WidgetComboBox(me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox)

Example 3 with AreaType

use of me.desht.pneumaticcraft.common.progwidgets.area.AreaType in project pnc-repressurized by TeamPneumatic.

the class GuiProgWidgetArea method switchToWidgets.

private void switchToWidgets(AreaType type) {
    saveWidgets();
    areaTypeValueWidgets.forEach(p -> removeWidget(p.getRight()));
    areaTypeStaticWidgets.forEach(w -> removeWidget(w));
    areaTypeValueWidgets.clear();
    areaTypeStaticWidgets.clear();
    int curY = guiTop + 60;
    int x = guiLeft + 150;
    List<AreaTypeWidget> widgets = new ArrayList<>();
    type.addUIWidgets(widgets);
    for (AreaTypeWidget widget : widgets) {
        WidgetLabel titleWidget = new WidgetLabel(x, curY, I18n.format(widget.title));
        addWidget(titleWidget);
        areaTypeStaticWidgets.add(titleWidget);
        curY += fontRenderer.FONT_HEIGHT + 1;
        if (widget instanceof AreaTypeWidgetInteger) {
            AreaTypeWidgetInteger intWidget = (AreaTypeWidgetInteger) widget;
            WidgetTextFieldNumber intField = new WidgetTextFieldNumber(fontRenderer, x, curY, 40, fontRenderer.FONT_HEIGHT + 1);
            intField.setValue(intWidget.readAction.get());
            addWidget(intField);
            areaTypeValueWidgets.add(new ImmutablePair<AreaType.AreaTypeWidget, IGuiWidget>(widget, intField));
            curY += fontRenderer.FONT_HEIGHT + 20;
        } else if (widget instanceof AreaTypeWidgetEnum<?>) {
            AreaTypeWidgetEnum<?> enumWidget = (AreaTypeWidgetEnum<?>) widget;
            WidgetComboBox enumCbb = new WidgetComboBox(fontRenderer, x, curY, 80, fontRenderer.FONT_HEIGHT + 1).setFixedOptions();
            enumCbb.setElements(getEnumNames(enumWidget.enumClass));
            enumCbb.setText(enumWidget.readAction.get().toString());
            addWidget(enumCbb);
            areaTypeValueWidgets.add(new ImmutablePair<AreaType.AreaTypeWidget, IGuiWidget>(widget, enumCbb));
            curY += fontRenderer.FONT_HEIGHT + 20;
        } else {
            throw new IllegalStateException("Invalid widget type: " + widget.getClass());
        }
    }
}
Also used : WidgetLabel(me.desht.pneumaticcraft.client.gui.widget.WidgetLabel) AreaTypeWidgetInteger(me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidgetInteger) WidgetTextFieldNumber(me.desht.pneumaticcraft.client.gui.widget.WidgetTextFieldNumber) IGuiWidget(me.desht.pneumaticcraft.client.gui.widget.IGuiWidget) ArrayList(java.util.ArrayList) AreaType(me.desht.pneumaticcraft.common.progwidgets.area.AreaType) AreaTypeWidgetEnum(me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidgetEnum) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) AreaTypeWidget(me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidget) WidgetComboBox(me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox)

Aggregations

AreaType (me.desht.pneumaticcraft.common.progwidgets.area.AreaType)3 ArrayList (java.util.ArrayList)2 GuiRadioButton (me.desht.pneumaticcraft.client.gui.widget.GuiRadioButton)2 WidgetComboBox (me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox)2 GuiButtonSpecial (me.desht.pneumaticcraft.client.gui.GuiButtonSpecial)1 IGuiWidget (me.desht.pneumaticcraft.client.gui.widget.IGuiWidget)1 WidgetLabel (me.desht.pneumaticcraft.client.gui.widget.WidgetLabel)1 WidgetTextFieldNumber (me.desht.pneumaticcraft.client.gui.widget.WidgetTextFieldNumber)1 AreaTypeWidget (me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidget)1 AreaTypeWidgetEnum (me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidgetEnum)1 AreaTypeWidgetInteger (me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidgetInteger)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1