Merge pull request #1525 from devLotto/hiscore-virtual-levels

Display levels above 99 in the hiscore panel
This commit is contained in:
Adam
2018-04-15 10:44:33 -04:00
committed by GitHub
3 changed files with 28 additions and 3 deletions

View File

@@ -56,4 +56,15 @@ public interface HiscoreConfig extends Config
{ {
return true; return true;
} }
@ConfigItem(
position = 3,
keyName = "virtualLevels",
name = "Display virtual levels",
description = "Display levels over 99 in the hiscore panel"
)
default boolean virtualLevels()
{
return true;
}
} }

View File

@@ -119,6 +119,7 @@ public class HiscorePanel extends PluginPanel
@Nullable @Nullable
private Client client; private Client client;
private final HiscoreConfig config;
private final IconTextField input; private final IconTextField input;
private final List<JLabel> skillLabels = new ArrayList<>(); private final List<JLabel> skillLabels = new ArrayList<>();
@@ -132,9 +133,11 @@ public class HiscorePanel extends PluginPanel
private final HiscoreClient hiscoreClient = new HiscoreClient(); private final HiscoreClient hiscoreClient = new HiscoreClient();
private HiscoreResult result; private HiscoreResult result;
public HiscorePanel() @Inject
public HiscorePanel(HiscoreConfig config)
{ {
super(); super();
this.config = config;
// Panel "constants" // Panel "constants"
// This was an EtchedBorder, but the style would change when the window was maximized. // This was an EtchedBorder, but the style would change when the window was maximized.
@@ -544,7 +547,18 @@ public class HiscorePanel extends PluginPanel
} }
else if (result.getSkill(skill) != null && result.getSkill(skill).getRank() != -1) else if (result.getSkill(skill) != null && result.getSkill(skill).getRank() != -1)
{ {
label.setText(Integer.toString(result.getSkill(skill).getLevel())); Skill s = result.getSkill(skill);
int level;
if (config.virtualLevels())
{
level = Experience.getLevelForXp((int) s.getExperience());
}
else
{
level = s.getLevel();
}
label.setText(Integer.toString(level));
} }
} }

View File

@@ -31,7 +31,7 @@ public class HiscorePanelTest
@Test @Test
public void testConstructor() public void testConstructor()
{ {
new HiscorePanel(); new HiscorePanel(new HiscoreConfig() {});
} }
} }