New storage GUIs, TODO re-add priority
This commit is contained in:
@@ -3,7 +3,6 @@ package com.raoulvdberge.refinedstorage;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
@@ -41,12 +40,12 @@ import java.util.function.Function;
|
||||
public final class RSUtils {
|
||||
public static final ItemStack EMPTY_BUCKET = new ItemStack(Items.BUCKET);
|
||||
|
||||
public static final DecimalFormat QUANTITY_FORMATTER = new DecimalFormat("####0.#", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
private static final String NBT_INVENTORY = "Inventory_%d";
|
||||
private static final String NBT_SLOT = "Slot";
|
||||
private static final String NBT_ACCESS_TYPE = "AccessType";
|
||||
|
||||
public static final DecimalFormat QUANTITY_FORMATTER = new DecimalFormat("####0.#", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
static {
|
||||
QUANTITY_FORMATTER.setRoundingMode(RoundingMode.DOWN);
|
||||
}
|
||||
@@ -154,16 +153,6 @@ public final class RSUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static NBTTagList serializeItemStackList(IItemStackList list) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (ItemStack stack : list.getStacks()) {
|
||||
tagList.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
return tagList;
|
||||
}
|
||||
|
||||
public static NBTTagList serializeFluidStackList(IFluidStackList list) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
@@ -174,20 +163,6 @@ public final class RSUtils {
|
||||
return tagList;
|
||||
}
|
||||
|
||||
public static IItemStackList readItemStackList(NBTTagList tagList) {
|
||||
IItemStackList list = API.instance().createItemStackList();
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tagList.getCompoundTagAt(i));
|
||||
|
||||
if (stack != null) {
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static IFluidStackList readFluidStackList(NBTTagList tagList) {
|
||||
IFluidStackList list = API.instance().createFluidStackList();
|
||||
|
||||
@@ -279,4 +254,14 @@ public final class RSUtils {
|
||||
public static FluidStack copyStack(FluidStack stack) {
|
||||
return stack == null ? null : stack.copy();
|
||||
}
|
||||
|
||||
public static String formatQuantity(int qty) {
|
||||
if (qty >= 1000000) {
|
||||
return RSUtils.QUANTITY_FORMATTER.format((float) qty / 1000000F) + "M";
|
||||
} else if (qty >= 1000) {
|
||||
return RSUtils.QUANTITY_FORMATTER.format((float) qty / 1000F) + "K";
|
||||
}
|
||||
|
||||
return String.valueOf(qty);
|
||||
}
|
||||
}
|
||||
|
@@ -11,19 +11,18 @@ public class ContainerDiskDrive extends ContainerBase {
|
||||
public ContainerDiskDrive(TileDiskDrive drive, EntityPlayer player) {
|
||||
super(drive, player);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotItemHandler(drive.getDisks(), i, 98 + (i * 18), 78));
|
||||
}
|
||||
int x = 71;
|
||||
int y = 54;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotItemHandler(drive.getDisks(), 4 + i, 98 + (i * 18), 96));
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
addSlotToContainer(new SlotItemHandler(drive.getDisks(), i, x + ((i % 2) * 18), y + Math.floorDiv(i, 2) * 18));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotSpecimenType(drive, i, 8 + (18 * i), 20));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 129);
|
||||
addPlayerInventory(8, 141);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -14,7 +14,7 @@ public class ContainerStorage extends ContainerBase {
|
||||
addSlotToContainer(new SlotSpecimen(tile.getFilters(), i, 8 + (18 * i), 20));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 129);
|
||||
addPlayerInventory(8, 141);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,28 +1,22 @@
|
||||
package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.IStorageGui;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiStorage extends GuiBase {
|
||||
private IStorageGui gui;
|
||||
private String texture;
|
||||
|
||||
private GuiTextField priorityField;
|
||||
|
||||
private int barX = 8;
|
||||
private int barY = 54;
|
||||
private int barWidth = 16;
|
||||
private int barHeight = 58;
|
||||
private int barHeight = 70;
|
||||
|
||||
public GuiStorage(ContainerBase container, IStorageGui gui, String texture) {
|
||||
super(container, 176, 211);
|
||||
super(container, 176, 223);
|
||||
|
||||
this.gui = gui;
|
||||
this.texture = texture;
|
||||
@@ -60,14 +54,9 @@ public class GuiStorage extends GuiBase {
|
||||
addSideButton(new SideButtonAccessType(this, gui.getAccessTypeParameter()));
|
||||
}
|
||||
|
||||
priorityField = new GuiTextField(0, fontRendererObj, x + 98 + 1, y + 54 + 1, 29, fontRendererObj.FONT_HEIGHT);
|
||||
priorityField.setEnableBackgroundDrawing(false);
|
||||
priorityField.setVisible(true);
|
||||
priorityField.setTextColor(16777215);
|
||||
priorityField.setCanLoseFocus(true);
|
||||
priorityField.setFocused(false);
|
||||
|
||||
updatePriority(gui.getPriorityParameter().getValue());
|
||||
String txt = "Priority"; // @TODO: I18n
|
||||
int bw = 10 + fontRendererObj.getStringWidth(txt);
|
||||
addButton(x + 169 - bw, y + 41, bw, 20, txt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,16 +72,21 @@ public class GuiStorage extends GuiBase {
|
||||
int barHeightNew = (int) ((float) gui.getStored() / (float) gui.getCapacity() * (float) barHeight);
|
||||
|
||||
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 179, barHeight - barHeightNew, barWidth, barHeightNew);
|
||||
|
||||
priorityField.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t(gui.getGuiTitle()));
|
||||
drawString(7, 42, gui.getCapacity() == -1 ? t("misc.refinedstorage:storage.stored_minimal", gui.getStored()) : t("misc.refinedstorage:storage.stored_capacity_minimal", gui.getStored(), gui.getCapacity()));
|
||||
drawString(97, 42, t("misc.refinedstorage:priority"));
|
||||
drawString(7, 117, t("container.inventory"));
|
||||
drawString(7, 42, gui.getCapacity() == -1 ?
|
||||
t("misc.refinedstorage:storage.stored_minimal", RSUtils.formatQuantity(gui.getStored())) :
|
||||
t("misc.refinedstorage:storage.stored_capacity_minimal", RSUtils.formatQuantity(gui.getStored()), RSUtils.formatQuantity(gui.getCapacity())));
|
||||
|
||||
// @TODO: I18n
|
||||
if (texture.contains("disk_drive")) { // HACK!
|
||||
drawString(70, 42, "Disks");
|
||||
}
|
||||
|
||||
drawString(7, 129, t("container.inventory"));
|
||||
|
||||
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY)) {
|
||||
int full = 0;
|
||||
@@ -105,31 +99,7 @@ public class GuiStorage extends GuiBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
priorityField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int keyCode) throws IOException {
|
||||
if (checkHotbarKeys(keyCode)) {
|
||||
// NO OP
|
||||
} else if (priorityField.textboxKeyTyped(character, keyCode)) {
|
||||
Integer result = Ints.tryParse(priorityField.getText());
|
||||
|
||||
if (result != null) {
|
||||
TileDataManager.setParameter(gui.getPriorityParameter(), result);
|
||||
}
|
||||
} else {
|
||||
super.keyTyped(character, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
// @TODO: Remove
|
||||
public void updatePriority(int priority) {
|
||||
if (priorityField != null) {
|
||||
priorityField.setText(String.valueOf(priority));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -74,19 +74,13 @@ public class ClientStackItem implements IClientStack {
|
||||
|
||||
if (advanced && qty > 1) {
|
||||
return String.valueOf(qty);
|
||||
}
|
||||
|
||||
if (qty >= 1000000) {
|
||||
return RSUtils.QUANTITY_FORMATTER.format((float) qty / 1000000F) + "M";
|
||||
} else if (qty >= 1000) {
|
||||
return RSUtils.QUANTITY_FORMATTER.format((float) qty / 1000F) + "K";
|
||||
} else if (qty == 1) {
|
||||
return null;
|
||||
} else if (qty == 0) {
|
||||
return I18n.format("gui.refinedstorage:grid.craft");
|
||||
}
|
||||
|
||||
return String.valueOf(qty);
|
||||
return RSUtils.formatQuantity(qty);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -54,10 +54,10 @@ misc.refinedstorage:energy_stored=%d / %d RS
|
||||
misc.refinedstorage:energy_usage=Usage: %d RS/t
|
||||
misc.refinedstorage:energy_usage_minimal=%d RS/t
|
||||
|
||||
misc.refinedstorage:storage.stored=Stored: %d
|
||||
misc.refinedstorage:storage.stored_capacity=Stored: %d / %d
|
||||
misc.refinedstorage:storage.stored_minimal=%d
|
||||
misc.refinedstorage:storage.stored_capacity_minimal=%d / %d
|
||||
misc.refinedstorage:storage.stored=Stored: %s
|
||||
misc.refinedstorage:storage.stored_capacity=Stored: %s / %s
|
||||
misc.refinedstorage:storage.stored_minimal=%s
|
||||
misc.refinedstorage:storage.stored_capacity_minimal=%s / %s
|
||||
misc.refinedstorage:storage.full=%d%% full
|
||||
|
||||
misc.refinedstorage:wireless_grid.tooltip=Linked to %d, %d, %d.
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user