use of mods.railcraft.common.carts.EntityLocomotive.LocoMode in project Railcraft by Railcraft.
the class GuiLocomotive method initGui.
@Override
public void initGui() {
super.initGui();
if (loco == null)
return;
buttonList.clear();
int w = (width - xSize) / 2;
int h = (height - ySize) / 2;
int id = 0;
for (LocoMode mode : loco.getAllowedModes()) {
GuiToggleButtonSmall button = new GuiToggleButtonSmall(id++, 0, h + ySize - 129, 55, LocalizationPlugin.translate("gui.railcraft.locomotive.mode." + mode.getName()), loco.clientMode == mode);
button.setClickConsumer(b -> loco.clientMode = mode);
button.setStatusUpdater(b -> b.active = loco.clientMode == mode);
button.setToolTip(ToolTip.buildToolTip("gui.railcraft.locomotive." + typeTag + ".tips.button.mode." + mode.getName()));
modeButtons.put(mode, button);
}
GuiTools.newButtonRowAuto(buttonList, w + 3, 171, modeButtons.values());
GuiToggleButtonSmall reverseButton = new GuiToggleButtonSmall(id++, 0, h + ySize - 112, 12, "R", loco.isReverse());
reverseButton.setClickConsumer(b -> loco.setReverse(!loco.isReverse()));
reverseButton.setStatusUpdater(b -> b.active = loco.isReverse());
speedButtons.add(reverseButton);
for (LocoSpeed speed : LocoSpeed.VALUES) {
String label = "";
for (int i = 0; i < speed.getLevel(); i++) {
label += ">";
}
GuiToggleButtonSmall button = new GuiToggleButtonSmall(id++, 0, h + ySize - 112, 7 + speed.getLevel() * 5, label, loco.clientSpeed == speed);
button.setClickConsumer(b -> loco.clientSpeed = speed);
button.setStatusUpdater(b -> b.active = loco.clientSpeed == speed);
speedButtons.add(button);
}
GuiTools.newButtonRow(buttonList, w + 8, 3, speedButtons);
buttonList.add(lockButton = GuiMultiButton.create(id, w + 152, h + ySize - 111, 16, loco.getLockController()));
lockButton.enabled = loco.clientCanLock;
}
use of mods.railcraft.common.carts.EntityLocomotive.LocoMode in project Railcraft by Railcraft.
the class ContainerLocomotive method sendUpdateToClient.
@Override
public void sendUpdateToClient() {
super.sendUpdateToClient();
for (IContainerListener crafter : listeners) {
LocoSpeed speed = loco.getSpeed();
if (lastSpeed != speed)
crafter.sendProgressBarUpdate(this, 10, speed.ordinal());
LocoMode mode = loco.getMode();
if (lastMode != mode)
crafter.sendProgressBarUpdate(this, 11, mode.ordinal());
int lock = loco.getLockController().getCurrentState();
if (lastLockState != lock)
crafter.sendProgressBarUpdate(this, 12, lock);
}
this.lastSpeed = loco.getSpeed();
this.lastMode = loco.getMode();
this.lastLockState = loco.getLockController().getCurrentState();
}
Aggregations