CraftingMonitorElementText
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package refinedstorage.apiimpl.autocrafting.craftingmonitor;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
|
||||
public abstract class CraftingMonitorElementItemRender implements ICraftingMonitorElement<GuiBase> {
|
||||
@Override
|
||||
public void draw(GuiBase gui, int x, int y) {
|
||||
gui.drawItem(x + 2, y + 1, getItem());
|
||||
|
||||
float scale = 0.5f;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
|
||||
gui.drawString(gui.calculateOffsetOnScale(x + 21, scale), gui.calculateOffsetOnScale(y + 7, scale), getQuantity() + " " + getItem().getDisplayName());
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
protected abstract ItemStack getItem();
|
||||
|
||||
protected abstract int getQuantity();
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
package refinedstorage.apiimpl.autocrafting.craftingmonitor;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
|
||||
public class CraftingMonitorElementRoot implements ICraftingMonitorElement<GuiBase> {
|
||||
public class CraftingMonitorElementRoot extends CraftingMonitorElementItemRender {
|
||||
public static final String ID = "root";
|
||||
|
||||
private int id;
|
||||
@@ -20,20 +17,6 @@ public class CraftingMonitorElementRoot implements ICraftingMonitorElement<GuiBa
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui, int x, int y) {
|
||||
gui.drawItem(x + 2, y + 1, output);
|
||||
|
||||
float scale = 0.5f;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
|
||||
gui.drawString(gui.calculateOffsetOnScale(x + 21, scale), gui.calculateOffsetOnScale(y + 7, scale), quantity + " " + output.getDisplayName());
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskId() {
|
||||
return id;
|
||||
@@ -50,4 +33,14 @@ public class CraftingMonitorElementRoot implements ICraftingMonitorElement<GuiBa
|
||||
ByteBufUtils.writeItemStack(buf, output);
|
||||
buf.writeInt(quantity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getItem() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package refinedstorage.apiimpl.autocrafting.craftingmonitor;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
|
||||
public class CraftingMonitorElementText implements ICraftingMonitorElement<GuiBase> {
|
||||
public static final String ID = "text";
|
||||
|
||||
private String text;
|
||||
private int offset;
|
||||
|
||||
public CraftingMonitorElementText(String text, int offset) {
|
||||
this.text = text;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui, int x, int y) {
|
||||
float scale = 0.5f;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
|
||||
gui.drawString(gui.calculateOffsetOnScale(x + offset, scale), gui.calculateOffsetOnScale(y + 7, scale), I18n.format(text));
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf) {
|
||||
ByteBufUtils.writeUTF8String(buf, text);
|
||||
buf.writeInt(offset);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package refinedstorage.apiimpl.autocrafting.craftingmonitor;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
|
||||
public class CraftingMonitorElementToTake implements ICraftingMonitorElement<GuiBase> {
|
||||
public class CraftingMonitorElementToTake extends CraftingMonitorElementItemRender {
|
||||
public static final String ID = "to_take";
|
||||
|
||||
private ItemStack toTake;
|
||||
@@ -20,18 +18,7 @@ public class CraftingMonitorElementToTake implements ICraftingMonitorElement<Gui
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui, int x, int y) {
|
||||
x += 4;
|
||||
|
||||
gui.drawItem(x + 2, y + 1, toTake);
|
||||
|
||||
float scale = 0.5f;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
|
||||
gui.drawString(gui.calculateOffsetOnScale(x + 21, scale), gui.calculateOffsetOnScale(y + 7, scale), remaining + " " + toTake.getDisplayName());
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
super.draw(gui, x + 32, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,4 +36,14 @@ public class CraftingMonitorElementToTake implements ICraftingMonitorElement<Gui
|
||||
ByteBufUtils.writeItemStack(buf, toTake);
|
||||
buf.writeInt(remaining);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getItem() {
|
||||
return toTake;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getQuantity() {
|
||||
return remaining;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import refinedstorage.api.autocrafting.task.IProcessable;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.util.IItemStackList;
|
||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementRoot;
|
||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementText;
|
||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementToTake;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -159,6 +160,8 @@ public class CraftingTaskNormal implements ICraftingTask {
|
||||
quantity
|
||||
));
|
||||
|
||||
elements.add(new CraftingMonitorElementText("gui.refinedstorage:crafting_monitor.items_taking", 16));
|
||||
|
||||
elements.addAll(toTake.getStacks().stream()
|
||||
.map(stack -> new CraftingMonitorElementToTake(stack, stack.stackSize))
|
||||
.collect(Collectors.toList())
|
||||
|
||||
@@ -59,7 +59,7 @@ public class GuiCraftingMonitor extends GuiBase {
|
||||
itemSelected = -1;
|
||||
}
|
||||
|
||||
cancelButton.enabled = itemSelected != -1;
|
||||
cancelButton.enabled = itemSelected != -1 && getElements().get(itemSelected).getTaskId() != -1;
|
||||
cancelAllButton.enabled = getElements().size() > 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import refinedstorage.RSBlocks;
|
||||
import refinedstorage.RSItems;
|
||||
import refinedstorage.api.RSAPI;
|
||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementRoot;
|
||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementText;
|
||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementToTake;
|
||||
import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactoryNormal;
|
||||
import refinedstorage.apiimpl.solderer.*;
|
||||
@@ -51,6 +52,7 @@ public class CommonProxy {
|
||||
|
||||
RSAPI.instance().getCraftingMonitorElementRegistry().add(CraftingMonitorElementRoot.ID, buf -> new CraftingMonitorElementRoot(buf.readInt(), ByteBufUtils.readItemStack(buf), buf.readInt()));
|
||||
RSAPI.instance().getCraftingMonitorElementRegistry().add(CraftingMonitorElementToTake.ID, buf -> new CraftingMonitorElementToTake(ByteBufUtils.readItemStack(buf), buf.readInt()));
|
||||
RSAPI.instance().getCraftingMonitorElementRegistry().add(CraftingMonitorElementText.ID, buf -> new CraftingMonitorElementText(ByteBufUtils.readUTF8String(buf), buf.readInt()));
|
||||
|
||||
int id = 0;
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@ gui.refinedstorage:relay=Relay
|
||||
gui.refinedstorage:interface.import=Interface Import
|
||||
gui.refinedstorage:interface.export=Interface Export
|
||||
gui.refinedstorage:crafting_monitor=Crafting Monitor
|
||||
gui.refinedstorage:crafting_monitor.missing_items=Missing items
|
||||
gui.refinedstorage:crafting_monitor.items_crafting=Items crafting
|
||||
gui.refinedstorage:crafting_monitor.items_taking=Items taking
|
||||
gui.refinedstorage:crafting_monitor.items_processing=Items processing
|
||||
gui.refinedstorage:crafting_monitor.machine_in_use=Waiting on machine that is in use by another task
|
||||
gui.refinedstorage:crafting_monitor.machine_none=No machine found
|
||||
|
||||
Reference in New Issue
Block a user