itemstats: Add "Always Show Base Stats" option
This commit adds an option to display a more comprehensive tooltip which, alongside the stat changes, shows the base stats of any equipment hovered.
This commit is contained in:
@@ -112,6 +112,16 @@ public interface ItemStatConfig extends Config
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "alwaysShowBaseStats",
|
||||||
|
name = "Always Show Base Stats",
|
||||||
|
description = "Always include the base items stats in the tooltip"
|
||||||
|
)
|
||||||
|
default boolean alwaysShowBaseStats()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "colorBetterUncapped",
|
keyName = "colorBetterUncapped",
|
||||||
name = "Better (Uncapped)",
|
name = "Better (Uncapped)",
|
||||||
|
|||||||
@@ -167,7 +167,6 @@ public class ItemStatOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getChangeString(
|
private String getChangeString(
|
||||||
final String label,
|
|
||||||
final double value,
|
final double value,
|
||||||
final boolean inverse,
|
final boolean inverse,
|
||||||
final boolean showPercent)
|
final boolean showPercent)
|
||||||
@@ -194,17 +193,49 @@ public class ItemStatOverlay extends Overlay
|
|||||||
final String prefix = value > 0 ? "+" : "";
|
final String prefix = value > 0 ? "+" : "";
|
||||||
final String suffix = showPercent ? "%" : "";
|
final String suffix = showPercent ? "%" : "";
|
||||||
final String valueString = QuantityFormatter.formatNumber(value);
|
final String valueString = QuantityFormatter.formatNumber(value);
|
||||||
return label + ": " + ColorUtil.wrapWithColorTag(prefix + valueString + suffix, color) + "</br>";
|
return ColorUtil.wrapWithColorTag(prefix + valueString + suffix, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildStatRow(
|
||||||
|
final String label,
|
||||||
|
final double value,
|
||||||
|
final double diffValue,
|
||||||
|
final boolean inverse,
|
||||||
|
final boolean showPercent)
|
||||||
|
{
|
||||||
|
return buildStatRow(label, value, diffValue, inverse, showPercent, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildStatRow(
|
||||||
|
final String label,
|
||||||
|
final double value,
|
||||||
|
final double diffValue,
|
||||||
|
final boolean inverse,
|
||||||
|
final boolean showPercent,
|
||||||
|
final boolean showBase)
|
||||||
|
{
|
||||||
|
final StringBuilder b = new StringBuilder();
|
||||||
|
|
||||||
|
if (value != 0 || diffValue != 0)
|
||||||
|
{
|
||||||
|
final String changeStr = getChangeString(diffValue, inverse, showPercent);
|
||||||
|
|
||||||
|
if (config.alwaysShowBaseStats() && showBase)
|
||||||
|
{
|
||||||
|
final String valueStr = QuantityFormatter.formatNumber(value);
|
||||||
|
b.append(label).append(": ").append(valueStr).append((!changeStr.isEmpty() ? " (" + changeStr + ") " : "")).append("</br>");
|
||||||
|
}
|
||||||
|
else if (!changeStr.isEmpty())
|
||||||
|
{
|
||||||
|
b.append(label).append(": ").append(changeStr).append("</br>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildStatBonusString(ItemStats s)
|
private String buildStatBonusString(ItemStats s)
|
||||||
{
|
{
|
||||||
final StringBuilder b = new StringBuilder();
|
|
||||||
if (config.showWeight())
|
|
||||||
{
|
|
||||||
b.append(getChangeString("Weight", s.getWeight(), true, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStats other = null;
|
ItemStats other = null;
|
||||||
final ItemEquipmentStats currentEquipment = s.getEquipment();
|
final ItemEquipmentStats currentEquipment = s.getEquipment();
|
||||||
|
|
||||||
@@ -233,32 +264,44 @@ public class ItemStatOverlay extends Overlay
|
|||||||
final ItemStats subtracted = s.subtract(other);
|
final ItemStats subtracted = s.subtract(other);
|
||||||
final ItemEquipmentStats e = subtracted.getEquipment();
|
final ItemEquipmentStats e = subtracted.getEquipment();
|
||||||
|
|
||||||
|
final StringBuilder b = new StringBuilder();
|
||||||
|
|
||||||
|
if (config.showWeight())
|
||||||
|
{
|
||||||
|
double sw = config.alwaysShowBaseStats() ? subtracted.getWeight() : s.getWeight();
|
||||||
|
b.append(buildStatRow("Weight", s.getWeight(), sw, true, false, s.isEquipable()));
|
||||||
|
}
|
||||||
|
|
||||||
if (subtracted.isEquipable() && e != null)
|
if (subtracted.isEquipable() && e != null)
|
||||||
{
|
{
|
||||||
b.append(getChangeString("Prayer", e.getPrayer(), false, false));
|
b.append(buildStatRow("Prayer", currentEquipment.getPrayer(), e.getPrayer(), false, false));
|
||||||
b.append(getChangeString("Speed", e.getAspeed(), true, false));
|
b.append(buildStatRow("Speed", currentEquipment.getAspeed(), e.getAspeed(), true, false));
|
||||||
b.append(getChangeString("Melee Str", e.getStr(), false, false));
|
b.append(buildStatRow("Melee Str", currentEquipment.getStr(), e.getStr(), false, false));
|
||||||
b.append(getChangeString("Range Str", e.getRstr(), false, false));
|
b.append(buildStatRow("Range Str", currentEquipment.getRstr(), e.getRstr(), false, false));
|
||||||
b.append(getChangeString("Magic Dmg", e.getMdmg(), false, true));
|
b.append(buildStatRow("Magic Dmg", currentEquipment.getMdmg(), e.getMdmg(), false, true));
|
||||||
|
|
||||||
if (e.getAstab() != 0 || e.getAslash() != 0 || e.getAcrush() != 0 || e.getAmagic() != 0 || e.getArange() != 0)
|
final StringBuilder abb = new StringBuilder();
|
||||||
|
abb.append(buildStatRow("Stab", currentEquipment.getAspeed(), e.getAspeed(), false, false));
|
||||||
|
abb.append(buildStatRow("Slash", currentEquipment.getAslash(), e.getAslash(), false, false));
|
||||||
|
abb.append(buildStatRow("Crush", currentEquipment.getAcrush(), e.getAcrush(), false, false));
|
||||||
|
abb.append(buildStatRow("Magic", currentEquipment.getAmagic(), e.getAmagic(), false, false));
|
||||||
|
abb.append(buildStatRow("Range", currentEquipment.getArange(), e.getArange(), false, false));
|
||||||
|
|
||||||
|
if (abb.length() > 0)
|
||||||
{
|
{
|
||||||
b.append(ColorUtil.wrapWithColorTag("Attack Bonus</br>", JagexColors.MENU_TARGET));
|
b.append(ColorUtil.wrapWithColorTag("Attack Bonus</br>", JagexColors.MENU_TARGET)).append(abb);
|
||||||
b.append(getChangeString("Stab", e.getAstab(), false, false));
|
|
||||||
b.append(getChangeString("Slash", e.getAslash(), false, false));
|
|
||||||
b.append(getChangeString("Crush", e.getAcrush(), false, false));
|
|
||||||
b.append(getChangeString("Magic", e.getAmagic(), false, false));
|
|
||||||
b.append(getChangeString("Range", e.getArange(), false, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.getDstab() != 0 || e.getDslash() != 0 || e.getDcrush() != 0 || e.getDmagic() != 0 || e.getDrange() != 0)
|
final StringBuilder dbb = new StringBuilder();
|
||||||
|
dbb.append(buildStatRow("Stab", currentEquipment.getDstab(), e.getDstab(), false, false));
|
||||||
|
dbb.append(buildStatRow("Slash", currentEquipment.getDslash(), e.getDslash(), false, false));
|
||||||
|
dbb.append(buildStatRow("Crush", currentEquipment.getDcrush(), e.getDcrush(), false, false));
|
||||||
|
dbb.append(buildStatRow("Magic", currentEquipment.getDmagic(), e.getDmagic(), false, false));
|
||||||
|
dbb.append(buildStatRow("Range", currentEquipment.getDrange(), e.getDrange(), false, false));
|
||||||
|
|
||||||
|
if (dbb.length() > 0)
|
||||||
{
|
{
|
||||||
b.append(ColorUtil.wrapWithColorTag("Defence Bonus</br>", JagexColors.MENU_TARGET));
|
b.append(ColorUtil.wrapWithColorTag("Defence Bonus</br>", JagexColors.MENU_TARGET)).append(dbb);
|
||||||
b.append(getChangeString("Stab", e.getDstab(), false, false));
|
|
||||||
b.append(getChangeString("Slash", e.getDslash(), false, false));
|
|
||||||
b.append(getChangeString("Crush", e.getDcrush(), false, false));
|
|
||||||
b.append(getChangeString("Magic", e.getDmagic(), false, false));
|
|
||||||
b.append(getChangeString("Range", e.getDrange(), false, false));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user