Search in sources :

Example 1 with WButton

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

the class WKeyBind method init.

@Override
public void init() {
    label = add(theme.label("")).widget();
    WButton set = add(theme.button("Set")).widget();
    set.action = () -> {
        listening = true;
        label.set(appendBindText("..."));
        if (actionOnSet != null)
            actionOnSet.run();
    };
    WButton reset = add(theme.button(GuiRenderer.RESET)).expandCellX().right().widget();
    reset.action = this::resetBind;
    refreshLabel();
}
Also used : WButton(mathax.client.gui.widgets.pressable.WButton)

Example 2 with WButton

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

the class WPlaybackControls method add.

@Override
public void add(WTable parent, MusicTab.MusicScreen screen, GuiTheme theme) {
    WHorizontalList list = parent.add(theme.horizontalList()).widget();
    WButton pauseButton = list.add(theme.button(Music.player.isPaused() ? "Resume" : "Pause")).widget();
    pauseButton.action = () -> {
        if (Music.player.isPaused()) {
            Music.trackScheduler.setPaused(false);
            pauseButton.set("Pause");
        } else {
            Music.trackScheduler.setPaused(true);
            pauseButton.set("Resume");
        }
    };
    if (Music.trackScheduler.hasNext()) {
        list.add(theme.button("Shuffle")).widget().action = () -> {
            Collections.shuffle(Music.trackScheduler.tracks);
            screen.construct();
        };
        list.add(theme.button("Clear")).widget().action = () -> {
            Music.trackScheduler.tracks.clear();
            screen.construct();
        };
    }
    list.add(theme.button("Playlists")).widget().action = () -> {
        mc.setScreen(new PlaylistsScreen(theme, screen));
    };
    String duration;
    AudioTrack current = Music.player.getPlayingTrack();
    if (current == null)
        duration = "Not playing";
    else
        duration = Music.getTime();
    list.add(theme.label("Duration: " + duration)).right();
    parent.row();
    super.add(parent, screen, theme);
}
Also used : PlaylistsScreen(mathax.client.gui.screens.music.PlaylistsScreen) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) WButton(mathax.client.gui.widgets.pressable.WButton) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList)

Example 3 with WButton

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

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

the class DefaultSettingsWidgetFactory method colorW.

private void colorW(WTable table, ColorSetting setting) {
    WHorizontalList list = table.add(theme.horizontalList()).expandX().widget();
    WQuad quad = list.add(theme.quad(setting.get())).widget();
    WButton edit = list.add(theme.button(GuiRenderer.EDIT)).widget();
    edit.action = () -> mc.setScreen(new ColorSettingScreen(theme, setting));
    reset(table, setting, () -> quad.color = setting.get());
}
Also used : WButton(mathax.client.gui.widgets.pressable.WButton)

Example 5 with WButton

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

the class DefaultSettingsWidgetFactory method genericW.

private void genericW(WTable table, GenericSetting<?> setting) {
    WButton edit = table.add(theme.button(GuiRenderer.EDIT)).widget();
    edit.action = () -> mc.setScreen(setting.get().createScreen(theme));
    reset(table, setting, null);
}
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