Finished new End-Settings for WorldEdit Screen
This commit is contained in:
parent
7546efe097
commit
cb1986a1fa
12 changed files with 106 additions and 67 deletions
|
@ -40,6 +40,11 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
|
|
||||||
private final WorldCreationContext context;
|
private final WorldCreationContext context;
|
||||||
private final CreateWorldScreen createWorldScreen;
|
private final CreateWorldScreen createWorldScreen;
|
||||||
|
private Range<Integer> landBiomeSize;
|
||||||
|
private Range<Integer> voidBiomeSize;
|
||||||
|
private Range<Integer> centerBiomeSize;
|
||||||
|
private Range<Integer> barrensBiomeSize;
|
||||||
|
private Range<Integer> innerRadius;
|
||||||
|
|
||||||
public WorldSetupScreen(@Nullable CreateWorldScreen parent, WorldCreationContext context) {
|
public WorldSetupScreen(@Nullable CreateWorldScreen parent, WorldCreationContext context) {
|
||||||
super(parent, Component.translatable("title.screen.bclib.worldgen.main"), 10, 10, 10);
|
super(parent, Component.translatable("title.screen.bclib.worldgen.main"), 10, 10, 10);
|
||||||
|
@ -57,7 +62,7 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
|
|
||||||
public LayoutComponent<?, ?> netherPage(BCLNetherBiomeSourceConfig netherConfig) {
|
public LayoutComponent<?, ?> netherPage(BCLNetherBiomeSourceConfig netherConfig) {
|
||||||
VerticalStack content = new VerticalStack(Value.fill(), Value.fit()).centerHorizontal();
|
VerticalStack content = new VerticalStack(Value.fill(), Value.fit()).centerHorizontal();
|
||||||
content.addSpacer(4);
|
content.addSpacer(8);
|
||||||
|
|
||||||
bclibNether = content.addCheckbox(
|
bclibNether = content.addCheckbox(
|
||||||
Value.fit(), Value.fit(),
|
Value.fit(), Value.fit(),
|
||||||
|
@ -75,12 +80,14 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
bclibNether.onChange((cb, state) -> {
|
bclibNether.onChange((cb, state) -> {
|
||||||
netherLegacy.setEnabled(state);
|
netherLegacy.setEnabled(state);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
content.addSpacer(8);
|
||||||
return content.setDebugName("Nether page");
|
return content.setDebugName("Nether page");
|
||||||
}
|
}
|
||||||
|
|
||||||
public LayoutComponent<?, ?> endPage(BCLEndBiomeSourceConfig endConfig) {
|
public LayoutComponent<?, ?> endPage(BCLEndBiomeSourceConfig endConfig) {
|
||||||
VerticalStack content = new VerticalStack(Value.fill(), Value.fit()).centerHorizontal();
|
VerticalStack content = new VerticalStack(Value.fill(), Value.fit()).centerHorizontal();
|
||||||
content.addSpacer(4);
|
content.addSpacer(8);
|
||||||
bclibEnd = content.addCheckbox(
|
bclibEnd = content.addCheckbox(
|
||||||
Value.fit(), Value.fit(),
|
Value.fit(), Value.fit(),
|
||||||
Component.translatable("title.screen.bclib.worldgen.custom_biome_source"),
|
Component.translatable("title.screen.bclib.worldgen.custom_biome_source"),
|
||||||
|
@ -106,55 +113,55 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
);
|
);
|
||||||
|
|
||||||
content.addSpacer(12);
|
content.addSpacer(12);
|
||||||
content.addText(Value.fit(), Value.fit(), Component.literal("Average Biome Size (in Chunks)"))
|
content.addText(Value.fit(), Value.fit(), Component.translatable("title.screen.bclib.worldgen.avg_biome_size"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
content.addHorizontalSeparator(8).alignTop();
|
content.addHorizontalSeparator(8).alignTop();
|
||||||
|
|
||||||
Range<Integer> landBiomeSize = content.addRange(
|
landBiomeSize = content.addRange(
|
||||||
Value.fixed(200),
|
Value.fixed(200),
|
||||||
Value.fit(),
|
Value.fit(),
|
||||||
Component.literal("Land"),
|
Component.translatable("title.screen.bclib.worldgen.land_biome_size"),
|
||||||
1,
|
1,
|
||||||
512,
|
512,
|
||||||
endConfig.landBiomesSize / 16
|
endConfig.landBiomesSize / 16
|
||||||
);
|
);
|
||||||
|
|
||||||
Range<Integer> voidBiomeSize = content.addRange(
|
voidBiomeSize = content.addRange(
|
||||||
Value.fixed(200),
|
Value.fixed(200),
|
||||||
Value.fit(),
|
Value.fit(),
|
||||||
Component.literal("Void"),
|
Component.translatable("title.screen.bclib.worldgen.void_biome_size"),
|
||||||
1,
|
1,
|
||||||
512,
|
512,
|
||||||
endConfig.voidBiomesSize / 16
|
endConfig.voidBiomesSize / 16
|
||||||
);
|
);
|
||||||
|
|
||||||
Range<Integer> centerBiomeSize = content.addRange(
|
centerBiomeSize = content.addRange(
|
||||||
Value.fixed(200),
|
Value.fixed(200),
|
||||||
Value.fit(),
|
Value.fit(),
|
||||||
Component.literal("Center"),
|
Component.translatable("title.screen.bclib.worldgen.center_biome_size"),
|
||||||
1,
|
1,
|
||||||
512,
|
512,
|
||||||
endConfig.centerBiomesSize / 16
|
endConfig.centerBiomesSize / 16
|
||||||
);
|
);
|
||||||
|
|
||||||
Range<Integer> barrensBiomeSize = content.addRange(
|
barrensBiomeSize = content.addRange(
|
||||||
Value.fixed(200),
|
Value.fixed(200),
|
||||||
Value.fit(),
|
Value.fit(),
|
||||||
Component.literal("Barrens"),
|
Component.translatable("title.screen.bclib.worldgen.barrens_biome_size"),
|
||||||
1,
|
1,
|
||||||
512,
|
512,
|
||||||
endConfig.barrensBiomesSize / 16
|
endConfig.barrensBiomesSize / 16
|
||||||
);
|
);
|
||||||
|
|
||||||
content.addSpacer(12);
|
content.addSpacer(12);
|
||||||
content.addText(Value.fit(), Value.fit(), Component.literal("Other Settings"))
|
content.addText(Value.fit(), Value.fit(), Component.translatable("title.screen.bclib.worldgen.other"))
|
||||||
.centerHorizontal();
|
.centerHorizontal();
|
||||||
content.addHorizontalSeparator(8).alignTop();
|
content.addHorizontalSeparator(8).alignTop();
|
||||||
|
|
||||||
Range<Integer> innerRadius = content.addRange(
|
innerRadius = content.addRange(
|
||||||
Value.fixed(200),
|
Value.fixed(200),
|
||||||
Value.fit(),
|
Value.fit(),
|
||||||
Component.literal("Central Void Radius"),
|
Component.translatable("title.screen.bclib.worldgen.central_radius"),
|
||||||
1,
|
1,
|
||||||
512,
|
512,
|
||||||
(int) Math.sqrt(endConfig.innerVoidRadiusSquared) / 16
|
(int) Math.sqrt(endConfig.innerVoidRadiusSquared) / 16
|
||||||
|
@ -167,17 +174,23 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
generateEndVoid.setEnabled(state);
|
generateEndVoid.setEnabled(state);
|
||||||
|
|
||||||
landBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
landBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
||||||
voidBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
voidBiomeSize.setEnabled(state && endCustomTerrain.isChecked() && generateEndVoid.isChecked());
|
||||||
centerBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
centerBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
||||||
barrensBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
barrensBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
||||||
});
|
});
|
||||||
|
|
||||||
endCustomTerrain.onChange((cb, state) -> {
|
endCustomTerrain.onChange((cb, state) -> {
|
||||||
landBiomeSize.setEnabled(state);
|
landBiomeSize.setEnabled(state);
|
||||||
voidBiomeSize.setEnabled(state);
|
voidBiomeSize.setEnabled(state && generateEndVoid.isChecked());
|
||||||
centerBiomeSize.setEnabled(state);
|
centerBiomeSize.setEnabled(state);
|
||||||
barrensBiomeSize.setEnabled(state);
|
barrensBiomeSize.setEnabled(state);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
generateEndVoid.onChange((cb, state) -> {
|
||||||
|
voidBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
||||||
|
});
|
||||||
|
|
||||||
|
content.addSpacer(8);
|
||||||
return content.setDebugName("End Page");
|
return content.setDebugName("End Page");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,11 +211,11 @@ public class WorldSetupScreen extends LayoutScreen {
|
||||||
? BCLEndBiomeSourceConfig.EndBiomeGeneratorType.PAULEVS
|
? BCLEndBiomeSourceConfig.EndBiomeGeneratorType.PAULEVS
|
||||||
: BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA,
|
: BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA,
|
||||||
generateEndVoid.isChecked(),
|
generateEndVoid.isChecked(),
|
||||||
BCLEndBiomeSourceConfig.DEFAULT.innerVoidRadiusSquared,
|
(int) Math.pow(innerRadius.getValue() * 16, 2),
|
||||||
BCLEndBiomeSourceConfig.DEFAULT.centerBiomesSize,
|
centerBiomeSize.getValue(),
|
||||||
BCLEndBiomeSourceConfig.DEFAULT.voidBiomesSize,
|
voidBiomeSize.getValue(),
|
||||||
BCLEndBiomeSourceConfig.DEFAULT.landBiomesSize,
|
landBiomeSize.getValue(),
|
||||||
BCLEndBiomeSourceConfig.DEFAULT.barrensBiomesSize
|
barrensBiomeSize.getValue()
|
||||||
);
|
);
|
||||||
|
|
||||||
ChunkGenerator endGenerator = betterxDimensions.get(LevelStem.END);
|
ChunkGenerator endGenerator = betterxDimensions.get(LevelStem.END);
|
||||||
|
@ -307,7 +320,7 @@ 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());
|
Tabs main = new Tabs(Value.fill(), Value.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));
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.betterx.bclib.integration.modmenu;
|
package org.betterx.bclib.integration.modmenu;
|
||||||
|
|
||||||
import org.betterx.bclib.client.gui.modmenu.MainScreen;
|
import org.betterx.bclib.client.gui.modmenu.TestScreen;
|
||||||
|
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||||
|
@ -26,8 +28,8 @@ public class ModMenuEntryPoint implements ModMenuApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
//return (parent) -> new TestScreen(parent, Component.literal("Hello Test"));
|
return (parent) -> new TestScreen(parent, Component.literal("Hello Test"));
|
||||||
return (parent) -> new MainScreen(parent);
|
//return (parent) -> new MainScreen(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.betterx.ui.layout.components;
|
||||||
|
|
||||||
import org.betterx.ui.layout.components.input.RelativeContainerEventHandler;
|
import org.betterx.ui.layout.components.input.RelativeContainerEventHandler;
|
||||||
import org.betterx.ui.layout.components.render.ComponentRenderer;
|
import org.betterx.ui.layout.components.render.ComponentRenderer;
|
||||||
import org.betterx.ui.layout.components.render.NullRenderer;
|
|
||||||
import org.betterx.ui.layout.values.Rectangle;
|
import org.betterx.ui.layout.values.Rectangle;
|
||||||
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.layout.values.Value;
|
||||||
|
@ -152,16 +151,16 @@ public abstract class AbstractStack<R extends ComponentRenderer, T extends Abstr
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VerticalScroll<NullRenderer, VanillaScrollerRenderer> addScrollable(LayoutComponent<?, ?> content) {
|
protected VerticalScroll<VanillaScrollerRenderer> addScrollable(LayoutComponent<?, ?> content) {
|
||||||
return addScrollable(Value.fill(), Value.fill(), content);
|
return addScrollable(Value.fill(), Value.fill(), content);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VerticalScroll<NullRenderer, VanillaScrollerRenderer> addScrollable(
|
protected VerticalScroll<VanillaScrollerRenderer> addScrollable(
|
||||||
Value width,
|
Value width,
|
||||||
Value height,
|
Value height,
|
||||||
LayoutComponent<?, ?> content
|
LayoutComponent<?, ?> content
|
||||||
) {
|
) {
|
||||||
VerticalScroll<NullRenderer, VanillaScrollerRenderer> s = VerticalScroll.create(width, height, content);
|
VerticalScroll<VanillaScrollerRenderer> s = VerticalScroll.create(width, height, content);
|
||||||
add(s);
|
add(s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class Container extends LayoutComponent<Container.ContainerRenderer, Cont
|
||||||
GuiEventListener focused = null;
|
GuiEventListener focused = null;
|
||||||
boolean visible = true;
|
boolean visible = true;
|
||||||
|
|
||||||
int padding = 0;
|
int paddingLeft, paddingTop, paddingRight, paddingBottom;
|
||||||
|
|
||||||
int backgroundColor = 0;
|
int backgroundColor = 0;
|
||||||
int outlineColor = 0;
|
int outlineColor = 0;
|
||||||
|
@ -93,22 +93,29 @@ public class Container extends LayoutComponent<Container.ContainerRenderer, Cont
|
||||||
}
|
}
|
||||||
|
|
||||||
public Container setPadding(int padding) {
|
public Container setPadding(int padding) {
|
||||||
this.padding = padding;
|
return setPadding(padding, padding, padding, padding);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPadding() {
|
public Container setPadding(int left, int top, int right, int bottom) {
|
||||||
return padding;
|
this.paddingLeft = left;
|
||||||
|
this.paddingTop = top;
|
||||||
|
this.paddingRight = right;
|
||||||
|
this.paddingBottom = bottom;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getContentWidth() {
|
public int getContentWidth() {
|
||||||
return children.stream().map(LayoutComponent::getContentWidth).reduce(0, Math::max) + 2 * padding;
|
return children.stream()
|
||||||
|
.map(LayoutComponent::getContentWidth)
|
||||||
|
.reduce(0, Math::max) + paddingLeft + paddingRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getContentHeight() {
|
public int getContentHeight() {
|
||||||
return children.stream().map(LayoutComponent::getContentHeight).reduce(0, Math::max) + 2 * padding;
|
return children.stream()
|
||||||
|
.map(LayoutComponent::getContentHeight)
|
||||||
|
.reduce(0, Math::max) + paddingTop + paddingBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,7 +153,7 @@ public class Container extends LayoutComponent<Container.ContainerRenderer, Cont
|
||||||
protected int updateContainerWidth(int containerWidth) {
|
protected int updateContainerWidth(int containerWidth) {
|
||||||
int myWidth = width.calculateOrFill(containerWidth);
|
int myWidth = width.calculateOrFill(containerWidth);
|
||||||
for (var child : children) {
|
for (var child : children) {
|
||||||
child.width.calculateOrFill(myWidth - 2 * padding);
|
child.width.calculateOrFill(myWidth - (paddingLeft + paddingRight));
|
||||||
child.updateContainerWidth(child.width.calculatedSize());
|
child.updateContainerWidth(child.width.calculatedSize());
|
||||||
}
|
}
|
||||||
return myWidth;
|
return myWidth;
|
||||||
|
@ -156,7 +163,7 @@ public class Container extends LayoutComponent<Container.ContainerRenderer, Cont
|
||||||
protected int updateContainerHeight(int containerHeight) {
|
protected int updateContainerHeight(int containerHeight) {
|
||||||
int myHeight = height.calculateOrFill(containerHeight);
|
int myHeight = height.calculateOrFill(containerHeight);
|
||||||
for (var child : children) {
|
for (var child : children) {
|
||||||
child.height.calculateOrFill(myHeight - 2 * padding);
|
child.height.calculateOrFill(myHeight - (paddingTop + paddingBottom));
|
||||||
child.updateContainerHeight(child.height.calculatedSize());
|
child.updateContainerHeight(child.height.calculatedSize());
|
||||||
}
|
}
|
||||||
return myHeight;
|
return myHeight;
|
||||||
|
@ -190,15 +197,15 @@ public class Container extends LayoutComponent<Container.ContainerRenderer, Cont
|
||||||
super.setRelativeBounds(left, top);
|
super.setRelativeBounds(left, top);
|
||||||
|
|
||||||
for (var child : children) {
|
for (var child : children) {
|
||||||
int childLeft = (relativeBounds.width - 2 * padding) - child.width.calculatedSize();
|
int childLeft = (relativeBounds.width - (paddingLeft + paddingRight)) - child.width.calculatedSize();
|
||||||
if (child.hAlign == Alignment.MIN) childLeft = 0;
|
if (child.hAlign == Alignment.MIN) childLeft = 0;
|
||||||
else if (child.hAlign == Alignment.CENTER) childLeft /= 2;
|
else if (child.hAlign == Alignment.CENTER) childLeft /= 2;
|
||||||
|
|
||||||
int childTop = (relativeBounds.height - 2 * padding) - child.height.calculatedSize();
|
int childTop = (relativeBounds.height - (paddingTop + paddingBottom)) - child.height.calculatedSize();
|
||||||
if (child.vAlign == Alignment.MIN) childTop = 0;
|
if (child.vAlign == Alignment.MIN) childTop = 0;
|
||||||
else if (child.vAlign == Alignment.CENTER) childTop /= 2;
|
else if (child.vAlign == Alignment.CENTER) childTop /= 2;
|
||||||
|
|
||||||
child.setRelativeBounds(padding + childLeft, padding + childTop);
|
child.setRelativeBounds(paddingLeft + childLeft, paddingTop + childTop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.betterx.ui.layout.components;
|
package org.betterx.ui.layout.components;
|
||||||
|
|
||||||
import org.betterx.ui.layout.components.render.NullRenderer;
|
|
||||||
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.layout.values.Value;
|
||||||
import org.betterx.ui.vanilla.VanillaScrollerRenderer;
|
import org.betterx.ui.vanilla.VanillaScrollerRenderer;
|
||||||
|
@ -170,7 +169,7 @@ public class HorizontalStack extends AbstractHorizontalStack<HorizontalStack> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VerticalScroll<NullRenderer, VanillaScrollerRenderer> addScrollable(LayoutComponent<?, ?> content) {
|
public VerticalScroll<VanillaScrollerRenderer> addScrollable(LayoutComponent<?, ?> content) {
|
||||||
return super.addScrollable(content);
|
return super.addScrollable(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +189,7 @@ public class HorizontalStack extends AbstractHorizontalStack<HorizontalStack> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VerticalScroll<NullRenderer, VanillaScrollerRenderer> addScrollable(
|
public VerticalScroll<VanillaScrollerRenderer> addScrollable(
|
||||||
Value width,
|
Value width,
|
||||||
Value height,
|
Value height,
|
||||||
LayoutComponent<?, ?> content
|
LayoutComponent<?, ?> content
|
||||||
|
|
|
@ -68,6 +68,10 @@ public class Range<N extends Number> extends AbstractVanillaComponent<Slider<N>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public N getValue() {
|
||||||
|
return vanillaComponent.currentValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Component contentComponent() {
|
protected Component contentComponent() {
|
||||||
|
|
|
@ -79,8 +79,9 @@ public class Tabs extends AbstractVerticalStack<Tabs> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPadding() {
|
public Tabs setPadding(int left, int top, int right, int bottom) {
|
||||||
return content.getPadding();
|
content.setPadding(left, top, right, bottom);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.betterx.ui.layout.components;
|
package org.betterx.ui.layout.components;
|
||||||
|
|
||||||
import org.betterx.ui.layout.components.render.ComponentRenderer;
|
|
||||||
import org.betterx.ui.layout.components.render.NullRenderer;
|
import org.betterx.ui.layout.components.render.NullRenderer;
|
||||||
import org.betterx.ui.layout.components.render.ScrollerRenderer;
|
import org.betterx.ui.layout.components.render.ScrollerRenderer;
|
||||||
import org.betterx.ui.layout.values.Alignment;
|
import org.betterx.ui.layout.values.Alignment;
|
||||||
|
@ -19,10 +18,9 @@ import java.util.List;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRenderer> extends LayoutComponent<R, VerticalScroll<R, RS>> implements ContainerEventHandler {
|
public class VerticalScroll<RS extends ScrollerRenderer> extends LayoutComponent<NullRenderer, VerticalScroll<RS>> implements ContainerEventHandler {
|
||||||
protected LayoutComponent<?, ?> child;
|
protected LayoutComponent<?, ?> child;
|
||||||
protected final RS scrollerRenderer;
|
protected final RS scrollerRenderer;
|
||||||
protected Rectangle viewBounds;
|
|
||||||
|
|
||||||
protected int dist;
|
protected int dist;
|
||||||
protected double scrollerY;
|
protected double scrollerY;
|
||||||
|
@ -30,29 +28,26 @@ public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRend
|
||||||
protected int travel;
|
protected int travel;
|
||||||
protected int topOffset;
|
protected int topOffset;
|
||||||
|
|
||||||
public VerticalScroll(Value width, Value height, RS scrollerRenderer) {
|
protected boolean keepSpaceForScrollbar = true;
|
||||||
this(width, height, scrollerRenderer, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VerticalScroll(Value width, Value height, RS scrollerRenderer, R renderer) {
|
public VerticalScroll(Value width, Value height, RS scrollerRenderer) {
|
||||||
super(width, height, renderer);
|
super(width, height, new NullRenderer());
|
||||||
this.scrollerRenderer = scrollerRenderer;
|
this.scrollerRenderer = scrollerRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VerticalScroll<NullRenderer, VanillaScrollerRenderer> create(LayoutComponent<?, ?> c) {
|
public static VerticalScroll<VanillaScrollerRenderer> create(LayoutComponent<?, ?> c) {
|
||||||
return create(Value.relative(1), Value.relative(1), c);
|
return create(Value.relative(1), Value.relative(1), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VerticalScroll<NullRenderer, VanillaScrollerRenderer> create(
|
public static VerticalScroll<VanillaScrollerRenderer> create(
|
||||||
Value width,
|
Value width,
|
||||||
Value height,
|
Value height,
|
||||||
LayoutComponent<?, ?> c
|
LayoutComponent<?, ?> c
|
||||||
) {
|
) {
|
||||||
VerticalScroll<NullRenderer, VanillaScrollerRenderer> res = new VerticalScroll<>(
|
VerticalScroll<VanillaScrollerRenderer> res = new VerticalScroll<>(
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
VanillaScrollerRenderer.DEFAULT,
|
VanillaScrollerRenderer.DEFAULT
|
||||||
null
|
|
||||||
);
|
);
|
||||||
res.setChild(c);
|
res.setChild(c);
|
||||||
return res;
|
return res;
|
||||||
|
@ -60,9 +55,15 @@ public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRend
|
||||||
|
|
||||||
List<LayoutComponent<?, ?>> children = List.of();
|
List<LayoutComponent<?, ?>> children = List.of();
|
||||||
|
|
||||||
public void setChild(LayoutComponent<?, ?> c) {
|
public VerticalScroll<RS> setChild(LayoutComponent<?, ?> c) {
|
||||||
this.child = c;
|
this.child = c;
|
||||||
children = List.of(child);
|
children = List.of(child);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VerticalScroll<RS> setKeepSpaceForScrollbar(boolean value) {
|
||||||
|
keepSpaceForScrollbar = value;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,7 +108,7 @@ public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRend
|
||||||
|
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
int width = relativeBounds.width;
|
int width = relativeBounds.width;
|
||||||
boolean willNeedScrollBar = child.height.calculatedSize() > relativeBounds.height;
|
boolean willNeedScrollBar = keepSpaceForScrollbar || child.height.calculatedSize() > relativeBounds.height;
|
||||||
if (willNeedScrollBar) width -= scrollerWidth();
|
if (willNeedScrollBar) width -= scrollerWidth();
|
||||||
int childLeft = width - child.width.calculatedSize();
|
int childLeft = width - child.width.calculatedSize();
|
||||||
if (child.hAlign == Alignment.MIN) childLeft = 0;
|
if (child.hAlign == Alignment.MIN) childLeft = 0;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.betterx.ui.layout.components;
|
package org.betterx.ui.layout.components;
|
||||||
|
|
||||||
|
|
||||||
import org.betterx.ui.layout.components.render.NullRenderer;
|
|
||||||
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.layout.values.Value;
|
||||||
import org.betterx.ui.vanilla.VanillaScrollerRenderer;
|
import org.betterx.ui.vanilla.VanillaScrollerRenderer;
|
||||||
|
@ -182,7 +181,7 @@ public class VerticalStack extends AbstractVerticalStack<VerticalStack> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VerticalScroll<NullRenderer, VanillaScrollerRenderer> addScrollable(LayoutComponent<?, ?> content) {
|
public VerticalScroll<VanillaScrollerRenderer> addScrollable(LayoutComponent<?, ?> content) {
|
||||||
return super.addScrollable(content);
|
return super.addScrollable(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +201,7 @@ public class VerticalStack extends AbstractVerticalStack<VerticalStack> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VerticalScroll<NullRenderer, VanillaScrollerRenderer> addScrollable(
|
public VerticalScroll<VanillaScrollerRenderer> addScrollable(
|
||||||
Value width,
|
Value width,
|
||||||
Value height,
|
Value height,
|
||||||
LayoutComponent<?, ?> content
|
LayoutComponent<?, ?> content
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class Slider<N extends Number> extends AbstractSliderButton {
|
||||||
this.updateMessage();
|
this.updateMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected N currentValue() {
|
public N currentValue() {
|
||||||
Double res = value * (maxValue.doubleValue() - minValue.doubleValue()) + minValue.doubleValue();
|
Double res = value * (maxValue.doubleValue() - minValue.doubleValue()) + minValue.doubleValue();
|
||||||
if (minValue instanceof Integer) {
|
if (minValue instanceof Integer) {
|
||||||
return (N) (Integer) res.intValue();
|
return (N) (Integer) res.intValue();
|
||||||
|
|
|
@ -57,5 +57,12 @@
|
||||||
"title.screen.bclib.worldgen.custom_biome_source": "Benutzerdefinierte Biomquelle verwenden",
|
"title.screen.bclib.worldgen.custom_biome_source": "Benutzerdefinierte Biomquelle verwenden",
|
||||||
"title.screen.bclib.worldgen.legacy_square": "Legacy-Verteilung (1.17)",
|
"title.screen.bclib.worldgen.legacy_square": "Legacy-Verteilung (1.17)",
|
||||||
"title.screen.bclib.worldgen.custom_end_terrain": "Angepasster End-Terrain-Generator",
|
"title.screen.bclib.worldgen.custom_end_terrain": "Angepasster End-Terrain-Generator",
|
||||||
"title.screen.bclib.worldgen.end_void": "Kleine End-Inseln erzeugen"
|
"title.screen.bclib.worldgen.end_void": "Kleine End-Inseln erzeugen",
|
||||||
|
"title.screen.bclib.worldgen.avg_biome_size": "Durchscnittl. Biome Größe (in Chunks)",
|
||||||
|
"title.screen.bclib.worldgen.other": "Sonstiges",
|
||||||
|
"title.screen.bclib.worldgen.land_biome_size": "Land-Biome",
|
||||||
|
"title.screen.bclib.worldgen.void_biome_size": "Kleine Inseln",
|
||||||
|
"title.screen.bclib.worldgen.center_biome_size": "Zentralbiome",
|
||||||
|
"title.screen.bclib.worldgen.barrens_biome_size": "Ödniss",
|
||||||
|
"title.screen.bclib.worldgen.central_radius": "Innerer Radius (in Chunks)"
|
||||||
}
|
}
|
|
@ -58,5 +58,12 @@
|
||||||
"title.screen.bclib.worldgen.custom_biome_source": "Use Custom Biome Source",
|
"title.screen.bclib.worldgen.custom_biome_source": "Use Custom Biome Source",
|
||||||
"title.screen.bclib.worldgen.legacy_square": "Use Legacy Map (1.17)",
|
"title.screen.bclib.worldgen.legacy_square": "Use Legacy Map (1.17)",
|
||||||
"title.screen.bclib.worldgen.custom_end_terrain": "Custom End Terrain Generator",
|
"title.screen.bclib.worldgen.custom_end_terrain": "Custom End Terrain Generator",
|
||||||
"title.screen.bclib.worldgen.end_void": "Generate small Islands"
|
"title.screen.bclib.worldgen.avg_biome_size": "Average Biome Size (in Chunks)",
|
||||||
|
"title.screen.bclib.worldgen.other": "Other Settings",
|
||||||
|
"title.screen.bclib.worldgen.land_biome_size": "Land Biomes",
|
||||||
|
"title.screen.bclib.worldgen.void_biome_size": "Small Island Biomes",
|
||||||
|
"title.screen.bclib.worldgen.center_biome_size": "Central Biomes",
|
||||||
|
"title.screen.bclib.worldgen.barrens_biome_size": "Barrens",
|
||||||
|
"title.screen.bclib.worldgen.central_radius": "Central Void Radius (in Chunks)",
|
||||||
|
"title.screen.bclib.worldgen.end_void": "Generate Small Islands"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue