Search in sources :

Example 1 with WidgetComboBox

use of me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox in project pnc-repressurized by TeamPneumatic.

the class GuiProgWidgetCoordinateOperator method initGui.

@Override
public void initGui() {
    super.initGui();
    List<GuiRadioButton> radioButtons = new ArrayList<GuiRadioButton>();
    for (int i = 0; i < EnumOperator.values().length; i++) {
        GuiRadioButton radioButton = new GuiRadioButton(i, guiLeft + 7, guiTop + 42 + 12 * i, 0xFF404040, I18n.format(EnumOperator.values()[i].getUnlocalizedName()));
        radioButtons.add(radioButton);
        radioButton.checked = widget.getOperator().ordinal() == i;
        radioButton.otherChoices = radioButtons;
        addWidget(radioButton);
    }
    variableField = new WidgetComboBox(fontRenderer, guiLeft + 90, guiTop + 42, 80, fontRenderer.FONT_HEIGHT + 1);
    variableField.setElements(guiProgrammer.te.getAllVariables());
    addWidget(variableField);
    variableField.setText(widget.getVariable());
}
Also used : ArrayList(java.util.ArrayList) GuiRadioButton(me.desht.pneumaticcraft.client.gui.widget.GuiRadioButton) WidgetComboBox(me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox)

Example 2 with WidgetComboBox

use of me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox in project pnc-repressurized by TeamPneumatic.

the class GuiProgWidgetItemAssign method initGui.

@Override
public void initGui() {
    super.initGui();
    textfield = new WidgetComboBox(fontRenderer, guiLeft + 10, guiTop + 40, 160, 10);
    textfield.setElements(guiProgrammer.te.getAllVariables());
    textfield.setMaxStringLength(1000);
    textfield.setText(widget.getVariable());
    addWidget(textfield);
    addWidget(new WidgetLabel(guiLeft + 10, guiTop + 30, "Setting variable:"));
}
Also used : WidgetLabel(me.desht.pneumaticcraft.client.gui.widget.WidgetLabel) WidgetComboBox(me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox)

Example 3 with WidgetComboBox

use of me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox in project pnc-repressurized by TeamPneumatic.

the class ActionWidgetDropdown method getWidget.

@Override
public WidgetComboBox getWidget() {
    if (widget == null) {
        widget = new WidgetComboBox(Minecraft.getMinecraft().fontRenderer, x, y, width, height);
        widget.setElements(getDropdownElements());
        widget.setFixedOptions();
        updateWidget();
    }
    return widget;
}
Also used : WidgetComboBox(me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox)

Example 4 with WidgetComboBox

use of me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox 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 5 with WidgetComboBox

use of me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox in project pnc-repressurized by TeamPneumatic.

the class GuiProgWidgetArea method saveWidgets.

private void saveWidgets() {
    for (Pair<AreaTypeWidget, IGuiWidget> entry : areaTypeValueWidgets) {
        AreaTypeWidget widget = entry.getLeft();
        IGuiWidget guiWidget = entry.getRight();
        if (widget instanceof AreaTypeWidgetInteger) {
            AreaTypeWidgetInteger intWidget = (AreaTypeWidgetInteger) widget;
            intWidget.writeAction.accept(((WidgetTextFieldNumber) guiWidget).getValue());
        } else if (widget instanceof AreaTypeWidgetEnum<?>) {
            @SuppressWarnings("unchecked") AreaTypeWidgetEnum<Enum<?>> enumWidget = (AreaTypeWidgetEnum<Enum<?>>) widget;
            WidgetComboBox cbb = (WidgetComboBox) guiWidget;
            List<String> enumNames = getEnumNames(enumWidget.enumClass);
            Object[] enumValues = enumWidget.enumClass.getEnumConstants();
            Object selectedValue = enumValues[enumNames.indexOf(cbb.getText())];
            enumWidget.writeAction.accept((Enum<?>) selectedValue);
        }
    }
}
Also used : AreaTypeWidgetEnum(me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidgetEnum) AreaTypeWidgetInteger(me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidgetInteger) AreaTypeWidget(me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidget) IGuiWidget(me.desht.pneumaticcraft.client.gui.widget.IGuiWidget) ArrayList(java.util.ArrayList) List(java.util.List) AreaTypeWidgetEnum(me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidgetEnum) WidgetComboBox(me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox)

Aggregations

WidgetComboBox (me.desht.pneumaticcraft.client.gui.widget.WidgetComboBox)11 ArrayList (java.util.ArrayList)4 GuiCheckBox (me.desht.pneumaticcraft.client.gui.widget.GuiCheckBox)2 GuiRadioButton (me.desht.pneumaticcraft.client.gui.widget.GuiRadioButton)2 IGuiWidget (me.desht.pneumaticcraft.client.gui.widget.IGuiWidget)2 WidgetLabel (me.desht.pneumaticcraft.client.gui.widget.WidgetLabel)2 WidgetTextFieldNumber (me.desht.pneumaticcraft.client.gui.widget.WidgetTextFieldNumber)2 AreaType (me.desht.pneumaticcraft.common.progwidgets.area.AreaType)2 AreaTypeWidget (me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidget)2 AreaTypeWidgetEnum (me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidgetEnum)2 AreaTypeWidgetInteger (me.desht.pneumaticcraft.common.progwidgets.area.AreaType.AreaTypeWidgetInteger)2 ItemStack (net.minecraft.item.ItemStack)2 List (java.util.List)1 GuiButtonSpecial (me.desht.pneumaticcraft.client.gui.GuiButtonSpecial)1 WidgetTextField (me.desht.pneumaticcraft.client.gui.widget.WidgetTextField)1 PacketUpdateRemoteLayout (me.desht.pneumaticcraft.common.network.PacketUpdateRemoteLayout)1 IActionWidgetLabeled (me.desht.pneumaticcraft.common.remote.IActionWidgetLabeled)1 GuiButton (net.minecraft.client.gui.GuiButton)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 BlockPos (net.minecraft.util.math.BlockPos)1