use of mathax.client.gui.widgets.pressable.WPlus in project Client by MatHax.
the class StringListSetting method fillTable.
public static void fillTable(GuiTheme theme, WTable table, StringListSetting setting) {
setting.get().removeIf(String::isEmpty);
ArrayList<String> strings = new ArrayList<>(setting.get());
for (int i = 0; i < setting.get().size(); i++) {
int msgI = i;
String message = setting.get().get(i);
WTextBox textBox = table.add(theme.textBox(message)).expandX().widget();
textBox.action = () -> strings.set(msgI, textBox.get());
textBox.actionOnUnfocused = () -> setting.set(strings);
WMinus delete = table.add(theme.minus()).widget();
delete.action = () -> {
strings.remove(msgI);
setting.set(strings);
table.clear();
fillTable(theme, table, setting);
};
table.row();
}
WTextBox textBox = table.add(theme.textBox(setting.newText)).minWidth(300).expandX().widget();
textBox.action = () -> setting.newText = textBox.get();
WPlus add = table.add(theme.plus()).widget();
add.action = () -> {
strings.add(setting.newText);
setting.set(strings);
setting.newText = "";
table.clear();
fillTable(theme, table, setting);
};
// Reset
table.row();
WButton reset = table.add(theme.button("Reset")).widget();
reset.action = () -> {
setting.reset();
table.clear();
fillTable(theme, table, setting);
};
}
use of mathax.client.gui.widgets.pressable.WPlus in project Client by MatHax.
the class InteractionMenu method fillTable.
private void fillTable(GuiTheme theme, WTable table) {
table.clear();
messages.keySet().forEach((key) -> {
table.add(theme.label(key)).expandCellX();
table.add(theme.label(messages.get(key))).expandCellX();
WMinus delete = table.add(theme.minus()).widget();
delete.action = () -> {
messages.remove(key);
fillTable(theme, table);
};
table.row();
});
WTextBox textBoxK = table.add(theme.textBox(currMsgK)).minWidth(100).expandX().widget();
textBoxK.action = () -> currMsgK = textBoxK.get();
WTextBox textBoxV = table.add(theme.textBox(currMsgV)).minWidth(100).expandX().widget();
textBoxV.action = () -> currMsgV = textBoxV.get();
WPlus add = table.add(theme.plus()).widget();
add.action = () -> {
if (currMsgK.equals("") && currMsgV.equals("")) {
messages.put(currMsgK, currMsgV);
currMsgK = "";
currMsgV = "";
fillTable(theme, table);
}
};
table.row();
}