Search in sources :

Example 1 with WTable

use of mathax.client.gui.widgets.containers.WTable in project Client by MatHax.

the class HeadScreen method loadHeads.

private void loadHeads() {
    MatHaxExecutor.execute(() -> {
        List<Map<String, String>> res = HTTP.get("https://minecraft-heads.com/scripts/api.php?cat=" + getCategory()).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 ignored) {
            }
        });
        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(mathax.client.gui.widgets.containers.WTable) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) WButton(mathax.client.gui.widgets.pressable.WButton) Map(java.util.Map) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException)

Example 2 with WTable

use of mathax.client.gui.widgets.containers.WTable in project Client by MatHax.

the class AddAlteningAccountScreen method initWidgets.

@Override
public void initWidgets() {
    WTable t = add(theme.table()).widget();
    // Token
    t.add(theme.label("Token: "));
    WTextBox token = t.add(theme.textBox("")).minWidth(400).expandX().widget();
    token.setFocused(true);
    t.row();
    // Add
    add = t.add(theme.button("Add")).expandX().widget();
    add.action = () -> {
        if (!token.get().isEmpty())
            AccountsScreen.addAccount(this, parent, new TheAlteningAccount(token.get()));
    };
    enterAction = add.action;
}
Also used : WTable(mathax.client.gui.widgets.containers.WTable) TheAlteningAccount(mathax.client.systems.accounts.types.TheAlteningAccount) WTextBox(mathax.client.gui.widgets.input.WTextBox)

Example 3 with WTable

use of mathax.client.gui.widgets.containers.WTable in project Client by MatHax.

the class AddCrackedAccountScreen method initWidgets.

@Override
public void initWidgets() {
    WTable t = add(theme.table()).widget();
    // Name
    t.add(theme.label("Name: "));
    WTextBox name = t.add(theme.textBox("", (text, c) -> c != ' ')).minWidth(400).expandX().widget();
    name.setFocused(true);
    t.row();
    // Add
    add = t.add(theme.button("Add")).expandX().widget();
    add.action = () -> {
        if (!name.get().isEmpty() && (name.get().length() < 17) && name.get().matches("^[a-zA-Z0-9_]+$")) {
            CrackedAccount account = new CrackedAccount(name.get());
            if (!(Accounts.get().exists(account)))
                AccountsScreen.addAccount(this, parent, account);
        }
    };
    enterAction = add.action;
}
Also used : WTable(mathax.client.gui.widgets.containers.WTable) WTextBox(mathax.client.gui.widgets.input.WTextBox) CrackedAccount(mathax.client.systems.accounts.types.CrackedAccount)

Example 4 with WTable

use of mathax.client.gui.widgets.containers.WTable 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 5 with WTable

use of mathax.client.gui.widgets.containers.WTable in project Client by MatHax.

the class ServerCleanUpScreen method initWidgets.

@Override
public void initWidgets() {
    WTable table = add(new WTable()).widget();
    table.add(theme.label("Servers to remove:"));
    table.row();
    table.add(theme.label("Unknown Hosts")).widget().tooltip = "";
    table.add(removeUnknown).widget();
    table.row();
    table.add(theme.label("Outdated Servers"));
    table.add(removeOutdated).widget();
    table.row();
    table.add(theme.label("Failed Ping"));
    table.add(removeFailed).widget();
    table.row();
    table.add(theme.label("\"Server Finder\" Servers"));
    table.add(removeFound).widget();
    table.row();
    table.add(theme.label("Everything")).widget().color = new Color(255, 0, 0);
    table.add(removeAll).widget();
    table.row();
    table.add(theme.label("Rename all Servers"));
    table.add(rename).widget();
    table.row();
    table.add(theme.button("Execute")).expandX().widget().action = this::cleanUp;
}
Also used : WTable(mathax.client.gui.widgets.containers.WTable) Color(mathax.client.utils.render.color.Color)

Aggregations

WTable (mathax.client.gui.widgets.containers.WTable)14 WTextBox (mathax.client.gui.widgets.input.WTextBox)6 ArrayList (java.util.ArrayList)4 WButton (mathax.client.gui.widgets.pressable.WButton)4 GuiTheme (mathax.client.gui.GuiTheme)3 Collection (java.util.Collection)2 Comparator (java.util.Comparator)2 List (java.util.List)2 Consumer (java.util.function.Consumer)2 WindowScreen (mathax.client.gui.WindowScreen)2 Cell (mathax.client.gui.utils.Cell)2 WWidget (mathax.client.gui.widgets.WWidget)2 WHorizontalList (mathax.client.gui.widgets.containers.WHorizontalList)2 WPressable (mathax.client.gui.widgets.pressable.WPressable)2 Setting (mathax.client.settings.Setting)2 Utils (mathax.client.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