-
Notifications
You must be signed in to change notification settings - Fork 42
Toggle fuzzy for all #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Toggle fuzzy for all #351
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1495,7 +1495,7 @@ public void updateSlotFromSearch(final InventorySetupsSlot slot, boolean allowSt | |
| panel.getCurrentSelectedSetup().getAdditionalFilteredItems(); | ||
| if (!additionalFilteredItemsHasItem(finalId, additionalFilteredItems)) | ||
| { | ||
| removeAdditionalFilteredItem(slot, additionalFilteredItems); | ||
| removeAdditionalFilteredItem(slot); | ||
| addAdditionalFilteredItem(finalId, slot.getParentSetup(), additionalFilteredItems); | ||
| } | ||
| return; | ||
|
|
@@ -1608,14 +1608,18 @@ public void removeItemFromSlot(final InventorySetupsSlot slot) | |
| JOptionPane.ERROR_MESSAGE); | ||
| return; | ||
| } | ||
| if (panel.getCurrentSelectedSetup() == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // must be invoked on client thread to get the name | ||
| clientThread.invokeLater(() -> | ||
| { | ||
|
|
||
| if (slot.getSlotID() == InventorySetupsSlotID.ADDITIONAL_ITEMS) | ||
| { | ||
| removeAdditionalFilteredItem(slot, panel.getCurrentSelectedSetup().getAdditionalFilteredItems()); | ||
| removeAdditionalFilteredItem(slot); | ||
| layoutUtilities.recalculateLayout(panel.getCurrentSelectedSetup()); | ||
| dataManager.updateConfig(true, false); | ||
| panel.refreshCurrentSetup(); | ||
|
|
@@ -1642,58 +1646,70 @@ public void removeItemFromSlot(final InventorySetupsSlot slot) | |
| }); | ||
| } | ||
|
|
||
| public void toggleFuzzyOnSlot(final InventorySetupsSlot slot) | ||
| public void toggleAllFuzzyOnSlot(final InventorySetupsSlot slot) | ||
|
Dragonkiller93 marked this conversation as resolved.
|
||
| { | ||
| if (panel.getCurrentSelectedSetup() == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| InventorySetupsItem item = null; | ||
|
|
||
| final InventorySetup inventorySetup = slot.getParentSetup(); | ||
| InventorySetupsItem originalItem; | ||
| //If an additional slot was clicked | ||
| if (slot.getSlotID() == InventorySetupsSlotID.ADDITIONAL_ITEMS) | ||
| { | ||
| // Empty slot was selected to be toggled, don't do anything | ||
| if (slot.getIndexInSlot() >= slot.getParentSetup().getAdditionalFilteredItems().size()) | ||
| Integer keyToToggle = getAdditionalItemKey(slot); | ||
| if (keyToToggle == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| final Map<Integer, InventorySetupsItem> additionalFilteredItems = slot.getParentSetup().getAdditionalFilteredItems(); | ||
| final int slotID = slot.getIndexInSlot(); | ||
| int j = 0; | ||
| Integer keyToMakeFuzzy = null; | ||
| for (final Integer key : additionalFilteredItems.keySet()) | ||
| { | ||
| if (slotID == j) | ||
| { | ||
| keyToMakeFuzzy = key; | ||
| break; | ||
| } | ||
| j++; | ||
| else{ | ||
|
Dragonkiller93 marked this conversation as resolved.
|
||
| originalItem = inventorySetup.getAdditionalFilteredItems().get(keyToToggle); | ||
| } | ||
| item = additionalFilteredItems.get(keyToMakeFuzzy); | ||
| } | ||
| else | ||
| else{ | ||
|
Dragonkiller93 marked this conversation as resolved.
|
||
| originalItem = getContainerFromSlot(slot).get(slot.getIndexInSlot()); | ||
| } | ||
| if (originalItem.getId() == -1) | ||
| { | ||
| final List<InventorySetupsItem> container = getContainerFromSlot(slot); | ||
| item = container.get(slot.getIndexInSlot()); | ||
| return; | ||
| } | ||
| item.toggleIsFuzzy(); | ||
| final int itemId = item.getId(); | ||
| boolean newFuzzyValue = !originalItem.isFuzzy(); | ||
|
|
||
| //has to be in client to use itemManager | ||
|
Dragonkiller93 marked this conversation as resolved.
|
||
| clientThread.invoke(() -> | ||
| { | ||
| if (itemId == -1) | ||
| //Find all variations of the item, so they can also be toggled | ||
|
Dragonkiller93 marked this conversation as resolved.
|
||
| int processedId = itemManager.canonicalize(originalItem.getId()); | ||
| int baseProcessedId = InventorySetupsVariationMapping.map(processedId); | ||
| Collection<Integer> variations = InventorySetupsVariationMapping.getVariations(baseProcessedId); | ||
| variations.add(processedId); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need to add the processedId here? Shouldn't variations contain it already? |
||
|
|
||
| Consumer<InventorySetupsItem> toggleFuzzyIfMatched = item -> | ||
| { | ||
| return; | ||
| if (variations.contains(item.getId())) | ||
| { | ||
| item.setFuzzy(newFuzzyValue); | ||
| } | ||
| }; | ||
|
|
||
| inventorySetup.getInventory().forEach(toggleFuzzyIfMatched); | ||
|
|
||
|
Dragonkiller93 marked this conversation as resolved.
|
||
| inventorySetup.getEquipment().forEach(toggleFuzzyIfMatched); | ||
| inventorySetup.getAdditionalFilteredItems().values().forEach(toggleFuzzyIfMatched); | ||
|
|
||
|
Dragonkiller93 marked this conversation as resolved.
|
||
| if (inventorySetup.getQuiver() != null) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need to also consider the bolt pouch and rune pouch. The InventorySetup needs a nicer/extendable interface for "Containers" but that's a different problem |
||
| { | ||
| inventorySetup.getQuiver().forEach(toggleFuzzyIfMatched); | ||
| } | ||
|
|
||
| layoutUtilities.recalculateLayout(slot.getParentSetup()); | ||
| dataManager.updateConfig(true, false); | ||
| panel.refreshCurrentSetup(); | ||
| }); | ||
|
|
||
| dataManager.updateConfig(true, false); | ||
| panel.refreshCurrentSetup(); | ||
| } | ||
|
|
||
| } | ||
| public void setStackCompareOnSlot(final InventorySetupsSlot slot, final InventorySetupsStackCompareID newStackCompare) | ||
| { | ||
| if (panel.getCurrentSelectedSetup() == null) | ||
|
|
@@ -1708,32 +1724,45 @@ public void setStackCompareOnSlot(final InventorySetupsSlot slot, final Inventor | |
| panel.refreshCurrentSetup(); | ||
| } | ||
|
|
||
| private void removeAdditionalFilteredItem(final InventorySetupsSlot slot, final Map<Integer, InventorySetupsItem> additionalFilteredItems) | ||
| private Integer getAdditionalItemKey(final InventorySetupsSlot slot) | ||
| { | ||
|
|
||
| assert panel.getCurrentSelectedSetup() != null : "Current setup is null"; | ||
|
|
||
| final int slotID = slot.getIndexInSlot(); | ||
|
|
||
| // Empty slot was selected to be removed, don't do anything | ||
| if (slotID >= additionalFilteredItems.size()) | ||
| final Map<Integer, InventorySetupsItem> additionalFilteredItems = slot.getParentSetup().getAdditionalFilteredItems(); | ||
| // Empty slot was selected to be toggled, don't do anything | ||
| if (slot.getIndexInSlot() >= additionalFilteredItems.size()) | ||
| { | ||
| return; | ||
| return null; | ||
| } | ||
|
|
||
|
|
||
| final int slotID = slot.getIndexInSlot(); | ||
| int j = 0; | ||
| Integer keyToDelete = null; | ||
| Integer keyToMakeFuzzy = null; | ||
| for (final Integer key : additionalFilteredItems.keySet()) | ||
| { | ||
| if (slotID == j) | ||
| { | ||
| keyToDelete = key; | ||
| keyToMakeFuzzy = key; | ||
| break; | ||
| } | ||
| j++; | ||
| } | ||
| return keyToMakeFuzzy; | ||
| } | ||
| private void removeAdditionalFilteredItem(final InventorySetupsSlot slot) | ||
| { | ||
|
|
||
| if (panel.getCurrentSelectedSetup() == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| Integer keyToDelete = getAdditionalItemKey(slot); | ||
| if (keyToDelete == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| additionalFilteredItems.remove(keyToDelete); | ||
| slot.getParentSetup().getAdditionalFilteredItems().remove(keyToDelete); | ||
| // None of the data functions are called here because the callee does it. | ||
| // If an item is swapped (removed + added) this would result in a double data process | ||
| // Which isn't bad, just a minor optimization | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -254,10 +254,9 @@ public static void addFuzzyMouseListenerToSlot(final InventorySetupsPlugin plugi | |
| slot.getRightClickMenu().add(makeSlotFuzzy); | ||
| makeSlotFuzzy.addActionListener(e -> | ||
| { | ||
| plugin.toggleFuzzyOnSlot(slot); | ||
| plugin.toggleAllFuzzyOnSlot(slot); | ||
|
Dragonkiller93 marked this conversation as resolved.
|
||
| }); | ||
| } | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bring back this newline |
||
| // adds the menu option to update set a slot to fuzzy | ||
| public static void addStackMouseListenerToSlot(final InventorySetupsPlugin plugin, final InventorySetupsSlot slot) | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.