Search in sources :

Example 1 with Cell

use of mathax.client.gui.utils.Cell in project Client by MatHax.

the class ModulesScreen method createFavorites.

// Favorites
protected Cell<WWindow> createFavorites(WContainer c) {
    boolean hasFavorites = Modules.get().getAll().stream().anyMatch(module -> module.favorite);
    if (!hasFavorites)
        return null;
    WWindow w = theme.window("Favorites");
    w.id = "favorites";
    w.padding = 0;
    w.spacing = 0;
    if (theme.categoryIcons())
        w.beforeHeaderInit = wContainer -> wContainer.add(theme.item(Items.NETHER_STAR.getDefaultStack())).pad(2);
    Cell<WWindow> cell = c.add(w);
    w.view.scrollOnlyWhenMouseOver = true;
    w.view.hasScrollBar = false;
    w.view.spacing = 0;
    createFavoritesW(w);
    return cell;
}
Also used : Utils(mathax.client.utils.Utils) WVerticalList(mathax.client.gui.widgets.containers.WVerticalList) WWindow(mathax.client.gui.widgets.containers.WWindow) GuiTheme(mathax.client.gui.GuiTheme) Set(java.util.Set) Items(net.minecraft.item.Items) WContainer(mathax.client.gui.widgets.containers.WContainer) WSection(mathax.client.gui.widgets.containers.WSection) Tabs(mathax.client.gui.tabs.Tabs) ArrayList(java.util.ArrayList) Cell(mathax.client.gui.utils.Cell) List(java.util.List) WTextBox(mathax.client.gui.widgets.input.WTextBox) TabScreen(mathax.client.gui.tabs.TabScreen) NbtUtils(mathax.client.utils.misc.NbtUtils) Category(mathax.client.systems.modules.Category) Modules(mathax.client.systems.modules.Modules) Module(mathax.client.systems.modules.Module) WWindow(mathax.client.gui.widgets.containers.WWindow)

Example 2 with Cell

use of mathax.client.gui.utils.Cell in project Client by MatHax.

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 : Utils(mathax.client.utils.Utils) Pair(net.minecraft.util.Pair) GuiTheme(mathax.client.gui.GuiTheme) Collection(java.util.Collection) Registry(net.minecraft.util.registry.Registry) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) Cell(mathax.client.gui.utils.Cell) WTable(mathax.client.gui.widgets.containers.WTable) List(java.util.List) Setting(mathax.client.settings.Setting) WTextBox(mathax.client.gui.widgets.input.WTextBox) WPressable(mathax.client.gui.widgets.pressable.WPressable) Comparator(java.util.Comparator) WindowScreen(mathax.client.gui.WindowScreen) WWidget(mathax.client.gui.widgets.WWidget) WPressable(mathax.client.gui.widgets.pressable.WPressable) WTable(mathax.client.gui.widgets.containers.WTable) ArrayList(java.util.ArrayList) Pair(net.minecraft.util.Pair)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 GuiTheme (mathax.client.gui.GuiTheme)2 Cell (mathax.client.gui.utils.Cell)2 WTextBox (mathax.client.gui.widgets.input.WTextBox)2 Utils (mathax.client.utils.Utils)2 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 Set (java.util.Set)1 Consumer (java.util.function.Consumer)1 WindowScreen (mathax.client.gui.WindowScreen)1 TabScreen (mathax.client.gui.tabs.TabScreen)1 Tabs (mathax.client.gui.tabs.Tabs)1 WWidget (mathax.client.gui.widgets.WWidget)1 WContainer (mathax.client.gui.widgets.containers.WContainer)1 WSection (mathax.client.gui.widgets.containers.WSection)1 WTable (mathax.client.gui.widgets.containers.WTable)1 WVerticalList (mathax.client.gui.widgets.containers.WVerticalList)1 WWindow (mathax.client.gui.widgets.containers.WWindow)1 WPressable (mathax.client.gui.widgets.pressable.WPressable)1