Search in sources :

Example 6 with WTextBox

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

the class ModulesScreen method createSearch.

protected WWindow createSearch(WContainer c) {
    WWindow w = theme.window("Search");
    w.id = "search";
    if (theme.categoryIcons())
        w.beforeHeaderInit = wContainer -> wContainer.add(theme.item(Items.COMPASS.getDefaultStack())).pad(2);
    c.add(w);
    w.view.scrollOnlyWhenMouseOver = true;
    w.view.hasScrollBar = false;
    w.view.maxHeight -= 20;
    WVerticalList l = theme.verticalList();
    WTextBox text = w.add(theme.textBox("")).minWidth(140).expandX().widget();
    text.setFocused(true);
    text.action = () -> {
        l.clear();
        createSearchW(l, text.get());
    };
    text.actionOnEnter = () -> {
        Set<Module> modules = Modules.get().searchTitles(text.get());
        if (modules.size() != 1)
            return;
        Module target = modules.iterator().next();
        target.toggle();
    };
    w.add(l).expandX();
    createSearchW(l, text.get());
    return w;
}
Also used : Utils(mathax.client.utils.Utils) WVerticalList(mathax.client.gui.widgets.containers.WVerticalList) WWindow(mathax.client.gui.widgets.containers.WWindow) GuiTheme(mathax.client.gui.GuiTheme) Set(java.util.Set) Items(net.minecraft.item.Items) WContainer(mathax.client.gui.widgets.containers.WContainer) WSection(mathax.client.gui.widgets.containers.WSection) Tabs(mathax.client.gui.tabs.Tabs) ArrayList(java.util.ArrayList) Cell(mathax.client.gui.utils.Cell) List(java.util.List) WTextBox(mathax.client.gui.widgets.input.WTextBox) TabScreen(mathax.client.gui.tabs.TabScreen) NbtUtils(mathax.client.utils.misc.NbtUtils) Category(mathax.client.systems.modules.Category) Modules(mathax.client.systems.modules.Modules) Module(mathax.client.systems.modules.Module) WWindow(mathax.client.gui.widgets.containers.WWindow) WTextBox(mathax.client.gui.widgets.input.WTextBox) Module(mathax.client.systems.modules.Module) WVerticalList(mathax.client.gui.widgets.containers.WVerticalList)

Example 7 with WTextBox

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

the class PlaylistsScreen method construct.

public void construct() {
    pagination.setMaxPage(PlaylistUtils.count() / MusicTab.MusicScreen.pageSize);
    table.clear();
    WTextBox box = table.add(theme.textBox("")).expandX().widget();
    table.add(theme.plus()).widget().action = () -> SearchUtils.search(box.get(), playlist -> {
        PlaylistUtils.add(box.get());
        construct();
    });
    table.row();
    table.add(theme.button("Reset")).expandX().widget().action = () -> {
        PlaylistUtils.reset();
        construct();
    };
    List<Map.Entry<String, AudioPlaylist>> keys = PlaylistUtils.getEntriesOrdered();
    for (int i = 0; i < keys.size(); i++) {
        int j = i + pagination.getPageOffset();
        table.row();
        AudioPlaylist playlist = keys.get(j).getValue();
        table.add(theme.button(playlist.getName())).expandX().widget().action = () -> mc.setScreen(new PlaylistViewScreen(theme, playlist, musicScreen).setParent(this));
        table.add(theme.minus()).right().widget().action = () -> {
            PlaylistUtils.remove(keys.get(j).getKey());
            construct();
        };
    }
    for (WMusicWidget wMusicWidget : childWidgets) {
        wMusicWidget.add(table, musicScreen, theme);
    }
}
Also used : MusicTab(mathax.client.gui.tabs.builtin.MusicTab) GuiTheme(mathax.client.gui.GuiTheme) AudioPlaylist(com.sedmelluq.discord.lavaplayer.track.AudioPlaylist) PlaylistUtils(mathax.client.utils.music.PlaylistUtils) MatHax.mc(mathax.client.MatHax.mc) ArrayList(java.util.ArrayList) WTable(mathax.client.gui.widgets.containers.WTable) List(java.util.List) WTextBox(mathax.client.gui.widgets.input.WTextBox) WPaginationProvider(mathax.client.gui.widgets.music.WPaginationProvider) Map(java.util.Map) WMusicWidget(mathax.client.gui.widgets.music.WMusicWidget) SearchUtils(mathax.client.utils.music.SearchUtils) WindowScreen(mathax.client.gui.WindowScreen) WMusicWidget(mathax.client.gui.widgets.music.WMusicWidget) WTextBox(mathax.client.gui.widgets.input.WTextBox) AudioPlaylist(com.sedmelluq.discord.lavaplayer.track.AudioPlaylist)

Example 8 with WTextBox

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

the class EditBookTitleAndAuthorScreen method initWidgets.

@Override
public void initWidgets() {
    WTable t = add(theme.table()).expandX().widget();
    t.add(theme.label("Title"));
    WTextBox title = t.add(theme.textBox(itemStack.getOrCreateNbt().getString("title"))).minWidth(220).expandX().widget();
    t.row();
    t.add(theme.label("Author"));
    WTextBox author = t.add(theme.textBox(itemStack.getNbt().getString("author"))).minWidth(220).expandX().widget();
    t.row();
    t.add(theme.button("Done")).expandX().widget().action = () -> {
        itemStack.getNbt().putString("author", author.get());
        itemStack.getNbt().putString("title", title.get());
        BookScreen.Contents contents = new BookScreen.WrittenBookContents(itemStack);
        List<String> pages = new ArrayList<>(contents.getPageCount());
        for (int i = 0; i < contents.getPageCount(); i++) pages.add(contents.getPage(i).getString());
        mc.getNetworkHandler().sendPacket(new BookUpdateC2SPacket(hand == Hand.MAIN_HAND ? mc.player.getInventory().selectedSlot : 40, pages, Optional.of(title.get())));
        close();
    };
}
Also used : BookUpdateC2SPacket(net.minecraft.network.packet.c2s.play.BookUpdateC2SPacket) WTable(mathax.client.gui.widgets.containers.WTable) BookScreen(net.minecraft.client.gui.screen.ingame.BookScreen) ArrayList(java.util.ArrayList) WTextBox(mathax.client.gui.widgets.input.WTextBox)

Example 9 with WTextBox

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

the class WSearchBar method add.

@Override
public void add(WTable parent, MusicTab.MusicScreen screen, GuiTheme theme) {
    WTextBox box = parent.add(theme.textBox("")).expandX().widget();
    parent.add(theme.button("Search")).widget().action = () -> SearchUtils.search(box.get(), playlist -> mc.setScreen(new PlaylistViewScreen(theme, playlist, screen)));
    super.add(parent, screen, theme);
}
Also used : PlaylistViewScreen(mathax.client.gui.screens.music.PlaylistViewScreen) WTable(mathax.client.gui.widgets.containers.WTable) MusicTab(mathax.client.gui.tabs.builtin.MusicTab) WTextBox(mathax.client.gui.widgets.input.WTextBox) GuiTheme(mathax.client.gui.GuiTheme) SearchUtils(mathax.client.utils.music.SearchUtils) MatHax.mc(mathax.client.MatHax.mc) WTextBox(mathax.client.gui.widgets.input.WTextBox) PlaylistViewScreen(mathax.client.gui.screens.music.PlaylistViewScreen)

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