Skip to content

Commit

Permalink
Add tooltip support to modifiers
Browse files Browse the repository at this point in the history
Closes #140
  • Loading branch information
TheStonedTurtle committed Mar 13, 2024
1 parent ea6e643 commit 353ce8a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ public class ConsumptionModifier extends Modifier
super(skill, name, included, ignored);
this.savePercentage = savePercentage;
}

ConsumptionModifier(Skill skill, String name, float savePercentage, Collection<Activity> included, Collection<Activity> ignored, String tooltip)
{
super(skill, name, included, ignored, tooltip);
this.savePercentage = savePercentage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,29 @@ public abstract class Modifier
*/
private final ImmutableSet<Activity> ignoredActivities;

private final String tooltip;

Modifier(Skill skill, String name)
{
this(skill, name, null, null);
this(skill, name, null, null, null);
}

Modifier(Skill skill, String name, String tooltip)
{
this(skill, name, null, null, tooltip);
}
Modifier(Skill skill, String name, Collection<Activity> included, Collection<Activity> ignored)
{
this(skill, name, included, ignored, null);
}

Modifier(Skill skill, String name, Collection<Activity> included, Collection<Activity> ignored, String tooltip)
{
this.skill = skill;
this.name = name;
this.includedActivities = included == null ? ImmutableSet.of() : ImmutableSet.copyOf(included);
this.ignoredActivities = ignored == null ? ImmutableSet.of() : ImmutableSet.copyOf(ignored);
this.tooltip = tooltip;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
*/
public final class Modifiers
{
private static final String ASHES_TOOLTIP_TEXT = "Only applies to ashes";
private static final String BONES_TOOLTIP_TEXT = "Only applies to bones";
private static final Multimap<Skill, Modifier> modifiers = ArrayListMultimap.create();

static final Set<Activity> BONES = ImmutableSet.of(
Expand All @@ -60,7 +62,7 @@ public final class Modifiers

public static void prepare(ItemManager manager)
{
assert modifiers.size() == 0;
assert modifiers.isEmpty();

final Map<Integer, ItemComposition[]> compositions = new HashMap<>();

Expand Down Expand Up @@ -96,11 +98,11 @@ private static void createModifiers(final ItemManager manager, final Map<Integer
{
// Prayer Modifiers
addModifier(new ZealotsRobes(manager, compositions.get(ItemID.ZEALOTS_HELM)));
addModifier(new StaticModifier(Skill.PRAYER, "Demonic Offering (300% xp)", 3, ASHES, null));
addModifier(new StaticModifier(Skill.PRAYER, "Lit Gilded Altar (350% xp)", 3.5f, BONES, null));
addModifier(new StaticModifier(Skill.PRAYER, "Ectofuntus (400% xp)", 4, BONES, null));
addModifier(new ConsumptionModifier(Skill.PRAYER, "Wildy Altar (350% xp & 50% Save)", 0.5f, BONES, null)
addModifier(new StaticModifier(Skill.PRAYER, "Sinister Offering (300% xp)", 3, BONES, null));
addModifier(new StaticModifier(Skill.PRAYER, "Demonic Offering (300% xp)", 3, ASHES, null, ASHES_TOOLTIP_TEXT));
addModifier(new StaticModifier(Skill.PRAYER, "Sinister Offering (300% xp)", 3, BONES, null, BONES_TOOLTIP_TEXT));
addModifier(new StaticModifier(Skill.PRAYER, "Lit Gilded Altar (350% xp)", 3.5f, BONES, null, BONES_TOOLTIP_TEXT));
addModifier(new StaticModifier(Skill.PRAYER, "Ectofuntus (400% xp)", 4, BONES, null, BONES_TOOLTIP_TEXT));
addModifier(new ConsumptionModifier(Skill.PRAYER, "Wildy Altar (350% xp & 50% Save)", 0.5f, BONES, null, BONES_TOOLTIP_TEXT)
{
@Override
public double appliedXpRate(final Activity activity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public class StaticModifier extends Modifier
this.xpModifier = xpModifier;
}

StaticModifier(Skill skill, String name, final float xpModifier, Collection<Activity> included, Collection<Activity> ignored, String tooltip)
{
super(skill, name, included, ignored, tooltip);
this.xpModifier = xpModifier;
}

/**
* Applies the {@link #xpModifier} to the default xp rate of the passed activity, if applicable.
* @param activity the {@link Activity} to apply this modifier to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public ModifierPanel(final Modifier modifier)

modifierConsumer.accept(modifier, getButton().isSelected());
});

if (modifier.getTooltip() != null)
{
this.setToolTipText(modifier.getTooltip());
}
}

@Override
Expand Down

0 comments on commit 353ce8a

Please sign in to comment.