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) - Added Project E integration for the energy values of Solderer items (raoulvdberge)
- Fixed network not disconnecting when Controller is broken (raoulvdberge) - Fixed network not disconnecting when Controller is broken (raoulvdberge)
- The Fortune Upgrade doesn't use NBT anymore to store the fortune level (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 ### 1.5.17
- Re-added support for OpenComputers (raoulvdberge) - Re-added support for OpenComputers (raoulvdberge)

View File

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

View File

@@ -476,7 +476,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
} }
if (slot < STACKS.size()) { 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()) { if (inBounds(xx, yy, 16, 16, mouseX, mouseY) || !grid.isActive()) {
@@ -506,7 +506,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
if (isOverSlotWithStack()) { if (isOverSlotWithStack()) {
IGridStack stack = STACKS.get(slotNumber); 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)) { if (isOverClear(mouseX, mouseY)) {

View File

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

View File

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

View File

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

View File

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

View File

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