Save configs from ModMenu-Screen
This commit is contained in:
parent
092e0a39e8
commit
b369954c05
7 changed files with 68 additions and 24 deletions
|
@ -31,13 +31,20 @@ public class GridCheckboxCell extends GridCell{
|
|||
private boolean checked;
|
||||
|
||||
GridCheckboxCell(Component text, boolean checked, float alpha, double width, GridValueType widthType, double height) {
|
||||
this(text, checked, alpha, width, widthType, height, null);
|
||||
}
|
||||
|
||||
GridCheckboxCell(Component text, boolean checked, float alpha, double width, GridValueType widthType, double height, Consumer<Boolean> onChange) {
|
||||
super(width, height, widthType, null, null);
|
||||
|
||||
this.componentPlacer = (transform) -> {
|
||||
Checkbox cb = new SignalingCheckBox(transform.left, transform.top, transform.width, transform.height,
|
||||
text,
|
||||
checked,
|
||||
(state)-> this.checked = state
|
||||
(state)-> {
|
||||
this.checked = state;
|
||||
if (onChange!=null) onChange.accept(state);
|
||||
}
|
||||
);
|
||||
cb.setAlpha(alpha);
|
||||
return cb;
|
||||
|
|
|
@ -14,6 +14,7 @@ import ru.bclib.gui.gridlayout.GridLayout.VerticalAlignment;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
|
@ -86,6 +87,13 @@ public class GridRow extends GridContainer {
|
|||
return cell;
|
||||
}
|
||||
|
||||
public GridCheckboxCell addCheckbox(Component text, boolean checked, Font font, Consumer<Boolean> onChange){
|
||||
final int width = font.width(text.getVisualOrderText()) + 24 + 2 * 12;
|
||||
|
||||
GridCheckboxCell cell = new GridCheckboxCell(text, checked, 1.0f, width, widthType, 20, onChange);
|
||||
this.cells.add(cell);
|
||||
return cell;
|
||||
}
|
||||
|
||||
public GridCheckboxCell addCheckbox(Component text, boolean checked, int height) {
|
||||
return addCheckbox(text, checked, 1.0f, height);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue