use of mathax.client.gui.widgets.containers.WTable in project Client by MatHax.
the class LeftRightListSettingScreen method initWidgets.
private void initWidgets(Registry<T> registry) {
// Left (all)
WTable left = abc(pairs -> registry.forEach(t -> {
if (skipValue(t) || collection.contains(t))
return;
int words = Utils.search(getValueName(t), filterText);
if (words > 0)
pairs.add(new Pair<>(t, words));
}), true, t -> {
addValue(registry, t);
T v = getAdditionalValue(t);
if (v != null)
addValue(registry, v);
});
if (left.cells.size() > 0)
table.add(theme.verticalSeparator()).expandWidgetY();
// Right (selected)
abc(pairs -> {
for (T value : collection) {
if (skipValue(value))
continue;
int words = Utils.search(getValueName(value), filterText);
if (words > 0)
pairs.add(new Pair<>(value, words));
}
}, false, t -> {
removeValue(registry, t);
T v = getAdditionalValue(t);
if (v != null)
removeValue(registry, v);
});
}
use of mathax.client.gui.widgets.containers.WTable in project Client by MatHax.
the class PotionSettingScreen method initWidgets.
@Override
public void initWidgets() {
WTable table = add(theme.table()).expandX().widget();
for (MyPotion potion : MyPotion.values()) {
table.add(theme.itemWithLabel(potion.potion, potion.potion.getName().getString()));
WButton select = table.add(theme.button("Select")).widget();
select.action = () -> {
setting.set(potion);
close();
};
table.row();
}
}
use of mathax.client.gui.widgets.containers.WTable in project Client by MatHax.
the class ServerFinderScreen method initWidgets.
@Override
public void initWidgets() {
add(theme.label("This will search for servers with similar IPs"));
add(theme.label("to the IP you type into the field below."));
add(theme.label("The servers it finds will be added to your server list."));
WTable table = add(new WTable()).expandX().widget();
table.add(theme.label("Server address:"));
table.add(ipBox).expandX();
table.row();
table.add(theme.label("Max. Threads:"));
table.add(maxThreadsBox);
table.row();
table.add(theme.label("Scan ports"));
table.add(scanPortsBox);
table.row();
table.add(theme.label("Versions:"));
table.add(versionBox).expandX();
add(stateLabel);
add(checkedLabel);
add(workingLabel);
WHorizontalList list = add(theme.horizontalList()).expandX().widget();
list.add(searchButton).expandX();
list.add(theme.button("Save")).expandX().widget().action = this::saveToFile;
searchButton.action = this::searchOrCancel;
}
use of mathax.client.gui.widgets.containers.WTable 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();
};
}
use of mathax.client.gui.widgets.containers.WTable in project Client by MatHax.
the class LeftRightListSettingScreen method abc.
private WTable abc(Consumer<List<Pair<T, Integer>>> addValues, boolean isLeft, Consumer<T> buttonAction) {
// Create
Cell<WTable> cell = this.table.add(theme.table()).top();
WTable table = cell.widget();
Consumer<T> forEach = t -> {
if (!includeValue(t))
return;
table.add(getValueWidget(t));
WPressable button = table.add(isLeft ? theme.plus() : theme.minus()).expandCellX().right().widget();
button.action = () -> buttonAction.accept(t);
table.row();
};
// Sort
List<Pair<T, Integer>> values = new ArrayList<>();
addValues.accept(values);
if (!filterText.isEmpty())
values.sort(Comparator.comparingInt(value -> -value.getRight()));
for (Pair<T, Integer> pair : values) forEach.accept(pair.getLeft());
if (table.cells.size() > 0)
cell.expandX();
return table;
}
Aggregations