Search in sources :

Example 1 with WCheckbox

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

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

the class ModuleScreen method initWidgets.

@Override
public void initWidgets() {
    // Description
    add(theme.label(module.description, Utils.getWindowWidth() / 2.0));
    // Settings
    if (module.settings.groups.size() > 0) {
        settingsContainer = add(theme.verticalList()).expandX().widget();
        settingsContainer.add(theme.settings(module.settings)).expandX();
    }
    // Custom widget
    WWidget widget = module.getWidget(theme);
    if (widget != null) {
        add(theme.horizontalSeparator()).expandX();
        Cell<WWidget> cell = add(widget);
        if (widget instanceof WContainer)
            cell.expandX();
    }
    // Bind
    WSection section = add(theme.section("Bind", true)).expandX().widget();
    keybind = section.add(theme.keybind(module.keybind)).expandX().widget();
    keybind.actionOnSet = () -> Modules.get().setModuleToBind(module);
    // Toggle on bind release
    WHorizontalList tobr = section.add(theme.horizontalList()).widget();
    tobr.add(theme.label("Toggle on bind release: "));
    WCheckbox tobrC = tobr.add(theme.checkbox(module.toggleOnBindRelease)).widget();
    tobrC.action = () -> module.toggleOnBindRelease = tobrC.checked;
    // Module
    add(theme.section("Module", true)).expandX().widget();
    // Bottom
    WHorizontalList bottom = add(theme.horizontalList()).expandX().widget();
    // Messages
    bottom.add(theme.label("Toggle message: "));
    WCheckbox messageToggle = bottom.add(theme.checkbox(module.isMessageEnabled())).expandCellX().widget();
    messageToggle.action = () -> {
        if (module.isMessageEnabled() != messageToggle.checked)
            module.setToggleMessage(messageToggle.checked);
    };
    // Toasts
    bottom.add(theme.label("Toggle toast: "));
    WCheckbox toastToggle = bottom.add(theme.checkbox(module.isToastEnabled())).widget();
    toastToggle.action = () -> {
        if (module.isToastEnabled() != toastToggle.checked)
            module.setToggleToast(toastToggle.checked);
    };
    // Bottom 2
    WHorizontalList bottom2 = add(theme.horizontalList()).expandX().widget();
    // Active
    bottom2.add(theme.label("Active: "));
    WCheckbox active = bottom2.add(theme.checkbox(module.isActive())).expandCellX().widget();
    active.action = () -> {
        if (module.isActive() != active.checked)
            module.toggle();
    };
    // Visible
    bottom2.add(theme.label("Visible: "));
    WCheckbox visible = bottom2.add(theme.checkbox(module.isVisible())).widget();
    visible.action = () -> {
        if (module.isVisible() != visible.checked)
            module.setVisible(visible.checked);
    };
}
Also used : WSection(mathax.client.gui.widgets.containers.WSection) WWidget(mathax.client.gui.widgets.WWidget) WContainer(mathax.client.gui.widgets.containers.WContainer) WCheckbox(mathax.client.gui.widgets.pressable.WCheckbox) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList)

Example 3 with WCheckbox

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

the class HudElementScreen method initWidgets.

@Override
public void initWidgets() {
    // Description
    add(theme.label(element.description, Utils.getWindowWidth() / 2.0));
    // Settings
    if (element.settings.sizeGroups() > 0) {
        settings = add(theme.verticalList()).expandX().widget();
        settings.add(theme.settings(element.settings)).expandX();
        add(theme.horizontalSeparator()).expandX();
    }
    // Bottom
    WHorizontalList bottomList = add(theme.horizontalList()).expandX().widget();
    // Active
    bottomList.add(theme.label("Active:"));
    WCheckbox active = bottomList.add(theme.checkbox(element.active)).widget();
    active.action = () -> {
        if (element.active != active.checked)
            element.toggle();
    };
    WButton reset = bottomList.add(theme.button(GuiRenderer.RESET)).expandCellX().right().widget();
    reset.action = () -> {
        if (element.active != element.defaultActive)
            element.active = active.checked = element.defaultActive;
    };
}
Also used : WButton(mathax.client.gui.widgets.pressable.WButton) WCheckbox(mathax.client.gui.widgets.pressable.WCheckbox) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList)

Example 4 with WCheckbox

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

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

the class DefaultSettingsWidgetFactory method boolW.

// Settings
private void boolW(WTable table, BoolSetting setting) {
    WCheckbox checkbox = table.add(theme.checkbox(setting.get())).expandCellX().widget();
    checkbox.action = () -> setting.set(checkbox.checked);
    reset(table, setting, () -> checkbox.checked = setting.get());
}
Also used : WCheckbox(mathax.client.gui.widgets.pressable.WCheckbox)

Aggregations

WCheckbox (mathax.client.gui.widgets.pressable.WCheckbox)5 WHorizontalList (mathax.client.gui.widgets.containers.WHorizontalList)4 WButton (mathax.client.gui.widgets.pressable.WButton)3 WLabel (mathax.client.gui.widgets.WLabel)2 WMinus (mathax.client.gui.widgets.pressable.WMinus)2 File (java.io.File)1 ByteBuffer (java.nio.ByteBuffer)1 WWidget (mathax.client.gui.widgets.WWidget)1 WContainer (mathax.client.gui.widgets.containers.WContainer)1 WSection (mathax.client.gui.widgets.containers.WSection)1 WTable (mathax.client.gui.widgets.containers.WTable)1 Proxy (mathax.client.systems.proxies.Proxy)1 PointerBuffer (org.lwjgl.PointerBuffer)1