Search in sources :

Example 1 with WTable

use of meteordevelopment.meteorclient.gui.widgets.containers.WTable in project meteor-rejects by AntiCope.

the class ChatBot method getWidget.

@Override
public WWidget getWidget(GuiTheme theme) {
    WTable table = theme.table();
    fillTable(theme, table);
    return table;
}
Also used : WTable(meteordevelopment.meteorclient.gui.widgets.containers.WTable)

Example 2 with WTable

use of meteordevelopment.meteorclient.gui.widgets.containers.WTable in project meteor-rejects by AntiCope.

the class HeadScreen method loadHeads.

private void loadHeads() {
    MeteorExecutor.execute(() -> {
        List<Map<String, String>> res = Http.get("https://minecraft-heads.com/scripts/api.php?cat=" + getCat()).sendJson(gsonType);
        List<ItemStack> heads = new ArrayList<>();
        res.forEach(a -> {
            try {
                heads.add(createHeadStack(a.get("uuid"), a.get("value"), a.get("name")));
            } catch (Exception e) {
            }
        });
        WTable t = theme.table();
        for (ItemStack head : heads) {
            t.add(theme.item(head));
            t.add(theme.label(head.getName().asString()));
            WButton give = t.add(theme.button("Give")).widget();
            give.action = () -> {
                try {
                    GiveUtils.giveItem(head);
                } catch (CommandSyntaxException e) {
                    ChatUtils.error("Heads", e.getMessage());
                }
            };
            WButton equip = t.add(theme.button("Equip")).widget();
            equip.tooltip = "Equip client-side.";
            equip.action = () -> {
                mc.player.getInventory().armor.set(3, head);
            };
            t.row();
        }
        set();
        add(t).expandX().minWidth(400).widget();
    });
}
Also used : WTable(meteordevelopment.meteorclient.gui.widgets.containers.WTable) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) WButton(meteordevelopment.meteorclient.gui.widgets.pressable.WButton) Map(java.util.Map) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException)

Example 3 with WTable

use of meteordevelopment.meteorclient.gui.widgets.containers.WTable in project meteor-client by MeteorDevelopment.

the class ProxiesScreen method initWidgets.

@Override
public void initWidgets() {
    // Proxies
    WTable table = add(theme.table()).expandX().widget();
    for (Proxy proxy : Proxies.get()) {
        // Enabled
        WCheckbox enabled = table.add(theme.checkbox(proxy.enabled)).widget();
        checkboxes.add(enabled);
        enabled.action = () -> {
            boolean checked = enabled.checked;
            Proxies.get().setEnabled(proxy, checked);
            for (WCheckbox checkbox : checkboxes) checkbox.checked = false;
            enabled.checked = checked;
        };
        // Name
        WLabel name = table.add(theme.label(proxy.name)).widget();
        name.color = theme.textColor();
        // Type
        WLabel type = table.add(theme.label("(" + proxy.type + ")")).widget();
        type.color = theme.textSecondaryColor();
        // IP + Port
        WHorizontalList ipList = table.add(theme.horizontalList()).expandCellX().widget();
        ipList.spacing = 0;
        ipList.add(theme.label(proxy.address));
        ipList.add(theme.label(":")).widget().color = theme.textSecondaryColor();
        ipList.add(theme.label(Integer.toString(proxy.port)));
        // Edit
        WButton edit = table.add(theme.button(GuiRenderer.EDIT)).widget();
        edit.action = () -> openEditProxyScreen(proxy);
        // Remove
        WMinus remove = table.add(theme.minus()).widget();
        remove.action = () -> {
            Proxies.get().remove(proxy);
            reload();
        };
        table.row();
    }
    WHorizontalList l = add(theme.horizontalList()).expandX().widget();
    // New
    WButton newBtn = l.add(theme.button("New")).expandX().widget();
    newBtn.action = () -> openEditProxyScreen(null);
    // Import
    PointerBuffer filters = BufferUtils.createPointerBuffer(1);
    ByteBuffer txtFilter = MemoryUtil.memASCII("*.txt");
    filters.put(txtFilter);
    filters.rewind();
    WButton importBtn = l.add(theme.button("Import")).expandX().widget();
    importBtn.action = () -> {
        String selectedFile = TinyFileDialogs.tinyfd_openFileDialog("Import Proxies", null, filters, null, false);
        if (selectedFile != null) {
            File file = new File(selectedFile);
            mc.setScreen(new ProxiesImportScreen(theme, file));
        }
    };
}
Also used : PointerBuffer(org.lwjgl.PointerBuffer) WButton(meteordevelopment.meteorclient.gui.widgets.pressable.WButton) WCheckbox(meteordevelopment.meteorclient.gui.widgets.pressable.WCheckbox) ByteBuffer(java.nio.ByteBuffer) WLabel(meteordevelopment.meteorclient.gui.widgets.WLabel) Proxy(meteordevelopment.meteorclient.systems.proxies.Proxy) WTable(meteordevelopment.meteorclient.gui.widgets.containers.WTable) WMinus(meteordevelopment.meteorclient.gui.widgets.pressable.WMinus) File(java.io.File) WHorizontalList(meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList)

Example 4 with WTable

use of meteordevelopment.meteorclient.gui.widgets.containers.WTable 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)

Example 5 with WTable

use of meteordevelopment.meteorclient.gui.widgets.containers.WTable in project meteor-client by MeteorDevelopment.

the class LeftRightListSettingScreen method initWidgets.

private void initWidgets(Registry<T> registry) {
    // Left (all)
    WTable left = abc(pairs -> registry.forEach(t -> {
        if (skipValue(t) || collection.contains(t))
            return;
        int words = Utils.search(getValueName(t), filterText);
        if (words > 0)
            pairs.add(new Pair<>(t, words));
    }), true, t -> {
        addValue(registry, t);
        T v = getAdditionalValue(t);
        if (v != null)
            addValue(registry, v);
    });
    if (left.cells.size() > 0)
        table.add(theme.verticalSeparator()).expandWidgetY();
    // Right (selected)
    abc(pairs -> {
        for (T value : collection) {
            if (skipValue(value))
                continue;
            int words = Utils.search(getValueName(value), filterText);
            if (words > 0)
                pairs.add(new Pair<>(value, words));
        }
    }, false, t -> {
        removeValue(registry, t);
        T v = getAdditionalValue(t);
        if (v != null)
            removeValue(registry, v);
    });
}
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) WTable(meteordevelopment.meteorclient.gui.widgets.containers.WTable) Pair(net.minecraft.util.Pair)

Aggregations

WTable (meteordevelopment.meteorclient.gui.widgets.containers.WTable)10 WTextBox (meteordevelopment.meteorclient.gui.widgets.input.WTextBox)5 ArrayList (java.util.ArrayList)4 WButton (meteordevelopment.meteorclient.gui.widgets.pressable.WButton)4 Collection (java.util.Collection)2 Comparator (java.util.Comparator)2 List (java.util.List)2 Consumer (java.util.function.Consumer)2 GuiTheme (meteordevelopment.meteorclient.gui.GuiTheme)2 WindowScreen (meteordevelopment.meteorclient.gui.WindowScreen)2 Cell (meteordevelopment.meteorclient.gui.utils.Cell)2 WWidget (meteordevelopment.meteorclient.gui.widgets.WWidget)2 WPressable (meteordevelopment.meteorclient.gui.widgets.pressable.WPressable)2 Setting (meteordevelopment.meteorclient.settings.Setting)2 Utils (meteordevelopment.meteorclient.utils.Utils)2 Pair (net.minecraft.util.Pair)2 Registry (net.minecraft.util.registry.Registry)2 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 File (java.io.File)1 IOException (java.io.IOException)1