Search in sources :

Example 1 with WPressable

use of meteordevelopment.meteorclient.gui.widgets.pressable.WPressable in project meteor-client by MeteorDevelopment.

the class LeftRightListSettingScreen method abc.

private WTable abc(Consumer<List<Pair<T, Integer>>> addValues, boolean isLeft, Consumer<T> buttonAction) {
    // Create
    Cell<WTable> cell = this.table.add(theme.table()).top();
    WTable table = cell.widget();
    Consumer<T> forEach = t -> {
        if (!includeValue(t))
            return;
        table.add(getValueWidget(t));
        WPressable button = table.add(isLeft ? theme.plus() : theme.minus()).expandCellX().right().widget();
        button.action = () -> buttonAction.accept(t);
        table.row();
    };
    // Sort
    List<Pair<T, Integer>> values = new ArrayList<>();
    addValues.accept(values);
    if (!filterText.isEmpty())
        values.sort(Comparator.comparingInt(value -> -value.getRight()));
    for (Pair<T, Integer> pair : values) forEach.accept(pair.getLeft());
    if (table.cells.size() > 0)
        cell.expandX();
    return table;
}
Also used : WTextBox(meteordevelopment.meteorclient.gui.widgets.input.WTextBox) Setting(meteordevelopment.meteorclient.settings.Setting) Pair(net.minecraft.util.Pair) GuiTheme(meteordevelopment.meteorclient.gui.GuiTheme) WPressable(meteordevelopment.meteorclient.gui.widgets.pressable.WPressable) Collection(java.util.Collection) Cell(meteordevelopment.meteorclient.gui.utils.Cell) WTable(meteordevelopment.meteorclient.gui.widgets.containers.WTable) Registry(net.minecraft.util.registry.Registry) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) List(java.util.List) WindowScreen(meteordevelopment.meteorclient.gui.WindowScreen) Comparator(java.util.Comparator) WWidget(meteordevelopment.meteorclient.gui.widgets.WWidget) Utils(meteordevelopment.meteorclient.utils.Utils) WPressable(meteordevelopment.meteorclient.gui.widgets.pressable.WPressable) WTable(meteordevelopment.meteorclient.gui.widgets.containers.WTable) ArrayList(java.util.ArrayList) Pair(net.minecraft.util.Pair)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 GuiTheme (meteordevelopment.meteorclient.gui.GuiTheme)1 WindowScreen (meteordevelopment.meteorclient.gui.WindowScreen)1 Cell (meteordevelopment.meteorclient.gui.utils.Cell)1 WWidget (meteordevelopment.meteorclient.gui.widgets.WWidget)1 WTable (meteordevelopment.meteorclient.gui.widgets.containers.WTable)1 WTextBox (meteordevelopment.meteorclient.gui.widgets.input.WTextBox)1 WPressable (meteordevelopment.meteorclient.gui.widgets.pressable.WPressable)1 Setting (meteordevelopment.meteorclient.settings.Setting)1 Utils (meteordevelopment.meteorclient.utils.Utils)1 Pair (net.minecraft.util.Pair)1 Registry (net.minecraft.util.registry.Registry)1