Search in sources :

Example 1 with WTextBox

use of mathax.client.gui.widgets.input.WTextBox 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 WTextBox

use of mathax.client.gui.widgets.input.WTextBox 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 WTextBox

use of mathax.client.gui.widgets.input.WTextBox 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 WTextBox

use of mathax.client.gui.widgets.input.WTextBox in project Client by MatHax.

the class BlockDataSettingScreen method initWidgets.

@Override
public void initWidgets() {
    WTextBox filter = add(theme.textBox("")).minWidth(400).expandX().widget();
    filter.setFocused(true);
    filter.action = () -> {
        filterText = filter.get().trim();
        table.clear();
        initWidgets();
    };
    table = add(theme.table()).expandX().widget();
    initTable();
}
Also used : WTextBox(mathax.client.gui.widgets.input.WTextBox)

Example 5 with WTextBox

use of mathax.client.gui.widgets.input.WTextBox 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)

Aggregations

WTextBox (mathax.client.gui.widgets.input.WTextBox)9 WTable (mathax.client.gui.widgets.containers.WTable)5 ArrayList (java.util.ArrayList)4 GuiTheme (mathax.client.gui.GuiTheme)3 List (java.util.List)2 MatHax.mc (mathax.client.MatHax.mc)2 MusicTab (mathax.client.gui.tabs.builtin.MusicTab)2 WMinus (mathax.client.gui.widgets.pressable.WMinus)2 WPlus (mathax.client.gui.widgets.pressable.WPlus)2 SearchUtils (mathax.client.utils.music.SearchUtils)2 AudioPlaylist (com.sedmelluq.discord.lavaplayer.track.AudioPlaylist)1 Map (java.util.Map)1 Set (java.util.Set)1 WindowScreen (mathax.client.gui.WindowScreen)1 PlaylistViewScreen (mathax.client.gui.screens.music.PlaylistViewScreen)1 TabScreen (mathax.client.gui.tabs.TabScreen)1 Tabs (mathax.client.gui.tabs.Tabs)1 Cell (mathax.client.gui.utils.Cell)1 WContainer (mathax.client.gui.widgets.containers.WContainer)1 WSection (mathax.client.gui.widgets.containers.WSection)1