Add reader writer gui
This commit is contained in:
@@ -27,4 +27,5 @@ public final class RSBlocks {
|
|||||||
public static final BlockFluidInterface FLUID_INTERFACE = new BlockFluidInterface();
|
public static final BlockFluidInterface FLUID_INTERFACE = new BlockFluidInterface();
|
||||||
public static final BlockFluidStorage FLUID_STORAGE = new BlockFluidStorage();
|
public static final BlockFluidStorage FLUID_STORAGE = new BlockFluidStorage();
|
||||||
public static final BlockDiskManipulator DISK_MANIPULATOR = new BlockDiskManipulator();
|
public static final BlockDiskManipulator DISK_MANIPULATOR = new BlockDiskManipulator();
|
||||||
|
public static final BlockReader READER = new BlockReader();
|
||||||
}
|
}
|
||||||
@@ -25,4 +25,5 @@ public final class RSGui {
|
|||||||
public static final int FLUID_STORAGE = 21;
|
public static final int FLUID_STORAGE = 21;
|
||||||
public static final int DISK_MANIPULATOR = 22;
|
public static final int DISK_MANIPULATOR = 22;
|
||||||
public static final int WIRELESS_CRAFTING_MONITOR = 23;
|
public static final int WIRELESS_CRAFTING_MONITOR = 23;
|
||||||
|
public static final int READER_WRITER = 24;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,14 +232,6 @@ public interface INetworkMaster {
|
|||||||
*/
|
*/
|
||||||
void addReaderWriterChannel(String name);
|
void addReaderWriterChannel(String name);
|
||||||
|
|
||||||
/**
|
|
||||||
* Renames a reader writer channel.
|
|
||||||
*
|
|
||||||
* @param oldName the old name
|
|
||||||
* @param newName the new name
|
|
||||||
*/
|
|
||||||
void renameReaderWriterChannel(String oldName, String newName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a reader writer channel.
|
* Removes a reader writer channel.
|
||||||
*
|
*
|
||||||
|
|||||||
38
src/main/java/com/raoulvdberge/refinedstorage/block/BlockReader.java
Executable file
38
src/main/java/com/raoulvdberge/refinedstorage/block/BlockReader.java
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.block;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.RSGui;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileReader;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockReader extends BlockNode {
|
||||||
|
public BlockReader() {
|
||||||
|
super("reader");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
|
if (!world.isRemote) {
|
||||||
|
player.openGui(RS.INSTANCE, RSGui.READER_WRITER, world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||||
|
return new TileReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumPlacementType getPlacementType() {
|
||||||
|
return EnumPlacementType.ANY;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
||||||
|
public class ContainerReaderWriter extends ContainerBase {
|
||||||
|
public ContainerReaderWriter(TileBase tile, EntityPlayer player) {
|
||||||
|
super(tile, player);
|
||||||
|
|
||||||
|
addPlayerInventory(8, 127);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -116,8 +116,7 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
|
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
|
|
||||||
int ox = 8;
|
int x = 8;
|
||||||
int x = ox;
|
|
||||||
int y = 20;
|
int y = 20;
|
||||||
|
|
||||||
itemSelectedX = -1;
|
itemSelectedX = -1;
|
||||||
@@ -139,7 +138,6 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
|
|
||||||
element.draw(x, y, drawers);
|
element.draw(x, y, drawers);
|
||||||
|
|
||||||
x = ox;
|
|
||||||
y += ITEM_HEIGHT;
|
y += ITEM_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
return new ContainerFluidStorage((TileFluidStorage) tile, player);
|
return new ContainerFluidStorage((TileFluidStorage) tile, player);
|
||||||
case RSGui.DISK_MANIPULATOR:
|
case RSGui.DISK_MANIPULATOR:
|
||||||
return new ContainerDiskManipulator((TileDiskManipulator) tile, player);
|
return new ContainerDiskManipulator((TileDiskManipulator) tile, player);
|
||||||
|
case RSGui.READER_WRITER:
|
||||||
|
return new ContainerReaderWriter((TileBase) tile, player);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -133,6 +135,8 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
return new GuiDiskManipulator((ContainerDiskManipulator) getContainer(ID, player, tile));
|
return new GuiDiskManipulator((ContainerDiskManipulator) getContainer(ID, player, tile));
|
||||||
case RSGui.WIRELESS_CRAFTING_MONITOR:
|
case RSGui.WIRELESS_CRAFTING_MONITOR:
|
||||||
return getWirelessCraftingMonitorGui(player, x, y);
|
return getWirelessCraftingMonitorGui(player, x, y);
|
||||||
|
case RSGui.READER_WRITER:
|
||||||
|
return new GuiReaderWriter((ContainerReaderWriter) getContainer(ID, player, tile), (IReaderWriterGui) tile);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
167
src/main/java/com/raoulvdberge/refinedstorage/gui/GuiReaderWriter.java
Executable file
167
src/main/java/com/raoulvdberge/refinedstorage/gui/GuiReaderWriter.java
Executable file
@@ -0,0 +1,167 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.gui;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.container.ContainerReaderWriter;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.IReaderWriterGui;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GuiReaderWriter extends GuiBase {
|
||||||
|
private static final int VISIBLE_ROWS = 4;
|
||||||
|
|
||||||
|
private static final int ITEM_WIDTH = 143;
|
||||||
|
private static final int ITEM_HEIGHT = 18;
|
||||||
|
|
||||||
|
private GuiButton add;
|
||||||
|
private GuiButton remove;
|
||||||
|
private GuiTextField name;
|
||||||
|
private IReaderWriterGui readerWriter;
|
||||||
|
|
||||||
|
private int itemSelected = -1;
|
||||||
|
|
||||||
|
private int itemSelectedX = -1;
|
||||||
|
private int itemSelectedY = -1;
|
||||||
|
|
||||||
|
public GuiReaderWriter(ContainerReaderWriter container, IReaderWriterGui readerWriter) {
|
||||||
|
super(container, 176, 209);
|
||||||
|
|
||||||
|
this.readerWriter = readerWriter;
|
||||||
|
this.scrollbar = new Scrollbar(157, 39, 12, 71);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(int x, int y) {
|
||||||
|
add = addButton(x + 128, y + 15, 20, 20, "+");
|
||||||
|
remove = addButton(x + 150, y + 15, 20, 20, "-");
|
||||||
|
name = new GuiTextField(0, fontRendererObj, x + 8 + 1, y + 20 + 1, 107, fontRendererObj.FONT_HEIGHT);
|
||||||
|
name.setEnableBackgroundDrawing(false);
|
||||||
|
name.setVisible(true);
|
||||||
|
name.setTextColor(16777215);
|
||||||
|
name.setCanLoseFocus(true);
|
||||||
|
name.setFocused(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(int x, int y) {
|
||||||
|
scrollbar.setEnabled(getRows() > VISIBLE_ROWS);
|
||||||
|
scrollbar.setMaxOffset(getRows() - VISIBLE_ROWS);
|
||||||
|
|
||||||
|
if (itemSelected >= getChannels().size()) {
|
||||||
|
itemSelected = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getRows() {
|
||||||
|
return getChannels().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||||
|
bindTexture("gui/readerwriter.png");
|
||||||
|
|
||||||
|
drawTexture(x, y, 0, 0, width, height);
|
||||||
|
|
||||||
|
if (itemSelectedX != -1 &&
|
||||||
|
itemSelectedY != -1 &&
|
||||||
|
itemSelected >= 0 &&
|
||||||
|
itemSelected < getChannels().size()) {
|
||||||
|
drawTexture(x + itemSelectedX, y + itemSelectedY, 0, 216, ITEM_WIDTH, ITEM_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
name.drawTextBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawForeground(int mouseX, int mouseY) {
|
||||||
|
drawString(7, 7, t(readerWriter.getTitle()));
|
||||||
|
drawString(7, 115, t("container.inventory"));
|
||||||
|
|
||||||
|
int x = 8;
|
||||||
|
int y = 39;
|
||||||
|
|
||||||
|
int item = scrollbar.getOffset();
|
||||||
|
|
||||||
|
for (int i = 0; i < VISIBLE_ROWS; ++i) {
|
||||||
|
if (item < getChannels().size()) {
|
||||||
|
if (item == itemSelected) {
|
||||||
|
itemSelectedX = x;
|
||||||
|
itemSelectedY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
float scale = 0.5f;
|
||||||
|
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.scale(scale, scale, 1);
|
||||||
|
|
||||||
|
drawString(calculateOffsetOnScale(x + 5, scale), calculateOffsetOnScale(y + 7, scale), getChannels().get(item));
|
||||||
|
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
|
||||||
|
y += ITEM_HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
item++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||||
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
|
name.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
|
itemSelected = -1;
|
||||||
|
|
||||||
|
if (mouseButton == 0 && inBounds(8, 39, 144, 73, mouseX - guiLeft, mouseY - guiTop)) {
|
||||||
|
int item = scrollbar.getOffset();
|
||||||
|
|
||||||
|
for (int i = 0; i < VISIBLE_ROWS; ++i) {
|
||||||
|
int ix = 8;
|
||||||
|
int iy = 39 + (i * ITEM_HEIGHT);
|
||||||
|
|
||||||
|
if (inBounds(ix, iy, ITEM_WIDTH, ITEM_HEIGHT, mouseX - guiLeft, mouseY - guiTop) && (item + i) < getChannels().size()) {
|
||||||
|
itemSelected = item + i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void keyTyped(char character, int keyCode) throws IOException {
|
||||||
|
if (!checkHotbarKeys(keyCode) && name.textboxKeyTyped(character, keyCode)) {
|
||||||
|
// NO OP
|
||||||
|
} else {
|
||||||
|
super.keyTyped(character, keyCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
|
super.actionPerformed(button);
|
||||||
|
|
||||||
|
if (button == add) {
|
||||||
|
|
||||||
|
} else if (button == remove) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> tempChannels;
|
||||||
|
|
||||||
|
private List<String> getChannels() {
|
||||||
|
if (tempChannels == null) {
|
||||||
|
tempChannels = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 40; ++i) {
|
||||||
|
tempChannels.add("Item " + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tempChannels;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -128,6 +128,7 @@ public class ProxyCommon {
|
|||||||
registerTile(TileFluidInterface.class, "fluid_interface");
|
registerTile(TileFluidInterface.class, "fluid_interface");
|
||||||
registerTile(TileFluidStorage.class, "fluid_storage");
|
registerTile(TileFluidStorage.class, "fluid_storage");
|
||||||
registerTile(TileDiskManipulator.class, "disk_manipulator");
|
registerTile(TileDiskManipulator.class, "disk_manipulator");
|
||||||
|
registerTile(TileReader.class, "reader");
|
||||||
|
|
||||||
registerBlock(RSBlocks.CONTROLLER);
|
registerBlock(RSBlocks.CONTROLLER);
|
||||||
registerBlock(RSBlocks.GRID);
|
registerBlock(RSBlocks.GRID);
|
||||||
@@ -153,6 +154,7 @@ public class ProxyCommon {
|
|||||||
registerBlock(RSBlocks.NETWORK_TRANSMITTER);
|
registerBlock(RSBlocks.NETWORK_TRANSMITTER);
|
||||||
registerBlock(RSBlocks.NETWORK_RECEIVER);
|
registerBlock(RSBlocks.NETWORK_RECEIVER);
|
||||||
registerBlock(RSBlocks.DISK_MANIPULATOR);
|
registerBlock(RSBlocks.DISK_MANIPULATOR);
|
||||||
|
registerBlock(RSBlocks.READER);
|
||||||
|
|
||||||
registerItem(RSItems.QUARTZ_ENRICHED_IRON);
|
registerItem(RSItems.QUARTZ_ENRICHED_IRON);
|
||||||
registerItem(RSItems.STORAGE_DISK);
|
registerItem(RSItems.STORAGE_DISK);
|
||||||
|
|||||||
9
src/main/java/com/raoulvdberge/refinedstorage/tile/IReaderWriterGui.java
Executable file
9
src/main/java/com/raoulvdberge/refinedstorage/tile/IReaderWriterGui.java
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
public interface IReaderWriterGui {
|
||||||
|
String getTitle();
|
||||||
|
|
||||||
|
void onAdd(String name);
|
||||||
|
|
||||||
|
void onRemove(String name);
|
||||||
|
}
|
||||||
@@ -573,13 +573,6 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
readerWriterChannels.put(name, API.instance().createReaderWriterChannel(this));
|
readerWriterChannels.put(name, API.instance().createReaderWriterChannel(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renameReaderWriterChannel(String oldName, String newName) {
|
|
||||||
readerWriterChannels.put(newName, readerWriterChannels.get(oldName));
|
|
||||||
|
|
||||||
removeReaderWriterChannel(oldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeReaderWriterChannel(String name) {
|
public void removeReaderWriterChannel(String name) {
|
||||||
readerWriterChannels.remove(name);
|
readerWriterChannels.remove(name);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.tile;
|
|||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReader;
|
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReader;
|
||||||
|
|
||||||
public class TileReader extends TileNode implements IReader {
|
public class TileReader extends TileNode implements IReader, IReaderWriterGui {
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
return 0; // @TODO
|
return 0; // @TODO
|
||||||
@@ -16,4 +16,19 @@ public class TileReader extends TileNode implements IReader {
|
|||||||
public int getRedstoneStrength() {
|
public int getRedstoneStrength() {
|
||||||
return worldObj.getRedstonePower(pos, getDirection().getOpposite());
|
return worldObj.getRedstonePower(pos, getDirection().getOpposite());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle() {
|
||||||
|
return "gui.refinedstorage:reader";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdd(String name) {
|
||||||
|
// @TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRemove(String name) {
|
||||||
|
// @TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ gui.refinedstorage:crafting_preview.missing=Missing: %d
|
|||||||
gui.refinedstorage:crafting_preview.circular=Circular dependency!
|
gui.refinedstorage:crafting_preview.circular=Circular dependency!
|
||||||
gui.refinedstorage:crafting_preview.loop=Loop in processing...
|
gui.refinedstorage:crafting_preview.loop=Loop in processing...
|
||||||
gui.refinedstorage:crafting_preview.force_start=Press CTRL + SHIFT to start anyway
|
gui.refinedstorage:crafting_preview.force_start=Press CTRL + SHIFT to start anyway
|
||||||
|
gui.refinedstorage:reader=Reader
|
||||||
|
|
||||||
misc.refinedstorage:energy_stored=%d / %d RS
|
misc.refinedstorage:energy_stored=%d / %d RS
|
||||||
misc.refinedstorage:energy_usage=Usage: %d RS/t
|
misc.refinedstorage:energy_usage=Usage: %d RS/t
|
||||||
@@ -179,6 +180,7 @@ block.refinedstorage:fluid_storage.1.name=128k Fluid Storage Block
|
|||||||
block.refinedstorage:fluid_storage.2.name=256k Fluid Storage Block
|
block.refinedstorage:fluid_storage.2.name=256k Fluid Storage Block
|
||||||
block.refinedstorage:fluid_storage.3.name=512k Fluid Storage Block
|
block.refinedstorage:fluid_storage.3.name=512k Fluid Storage Block
|
||||||
block.refinedstorage:fluid_storage.4.name=Creative Fluid Storage Block
|
block.refinedstorage:fluid_storage.4.name=Creative Fluid Storage Block
|
||||||
|
block.refinedstorage:reader.name=Reader
|
||||||
|
|
||||||
item.refinedstorage:storage_disk.0.name=1k Storage Disk
|
item.refinedstorage:storage_disk.0.name=1k Storage Disk
|
||||||
item.refinedstorage:storage_disk.1.name=4k Storage Disk
|
item.refinedstorage:storage_disk.1.name=4k Storage Disk
|
||||||
|
|||||||
BIN
src/main/resources/assets/refinedstorage/textures/gui/readerwriter.png
Executable file
BIN
src/main/resources/assets/refinedstorage/textures/gui/readerwriter.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Reference in New Issue
Block a user