Search in sources :

Example 1 with WMinus

use of meteordevelopment.meteorclient.gui.widgets.pressable.WMinus in project meteor-rejects by AntiCope.

the class ChatBot method fillTable.

private void fillTable(GuiTheme theme, WTable table) {
    table.clear();
    commands.keySet().forEach((key) -> {
        table.add(theme.label(key)).expandCellX();
        table.add(theme.label(commands.get(key))).expandCellX();
        WMinus delete = table.add(theme.minus()).widget();
        delete.action = () -> {
            commands.remove(key);
            fillTable(theme, table);
        };
        table.row();
    });
    WTextBox textBoxK = table.add(theme.textBox(currMsgK)).minWidth(100).expandX().widget();
    textBoxK.action = () -> {
        currMsgK = textBoxK.get();
    };
    WTextBox textBoxV = table.add(theme.textBox(currMsgV)).minWidth(100).expandX().widget();
    textBoxV.action = () -> {
        currMsgV = textBoxV.get();
    };
    WPlus add = table.add(theme.plus()).widget();
    add.action = () -> {
        if (currMsgK != "" && currMsgV != "") {
            commands.put(currMsgK, currMsgV);
            currMsgK = "";
            currMsgV = "";
            fillTable(theme, table);
        }
    };
    table.row();
}
Also used : WTextBox(meteordevelopment.meteorclient.gui.widgets.input.WTextBox) WMinus(meteordevelopment.meteorclient.gui.widgets.pressable.WMinus) WPlus(meteordevelopment.meteorclient.gui.widgets.pressable.WPlus)

Example 2 with WMinus

use of meteordevelopment.meteorclient.gui.widgets.pressable.WMinus in project vector-addon by cally72jhb.

the class Placeholders method fillTable.

private void fillTable(GuiTheme theme, WTable table) {
    if (!placeholders.isEmpty()) {
        for (int i = 0; i < placeholders.size(); i++) {
            int messageI = i;
            if (placeholders.get(i) != null && placeholders.get(i).getA() != null && placeholders.get(i).getB() != null && !placeholders.get(i).getA().isEmpty() && !placeholders.get(i).getB().isEmpty()) {
                String messageA = placeholders.get(i).getA();
                String messageB = placeholders.get(i).getB();
                WTextBox left = table.add(theme.textBox(messageA)).minWidth(300).expandX().widget();
                left.action = () -> placeholders.set(messageI, new Pair<>(left.get(), messageB));
                WTextBox right = table.add(theme.textBox(messageB)).minWidth(300).expandX().widget();
                right.action = () -> placeholders.set(messageI, new Pair<>(messageA, right.get()));
                WMinus delete = table.add(theme.minus()).widget();
                delete.action = () -> {
                    placeholders.remove(messageI);
                    table.clear();
                    fillTable(theme, table);
                };
                table.row();
            } else if (placeholders.get(i) != null && placeholders.get(i).getA() == null && placeholders.get(i).getB() != null) {
                WMinus delete = table.add(theme.minus()).widget();
                delete.action = () -> {
                    placeholders.remove(messageI);
                    table.clear();
                    fillTable(theme, table);
                };
                table.add(theme.label(placeholders.get(i).getB()));
                table.row();
            }
        }
    }
    WTextBox left = table.add(theme.textBox(":example:")).minWidth(300).expandX().widget();
    WTextBox right = table.add(theme.textBox("")).minWidth(300).expandX().widget();
    WPlus add = table.add(theme.plus()).widget();
    add.action = () -> {
        placeholders.add(new Pair<>(left.get(), right.get()));
        table.clear();
        fillTable(theme, table);
    };
    table.row();
    // Reset
    WButton reset = table.add(theme.button("Reset")).widget();
    reset.action = () -> {
        resetPlaceholders();
        table.clear();
        fillTable(theme, table);
    };
    // Clear
    WButton clear = table.add(theme.button("Clear")).widget();
    clear.action = () -> {
        placeholders.clear();
        table.clear();
        fillTable(theme, table);
    };
}
Also used : NbtString(net.minecraft.nbt.NbtString) WTextBox(meteordevelopment.meteorclient.gui.widgets.input.WTextBox) WButton(meteordevelopment.meteorclient.gui.widgets.pressable.WButton) WMinus(meteordevelopment.meteorclient.gui.widgets.pressable.WMinus) WPlus(meteordevelopment.meteorclient.gui.widgets.pressable.WPlus) Pair(oshi.util.tuples.Pair)

Example 3 with WMinus

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

the class StringListSetting method fillTable.

public static void fillTable(GuiTheme theme, WTable table, StringListSetting setting) {
    setting.get().removeIf(String::isEmpty);
    ArrayList<String> strings = new ArrayList<>(setting.get());
    for (int i = 0; i < setting.get().size(); i++) {
        int msgI = i;
        String message = setting.get().get(i);
        WTextBox textBox = table.add(theme.textBox(message)).expandX().widget();
        textBox.action = () -> strings.set(msgI, textBox.get());
        textBox.actionOnUnfocused = () -> setting.set(strings);
        WMinus delete = table.add(theme.minus()).widget();
        delete.action = () -> {
            strings.remove(msgI);
            setting.set(strings);
            table.clear();
            fillTable(theme, table, setting);
        };
        table.row();
    }
    WTextBox textBox = table.add(theme.textBox(setting.newText)).minWidth(300).expandX().widget();
    textBox.action = () -> setting.newText = textBox.get();
    WPlus add = table.add(theme.plus()).widget();
    add.action = () -> {
        strings.add(setting.newText);
        setting.set(strings);
        setting.newText = "";
        table.clear();
        fillTable(theme, table, setting);
    };
    // Reset
    table.row();
    WButton reset = table.add(theme.button("Reset")).widget();
    reset.action = () -> {
        setting.reset();
        table.clear();
        fillTable(theme, table, setting);
    };
}
Also used : ArrayList(java.util.ArrayList) NbtString(net.minecraft.nbt.NbtString) WTextBox(meteordevelopment.meteorclient.gui.widgets.input.WTextBox) WButton(meteordevelopment.meteorclient.gui.widgets.pressable.WButton) WMinus(meteordevelopment.meteorclient.gui.widgets.pressable.WMinus) WPlus(meteordevelopment.meteorclient.gui.widgets.pressable.WPlus)

Example 4 with WMinus

use of meteordevelopment.meteorclient.gui.widgets.pressable.WMinus 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 5 with WMinus

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

the class Marker method fillList.

protected void fillList(GuiTheme theme, WVerticalList list) {
    // Marker List
    for (BaseMarker marker : markers) {
        WHorizontalList hList = list.add(theme.horizontalList()).expandX().widget();
        // Name
        WLabel label = hList.add(theme.label(marker.name.get())).widget();
        label.tooltip = marker.description.get();
        // Dimension
        hList.add(theme.label(" - " + marker.getDimension().toString())).expandX().widget().color = theme.textSecondaryColor();
        // Toggle
        WCheckbox checkbox = hList.add(theme.checkbox(marker.isActive())).widget();
        checkbox.action = () -> {
            if (marker.isActive() != checkbox.checked)
                marker.toggle();
        };
        // Edit
        WButton edit = hList.add(theme.button(GuiRenderer.EDIT)).widget();
        edit.action = () -> mc.setScreen(marker.getScreen(theme));
        // Remove
        WMinus remove = hList.add(theme.minus()).widget();
        remove.action = () -> {
            markers.remove(marker);
            marker.settings.unregisterColorSettings();
            list.clear();
            fillList(theme, list);
        };
    }
    // Bottom
    WHorizontalList bottom = list.add(theme.horizontalList()).expandX().widget();
    WDropdown<String> newMarker = bottom.add(theme.dropdown(factory.getNames(), factory.getNames()[0])).widget();
    WButton add = bottom.add(theme.button("Add")).expandX().widget();
    add.action = () -> {
        String name = newMarker.get();
        markers.add(factory.createMarker(name));
        list.clear();
        fillList(theme, list);
    };
}
Also used : WButton(meteordevelopment.meteorclient.gui.widgets.pressable.WButton) WCheckbox(meteordevelopment.meteorclient.gui.widgets.pressable.WCheckbox) WMinus(meteordevelopment.meteorclient.gui.widgets.pressable.WMinus) WHorizontalList(meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList) WLabel(meteordevelopment.meteorclient.gui.widgets.WLabel)

Aggregations

WMinus (meteordevelopment.meteorclient.gui.widgets.pressable.WMinus)7 WButton (meteordevelopment.meteorclient.gui.widgets.pressable.WButton)6 WTextBox (meteordevelopment.meteorclient.gui.widgets.input.WTextBox)4 WPlus (meteordevelopment.meteorclient.gui.widgets.pressable.WPlus)4 NbtString (net.minecraft.nbt.NbtString)3 WLabel (meteordevelopment.meteorclient.gui.widgets.WLabel)2 WHorizontalList (meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList)2 WCheckbox (meteordevelopment.meteorclient.gui.widgets.pressable.WCheckbox)2 Pair (oshi.util.tuples.Pair)2 File (java.io.File)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 WTable (meteordevelopment.meteorclient.gui.widgets.containers.WTable)1 Proxy (meteordevelopment.meteorclient.systems.proxies.Proxy)1 PointerBuffer (org.lwjgl.PointerBuffer)1