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);
};
}
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));
}
};
}
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;
}
Aggregations