Search in sources :

Example 26 with WButton

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

the class WAccount method init.

@Override
public void init() {
    // Head
    add(theme.texture(32, 32, account.getCache().shouldRotateHeadTexture() ? 90 : 0, account.getCache().getHeadTexture()));
    // Name
    WLabel name = add(theme.label(account.getUsername())).widget();
    if (mc.getSession().getUsername().equalsIgnoreCase(account.getUsername()))
        name.color = loggedInColor();
    // Type
    WLabel label = add(theme.label("(" + account.getType() + ")")).expandCellX().right().widget();
    label.color = accountTypeColor();
    // Login
    WButton login = add(theme.button("Login")).widget();
    login.action = () -> {
        login.minWidth = login.width;
        login.set("...");
        screen.locked = true;
        MatHaxExecutor.execute(() -> {
            if (account.login()) {
                name.set(account.getUsername());
                Accounts.get().save();
                screen.taskAfterRender = refreshScreenAction;
            }
            login.minWidth = 0;
            login.set("Login");
            screen.locked = false;
        });
    };
    // Remove
    WMinus remove = add(theme.minus()).widget();
    remove.action = () -> {
        Accounts.get().remove(account);
        if (refreshScreenAction != null)
            refreshScreenAction.run();
    };
}
Also used : WButton(mathax.client.gui.widgets.pressable.WButton) WMinus(mathax.client.gui.widgets.pressable.WMinus)

Example 27 with WButton

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

the class Notebot method getWidget.

// Buttons
@Override
public WWidget getWidget(GuiTheme theme) {
    WTable table = theme.table();
    // Label
    status = table.add(theme.label(getStatus())).expandCellX().widget();
    // Pause
    WButton pauseBtn = table.add(theme.button(isPlaying ? "Pause" : "Resume")).right().widget();
    pauseBtn.action = () -> {
        pause();
        pauseBtn.set(isPlaying ? "Pause" : "Resume");
        status.set(getStatus());
    };
    // Stop
    WButton stop = table.add(theme.button("Stop")).right().widget();
    stop.action = this::stop;
    table.row();
    noSongsFound = true;
    try {
        Files.list(MatHax.FOLDER.toPath().resolve("Notebot")).forEach(path -> {
            if (isValidFile(path)) {
                noSongsFound = false;
                table.add(theme.label(getFileLabel(path))).expandCellX();
                WButton load = table.add(theme.button("Load")).right().widget();
                load.action = () -> {
                    loadSong(path.toFile());
                    status.set(getStatus());
                };
                WButton preview = table.add(theme.button("Preview")).right().widget();
                preview.action = () -> {
                    previewSong(path.toFile());
                    status.set(getStatus());
                };
                table.row();
            }
        });
    } catch (IOException e) {
        table.add(theme.label("Missing \"Notebot\" folder.")).expandCellX();
        table.row();
    }
    if (noSongsFound) {
        table.add(theme.label("No songs found.")).expandCellX();
        table.row();
        WButton guide = table.add(theme.button("Guide")).expandX().widget();
        guide.action = () -> Util.getOperatingSystem().open("https://mathaxclient.xyz/Notebot-Guide");
    }
    return table;
}
Also used : WTable(mathax.client.gui.widgets.containers.WTable) IOException(java.io.IOException) WButton(mathax.client.gui.widgets.pressable.WButton)

Example 28 with WButton

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

the class BookBot method getWidget.

// Buttons
@Override
public WWidget getWidget(GuiTheme theme) {
    WHorizontalList list = theme.horizontalList();
    WButton selectFile = list.add(theme.button("Select File")).widget();
    WLabel fileName = list.add(theme.label((file != null && file.exists()) ? file.getName() : "No file selected.")).widget();
    selectFile.action = () -> {
        String path = TinyFileDialogs.tinyfd_openFileDialog("Select File", new File(MatHax.FOLDER, "bookbot.txt").getAbsolutePath(), filters, null, false);
        if (path != null) {
            file = new File(path);
            fileName.set(file.getName());
        }
    };
    return list;
}
Also used : NbtString(net.minecraft.nbt.NbtString) WButton(mathax.client.gui.widgets.pressable.WButton) File(java.io.File) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList) WLabel(mathax.client.gui.widgets.WLabel)

Example 29 with WButton

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

the class Swarm method getWidget.

// Buttons
@Override
public WWidget getWidget(GuiTheme theme) {
    WVerticalList list = theme.verticalList();
    WHorizontalList b = list.add(theme.horizontalList()).expandX().widget();
    WButton start = b.add(theme.button("Start")).expandX().widget();
    start.action = () -> {
        if (!isActive())
            return;
        close();
        if (mode.get() == Mode.Host)
            host = new SwarmHost(serverPort.get());
        else
            worker = new SwarmWorker(ipAddress.get(), serverPort.get());
    };
    WButton stop = b.add(theme.button("Stop")).expandX().widget();
    stop.action = this::close;
    WButton guide = list.add(theme.button("Guide")).expandX().widget();
    guide.action = () -> Util.getOperatingSystem().open("https://mathaxclient.xyz/Swarm-Guide");
    return list;
}
Also used : WButton(mathax.client.gui.widgets.pressable.WButton) WVerticalList(mathax.client.gui.widgets.containers.WVerticalList) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList)

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