diff options
| author | DoKM <mcazzyman@gmail.com> | 2021-07-22 09:57:31 +0200 |
|---|---|---|
| committer | DoKM <mcazzyman@gmail.com> | 2021-07-22 09:57:31 +0200 |
| commit | befa3f0f8aeb0166bf84dddd14f6b4fabc236cf0 (patch) | |
| tree | 4ef5014cf74f57ef52fa2650703de7b8f1153f6c /src/main/java/io/github/moulberry/notenoughupdates/miscgui | |
| parent | aebc16a2a5ca9c20affc27eb5a45cd9a95085168 (diff) | |
| parent | c1c4562b42d53ec2e8885c48f97249d7768fe1c7 (diff) | |
| download | notenoughupdates-befa3f0f8aeb0166bf84dddd14f6b4fabc236cf0.tar.gz notenoughupdates-befa3f0f8aeb0166bf84dddd14f6b4fabc236cf0.tar.bz2 notenoughupdates-befa3f0f8aeb0166bf84dddd14f6b4fabc236cf0.zip | |
Fix merge conflicts for moulberry
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui')
3 files changed, 63 insertions, 58 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java index d07a6898..3cc42d7d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java @@ -10,6 +10,7 @@ import io.github.moulberry.notenoughupdates.core.GuiElementTextField; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingFloat; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; +import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -198,11 +199,8 @@ public class GuiCustomEnchant extends Gui { } public boolean shouldOverride(String containerName) { - if(!NotEnoughUpdates.INSTANCE.config.enchanting.enableGui) return false; -// shouldOverrideFast = false; -// if(true) return shouldOverrideFast; - - shouldOverrideFast = containerName != null && + shouldOverrideFast = NotEnoughUpdates.INSTANCE.config.enchanting.enableTableGUI && + containerName != null && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && containerName.equalsIgnoreCase("Enchant Item"); if(!shouldOverrideFast) { @@ -467,8 +465,13 @@ public class GuiCustomEnchant extends Gui { } } } - removable.sort(Comparator.comparingInt(e -> e.xpCost)); - applicable.sort(Comparator.comparingInt(e -> e.xpCost)); + NEUConfig cfg = NotEnoughUpdates.INSTANCE.config; + int mult = cfg.enchanting.enchantOrdering == 0 ? 1 : -1; + Comparator<Enchantment> comparator = cfg.enchanting.enchantSorting == 0 ? + Comparator.comparingInt(e -> mult*e.xpCost) : + (c1, c2) -> mult*c1.enchId.toLowerCase().compareTo(c2.enchId.toLowerCase()); + removable.sort(comparator); + applicable.sort(comparator); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java index c1a7ec6d..d24f2572 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java @@ -30,7 +30,6 @@ public class InventoryStorageSelector { private static final ResourceLocation STORAGE_PANE_CTM_TEXTURE = new ResourceLocation("notenoughupdates:storage_gui/storage_gui_pane_ctm.png"); public boolean isOverridingSlot = false; - public int selectedIndex = 0; public static InventoryStorageSelector getInstance() { return INSTANCE; @@ -65,19 +64,19 @@ public class InventoryStorageSelector { } if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) { - selectedIndex--; + NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex--; int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1; - if(selectedIndex > max) selectedIndex = max; - if(selectedIndex < 0) selectedIndex = 0; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0; } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowRightKey)) { - selectedIndex++; + NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex++; int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1; - if(selectedIndex > max) selectedIndex = max; - if(selectedIndex < 0) selectedIndex = 0; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0; } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowDownKey)) { - sendToPage(selectedIndex); + sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex); } if(isSlotSelected()) { @@ -87,7 +86,7 @@ public class InventoryStorageSelector { if(Mouse.getEventButton() == useKeycode || Mouse.getEventButton() == attackKeycode) { if(Mouse.getEventButtonState() && Mouse.getEventButton() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey+100) { - sendToPage(selectedIndex); + sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex); } event.setCanceled(true); @@ -99,10 +98,10 @@ public class InventoryStorageSelector { if(!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(displayId)) { return; } - if(getPage(selectedIndex) == null) { + if(getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex) == null) { NotEnoughUpdates.INSTANCE.sendChatMessage("/storage"); } else { - int index = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(selectedIndex); + int index = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex); StorageManager.getInstance().sendToPage(index); } } @@ -120,25 +119,23 @@ public class InventoryStorageSelector { return; } - if(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowKeyBackpacks) { - if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotkey)) { - Minecraft.getMinecraft().thePlayer.inventory.currentItem = 0; - isOverridingSlot = true; - } else if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) { - selectedIndex--; - - int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size() - 1; - if (selectedIndex > max) selectedIndex = max; - if (selectedIndex < 0) selectedIndex = 0; - } else if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowRightKey)) { - selectedIndex++; - - int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size() - 1; - if (selectedIndex > max) selectedIndex = max; - if (selectedIndex < 0) selectedIndex = 0; - } else if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowDownKey)) { - sendToPage(selectedIndex); - } + if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotkey)) { + Minecraft.getMinecraft().thePlayer.inventory.currentItem = 0; + isOverridingSlot = true; + } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) { + NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex--; + + int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0; + } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowRightKey)) { + NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex++; + + int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0; + } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowDownKey)) { + sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex); } if(isSlotSelected()) { @@ -147,7 +144,7 @@ public class InventoryStorageSelector { if(attack.isPressed() || attack.isKeyDown()) { if(attack.getKeyCode() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) { - sendToPage(selectedIndex); + sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex); } KeyBinding.setKeyBindState(attack.getKeyCode(), false); @@ -156,7 +153,7 @@ public class InventoryStorageSelector { if(use.isPressed() || use.isKeyDown()) { if(attack.getKeyCode() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) { - sendToPage(selectedIndex); + sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex); } KeyBinding.setKeyBindState(use.getKeyCode(), false); @@ -175,16 +172,19 @@ public class InventoryStorageSelector { int keyCode = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey; if(isOverridingSlot && KeybindHelper.isKeyDown(keyCode)) { - selectedIndex -= direction; + NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex -= direction; int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1; - if(selectedIndex > max) selectedIndex = max; - if(selectedIndex < 0) selectedIndex = 0; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0; return 0; } - if(NotEnoughUpdates.INSTANCE.config.storageGUI.scrollToBackpack && - resultantSlot == 0 && direction == -1 && !isOverridingSlot) { + boolean allowScroll = NotEnoughUpdates.INSTANCE.config.storageGUI.scrollToBackpack2 == 0 ? + KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) : + NotEnoughUpdates.INSTANCE.config.storageGUI.scrollToBackpack2 == 1; + + if(allowScroll && resultantSlot == 0 && direction == -1 && !isOverridingSlot) { isOverridingSlot = true; Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress(); return 0; @@ -192,8 +192,7 @@ public class InventoryStorageSelector { isOverridingSlot = false; Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress(); return 0; - } else if(NotEnoughUpdates.INSTANCE.config.storageGUI.scrollToBackpack && - resultantSlot == 8 && direction == 1 && !isOverridingSlot) { + } else if(allowScroll && resultantSlot == 8 && direction == 1 && !isOverridingSlot) { isOverridingSlot = true; Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress(); return 0; @@ -210,7 +209,7 @@ public class InventoryStorageSelector { } public ItemStack getNamedHeldItemOverride() { - StorageManager.StoragePage page = getPage(selectedIndex); + StorageManager.StoragePage page = getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex); if(page != null && page.backpackDisplayStack != null) { return page.backpackDisplayStack; } @@ -218,7 +217,7 @@ public class InventoryStorageSelector { } public ItemStack getHeldItemOverride() { - return getHeldItemOverride(selectedIndex); + return getHeldItemOverride(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex); } public ItemStack getHeldItemOverride(int selectedIndex) { @@ -242,8 +241,8 @@ public class InventoryStorageSelector { } int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1; - if(selectedIndex > max) selectedIndex = max; - if(selectedIndex < 0) selectedIndex = 0; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max; + if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0; int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); @@ -261,7 +260,7 @@ public class InventoryStorageSelector { int top = scaledResolution.getScaledHeight() - 22; if(NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpackPreview && isSlotSelected()) { - StorageManager.StoragePage page = getPage(selectedIndex); + StorageManager.StoragePage page = getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex); if(page != null && page.rows > 0) { int rows = page.rows; @@ -430,8 +429,8 @@ public class InventoryStorageSelector { } int index = 1; - if(StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(selectedIndex)) { - int displayIndex = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(selectedIndex); + if(StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex)) { + int displayIndex = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex); if(displayIndex < 9) { index = displayIndex+1; } else { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java index 2dd0fbd1..e525117c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java @@ -118,6 +118,7 @@ public class StorageOverlay extends GuiElement { private int desiredHeightMY = -1; private boolean dirty = false; + private boolean allowTypingInSearchBar = true; private int scrollGrabOffset = -1; @@ -1238,6 +1239,7 @@ public class StorageOverlay extends GuiElement { GlStateManager.popMatrix(); GlStateManager.translate(0, 0, 300); + allowTypingInSearchBar = false; if(stackOnMouse != null) { if(hoveringOtherBackpack) { Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.barrier)), mouseX - 8, mouseY - 8); @@ -1277,6 +1279,8 @@ public class StorageOverlay extends GuiElement { } } else if(tooltipToDisplay != null) { Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj); + } else { + allowTypingInSearchBar = true; } GlStateManager.translate(0, 0, -300); } @@ -1440,9 +1444,8 @@ public class StorageOverlay extends GuiElement { if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return false; int dWheel = Mouse.getEventDWheel(); - if(dWheel != 0 && - (((NotEnoughUpdates.INSTANCE.config.storageGUI.scrollLock == 0)|| - (NotEnoughUpdates.INSTANCE.config.storageGUI.scrollLock == 1 && !KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.slotLockKey))))) { + if(!(NotEnoughUpdates.INSTANCE.config.storageGUI.cancelScrollKey != 0 && + Keyboard.isKeyDown(NotEnoughUpdates.INSTANCE.config.storageGUI.cancelScrollKey)) && dWheel != 0) { if(dWheel < 0) { dWheel = -1; if(scrollVelocity > 0) scrollVelocity = 0; @@ -1636,7 +1639,7 @@ public class StorageOverlay extends GuiElement { switch(buttonIndex) { case 0: - NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI = false; break; + NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI2 = false; break; case 1: int size = desiredHeightSwitch != -1 ? desiredHeightSwitch : NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight; int sizeIndex = Math.round((size-104)/54f); @@ -1882,7 +1885,7 @@ public class StorageOverlay extends GuiElement { page.customTitle = renameStorageField.getText(); } } - } else if(NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus || searchBar.getFocus()) { + } else if(searchBar.getFocus() || (allowTypingInSearchBar && NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus)) { String prevText = searchBar.getText(); searchBar.setFocus(true); renameStorageField.setFocus(false); |
