[Changes] Converted Screens to new Layout Engine
This commit is contained in:
parent
96bfdc5afa
commit
2d997c53ce
31 changed files with 475 additions and 375 deletions
|
@ -10,6 +10,7 @@ import net.fabricmc.api.Environment;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
class GridCell extends GridCellDefinition {
|
class GridCell extends GridCellDefinition {
|
||||||
public final float height;
|
public final float height;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
class SignalingCheckBox extends Checkbox {
|
class SignalingCheckBox extends Checkbox {
|
||||||
private final Consumer<Boolean> onChange;
|
private final Consumer<Boolean> onChange;
|
||||||
|
@ -35,6 +36,7 @@ class SignalingCheckBox extends Checkbox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class GridCheckboxCell extends GridCell implements GridWidgetWithEnabledState {
|
public class GridCheckboxCell extends GridCell implements GridWidgetWithEnabledState {
|
||||||
private boolean checked;
|
private boolean checked;
|
||||||
|
|
|
@ -5,6 +5,10 @@ import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use {@link org.betterx.ui.layout.components.VerticalStack} instead
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class GridColumn extends GridContainer {
|
public class GridColumn extends GridContainer {
|
||||||
GridColumn(double width) {
|
GridColumn(double width) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public abstract class GridCustomRenderCell extends GridCell {
|
public abstract class GridCustomRenderCell extends GridCell {
|
||||||
protected GridCustomRenderCell(double width, GridValueType widthType, double height) {
|
protected GridCustomRenderCell(double width, GridValueType widthType, double height) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class GridImageCell extends GridCell {
|
public class GridImageCell extends GridCell {
|
||||||
GridImageCell(
|
GridImageCell(
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
abstract class GridCellDefinition {
|
abstract class GridCellDefinition {
|
||||||
public final float width;
|
public final float width;
|
||||||
|
@ -57,6 +58,7 @@ abstract class GridCellDefinition {
|
||||||
abstract protected GridElement buildElementAt(int left, int top, int width, final List<GridElement> collector);
|
abstract protected GridElement buildElementAt(int left, int top, int width, final List<GridElement> collector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
class GridElement extends GridTransform {
|
class GridElement extends GridTransform {
|
||||||
final Function<GridTransform, Object> componentPlacer;
|
final Function<GridTransform, Object> componentPlacer;
|
||||||
|
@ -85,6 +87,7 @@ class GridElement extends GridTransform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
abstract class GridContainer extends GridCellDefinition {
|
abstract class GridContainer extends GridCellDefinition {
|
||||||
protected List<GridCellDefinition> cells;
|
protected List<GridCellDefinition> cells;
|
||||||
|
@ -99,6 +102,11 @@ abstract class GridContainer extends GridCellDefinition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use {@link org.betterx.ui.layout.components.Panel} instead
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class GridLayout extends GridColumn {
|
public class GridLayout extends GridColumn {
|
||||||
public static final int COLOR_WHITE = 0xFFFFFFFF;
|
public static final int COLOR_WHITE = 0xFFFFFFFF;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class GridMessageCell extends GridCell {
|
public class GridMessageCell extends GridCell {
|
||||||
private final Font font;
|
private final Font font;
|
||||||
|
|
|
@ -15,6 +15,10 @@ import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use {@link org.betterx.ui.layout.components.HorizontalStack} instead
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class GridRow extends GridContainer {
|
public class GridRow extends GridContainer {
|
||||||
public final GridLayout.VerticalAlignment alignment;
|
public final GridLayout.VerticalAlignment alignment;
|
||||||
|
|
|
@ -16,7 +16,10 @@ import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link org.betterx.ui.vanilla.LayoutScreen} or {@link org.betterx.ui.vanilla.LayoutScreenWithIcon} instead
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public abstract class GridScreen extends Screen {
|
public abstract class GridScreen extends Screen {
|
||||||
protected GridLayout grid = null;
|
protected GridLayout grid = null;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.network.chat.Component;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class GridStringCell extends GridCell {
|
public class GridStringCell extends GridCell {
|
||||||
private Component text;
|
private Component text;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.betterx.bclib.client.gui.gridlayout;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class GridTransform {
|
public class GridTransform {
|
||||||
public final int left;
|
public final int left;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
package org.betterx.bclib.client.gui.gridlayout;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public interface GridWidgetWithEnabledState {
|
public interface GridWidgetWithEnabledState {
|
||||||
boolean isEnabled();
|
boolean isEnabled();
|
||||||
void setEnabled(boolean enabled);
|
void setEnabled(boolean enabled);
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.betterx.ui.layout.components.Checkbox;
|
||||||
import org.betterx.ui.layout.components.HorizontalStack;
|
import org.betterx.ui.layout.components.HorizontalStack;
|
||||||
import org.betterx.ui.layout.components.LayoutComponent;
|
import org.betterx.ui.layout.components.LayoutComponent;
|
||||||
import org.betterx.ui.layout.components.VerticalStack;
|
import org.betterx.ui.layout.components.VerticalStack;
|
||||||
import org.betterx.ui.layout.values.Value;
|
|
||||||
import org.betterx.ui.vanilla.LayoutScreenWithIcon;
|
import org.betterx.ui.vanilla.LayoutScreenWithIcon;
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
@ -59,7 +58,7 @@ public class MainScreen extends LayoutScreenWithIcon {
|
||||||
row.addSpacer(option.leftPadding);
|
row.addSpacer(option.leftPadding);
|
||||||
}
|
}
|
||||||
Checkbox cb = row.addCheckbox(
|
Checkbox cb = row.addCheckbox(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
getComponent(config, option, "title"),
|
getComponent(config, option, "title"),
|
||||||
config.getRaw(option.token)
|
config.getRaw(option.token)
|
||||||
).onChange(
|
).onChange(
|
||||||
|
@ -84,7 +83,7 @@ public class MainScreen extends LayoutScreenWithIcon {
|
||||||
@Override
|
@Override
|
||||||
protected LayoutComponent initContent() {
|
protected LayoutComponent initContent() {
|
||||||
|
|
||||||
VerticalStack content = new VerticalStack(Value.fit(), Value.fit()).setDebugName("content");
|
VerticalStack content = new VerticalStack(fit(), fit()).setDebugName("content");
|
||||||
|
|
||||||
Configs.GENERATOR_CONFIG.getAllOptions()
|
Configs.GENERATOR_CONFIG.getAllOptions()
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -102,10 +101,10 @@ public class MainScreen extends LayoutScreenWithIcon {
|
||||||
.forEach(o -> addRow(content, Configs.CLIENT_CONFIG, o));
|
.forEach(o -> addRow(content, Configs.CLIENT_CONFIG, o));
|
||||||
|
|
||||||
|
|
||||||
VerticalStack grid = new VerticalStack(Value.fill(), Value.fill()).setDebugName("main grid");
|
VerticalStack grid = new VerticalStack(fill(), fill()).setDebugName("main grid");
|
||||||
grid.addScrollable(content);
|
grid.addScrollable(content);
|
||||||
grid.addSpacer(8);
|
grid.addSpacer(8);
|
||||||
grid.addButton(Value.fit(), Value.fit(), CommonComponents.GUI_DONE).onPress((button) -> {
|
grid.addButton(fit(), fit(), CommonComponents.GUI_DONE).onPress((button) -> {
|
||||||
Configs.CLIENT_CONFIG.saveChanges();
|
Configs.CLIENT_CONFIG.saveChanges();
|
||||||
Configs.GENERATOR_CONFIG.saveChanges();
|
Configs.GENERATOR_CONFIG.saveChanges();
|
||||||
Configs.MAIN_CONFIG.saveChanges();
|
Configs.MAIN_CONFIG.saveChanges();
|
||||||
|
|
|
@ -4,7 +4,6 @@ import org.betterx.bclib.BCLib;
|
||||||
import org.betterx.ui.ColorUtil;
|
import org.betterx.ui.ColorUtil;
|
||||||
import org.betterx.ui.layout.components.*;
|
import org.betterx.ui.layout.components.*;
|
||||||
import org.betterx.ui.layout.values.Size;
|
import org.betterx.ui.layout.values.Size;
|
||||||
import org.betterx.ui.layout.values.Value;
|
|
||||||
import org.betterx.ui.vanilla.LayoutScreen;
|
import org.betterx.ui.vanilla.LayoutScreen;
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
@ -25,76 +24,76 @@ public class TestScreen extends LayoutScreen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LayoutComponent<?, ?> initContent() {
|
protected LayoutComponent<?, ?> initContent() {
|
||||||
VerticalStack page1 = new VerticalStack(Value.fill(), Value.fit());
|
VerticalStack page1 = new VerticalStack(fill(), fit());
|
||||||
page1.addText(Value.fit(), Value.fit(), Component.literal("Page 1")).alignLeft().centerVertical();
|
page1.addText(fit(), fit(), Component.literal("Page 1")).alignLeft().centerVertical();
|
||||||
page1.addButton(Value.fit(), Value.fit(), Component.literal("A1")).onPress((bt) -> System.out.println("A1"))
|
page1.addButton(fit(), fit(), Component.literal("A1")).onPress((bt) -> System.out.println("A1"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
page1.addButton(Value.fit(), Value.fit(), Component.literal("A2")).onPress((bt) -> System.out.println("A2"))
|
page1.addButton(fit(), fit(), Component.literal("A2")).onPress((bt) -> System.out.println("A2"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
page1.addButton(Value.fit(), Value.fit(), Component.literal("A3")).onPress((bt) -> System.out.println("A3"))
|
page1.addButton(fit(), fit(), Component.literal("A3")).onPress((bt) -> System.out.println("A3"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
page1.addButton(Value.fit(), Value.fit(), Component.literal("A4")).onPress((bt) -> System.out.println("A4"))
|
page1.addButton(fit(), fit(), Component.literal("A4")).onPress((bt) -> System.out.println("A4"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
page1.addRange(Value.fixed(100), Value.fit(), Component.literal("N1"), 0, 10, 5);
|
page1.addRange(fixed(100), fit(), Component.literal("N1"), 0, 10, 5);
|
||||||
|
|
||||||
VerticalStack page2 = new VerticalStack(Value.fill(), Value.fit());
|
VerticalStack page2 = new VerticalStack(fill(), fit());
|
||||||
page2.addText(Value.fit(), Value.fit(), Component.literal("Page 2")).alignRight().centerVertical();
|
page2.addText(fit(), fit(), Component.literal("Page 2")).alignRight().centerVertical();
|
||||||
page2.addButton(Value.fit(), Value.fit(), Component.literal("B1")).onPress((bt) -> System.out.println("B1"))
|
page2.addButton(fit(), fit(), Component.literal("B1")).onPress((bt) -> System.out.println("B1"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
page2.addButton(Value.fit(), Value.fit(), Component.literal("B2")).onPress((bt) -> System.out.println("B2"))
|
page2.addButton(fit(), fit(), Component.literal("B2")).onPress((bt) -> System.out.println("B2"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
page2.addButton(Value.fit(), Value.fit(), Component.literal("B3")).onPress((bt) -> System.out.println("B3"))
|
page2.addButton(fit(), fit(), Component.literal("B3")).onPress((bt) -> System.out.println("B3"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
page2.addButton(Value.fit(), Value.fit(), Component.literal("B4")).onPress((bt) -> System.out.println("B4"))
|
page2.addButton(fit(), fit(), Component.literal("B4")).onPress((bt) -> System.out.println("B4"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
page2.addRange(Value.fixed(100), Value.fit(), Component.literal("N2"), 0, 10, 5);
|
page2.addRange(fixed(100), fit(), Component.literal("N2"), 0, 10, 5);
|
||||||
|
|
||||||
|
|
||||||
Container c = new Container(Value.fill(), Value.fixed(40));
|
Container c = new Container(fill(), fixed(40));
|
||||||
c.addChild(new Button(Value.fit(), Value.fit(), Component.literal("Containerd")).onPress(bt -> {
|
c.addChild(new Button(fit(), fit(), Component.literal("Containerd")).onPress(bt -> {
|
||||||
System.out.println("Containerd");
|
System.out.println("Containerd");
|
||||||
}).centerHorizontal().centerVertical());
|
}).centerHorizontal().centerVertical());
|
||||||
c.setBackgroundColor(0x77000000);
|
c.setBackgroundColor(0x77000000);
|
||||||
VerticalStack rows = new VerticalStack(Value.fit(), Value.fitOrFill());
|
VerticalStack rows = new VerticalStack(fit(), fitOrFill());
|
||||||
|
|
||||||
rows.addFiller();
|
rows.addFiller();
|
||||||
rows.add(new Text(
|
rows.add(new Text(
|
||||||
Value.fitOrFill(), Value.fixed(20),
|
fitOrFill(), fixed(20),
|
||||||
Component.literal("Some Text")
|
Component.literal("Some Text")
|
||||||
).alignRight()
|
).alignRight()
|
||||||
);
|
);
|
||||||
rows.add(new Text(
|
rows.add(new Text(
|
||||||
Value.fitOrFill(), Value.fixed(20),
|
fitOrFill(), fixed(20),
|
||||||
Component.literal("Some other, longer Text")
|
Component.literal("Some other, longer Text")
|
||||||
).centerHorizontal()
|
).centerHorizontal()
|
||||||
);
|
);
|
||||||
rows.addHorizontalSeparator(16).alignTop();
|
rows.addHorizontalSeparator(16).alignTop();
|
||||||
rows.add(new Tabs(Value.fixed(300), Value.fixed(80)).addPage(
|
rows.add(new Tabs(fixed(300), fixed(80)).addPage(
|
||||||
Component.literal("PAGE 1"),
|
Component.literal("PAGE 1"),
|
||||||
VerticalScroll.create(page1)
|
VerticalScroll.create(page1)
|
||||||
)
|
)
|
||||||
.addPage(
|
.addPage(
|
||||||
Component.literal("PAGE 2"),
|
Component.literal("PAGE 2"),
|
||||||
VerticalScroll.create(page2)
|
VerticalScroll.create(page2)
|
||||||
));
|
));
|
||||||
rows.add(new Input(Value.fitOrFill(), Value.fit(), Component.literal("Input"), "0xff00ff"));
|
rows.add(new Input(fitOrFill(), fit(), Component.literal("Input"), "0xff00ff"));
|
||||||
rows.add(new ColorSwatch(Value.fit(), Value.fit(), ColorUtil.LIGHT_PURPLE).centerHorizontal());
|
rows.add(new ColorSwatch(fit(), fit(), ColorUtil.LIGHT_PURPLE).centerHorizontal());
|
||||||
rows.add(new ColorPicker(
|
rows.add(new ColorPicker(
|
||||||
Value.fill(),
|
fill(),
|
||||||
Value.fit(),
|
fit(),
|
||||||
Component.literal("Color"),
|
Component.literal("Color"),
|
||||||
ColorUtil.GREEN
|
ColorUtil.GREEN
|
||||||
).centerHorizontal());
|
).centerHorizontal());
|
||||||
rows.add(new Text(
|
rows.add(new Text(
|
||||||
Value.fitOrFill(), Value.fixed(20),
|
fitOrFill(), fixed(20),
|
||||||
Component.literal("Some blue text")
|
Component.literal("Some blue text")
|
||||||
).centerHorizontal().setColor(ColorUtil.BLUE)
|
).centerHorizontal().setColor(ColorUtil.BLUE)
|
||||||
);
|
);
|
||||||
rows.addHLine(Value.fixed(32), Value.fixed(16));
|
rows.addHLine(fixed(32), fixed(16));
|
||||||
rows.add(c);
|
rows.add(c);
|
||||||
rows.addCheckbox(
|
rows.addCheckbox(
|
||||||
Value.fitOrFill(),
|
fitOrFill(),
|
||||||
Value.fit(),
|
fit(),
|
||||||
Component.literal("Hide"),
|
Component.literal("Hide"),
|
||||||
false
|
false
|
||||||
).onChange(
|
).onChange(
|
||||||
|
@ -102,13 +101,13 @@ public class TestScreen extends LayoutScreen {
|
||||||
);
|
);
|
||||||
rows.addSpacer(16);
|
rows.addSpacer(16);
|
||||||
rows.add(new Image(
|
rows.add(new Image(
|
||||||
Value.fixed(24), Value.fixed(24),
|
fixed(24), fixed(24),
|
||||||
BCLib.makeID("icon.png"),
|
BCLib.makeID("icon.png"),
|
||||||
new Size(512, 512)
|
new Size(512, 512)
|
||||||
).centerHorizontal()
|
).centerHorizontal()
|
||||||
);
|
);
|
||||||
rows.add(new MultiLineText(
|
rows.add(new MultiLineText(
|
||||||
Value.fill(), Value.fit(),
|
fill(), fit(),
|
||||||
Component.literal(
|
Component.literal(
|
||||||
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.")
|
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.")
|
||||||
).setColor(ColorUtil.LIGHT_PURPLE).centerHorizontal()
|
).setColor(ColorUtil.LIGHT_PURPLE).centerHorizontal()
|
||||||
|
@ -116,7 +115,7 @@ public class TestScreen extends LayoutScreen {
|
||||||
|
|
||||||
rows.addHorizontalLine(16);
|
rows.addHorizontalLine(16);
|
||||||
rows.add(new Range<>(
|
rows.add(new Range<>(
|
||||||
Value.fill(), Value.fit(),
|
fill(), fit(),
|
||||||
Component.literal("Integer"),
|
Component.literal("Integer"),
|
||||||
10, 90, 20
|
10, 90, 20
|
||||||
).onChange(
|
).onChange(
|
||||||
|
@ -126,7 +125,7 @@ public class TestScreen extends LayoutScreen {
|
||||||
));
|
));
|
||||||
rows.addSpacer(8);
|
rows.addSpacer(8);
|
||||||
rows.add(new Range<>(
|
rows.add(new Range<>(
|
||||||
Value.fill(), Value.fit(),
|
fill(), fit(),
|
||||||
Component.literal("Float"),
|
Component.literal("Float"),
|
||||||
10f, 90f, 20f
|
10f, 90f, 20f
|
||||||
).onChange(
|
).onChange(
|
||||||
|
@ -136,7 +135,7 @@ public class TestScreen extends LayoutScreen {
|
||||||
));
|
));
|
||||||
rows.addSpacer(16);
|
rows.addSpacer(16);
|
||||||
Checkbox cb1 = new Checkbox(
|
Checkbox cb1 = new Checkbox(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
Component.literal("Some Sub-State"),
|
Component.literal("Some Sub-State"),
|
||||||
false, true
|
false, true
|
||||||
).onChange(
|
).onChange(
|
||||||
|
@ -145,7 +144,7 @@ public class TestScreen extends LayoutScreen {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
rows.add(new Checkbox(
|
rows.add(new Checkbox(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
Component.literal("Some Selectable State"),
|
Component.literal("Some Selectable State"),
|
||||||
false, true
|
false, true
|
||||||
).onChange(
|
).onChange(
|
||||||
|
@ -157,7 +156,7 @@ public class TestScreen extends LayoutScreen {
|
||||||
rows.add(cb1);
|
rows.add(cb1);
|
||||||
rows.addSpacer(16);
|
rows.addSpacer(16);
|
||||||
rows.add(new Button(
|
rows.add(new Button(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
Component.literal("test")
|
Component.literal("test")
|
||||||
).onPress(
|
).onPress(
|
||||||
(bt) -> {
|
(bt) -> {
|
||||||
|
@ -167,7 +166,7 @@ public class TestScreen extends LayoutScreen {
|
||||||
);
|
);
|
||||||
rows.addSpacer(8);
|
rows.addSpacer(8);
|
||||||
rows.add(new Button(
|
rows.add(new Button(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
Component.literal("Hello World")
|
Component.literal("Hello World")
|
||||||
).onPress(
|
).onPress(
|
||||||
(bt) -> {
|
(bt) -> {
|
||||||
|
@ -177,6 +176,6 @@ public class TestScreen extends LayoutScreen {
|
||||||
);
|
);
|
||||||
rows.addFiller();
|
rows.addFiller();
|
||||||
|
|
||||||
return HorizontalStack.centered(VerticalScroll.create(Value.fit(), Value.relative(1), rows));
|
return HorizontalStack.centered(VerticalScroll.create(fit(), relative(1), rows));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.betterx.bclib.client.gui.screens;
|
||||||
|
|
||||||
|
import org.betterx.bclib.BCLib;
|
||||||
|
import org.betterx.ui.vanilla.LayoutScreenWithIcon;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public abstract class BCLibLayoutScreen extends LayoutScreenWithIcon {
|
||||||
|
static final ResourceLocation BCLIB_LOGO_LOCATION = new ResourceLocation(BCLib.MOD_ID, "icon.png");
|
||||||
|
|
||||||
|
public BCLibLayoutScreen(
|
||||||
|
Component component
|
||||||
|
) {
|
||||||
|
super(BCLIB_LOGO_LOCATION, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BCLibLayoutScreen(
|
||||||
|
@Nullable Screen parent,
|
||||||
|
Component component
|
||||||
|
) {
|
||||||
|
super(parent, BCLIB_LOGO_LOCATION, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BCLibLayoutScreen(
|
||||||
|
@Nullable Screen parent,
|
||||||
|
Component component,
|
||||||
|
int topPadding,
|
||||||
|
int bottomPadding,
|
||||||
|
int sidePadding
|
||||||
|
) {
|
||||||
|
super(parent, BCLIB_LOGO_LOCATION, component, topPadding, bottomPadding, sidePadding);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,61 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.screens;
|
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridRow;
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridScreen;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
abstract class BCLibScreen extends GridScreen {
|
|
||||||
static final ResourceLocation BCLIB_LOGO_LOCATION = new ResourceLocation(BCLib.MOD_ID, "icon.png");
|
|
||||||
|
|
||||||
public BCLibScreen(Component title) {
|
|
||||||
super(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLibScreen(@Nullable Screen parent, Component title) {
|
|
||||||
super(parent, title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLibScreen(Component title, int topPadding, boolean centerVertically) {
|
|
||||||
super(title, topPadding, 20, centerVertically);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLibScreen(@Nullable Screen parent, Component title, int topPadding, boolean centerVertically) {
|
|
||||||
super(parent, title, topPadding, centerVertically);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLibScreen(Component title, int topPadding, int sidePadding, boolean centerVertically) {
|
|
||||||
super(title, topPadding, sidePadding, centerVertically);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLibScreen(
|
|
||||||
@Nullable Screen parent,
|
|
||||||
Component title,
|
|
||||||
int topPadding,
|
|
||||||
int sidePadding,
|
|
||||||
boolean centerVertically
|
|
||||||
) {
|
|
||||||
super(parent, title, topPadding, sidePadding, centerVertically);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void addTitle() {
|
|
||||||
GridRow row = grid.addRow(GridLayout.VerticalAlignment.CENTER);
|
|
||||||
row.addFiller();
|
|
||||||
row.addImage(BCLIB_LOGO_LOCATION, 24, GridLayout.GridValueType.CONSTANT, 24, 512, 512);
|
|
||||||
row.addSpacer(4);
|
|
||||||
row.addString(this.title, this);
|
|
||||||
row.addFiller();
|
|
||||||
grid.addSpacerRow(15);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,10 @@
|
||||||
package org.betterx.bclib.client.gui.screens;
|
package org.betterx.bclib.client.gui.screens;
|
||||||
|
|
||||||
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridCheckboxCell;
|
import org.betterx.ui.layout.components.Checkbox;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
|
import org.betterx.ui.layout.components.HorizontalStack;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridRow;
|
import org.betterx.ui.layout.components.LayoutComponent;
|
||||||
|
import org.betterx.ui.layout.components.VerticalStack;
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.CommonComponents;
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
|
@ -15,7 +16,7 @@ import net.fabricmc.api.Environment;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class ConfirmFixScreen extends BCLibScreen {
|
public class ConfirmFixScreen extends BCLibLayoutScreen {
|
||||||
protected final ConfirmFixScreen.Listener listener;
|
protected final ConfirmFixScreen.Listener listener;
|
||||||
private final Component description;
|
private final Component description;
|
||||||
protected int id;
|
protected int id;
|
||||||
|
@ -27,48 +28,38 @@ public class ConfirmFixScreen extends BCLibScreen {
|
||||||
this.description = Component.translatable("bclib.datafixer.backupWarning.message");
|
this.description = Component.translatable("bclib.datafixer.backupWarning.message");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initLayout() {
|
|
||||||
final int BUTTON_HEIGHT = 20;
|
|
||||||
|
|
||||||
grid.addRow().addMessage(this.description, this.font, GridLayout.Alignment.CENTER);
|
|
||||||
grid.addSpacerRow();
|
|
||||||
|
|
||||||
GridRow row = grid.addRow();
|
|
||||||
GridCheckboxCell backup = row.addCheckbox(
|
|
||||||
Component.translatable("bclib.datafixer.backupWarning.backup"),
|
|
||||||
true,
|
|
||||||
BUTTON_HEIGHT,
|
|
||||||
this.font
|
|
||||||
);
|
|
||||||
|
|
||||||
grid.addSpacerRow(10);
|
|
||||||
|
|
||||||
row = grid.addRow();
|
|
||||||
GridCheckboxCell fix = row.addCheckbox(
|
|
||||||
Component.translatable("bclib.datafixer.backupWarning.fix"),
|
|
||||||
true,
|
|
||||||
BUTTON_HEIGHT,
|
|
||||||
this.font
|
|
||||||
);
|
|
||||||
|
|
||||||
grid.addSpacerRow(20);
|
|
||||||
|
|
||||||
row = grid.addRow();
|
|
||||||
row.addFiller();
|
|
||||||
row.addButton(CommonComponents.GUI_CANCEL, BUTTON_HEIGHT, this.font, (button) -> {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
row.addSpacer();
|
|
||||||
row.addButton(CommonComponents.GUI_PROCEED, BUTTON_HEIGHT, this.font, (button) -> {
|
|
||||||
this.listener.proceed(backup.isChecked(), fix.isChecked());
|
|
||||||
});
|
|
||||||
row.addFiller();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldCloseOnEsc() {
|
public boolean shouldCloseOnEsc() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LayoutComponent<?, ?> initContent() {
|
||||||
|
VerticalStack grid = new VerticalStack(fill(), fill());
|
||||||
|
grid.addFiller();
|
||||||
|
grid.addMultilineText(fill(), fit(), this.description).centerHorizontal();
|
||||||
|
grid.addSpacer(8);
|
||||||
|
Checkbox backup = grid.addCheckbox(
|
||||||
|
fit(), fit(),
|
||||||
|
Component.translatable("bclib.datafixer.backupWarning.backup"),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
grid.addSpacer(4);
|
||||||
|
Checkbox fix = grid.addCheckbox(
|
||||||
|
fit(), fit(),
|
||||||
|
Component.translatable("bclib.datafixer.backupWarning.fix"),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
grid.addSpacer(20);
|
||||||
|
|
||||||
|
HorizontalStack row = grid.addRow().centerHorizontal();
|
||||||
|
row.addButton(fit(), fit(), CommonComponents.GUI_CANCEL).onPress((button) -> onClose());
|
||||||
|
row.addSpacer(4);
|
||||||
|
row.addButton(fit(), fit(), CommonComponents.GUI_PROCEED)
|
||||||
|
.onPress((button) -> this.listener.proceed(backup.isChecked(), fix.isChecked()));
|
||||||
|
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
void proceed(boolean createBackup, boolean applyPatches);
|
void proceed(boolean createBackup, boolean applyPatches);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.betterx.bclib.client.gui.screens;
|
package org.betterx.bclib.client.gui.screens;
|
||||||
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
|
import org.betterx.ui.layout.components.LayoutComponent;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridRow;
|
import org.betterx.ui.layout.components.VerticalStack;
|
||||||
|
|
||||||
import net.minecraft.network.chat.CommonComponents;
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -11,7 +11,7 @@ import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class ConfirmRestartScreen extends BCLibScreen {
|
public class ConfirmRestartScreen extends BCLibLayoutScreen {
|
||||||
private final Component description;
|
private final Component description;
|
||||||
private final ConfirmRestartScreen.Listener listener;
|
private final ConfirmRestartScreen.Listener listener;
|
||||||
|
|
||||||
|
@ -26,25 +26,24 @@ public class ConfirmRestartScreen extends BCLibScreen {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initLayout() {
|
|
||||||
final int BUTTON_HEIGHT = 20;
|
|
||||||
|
|
||||||
grid.addRow().addMessage(this.description, this.font, GridLayout.Alignment.CENTER);
|
|
||||||
|
|
||||||
grid.addSpacerRow();
|
|
||||||
|
|
||||||
GridRow row = grid.addRow();
|
|
||||||
row.addFiller();
|
|
||||||
row.addButton(CommonComponents.GUI_PROCEED, BUTTON_HEIGHT, font, (button) -> {
|
|
||||||
listener.proceed();
|
|
||||||
});
|
|
||||||
row.addFiller();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldCloseOnEsc() {
|
public boolean shouldCloseOnEsc() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LayoutComponent<?, ?> initContent() {
|
||||||
|
VerticalStack grid = new VerticalStack(fill(), fill());
|
||||||
|
grid.addFiller();
|
||||||
|
grid.addMultilineText(fill(), fit(), this.description).centerHorizontal();
|
||||||
|
grid.addSpacer(10);
|
||||||
|
grid.addButton(fit(), fit(), CommonComponents.GUI_PROCEED)
|
||||||
|
.onPress((button) -> listener.proceed())
|
||||||
|
.centerHorizontal();
|
||||||
|
grid.addFiller();
|
||||||
|
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
void proceed();
|
void proceed();
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package org.betterx.bclib.client.gui.screens;
|
package org.betterx.bclib.client.gui.screens;
|
||||||
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridColumn;
|
import org.betterx.ui.ColorUtil;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
|
import org.betterx.ui.layout.components.HorizontalStack;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridRow;
|
import org.betterx.ui.layout.components.LayoutComponent;
|
||||||
|
import org.betterx.ui.layout.components.VerticalStack;
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.CommonComponents;
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
|
@ -12,47 +13,58 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class LevelFixErrorScreen extends BCLibScreen {
|
public class LevelFixErrorScreen extends BCLibLayoutScreen {
|
||||||
private final String[] errors;
|
private final String[] errors;
|
||||||
final Listener onContinue;
|
final Listener onContinue;
|
||||||
|
|
||||||
public LevelFixErrorScreen(Screen parent, String[] errors, Listener onContinue) {
|
public LevelFixErrorScreen(Screen parent, String[] errors, Listener onContinue) {
|
||||||
super(parent, Component.translatable("title.bclib.datafixer.error"), 10, true);
|
super(parent, Component.translatable("title.bclib.datafixer.error"), 10, 10, 10);
|
||||||
this.errors = errors;
|
this.errors = errors;
|
||||||
this.onContinue = onContinue;
|
this.onContinue = onContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initLayout() {
|
|
||||||
grid.addSpacerRow();
|
|
||||||
grid.addRow()
|
|
||||||
.addMessage(Component.translatable("message.bclib.datafixer.error"), font, GridLayout.Alignment.CENTER);
|
|
||||||
grid.addSpacerRow(8);
|
|
||||||
|
|
||||||
GridRow row = grid.addRow();
|
@Override
|
||||||
|
protected LayoutComponent<?, ?> initContent() {
|
||||||
|
VerticalStack grid = new VerticalStack(fill(), fill());
|
||||||
|
grid.addSpacer(4);
|
||||||
|
grid.addMultilineText(fill(), fit(), Component.translatable("message.bclib.datafixer.error"))
|
||||||
|
.centerHorizontal();
|
||||||
|
grid.addSpacer(8);
|
||||||
|
|
||||||
|
HorizontalStack row = new HorizontalStack(fill(), fit());
|
||||||
row.addSpacer(10);
|
row.addSpacer(10);
|
||||||
GridColumn col = row.addColumn(300, GridLayout.GridValueType.CONSTANT);
|
VerticalStack col = row.addColumn(fixed(300), fit());
|
||||||
|
grid.addScrollable(row);
|
||||||
|
|
||||||
for (String error : errors) {
|
for (String error : errors) {
|
||||||
Component dash = Component.literal("-");
|
Component dash = Component.literal("-");
|
||||||
row = col.addRow();
|
row = col.addRow();
|
||||||
row.addString(dash, this);
|
row.addText(fit(), fit(), dash);
|
||||||
|
|
||||||
row.addSpacer(4);
|
row.addSpacer(4);
|
||||||
row.addString(Component.literal(error), this);
|
row.addText(fit(), fit(), Component.literal(error)).setColor(ColorUtil.RED);
|
||||||
}
|
}
|
||||||
|
grid.addSpacer(8);
|
||||||
|
|
||||||
grid.addSpacerRow(8);
|
row = grid.addRow().centerHorizontal();
|
||||||
row = grid.addRow();
|
row.addButton(
|
||||||
row.addFiller();
|
fit(), fit(),
|
||||||
row.addButton(Component.translatable("title.bclib.datafixer.error.continue"), 0.5f, 20, font, (n) -> {
|
Component.translatable("title.bclib.datafixer.error.continue")
|
||||||
|
).setAlpha(0.5f).onPress((n) -> {
|
||||||
onClose();
|
onClose();
|
||||||
onContinue.doContinue(true);
|
onContinue.doContinue(true);
|
||||||
});
|
});
|
||||||
row.addSpacer();
|
row.addSpacer(4);
|
||||||
row.addButton(CommonComponents.GUI_CANCEL, 20, font, (n) -> {
|
row.addButton(
|
||||||
|
fit(), fit(),
|
||||||
|
CommonComponents.GUI_CANCEL
|
||||||
|
).onPress((n) -> {
|
||||||
this.minecraft.setScreen(null);
|
this.minecraft.setScreen(null);
|
||||||
});
|
});
|
||||||
row.addFiller();
|
|
||||||
|
|
||||||
|
return grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package org.betterx.bclib.client.gui.screens;
|
package org.betterx.bclib.client.gui.screens;
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.HelloClient;
|
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.HelloClient;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridColumn;
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
|
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridRow;
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridScreen;
|
|
||||||
import org.betterx.bclib.util.Triple;
|
import org.betterx.bclib.util.Triple;
|
||||||
|
import org.betterx.ui.layout.components.HorizontalStack;
|
||||||
|
import org.betterx.ui.layout.components.LayoutComponent;
|
||||||
|
import org.betterx.ui.layout.components.Text;
|
||||||
|
import org.betterx.ui.layout.components.VerticalStack;
|
||||||
import org.betterx.worlds.together.util.ModUtil;
|
import org.betterx.worlds.together.util.ModUtil;
|
||||||
import org.betterx.worlds.together.util.PathUtil;
|
import org.betterx.worlds.together.util.PathUtil;
|
||||||
|
|
||||||
|
@ -21,8 +22,7 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class ModListScreen extends BCLibScreen {
|
public class ModListScreen extends BCLibLayoutScreen {
|
||||||
|
|
||||||
private final List<ModUtil.ModInfo> mods;
|
private final List<ModUtil.ModInfo> mods;
|
||||||
private final HelloClient.IServerModMap serverInfo;
|
private final HelloClient.IServerModMap serverInfo;
|
||||||
private final Component description;
|
private final Component description;
|
||||||
|
@ -73,7 +73,7 @@ public class ModListScreen extends BCLibScreen {
|
||||||
List<ModUtil.ModInfo> mods,
|
List<ModUtil.ModInfo> mods,
|
||||||
HelloClient.IServerModMap serverInfo
|
HelloClient.IServerModMap serverInfo
|
||||||
) {
|
) {
|
||||||
super(parent, title, 10, true);
|
super(parent, title);
|
||||||
this.mods = mods;
|
this.mods = mods;
|
||||||
this.serverInfo = serverInfo;
|
this.serverInfo = serverInfo;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
@ -105,10 +105,9 @@ public class ModListScreen extends BCLibScreen {
|
||||||
|
|
||||||
|
|
||||||
public static void addModDesc(
|
public static void addModDesc(
|
||||||
GridColumn grid,
|
VerticalStack grid,
|
||||||
java.util.List<ModUtil.ModInfo> mods,
|
java.util.List<ModUtil.ModInfo> mods,
|
||||||
HelloClient.IServerModMap serverInfo,
|
HelloClient.IServerModMap serverInfo
|
||||||
GridScreen parent
|
|
||||||
) {
|
) {
|
||||||
final int STATE_OK = 6;
|
final int STATE_OK = 6;
|
||||||
final int STATE_SERVER_MISSING_CLIENT_MOD = 5;
|
final int STATE_SERVER_MISSING_CLIENT_MOD = 5;
|
||||||
|
@ -190,6 +189,7 @@ public class ModListScreen extends BCLibScreen {
|
||||||
});
|
});
|
||||||
|
|
||||||
items.stream()
|
items.stream()
|
||||||
|
.filter(t -> t.second != STATE_SERVER_MISSING)
|
||||||
.sorted(Comparator.comparing(a -> a.second + a.first.toLowerCase(Locale.ROOT)))
|
.sorted(Comparator.comparing(a -> a.second + a.first.toLowerCase(Locale.ROOT)))
|
||||||
.forEach(t -> {
|
.forEach(t -> {
|
||||||
final String name = t.first;
|
final String name = t.first;
|
||||||
|
@ -223,46 +223,46 @@ public class ModListScreen extends BCLibScreen {
|
||||||
}
|
}
|
||||||
Component dash = Component.literal("-");
|
Component dash = Component.literal("-");
|
||||||
Component typeTextComponent = Component.literal(typeText);
|
Component typeTextComponent = Component.literal(typeText);
|
||||||
GridRow row = grid.addRow();
|
HorizontalStack row = grid.addRow();
|
||||||
|
|
||||||
row.addString(dash, parent);
|
Text dashText = row.addText(fit(), fit(), dash);
|
||||||
|
|
||||||
row.addSpacer(4);
|
row.addSpacer(4);
|
||||||
row.addString(Component.literal(name), parent);
|
row.addText(fit(), fit(), Component.literal(name));
|
||||||
|
|
||||||
row.addSpacer(4);
|
row.addSpacer(4);
|
||||||
row.addString(typeTextComponent, color, parent);
|
row.addText(fit(), fit(), typeTextComponent).setColor(color);
|
||||||
|
|
||||||
if (!stateString.isEmpty()) {
|
if (!stateString.isEmpty()) {
|
||||||
row = grid.addRow();
|
row = grid.addRow();
|
||||||
row.addSpacer(4 + parent.getWidth(dash));
|
row.addSpacer(4 + dashText.getContentWidth());
|
||||||
row.addString(Component.literal(stateString), GridLayout.COLOR_GRAY, parent);
|
row.addText(fit(), fit(), Component.literal(stateString))
|
||||||
|
.setColor(GridLayout.COLOR_GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
grid.addSpacerRow();
|
grid.addSpacer(4);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initLayout() {
|
protected LayoutComponent<?, ?> initContent() {
|
||||||
|
VerticalStack grid = new VerticalStack(fill(), fill());
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
grid.addSpacerRow();
|
grid.addSpacer(4);
|
||||||
grid.addRow().addMessage(description, font, GridLayout.Alignment.CENTER);
|
grid.addMultilineText(fill(), fit(), description).centerHorizontal();
|
||||||
grid.addSpacerRow(8);
|
grid.addSpacer(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
GridRow row = grid.addRow();
|
HorizontalStack row = new HorizontalStack(fill(), fit());
|
||||||
row.addSpacer(10);
|
row.addSpacer(10);
|
||||||
GridColumn col = row.addColumn(200, GridLayout.GridValueType.CONSTANT);
|
VerticalStack col = row.addColumn(fixed(200), fit());
|
||||||
addModDesc(col, mods, serverInfo, this);
|
addModDesc(col, mods, serverInfo);
|
||||||
|
grid.addScrollable(row);
|
||||||
|
|
||||||
grid.addSpacerRow(8);
|
grid.addSpacer(8);
|
||||||
row = grid.addRow();
|
grid.addButton(fit(), fit(), buttonTitle).onPress((n) -> onClose()).centerHorizontal();
|
||||||
row.addFiller();
|
|
||||||
row.addButton(buttonTitle, 20, font, (n) -> {
|
return grid;
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
row.addFiller();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package org.betterx.bclib.client.gui.screens;
|
package org.betterx.bclib.client.gui.screens;
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
import org.betterx.bclib.BCLib;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.*;
|
import org.betterx.ui.ColorUtil;
|
||||||
|
import org.betterx.ui.layout.components.*;
|
||||||
|
import org.betterx.ui.layout.values.Rectangle;
|
||||||
|
import org.betterx.ui.layout.values.Value;
|
||||||
|
import org.betterx.ui.vanilla.LayoutScreen;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
@ -16,7 +20,7 @@ import net.minecraft.util.ProgressListener;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
class ProgressLogoRender extends GridCustomRenderCell {
|
class ProgressLogoRender extends CustomRenderComponent<ProgressLogoRender> {
|
||||||
public static final int SIZE = 64;
|
public static final int SIZE = 64;
|
||||||
public static final int LOGO_SIZE = 512;
|
public static final int LOGO_SIZE = 512;
|
||||||
public static final int PIXELATED_SIZE = 512;
|
public static final int PIXELATED_SIZE = 512;
|
||||||
|
@ -24,19 +28,38 @@ class ProgressLogoRender extends GridCustomRenderCell {
|
||||||
double time = 0;
|
double time = 0;
|
||||||
|
|
||||||
protected ProgressLogoRender() {
|
protected ProgressLogoRender() {
|
||||||
super(SIZE, GridLayout.GridValueType.CONSTANT, SIZE);
|
super(Value.fixed(SIZE), Value.fixed(SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRender(PoseStack poseStack, GridTransform transform, Object context) {
|
public int getContentWidth() {
|
||||||
time += 0.03;
|
return SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getContentHeight() {
|
||||||
|
return SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void customRender(
|
||||||
|
PoseStack poseStack,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
float deltaTicks,
|
||||||
|
Rectangle transform,
|
||||||
|
Rectangle clipRect
|
||||||
|
) {
|
||||||
|
//time += 0.03;
|
||||||
|
time += deltaTicks * 0.1;
|
||||||
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0f);
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0f);
|
||||||
|
|
||||||
final int yBarLocal = (int) (transform.height * percentage);
|
final int yBarLocal = (int) (transform.height * percentage);
|
||||||
final int yBar = transform.top + yBarLocal;
|
final int yBar = yBarLocal;
|
||||||
|
|
||||||
final float fScale = (float) (0.3 * ((Math.sin(time) + 1.0) * 0.5) + 0.7);
|
final float fScale = (float) (0.3 * ((Math.sin(time) + 1.0) * 0.5) + 0.7);
|
||||||
int height = (int) (transform.height * fScale);
|
int height = (int) (transform.height * fScale);
|
||||||
|
@ -53,10 +76,10 @@ class ProgressLogoRender extends GridCustomRenderCell {
|
||||||
|
|
||||||
if (yBarImage > 0) {
|
if (yBarImage > 0) {
|
||||||
final int uvTopLogo = (int) (relativeY * LOGO_SIZE);
|
final int uvTopLogo = (int) (relativeY * LOGO_SIZE);
|
||||||
RenderSystem.setShaderTexture(0, BCLibScreen.BCLIB_LOGO_LOCATION);
|
RenderSystem.setShaderTexture(0, BCLibLayoutScreen.BCLIB_LOGO_LOCATION);
|
||||||
GuiComponent.blit(poseStack,
|
GuiComponent.blit(poseStack,
|
||||||
xOffset + transform.left,
|
xOffset,
|
||||||
yOffset + transform.top,
|
yOffset,
|
||||||
width,
|
width,
|
||||||
yBarImage,
|
yBarImage,
|
||||||
0, 0, LOGO_SIZE, uvTopLogo,
|
0, 0, LOGO_SIZE, uvTopLogo,
|
||||||
|
@ -68,8 +91,8 @@ class ProgressLogoRender extends GridCustomRenderCell {
|
||||||
final int uvTopPixelated = (int) (relativeY * PIXELATED_SIZE);
|
final int uvTopPixelated = (int) (relativeY * PIXELATED_SIZE);
|
||||||
RenderSystem.setShaderTexture(0, ProgressScreen.BCLIB_LOGO_PIXELATED_LOCATION);
|
RenderSystem.setShaderTexture(0, ProgressScreen.BCLIB_LOGO_PIXELATED_LOCATION);
|
||||||
GuiComponent.blit(poseStack,
|
GuiComponent.blit(poseStack,
|
||||||
xOffset + transform.left,
|
xOffset,
|
||||||
yOffset + transform.top + yBarImage,
|
yOffset + yBarImage,
|
||||||
width,
|
width,
|
||||||
height - yBarImage,
|
height - yBarImage,
|
||||||
0, uvTopPixelated, PIXELATED_SIZE, PIXELATED_SIZE - uvTopPixelated,
|
0, uvTopPixelated, PIXELATED_SIZE, PIXELATED_SIZE - uvTopPixelated,
|
||||||
|
@ -80,9 +103,9 @@ class ProgressLogoRender extends GridCustomRenderCell {
|
||||||
if (percentage > 0 && percentage < 1.0) {
|
if (percentage > 0 && percentage < 1.0) {
|
||||||
GuiComponent.fill(
|
GuiComponent.fill(
|
||||||
poseStack,
|
poseStack,
|
||||||
transform.left,
|
0,
|
||||||
yBar,
|
yBar,
|
||||||
transform.left + transform.width,
|
transform.width,
|
||||||
yBar + 1,
|
yBar + 1,
|
||||||
0x3FFFFFFF
|
0x3FFFFFFF
|
||||||
);
|
);
|
||||||
|
@ -90,7 +113,7 @@ class ProgressLogoRender extends GridCustomRenderCell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ProgressScreen extends GridScreen implements ProgressListener, AtomicProgressListener {
|
public class ProgressScreen extends LayoutScreen implements ProgressListener, AtomicProgressListener {
|
||||||
|
|
||||||
static final ResourceLocation BCLIB_LOGO_PIXELATED_LOCATION = new ResourceLocation(
|
static final ResourceLocation BCLIB_LOGO_PIXELATED_LOCATION = new ResourceLocation(
|
||||||
BCLib.MOD_ID,
|
BCLib.MOD_ID,
|
||||||
|
@ -98,15 +121,16 @@ public class ProgressScreen extends GridScreen implements ProgressListener, Atom
|
||||||
);
|
);
|
||||||
|
|
||||||
public ProgressScreen(@Nullable Screen parent, Component title, Component description) {
|
public ProgressScreen(@Nullable Screen parent, Component title, Component description) {
|
||||||
super(parent, title, 20, true);
|
super(parent, title);
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Component description;
|
Component description;
|
||||||
private Component stageComponent;
|
private Component stageComponent;
|
||||||
private GridMessageCell stage;
|
private MultiLineText stage;
|
||||||
private GridStringCell progress;
|
private HorizontalStack stageRow;
|
||||||
|
private Text progress;
|
||||||
private ProgressLogoRender progressImage;
|
private ProgressLogoRender progressImage;
|
||||||
private int currentProgress = 0;
|
private int currentProgress = 0;
|
||||||
private AtomicInteger atomicCounter;
|
private AtomicInteger atomicCounter;
|
||||||
|
@ -136,34 +160,6 @@ public class ProgressScreen extends GridScreen implements ProgressListener, Atom
|
||||||
return Component.translatable("title.bclib.progress").append(": " + pg + "%");
|
return Component.translatable("title.bclib.progress").append(": " + pg + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initLayout() {
|
|
||||||
grid.addSpacerRow();
|
|
||||||
|
|
||||||
GridRow row = grid.addRow(GridLayout.VerticalAlignment.CENTER);
|
|
||||||
row.addFiller();
|
|
||||||
progressImage = new ProgressLogoRender();
|
|
||||||
progressImage.percentage = currentProgress / 100.0f;
|
|
||||||
row.addCustomRender(progressImage);
|
|
||||||
row.addSpacer();
|
|
||||||
|
|
||||||
int textWidth = Math.max(getWidth(description), getWidth(getProgressComponent(100)));
|
|
||||||
GridColumn textCol = row.addColumn(0, GridLayout.GridValueType.INHERIT);
|
|
||||||
textCol.addRow().addString(description, this);
|
|
||||||
textCol.addSpacerRow();
|
|
||||||
progress = textCol.addRow()
|
|
||||||
.addString(getProgressComponent(), GridLayout.COLOR_GRAY, GridLayout.Alignment.LEFT, this);
|
|
||||||
|
|
||||||
row.addFiller();
|
|
||||||
|
|
||||||
grid.addSpacerRow(20);
|
|
||||||
row = grid.addRow();
|
|
||||||
stage = row.addMessage(
|
|
||||||
stageComponent != null ? stageComponent : Component.literal(""),
|
|
||||||
font,
|
|
||||||
GridLayout.Alignment.CENTER
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void progressStartNoAbort(Component text) {
|
public void progressStartNoAbort(Component text) {
|
||||||
|
@ -180,6 +176,7 @@ public class ProgressScreen extends GridScreen implements ProgressListener, Atom
|
||||||
public void progressStage(Component text) {
|
public void progressStage(Component text) {
|
||||||
stageComponent = text;
|
stageComponent = text;
|
||||||
if (stage != null) stage.setText(text);
|
if (stage != null) stage.setText(text);
|
||||||
|
if (stageRow != null) stageRow.reCalculateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -195,4 +192,42 @@ public class ProgressScreen extends GridScreen implements ProgressListener, Atom
|
||||||
public void stop() {
|
public void stop() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LayoutComponent<?, ?> addTitle(LayoutComponent<?, ?> content) {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LayoutComponent<?, ?> initContent() {
|
||||||
|
VerticalStack grid = new VerticalStack(fill(), fill()).setDebugName("grid");
|
||||||
|
grid.addFiller();
|
||||||
|
grid.add(buildTitle());
|
||||||
|
grid.addSpacer(4);
|
||||||
|
|
||||||
|
HorizontalStack contentRow = grid.addRow(fit(), fit())
|
||||||
|
.centerHorizontal()
|
||||||
|
.setDebugName("contentRow");
|
||||||
|
|
||||||
|
progressImage = new ProgressLogoRender();
|
||||||
|
progressImage.percentage = currentProgress / 100.0f;
|
||||||
|
contentRow.add(progressImage);
|
||||||
|
contentRow.addSpacer(8);
|
||||||
|
|
||||||
|
VerticalStack textCol = contentRow.addColumn(fit(), fit()).setDebugName("textCol").centerVertical();
|
||||||
|
textCol.addText(fit(), fit(), description);
|
||||||
|
textCol.addSpacer(4);
|
||||||
|
progress = textCol.addText(fit(), fit(), getProgressComponent()).setColor(ColorUtil.GRAY);
|
||||||
|
|
||||||
|
|
||||||
|
grid.addSpacer(20);
|
||||||
|
stageRow = grid.addRow(fill(), fit());
|
||||||
|
stage = stageRow.addMultilineText(
|
||||||
|
fill(), fit(),
|
||||||
|
stageComponent != null ? stageComponent : Component.literal("")
|
||||||
|
).centerHorizontal();
|
||||||
|
grid.addFiller();
|
||||||
|
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package org.betterx.bclib.client.gui.screens;
|
package org.betterx.bclib.client.gui.screens;
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.HelloClient;
|
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.HelloClient;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridCheckboxCell;
|
import org.betterx.ui.layout.components.Checkbox;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
|
import org.betterx.ui.layout.components.HorizontalStack;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridRow;
|
import org.betterx.ui.layout.components.LayoutComponent;
|
||||||
|
import org.betterx.ui.layout.components.VerticalStack;
|
||||||
import org.betterx.worlds.together.util.ModUtil;
|
import org.betterx.worlds.together.util.ModUtil;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -14,7 +15,7 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class SyncFilesScreen extends BCLibScreen {
|
public class SyncFilesScreen extends BCLibLayoutScreen {
|
||||||
private final Component description;
|
private final Component description;
|
||||||
private final SyncFilesScreen.Listener listener;
|
private final SyncFilesScreen.Listener listener;
|
||||||
private final boolean hasConfigFiles;
|
private final boolean hasConfigFiles;
|
||||||
|
@ -44,29 +45,36 @@ public class SyncFilesScreen extends BCLibScreen {
|
||||||
this.shouldDelete = deleteFiles > 0;
|
this.shouldDelete = deleteFiles > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initLayout() {
|
|
||||||
|
public boolean shouldCloseOnEsc() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LayoutComponent<?, ?> initContent() {
|
||||||
|
VerticalStack grid = new VerticalStack(fill(), fill());
|
||||||
final int BUTTON_HEIGHT = 20;
|
final int BUTTON_HEIGHT = 20;
|
||||||
|
|
||||||
grid.addRow()
|
grid.addMultilineText(fill(), fit(), this.description).centerHorizontal();
|
||||||
.addMessage(this.description, this.font, GridLayout.Alignment.CENTER);
|
|
||||||
|
|
||||||
grid.addSpacerRow(10);
|
grid.addSpacer(10);
|
||||||
|
|
||||||
GridRow row;
|
HorizontalStack row;
|
||||||
|
|
||||||
|
final Checkbox mods;
|
||||||
final GridCheckboxCell mods;
|
|
||||||
row = grid.addRow();
|
row = grid.addRow();
|
||||||
mods = row.addCheckbox(
|
mods = row.addCheckbox(
|
||||||
|
fit(), fit(),
|
||||||
Component.translatable("message.bclib.syncfiles.mods"),
|
Component.translatable("message.bclib.syncfiles.mods"),
|
||||||
hasMods,
|
hasMods
|
||||||
BUTTON_HEIGHT,
|
|
||||||
this.font
|
|
||||||
);
|
);
|
||||||
mods.setEnabled(hasMods);
|
mods.setEnabled(hasMods);
|
||||||
|
|
||||||
row.addSpacer();
|
row.addSpacer(4);
|
||||||
row.addButton(Component.translatable("title.bclib.syncfiles.modInfo"), 20, font, (button) -> {
|
row.addButton(
|
||||||
|
fit(), fit(),
|
||||||
|
Component.translatable("title.bclib.syncfiles.modInfo")
|
||||||
|
).onPress((button) -> {
|
||||||
ModListScreen scr = new ModListScreen(
|
ModListScreen scr = new ModListScreen(
|
||||||
this,
|
this,
|
||||||
Component.translatable("title.bclib.syncfiles.modlist"),
|
Component.translatable("title.bclib.syncfiles.modlist"),
|
||||||
|
@ -77,51 +85,47 @@ public class SyncFilesScreen extends BCLibScreen {
|
||||||
Minecraft.getInstance().setScreen(scr);
|
Minecraft.getInstance().setScreen(scr);
|
||||||
});
|
});
|
||||||
|
|
||||||
grid.addSpacerRow();
|
grid.addSpacer(4);
|
||||||
|
|
||||||
|
|
||||||
final GridCheckboxCell configs;
|
final Checkbox configs;
|
||||||
row = grid.addRow();
|
row = grid.addRow();
|
||||||
configs = row.addCheckbox(
|
configs = row.addCheckbox(
|
||||||
|
fit(), fit(),
|
||||||
Component.translatable("message.bclib.syncfiles.configs"),
|
Component.translatable("message.bclib.syncfiles.configs"),
|
||||||
hasConfigFiles,
|
hasConfigFiles
|
||||||
BUTTON_HEIGHT,
|
|
||||||
this.font
|
|
||||||
);
|
);
|
||||||
configs.setEnabled(hasConfigFiles);
|
configs.setEnabled(hasConfigFiles);
|
||||||
|
|
||||||
grid.addSpacerRow();
|
grid.addSpacer(4);
|
||||||
|
|
||||||
row = grid.addRow();
|
row = grid.addRow();
|
||||||
|
|
||||||
final GridCheckboxCell folder;
|
final Checkbox folder;
|
||||||
folder = row.addCheckbox(
|
folder = row.addCheckbox(
|
||||||
|
fit(), fit(),
|
||||||
Component.translatable("message.bclib.syncfiles.folders"),
|
Component.translatable("message.bclib.syncfiles.folders"),
|
||||||
hasFiles,
|
hasFiles
|
||||||
BUTTON_HEIGHT,
|
|
||||||
this.font
|
|
||||||
);
|
);
|
||||||
folder.setEnabled(hasFiles);
|
folder.setEnabled(hasFiles);
|
||||||
row.addSpacer();
|
row.addSpacer(4);
|
||||||
|
|
||||||
GridCheckboxCell delete;
|
Checkbox delete;
|
||||||
delete = row.addCheckbox(
|
delete = row.addCheckbox(
|
||||||
|
fit(), fit(),
|
||||||
Component.translatable("message.bclib.syncfiles.delete"),
|
Component.translatable("message.bclib.syncfiles.delete"),
|
||||||
shouldDelete,
|
shouldDelete
|
||||||
BUTTON_HEIGHT,
|
|
||||||
this.font
|
|
||||||
);
|
);
|
||||||
delete.setEnabled(shouldDelete);
|
delete.setEnabled(shouldDelete);
|
||||||
|
|
||||||
|
|
||||||
grid.addSpacerRow(30);
|
grid.addSpacer(30);
|
||||||
row = grid.addRow();
|
row = grid.addRow().centerHorizontal();
|
||||||
row.addFiller();
|
row.addButton(fit(), fit(), CommonComponents.GUI_NO).onPress((button) -> {
|
||||||
row.addButton(CommonComponents.GUI_NO, BUTTON_HEIGHT, this.font, (button) -> {
|
|
||||||
listener.proceed(false, false, false, false);
|
listener.proceed(false, false, false, false);
|
||||||
});
|
});
|
||||||
row.addSpacer();
|
row.addSpacer(4);
|
||||||
row.addButton(CommonComponents.GUI_YES, BUTTON_HEIGHT, this.font, (button) -> {
|
row.addButton(fit(), fit(), CommonComponents.GUI_YES).onPress((button) -> {
|
||||||
listener.proceed(
|
listener.proceed(
|
||||||
mods.isChecked(),
|
mods.isChecked(),
|
||||||
configs.isChecked(),
|
configs.isChecked(),
|
||||||
|
@ -129,11 +133,8 @@ public class SyncFilesScreen extends BCLibScreen {
|
||||||
delete.isChecked()
|
delete.isChecked()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
row.addFiller();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldCloseOnEsc() {
|
return grid;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package org.betterx.bclib.client.gui.screens;
|
package org.betterx.bclib.client.gui.screens;
|
||||||
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
|
import org.betterx.ui.layout.components.HorizontalStack;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridRow;
|
import org.betterx.ui.layout.components.LayoutComponent;
|
||||||
|
import org.betterx.ui.layout.components.VerticalStack;
|
||||||
|
|
||||||
import net.minecraft.network.chat.CommonComponents;
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -10,7 +11,7 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class WarnBCLibVersionMismatch extends BCLibScreen {
|
public class WarnBCLibVersionMismatch extends BCLibLayoutScreen {
|
||||||
private final Component description;
|
private final Component description;
|
||||||
private final Listener listener;
|
private final Listener listener;
|
||||||
|
|
||||||
|
@ -21,27 +22,26 @@ public class WarnBCLibVersionMismatch extends BCLibScreen {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initLayout() {
|
|
||||||
final int BUTTON_HEIGHT = 20;
|
|
||||||
|
|
||||||
grid.addRow().addMessage(this.description, this.font, GridLayout.Alignment.CENTER);
|
|
||||||
grid.addSpacerRow(20);
|
|
||||||
GridRow row = grid.addRow();
|
|
||||||
row.addFiller();
|
|
||||||
row.addButton(CommonComponents.GUI_NO, BUTTON_HEIGHT, this.font, (button) -> {
|
|
||||||
listener.proceed(false);
|
|
||||||
});
|
|
||||||
row.addSpacer();
|
|
||||||
row.addButton(CommonComponents.GUI_YES, BUTTON_HEIGHT, this.font, (button) -> {
|
|
||||||
listener.proceed(true);
|
|
||||||
});
|
|
||||||
row.addFiller();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldCloseOnEsc() {
|
public boolean shouldCloseOnEsc() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LayoutComponent<?, ?> initContent() {
|
||||||
|
VerticalStack grid = new VerticalStack(fill(), fill());
|
||||||
|
grid.addFiller();
|
||||||
|
grid.addMultilineText(fill(), fit(), this.description).centerHorizontal();
|
||||||
|
grid.addSpacer(20);
|
||||||
|
|
||||||
|
HorizontalStack row = grid.addRow().centerHorizontal();
|
||||||
|
row.addButton(fit(), fit(), CommonComponents.GUI_NO).onPress((button) -> listener.proceed(false));
|
||||||
|
row.addSpacer(4);
|
||||||
|
row.addButton(fit(), fit(), CommonComponents.GUI_YES).onPress((button) -> listener.proceed(true));
|
||||||
|
|
||||||
|
grid.addFiller();
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
void proceed(boolean download);
|
void proceed(boolean download);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.betterx.bclib.client.gui.screens;
|
package org.betterx.bclib.client.gui.screens;
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
|
||||||
import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
||||||
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
|
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
|
||||||
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
||||||
|
@ -9,7 +8,6 @@ import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||||
import org.betterx.bclib.registry.PresetsRegistry;
|
import org.betterx.bclib.registry.PresetsRegistry;
|
||||||
import org.betterx.ui.layout.components.*;
|
import org.betterx.ui.layout.components.*;
|
||||||
import org.betterx.ui.layout.values.Size;
|
import org.betterx.ui.layout.values.Size;
|
||||||
import org.betterx.ui.layout.values.Value;
|
|
||||||
import org.betterx.ui.vanilla.LayoutScreen;
|
import org.betterx.ui.vanilla.LayoutScreen;
|
||||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||||
import org.betterx.worlds.together.worldPreset.WorldGenSettingsComponentAccessor;
|
import org.betterx.worlds.together.worldPreset.WorldGenSettingsComponentAccessor;
|
||||||
|
@ -20,7 +18,6 @@ import net.minecraft.core.Holder;
|
||||||
import net.minecraft.network.chat.CommonComponents;
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
||||||
import net.minecraft.world.level.dimension.DimensionType;
|
import net.minecraft.world.level.dimension.DimensionType;
|
||||||
|
@ -36,8 +33,6 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class WorldSetupScreen extends LayoutScreen {
|
public class WorldSetupScreen extends LayoutScreen {
|
||||||
static final ResourceLocation BCLIB_LOGO_LOCATION = new ResourceLocation(BCLib.MOD_ID, "icon.png");
|
|
||||||
|
|
||||||
private final WorldCreationContext context;
|
private final WorldCreationContext context;
|
||||||
private final CreateWorldScreen createWorldScreen;
|
private final CreateWorldScreen createWorldScreen;
|
||||||
private Range<Integer> landBiomeSize;
|
private Range<Integer> landBiomeSize;
|
||||||
|
@ -61,17 +56,17 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
Checkbox netherLegacy;
|
Checkbox netherLegacy;
|
||||||
|
|
||||||
public LayoutComponent<?, ?> netherPage(BCLNetherBiomeSourceConfig netherConfig) {
|
public LayoutComponent<?, ?> netherPage(BCLNetherBiomeSourceConfig netherConfig) {
|
||||||
VerticalStack content = new VerticalStack(Value.fill(), Value.fit()).centerHorizontal();
|
VerticalStack content = new VerticalStack(fill(), fit()).centerHorizontal();
|
||||||
content.addSpacer(8);
|
content.addSpacer(8);
|
||||||
|
|
||||||
bclibNether = content.addCheckbox(
|
bclibNether = content.addCheckbox(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.custom_biome_source"),
|
Component.translatable("title.screen.bclib.worldgen.custom_biome_source"),
|
||||||
netherConfig.mapVersion != BCLNetherBiomeSourceConfig.NetherBiomeMapType.VANILLA
|
netherConfig.mapVersion != BCLNetherBiomeSourceConfig.NetherBiomeMapType.VANILLA
|
||||||
);
|
);
|
||||||
|
|
||||||
netherLegacy = content.indent(20).addCheckbox(
|
netherLegacy = content.indent(20).addCheckbox(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
||||||
netherConfig.mapVersion == BCLNetherBiomeSourceConfig.NetherBiomeMapType.SQUARE
|
netherConfig.mapVersion == BCLNetherBiomeSourceConfig.NetherBiomeMapType.SQUARE
|
||||||
);
|
);
|
||||||
|
@ -86,40 +81,40 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LayoutComponent<?, ?> endPage(BCLEndBiomeSourceConfig endConfig) {
|
public LayoutComponent<?, ?> endPage(BCLEndBiomeSourceConfig endConfig) {
|
||||||
VerticalStack content = new VerticalStack(Value.fill(), Value.fit()).centerHorizontal();
|
VerticalStack content = new VerticalStack(fill(), fit()).centerHorizontal();
|
||||||
content.addSpacer(8);
|
content.addSpacer(8);
|
||||||
bclibEnd = content.addCheckbox(
|
bclibEnd = content.addCheckbox(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.custom_biome_source"),
|
Component.translatable("title.screen.bclib.worldgen.custom_biome_source"),
|
||||||
endConfig.mapVersion != BCLEndBiomeSourceConfig.EndBiomeMapType.VANILLA
|
endConfig.mapVersion != BCLEndBiomeSourceConfig.EndBiomeMapType.VANILLA
|
||||||
);
|
);
|
||||||
|
|
||||||
endLegacy = content.indent(20).addCheckbox(
|
endLegacy = content.indent(20).addCheckbox(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
||||||
endConfig.mapVersion == BCLEndBiomeSourceConfig.EndBiomeMapType.SQUARE
|
endConfig.mapVersion == BCLEndBiomeSourceConfig.EndBiomeMapType.SQUARE
|
||||||
);
|
);
|
||||||
|
|
||||||
endCustomTerrain = content.indent(20).addCheckbox(
|
endCustomTerrain = content.indent(20).addCheckbox(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.custom_end_terrain"),
|
Component.translatable("title.screen.bclib.worldgen.custom_end_terrain"),
|
||||||
endConfig.generatorVersion != BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA
|
endConfig.generatorVersion != BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA
|
||||||
);
|
);
|
||||||
|
|
||||||
generateEndVoid = content.indent(20).addCheckbox(
|
generateEndVoid = content.indent(20).addCheckbox(
|
||||||
Value.fit(), Value.fit(),
|
fit(), fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.end_void"),
|
Component.translatable("title.screen.bclib.worldgen.end_void"),
|
||||||
endConfig.withVoidBiomes
|
endConfig.withVoidBiomes
|
||||||
);
|
);
|
||||||
|
|
||||||
content.addSpacer(12);
|
content.addSpacer(12);
|
||||||
content.addText(Value.fit(), Value.fit(), Component.translatable("title.screen.bclib.worldgen.avg_biome_size"))
|
content.addText(fit(), fit(), Component.translatable("title.screen.bclib.worldgen.avg_biome_size"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
content.addHorizontalSeparator(8).alignTop();
|
content.addHorizontalSeparator(8).alignTop();
|
||||||
|
|
||||||
landBiomeSize = content.addRange(
|
landBiomeSize = content.addRange(
|
||||||
Value.fixed(200),
|
fixed(200),
|
||||||
Value.fit(),
|
fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.land_biome_size"),
|
Component.translatable("title.screen.bclib.worldgen.land_biome_size"),
|
||||||
1,
|
1,
|
||||||
512,
|
512,
|
||||||
|
@ -127,8 +122,8 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
);
|
);
|
||||||
|
|
||||||
voidBiomeSize = content.addRange(
|
voidBiomeSize = content.addRange(
|
||||||
Value.fixed(200),
|
fixed(200),
|
||||||
Value.fit(),
|
fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.void_biome_size"),
|
Component.translatable("title.screen.bclib.worldgen.void_biome_size"),
|
||||||
1,
|
1,
|
||||||
512,
|
512,
|
||||||
|
@ -136,8 +131,8 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
);
|
);
|
||||||
|
|
||||||
centerBiomeSize = content.addRange(
|
centerBiomeSize = content.addRange(
|
||||||
Value.fixed(200),
|
fixed(200),
|
||||||
Value.fit(),
|
fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.center_biome_size"),
|
Component.translatable("title.screen.bclib.worldgen.center_biome_size"),
|
||||||
1,
|
1,
|
||||||
512,
|
512,
|
||||||
|
@ -145,8 +140,8 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
);
|
);
|
||||||
|
|
||||||
barrensBiomeSize = content.addRange(
|
barrensBiomeSize = content.addRange(
|
||||||
Value.fixed(200),
|
fixed(200),
|
||||||
Value.fit(),
|
fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.barrens_biome_size"),
|
Component.translatable("title.screen.bclib.worldgen.barrens_biome_size"),
|
||||||
1,
|
1,
|
||||||
512,
|
512,
|
||||||
|
@ -154,13 +149,13 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
);
|
);
|
||||||
|
|
||||||
content.addSpacer(12);
|
content.addSpacer(12);
|
||||||
content.addText(Value.fit(), Value.fit(), Component.translatable("title.screen.bclib.worldgen.other"))
|
content.addText(fit(), fit(), Component.translatable("title.screen.bclib.worldgen.other"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
content.addHorizontalSeparator(8).alignTop();
|
content.addHorizontalSeparator(8).alignTop();
|
||||||
|
|
||||||
innerRadius = content.addRange(
|
innerRadius = content.addRange(
|
||||||
Value.fixed(200),
|
fixed(200),
|
||||||
Value.fit(),
|
fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.central_radius"),
|
Component.translatable("title.screen.bclib.worldgen.central_radius"),
|
||||||
1,
|
1,
|
||||||
512,
|
512,
|
||||||
|
@ -282,7 +277,7 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LayoutComponent<?, ?> addTitle(LayoutComponent<?, ?> content) {
|
protected LayoutComponent<?, ?> addTitle(LayoutComponent<?, ?> content) {
|
||||||
VerticalStack rows = new VerticalStack(Value.fill(), Value.fill()).setDebugName("title stack");
|
VerticalStack rows = new VerticalStack(fill(), fill()).setDebugName("title stack");
|
||||||
|
|
||||||
if (topPadding > 0) rows.addSpacer(topPadding);
|
if (topPadding > 0) rows.addSpacer(topPadding);
|
||||||
rows.add(content);
|
rows.add(content);
|
||||||
|
@ -290,7 +285,7 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
|
|
||||||
if (sidePadding <= 0) return rows;
|
if (sidePadding <= 0) return rows;
|
||||||
|
|
||||||
HorizontalStack cols = new HorizontalStack(Value.fill(), Value.fill()).setDebugName("padded side");
|
HorizontalStack cols = new HorizontalStack(fill(), fill()).setDebugName("padded side");
|
||||||
cols.addSpacer(sidePadding);
|
cols.addSpacer(sidePadding);
|
||||||
cols.add(rows);
|
cols.add(rows);
|
||||||
cols.addSpacer(sidePadding);
|
cols.addSpacer(sidePadding);
|
||||||
|
@ -320,12 +315,12 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
var netherPage = netherPage(netherConfig);
|
var netherPage = netherPage(netherConfig);
|
||||||
var endPage = endPage(endConfig);
|
var endPage = endPage(endConfig);
|
||||||
|
|
||||||
Tabs main = new Tabs(Value.fill(), Value.fill()).setPadding(8, 0, 0, 0);
|
Tabs main = new Tabs(fill(), fill()).setPadding(8, 0, 0, 0);
|
||||||
main.addPage(Component.translatable("title.bclib.the_nether"), VerticalScroll.create(netherPage));
|
main.addPage(Component.translatable("title.bclib.the_nether"), VerticalScroll.create(netherPage));
|
||||||
main.addPage(Component.translatable("title.bclib.the_end"), VerticalScroll.create(endPage));
|
main.addPage(Component.translatable("title.bclib.the_end"), VerticalScroll.create(endPage));
|
||||||
|
|
||||||
HorizontalStack title = new HorizontalStack(Value.fit(), Value.fit()).setDebugName("title bar");
|
HorizontalStack title = new HorizontalStack(fit(), fit()).setDebugName("title bar");
|
||||||
title.addIcon(BCLIB_LOGO_LOCATION, Size.of(512)).setDebugName("icon");
|
title.addIcon(BCLibLayoutScreen.BCLIB_LOGO_LOCATION, Size.of(512)).setDebugName("icon");
|
||||||
title.addSpacer(4);
|
title.addSpacer(4);
|
||||||
title.add(super.buildTitle());
|
title.add(super.buildTitle());
|
||||||
|
|
||||||
|
@ -333,10 +328,10 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
main.addComponent(title);
|
main.addComponent(title);
|
||||||
|
|
||||||
|
|
||||||
VerticalStack rows = new VerticalStack(Value.fill(), Value.fill());
|
VerticalStack rows = new VerticalStack(fill(), fill());
|
||||||
rows.add(main);
|
rows.add(main);
|
||||||
rows.addSpacer(4);
|
rows.addSpacer(4);
|
||||||
rows.addButton(Value.fit(), Value.fit(), CommonComponents.GUI_DONE).onPress((bt) -> {
|
rows.addButton(fit(), fit(), CommonComponents.GUI_DONE).onPress((bt) -> {
|
||||||
updateSettings();
|
updateSettings();
|
||||||
onClose();
|
onClose();
|
||||||
}).alignRight();
|
}).alignRight();
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class ColorUtil {
|
||||||
public static final int LIGHT_PURPLE = ChatFormatting.LIGHT_PURPLE.getColor() | 0xFF000000;
|
public static final int LIGHT_PURPLE = ChatFormatting.LIGHT_PURPLE.getColor() | 0xFF000000;
|
||||||
public static final int YELLOW = ChatFormatting.YELLOW.getColor() | 0xFF000000;
|
public static final int YELLOW = ChatFormatting.YELLOW.getColor() | 0xFF000000;
|
||||||
public static final int WHITE = ChatFormatting.WHITE.getColor() | 0xFF000000;
|
public static final int WHITE = ChatFormatting.WHITE.getColor() | 0xFF000000;
|
||||||
public static final int DEFAULT_TEXT = 0xFFA0A0A0;
|
public static final int DEFAULT_TEXT = WHITE;
|
||||||
private static final float[] FLOAT_BUFFER = new float[4];
|
private static final float[] FLOAT_BUFFER = new float[4];
|
||||||
private static final int ALPHA = 255 << 24;
|
private static final int ALPHA = 255 << 24;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,12 @@ public abstract class LayoutComponent<R extends ComponentRenderer, L extends Lay
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reCalculateLayout() {
|
||||||
|
updateContainerWidth(relativeBounds.width);
|
||||||
|
updateContainerHeight(relativeBounds.height);
|
||||||
|
setRelativeBounds(relativeBounds.left, relativeBounds.top);
|
||||||
|
}
|
||||||
|
|
||||||
protected int updateContainerWidth(int containerWidth) {
|
protected int updateContainerWidth(int containerWidth) {
|
||||||
return width.setCalculatedSize(containerWidth);
|
return width.setCalculatedSize(containerWidth);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,13 @@ import org.betterx.ui.layout.values.Value;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.components.MultiLineLabel;
|
import net.minecraft.client.gui.components.MultiLineLabel;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
public class MultiLineText extends LayoutComponent<MultiLineText.MultiLineTextRenderer, MultiLineText> {
|
public class MultiLineText extends LayoutComponent<MultiLineText.MultiLineTextRenderer, MultiLineText> {
|
||||||
final net.minecraft.network.chat.Component text;
|
net.minecraft.network.chat.Component text;
|
||||||
int color = ColorUtil.DEFAULT_TEXT;
|
int color = ColorUtil.DEFAULT_TEXT;
|
||||||
protected MultiLineLabel multiLineLabel;
|
protected MultiLineLabel multiLineLabel;
|
||||||
|
int bufferedContentWidth = 0;
|
||||||
|
|
||||||
public MultiLineText(
|
public MultiLineText(
|
||||||
Value width,
|
Value width,
|
||||||
|
@ -23,6 +25,7 @@ public class MultiLineText extends LayoutComponent<MultiLineText.MultiLineTextRe
|
||||||
super(width, height, new MultiLineTextRenderer());
|
super(width, height, new MultiLineTextRenderer());
|
||||||
renderer.linkedComponent = this;
|
renderer.linkedComponent = this;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
|
updatedContentWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultiLineText setColor(int cl) {
|
public MultiLineText setColor(int cl) {
|
||||||
|
@ -30,6 +33,17 @@ public class MultiLineText extends LayoutComponent<MultiLineText.MultiLineTextRe
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MultiLineText setText(Component text) {
|
||||||
|
this.text = text;
|
||||||
|
this.updatedContentWidth();
|
||||||
|
|
||||||
|
if (multiLineLabel != null) {
|
||||||
|
multiLineLabel = createVanillaComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
protected MultiLineLabel createVanillaComponent() {
|
protected MultiLineLabel createVanillaComponent() {
|
||||||
return MultiLineLabel.create(
|
return MultiLineLabel.create(
|
||||||
renderer.getFont(),
|
renderer.getFont(),
|
||||||
|
@ -38,6 +52,19 @@ public class MultiLineText extends LayoutComponent<MultiLineText.MultiLineTextRe
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updatedContentWidth() {
|
||||||
|
String[] lines = text.getString().split("\n");
|
||||||
|
if (lines.length == 0) bufferedContentWidth = 0;
|
||||||
|
else {
|
||||||
|
String line = lines[0];
|
||||||
|
for (int i = 1; i < lines.length; i++)
|
||||||
|
if (lines[i].length() > line.length())
|
||||||
|
line = lines[i];
|
||||||
|
|
||||||
|
bufferedContentWidth = renderer.getWidth(Component.literal(line));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void setRelativeBounds(int left, int top) {
|
void setRelativeBounds(int left, int top) {
|
||||||
super.setRelativeBounds(left, top);
|
super.setRelativeBounds(left, top);
|
||||||
|
@ -46,7 +73,7 @@ public class MultiLineText extends LayoutComponent<MultiLineText.MultiLineTextRe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getContentWidth() {
|
public int getContentWidth() {
|
||||||
return renderer.getWidth(text);
|
return bufferedContentWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,6 +84,11 @@ public class MultiLineText extends LayoutComponent<MultiLineText.MultiLineTextRe
|
||||||
protected static class MultiLineTextRenderer implements ComponentRenderer, TextProvider {
|
protected static class MultiLineTextRenderer implements ComponentRenderer, TextProvider {
|
||||||
MultiLineText linkedComponent;
|
MultiLineText linkedComponent;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWidth(Component c) {
|
||||||
|
return getFont().width(c.getVisualOrderText());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight(net.minecraft.network.chat.Component c) {
|
public int getHeight(net.minecraft.network.chat.Component c) {
|
||||||
if (linkedComponent == null) return 20;
|
if (linkedComponent == null) return 20;
|
||||||
|
|
|
@ -99,4 +99,6 @@ public class Panel implements ComponentWithBounds, RelativeContainerEventHandler
|
||||||
child.render(poseStack, mouseX - bounds.left, mouseY - bounds.top, deltaTicks, bounds, bounds);
|
child.render(poseStack, mouseX - bounds.left, mouseY - bounds.top, deltaTicks, bounds, bounds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,10 @@ import org.betterx.ui.layout.values.Value;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.GuiComponent;
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
public class Text extends LayoutComponent<Text.TextRenderer, Text> {
|
public class Text extends LayoutComponent<Text.TextRenderer, Text> {
|
||||||
final net.minecraft.network.chat.Component text;
|
net.minecraft.network.chat.Component text;
|
||||||
int color = ColorUtil.DEFAULT_TEXT;
|
int color = ColorUtil.DEFAULT_TEXT;
|
||||||
|
|
||||||
public Text(
|
public Text(
|
||||||
|
@ -30,6 +31,11 @@ public class Text extends LayoutComponent<Text.TextRenderer, Text> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Text setText(Component text) {
|
||||||
|
this.text = text;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getContentWidth() {
|
public int getContentWidth() {
|
||||||
return renderer.getWidth(text);
|
return renderer.getWidth(text);
|
||||||
|
|
|
@ -59,7 +59,7 @@ public abstract class LayoutScreen extends Screen {
|
||||||
}
|
}
|
||||||
this.minecraft.setScreen(this);
|
this.minecraft.setScreen(this);
|
||||||
}, uri, true);
|
}, uri, true);
|
||||||
|
|
||||||
Minecraft.getInstance().setScreen(cls);
|
Minecraft.getInstance().setScreen(cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,14 +74,14 @@ public abstract class LayoutScreen extends Screen {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LayoutComponent<?, ?> buildTitle() {
|
protected LayoutComponent<?, ?> buildTitle() {
|
||||||
var text = new Text(Value.fit(), Value.fit(), title).centerHorizontal()
|
var text = new Text(fit(), fit(), title).centerHorizontal()
|
||||||
.setColor(ColorUtil.WHITE)
|
.setColor(ColorUtil.WHITE)
|
||||||
.setDebugName("title");
|
.setDebugName("title");
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LayoutComponent<?, ?> addTitle(LayoutComponent<?, ?> content) {
|
protected LayoutComponent<?, ?> addTitle(LayoutComponent<?, ?> content) {
|
||||||
VerticalStack rows = new VerticalStack(Value.fill(), Value.fill()).setDebugName("title stack");
|
VerticalStack rows = new VerticalStack(fill(), fill()).setDebugName("title stack");
|
||||||
|
|
||||||
if (topPadding > 0) rows.addSpacer(topPadding);
|
if (topPadding > 0) rows.addSpacer(topPadding);
|
||||||
rows.add(buildTitle());
|
rows.add(buildTitle());
|
||||||
|
@ -91,7 +91,7 @@ public abstract class LayoutScreen extends Screen {
|
||||||
|
|
||||||
if (sidePadding <= 0) return rows;
|
if (sidePadding <= 0) return rows;
|
||||||
|
|
||||||
HorizontalStack cols = new HorizontalStack(Value.fill(), Value.fill()).setDebugName("padded side");
|
HorizontalStack cols = new HorizontalStack(fill(), fill()).setDebugName("padded side");
|
||||||
cols.addSpacer(sidePadding);
|
cols.addSpacer(sidePadding);
|
||||||
cols.add(rows);
|
cols.add(rows);
|
||||||
cols.addSpacer(sidePadding);
|
cols.addSpacer(sidePadding);
|
||||||
|
@ -118,4 +118,24 @@ public abstract class LayoutScreen extends Screen {
|
||||||
public boolean isPauseScreen() {
|
public boolean isPauseScreen() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Value fit() {
|
||||||
|
return Value.fit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Value fitOrFill() {
|
||||||
|
return Value.fitOrFill();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Value fill() {
|
||||||
|
return Value.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Value fixed(int size) {
|
||||||
|
return Value.fixed(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Value relative(double percentage) {
|
||||||
|
return Value.relative(percentage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package org.betterx.ui.vanilla;
|
||||||
import org.betterx.ui.layout.components.HorizontalStack;
|
import org.betterx.ui.layout.components.HorizontalStack;
|
||||||
import org.betterx.ui.layout.components.LayoutComponent;
|
import org.betterx.ui.layout.components.LayoutComponent;
|
||||||
import org.betterx.ui.layout.values.Size;
|
import org.betterx.ui.layout.values.Size;
|
||||||
import org.betterx.ui.layout.values.Value;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -41,7 +40,7 @@ public abstract class LayoutScreenWithIcon extends LayoutScreen {
|
||||||
@Override
|
@Override
|
||||||
protected LayoutComponent<?, ?> buildTitle() {
|
protected LayoutComponent<?, ?> buildTitle() {
|
||||||
LayoutComponent<?, ?> title = super.buildTitle();
|
LayoutComponent<?, ?> title = super.buildTitle();
|
||||||
HorizontalStack row = new HorizontalStack(Value.fill(), Value.fit()).setDebugName("title bar");
|
HorizontalStack row = new HorizontalStack(fill(), fit()).setDebugName("title bar");
|
||||||
row.addFiller();
|
row.addFiller();
|
||||||
row.addIcon(icon, Size.of(512)).setDebugName("icon");
|
row.addIcon(icon, Size.of(512)).setDebugName("icon");
|
||||||
row.addSpacer(4);
|
row.addSpacer(4);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue