Search in sources :

Example 16 with WButton

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

the class PotionSettingScreen method initWidgets.

@Override
public void initWidgets() {
    WTable table = add(theme.table()).expandX().widget();
    for (MyPotion potion : MyPotion.values()) {
        table.add(theme.itemWithLabel(potion.potion, potion.potion.getName().getString()));
        WButton select = table.add(theme.button("Select")).widget();
        select.action = () -> {
            setting.set(potion);
            close();
        };
        table.row();
    }
}
Also used : WTable(mathax.client.gui.widgets.containers.WTable) WButton(mathax.client.gui.widgets.pressable.WButton) MyPotion(mathax.client.utils.misc.MyPotion)

Example 17 with WButton

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

the class ServerManagerScreen method addButton.

private void addButton(WContainer c, String text, IGetter<Screen> action) {
    WButton button = c.add(theme.button(text)).expandX().widget();
    button.action = () -> client.setScreen(action.get());
}
Also used : WButton(mathax.client.gui.widgets.pressable.WButton)

Example 18 with WButton

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

the class BlockDataSettingScreen method initTable.

public <T extends ICopyable<T> & ISerializable<T> & IChangeable & IBlockData<T>> void initTable() {
    for (Block block : Registry.BLOCK) {
        T blockData = (T) setting.get().get(block);
        if (blockData != null && blockData.isChanged())
            BLOCKS.add(0, block);
        else
            BLOCKS.add(block);
    }
    for (Block block : BLOCKS) {
        String name = Names.get(block);
        if (!StringUtils.containsIgnoreCase(name, filterText))
            continue;
        T blockData = (T) setting.get().get(block);
        table.add(theme.itemWithLabel(block.asItem().getDefaultStack(), Names.get(block))).expandCellX();
        table.add(theme.label((blockData != null && blockData.isChanged()) ? "*" : " "));
        WButton edit = table.add(theme.button(GuiRenderer.EDIT)).widget();
        edit.action = () -> {
            T data = blockData;
            if (data == null)
                data = (T) setting.defaultData.get().copy();
            mc.setScreen(data.createScreen(theme, block, (BlockDataSetting<T>) setting));
        };
        WButton reset = table.add(theme.button(GuiRenderer.RESET)).widget();
        reset.action = () -> {
            setting.get().remove(block);
            setting.onChanged();
            if (blockData != null && blockData.isChanged()) {
                table.clear();
                initTable();
            }
        };
        table.row();
    }
    BLOCKS.clear();
}
Also used : BlockDataSetting(mathax.client.settings.BlockDataSetting) Block(net.minecraft.block.Block) WButton(mathax.client.gui.widgets.pressable.WButton)

Example 19 with WButton

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

the class BlockSettingScreen method initTable.

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

Example 20 with WButton

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

the class AccountsScreen method addButton.

private void addButton(WContainer c, String text, Runnable action) {
    WButton button = c.add(theme.button(text)).expandX().widget();
    button.action = action;
}
Also used : 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