You can now use up and down arrows to scroll through Grid search history
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
- Fixed oredict not working (raoulvdberge)
|
- Fixed oredict not working (raoulvdberge)
|
||||||
- You can now shift click Grid Filters into a Grid instead of manually inserting them (raoulvdberge)
|
- You can now shift click Grid Filters into a Grid instead of manually inserting them (raoulvdberge)
|
||||||
- The Solderer inventory isn't sided anymore (raoulvdberge)
|
- The Solderer inventory isn't sided anymore (raoulvdberge)
|
||||||
|
- You can now use up and down arrows to scroll through Grid search history (raoulvdberge)
|
||||||
|
|
||||||
### 1.4.2
|
### 1.4.2
|
||||||
- Updated Forge to 2261 (raoulvdberge)
|
- Updated Forge to 2261 (raoulvdberge)
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
private static final GridSorting SORTING_NAME = new GridSortingName();
|
private static final GridSorting SORTING_NAME = new GridSortingName();
|
||||||
private static final GridSorting SORTING_ID = new GridSortingID();
|
private static final GridSorting SORTING_ID = new GridSortingID();
|
||||||
|
|
||||||
|
private static final List<String> SEARCH_HISTORY = new ArrayList<>();
|
||||||
|
|
||||||
public static final ListMultimap<Item, GridStackItem> ITEMS = Multimaps.synchronizedListMultimap(ArrayListMultimap.create());
|
public static final ListMultimap<Item, GridStackItem> ITEMS = Multimaps.synchronizedListMultimap(ArrayListMultimap.create());
|
||||||
public static final ListMultimap<Fluid, GridStackFluid> FLUIDS = Multimaps.synchronizedListMultimap(ArrayListMultimap.create());
|
public static final ListMultimap<Fluid, GridStackFluid> FLUIDS = Multimaps.synchronizedListMultimap(ArrayListMultimap.create());
|
||||||
|
|
||||||
@@ -72,6 +74,8 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
|
|
||||||
private int slotNumber;
|
private int slotNumber;
|
||||||
|
|
||||||
|
private int searchHistory = -1;
|
||||||
|
|
||||||
private Deque<Integer> konami = new ArrayDeque<>(Arrays.asList(
|
private Deque<Integer> konami = new ArrayDeque<>(Arrays.asList(
|
||||||
Keyboard.KEY_UP,
|
Keyboard.KEY_UP,
|
||||||
Keyboard.KEY_UP,
|
Keyboard.KEY_UP,
|
||||||
@@ -502,6 +506,8 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException {
|
public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException {
|
||||||
super.mouseClicked(mouseX, mouseY, clickedButton);
|
super.mouseClicked(mouseX, mouseY, clickedButton);
|
||||||
|
|
||||||
|
boolean wasSearchFieldFocused = searchField.isFocused();
|
||||||
|
|
||||||
searchField.mouseClicked(mouseX, mouseY, clickedButton);
|
searchField.mouseClicked(mouseX, mouseY, clickedButton);
|
||||||
|
|
||||||
if (tabHovering >= 0 && tabHovering < grid.getTabs().size()) {
|
if (tabHovering >= 0 && tabHovering < grid.getTabs().size()) {
|
||||||
@@ -515,6 +521,8 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
sortItems();
|
sortItems();
|
||||||
|
|
||||||
updateJEI();
|
updateJEI();
|
||||||
|
} else if (wasSearchFieldFocused != searchField.isFocused()) {
|
||||||
|
saveHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean clickedClear = clickedButton == 0 && isOverClear(mouseX - guiLeft, mouseY - guiTop);
|
boolean clickedClear = clickedButton == 0 && isOverClear(mouseX - guiLeft, mouseY - guiTop);
|
||||||
@@ -581,13 +589,67 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
updateJEI();
|
updateJEI();
|
||||||
|
|
||||||
sortItems();
|
sortItems();
|
||||||
|
} else if (searchField.isFocused() && (keyCode == Keyboard.KEY_UP || keyCode == Keyboard.KEY_DOWN || keyCode == Keyboard.KEY_RETURN)) {
|
||||||
|
if (keyCode == Keyboard.KEY_UP) {
|
||||||
|
updateSearchHistory(-1);
|
||||||
|
} else if (keyCode == Keyboard.KEY_DOWN) {
|
||||||
|
updateSearchHistory(1);
|
||||||
|
} else {
|
||||||
|
saveHistory();
|
||||||
|
|
||||||
|
if (grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL || grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED) {
|
||||||
|
searchField.setFocused(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (keyCode == RSKeyBindings.FOCUS_SEARCH_BAR.getKeyCode() && (grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL || grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED)) {
|
} else if (keyCode == RSKeyBindings.FOCUS_SEARCH_BAR.getKeyCode() && (grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL || grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED)) {
|
||||||
searchField.setFocused(!searchField.isFocused());
|
searchField.setFocused(!searchField.isFocused());
|
||||||
|
|
||||||
|
saveHistory();
|
||||||
} else {
|
} else {
|
||||||
super.keyTyped(character, keyCode);
|
super.keyTyped(character, keyCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSearchHistory(int delta) {
|
||||||
|
if (searchHistory == -1) {
|
||||||
|
searchHistory = SEARCH_HISTORY.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
searchHistory += delta;
|
||||||
|
|
||||||
|
if (searchHistory < 0) {
|
||||||
|
searchHistory = 0;
|
||||||
|
} else if (searchHistory > SEARCH_HISTORY.size() - 1) {
|
||||||
|
searchHistory = SEARCH_HISTORY.size() - 1;
|
||||||
|
|
||||||
|
if (delta == 1) {
|
||||||
|
searchField.setText("");
|
||||||
|
|
||||||
|
sortItems();
|
||||||
|
|
||||||
|
updateJEI();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
searchField.setText(SEARCH_HISTORY.get(searchHistory));
|
||||||
|
|
||||||
|
sortItems();
|
||||||
|
|
||||||
|
updateJEI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveHistory() {
|
||||||
|
if (!SEARCH_HISTORY.isEmpty() && SEARCH_HISTORY.get(SEARCH_HISTORY.size() - 1).equals(searchField.getText())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!searchField.getText().trim().isEmpty()) {
|
||||||
|
SEARCH_HISTORY.add(searchField.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateJEI() {
|
private void updateJEI() {
|
||||||
if (IntegrationJEI.isLoaded() && (grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED || grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED)) {
|
if (IntegrationJEI.isLoaded() && (grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED || grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED)) {
|
||||||
RSJEIPlugin.INSTANCE.getRuntime().getItemListOverlay().setFilterText(searchField.getText());
|
RSJEIPlugin.INSTANCE.getRuntime().getItemListOverlay().setFilterText(searchField.getText());
|
||||||
|
|||||||
Reference in New Issue
Block a user