Search in sources :

Example 21 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFTools by McJty.

the class GuiDimletFilter method initGui.

@Override
public void initGui() {
    super.initGui();
    Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout());
    int[] inputMode = tileEntity.getInputMode();
    int[] minRarity = tileEntity.getMinRarity();
    int[] maxRarity = tileEntity.getMaxRarity();
    int[] craftableI = tileEntity.getCraftable();
    DimletType[] dimletTypes = tileEntity.getTypes();
    for (ForgeDirection direction : ForgeDirection.values()) {
        if (!ForgeDirection.UNKNOWN.equals(direction)) {
            final int side = direction.ordinal();
            Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(2).setHorizontalMargin(2)).setLayoutHint(new PositionalLayout.PositionalHint(18, 21 + side * 13, 190, 12));
            ImageChoiceLabel choiceLabel = new ImageChoiceLabel(mc, this).setDesiredWidth(12).setDesiredHeight(12).addChoice("0", "Disabled", iconGuiElements, 160, 0).addChoice("1", "Input", iconGuiElements, 96, 16).addChoice("2", "Output", iconGuiElements, 80, 16);
            bits[side] = choiceLabel;
            choiceLabel.setCurrentChoice(inputMode[side]);
            choiceLabel.addChoiceEvent(new ChoiceEvent() {

                @Override
                public void choiceChanged(Widget parent, String newChoice) {
                    changeMode(side);
                }
            });
            Label minLabel = new Label(mc, this).setText("R:");
            minText[side] = new TextField(mc, this).setDesiredHeight(12).setDesiredWidth(20).addTextEvent(new TextEvent() {

                @Override
                public void textChanged(Widget parent, String newText) {
                    setMinimumRarity(side);
                }
            });
            minText[side].setText(Integer.toString(minRarity[side]));
            maxText[side] = new TextField(mc, this).setDesiredHeight(12).setDesiredWidth(20).addTextEvent(new TextEvent() {

                @Override
                public void textChanged(Widget parent, String newText) {
                    setMaximumRarity(side);
                }
            });
            maxText[side].setText(Integer.toString(maxRarity[side]));
            types[side] = new ChoiceLabel(mc, this).setDesiredHeight(12).setDesiredWidth(83).setTooltips("Filter based on type", "of the dimlet");
            types[side].addChoices("*");
            for (DimletType type : DimletType.values()) {
                types[side].addChoices(type.dimletType.getName());
            }
            if (dimletTypes[side] == null) {
                types[side].setChoice("*");
            } else {
                types[side].setChoice(dimletTypes[side].dimletType.getName());
            }
            types[side].addChoiceEvent(new ChoiceEvent() {

                @Override
                public void choiceChanged(Widget parent, String newChoice) {
                    setType(side);
                }
            });
            craftable[side] = new ChoiceLabel(mc, this).setDesiredHeight(12).setDesiredWidth(26).setTooltips("Filter based on craftability", "of the dimlet");
            craftable[side].addChoices("*", "Y", "N");
            if (craftableI[side] == DimletFilterTileEntity.CRAFTABLE_DONTCARE) {
                craftable[side].setChoice("*");
            } else if (craftableI[side] == DimletFilterTileEntity.CRAFTABLE_YES) {
                craftable[side].setChoice("Y");
            } else {
                craftable[side].setChoice("N");
            }
            craftable[side].addChoiceEvent(new ChoiceEvent() {

                @Override
                public void choiceChanged(Widget parent, String newChoice) {
                    setCraftable(side);
                }
            });
            panel.addChild(choiceLabel).addChild(minLabel).addChild(minText[side]).addChild(maxText[side]).addChild(types[side]).addChild(craftable[side]);
            toplevel.addChild(panel);
        }
    }
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
}
Also used : Window(mcjty.lib.gui.Window) TextEvent(mcjty.lib.gui.events.TextEvent) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) DimletType(mcjty.rftools.items.dimlets.DimletType) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) TextField(mcjty.lib.gui.widgets.TextField)

Example 22 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFTools by McJty.

the class GuiItemFilter method initGui.

@Override
public void initGui() {
    super.initGui();
    Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout());
    int[] inputMode = tileEntity.getInputMode();
    int[] outputMode = tileEntity.getOutputMode();
    for (ForgeDirection direction : ForgeDirection.values()) {
        if (!ForgeDirection.UNKNOWN.equals(direction)) {
            final int side = direction.ordinal();
            for (int slot = 0; slot < ItemFilterContainer.BUFFER_SIZE; slot++) {
                ImageChoiceLabel choiceLabel = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(25 + slot * 18, 4 + side * 13, 12, 12)).addChoice("0", "Disabled", iconGuiElements, 160, 0).addChoice("1", "Input", iconGuiElements, 96, 16).addChoice("2", "Output", iconGuiElements, 80, 16);
                bits[side * ItemFilterContainer.BUFFER_SIZE + slot] = choiceLabel;
                if ((inputMode[side] & (1 << slot)) != 0) {
                    choiceLabel.setCurrentChoice(1);
                } else if ((outputMode[side] & (1 << slot)) != 0) {
                    choiceLabel.setCurrentChoice(2);
                } else {
                    choiceLabel.setCurrentChoice(0);
                }
                final int finalSlot = slot;
                choiceLabel.addChoiceEvent(new ChoiceEvent() {

                    @Override
                    public void choiceChanged(Widget parent, String newChoice) {
                        changeMode(side, finalSlot);
                    }
                });
                toplevel.addChild(choiceLabel);
            }
        }
    }
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
}
Also used : Window(mcjty.lib.gui.Window) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Widget(mcjty.lib.gui.widgets.Widget) ImageChoiceLabel(mcjty.lib.gui.widgets.ImageChoiceLabel) Panel(mcjty.lib.gui.widgets.Panel) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 23 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFTools by McJty.

the class GuiShapeCard method initGui.

@Override
public void initGui() {
    super.initGui();
    shapeLabel = new ChoiceLabel(mc, this).setDesiredWidth(100).setDesiredHeight(16).addChoices(ShapeCardItem.Shape.SHAPE_BOX.getDescription(), ShapeCardItem.Shape.SHAPE_TOPDOME.getDescription(), ShapeCardItem.Shape.SHAPE_BOTTOMDOME.getDescription(), ShapeCardItem.Shape.SHAPE_SPHERE.getDescription(), ShapeCardItem.Shape.SHAPE_CYLINDER.getDescription(), ShapeCardItem.Shape.SHAPE_CAPPEDCYLINDER.getDescription(), ShapeCardItem.Shape.SHAPE_PRISM.getDescription(), ShapeCardItem.Shape.SHAPE_TORUS.getDescription(), ShapeCardItem.Shape.SHAPE_SOLIDBOX.getDescription(), ShapeCardItem.Shape.SHAPE_SOLIDSPHERE.getDescription(), ShapeCardItem.Shape.SHAPE_SOLIDCYLINDER.getDescription(), ShapeCardItem.Shape.SHAPE_SOLIDTORUS.getDescription()).addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateSettings();
        }
    });
    ItemStack heldItem = mc.thePlayer.getHeldItem();
    if (heldItem == null) {
        // Cannot happen!
        return;
    }
    isQuarryCard = ShapeCardItem.isQuarry(heldItem.getItemDamage());
    if (isQuarryCard) {
        ySize = 46 + 28;
    }
    ShapeCardItem.Shape shape = ShapeCardItem.getShape(heldItem);
    shapeLabel.setChoice(shape.getDescription());
    blocksLabel = new Label(mc, this).setText("# ").setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT);
    blocksLabel.setDesiredWidth(100).setDesiredHeight(16);
    Panel modePanel = new Panel(mc, this).setLayout(new VerticalLayout()).setDesiredWidth(100).addChild(shapeLabel).addChild(blocksLabel);
    Coordinate dim = ShapeCardItem.getDimension(heldItem);
    Coordinate offset = ShapeCardItem.getOffset(heldItem);
    dimX = new TextField(mc, this).addTextEvent(new TextEvent() {

        @Override
        public void textChanged(Widget parent, String newText) {
            if (isTorus()) {
                dimZ.setText(newText);
            }
            updateSettings();
        }
    }).setText(String.valueOf(dim.getX()));
    dimY = new TextField(mc, this).addTextEvent(new TextEvent() {

        @Override
        public void textChanged(Widget parent, String newText) {
            updateSettings();
        }
    }).setText(String.valueOf(dim.getY()));
    dimZ = new TextField(mc, this).addTextEvent(new TextEvent() {

        @Override
        public void textChanged(Widget parent, String newText) {
            updateSettings();
        }
    }).setText(String.valueOf(dim.getZ()));
    Panel dimPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0)).addChild(new Label(mc, this).setText("Dim:").setHorizontalAlignment(HorizontalAlignment.ALIGN_RIGHT).setDesiredWidth(70)).setDesiredHeight(18).addChild(dimX).addChild(dimY).addChild(dimZ);
    offsetX = new TextField(mc, this).addTextEvent(new TextEvent() {

        @Override
        public void textChanged(Widget parent, String newText) {
            updateSettings();
        }
    }).setText(String.valueOf(offset.getX()));
    offsetY = new TextField(mc, this).addTextEvent(new TextEvent() {

        @Override
        public void textChanged(Widget parent, String newText) {
            updateSettings();
        }
    }).setText(String.valueOf(offset.getY()));
    offsetZ = new TextField(mc, this).addTextEvent(new TextEvent() {

        @Override
        public void textChanged(Widget parent, String newText) {
            updateSettings();
        }
    }).setText(String.valueOf(offset.getZ()));
    Panel offsetPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0)).addChild(new Label(mc, this).setText("Offset:").setHorizontalAlignment(HorizontalAlignment.ALIGN_RIGHT).setDesiredWidth(70)).setDesiredHeight(18).addChild(offsetX).addChild(offsetY).addChild(offsetZ);
    Panel settingsPanel = new Panel(mc, this).setLayout(new VerticalLayout().setSpacing(1).setVerticalMargin(1).setHorizontalMargin(0)).addChild(dimPanel).addChild(offsetPanel);
    int k = (this.width - this.xSize) / 2;
    int l = (this.height - this.ySize) / 2;
    Panel modeSettingsPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0)).addChild(modePanel).addChild(settingsPanel);
    Widget toplevel;
    if (isQuarryCard) {
        setupVoidPanel(heldItem);
        toplevel = new Panel(mc, this).setLayout(new VerticalLayout()).setFilledRectThickness(2).addChild(modeSettingsPanel).addChild(voidPanel);
    } else {
        toplevel = new Panel(mc, this).setLayout(new VerticalLayout()).setFilledRectThickness(2).addChild(modeSettingsPanel);
    }
    toplevel.setBounds(new Rectangle(k, l, xSize, ySize));
    window = new Window(this, toplevel);
}
Also used : Window(mcjty.lib.gui.Window) TextEvent(mcjty.lib.gui.events.TextEvent) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) Coordinate(mcjty.lib.varia.Coordinate) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) TextField(mcjty.lib.gui.widgets.TextField) ItemStack(net.minecraft.item.ItemStack)

Example 24 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFTools by McJty.

the class GuiStorageFilter method initGui.

@Override
public void initGui() {
    super.initGui();
    blacklistMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(130, 9, 16, 16)).setTooltips("Black or whitelist mode").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateSettings();
        }
    });
    blacklistMode.addChoice("Black", "Blacklist items", guiElements, 14 * 16, 32);
    blacklistMode.addChoice("White", "Whitelist items", guiElements, 15 * 16, 32);
    oredictMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(148, 9, 16, 16)).setTooltips("Filter based on ore dictionary").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateSettings();
        }
    });
    oredictMode.addChoice("Off", "Oredict matching off", guiElements, 10 * 16, 32);
    oredictMode.addChoice("On", "Oredict matching on", guiElements, 11 * 16, 32);
    damageMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(130, 27, 16, 16)).setTooltips("Filter ignoring damage").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateSettings();
        }
    });
    damageMode.addChoice("Off", "Ignore damage", guiElements, 6 * 16, 32);
    damageMode.addChoice("On", "Damage must match", guiElements, 7 * 16, 32);
    nbtMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(148, 27, 16, 16)).setTooltips("Filter ignoring NBT").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateSettings();
        }
    });
    nbtMode.addChoice("Off", "Ignore MBT", guiElements, 8 * 16, 32);
    nbtMode.addChoice("On", "NBT must match", guiElements, 9 * 16, 32);
    modMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(130, 45, 16, 16)).setTooltips("Filter ignoring mod").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateSettings();
        }
    });
    modMode.addChoice("Off", "Don't match on mod", guiElements, 12 * 16, 32);
    modMode.addChoice("On", "Only mod must match", guiElements, 13 * 16, 32);
    NBTTagCompound tagCompound = Minecraft.getMinecraft().thePlayer.getHeldItem().getTagCompound();
    if (tagCompound != null) {
        setBlacklistMode(tagCompound.getString("blacklistMode"));
        oredictMode.setCurrentChoice(tagCompound.getBoolean("oredictMode") ? 1 : 0);
        damageMode.setCurrentChoice(tagCompound.getBoolean("damageMode") ? 1 : 0);
        nbtMode.setCurrentChoice(tagCompound.getBoolean("nbtMode") ? 1 : 0);
        modMode.setCurrentChoice(tagCompound.getBoolean("modMode") ? 1 : 0);
    }
    Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(iconLocation).addChild(blacklistMode).addChild(oredictMode).addChild(damageMode).addChild(nbtMode).addChild(modMode);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) Widget(mcjty.lib.gui.widgets.Widget) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) ImageChoiceLabel(mcjty.lib.gui.widgets.ImageChoiceLabel)

Example 25 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFTools by McJty.

the class GuiModularStorage method setupModePanel.

private Panel setupModePanel() {
    filter = new TextField(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(3, 3, 57, 13)).setTooltips("Name based filter for items").addTextEvent(new TextEvent() {

        @Override
        public void textChanged(Widget parent, String newText) {
            updateSettings();
        }
    });
    viewMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(4, 19, 16, 16)).setTooltips("Control how items are shown", "in the view").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateSettings();
        }
    });
    viewMode.addChoice(VIEW_LIST, "Items are shown in a list view", guiElements, 9 * 16, 16);
    viewMode.addChoice(VIEW_COLUMNS, "Items are shown in columns", guiElements, 10 * 16, 16);
    viewMode.addChoice(VIEW_ICONS, "Items are shown with icons", guiElements, 11 * 16, 16);
    updateTypeModule();
    sortMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(23, 19, 16, 16)).setTooltips("Control how items are sorted", "in the view").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateSettings();
        }
    });
    for (ItemSorter sorter : typeModule.getSorters()) {
        sortMode.addChoice(sorter.getName(), sorter.getTooltip(), guiElements, sorter.getU(), sorter.getV());
    }
    groupMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(42, 19, 16, 16)).setTooltips("If enabled it will show groups", "based on sorting criterium").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateSettings();
        }
    });
    groupMode.addChoice("Off", "Don't show groups", guiElements, 13 * 16, 0);
    groupMode.addChoice("On", "Show groups", guiElements, 14 * 16, 0);
    amountLabel = new Label(mc, this);
    amountLabel.setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT);
    amountLabel.setLayoutHint(new PositionalLayout.PositionalHint(16, 40, 66, 12));
    amountLabel.setTooltips("Amount of stacks / maximum amount");
    amountLabel.setText("?/?");
    compactButton = new Button(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(4, 39, 12, 12)).setText("z").setTooltips("Compact equal stacks").addButtonEvent(new ButtonEvent() {

        @Override
        public void buttonClicked(Widget parent) {
            compact();
        }
    });
    if (tileEntity != null) {
        filter.setText(ModularStorageConfiguration.clearSearchOnOpen ? "" : tileEntity.getFilter());
        setViewMode(tileEntity.getViewMode());
        setSortMode(tileEntity.getSortMode());
        groupMode.setCurrentChoice(tileEntity.isGroupMode() ? 1 : 0);
    } else {
        NBTTagCompound tagCompound = Minecraft.getMinecraft().thePlayer.getHeldItem().getTagCompound();
        filter.setText(ModularStorageConfiguration.clearSearchOnOpen ? "" : tagCompound.getString("filter"));
        setViewMode(tagCompound.getString("viewMode"));
        setSortMode(tagCompound.getString("sortMode"));
        groupMode.setCurrentChoice(tagCompound.getBoolean("groupMode") ? 1 : 0);
    }
    return new Panel(mc, this).setLayout(new PositionalLayout()).setLayoutHint(new PositionalLayout.PositionalHint(24, ySize - 80, 64, 77)).setFilledRectThickness(-2).setFilledBackground(StyleConfig.colorListBackground).addChild(filter).addChild(viewMode).addChild(sortMode).addChild(groupMode).addChild(amountLabel).addChild(compactButton);
}
Also used : TextEvent(mcjty.lib.gui.events.TextEvent) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) Label(mcjty.lib.gui.widgets.Label) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) ButtonEvent(mcjty.lib.gui.events.ButtonEvent) TextField(mcjty.lib.gui.widgets.TextField) ItemSorter(mcjty.rftools.blocks.storage.sorters.ItemSorter)

Aggregations

ChoiceEvent (mcjty.lib.gui.events.ChoiceEvent)33 Panel (mcjty.lib.gui.widgets.Panel)19 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)15 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)14 Window (mcjty.lib.gui.Window)12 Label (mcjty.lib.gui.widgets.Label)9 TextField (mcjty.lib.gui.widgets.TextField)9 TextEvent (mcjty.lib.gui.events.TextEvent)8 VerticalLayout (mcjty.lib.gui.layout.VerticalLayout)7 Button (mcjty.lib.gui.widgets.Button)7 ButtonEvent (mcjty.lib.gui.events.ButtonEvent)6 ColorChoiceEvent (mcjty.lib.gui.events.ColorChoiceEvent)6 Widget (mcjty.lib.gui.widgets.Widget)5 ImageChoiceLabel (mcjty.lib.gui.widgets.ImageChoiceLabel)4 Coordinate (mcjty.lib.varia.Coordinate)4 ValueEvent (mcjty.lib.gui.events.ValueEvent)3 DefaultSelectionEvent (mcjty.lib.gui.events.DefaultSelectionEvent)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 HashMap (java.util.HashMap)1