Display active machines in controller.
This commit is contained in:
@@ -1,8 +1,13 @@
|
|||||||
package refinedstorage.gui;
|
package refinedstorage.gui;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import refinedstorage.container.ContainerController;
|
import refinedstorage.container.ContainerController;
|
||||||
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||||
import refinedstorage.tile.TileController;
|
import refinedstorage.tile.TileController;
|
||||||
|
import refinedstorage.tile.TileMachine;
|
||||||
|
|
||||||
public class GuiController extends GuiBase
|
public class GuiController extends GuiBase
|
||||||
{
|
{
|
||||||
@@ -11,7 +16,9 @@ public class GuiController extends GuiBase
|
|||||||
private int barX = 8;
|
private int barX = 8;
|
||||||
private int barY = 20;
|
private int barY = 20;
|
||||||
private int barWidth = 16;
|
private int barWidth = 16;
|
||||||
private int barHeight = 58;
|
private int barHeight = 59;
|
||||||
|
|
||||||
|
private Scrollbar scrollbar = new Scrollbar(157, 20, 12, 59);
|
||||||
|
|
||||||
public GuiController(ContainerController container, TileController controller)
|
public GuiController(ContainerController container, TileController controller)
|
||||||
{
|
{
|
||||||
@@ -29,6 +36,7 @@ public class GuiController extends GuiBase
|
|||||||
@Override
|
@Override
|
||||||
public void update(int x, int y)
|
public void update(int x, int y)
|
||||||
{
|
{
|
||||||
|
scrollbar.setCanScroll(getRows() > getVisibleRows());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -41,19 +49,72 @@ public class GuiController extends GuiBase
|
|||||||
int barHeightNew = (int) ((float) controller.getEnergyStored(null) / (float) controller.getMaxEnergyStored(null) * (float) barHeight);
|
int barHeightNew = (int) ((float) controller.getEnergyStored(null) / (float) controller.getMaxEnergyStored(null) * (float) barHeight);
|
||||||
|
|
||||||
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 178, 0 + (barHeight - barHeightNew), barWidth, barHeightNew);
|
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 178, 0 + (barHeight - barHeightNew), barWidth, barHeightNew);
|
||||||
|
|
||||||
|
scrollbar.draw(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawForeground(int mouseX, int mouseY)
|
public void drawForeground(int mouseX, int mouseY)
|
||||||
{
|
{
|
||||||
|
scrollbar.update(this, mouseX, mouseY);
|
||||||
|
|
||||||
drawString(7, 7, t("gui.refinedstorage:controller." + controller.getType().getId()));
|
drawString(7, 7, t("gui.refinedstorage:controller." + controller.getType().getId()));
|
||||||
drawString(7, 87, t("container.inventory"));
|
drawString(7, 87, t("container.inventory"));
|
||||||
|
|
||||||
drawString(31, 20, t("misc.refinedstorage:energy_usage", controller.getEnergyUsage()));
|
int x = 33;
|
||||||
|
int y = 26;
|
||||||
|
|
||||||
|
int slot = getOffset() * 2;
|
||||||
|
|
||||||
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
if (slot < controller.getMachines().size())
|
||||||
|
{
|
||||||
|
TileMachine machine = controller.getMachines().get(slot);
|
||||||
|
IBlockState machineState = machine.getWorld().getBlockState(machine.getPos());
|
||||||
|
Block machineBlock = machineState.getBlock();
|
||||||
|
|
||||||
|
ItemStack machineStack = new ItemStack(machineBlock, 1, machineBlock.getMetaFromState(machineState));
|
||||||
|
|
||||||
|
drawItem(x, y, machineStack);
|
||||||
|
drawString(x + 21, y + 5, t("misc.refinedstorage:energy_usage_minimal", machine.getEnergyUsage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 1)
|
||||||
|
{
|
||||||
|
x = 33;
|
||||||
|
y += 30;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x += 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot++;
|
||||||
|
}
|
||||||
|
|
||||||
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY))
|
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY))
|
||||||
{
|
{
|
||||||
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:energy_stored", controller.getEnergyStored(null), controller.getMaxEnergyStored(null)));
|
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:energy_usage", controller.getEnergyUsage()) + "\n" + t("misc.refinedstorage:energy_stored", controller.getEnergyStored(null), controller.getMaxEnergyStored(null)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getOffset()
|
||||||
|
{
|
||||||
|
return (int) (scrollbar.getCurrentScroll() / 59f * (float) getRows());
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getRows()
|
||||||
|
{
|
||||||
|
int max = (int) Math.ceil((float) controller.getMachines().size() / (float) 2);
|
||||||
|
|
||||||
|
return max < 0 ? 0 : max;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getVisibleRows()
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
import net.minecraft.init.SoundEvents;
|
import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import org.lwjgl.input.Mouse;
|
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.block.EnumGridType;
|
import refinedstorage.block.EnumGridType;
|
||||||
import refinedstorage.container.ContainerGrid;
|
import refinedstorage.container.ContainerGrid;
|
||||||
@@ -66,24 +65,6 @@ public class GuiGrid extends GuiBase
|
|||||||
public void update(int x, int y)
|
public void update(int x, int y)
|
||||||
{
|
{
|
||||||
scrollbar.setCanScroll(getRows() > getVisibleRows());
|
scrollbar.setCanScroll(getRows() > getVisibleRows());
|
||||||
|
|
||||||
if (scrollbar.canScroll())
|
|
||||||
{
|
|
||||||
int wheel = Mouse.getDWheel();
|
|
||||||
|
|
||||||
wheel = Math.max(Math.min(-wheel, 1), -1);
|
|
||||||
|
|
||||||
float delta = 20;
|
|
||||||
|
|
||||||
if (wheel == -1)
|
|
||||||
{
|
|
||||||
scrollbar.setCurrentScroll(scrollbar.getCurrentScroll() - delta);
|
|
||||||
}
|
|
||||||
else if (wheel == 1)
|
|
||||||
{
|
|
||||||
scrollbar.setCurrentScroll(scrollbar.getCurrentScroll() + delta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOffset()
|
public int getOffset()
|
||||||
|
|||||||
@@ -73,6 +73,21 @@ public class Scrollbar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int wheel = Mouse.getDWheel();
|
||||||
|
|
||||||
|
wheel = Math.max(Math.min(-wheel, 1), -1);
|
||||||
|
|
||||||
|
float delta = 15;
|
||||||
|
|
||||||
|
if (wheel == -1)
|
||||||
|
{
|
||||||
|
setCurrentScroll(currentScroll - delta);
|
||||||
|
}
|
||||||
|
else if (wheel == 1)
|
||||||
|
{
|
||||||
|
setCurrentScroll(currentScroll + delta);
|
||||||
|
}
|
||||||
|
|
||||||
boolean down = Mouse.isButtonDown(0);
|
boolean down = Mouse.isButtonDown(0);
|
||||||
|
|
||||||
if (!wasClicking && down && gui.inBounds(x, y, scrollbarWidth, scrollbarHeight, mouseX, mouseY))
|
if (!wasClicking && down && gui.inBounds(x, y, scrollbarWidth, scrollbarHeight, mouseX, mouseY))
|
||||||
|
|||||||
@@ -413,6 +413,21 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
|||||||
{
|
{
|
||||||
items.add(new StorageItem(buf));
|
items.add(new StorageItem(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
machines.clear();
|
||||||
|
|
||||||
|
size = buf.readInt();
|
||||||
|
|
||||||
|
for (int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
TileEntity tile = worldObj.getTileEntity(new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()));
|
||||||
|
|
||||||
|
if (tile instanceof TileMachine)
|
||||||
|
{
|
||||||
|
machines.add((TileMachine) tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -429,5 +444,14 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
|||||||
{
|
{
|
||||||
item.toBytes(buf, items.indexOf(item));
|
item.toBytes(buf, items.indexOf(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf.writeInt(machines.size());
|
||||||
|
|
||||||
|
for (TileMachine machine : machines)
|
||||||
|
{
|
||||||
|
buf.writeInt(machine.getPos().getX());
|
||||||
|
buf.writeInt(machine.getPos().getY());
|
||||||
|
buf.writeInt(machine.getPos().getZ());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class TileDetector extends TileMachine implements ICompareSetting
|
|||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage()
|
public int getEnergyUsage()
|
||||||
{
|
{
|
||||||
return 4;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class TileGrid extends TileMachine
|
|||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage()
|
public int getEnergyUsage()
|
||||||
{
|
{
|
||||||
return 5;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class TileInterface extends TileMachine implements ICompareSetting, ISide
|
|||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage()
|
public int getEnergyUsage()
|
||||||
{
|
{
|
||||||
return 5;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
|||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage()
|
public int getEnergyUsage()
|
||||||
{
|
{
|
||||||
return 1;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class TileWirelessTransmitter extends TileMachine implements IInventory
|
|||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage()
|
public int getEnergyUsage()
|
||||||
{
|
{
|
||||||
return 4;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ gui.refinedstorage:interface.export.explanation.2=Incr. or decr. a slot: left/ r
|
|||||||
|
|
||||||
misc.refinedstorage:energy_stored=%d / %d RF
|
misc.refinedstorage:energy_stored=%d / %d RF
|
||||||
misc.refinedstorage:energy_usage=Usage: %d RF/t
|
misc.refinedstorage:energy_usage=Usage: %d RF/t
|
||||||
|
misc.refinedstorage:energy_usage_minimal=%d RF/t
|
||||||
|
|
||||||
misc.refinedstorage:storage.stored=Stored: %d
|
misc.refinedstorage:storage.stored=Stored: %d
|
||||||
misc.refinedstorage:storage.stored_capacity=Stored: %d / %d
|
misc.refinedstorage:storage.stored_capacity=Stored: %d / %d
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.2 KiB |
Reference in New Issue
Block a user