Press OK to OK

- Station UIs no longer show intermediate assembly information after the assemble button is clicked
This commit is contained in:
simibubi 2022-05-27 16:12:46 +02:00
parent cfbde0ab6c
commit 8d84910fb9
3 changed files with 22 additions and 11 deletions

View file

@ -88,7 +88,10 @@ public class Train {
public UUID currentStation; public UUID currentStation;
public boolean currentlyBackwards; public boolean currentlyBackwards;
// considered for removal
@Deprecated
public boolean heldForAssembly; public boolean heldForAssembly;
public boolean doubleEnded; public boolean doubleEnded;
public List<Carriage> carriages; public List<Carriage> carriages;
public List<Integer> carriageSpacing; public List<Integer> carriageSpacing;
@ -124,7 +127,7 @@ public class Train {
navigation = new Navigation(this); navigation = new Navigation(this);
runtime = new ScheduleRuntime(this); runtime = new ScheduleRuntime(this);
heldForAssembly = true; heldForAssembly = false;
migratingPoints = new ArrayList<>(); migratingPoints = new ArrayList<>();
currentStation = null; currentStation = null;
manualSteer = SteerDirection.NONE; manualSteer = SteerDirection.NONE;
@ -171,9 +174,6 @@ public class Train {
return; return;
} }
if (heldForAssembly && getCurrentStation() == null)
heldForAssembly = false;
updateConductors(); updateConductors();
runtime.tick(level); runtime.tick(level);
navigation.tick(level); navigation.tick(level);

View file

@ -65,14 +65,14 @@ public class AssemblyScreen extends AbstractStationScreen {
iconTypeScroll.active = iconTypeScroll.visible = false; iconTypeScroll.active = iconTypeScroll.visible = false;
addRenderableWidget(iconTypeScroll); addRenderableWidget(iconTypeScroll);
toggleAssemblyButton = new WideIconButton(x + 83, by, AllGuiTextures.I_ASSEMBLE_TRAIN); toggleAssemblyButton = new WideIconButton(x + 94, by, AllGuiTextures.I_ASSEMBLE_TRAIN);
toggleAssemblyButton.active = false; toggleAssemblyButton.active = false;
toggleAssemblyButton.setToolTip(new TextComponent("Assemble Train")); toggleAssemblyButton.setToolTip(new TextComponent("Assemble Train"));
toggleAssemblyButton.withCallback(() -> { toggleAssemblyButton.withCallback(() -> {
AllPackets.channel.sendToServer(StationEditPacket.tryAssemble(te.getBlockPos())); AllPackets.channel.sendToServer(StationEditPacket.tryAssemble(te.getBlockPos()));
}); });
quitAssembly = new IconButton(x + 62, by, AllIcons.I_DISABLE); quitAssembly = new IconButton(x + 73, by, AllIcons.I_DISABLE);
quitAssembly.active = true; quitAssembly.active = true;
quitAssembly.setToolTip(new TextComponent("Cancel Assembly")); quitAssembly.setToolTip(new TextComponent("Cancel Assembly"));
quitAssembly.withCallback(() -> { quitAssembly.withCallback(() -> {
@ -89,6 +89,8 @@ public class AssemblyScreen extends AbstractStationScreen {
minecraft.setScreen(new StationScreen(te, station)); minecraft.setScreen(new StationScreen(te, station));
}); });
completeAssembly.visible = false;
addRenderableWidget(toggleAssemblyButton); addRenderableWidget(toggleAssemblyButton);
addRenderableWidget(quitAssembly); addRenderableWidget(quitAssembly);
addRenderableWidget(completeAssembly); addRenderableWidget(completeAssembly);
@ -103,9 +105,13 @@ public class AssemblyScreen extends AbstractStationScreen {
Train train = displayedTrain.get(); Train train = displayedTrain.get();
toggleAssemblyButton.active = te.bogeyCount > 0 || train != null; toggleAssemblyButton.active = te.bogeyCount > 0 || train != null;
if (train != null) if (train != null) {
assemblyCompleted = true;
AllPackets.channel.sendToServer(StationEditPacket.configure(te.getBlockPos(), false, station.name));
minecraft.setScreen(new StationScreen(te, station));
for (Carriage carriage : train.carriages) for (Carriage carriage : train.carriages)
carriage.updateConductors(); carriage.updateConductors();
}
} }
private void tickTrainDisplay() { private void tickTrainDisplay() {
@ -113,7 +119,7 @@ public class AssemblyScreen extends AbstractStationScreen {
Train imminentTrain = getImminent(); Train imminentTrain = getImminent();
if (train == null) { if (train == null) {
if (imminentTrain != null) { if (imminentTrain != null && !imminentTrain.heldForAssembly) {
displayedTrain = new WeakReference<>(imminentTrain); displayedTrain = new WeakReference<>(imminentTrain);
completeAssembly.active = true; completeAssembly.active = true;
quitAssembly.active = false; quitAssembly.active = false;
@ -151,6 +157,7 @@ public class AssemblyScreen extends AbstractStationScreen {
Train train = displayedTrain.get(); Train train = displayedTrain.get();
if (train != null) { if (train != null) {
// note: the code below becomes redundant if Train.heldForAssembly is removed
TrainIconType icon = train.icon; TrainIconType icon = train.icon;
int offset = 0; int offset = 0;
int trainIconWidth = getTrainIconWidth(train); int trainIconWidth = getTrainIconWidth(train);
@ -220,8 +227,8 @@ public class AssemblyScreen extends AbstractStationScreen {
new TextComponent(bogeyCount == 0 ? "No Bogeys" : bogeyCount + (bogeyCount == 1 ? " Bogey" : " Bogeys")); new TextComponent(bogeyCount == 0 ? "No Bogeys" : bogeyCount + (bogeyCount == 1 ? " Bogey" : " Bogeys"));
font.draw(ms, text, x + 97 - font.width(text) / 2, y + 47, 0x7A7A7A); font.draw(ms, text, x + 97 - font.width(text) / 2, y + 47, 0x7A7A7A);
font.drawWordWrap(new TextComponent("Use Train Casing on highlighted Tracks to create bogeys."), x + 28, y + 62, 134, font.drawWordWrap(new TextComponent("Use Train Casing on highlighted Tracks to create bogeys."), x + 28, y + 62,
0x7A7A7A); 134, 0x7A7A7A);
font.drawWordWrap(new TextComponent("Remove bogeys by breaking the block on top."), x + 28, y + 94, 134, font.drawWordWrap(new TextComponent("Remove bogeys by breaking the block on top."), x + 28, y + 94, 134,
0x7A7A7A); 0x7A7A7A);
font.drawWordWrap(new TextComponent("Build carriages attached to one or two bogeys each."), x + 28, y + 117, font.drawWordWrap(new TextComponent("Build carriages attached to one or two bogeys each."), x + 28, y + 117,

View file

@ -347,7 +347,11 @@ public class StationScreen extends AbstractStationScreen {
AllPackets.channel AllPackets.channel
.sendToServer(StationEditPacket.configure(te.getBlockPos(), switchingToAssemblyMode, nameBox.getValue())); .sendToServer(StationEditPacket.configure(te.getBlockPos(), switchingToAssemblyMode, nameBox.getValue()));
Train train = displayedTrain.get(); Train train = displayedTrain.get();
if (!switchingToAssemblyMode && train != null) if (train == null)
return;
if (switchingToAssemblyMode)
train.heldForAssembly = true;
if (!switchingToAssemblyMode)
AllPackets.channel AllPackets.channel
.sendToServer(new TrainEditPacket(train.id, trainNameBox.getValue(), false, train.icon.getId())); .sendToServer(new TrainEditPacket(train.id, trainNameBox.getValue(), false, train.icon.getId()));
} }