item identification: clean up config enabled checks

This commit is contained in:
Adam
2021-07-14 22:52:51 -04:00
committed by Adam
parent af07d895c1
commit 845ca463d5
2 changed files with 20 additions and 103 deletions

View File

@@ -26,6 +26,8 @@ package net.runelite.client.plugins.itemidentification;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import java.util.function.Predicate;
import lombok.AllArgsConstructor;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
enum ItemIdentification enum ItemIdentification
@@ -419,21 +421,24 @@ enum ItemIdentification
return itemIdentifications.get(id); return itemIdentifications.get(id);
} }
@AllArgsConstructor
enum Type enum Type
{ {
SEED, SEED(ItemIdentificationConfig::showSeeds),
SACK, SACK(ItemIdentificationConfig::showSacks),
HERB, HERB(ItemIdentificationConfig::showHerbs),
LOGS, LOGS(ItemIdentificationConfig::showLogs),
PLANK, PLANK(ItemIdentificationConfig::showPlanks),
SAPLING, SAPLING(ItemIdentificationConfig::showSaplings),
COMPOST, COMPOST(ItemIdentificationConfig::showComposts),
ORE, ORE(ItemIdentificationConfig::showOres),
BAR, BAR(ItemIdentificationConfig::showBars),
GEM, GEM(ItemIdentificationConfig::showGems),
POTION, POTION(ItemIdentificationConfig::showPotions),
IMPLING_JAR, IMPLING_JAR(ItemIdentificationConfig::showImplingJars),
TABLET, TABLET(ItemIdentificationConfig::showTablets),
SCROLL SCROLL(ItemIdentificationConfig::showTeleportScrolls);
final Predicate<ItemIdentificationConfig> enabled;
} }
} }

View File

@@ -58,99 +58,11 @@ class ItemIdentificationOverlay extends WidgetItemOverlay
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem widgetItem) public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem widgetItem)
{ {
ItemIdentification iden = findItemIdentification(itemId); ItemIdentification iden = findItemIdentification(itemId);
if (iden == null) if (iden == null || !iden.type.enabled.test(config))
{ {
return; return;
} }
switch (iden.type)
{
case SEED:
if (!config.showSeeds())
{
return;
}
break;
case SACK:
if (!config.showSacks())
{
return;
}
break;
case HERB:
if (!config.showHerbs())
{
return;
}
break;
case LOGS:
if (!config.showLogs())
{
return;
}
break;
case PLANK:
if (!config.showPlanks())
{
return;
}
break;
case SAPLING:
if (!config.showSaplings())
{
return;
}
break;
case COMPOST:
if (!config.showComposts())
{
return;
}
break;
case ORE:
if (!config.showOres())
{
return;
}
break;
case BAR:
if (!config.showBars())
{
return;
}
break;
case GEM:
if (!config.showGems())
{
return;
}
break;
case POTION:
if (!config.showPotions())
{
return;
}
break;
case IMPLING_JAR:
if (!config.showImplingJars())
{
return;
}
break;
case TABLET:
if (!config.showTablets())
{
return;
}
break;
case SCROLL:
if (!config.showTeleportScrolls())
{
return;
}
break;
}
graphics.setFont(FontManager.getRunescapeSmallFont()); graphics.setFont(FontManager.getRunescapeSmallFont());
renderText(graphics, widgetItem.getCanvasBounds(), iden); renderText(graphics, widgetItem.getCanvasBounds(), iden);
} }