Search in sources :

Example 11 with WButton

use of mathax.client.gui.widgets.pressable.WButton 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 12 with WButton

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

the class Timer method getWidget.

// Buttons
@Override
public WWidget getWidget(GuiTheme theme) {
    if (Modules.get().get(TPSSync.class).isActive()) {
        WHorizontalList list = theme.horizontalList();
        list.add(theme.label("Multiplier is overwritten by TPSSync."));
        WButton disableBtn = list.add(theme.button("Disable TPSSync")).widget();
        disableBtn.action = () -> {
            TPSSync tpsSync = Modules.get().get(TPSSync.class);
            if (tpsSync.isActive())
                tpsSync.toggle();
            list.visible = false;
        };
        return list;
    }
    return null;
}
Also used : TPSSync(mathax.client.systems.modules.misc.TPSSync) WButton(mathax.client.gui.widgets.pressable.WButton) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList)

Example 13 with WButton

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

the class HudElementScreen method initWidgets.

@Override
public void initWidgets() {
    // Description
    add(theme.label(element.description, Utils.getWindowWidth() / 2.0));
    // Settings
    if (element.settings.sizeGroups() > 0) {
        settings = add(theme.verticalList()).expandX().widget();
        settings.add(theme.settings(element.settings)).expandX();
        add(theme.horizontalSeparator()).expandX();
    }
    // Bottom
    WHorizontalList bottomList = add(theme.horizontalList()).expandX().widget();
    // Active
    bottomList.add(theme.label("Active:"));
    WCheckbox active = bottomList.add(theme.checkbox(element.active)).widget();
    active.action = () -> {
        if (element.active != active.checked)
            element.toggle();
    };
    WButton reset = bottomList.add(theme.button(GuiRenderer.RESET)).expandCellX().right().widget();
    reset.action = () -> {
        if (element.active != element.defaultActive)
            element.active = active.checked = element.defaultActive;
    };
}
Also used : WButton(mathax.client.gui.widgets.pressable.WButton) WCheckbox(mathax.client.gui.widgets.pressable.WCheckbox) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList)

Example 14 with WButton

use of mathax.client.gui.widgets.pressable.WButton 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 15 with WButton

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

the class ItemSettingScreen method initTable.

public void initTable() {
    for (Item item : Registry.ITEM) {
        if (setting.filter != null && !setting.filter.test(item))
            continue;
        if (item == Items.AIR)
            continue;
        WItemWithLabel itemLabel = theme.itemWithLabel(item.getDefaultStack(), Names.get(item));
        if (!filterText.isEmpty() && !StringUtils.containsIgnoreCase(itemLabel.getLabelText(), filterText))
            continue;
        table.add(itemLabel);
        WButton select = table.add(theme.button("Select")).expandCellX().right().widget();
        select.action = () -> {
            setting.set(item);
            close();
        };
        table.row();
    }
}
Also used : Item(net.minecraft.item.Item) WItemWithLabel(mathax.client.gui.widgets.WItemWithLabel) WButton(mathax.client.gui.widgets.pressable.WButton)

Aggregations

WButton (mathax.client.gui.widgets.pressable.WButton)29 WHorizontalList (mathax.client.gui.widgets.containers.WHorizontalList)9 WTable (mathax.client.gui.widgets.containers.WTable)4 WMinus (mathax.client.gui.widgets.pressable.WMinus)4 WLabel (mathax.client.gui.widgets.WLabel)3 WCheckbox (mathax.client.gui.widgets.pressable.WCheckbox)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 WItemWithLabel (mathax.client.gui.widgets.WItemWithLabel)2 Block (net.minecraft.block.Block)2 NbtString (net.minecraft.nbt.NbtString)2 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 Map (java.util.Map)1 PlaylistsScreen (mathax.client.gui.screens.music.PlaylistsScreen)1 WVerticalList (mathax.client.gui.widgets.containers.WVerticalList)1 WTextBox (mathax.client.gui.widgets.input.WTextBox)1 WPlus (mathax.client.gui.widgets.pressable.WPlus)1