Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,25 @@ default void applyPos() {}

void setLayoutDone(boolean done);

default void setAxisResized(GuiAxis axis, boolean pos, boolean size) {
if (axis.isHorizontal()) {
setXAxisResized(pos, size);
} else {
setYAxisResized(pos, size);
}
}

void setXAxisResized(boolean pos, boolean size);

void setYAxisResized(boolean pos, boolean size);

/**
* Marks position and size as calculated.
*/
void setResized(boolean x, boolean y, boolean w, boolean h);
default void setResized(boolean x, boolean y, boolean w, boolean h) {
setXAxisResized(x, w);
setYAxisResized(y, h);
}

default void setPosResized(boolean x, boolean y) {
setResized(x, y, isWidthCalculated(), isHeightCalculated());
Expand All @@ -57,11 +72,11 @@ default void setSizeResized(boolean w, boolean h) {
}

default void setXResized(boolean v) {
setResized(v, isYCalculated(), isWidthCalculated(), isHeightCalculated());
setXAxisResized(v, isWidthCalculated());
}

default void setYResized(boolean v) {
setResized(isXCalculated(), v, isWidthCalculated(), isHeightCalculated());
setYAxisResized(v, isHeightCalculated());
}

default void setPosResized(GuiAxis axis, boolean v) {
Expand All @@ -73,11 +88,11 @@ default void setPosResized(GuiAxis axis, boolean v) {
}

default void setWidthResized(boolean v) {
setResized(isXCalculated(), isYCalculated(), v, isHeightCalculated());
setXAxisResized(isXCalculated(), v);
}

default void setHeightResized(boolean v) {
setResized(isXCalculated(), isYCalculated(), isWidthCalculated(), v);
setYAxisResized(isYCalculated(), v);
}

default void setSizeResized(GuiAxis axis, boolean v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,33 @@ private Alignment(float x, float y, String name) {
*/
public enum MainAxis {

/**
* All children will be put at the start of the Flow next to each other.
*/
START,
/**
* All children will be put in the center of the Flow next to each other.
*/
CENTER,
/**
* All children will be put at the end of the Flow next to each other (this does not reverse children order).
*/
END,
/**
* This maximizes the space between children with the given available space of the Flow. The first widget will
* be put at the very
* start and the last widget will be put at the very end. If the flow has exactly one child, then this behaves
* the same as
* {@link #CENTER}.
*/
SPACE_BETWEEN,
/**
* This maximizes the space around the children with the given available space of the Flow. Contrary to
* {@link #SPACE_BETWEEN} this
* does not put one "space" between every widget, but rather one "space" on both sides of every widget. If the
* flow has exactly one
* child, then this behaves the same as {@link #CENTER}.
*/
SPACE_AROUND
}

Expand All @@ -75,8 +98,17 @@ public enum MainAxis {
*/
public enum CrossAxis {

/**
* All children will be put at the start of the Flow next to each other.
*/
START,
/**
* All children will be put in the center of the Flow next to each other.
*/
CENTER,
/**
* All children will be put at the end of the Flow next to each other (this does not reverse children order).
*/
END
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public int darkerSafe(int index) {
return this.darker[Mth.clamp(index, 0, this.darker.length - 1)];
}

public int darkerShadeCount() {
return this.darker.length;
}

public int brighter(int index) {
return this.brighter[index];
}
Expand All @@ -72,6 +76,10 @@ public int brighterSafe(int index) {
return this.brighter[Mth.clamp(index, 0, this.brighter.length - 1)];
}

public int brighterShadeCount() {
return this.brighter.length;
}

@NotNull
@Override
public IntIterator iterator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
public class BigDecimalSyncValue extends GenericSyncValue<BigDecimal> implements IStringValue<BigDecimal> {

public BigDecimalSyncValue(@NotNull Supplier<BigDecimal> getter, @Nullable Consumer<BigDecimal> setter) {
super(BigDecimal.class, getter, setter, ByteBufAdapters.BIG_DECIMAL, ICopy.immutable());
this(getter, setter, false);
}

public BigDecimalSyncValue(@NotNull Supplier<BigDecimal> getter, @Nullable Consumer<BigDecimal> setter,
boolean nullable) {
super(BigDecimal.class, getter, setter, ByteBufAdapters.BIG_DECIMAL, ICopy.immutable(), nullable);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
public class BigIntegerSyncValue extends GenericSyncValue<BigInteger> implements IStringValue<BigInteger> {

public BigIntegerSyncValue(@NotNull Supplier<BigInteger> getter, @Nullable Consumer<BigInteger> setter) {
super(BigInteger.class, getter, setter, ByteBufAdapters.BIG_INT, ICopy.immutable());
this(getter, setter, false);
}

public BigIntegerSyncValue(@NotNull Supplier<BigInteger> getter, @Nullable Consumer<BigInteger> setter,
boolean nullable) {
super(BigInteger.class, getter, setter, ByteBufAdapters.BIG_INT, ICopy.immutable(), nullable);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
public class ByteArraySyncValue extends GenericSyncValue<byte[]> {

public ByteArraySyncValue(@NotNull Supplier<byte[]> getter, @Nullable Consumer<byte[]> setter) {
super(byte[].class, getter, setter, ByteBufAdapters.BYTE_ARR, byte[]::clone);
this(getter, setter, false);
}

public ByteArraySyncValue(@NotNull Supplier<byte[]> getter, @Nullable Consumer<byte[]> setter, boolean nullable) {
super(byte[].class, getter, setter, ByteBufAdapters.BYTE_ARR, byte[]::clone, nullable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ public GenericSyncValue(@NotNull Supplier<T> getter,
this(null, getter, setter, deserializer, serializer, equals, copy);
}

@ApiStatus.Obsolete
public GenericSyncValue(@NotNull Class<T> type,
@NotNull Supplier<T> getter,
@Nullable Consumer<T> setter,
@NotNull IByteBufAdapter<T> adapter,
@Nullable ICopy<T> copy,
boolean nullable) {
this(type, getter, setter, adapter, adapter, adapter, copy, nullable);
}

@ApiStatus.ScheduledForRemoval(inVersion = "3.2.0")
@Deprecated
public GenericSyncValue(@NotNull Class<T> type,
@NotNull Supplier<T> getter,
@Nullable Consumer<T> setter,
Expand All @@ -123,30 +135,49 @@ public GenericSyncValue(@NotNull Class<T> type,
this(type, getter, setter, adapter, adapter, adapter, copy);
}

@ApiStatus.Obsolete
public GenericSyncValue(@NotNull Class<T> type,
@NotNull Supplier<T> getter,
@Nullable Consumer<T> setter,
@NotNull IByteBufAdapter<T> adapter) {
this(type, getter, setter, adapter, adapter, adapter, null);
}

@ApiStatus.ScheduledForRemoval(inVersion = "3.3.0")
@Deprecated
public GenericSyncValue(@NotNull Class<T> type,
@NotNull Supplier<T> getter,
@Nullable Consumer<T> setter,
@NotNull IByteBufDeserializer<T> deserializer,
@NotNull IByteBufSerializer<T> serializer,
@Nullable EqualityTest<T> equals,
@Nullable ICopy<T> copy) {
this(type, getter, setter, deserializer, serializer, equals, copy, false);
}

@ApiStatus.Obsolete
public GenericSyncValue(@NotNull Class<T> type,
@NotNull Supplier<T> getter,
@Nullable Consumer<T> setter,
@NotNull IByteBufDeserializer<T> deserializer,
@NotNull IByteBufSerializer<T> serializer,
@Nullable EqualityTest<T> equals,
@Nullable ICopy<T> copy,
boolean nullable) {
super(type, getter, setter);
this.deserializer = Objects.requireNonNull(deserializer);
this.serializer = Objects.requireNonNull(serializer);
this.equals = equals == null ? Objects::equals : EqualityTest.wrapNullSafe(equals);
this.copy = copy == null ? ICopy.ofSerializer(serializer, deserializer) : copy;
Objects.requireNonNull(deserializer);
Objects.requireNonNull(serializer);
this.deserializer = nullable ? IByteBufDeserializer.wrapNullSafe(deserializer) : deserializer;
this.serializer = nullable ? IByteBufSerializer.wrapNullSafe(serializer) : serializer;
if (equals == null) equals = EqualityTest.defaultTester();
this.equals = nullable ? EqualityTest.wrapNullSafe(equals) : equals;
if (copy == null) copy = ICopy.ofSerializer(serializer, deserializer);
this.copy = copy; // null check in createDeepCopyOf()
}

@Override
protected T createDeepCopyOf(T value) {
return this.copy.createDeepCopy(value);
return value == null ? null : this.copy.createDeepCopy(value);
}

@Override
Expand Down Expand Up @@ -178,6 +209,7 @@ public static class Builder<T> {
private IByteBufSerializer<T> serializer;
private EqualityTest<T> equals;
private ICopy<T> copy;
private boolean nullable;

public Builder(Class<T> type) {
this.type = type;
Expand Down Expand Up @@ -231,8 +263,13 @@ public Builder<T> adapter(IByteBufAdapter<T> adapter) {
.equals(adapter);
}

public Builder<T> nullable() {
this.nullable = true;
return this;
}

public GenericSyncValue<T> build() {
return new GenericSyncValue<>(type, getter, setter, deserializer, serializer, equals, copy);
return new GenericSyncValue<>(type, getter, setter, deserializer, serializer, equals, copy, nullable);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
public class LongArraySyncValue extends GenericSyncValue<long[]> {

public LongArraySyncValue(@NotNull Supplier<long[]> getter, @Nullable Consumer<long[]> setter) {
super(long[].class, getter, setter, ByteBufAdapters.LONG_ARR, long[]::clone);
this(getter, setter, false);
}

public LongArraySyncValue(@NotNull Supplier<long[]> getter, @Nullable Consumer<long[]> setter, boolean nullable) {
super(long[].class, getter, setter, ByteBufAdapters.LONG_ARR, long[]::clone, nullable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ protected void setName(String name) {
this.name = name;
}

public boolean isName(String name) {
return Objects.equals(name, this.name);
}

public boolean nameContains(String part) {
return this.name != null && this.name.contains(part);
}

/**
* This is only used in {@link #toString()}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ static boolean resize(ResizeNode resizer, boolean init, boolean onOpen, boolean

if (isLayout && shouldLayout) {
layoutSuccessful &= resizer.postLayoutChildren();
if (!selfFullyCalculated) resizer.postResize();
}
if (shouldLayout) resizer.setLayoutDone(layoutSuccessful);
checkFullyCalculated(anotherResize, state, isLayout);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.gregtechceu.gtceu.api.mui.value.sync.ModularSyncManager;
import com.gregtechceu.gtceu.api.mui.value.sync.SyncHandler;
import com.gregtechceu.gtceu.api.mui.value.sync.ValueSyncHandler;
import com.gregtechceu.gtceu.api.mui.widget.sizer.Bounds;
import com.gregtechceu.gtceu.api.mui.widget.sizer.StandardResizer;
import com.gregtechceu.gtceu.client.mui.screen.RichTooltip;
import com.gregtechceu.gtceu.client.mui.screen.viewport.ModularGuiContext;
Expand Down Expand Up @@ -579,8 +578,6 @@ public W setEnabledIf(Predicate<W> condition) {
// === Resizing ===
// ----------------

public void estimateSize(Bounds bounds) {}

@Override
public int getDefaultWidth() {
return isValid() ? getWidgetTheme(getPanel().getTheme()).getTheme().getDefaultWidth() : 18;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ public int requestedSize(GuiAxis axis) {
return axis.isHorizontal() ? requestedWidth() : requestedHeight();
}

public int paddedSize(GuiAxis axis) {
return axis.isHorizontal() ? paddedWidth() : paddedHeight();
}

public int relativeEndX() {
return this.rx + this.width;
}
Expand Down
Loading
Loading