Add zeroed state for preventSorting stuffs
This commit is contained in:
@@ -32,7 +32,7 @@ public class ClientConfig {
|
||||
private final ForgeConfigSpec.IntValue maxRowsStretch;
|
||||
private final ForgeConfigSpec.BooleanValue detailedTooltip;
|
||||
private final ForgeConfigSpec.BooleanValue largeFont;
|
||||
private final ForgeConfigSpec.BooleanValue sortGrid;
|
||||
private final ForgeConfigSpec.BooleanValue preventSortingWhileShiftIsDown;
|
||||
|
||||
public Grid() {
|
||||
builder.push("grid");
|
||||
@@ -40,7 +40,7 @@ public class ClientConfig {
|
||||
maxRowsStretch = builder.comment("The maximum amount of rows that the Grid can show when stretched").defineInRange("maxRowsStretch", Integer.MAX_VALUE, 3, Integer.MAX_VALUE);
|
||||
detailedTooltip = builder.comment("Whether the Grid should display a detailed tooltip when hovering over an item or fluid").define("detailedTooltip", true);
|
||||
largeFont = builder.comment("Whether the Grid should use a large font for stack quantity display").define("largeFont", false);
|
||||
sortGrid = builder.comment("Whether the grid should prevent sorting while Shift is held down").define("sortGrid", true);
|
||||
preventSortingWhileShiftIsDown = builder.comment("Whether the Grid should prevent sorting while the shift key is held down").define("preventSortingWhileShiftIsDown", true);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
@@ -57,8 +57,8 @@ public class ClientConfig {
|
||||
return largeFont.get();
|
||||
}
|
||||
|
||||
public boolean getSortGrid() {
|
||||
return sortGrid.get();
|
||||
public boolean getPreventSortingWhileShiftIsDown() {
|
||||
return preventSortingWhileShiftIsDown.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.screen;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -58,7 +59,7 @@ public abstract class AmountSpecifyingScreen<T extends Container> extends BaseSc
|
||||
amountField.setEnableBackgroundDrawing(false);
|
||||
amountField.setVisible(true);
|
||||
amountField.setText(String.valueOf(getDefaultAmount()));
|
||||
amountField.setTextColor(16777215);
|
||||
amountField.setTextColor(RenderUtils.DEFAULT_COLOR);
|
||||
amountField.setCanLoseFocus(false);
|
||||
amountField.changeFocus(true);
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
||||
FluidRenderer.INSTANCE.render(guiLeft + slot.xPos, guiTop + slot.yPos, stack);
|
||||
|
||||
if (((FluidFilterSlot) slot).isSizeAllowed()) {
|
||||
renderQuantity(guiLeft + slot.xPos, guiTop + slot.yPos, API.instance().getQuantityFormatter().formatInBucketForm(stack.getAmount()));
|
||||
renderQuantity(guiLeft + slot.xPos, guiTop + slot.yPos, API.instance().getQuantityFormatter().formatInBucketForm(stack.getAmount()), RenderUtils.DEFAULT_COLOR);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
}
|
||||
@@ -272,10 +272,10 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
||||
}
|
||||
|
||||
public void renderItem(int x, int y, ItemStack stack) {
|
||||
renderItem(x, y, stack, false, null);
|
||||
renderItem(x, y, stack, false, null, RenderUtils.DEFAULT_COLOR);
|
||||
}
|
||||
|
||||
public void renderItem(int x, int y, ItemStack stack, boolean overlay, @Nullable String text) {
|
||||
public void renderItem(int x, int y, ItemStack stack, boolean overlay, @Nullable String text, int textColor) {
|
||||
try {
|
||||
itemRenderer.zLevel = 200.0F;
|
||||
|
||||
@@ -286,7 +286,7 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
||||
}
|
||||
|
||||
if (text != null) {
|
||||
renderQuantity(x, y, text);
|
||||
renderQuantity(x, y, text, textColor);
|
||||
}
|
||||
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
@@ -295,7 +295,7 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
||||
}
|
||||
}
|
||||
|
||||
public void renderQuantity(int x, int y, String qty) {
|
||||
public void renderQuantity(int x, int y, String qty, int color) {
|
||||
boolean large = minecraft.getForceUnicodeFont() || RS.CLIENT_CONFIG.getGrid().getLargeFont();
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
@@ -312,7 +312,7 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
||||
GlStateManager.blendFunc(770, 771);
|
||||
GlStateManager.disableDepthTest();
|
||||
|
||||
font.drawStringWithShadow(qty, (large ? 16 : 30) - font.getStringWidth(qty), large ? 8 : 22, 16777215);
|
||||
font.drawStringWithShadow(qty, (large ? 16 : 30) - font.getStringWidth(qty), large ? 8 : 22, color);
|
||||
|
||||
GlStateManager.enableDepthTest();
|
||||
GlStateManager.enableTexture();
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.ExactModeSideBut
|
||||
import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.TypeSideButton;
|
||||
import com.raoulvdberge.refinedstorage.tile.DetectorTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@@ -34,7 +35,7 @@ public class DetectorScreen extends BaseScreen<DetectorContainer> {
|
||||
amountField.setVisible(true);
|
||||
amountField.setCanLoseFocus(true);
|
||||
amountField.setFocused2(false);
|
||||
amountField.setTextColor(16777215);
|
||||
amountField.setTextColor(RenderUtils.DEFAULT_COLOR);
|
||||
amountField.func_212954_a(value -> {
|
||||
try {
|
||||
int result = Integer.parseInt(value);
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.raoulvdberge.refinedstorage.container.FilterContainer;
|
||||
import com.raoulvdberge.refinedstorage.item.FilterItem;
|
||||
import com.raoulvdberge.refinedstorage.network.FilterUpdateMessage;
|
||||
import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.FilterTypeSideButton;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -71,7 +72,7 @@ public class FilterScreen extends BaseScreen<FilterContainer> {
|
||||
nameField.setVisible(true);
|
||||
nameField.setCanLoseFocus(true);
|
||||
nameField.setFocused2(false);
|
||||
nameField.setTextColor(16777215);
|
||||
nameField.setTextColor(RenderUtils.DEFAULT_COLOR);
|
||||
nameField.func_212954_a(name -> sendUpdate());
|
||||
|
||||
addButton(nameField);
|
||||
|
||||
@@ -420,9 +420,11 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
if (scrollbar.mouseClicked(mouseX, mouseY, clickedButton)) {
|
||||
return true;
|
||||
}
|
||||
if (RS.CLIENT_CONFIG.getGrid().getSortGrid()) {
|
||||
|
||||
if (RS.CLIENT_CONFIG.getGrid().getPreventSortingWhileShiftIsDown()) {
|
||||
doSort = !isOverSlotArea(mouseX - guiLeft, mouseY - guiTop) && !isOverCraftingOutputArea(mouseX - guiLeft, mouseY - guiTop);
|
||||
}
|
||||
|
||||
boolean clickedClear = clickedButton == 0 && isOverClear(mouseX - guiLeft, mouseY - guiTop);
|
||||
boolean clickedCreatePattern = clickedButton == 0 && isOverCreatePattern(mouseX - guiLeft, mouseY - guiTop);
|
||||
|
||||
@@ -563,6 +565,10 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
scrollbar.setMaxOffset(getRows() - getVisibleRows());
|
||||
}
|
||||
|
||||
public boolean canSort() {
|
||||
return doSort || !hasShiftDown();
|
||||
}
|
||||
|
||||
public static List<IGridSorter> getSorters() {
|
||||
List<IGridSorter> sorters = new LinkedList<>();
|
||||
sorters.add(getDefaultSorter());
|
||||
@@ -577,8 +583,4 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
public static IGridSorter getDefaultSorter() {
|
||||
return new NameGridSorter();
|
||||
}
|
||||
|
||||
public boolean canSort() {
|
||||
return doSort || !hasShiftDown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.raoulvdberge.refinedstorage.api.storage.tracker.StorageTrackerEntry;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -26,6 +27,7 @@ public class FluidGridStack implements IGridStack {
|
||||
@Nullable
|
||||
private StorageTrackerEntry entry;
|
||||
private boolean craftable;
|
||||
private boolean zeroed;
|
||||
|
||||
private Set<String> cachedTags;
|
||||
private String cachedName;
|
||||
@@ -41,6 +43,10 @@ public class FluidGridStack implements IGridStack {
|
||||
this.craftable = craftable;
|
||||
}
|
||||
|
||||
public void setZeroed(boolean zeroed) {
|
||||
this.zeroed = zeroed;
|
||||
}
|
||||
|
||||
public FluidStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
@@ -153,14 +159,18 @@ public class FluidGridStack implements IGridStack {
|
||||
FluidRenderer.INSTANCE.render(x, y, stack);
|
||||
|
||||
String text;
|
||||
int color = RenderUtils.DEFAULT_COLOR;
|
||||
|
||||
if (isCraftable()) {
|
||||
if (zeroed) {
|
||||
text = "0";
|
||||
color = 16733525;
|
||||
} else if (isCraftable()) {
|
||||
text = I18n.format("gui.refinedstorage.grid.craft");
|
||||
} else {
|
||||
text = API.instance().getQuantityFormatter().formatInBucketFormWithOnlyTrailingDigitsIfZero(getQuantity());
|
||||
}
|
||||
|
||||
gui.renderQuantity(x, y, text);
|
||||
gui.renderQuantity(x, y, text, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,7 @@ public class ItemGridStack implements IGridStack {
|
||||
private boolean craftable;
|
||||
@Nullable
|
||||
private StorageTrackerEntry entry;
|
||||
private boolean zeroed;
|
||||
|
||||
private Set<String> cachedTags;
|
||||
private String cachedName;
|
||||
@@ -49,6 +50,10 @@ public class ItemGridStack implements IGridStack {
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
public void setZeroed(boolean zeroed) {
|
||||
this.zeroed = zeroed;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static String getModNameByModId(String modId) {
|
||||
Optional<? extends ModContainer> modContainer = ModList.get().getModContainerById(modId);
|
||||
@@ -164,14 +169,18 @@ public class ItemGridStack implements IGridStack {
|
||||
@Override
|
||||
public void draw(BaseScreen gui, int x, int y) {
|
||||
String text = null;
|
||||
int color = RenderUtils.DEFAULT_COLOR;
|
||||
|
||||
if (craftable) {
|
||||
if (zeroed) {
|
||||
text = "0";
|
||||
color = 16733525;
|
||||
} else if (craftable) {
|
||||
text = I18n.format("gui.refinedstorage.grid.craft");
|
||||
} else if (stack.getCount() > 1) {
|
||||
text = API.instance().getQuantityFormatter().formatWithUnits(getQuantity());
|
||||
}
|
||||
|
||||
gui.renderItem(x, y, stack, true, text);
|
||||
gui.renderItem(x, y, stack, true, text, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,6 +43,7 @@ public abstract class BaseGridView implements IGridView {
|
||||
if (!screen.canSort()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<IGridStack> stacks = new ArrayList<>();
|
||||
|
||||
if (screen.getGrid().isActive()) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class FluidGridView extends BaseGridView {
|
||||
map.put(stack.getId(), stack);
|
||||
} else {
|
||||
if (existing.getStack().getAmount() + delta <= 0) {
|
||||
existing.getStack().grow(delta);
|
||||
existing.setZeroed(true);
|
||||
|
||||
map.remove(existing.getId());
|
||||
} else {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ItemGridView extends BaseGridView {
|
||||
map.put(stack.getId(), stack);
|
||||
} else {
|
||||
if (existing.getStack().getCount() + delta <= 0) {
|
||||
existing.getStack().grow(delta);
|
||||
existing.setZeroed(true);
|
||||
|
||||
map.remove(existing.getId());
|
||||
} else {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.JeiIntegration;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.RSJeiPlugin;
|
||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -23,7 +24,7 @@ public class SearchWidget extends TextFieldWidget {
|
||||
|
||||
this.setEnableBackgroundDrawing(false);
|
||||
this.setVisible(true);
|
||||
this.setTextColor(16777215);
|
||||
this.setTextColor(RenderUtils.DEFAULT_COLOR);
|
||||
}
|
||||
|
||||
public void updateJei() {
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public final class RenderUtils {
|
||||
public static final int DEFAULT_COLOR = 16777215;
|
||||
|
||||
private static final VertexFormat ITEM_FORMAT_WITH_LIGHTMAP = new VertexFormat(DefaultVertexFormats.ITEM).addElement(DefaultVertexFormats.TEX_2S);
|
||||
|
||||
public static String shorten(String text, int length) {
|
||||
|
||||
Reference in New Issue
Block a user