Search in sources :

Example 1 with ICondition

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

the class GuiProgWidgetCondition method initGui.

@Override
public void initGui() {
    super.initGui();
    if (isSidedWidget()) {
        for (int i = 0; i < 6; i++) {
            String sideName = PneumaticCraftUtils.getOrientationName(EnumFacing.getFront(i));
            GuiCheckBox checkBox = new GuiCheckBox(i, guiLeft + 4, guiTop + 30 + i * 12, 0xFF404040, sideName);
            checkBox.checked = ((ISidedWidget) widget).getSides()[i];
            addWidget(checkBox);
        }
    }
    int baseX = isSidedWidget() ? 90 : 4;
    int baseY = isUsingAndOr() ? 60 : 30;
    List<GuiRadioButton> radioButtons;
    GuiRadioButton radioButton;
    if (isUsingAndOr()) {
        radioButtons = new ArrayList<>();
        radioButton = new GuiRadioButton(6, guiLeft + baseX, guiTop + 30, 0xFF404040, "Any block");
        radioButton.checked = !((ICondition) widget).isAndFunction();
        addWidget(radioButton);
        radioButtons.add(radioButton);
        radioButton.otherChoices = radioButtons;
        radioButton = new GuiRadioButton(7, guiLeft + baseX, guiTop + 42, 0xFF404040, "All blocks");
        radioButton.checked = ((ICondition) widget).isAndFunction();
        addWidget(radioButton);
        radioButtons.add(radioButton);
        radioButton.otherChoices = radioButtons;
    }
    if (requiresNumber()) {
        radioButtons = new ArrayList<>();
        for (int i = 0; i < ICondition.Operator.values().length; i++) {
            radioButton = new GuiRadioButton(8 + i, guiLeft + baseX, guiTop + baseY + i * 12, 0xFF404040, ICondition.Operator.values()[i].toString());
            radioButton.checked = ((ICondition) widget).getOperator().ordinal() == i;
            addWidget(radioButton);
            radioButtons.add(radioButton);
            radioButton.otherChoices = radioButtons;
        }
        textField = new WidgetTextField(Minecraft.getMinecraft().fontRenderer, guiLeft + baseX, guiTop + baseY + 30, 50, 11);
        textField.setText(((ICondition) widget).getRequiredCount() + "");
        addWidget(textField);
    }
}
Also used : ISidedWidget(me.desht.pneumaticcraft.common.progwidgets.ISidedWidget) GuiCheckBox(me.desht.pneumaticcraft.client.gui.widget.GuiCheckBox) GuiRadioButton(me.desht.pneumaticcraft.client.gui.widget.GuiRadioButton) ICondition(me.desht.pneumaticcraft.common.progwidgets.ICondition) WidgetTextField(me.desht.pneumaticcraft.client.gui.widget.WidgetTextField)

Aggregations

GuiCheckBox (me.desht.pneumaticcraft.client.gui.widget.GuiCheckBox)1 GuiRadioButton (me.desht.pneumaticcraft.client.gui.widget.GuiRadioButton)1 WidgetTextField (me.desht.pneumaticcraft.client.gui.widget.WidgetTextField)1 ICondition (me.desht.pneumaticcraft.common.progwidgets.ICondition)1 ISidedWidget (me.desht.pneumaticcraft.common.progwidgets.ISidedWidget)1