Merge pull request #3555 from evansloan/xptrack-hide-others

Add reset others to XpInfoBox right click menu
This commit is contained in:
Adam
2018-06-01 11:44:26 -04:00
committed by GitHub
2 changed files with 20 additions and 0 deletions

View File

@@ -94,11 +94,16 @@ class XpInfoBox extends JPanel
final JMenuItem reset = new JMenuItem("Reset");
reset.addActionListener(e -> xpTrackerPlugin.resetSkillState(skill));
// Create reset others menu
final JMenuItem resetOthers = new JMenuItem("Reset others");
resetOthers.addActionListener(e -> xpTrackerPlugin.resetOtherSkillState(skill));
// Create popup menu
final JPopupMenu popupMenu = new JPopupMenu();
popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
popupMenu.add(openXpTracker);
popupMenu.add(reset);
popupMenu.add(resetOthers);
JLabel skillIcon = new JLabel(new ImageIcon(iconManager.getSkillImage(skill)));
skillIcon.setHorizontalAlignment(SwingConstants.CENTER);

View File

@@ -239,6 +239,21 @@ public class XpTrackerPlugin extends Plugin
xpPanel.updateTotal(xpState.getTotalSnapshot());
}
/**
* Reset all skills except for the one provided
* @param skill Skill to ignore during reset
*/
public void resetOtherSkillState(Skill skill)
{
for (Skill s : Skill.values())
{
if (skill != s)
{
resetSkillState(s);
}
}
}
@Subscribe
public void onXpChanged(ExperienceChanged event)