Search in sources :

Example 1 with LocoMode

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;
}
Also used : GuiToggleButtonSmall(mods.railcraft.client.gui.buttons.GuiToggleButtonSmall) LocoSpeed(mods.railcraft.common.carts.EntityLocomotive.LocoSpeed) LocoMode(mods.railcraft.common.carts.EntityLocomotive.LocoMode)

Example 2 with LocoMode

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();
}
Also used : LocoSpeed(mods.railcraft.common.carts.EntityLocomotive.LocoSpeed) IContainerListener(net.minecraft.inventory.IContainerListener) LocoMode(mods.railcraft.common.carts.EntityLocomotive.LocoMode)

Aggregations

LocoMode (mods.railcraft.common.carts.EntityLocomotive.LocoMode)2 LocoSpeed (mods.railcraft.common.carts.EntityLocomotive.LocoSpeed)2 GuiToggleButtonSmall (mods.railcraft.client.gui.buttons.GuiToggleButtonSmall)1 IContainerListener (net.minecraft.inventory.IContainerListener)1