Search in sources :

Example 1 with WLabel

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

the class Marker method fillList.

protected void fillList(GuiTheme theme, WVerticalList list) {
    // Marker List
    for (BaseMarker marker : markers) {
        WHorizontalList hList = list.add(theme.horizontalList()).expandX().widget();
        // Name
        WLabel label = hList.add(theme.label(marker.name.get())).widget();
        label.tooltip = marker.description.get();
        // Dimension
        hList.add(theme.label(" - " + marker.getDimension().toString())).expandX().widget().color = theme.textSecondaryColor();
        // Toggle
        WCheckbox checkbox = hList.add(theme.checkbox(marker.isActive())).widget();
        checkbox.action = () -> {
            if (marker.isActive() != checkbox.checked)
                marker.toggle();
        };
        // Edit
        WButton edit = hList.add(theme.button(GuiRenderer.EDIT)).widget();
        edit.action = () -> mc.setScreen(marker.getScreen(theme));
        // Remove
        WMinus remove = hList.add(theme.minus()).widget();
        remove.action = () -> {
            markers.remove(marker);
            marker.settings.unregisterColorSettings();
            list.clear();
            fillList(theme, list);
        };
    }
    // Bottom
    WHorizontalList bottom = list.add(theme.horizontalList()).expandX().widget();
    WDropdown<String> newMarker = bottom.add(theme.dropdown(factory.getNames(), factory.getNames()[0])).widget();
    WButton add = bottom.add(theme.button("Add")).expandX().widget();
    add.action = () -> {
        String name = newMarker.get();
        markers.add(factory.createMarker(name));
        list.clear();
        fillList(theme, list);
    };
}
Also used : WButton(mathax.client.gui.widgets.pressable.WButton) WCheckbox(mathax.client.gui.widgets.pressable.WCheckbox) WMinus(mathax.client.gui.widgets.pressable.WMinus) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList) WLabel(mathax.client.gui.widgets.WLabel)

Example 2 with WLabel

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

the class ProxiesScreen method initWidgets.

@Override
public void initWidgets() {
    // Proxies
    WTable table = add(theme.table()).expandX().widget();
    for (Proxy proxy : Proxies.get()) {
        // Enabled
        WCheckbox enabled = table.add(theme.checkbox(proxy.enabled)).widget();
        checkboxes.add(enabled);
        enabled.action = () -> {
            boolean checked = enabled.checked;
            Proxies.get().setEnabled(proxy, checked);
            for (WCheckbox checkbox : checkboxes) checkbox.checked = false;
            enabled.checked = checked;
        };
        // Name
        WLabel name = table.add(theme.label(proxy.name)).widget();
        name.color = theme.textColor();
        // Type
        WLabel type = table.add(theme.label("(" + proxy.type + ")")).widget();
        type.color = theme.textSecondaryColor();
        // IP + Port
        WHorizontalList ipList = table.add(theme.horizontalList()).expandCellX().widget();
        ipList.spacing = 0;
        ipList.add(theme.label(proxy.address));
        ipList.add(theme.label(":")).widget().color = theme.textSecondaryColor();
        ipList.add(theme.label(Integer.toString(proxy.port)));
        // Edit
        WButton edit = table.add(theme.button(GuiRenderer.EDIT)).widget();
        edit.action = () -> openEditProxyScreen(proxy);
        // Remove
        WMinus remove = table.add(theme.minus()).widget();
        remove.action = () -> {
            Proxies.get().remove(proxy);
            reload();
        };
        table.row();
    }
    WHorizontalList l = add(theme.horizontalList()).expandX().widget();
    // New
    WButton newBtn = l.add(theme.button("New")).expandX().widget();
    newBtn.action = () -> openEditProxyScreen(null);
    // Import
    PointerBuffer filters = BufferUtils.createPointerBuffer(1);
    ByteBuffer txtFilter = MemoryUtil.memASCII("*.txt");
    filters.put(txtFilter);
    filters.rewind();
    WButton importBtn = l.add(theme.button("Import")).expandX().widget();
    importBtn.action = () -> {
        String selectedFile = TinyFileDialogs.tinyfd_openFileDialog("Import Proxies", null, filters, null, false);
        if (selectedFile != null) {
            File file = new File(selectedFile);
            mc.setScreen(new ProxiesImportScreen(theme, file));
        }
    };
}
Also used : PointerBuffer(org.lwjgl.PointerBuffer) WButton(mathax.client.gui.widgets.pressable.WButton) WCheckbox(mathax.client.gui.widgets.pressable.WCheckbox) ByteBuffer(java.nio.ByteBuffer) WLabel(mathax.client.gui.widgets.WLabel) Proxy(mathax.client.systems.proxies.Proxy) WTable(mathax.client.gui.widgets.containers.WTable) WMinus(mathax.client.gui.widgets.pressable.WMinus) File(java.io.File) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList)

Example 3 with WLabel

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

Aggregations

WLabel (mathax.client.gui.widgets.WLabel)3 WHorizontalList (mathax.client.gui.widgets.containers.WHorizontalList)3 WButton (mathax.client.gui.widgets.pressable.WButton)3 File (java.io.File)2 WCheckbox (mathax.client.gui.widgets.pressable.WCheckbox)2 WMinus (mathax.client.gui.widgets.pressable.WMinus)2 ByteBuffer (java.nio.ByteBuffer)1 WTable (mathax.client.gui.widgets.containers.WTable)1 Proxy (mathax.client.systems.proxies.Proxy)1 NbtString (net.minecraft.nbt.NbtString)1 PointerBuffer (org.lwjgl.PointerBuffer)1