Search in sources :

Example 1 with WMinus

use of mathax.client.gui.widgets.pressable.WMinus in project Client by MatHax.

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(mathax.client.gui.widgets.input.WTextBox) WButton(mathax.client.gui.widgets.pressable.WButton) WMinus(mathax.client.gui.widgets.pressable.WMinus) WPlus(mathax.client.gui.widgets.pressable.WPlus)

Example 2 with WMinus

use of mathax.client.gui.widgets.pressable.WMinus in project Client by MatHax.

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(mathax.client.gui.widgets.pressable.WButton) WCheckbox(mathax.client.gui.widgets.pressable.WCheckbox) WMinus(mathax.client.gui.widgets.pressable.WMinus) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList) WLabel(mathax.client.gui.widgets.WLabel)

Example 3 with WMinus

use of mathax.client.gui.widgets.pressable.WMinus in project Client by MatHax.

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(mathax.client.gui.widgets.pressable.WButton) WCheckbox(mathax.client.gui.widgets.pressable.WCheckbox) ByteBuffer(java.nio.ByteBuffer) WLabel(mathax.client.gui.widgets.WLabel) Proxy(mathax.client.systems.proxies.Proxy) WTable(mathax.client.gui.widgets.containers.WTable) WMinus(mathax.client.gui.widgets.pressable.WMinus) File(java.io.File) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList)

Example 4 with WMinus

use of mathax.client.gui.widgets.pressable.WMinus in project Client by MatHax.

the class InteractionMenu method fillTable.

private void fillTable(GuiTheme theme, WTable table) {
    table.clear();
    messages.keySet().forEach((key) -> {
        table.add(theme.label(key)).expandCellX();
        table.add(theme.label(messages.get(key))).expandCellX();
        WMinus delete = table.add(theme.minus()).widget();
        delete.action = () -> {
            messages.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.equals("") && currMsgV.equals("")) {
            messages.put(currMsgK, currMsgV);
            currMsgK = "";
            currMsgV = "";
            fillTable(theme, table);
        }
    };
    table.row();
}
Also used : WTextBox(mathax.client.gui.widgets.input.WTextBox) WMinus(mathax.client.gui.widgets.pressable.WMinus) WPlus(mathax.client.gui.widgets.pressable.WPlus)

Example 5 with WMinus

use of mathax.client.gui.widgets.pressable.WMinus in project Client by MatHax.

the class WAccount method init.

@Override
public void init() {
    // Head
    add(theme.texture(32, 32, account.getCache().shouldRotateHeadTexture() ? 90 : 0, account.getCache().getHeadTexture()));
    // Name
    WLabel name = add(theme.label(account.getUsername())).widget();
    if (mc.getSession().getUsername().equalsIgnoreCase(account.getUsername()))
        name.color = loggedInColor();
    // Type
    WLabel label = add(theme.label("(" + account.getType() + ")")).expandCellX().right().widget();
    label.color = accountTypeColor();
    // Login
    WButton login = add(theme.button("Login")).widget();
    login.action = () -> {
        login.minWidth = login.width;
        login.set("...");
        screen.locked = true;
        MatHaxExecutor.execute(() -> {
            if (account.login()) {
                name.set(account.getUsername());
                Accounts.get().save();
                screen.taskAfterRender = refreshScreenAction;
            }
            login.minWidth = 0;
            login.set("Login");
            screen.locked = false;
        });
    };
    // Remove
    WMinus remove = add(theme.minus()).widget();
    remove.action = () -> {
        Accounts.get().remove(account);
        if (refreshScreenAction != null)
            refreshScreenAction.run();
    };
}
Also used : WButton(mathax.client.gui.widgets.pressable.WButton) WMinus(mathax.client.gui.widgets.pressable.WMinus)

Aggregations

WMinus (mathax.client.gui.widgets.pressable.WMinus)5 WButton (mathax.client.gui.widgets.pressable.WButton)4 WLabel (mathax.client.gui.widgets.WLabel)2 WHorizontalList (mathax.client.gui.widgets.containers.WHorizontalList)2 WTextBox (mathax.client.gui.widgets.input.WTextBox)2 WCheckbox (mathax.client.gui.widgets.pressable.WCheckbox)2 WPlus (mathax.client.gui.widgets.pressable.WPlus)2 File (java.io.File)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 WTable (mathax.client.gui.widgets.containers.WTable)1 Proxy (mathax.client.systems.proxies.Proxy)1 NbtString (net.minecraft.nbt.NbtString)1 PointerBuffer (org.lwjgl.PointerBuffer)1