mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-24 05:54:27 +00:00
#1014 fuzzy filter option for the advanced item filter
This commit is contained in:
1 parent
f379d7e977
commit
6bd203b8cd
7 files changed
+59
-12
No files matched your search
@@ -1011,6 +1011,12 @@ enderio.gui.conduit.item.roundRobinEnabled=Round Robin Enabled
|
||||
enderio.gui.conduit.item.roundRobinDisabled=Round Robin Disabled
|
||||
enderio.gui.conduit.item.priority=Priority
|
||||
|
||||
enderio.gui.conduit.item.fuzzy.disabled=Fuzzy Mode disabled
|
||||
enderio.gui.conduit.item.fuzzy.fuzzy_25=Fuzzy match for 25% damage
|
||||
enderio.gui.conduit.item.fuzzy.fuzzy_50=Fuzzy match for 50% damage
|
||||
enderio.gui.conduit.item.fuzzy.fuzzy_75=Fuzzy match for 75% damage
|
||||
enderio.gui.conduit.item.fuzzy.fuzzy_99=Fuzzy match for any damage
|
||||
|
||||
enderio.gui.conduit.item.filterupgrade=Insert Item Filter
|
||||
enderio.gui.conduit.item.speedupgrade=Insert Item Conduit Speed Upgrades/Downgrade
|
||||
enderio.gui.conduit.item.speedupgrade2=Max upgrades is 15; Max downgrades is 1
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 25 KiB |
@@ -11,6 +11,7 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -224,4 +225,10 @@ public class GuiExternalConnection extends GuiContainerBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawFakeItemStack(int x, int y, ItemStack stack) {
|
||||
super.drawFakeItemStack(x, y, stack);
|
||||
itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, stack, x, y, "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,12 +5,14 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.enderio.core.client.gui.GuiContainerBase;
|
||||
import com.enderio.core.client.gui.button.CycleButton;
|
||||
import com.enderio.core.client.gui.button.IconButton;
|
||||
import com.enderio.core.client.gui.button.ToggleButton;
|
||||
import com.enderio.core.client.render.RenderUtil;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.gui.GuiExternalConnection;
|
||||
import crazypants.enderio.conduit.item.filter.FuzzyMode;
|
||||
import crazypants.enderio.conduit.item.filter.ItemFilter;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
|
||||
@@ -21,6 +23,7 @@ public class BasicItemFilterGui implements IItemFilterGui {
|
||||
private static final int ID_META = GuiExternalConnection.nextButtonId();
|
||||
private static final int ID_ORE_DICT = GuiExternalConnection.nextButtonId();
|
||||
private static final int ID_STICKY = GuiExternalConnection.nextButtonId();
|
||||
private static final int ID_FUZZY = GuiExternalConnection.nextButtonId();
|
||||
|
||||
private final GuiContainerBase gui;
|
||||
|
||||
@@ -29,6 +32,7 @@ public class BasicItemFilterGui implements IItemFilterGui {
|
||||
private final IconButton whiteListB;
|
||||
private final ToggleButton useOreDictB;
|
||||
private final ToggleButton stickyB;
|
||||
private final CycleButton<FuzzyMode> fuzzyB;
|
||||
|
||||
final boolean isAdvanced;
|
||||
final boolean isStickyModeAvailable;
|
||||
@@ -71,25 +75,26 @@ public class BasicItemFilterGui implements IItemFilterGui {
|
||||
|
||||
x += 20;
|
||||
stickyB = new ToggleButton(gui, ID_STICKY + buttonIdOffset, x, y, IconEIO.FILTER_STICKY_OFF, IconEIO.FILTER_STICKY);
|
||||
String[] lines = EnderIO.lang.localizeList("gui.conduit.item.stickyEnabled");
|
||||
stickyB.setSelectedToolTip(lines);
|
||||
stickyB.setSelectedToolTip(EnderIO.lang.localizeList("gui.conduit.item.stickyEnabled"));
|
||||
stickyB.setUnselectedToolTip(EnderIO.lang.localize("gui.conduit.item.stickyDisbaled"));
|
||||
stickyB.setPaintSelectedBorder(false);
|
||||
|
||||
y += 20;
|
||||
x = butLeft;
|
||||
|
||||
useOreDictB = new ToggleButton(gui, ID_ORE_DICT + buttonIdOffset, x, y, IconEIO.FILTER_ORE_DICT_OFF, IconEIO.FILTER_ORE_DICT);
|
||||
useOreDictB.setSelectedToolTip(EnderIO.lang.localize("gui.conduit.item.oreDicEnabled"));
|
||||
useOreDictB.setUnselectedToolTip(EnderIO.lang.localize("gui.conduit.item.oreDicDisabled"));
|
||||
useOreDictB.setPaintSelectedBorder(false);
|
||||
|
||||
x += 20;
|
||||
useNbtB = new ToggleButton(gui, ID_NBT + buttonIdOffset, x, y, IconEIO.FILTER_NBT_OFF, IconEIO.FILTER_NBT);
|
||||
useNbtB.setSelectedToolTip(EnderIO.lang.localize("gui.conduit.item.matchNBT"));
|
||||
useNbtB.setUnselectedToolTip(EnderIO.lang.localize("gui.conduit.item.ignoreNBT"));
|
||||
useNbtB.setPaintSelectedBorder(false);
|
||||
|
||||
x = butLeft;
|
||||
useOreDictB = new ToggleButton(gui, ID_ORE_DICT + buttonIdOffset, x, y, IconEIO.FILTER_ORE_DICT_OFF, IconEIO.FILTER_ORE_DICT);
|
||||
useOreDictB.setSelectedToolTip(EnderIO.lang.localize("gui.conduit.item.oreDicEnabled"));
|
||||
useOreDictB.setUnselectedToolTip(EnderIO.lang.localize("gui.conduit.item.oreDicDisabled"));
|
||||
useOreDictB.setPaintSelectedBorder(false);
|
||||
x += 20;
|
||||
fuzzyB = new CycleButton(gui, ID_FUZZY + buttonIdOffset, x, y, FuzzyMode.class);
|
||||
}
|
||||
|
||||
public void createFilterSlots() {
|
||||
@@ -100,7 +105,7 @@ public class BasicItemFilterGui implements IItemFilterGui {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int x, int y, int par3) {
|
||||
}
|
||||
@@ -120,6 +125,9 @@ public class BasicItemFilterGui implements IItemFilterGui {
|
||||
stickyB.onGuiInit();
|
||||
stickyB.setSelected(activeFilter.isSticky());
|
||||
}
|
||||
|
||||
fuzzyB.onGuiInit();
|
||||
fuzzyB.setMode(activeFilter.getFuzzyMode());
|
||||
}
|
||||
|
||||
useMetaB.onGuiInit();
|
||||
@@ -151,6 +159,9 @@ public class BasicItemFilterGui implements IItemFilterGui {
|
||||
} else if(guiButton.id == ID_ORE_DICT + buttonIdOffset) {
|
||||
filter.setUseOreDict(useOreDictB.isSelected());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_FUZZY + buttonIdOffset) {
|
||||
filter.setFuzzyMode(fuzzyB.getMode());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_WHITELIST + buttonIdOffset) {
|
||||
filter.setBlacklist(!filter.isBlacklist());
|
||||
sendFilterChange();
|
||||
@@ -169,6 +180,7 @@ public class BasicItemFilterGui implements IItemFilterGui {
|
||||
useOreDictB.detach();
|
||||
whiteListB.detach();
|
||||
stickyB.detach();
|
||||
fuzzyB.detach();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -170,9 +170,7 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
|
||||
x = priLeft + priWidth + 9;
|
||||
priUpB = MultiIconButton.createAddButton(gui, ID_PRIORITY_UP, x, y);
|
||||
|
||||
y += 8;
|
||||
priDownB = MultiIconButton.createMinusButton(gui, ID_PRIORITY_DOWN, x, y);
|
||||
priDownB = MultiIconButton.createMinusButton(gui, ID_PRIORITY_DOWN, x, y+8);
|
||||
|
||||
gui.getContainer().addFilterListener(new FilterChangeListener() {
|
||||
@Override
|
||||
|
||||
@@ -36,6 +36,7 @@ public class ItemFilter implements IInventory, IItemFilter {
|
||||
boolean matchNBT = true;
|
||||
boolean useOreDict = false;
|
||||
boolean sticky = false;
|
||||
FuzzyMode fuzzyMode = FuzzyMode.DISABLED;
|
||||
|
||||
ItemStack[] items;
|
||||
|
||||
@@ -82,12 +83,19 @@ public class ItemFilter implements IInventory, IItemFilter {
|
||||
if(item == null) {
|
||||
return false;
|
||||
}
|
||||
boolean doFuzzy = false;
|
||||
boolean fuzzyValue = false;
|
||||
if(fuzzyMode != FuzzyMode.DISABLED && item.getItem().isDamageable()) {
|
||||
doFuzzy = true;
|
||||
fuzzyValue = fuzzyMode.compare(item);
|
||||
}
|
||||
boolean matched = false;
|
||||
int i = 0;
|
||||
for (ItemStack it : items) {
|
||||
if(it != null && Item.getIdFromItem(item.getItem()) == Item.getIdFromItem(it.getItem())) {
|
||||
matched = true;
|
||||
if(matchMeta && item.getItemDamage() != it.getItemDamage()) {
|
||||
boolean fuzzyOk = doFuzzy && fuzzyMode.compare(it) == fuzzyValue;
|
||||
if(matchMeta && !fuzzyOk && item.getItemDamage() != it.getItemDamage()) {
|
||||
matched = false;
|
||||
} else if(matchNBT && !isNBTMatch(item, it)) {
|
||||
matched = false;
|
||||
@@ -203,6 +211,14 @@ public class ItemFilter implements IInventory, IItemFilter {
|
||||
this.sticky = sticky;
|
||||
}
|
||||
|
||||
public FuzzyMode getFuzzyMode() {
|
||||
return fuzzyMode;
|
||||
}
|
||||
|
||||
public void setFuzzyMode(FuzzyMode fuzzyMode) {
|
||||
this.fuzzyMode = fuzzyMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtRoot) {
|
||||
nbtRoot.setBoolean("isBlacklist", isBlacklist);
|
||||
@@ -211,6 +227,7 @@ public class ItemFilter implements IInventory, IItemFilter {
|
||||
nbtRoot.setBoolean("useOreDict", useOreDict);
|
||||
nbtRoot.setBoolean("sticky", sticky);
|
||||
nbtRoot.setBoolean("isAdvanced", isAdvanced);
|
||||
nbtRoot.setByte("fuzzyMode", (byte) fuzzyMode.ordinal());
|
||||
|
||||
int i = 0;
|
||||
for (ItemStack item : items) {
|
||||
@@ -232,6 +249,7 @@ public class ItemFilter implements IInventory, IItemFilter {
|
||||
useOreDict = nbtRoot.getBoolean("useOreDict");
|
||||
sticky = nbtRoot.getBoolean("sticky");
|
||||
isAdvanced = nbtRoot.getBoolean("isAdvanced");
|
||||
fuzzyMode = FuzzyMode.values()[nbtRoot.getByte("fuzzyMode") & 255];
|
||||
|
||||
int numItems = isAdvanced ? 10 : 5;
|
||||
items = new ItemStack[numItems];
|
||||
|
||||
@@ -60,6 +60,12 @@ public enum IconEIO implements IWidgetIcon {
|
||||
FILTER_NBT_OFF(224, 224),
|
||||
FILTER_ORE_DICT_OFF(240, 224),
|
||||
|
||||
FILTER_FUZZY_DISABLED(240, 176),
|
||||
FILTER_FUZZY_25(224, 176),
|
||||
FILTER_FUZZY_50(208, 176),
|
||||
FILTER_FUZZY_75(192, 176),
|
||||
FILTER_FUZZY_99(176, 176),
|
||||
|
||||
@Deprecated
|
||||
INPUT_OLD(128, 197 + 32, 30, 14),
|
||||
@Deprecated
|
||||
|
||||
Reference in new issue
Block a user