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());
}
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:"));
}
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;
}
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);
}
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);
}
}
}
Aggregations