Skip to content

Commit

Permalink
ref: better gui organisation
Browse files Browse the repository at this point in the history
  • Loading branch information
Uhutown committed Sep 10, 2024
1 parent b92039f commit d5775e6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
45 changes: 25 additions & 20 deletions src/main/java/com/troblecodings/signals/enums/EnumGuiMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,38 @@ public enum EnumGuiMode {
0, 0.5f, 0.5f, 1
}), END(new float[] {
0.9f, 0.2f, 0.9f, 0.8f
}, PathwayModeType.END), PLATFORM((state) -> new UILines(new float[] {
}, PathwayModeType.END, 0), PLATFORM((state) -> new UILines(new float[] {
0, 0.15f, 1, 0.15f
}, 3).setColor(SignalBoxUtil.FREE_COLOR), PathwayModeType.NONE), BUE(new float[] {
}, 3).setColor(SignalBoxUtil.FREE_COLOR), PathwayModeType.NONE, 0), BUE(new float[] {
0.3f, 0, 0.3f, 1, 0.7f, 0, 0.7f, 1
}), HP(0, true, PathwayModeType.START_END), VP(1, true, PathwayModeType.NONE),
RS(2, true, PathwayModeType.START_END), RA10(3, PathwayModeType.END),
SH2(4, PathwayModeType.NONE),
IN_CONNECTION((_u) -> new UITexture(UISignalBoxTile.INCOMING_ICON), PathwayModeType.START),
OUT_CONNECTION((_u) -> new UITexture(UISignalBoxTile.OUTGOING_ICON), PathwayModeType.END),
ARROW((_u) -> new UITexture(UISignalBoxTile.ARROW_ICON), PathwayModeType.END),
NE1((_u) -> new UITexture(UISignalBoxTile.NE1_ICON), PathwayModeType.START_END),
NE5((_u) -> new UITexture(UISignalBoxTile.NE5_ICON), PathwayModeType.START_END),
ZS3((_u) -> new UITexture(UISignalBoxTile.ZS3_ICON), PathwayModeType.NONE),
}), HP(0, true, PathwayModeType.START_END, 2), VP(1, true, PathwayModeType.NONE, 1),
RS(2, true, PathwayModeType.START_END, 1), RA10(3, PathwayModeType.END, 1),
SH2(4, PathwayModeType.NONE, 1),
IN_CONNECTION((_u) -> new UITexture(UISignalBoxTile.INCOMING_ICON), PathwayModeType.START, 1),
OUT_CONNECTION((_u) -> new UITexture(UISignalBoxTile.OUTGOING_ICON), PathwayModeType.END, 1),
ARROW((_u) -> new UITexture(UISignalBoxTile.ARROW_ICON), PathwayModeType.END, 1),
NE1((_u) -> new UITexture(UISignalBoxTile.NE1_ICON), PathwayModeType.START_END, 1),
NE5((_u) -> new UITexture(UISignalBoxTile.NE5_ICON), PathwayModeType.START_END, 1),
ZS3((_u) -> new UITexture(UISignalBoxTile.ZS3_ICON), PathwayModeType.NONE, 1),
TRAIN_NUMBER((_u) -> new UILines(new float[] {
0, 0.5f, 2, 0.5f
}, 6).setColor(GuiSignalBox.TRAIN_NUMBER_BACKGROUND_COLOR), PathwayModeType.NONE);
}, 6).setColor(GuiSignalBox.TRAIN_NUMBER_BACKGROUND_COLOR), PathwayModeType.NONE, 2);

/**
* Naming
*/

public final OSSupplier<Object> consumer;
public final int translation;
private final PathwayModeType type;

private EnumGuiMode(final int id, final PathwayModeType type) {
this((_u) -> new UITexture(UISignalBoxTile.ICON, id * 0.2, 0, id * 0.2 + 0.2, 0.5), type);
private EnumGuiMode(final int id, final PathwayModeType type, final int translation) {
this((_u) -> new UITexture(UISignalBoxTile.ICON, id * 0.2, 0, id * 0.2 + 0.2, 0.5), type,
translation);
}

private EnumGuiMode(final int id, final boolean unused, final PathwayModeType type) {
private EnumGuiMode(final int id, final boolean unused, final PathwayModeType type,
final int translation) {
this((state) -> {
switch (state) {
case GREEN: {
Expand Down Expand Up @@ -76,20 +79,22 @@ private EnumGuiMode(final int id, final boolean unused, final PathwayModeType ty
default:
return new UITexture(UISignalBoxTile.SIGNALS);
}
}, type);
}, type, translation);
}

private EnumGuiMode(final float[] array) {
this(array, PathwayModeType.NONE);
this(array, PathwayModeType.NONE, 0);
}

private EnumGuiMode(final float[] array, final PathwayModeType type) {
this((_u) -> new UILines(array, 2).setColor(SignalBoxUtil.FREE_COLOR), type);
private EnumGuiMode(final float[] array, final PathwayModeType type, final int translation) {
this((_u) -> new UILines(array, 2).setColor(SignalBoxUtil.FREE_COLOR), type, translation);
}

private EnumGuiMode(final OSSupplier<Object> consumer, final PathwayModeType type) {
private EnumGuiMode(final OSSupplier<Object> consumer, final PathwayModeType type,
final int translation) {
this.consumer = consumer;
this.type = type;
this.translation = translation;
}

public PathwayModeType getModeType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void localAdd(final ModeSet modeSet) {
rotation.setRotateZ(modeSet.rotation.ordinal() * ((float) 90));
entity.add(rotation);
}
entity.add(new UIIndependentTranslate(0, 0, 1));
entity.add(new UIIndependentTranslate(0, 0, modeSet.mode.translation + 1));

SignalState state = greenSignals.getOrDefault(modeSet, SignalState.RED);
if (modeSet.mode.equals(EnumGuiMode.RS)) {
Expand Down

0 comments on commit d5775e6

Please sign in to comment.