use of mods.railcraft.common.gui.widgets.FluidGaugeWidget in project Railcraft by Railcraft.
the class ContainerTank method createGauge.
public FluidGaugeWidget createGauge(StandardTank tank, int x, int y, int u, int v, int w, int h) {
if (logicContainer.getLogic(WaterGeneratorLogic.class).isPresent())
return new FluidGaugeWidget(tank, x, y, u, v, w, h) {
GeneratorStatus status = new GeneratorStatus();
ToolTip toolTip = new ToolTip() {
@Override
public void refresh() {
clear();
ToolTip tankToolTip = tank.getToolTip();
tankToolTip.refresh();
addAll(tankToolTip);
get(0).format = TextFormatting.BLUE;
newline();
add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.sky", status.canSeeSky), TextFormatting.DARK_GRAY));
add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.base", status.baseRate() * status.canSeeSky), TextFormatting.DARK_GRAY));
add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.humidity", status.humidityMultiplier), TextFormatting.DARK_GRAY));
add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.precipitation", status.precipitationMultiplier), TextFormatting.DARK_GRAY));
add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.temp", -status.tempPenalty), TextFormatting.DARK_GRAY));
add(new ToolTipLine(LocalizationPlugin.format("gui.railcraft.tank.final", (status.baseRate() * status.canSeeSky * status.humidityMultiplier * status.precipitationMultiplier) - status.tempPenalty), TextFormatting.DARK_GRAY));
}
};
@Override
public void writeServerSyncData(IContainerListener listener, RailcraftOutputStream data) throws IOException {
super.writeServerSyncData(listener, data);
GeneratorStatus temp = new GeneratorStatus();
temp.precipitationMultiplier = 0.0;
temp.humidityMultiplier = 0.0;
logicContainer.getLogic(StructureLogic.class).ifPresent(struct -> {
struct.getComponents().stream().map(t -> t.getLogic(WaterGeneratorLogic.class)).flatMap(Streams.unwrap()).map(l -> l.status).forEach(s -> {
temp.canSeeSky += s.canSeeSky;
if (s.canSeeSky > 0) {
temp.humidityMultiplier += s.humidityMultiplier;
temp.precipitationMultiplier += s.precipitationMultiplier;
temp.tempPenalty += s.tempPenalty;
}
});
});
if (temp.canSeeSky > 0) {
temp.humidityMultiplier /= temp.canSeeSky;
temp.precipitationMultiplier /= temp.canSeeSky;
}
temp.writeData(data);
}
@Override
public void readServerSyncData(RailcraftInputStream data) throws IOException {
super.readServerSyncData(data);
status.readData(data);
}
@Override
public ToolTip getToolTip() {
return toolTip;
}
};
return new FluidGaugeWidget(tank, x, y, u, v, w, h);
}
use of mods.railcraft.common.gui.widgets.FluidGaugeWidget in project Railcraft by Railcraft.
the class ContainerLocomotiveSteamSolid method defineSlotsAndWidgets.
@Override
public void defineSlotsAndWidgets() {
addWidget(new FluidGaugeWidget(loco.getTankManager().get(0), 53, 23, 176, 0, 16, 47));
addWidget(new FluidGaugeWidget(loco.getTankManager().get(1), 17, 23, 176, 0, 16, 47));
addWidget(new IndicatorWidget(loco.boiler.heatIndicator, 40, 25, 176, 61, 6, 43));
addSlot(new SlotWaterLimited(loco, 0, 152, 20));
addSlot(new SlotOutput(loco, 1, 152, 56));
addSlot(new SlotOutput(loco, 2, 116, 56));
// Burn
addSlot(new SlotRailcraft(loco, 3, 116, 20));
// Fuel
addSlot(new SlotRailcraft(loco, 4, 80, 20));
// Fuel
addSlot(new SlotRailcraft(loco, 5, 80, 38));
// Fuel
addSlot(new SlotRailcraft(loco, 6, 80, 56));
}
Aggregations