Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| da39d81d5f |
@@ -319,6 +319,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
|||||||
this.searchField.setText(memoryText);
|
this.searchField.setText(memoryText);
|
||||||
this.searchField.selectAll();
|
this.searchField.selectAll();
|
||||||
this.repo.setSearchString(memoryText);
|
this.repo.setSearchString(memoryText);
|
||||||
|
this.repo.updateView();
|
||||||
this.setScrollBar();
|
this.setScrollBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,6 +381,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
|||||||
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
|
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
|
||||||
this.searchField.setText("");
|
this.searchField.setText("");
|
||||||
this.repo.setSearchString("");
|
this.repo.setSearchString("");
|
||||||
|
this.repo.updateView();
|
||||||
this.setScrollBar();
|
this.setScrollBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,6 +476,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
|||||||
|
|
||||||
if (this.searchField.textboxKeyTyped(character, key)) {
|
if (this.searchField.textboxKeyTyped(character, key)) {
|
||||||
this.repo.setSearchString(this.searchField.getText());
|
this.repo.setSearchString(this.searchField.getText());
|
||||||
|
this.repo.updateView();
|
||||||
this.setScrollBar();
|
this.setScrollBar();
|
||||||
// tell forge the key event is handled and should not be sent out
|
// tell forge the key event is handled and should not be sent out
|
||||||
this.keyHandled = mouseInGui;
|
this.keyHandled = mouseInGui;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ import java.util.regex.Pattern;
|
|||||||
public class ItemRepo {
|
public class ItemRepo {
|
||||||
|
|
||||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||||
private List<IAEItemStack> view = new ArrayList<>();
|
private final ArrayList<IAEItemStack> view = new ArrayList<>();
|
||||||
private final IScrollSource src;
|
private final IScrollSource src;
|
||||||
private final ISortSource sortSrc;
|
private final ISortSource sortSrc;
|
||||||
|
|
||||||
@@ -56,16 +56,6 @@ public class ItemRepo {
|
|||||||
private String innerSearch = "";
|
private String innerSearch = "";
|
||||||
private boolean hasPower;
|
private boolean hasPower;
|
||||||
|
|
||||||
private Enum lastView;
|
|
||||||
private Enum lastSearchMode;
|
|
||||||
private Enum lastSortBy;
|
|
||||||
private Enum lastSortDir;
|
|
||||||
private String lastSearch = "";
|
|
||||||
|
|
||||||
private boolean resort = true;
|
|
||||||
private boolean changed = false;
|
|
||||||
|
|
||||||
|
|
||||||
public ItemRepo(final IScrollSource src, final ISortSource sortSrc) {
|
public ItemRepo(final IScrollSource src, final ISortSource sortSrc) {
|
||||||
this.src = src;
|
this.src = src;
|
||||||
this.sortSrc = sortSrc;
|
this.sortSrc = sortSrc;
|
||||||
@@ -93,8 +83,6 @@ public class ItemRepo {
|
|||||||
} else {
|
} else {
|
||||||
this.list.add(is);
|
this.list.add(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getItemCount(final IAEItemStack is) {
|
public long getItemCount(final IAEItemStack is) {
|
||||||
@@ -108,84 +96,18 @@ public class ItemRepo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateView() {
|
public void updateView() {
|
||||||
|
this.view.clear();
|
||||||
|
|
||||||
|
this.view.ensureCapacity(this.list.size());
|
||||||
|
|
||||||
final Enum viewMode = this.sortSrc.getSortDisplay();
|
final Enum viewMode = this.sortSrc.getSortDisplay();
|
||||||
|
|
||||||
if (lastView != viewMode) {
|
|
||||||
resort = true;
|
|
||||||
lastView = viewMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Enum searchMode = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_MODE);
|
final Enum searchMode = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_MODE);
|
||||||
if (lastSearchMode != searchMode) {
|
final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE;
|
||||||
resort = true;
|
|
||||||
lastSearchMode = searchMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH || searchMode == SearchBoxMode.JEI_AUTOSEARCH_KEEP || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP) {
|
if (searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH || searchMode == SearchBoxMode.JEI_AUTOSEARCH_KEEP || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP) {
|
||||||
this.updateJEI(this.searchString);
|
this.updateJEI(this.searchString);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lastSearch.equals(searchString)) {
|
|
||||||
resort = true;
|
|
||||||
lastSearch = searchString;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Enum sortBy = this.sortSrc.getSortBy();
|
|
||||||
final Enum sortDir = this.sortSrc.getSortDir();
|
|
||||||
|
|
||||||
if (lastSortBy != sortBy) {
|
|
||||||
resort = true;
|
|
||||||
lastSortBy = sortBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastSortDir != sortDir) {
|
|
||||||
resort = true;
|
|
||||||
lastSortDir = sortDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed || resort) {
|
|
||||||
changed = false;
|
|
||||||
resort = false;
|
|
||||||
|
|
||||||
view = new ArrayList<>();
|
|
||||||
|
|
||||||
ItemSorters.setDirection((appeng.api.config.SortDir) sortDir);
|
|
||||||
ItemSorters.init();
|
|
||||||
|
|
||||||
Comparator<IAEItemStack> c = getComparator(sortBy);
|
|
||||||
|
|
||||||
for (IAEItemStack is : this.list) {
|
|
||||||
addIAE(is, viewMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
view.sort(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Comparator<IAEItemStack> getComparator(Enum sortBy) {
|
|
||||||
Comparator<IAEItemStack> c;
|
|
||||||
|
|
||||||
if (sortBy == SortOrder.MOD) {
|
|
||||||
c = ItemSorters.CONFIG_BASED_SORT_BY_MOD;
|
|
||||||
} else if (sortBy == SortOrder.AMOUNT) {
|
|
||||||
c = ItemSorters.CONFIG_BASED_SORT_BY_SIZE;
|
|
||||||
} else if (sortBy == SortOrder.INVTWEAKS) {
|
|
||||||
if (InventoryBogoSortModule.isLoaded()) {
|
|
||||||
c = InventoryBogoSortModule.COMPARATOR;
|
|
||||||
} else {
|
|
||||||
c = ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
c = ItemSorters.CONFIG_BASED_SORT_BY_NAME;
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addIAE(IAEItemStack is, Enum viewMode) {
|
|
||||||
|
|
||||||
final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE;
|
|
||||||
|
|
||||||
final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
|
final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
|
||||||
|
|
||||||
boolean searchMod = false;
|
boolean searchMod = false;
|
||||||
@@ -207,52 +129,76 @@ public class ItemRepo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.myPartitionList != null) {
|
boolean notDone = false;
|
||||||
if (!this.myPartitionList.isListed(is)) {
|
for (IAEItemStack is : this.list) {
|
||||||
return;
|
if (this.myPartitionList != null) {
|
||||||
|
if (!this.myPartitionList.isListed(is)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String dspName = (searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is)).toLowerCase();
|
final String dspName = (searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is)).toLowerCase();
|
||||||
boolean foundMatchingItemStack = true;
|
boolean foundMatchingItemStack = true;
|
||||||
|
|
||||||
for (String term : innerSearch.split(" ")) {
|
for (String term : innerSearch.split(" ")) {
|
||||||
if (term.length() > 1 && (term.startsWith("-") || term.startsWith("!"))) {
|
if (term.length() > 1 && (term.startsWith("-") || term.startsWith("!"))) {
|
||||||
term = term.substring(1);
|
term = term.substring(1);
|
||||||
if (dspName.contains(term)) {
|
if (dspName.contains(term)) {
|
||||||
|
foundMatchingItemStack = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (!dspName.contains(term)) {
|
||||||
foundMatchingItemStack = false;
|
foundMatchingItemStack = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (!dspName.contains(term)) {
|
|
||||||
foundMatchingItemStack = false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (terminalSearchToolTips && !foundMatchingItemStack) {
|
if (terminalSearchToolTips && !foundMatchingItemStack) {
|
||||||
final List<String> tooltip = Platform.getTooltip(is);
|
final List<String> tooltip = Platform.getTooltip(is);
|
||||||
for (final String line : tooltip) {
|
for (final String line : tooltip) {
|
||||||
if (m.matcher(line).find()) {
|
if (m.matcher(line).find()) {
|
||||||
foundMatchingItemStack = true;
|
foundMatchingItemStack = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (foundMatchingItemStack) {
|
||||||
|
if (needsZeroCopy) {
|
||||||
|
is = is.copy();
|
||||||
|
is.setStackSize(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.view.add(is);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundMatchingItemStack) {
|
final Enum SortBy = this.sortSrc.getSortBy();
|
||||||
if (needsZeroCopy) {
|
final Enum SortDir = this.sortSrc.getSortDir();
|
||||||
is = is.copy();
|
|
||||||
is.setStackSize(0);
|
ItemSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||||
|
ItemSorters.init();
|
||||||
|
|
||||||
|
if (SortBy == SortOrder.MOD) {
|
||||||
|
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||||
|
} else if (SortBy == SortOrder.AMOUNT) {
|
||||||
|
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||||
|
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||||
|
if (InventoryBogoSortModule.isLoaded()) {
|
||||||
|
Collections.sort(this.view, InventoryBogoSortModule.COMPARATOR);
|
||||||
|
} else {
|
||||||
|
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||||
}
|
}
|
||||||
this.view.add(is);
|
} else {
|
||||||
|
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||||
found = false;
|
found = false;
|
||||||
if (i.isInput() && i.getAllIngredients().size() > 0) {
|
if (i.isInput() && !i.getAllIngredients().isEmpty()) {
|
||||||
List<?> allIngredients = i.getAllIngredients();
|
List<?> allIngredients = i.getAllIngredients();
|
||||||
for (Object allIngredient : allIngredients) {
|
for (Object allIngredient : allIngredients) {
|
||||||
if (allIngredient instanceof ItemStack) {
|
if (allIngredient instanceof ItemStack) {
|
||||||
@@ -66,7 +66,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
||||||
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
||||||
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
||||||
if (fuzzy.size() > 0) {
|
if (!fuzzy.isEmpty()) {
|
||||||
for (IAEItemStack itemStack : fuzzy) {
|
for (IAEItemStack itemStack : fuzzy) {
|
||||||
if (itemStack.getStackSize() > 0) {
|
if (itemStack.getStackSize() > 0) {
|
||||||
if (Platform.isGTDamageableItem(stack.getItem())) {
|
if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||||
@@ -145,7 +145,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||||
found = false;
|
found = false;
|
||||||
craftable = false;
|
craftable = false;
|
||||||
ArrayList<ItemStack> valid = new ArrayList<>();
|
IItemList<IAEItemStack> valid = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||||
if (i.isInput()) {
|
if (i.isInput()) {
|
||||||
List<?> allIngredients = i.getAllIngredients();
|
List<?> allIngredients = i.getAllIngredients();
|
||||||
for (Object allIngredient : allIngredients) {
|
for (Object allIngredient : allIngredients) {
|
||||||
@@ -155,7 +155,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
||||||
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
||||||
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
||||||
if (fuzzy.size() > 0) {
|
if (!fuzzy.isEmpty()) {
|
||||||
for (IAEItemStack itemStack : fuzzy) {
|
for (IAEItemStack itemStack : fuzzy) {
|
||||||
if (itemStack.getStackSize() > 0) {
|
if (itemStack.getStackSize() > 0) {
|
||||||
if (Platform.isGTDamageableItem(stack.getItem())) {
|
if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||||
@@ -165,7 +165,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
}
|
}
|
||||||
found = true;
|
found = true;
|
||||||
used.add(itemStack.copy().setStackSize(1));
|
used.add(itemStack.copy().setStackSize(1));
|
||||||
valid.add(itemStack.copy().setStackSize(1).createItemStack());
|
valid.add(itemStack.copy().setStackSize(1));
|
||||||
} else {
|
} else {
|
||||||
if (itemStack.isCraftable()) {
|
if (itemStack.isCraftable()) {
|
||||||
craftable = true;
|
craftable = true;
|
||||||
@@ -180,12 +180,12 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
if (ext.getStackSize() > 0 && (usedStack == null || usedStack.getStackSize() < ext.getStackSize())) {
|
if (ext.getStackSize() > 0 && (usedStack == null || usedStack.getStackSize() < ext.getStackSize())) {
|
||||||
used.add(ext.copy().setStackSize(1));
|
used.add(ext.copy().setStackSize(1));
|
||||||
if (craftable) {
|
if (craftable) {
|
||||||
valid.clear();
|
valid = null;
|
||||||
}
|
}
|
||||||
valid.add(ext.copy().setStackSize(1).createItemStack());
|
valid.add(ext.copy().setStackSize(1));
|
||||||
found = true;
|
found = true;
|
||||||
} else if (ext.isCraftable()) {
|
} else if (ext.isCraftable()) {
|
||||||
valid.add(ext.copy().setStackSize(1).createItemStack());
|
valid.add(ext.copy().setStackSize(1));
|
||||||
craftable = true;
|
craftable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,21 +195,29 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i.getAllIngredients().size() == 0) {
|
if (i.getAllIngredients().isEmpty()) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
ArrayList<ItemStack> validStacks = new ArrayList<>();
|
||||||
|
if (valid != null) {
|
||||||
|
valid.forEach(v -> {
|
||||||
|
ItemStack validStack = v.createItemStack();
|
||||||
|
validStack.setCount(1);
|
||||||
|
validStacks.add(validStack);
|
||||||
|
});
|
||||||
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (craftable) {
|
if (craftable) {
|
||||||
i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY);
|
i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY);
|
||||||
this.craftableSlots.add(currentSlot);
|
this.craftableSlots.add(currentSlot);
|
||||||
recipeLayout.getItemStacks().set(currentSlot, valid);
|
recipeLayout.getItemStacks().set(currentSlot, validStacks);
|
||||||
} else {
|
} else {
|
||||||
i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY);
|
i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY);
|
||||||
}
|
}
|
||||||
this.errored = true;
|
this.errored = true;
|
||||||
} else {
|
} else {
|
||||||
this.foundSlots.add(currentSlot);
|
this.foundSlots.add(currentSlot);
|
||||||
recipeLayout.getItemStacks().set(currentSlot, valid);
|
recipeLayout.getItemStacks().set(currentSlot, validStacks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentSlot++;
|
currentSlot++;
|
||||||
|
|||||||
Reference in New Issue
Block a user