Pressing SHIFT over an item in the Grid will no longer display the full unformatted count, instead, use CTRL + SHIFT and it will be displayed in the tooltip

This commit is contained in:
raoulvdberge
2017-09-01 20:46:14 +02:00
parent f432755535
commit 3480d0490b
8 changed files with 25 additions and 24 deletions

View File

@@ -5,6 +5,7 @@
- Added Project E integration for the energy values of Solderer items (raoulvdberge)
- Fixed network not disconnecting when Controller is broken (raoulvdberge)
- The Fortune Upgrade doesn't use NBT anymore to store the fortune level (raoulvdberge)
- Pressing SHIFT over an item in the Grid will no longer display the full unformatted count, instead, use CTRL + SHIFT and it will be displayed in the tooltip (raoulvdberge)
### 1.5.17
- Re-added support for OpenComputers (raoulvdberge)

View File

@@ -22,6 +22,7 @@ import net.minecraftforge.items.SlotItemHandler;
import org.lwjgl.input.Mouse;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
@@ -253,21 +254,21 @@ public abstract class GuiBase extends GuiContainer {
drawItem(x, y, stack, withOverlay, null);
}
public void drawItem(int x, int y, ItemStack stack, boolean withOverlay, String message) {
public void drawItem(int x, int y, ItemStack stack, boolean withOverlay, @Nullable String text) {
zLevel = 200.0F;
itemRender.zLevel = 200.0F;
itemRender.renderItemIntoGUI(stack, x, y);
if (withOverlay) {
drawItemOverlay(stack, message, x, y);
drawItemOverlay(stack, text, x, y);
}
zLevel = 0.0F;
itemRender.zLevel = 0.0F;
}
public void drawItemOverlay(ItemStack stack, String text, int x, int y) {
public void drawItemOverlay(ItemStack stack, @Nullable String text, int x, int y) {
itemRender.renderItemOverlayIntoGUI(fontRenderer, stack, x, y, "");
if (text != null) {

View File

@@ -476,7 +476,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
}
if (slot < STACKS.size()) {
STACKS.get(slot).draw(this, xx, yy, GuiScreen.isShiftKeyDown() && slotNumber == slot);
STACKS.get(slot).draw(this, xx, yy);
}
if (inBounds(xx, yy, 16, 16, mouseX, mouseY) || !grid.isActive()) {
@@ -506,7 +506,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
if (isOverSlotWithStack()) {
IGridStack stack = STACKS.get(slotNumber);
drawTooltip(stack instanceof GridStackItem ? ((GridStackItem) stack).getStack() : ItemStack.EMPTY, mouseX, mouseY, stack.getTooltip());
drawTooltip(stack instanceof GridStackItem ? ((GridStackItem) stack).getStack() : ItemStack.EMPTY, mouseX, mouseY, stack.getTooltip(GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown()));
}
if (isOverClear(mouseX, mouseY)) {

View File

@@ -13,7 +13,7 @@ public class GridFilterTooltip implements Predicate<IGridStack> {
@Override
public boolean test(IGridStack stack) {
String otherTooltip = stack.getTooltip().trim().toLowerCase();
String otherTooltip = stack.getTooltip(false).trim().toLowerCase();
if (!otherTooltip.contains("\n")) {
return false;

View File

@@ -39,7 +39,7 @@ public class GridStackFluid implements IGridStack {
}
@Override
public String getTooltip() {
public String getTooltip(boolean quantity) {
return stack.getFluid().getLocalizedName(stack);
}
@@ -49,7 +49,7 @@ public class GridStackFluid implements IGridStack {
}
@Override
public void draw(GuiBase gui, int x, int y, boolean isOverWithShift) {
public void draw(GuiBase gui, int x, int y) {
GuiBase.FLUID_RENDERER.draw(gui.mc, x, y, stack);
gui.drawQuantity(x, y, RenderUtils.formatQuantity((int) ((float) stack.amount / 1000F)));

View File

@@ -76,7 +76,7 @@ public class GridStackItem implements IGridStack {
}
@Override
public String getTooltip() {
public String getTooltip(boolean quantity) {
List<String> lines = stack.getTooltip(Minecraft.getMinecraft().player, Minecraft.getMinecraft().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL);
// From GuiScreen#renderToolTip
@@ -88,6 +88,10 @@ public class GridStackItem implements IGridStack {
}
}
if (quantity && !lines.isEmpty()) {
lines.set(0, lines.get(0) + " " + TextFormatting.GRAY + "(" + RenderUtils.QUANTITY_FORMATTER_UNFORMATTED.format(stack.getCount()) + "x)" + TextFormatting.RESET);
}
return lines.stream().collect(Collectors.joining("\n"));
}
@@ -96,23 +100,17 @@ public class GridStackItem implements IGridStack {
return stack.getCount();
}
private String getQuantityForDisplay(boolean advanced) {
int qty = stack.getCount();
@Override
public void draw(GuiBase gui, int x, int y) {
String text = null;
if (displayCraftText) {
return I18n.format("gui.refinedstorage:grid.craft");
} else if (advanced && qty > 1) {
return String.valueOf(qty);
} else if (qty == 1) {
return null;
text = I18n.format("gui.refinedstorage:grid.craft");
} else if (stack.getCount() > 1) {
text = RenderUtils.formatQuantity(stack.getCount());
}
return RenderUtils.formatQuantity(qty);
}
@Override
public void draw(GuiBase gui, int x, int y, boolean isOverWithShift) {
gui.drawItem(x, y, stack, true, getQuantityForDisplay(isOverWithShift));
gui.drawItem(x, y, stack, true, text);
}
@Override

View File

@@ -11,11 +11,11 @@ public interface IGridStack {
String[] getOreIds();
String getTooltip();
String getTooltip(boolean quantity);
int getQuantity();
void draw(GuiBase gui, int x, int y, boolean isOverWithShift);
void draw(GuiBase gui, int x, int y);
Object getIngredient();
}

View File

@@ -30,6 +30,7 @@ import java.util.Locale;
public final class RenderUtils {
public static final DecimalFormat QUANTITY_FORMATTER = new DecimalFormat("####0.#", DecimalFormatSymbols.getInstance(Locale.US));
public static final DecimalFormat QUANTITY_FORMATTER_UNFORMATTED = new DecimalFormat("#,###", DecimalFormatSymbols.getInstance(Locale.US));
public static final Matrix4f EMPTY_MATRIX_TRANSFORM = getTransform(0, 0, 0, 0, 0, 0, 1.0f).getMatrix();