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:
Darkere
2019-11-11 09:08:42 +01:00
committed by Raoul
parent 7bd8dd3900
commit c53ca4d546
4 changed files with 35 additions and 3 deletions

View File

@@ -5,6 +5,7 @@
- The Pattern Grid now switches automatically between crafting pattern and processing pattern mode when using JEI transfer (raoulvdberge) - The Pattern Grid now switches automatically between crafting pattern and processing pattern mode when using JEI transfer (raoulvdberge)
- The Pattern Grid now switches automatically between crafting pattern and processing pattern mode when re-inserting an existing Pattern (raoulvdberge) - The Pattern Grid now switches automatically between crafting pattern and processing pattern mode when re-inserting an existing Pattern (raoulvdberge)
- Removed migration code for the development builds that were released on Discord (not on CurseForge). If you used the development builds and never used version 1.7 before, first switch to 1.7, open your world, modify a storage disk, and then upgrade to 1.7.1 (raoulvdberge) - Removed migration code for the development builds that were released on Discord (not on CurseForge). If you used the development builds and never used version 1.7 before, first switch to 1.7, open your world, modify a storage disk, and then upgrade to 1.7.1 (raoulvdberge)
- Grids now do not sort if you interact with it while holding shift (Darkere)
### 1.7 ### 1.7
NOTE: This is an alpha release. Bugs may happen. Remember to take backups. NOTE: This is an alpha release. Bugs may happen. Remember to take backups.

View File

@@ -32,6 +32,7 @@ public class ClientConfig {
private final ForgeConfigSpec.IntValue maxRowsStretch; private final ForgeConfigSpec.IntValue maxRowsStretch;
private final ForgeConfigSpec.BooleanValue detailedTooltip; private final ForgeConfigSpec.BooleanValue detailedTooltip;
private final ForgeConfigSpec.BooleanValue largeFont; private final ForgeConfigSpec.BooleanValue largeFont;
private final ForgeConfigSpec.BooleanValue sortGrid;
public Grid() { public Grid() {
builder.push("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); 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); 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); 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(); builder.pop();
} }
@@ -54,6 +56,10 @@ public class ClientConfig {
public boolean getLargeFont() { public boolean getLargeFont() {
return largeFont.get(); return largeFont.get();
} }
public boolean getSortGrid() {
return sortGrid.get();
}
} }
public class CrafterManager { public class CrafterManager {

View File

@@ -55,6 +55,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
private TabListWidget tabs; private TabListWidget tabs;
private boolean wasConnected; private boolean wasConnected;
private boolean doSort;
private int slotNumber; private int slotNumber;
@@ -81,7 +82,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
@Override @Override
protected void onPreInit() { protected void onPreInit() {
super.onPreInit(); super.onPreInit();
this.doSort = true;
this.ySize = getTopHeight() + getBottomHeight() + (getVisibleRows() * 18); this.ySize = getTopHeight() + getBottomHeight() + (getVisibleRows() * 18);
} }
@@ -419,7 +420,9 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
if (scrollbar.mouseClicked(mouseX, mouseY, clickedButton)) { if (scrollbar.mouseClicked(mouseX, mouseY, clickedButton)) {
return true; 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 clickedClear = clickedButton == 0 && isOverClear(mouseX - guiLeft, mouseY - guiTop);
boolean clickedCreatePattern = clickedButton == 0 && isOverCreatePattern(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); 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 @Override
public void mouseMoved(double mx, double my) { public void mouseMoved(double mx, double my) {
scrollbar.mouseMoved(mx, 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_); 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 @Override
public boolean keyPressed(int key, int scanCode, int modifiers) { public boolean keyPressed(int key, int scanCode, int modifiers) {
if (key == GLFW.GLFW_KEY_ESCAPE) { if (key == GLFW.GLFW_KEY_ESCAPE) {
@@ -559,4 +577,8 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
public static IGridSorter getDefaultSorter() { public static IGridSorter getDefaultSorter() {
return new NameGridSorter(); return new NameGridSorter();
} }
public boolean canSort() {
return doSort || !hasShiftDown();
}
} }

View File

@@ -40,6 +40,9 @@ public abstract class BaseGridView implements IGridView {
@Override @Override
public void sort() { public void sort() {
if (!screen.canSort()) {
return;
}
List<IGridStack> stacks = new ArrayList<>(); List<IGridStack> stacks = new ArrayList<>();
if (screen.getGrid().isActive()) { if (screen.getGrid().isActive()) {