No Grid sorting when holding shift. (#2349)
* don't sort grid when holding shift and hovering over gridslots or crafting output * fix requested changes add Client Config option
This commit is contained in:
@@ -32,6 +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;
|
||||
|
||||
public Grid() {
|
||||
builder.push("grid");
|
||||
@@ -39,6 +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);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
@@ -54,6 +56,10 @@ public class ClientConfig {
|
||||
public boolean getLargeFont() {
|
||||
return largeFont.get();
|
||||
}
|
||||
|
||||
public boolean getSortGrid() {
|
||||
return sortGrid.get();
|
||||
}
|
||||
}
|
||||
|
||||
public class CrafterManager {
|
||||
|
||||
@@ -55,6 +55,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
private TabListWidget tabs;
|
||||
|
||||
private boolean wasConnected;
|
||||
private boolean doSort;
|
||||
|
||||
private int slotNumber;
|
||||
|
||||
@@ -81,7 +82,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
@Override
|
||||
protected void onPreInit() {
|
||||
super.onPreInit();
|
||||
|
||||
this.doSort = true;
|
||||
this.ySize = getTopHeight() + getBottomHeight() + (getVisibleRows() * 18);
|
||||
}
|
||||
|
||||
@@ -137,7 +138,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
if (!processingPattern.isChecked()) {
|
||||
exactPattern = addCheckBox(processingPattern.x + processingPattern.getWidth() + 5, y + getTopHeight() + (getVisibleRows() * 18) + 60, I18n.format("misc.refinedstorage.exact"), GridTile.EXACT_PATTERN.getValue(), btn -> TileDataManager.setParameter(GridTile.EXACT_PATTERN, exactPattern.isChecked()));
|
||||
}
|
||||
|
||||
|
||||
addSideButton(new TypeSideButton(this, GridTile.PROCESSING_TYPE));
|
||||
}
|
||||
|
||||
@@ -419,7 +420,9 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
if (scrollbar.mouseClicked(mouseX, mouseY, clickedButton)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (RS.CLIENT_CONFIG.getGrid().getSortGrid()) {
|
||||
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);
|
||||
|
||||
@@ -489,6 +492,13 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
return super.mouseClicked(mouseX, mouseY, clickedButton);
|
||||
}
|
||||
|
||||
private boolean isOverCraftingOutputArea(double mouseX, double mouseY) {
|
||||
if (grid.getGridType() != GridType.CRAFTING) {
|
||||
return false;
|
||||
}
|
||||
return RenderUtils.inBounds(130, getTopHeight() + getVisibleRows() * 18 + 18, 24, 24, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(double mx, double my) {
|
||||
scrollbar.mouseMoved(mx, my);
|
||||
@@ -515,6 +525,14 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
return super.charTyped(p_charTyped_1_, p_charTyped_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyReleased(int key, int p_223281_2_, int p_223281_3_) {
|
||||
if (key == GLFW.GLFW_KEY_LEFT_SHIFT || key == GLFW.GLFW_KEY_RIGHT_SHIFT) {
|
||||
view.sort();
|
||||
}
|
||||
return super.keyReleased(key, p_223281_2_, p_223281_3_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int key, int scanCode, int modifiers) {
|
||||
if (key == GLFW.GLFW_KEY_ESCAPE) {
|
||||
@@ -559,4 +577,8 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
public static IGridSorter getDefaultSorter() {
|
||||
return new NameGridSorter();
|
||||
}
|
||||
|
||||
public boolean canSort() {
|
||||
return doSort || !hasShiftDown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ public abstract class BaseGridView implements IGridView {
|
||||
|
||||
@Override
|
||||
public void sort() {
|
||||
if (!screen.canSort()) {
|
||||
return;
|
||||
}
|
||||
List<IGridStack> stacks = new ArrayList<>();
|
||||
|
||||
if (screen.getGrid().isActive()) {
|
||||
|
||||
Reference in New Issue
Block a user