hiscore plugin: add boss hiscores

Co-authored-by: Abex <mii7303@gmail.com>
Co-authored-by: Gamma91 <bramvgemert@gmail.com>
This commit is contained in:
Adam
2020-01-04 18:26:56 -05:00
committed by Adam
parent 062d1b99b9
commit 3cf777d274
54 changed files with 267 additions and 192 deletions

View File

@@ -26,89 +26,93 @@ package net.runelite.http.api.hiscore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import static net.runelite.http.api.hiscore.HiscoreSkillType.SKILL;
import static net.runelite.http.api.hiscore.HiscoreSkillType.ACTIVITY;
import static net.runelite.http.api.hiscore.HiscoreSkillType.BOSS;
@AllArgsConstructor
@Getter
public enum HiscoreSkill
{
OVERALL("Overall"),
ATTACK("Attack"),
DEFENCE("Defence"),
STRENGTH("Strength"),
HITPOINTS("Hitpoints"),
RANGED("Ranged"),
PRAYER("Prayer"),
MAGIC("Magic"),
COOKING("Cooking"),
WOODCUTTING("Woodcutting"),
FLETCHING("Fletching"),
FISHING("Fishing"),
FIREMAKING("Firemaking"),
CRAFTING("Crafting"),
SMITHING("Smithing"),
MINING("Mining"),
HERBLORE("Herblore"),
AGILITY("Agility"),
THIEVING("Thieving"),
SLAYER("Slayer"),
FARMING("Farming"),
RUNECRAFT("Runecraft"),
HUNTER("Hunter"),
CONSTRUCTION("Construction"),
LEAGUE_POINTS("League Points"),
BOUNTY_HUNTER_HUNTER("Bounty Hunter - Hunter"),
BOUNTY_HUNTER_ROGUE("Bounty Hunter - Rogue"),
CLUE_SCROLL_ALL("Clue Scrolls (all)"),
CLUE_SCROLL_BEGINNER("Clue Scrolls (beginner)"),
CLUE_SCROLL_EASY("Clue Scrolls (easy)"),
CLUE_SCROLL_MEDIUM("Clue Scrolls (medium)"),
CLUE_SCROLL_HARD("Clue Scrolls (hard)"),
CLUE_SCROLL_ELITE("Clue Scrolls (elite)"),
CLUE_SCROLL_MASTER("Clue Scrolls (master)"),
LAST_MAN_STANDING("Last Man Standing"),
ABYSSAL_SIRE("Abyssal Sire"),
ALCHEMICAL_HYDRA("Alchemical Hydra"),
BARROWS_CHESTS("Barrows Chests"),
BRYOPHYTA("Bryophyta"),
CALLISTO("Callisto"),
CERBERUS("Cerberus"),
CHAMBERS_OF_XERIC("Chambers of Xeric"),
CHAMBERS_OF_XERIC_CHALLENGE_MODE("Chambers of Xeric: Challenge Mode"),
CHAOS_ELEMENTAL("Chaos Elemental"),
CHAOS_FANATIC("Chaos Fanatic"),
COMMANDER_ZILYANA("Commander Zilyana"),
CORPOREAL_BEAST("Corporeal Beast"),
CRAZY_ARCHAEOLOGIST("Crazy Archaeologist"),
DAGANNOTH_PRIME("Dagannoth Prime"),
DAGANNOTH_REX("Dagannoth Rex"),
DAGANNOTH_SUPREME("Dagannoth Supreme"),
DERANGED_ARCHAEOLOGIST("Deranged Archaeologist"),
GENERAL_GRAARDOR("General Graardor"),
GIANT_MOLE("Giant Mole"),
GROTESQUE_GUARDIANS("Grotesque Guardians"),
HESPORI("Hespori"),
KALPHITE_QUEEN("Kalphite Queen"),
KING_BLACK_DRAGON("King Black Dragon"),
KRAKEN("Kraken"),
KREEARRA("Kree'Arra"),
KRIL_TSUTSAROTH("K'ril Tsutsaroth"),
MIMIC("Mimic"),
OBOR("Obor"),
SARACHNIS("Sarachnis"),
SCORPIA("Scorpia"),
SKOTIZO("Skotizo"),
THE_GAUNTLET("The Gauntlet"),
THE_CORRUPTED_GAUNTLET("The Corrupted Gauntlet"),
THEATRE_OF_BLOOD("Theatre of Blood"),
THERMONUCLEAR_SMOKE_DEVIL("Thermonuclear Smoke Devil"),
TZKAL_ZUK("TzKal-Zuk"),
TZTOK_JAD("TzTok-Jad"),
VENENATIS("Venenatis"),
VETION("Vet'ion"),
VORKATH("Vorkath"),
WINTERTODT("Wintertodt"),
ZALCANO("Zalcano"),
ZULRAH("Zulrah");
OVERALL("Overall", HiscoreSkillType.OVERALL),
ATTACK("Attack", SKILL),
DEFENCE("Defence", SKILL),
STRENGTH("Strength", SKILL),
HITPOINTS("Hitpoints", SKILL),
RANGED("Ranged", SKILL),
PRAYER("Prayer", SKILL),
MAGIC("Magic", SKILL),
COOKING("Cooking", SKILL),
WOODCUTTING("Woodcutting", SKILL),
FLETCHING("Fletching", SKILL),
FISHING("Fishing", SKILL),
FIREMAKING("Firemaking", SKILL),
CRAFTING("Crafting", SKILL),
SMITHING("Smithing", SKILL),
MINING("Mining", SKILL),
HERBLORE("Herblore", SKILL),
AGILITY("Agility", SKILL),
THIEVING("Thieving", SKILL),
SLAYER("Slayer", SKILL),
FARMING("Farming", SKILL),
RUNECRAFT("Runecraft", SKILL),
HUNTER("Hunter", SKILL),
CONSTRUCTION("Construction", SKILL),
LEAGUE_POINTS("League Points", ACTIVITY),
BOUNTY_HUNTER_HUNTER("Bounty Hunter - Hunter", ACTIVITY),
BOUNTY_HUNTER_ROGUE("Bounty Hunter - Rogue", ACTIVITY),
CLUE_SCROLL_ALL("Clue Scrolls (all)", ACTIVITY),
CLUE_SCROLL_BEGINNER("Clue Scrolls (beginner)", ACTIVITY),
CLUE_SCROLL_EASY("Clue Scrolls (easy)", ACTIVITY),
CLUE_SCROLL_MEDIUM("Clue Scrolls (medium)", ACTIVITY),
CLUE_SCROLL_HARD("Clue Scrolls (hard)", ACTIVITY),
CLUE_SCROLL_ELITE("Clue Scrolls (elite)", ACTIVITY),
CLUE_SCROLL_MASTER("Clue Scrolls (master)", ACTIVITY),
LAST_MAN_STANDING("Last Man Standing", ACTIVITY),
ABYSSAL_SIRE("Abyssal Sire", BOSS),
ALCHEMICAL_HYDRA("Alchemical Hydra", BOSS),
BARROWS_CHESTS("Barrows Chests", BOSS),
BRYOPHYTA("Bryophyta", BOSS),
CALLISTO("Callisto", BOSS),
CERBERUS("Cerberus", BOSS),
CHAMBERS_OF_XERIC("Chambers of Xeric", BOSS),
CHAMBERS_OF_XERIC_CHALLENGE_MODE("Chambers of Xeric: Challenge Mode", BOSS),
CHAOS_ELEMENTAL("Chaos Elemental", BOSS),
CHAOS_FANATIC("Chaos Fanatic", BOSS),
COMMANDER_ZILYANA("Commander Zilyana", BOSS),
CORPOREAL_BEAST("Corporeal Beast", BOSS),
CRAZY_ARCHAEOLOGIST("Crazy Archaeologist", BOSS),
DAGANNOTH_PRIME("Dagannoth Prime", BOSS),
DAGANNOTH_REX("Dagannoth Rex", BOSS),
DAGANNOTH_SUPREME("Dagannoth Supreme", BOSS),
DERANGED_ARCHAEOLOGIST("Deranged Archaeologist", BOSS),
GENERAL_GRAARDOR("General Graardor", BOSS),
GIANT_MOLE("Giant Mole", BOSS),
GROTESQUE_GUARDIANS("Grotesque Guardians", BOSS),
HESPORI("Hespori", BOSS),
KALPHITE_QUEEN("Kalphite Queen", BOSS),
KING_BLACK_DRAGON("King Black Dragon", BOSS),
KRAKEN("Kraken", BOSS),
KREEARRA("Kree'Arra", BOSS),
KRIL_TSUTSAROTH("K'ril Tsutsaroth", BOSS),
MIMIC("Mimic", BOSS),
OBOR("Obor", BOSS),
SARACHNIS("Sarachnis", BOSS),
SCORPIA("Scorpia", BOSS),
SKOTIZO("Skotizo", BOSS),
THE_GAUNTLET("The Gauntlet", BOSS),
THE_CORRUPTED_GAUNTLET("The Corrupted Gauntlet", BOSS),
THEATRE_OF_BLOOD("Theatre of Blood", BOSS),
THERMONUCLEAR_SMOKE_DEVIL("Thermonuclear Smoke Devil", BOSS),
TZKAL_ZUK("TzKal-Zuk", BOSS),
TZTOK_JAD("TzTok-Jad", BOSS),
VENENATIS("Venenatis", BOSS),
VETION("Vet'ion", BOSS),
VORKATH("Vorkath", BOSS),
WINTERTODT("Wintertodt", BOSS),
ZALCANO("Zalcano", BOSS),
ZULRAH("Zulrah", BOSS);
private final String name;
private final HiscoreSkillType type;
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2019, Bram91 <https://github.com/bram91>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.http.api.hiscore;
public enum HiscoreSkillType
{
OVERALL,
SKILL,
ACTIVITY,
BOSS
}

View File

@@ -1,6 +1,7 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Psikoi <https://github.com/psikoi>
* Copyright (c) 2019, Bram91 <https://github.com/bram91>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,6 +26,7 @@
*/
package net.runelite.client.plugins.hiscore;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import java.awt.Dimension;
@@ -37,9 +39,10 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable;
import javax.inject.Inject;
@@ -64,36 +67,10 @@ import net.runelite.http.api.hiscore.HiscoreClient;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import net.runelite.http.api.hiscore.HiscoreResult;
import net.runelite.http.api.hiscore.HiscoreSkill;
import static net.runelite.http.api.hiscore.HiscoreSkill.AGILITY;
import static net.runelite.http.api.hiscore.HiscoreSkill.ATTACK;
import static net.runelite.http.api.hiscore.HiscoreSkill.BOUNTY_HUNTER_HUNTER;
import static net.runelite.http.api.hiscore.HiscoreSkill.BOUNTY_HUNTER_ROGUE;
import static net.runelite.http.api.hiscore.HiscoreSkill.CLUE_SCROLL_ALL;
import static net.runelite.http.api.hiscore.HiscoreSkill.CONSTRUCTION;
import static net.runelite.http.api.hiscore.HiscoreSkill.COOKING;
import static net.runelite.http.api.hiscore.HiscoreSkill.CRAFTING;
import static net.runelite.http.api.hiscore.HiscoreSkill.DEFENCE;
import static net.runelite.http.api.hiscore.HiscoreSkill.FARMING;
import static net.runelite.http.api.hiscore.HiscoreSkill.FIREMAKING;
import static net.runelite.http.api.hiscore.HiscoreSkill.FISHING;
import static net.runelite.http.api.hiscore.HiscoreSkill.FLETCHING;
import static net.runelite.http.api.hiscore.HiscoreSkill.HERBLORE;
import static net.runelite.http.api.hiscore.HiscoreSkill.HITPOINTS;
import static net.runelite.http.api.hiscore.HiscoreSkill.HUNTER;
import static net.runelite.http.api.hiscore.HiscoreSkill.LAST_MAN_STANDING;
import static net.runelite.http.api.hiscore.HiscoreSkill.LEAGUE_POINTS;
import static net.runelite.http.api.hiscore.HiscoreSkill.MAGIC;
import static net.runelite.http.api.hiscore.HiscoreSkill.MINING;
import static net.runelite.http.api.hiscore.HiscoreSkill.OVERALL;
import static net.runelite.http.api.hiscore.HiscoreSkill.PRAYER;
import static net.runelite.http.api.hiscore.HiscoreSkill.RANGED;
import static net.runelite.http.api.hiscore.HiscoreSkill.RUNECRAFT;
import static net.runelite.http.api.hiscore.HiscoreSkill.SLAYER;
import static net.runelite.http.api.hiscore.HiscoreSkill.SMITHING;
import static net.runelite.http.api.hiscore.HiscoreSkill.STRENGTH;
import static net.runelite.http.api.hiscore.HiscoreSkill.THIEVING;
import static net.runelite.http.api.hiscore.HiscoreSkill.WOODCUTTING;
import static net.runelite.http.api.hiscore.HiscoreSkill.*;
import net.runelite.http.api.hiscore.HiscoreSkillType;
import net.runelite.http.api.hiscore.Skill;
import org.apache.commons.lang3.StringUtils;
@Slf4j
public class HiscorePanel extends PluginPanel
@@ -115,6 +92,27 @@ public class HiscorePanel extends PluginPanel
CONSTRUCTION, HUNTER
);
/**
* Bosses, ordered in the way they should be displayed in the panel.
*/
private static final List<HiscoreSkill> BOSSES = ImmutableList.of(
ABYSSAL_SIRE, ALCHEMICAL_HYDRA, BARROWS_CHESTS,
BRYOPHYTA, CALLISTO, CERBERUS,
CHAMBERS_OF_XERIC, CHAMBERS_OF_XERIC_CHALLENGE_MODE, CHAOS_ELEMENTAL,
CHAOS_FANATIC, COMMANDER_ZILYANA, CORPOREAL_BEAST,
DAGANNOTH_PRIME, DAGANNOTH_REX, DAGANNOTH_SUPREME,
CRAZY_ARCHAEOLOGIST, DERANGED_ARCHAEOLOGIST, GENERAL_GRAARDOR,
GIANT_MOLE, GROTESQUE_GUARDIANS, HESPORI,
KALPHITE_QUEEN, KING_BLACK_DRAGON, KRAKEN,
KREEARRA, KRIL_TSUTSAROTH, MIMIC,
OBOR, SARACHNIS, SCORPIA,
SKOTIZO, THE_GAUNTLET, THE_CORRUPTED_GAUNTLET,
THEATRE_OF_BLOOD, THERMONUCLEAR_SMOKE_DEVIL, TZKAL_ZUK,
TZTOK_JAD, VENENATIS, VETION,
VORKATH, WINTERTODT, ZALCANO,
ZULRAH
);
@Inject
ScheduledExecutorService executor;
@@ -126,9 +124,8 @@ public class HiscorePanel extends PluginPanel
private final IconTextField searchBar;
private final List<JLabel> skillLabels = new ArrayList<>();
private final JPanel statsPanel = new JPanel();
// Not an enummap because we need null keys for combat
private final Map<HiscoreSkill, JLabel> skillLabels = new HashMap<>();
/* Container of all the selectable endpoints (ironman, deadman, etc) */
private final MaterialTabGroup tabGroup;
@@ -245,15 +242,15 @@ public class HiscorePanel extends PluginPanel
c.gridy++;
// Panel that holds skill icons
GridLayout stats = new GridLayout(8, 3);
statsPanel.setLayout(stats);
JPanel statsPanel = new JPanel();
statsPanel.setLayout(new GridLayout(8, 3));
statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
statsPanel.setBorder(new EmptyBorder(5, 0, 5, 0));
// For each skill on the ingame skill panel, create a Label and add it to the UI
for (HiscoreSkill skill : SKILLS)
{
JPanel panel = makeSkillPanel(skill);
JPanel panel = makeHiscorePanel(skill);
statsPanel.add(panel);
}
@@ -261,11 +258,11 @@ public class HiscorePanel extends PluginPanel
c.gridy++;
JPanel totalPanel = new JPanel();
totalPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
totalPanel.setLayout(new GridLayout(1, 2));
totalPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
totalPanel.add(makeSkillPanel(null)); //combat has no hiscore skill, refered to as null
totalPanel.add(makeSkillPanel(OVERALL));
totalPanel.add(makeHiscorePanel(null)); //combat has no hiscore skill, referred to as null
totalPanel.add(makeHiscorePanel(OVERALL));
add(totalPanel, c);
c.gridy++;
@@ -276,14 +273,28 @@ public class HiscorePanel extends PluginPanel
minigamePanel.setLayout(new GridLayout(2, 3));
minigamePanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
minigamePanel.add(makeSkillPanel(CLUE_SCROLL_ALL));
minigamePanel.add(makeSkillPanel(LEAGUE_POINTS));
minigamePanel.add(makeSkillPanel(LAST_MAN_STANDING));
minigamePanel.add(makeSkillPanel(BOUNTY_HUNTER_ROGUE));
minigamePanel.add(makeSkillPanel(BOUNTY_HUNTER_HUNTER));
minigamePanel.add(makeHiscorePanel(CLUE_SCROLL_ALL));
minigamePanel.add(makeHiscorePanel(LEAGUE_POINTS));
minigamePanel.add(makeHiscorePanel(LAST_MAN_STANDING));
minigamePanel.add(makeHiscorePanel(BOUNTY_HUNTER_ROGUE));
minigamePanel.add(makeHiscorePanel(BOUNTY_HUNTER_HUNTER));
add(minigamePanel, c);
c.gridy++;
JPanel bossPanel = new JPanel();
bossPanel.setLayout(new GridLayout(0, 3));
bossPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
// For each boss on the hi-scores, create a Label and add it to the UI
for (HiscoreSkill skill : BOSSES)
{
JPanel panel = makeHiscorePanel(skill);
bossPanel.add(panel);
}
add(bossPanel, c);
c.gridy++;
}
@Override
@@ -294,24 +305,29 @@ public class HiscorePanel extends PluginPanel
}
/* Builds a JPanel displaying an icon and level/number associated with it */
private JPanel makeSkillPanel(HiscoreSkill skill)
private JPanel makeHiscorePanel(HiscoreSkill skill)
{
HiscoreSkillType skillType = skill == null ? HiscoreSkillType.SKILL : skill.getType();
JLabel label = new JLabel();
label.setFont(FontManager.getRunescapeSmallFont());
label.setText("--");
label.setText(pad("--", skillType));
String skillName = (skill == null ? "combat" : skill.getName().toLowerCase());
String directory = "/skill_icons";
if (skillName.equals("combat") || skillName.equals("overall"))
String directory;
if (skill == null || skill == OVERALL)
{
// Cannot use SpriteManager as HiscorePlugin loads before a Client is available
directory += "/";
directory = "/skill_icons/";
}
else if (skill.getType() == HiscoreSkillType.BOSS)
{
directory = "bosses/";
}
else
{
directory += "_small/";
directory = "/skill_icons_small/";
}
String skillName = (skill == null ? "combat" : skill.name().toLowerCase());
String skillIcon = directory + skillName + ".png";
log.debug("Loading skill icon from {}", skillIcon);
@@ -323,8 +339,8 @@ public class HiscorePanel extends PluginPanel
JPanel skillPanel = new JPanel();
skillPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
skillPanel.setBorder(new EmptyBorder(2, 0, 2, 0));
skillLabels.add(label);
skillPanel.add(skillLabels.get(skillLabels.size() - 1));
skillLabels.put(skill, label);
skillPanel.add(label);
return skillPanel;
}
@@ -359,9 +375,13 @@ public class HiscorePanel extends PluginPanel
searchBar.setIcon(IconTextField.Icon.LOADING_DARKER);
loading = true;
for (JLabel label : skillLabels)
for (Map.Entry<HiscoreSkill, JLabel> entry : skillLabels.entrySet())
{
label.setText("--");
HiscoreSkill skill = entry.getKey();
JLabel label = entry.getValue();
HiscoreSkillType skillType = skill == null ? HiscoreSkillType.SKILL : skill.getType();
label.setText(pad("--", skillType));
label.setToolTipText(null);
}
@@ -398,10 +418,10 @@ public class HiscorePanel extends PluginPanel
searchBar.setEditable(true);
loading = false;
int index = 0;
for (JLabel label : skillLabels)
for (Map.Entry<HiscoreSkill, JLabel> entry : skillLabels.entrySet())
{
HiscoreSkill skill = find(index);
HiscoreSkill skill = entry.getKey();
JLabel label = entry.getValue();
Skill s;
if (skill == null)
@@ -423,7 +443,7 @@ public class HiscorePanel extends PluginPanel
else if ((s = result.getSkill(skill)) != null)
{
final long exp = s.getExperience();
final boolean isSkill = SKILLS.contains(skill);
final boolean isSkill = skill.getType() == HiscoreSkillType.SKILL;
int level = -1;
if (config.virtualLevels() && isSkill && exp > -1L)
{
@@ -438,12 +458,11 @@ public class HiscorePanel extends PluginPanel
if (level != -1)
{
label.setText(Integer.toString(level));
label.setText(pad(formatLevel(level), skill.getType()));
}
}
label.setToolTipText(detailsHtml(result, skill));
index++;
}
}
@@ -457,37 +476,6 @@ public class HiscorePanel extends PluginPanel
this.searchBar.removeKeyListener(l);
}
/*
Returns a hiscore skill based on it's display order.
*/
private HiscoreSkill find(int index)
{
if (index < SKILLS.size())
{
return SKILLS.get(index);
}
switch (index - SKILLS.size())
{
case 0:
return null;
case 1:
return OVERALL;
case 2:
return CLUE_SCROLL_ALL;
case 3:
return LEAGUE_POINTS;
case 4:
return LAST_MAN_STANDING;
case 5:
return BOUNTY_HUNTER_ROGUE;
case 6:
return BOUNTY_HUNTER_HUNTER;
}
return null;
}
/*
Builds a html string to display on tooltip (when hovering a skill).
*/
@@ -584,36 +572,50 @@ public class HiscorePanel extends PluginPanel
}
default:
{
Skill requestedSkill = result.getSkill(skill);
final long experience = requestedSkill.getExperience();
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(requestedSkill.getRank());
String exp = (experience == -1L) ? "Unranked" : QuantityFormatter.formatNumber(experience);
String remainingXp;
if (experience == -1L)
if (skill.getType() == HiscoreSkillType.BOSS)
{
remainingXp = "Unranked";
Skill requestedSkill = result.getSkill(skill);
String rank = "Unranked";
String lvl = "0";
if (requestedSkill != null)
{
rank = (requestedSkill.getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(requestedSkill.getRank());
lvl = (requestedSkill.getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(requestedSkill.getLevel()));
}
content += "<p><span style = 'color:white'>Boss:</span> " + skill.getName() + "</p>";
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
content += "<p><span style = 'color:white'>KC:</span> " + lvl + "</p>";
}
else
{
int currentLevel = Experience.getLevelForXp((int) experience);
remainingXp = (currentLevel + 1 <= Experience.MAX_VIRT_LEVEL) ? QuantityFormatter.formatNumber(Experience.getXpForLevel(currentLevel + 1) - experience) : "0";
Skill requestedSkill = result.getSkill(skill);
final long experience = requestedSkill.getExperience();
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(requestedSkill.getRank());
String exp = (experience == -1L) ? "Unranked" : QuantityFormatter.formatNumber(experience);
String remainingXp;
if (experience == -1L)
{
remainingXp = "Unranked";
}
else
{
int currentLevel = Experience.getLevelForXp((int) experience);
remainingXp = (currentLevel + 1 <= Experience.MAX_VIRT_LEVEL) ? QuantityFormatter.formatNumber(Experience.getXpForLevel(currentLevel + 1) - experience) : "0";
}
content += "<p><span style = 'color:white'>Skill:</span> " + skill.getName() + "</p>";
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
content += "<p><span style = 'color:white'>Experience:</span> " + exp + "</p>";
content += "<p><span style = 'color:white'>Remaining XP:</span> " + remainingXp + "</p>";
}
content += "<p><span style = 'color:white'>Skill:</span> " + skill.getName() + "</p>";
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
content += "<p><span style = 'color:white'>Experience:</span> " + exp + "</p>";
content += "<p><span style = 'color:white'>Remaining XP:</span> " + remainingXp + "</p>";
break;
}
}
}
/**
* Adds a html progress bar to the hover information
*/
if (SKILLS.contains(skill))
// Add a html progress bar to the hover information
if (skill != null && skill.getType() == HiscoreSkillType.SKILL)
{
long experience = result.getSkill(skill).getExperience();
if (experience >= 0)
@@ -668,4 +670,24 @@ public class HiscorePanel extends PluginPanel
}
return HiscoreEndpoint.NORMAL;
}
@VisibleForTesting
static String formatLevel(int level)
{
if (level < 10000)
{
return Integer.toString(level);
}
else
{
return (level / 1000) + "k";
}
}
private static String pad(String str, HiscoreSkillType type)
{
// Left pad label text to keep labels aligned
int pad = type == HiscoreSkillType.BOSS ? 4 : 2;
return StringUtils.leftPad(str, pad);
}
}

View File

@@ -380,9 +380,13 @@ public class ImageUtil
return ImageIO.read(c.getResourceAsStream(path));
}
}
catch (IllegalArgumentException e)
{
throw new IllegalArgumentException(path, e);
}
catch (IOException e)
{
throw new RuntimeException(e);
throw new RuntimeException(path, e);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 881 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

View File

@@ -24,6 +24,8 @@
*/
package net.runelite.client.plugins.hiscore;
import static net.runelite.client.plugins.hiscore.HiscorePanel.formatLevel;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class HiscorePanelTest
@@ -35,4 +37,14 @@ public class HiscorePanelTest
{
});
}
@Test
public void testFormatLevel()
{
assertEquals("398", formatLevel(398));
assertEquals("5000", formatLevel(5000));
assertEquals("7682", formatLevel(7682));
assertEquals("12k", formatLevel(12398));
assertEquals("219k", formatLevel(219824));
}
}