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.AllArgsConstructor;
import lombok.Getter; 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 @AllArgsConstructor
@Getter @Getter
public enum HiscoreSkill public enum HiscoreSkill
{ {
OVERALL("Overall"), OVERALL("Overall", HiscoreSkillType.OVERALL),
ATTACK("Attack"), ATTACK("Attack", SKILL),
DEFENCE("Defence"), DEFENCE("Defence", SKILL),
STRENGTH("Strength"), STRENGTH("Strength", SKILL),
HITPOINTS("Hitpoints"), HITPOINTS("Hitpoints", SKILL),
RANGED("Ranged"), RANGED("Ranged", SKILL),
PRAYER("Prayer"), PRAYER("Prayer", SKILL),
MAGIC("Magic"), MAGIC("Magic", SKILL),
COOKING("Cooking"), COOKING("Cooking", SKILL),
WOODCUTTING("Woodcutting"), WOODCUTTING("Woodcutting", SKILL),
FLETCHING("Fletching"), FLETCHING("Fletching", SKILL),
FISHING("Fishing"), FISHING("Fishing", SKILL),
FIREMAKING("Firemaking"), FIREMAKING("Firemaking", SKILL),
CRAFTING("Crafting"), CRAFTING("Crafting", SKILL),
SMITHING("Smithing"), SMITHING("Smithing", SKILL),
MINING("Mining"), MINING("Mining", SKILL),
HERBLORE("Herblore"), HERBLORE("Herblore", SKILL),
AGILITY("Agility"), AGILITY("Agility", SKILL),
THIEVING("Thieving"), THIEVING("Thieving", SKILL),
SLAYER("Slayer"), SLAYER("Slayer", SKILL),
FARMING("Farming"), FARMING("Farming", SKILL),
RUNECRAFT("Runecraft"), RUNECRAFT("Runecraft", SKILL),
HUNTER("Hunter"), HUNTER("Hunter", SKILL),
CONSTRUCTION("Construction"), CONSTRUCTION("Construction", SKILL),
LEAGUE_POINTS("League Points"), LEAGUE_POINTS("League Points", ACTIVITY),
BOUNTY_HUNTER_HUNTER("Bounty Hunter - Hunter"), BOUNTY_HUNTER_HUNTER("Bounty Hunter - Hunter", ACTIVITY),
BOUNTY_HUNTER_ROGUE("Bounty Hunter - Rogue"), BOUNTY_HUNTER_ROGUE("Bounty Hunter - Rogue", ACTIVITY),
CLUE_SCROLL_ALL("Clue Scrolls (all)"), CLUE_SCROLL_ALL("Clue Scrolls (all)", ACTIVITY),
CLUE_SCROLL_BEGINNER("Clue Scrolls (beginner)"), CLUE_SCROLL_BEGINNER("Clue Scrolls (beginner)", ACTIVITY),
CLUE_SCROLL_EASY("Clue Scrolls (easy)"), CLUE_SCROLL_EASY("Clue Scrolls (easy)", ACTIVITY),
CLUE_SCROLL_MEDIUM("Clue Scrolls (medium)"), CLUE_SCROLL_MEDIUM("Clue Scrolls (medium)", ACTIVITY),
CLUE_SCROLL_HARD("Clue Scrolls (hard)"), CLUE_SCROLL_HARD("Clue Scrolls (hard)", ACTIVITY),
CLUE_SCROLL_ELITE("Clue Scrolls (elite)"), CLUE_SCROLL_ELITE("Clue Scrolls (elite)", ACTIVITY),
CLUE_SCROLL_MASTER("Clue Scrolls (master)"), CLUE_SCROLL_MASTER("Clue Scrolls (master)", ACTIVITY),
LAST_MAN_STANDING("Last Man Standing"), LAST_MAN_STANDING("Last Man Standing", ACTIVITY),
ABYSSAL_SIRE("Abyssal Sire"), ABYSSAL_SIRE("Abyssal Sire", BOSS),
ALCHEMICAL_HYDRA("Alchemical Hydra"), ALCHEMICAL_HYDRA("Alchemical Hydra", BOSS),
BARROWS_CHESTS("Barrows Chests"), BARROWS_CHESTS("Barrows Chests", BOSS),
BRYOPHYTA("Bryophyta"), BRYOPHYTA("Bryophyta", BOSS),
CALLISTO("Callisto"), CALLISTO("Callisto", BOSS),
CERBERUS("Cerberus"), CERBERUS("Cerberus", BOSS),
CHAMBERS_OF_XERIC("Chambers of Xeric"), CHAMBERS_OF_XERIC("Chambers of Xeric", BOSS),
CHAMBERS_OF_XERIC_CHALLENGE_MODE("Chambers of Xeric: Challenge Mode"), CHAMBERS_OF_XERIC_CHALLENGE_MODE("Chambers of Xeric: Challenge Mode", BOSS),
CHAOS_ELEMENTAL("Chaos Elemental"), CHAOS_ELEMENTAL("Chaos Elemental", BOSS),
CHAOS_FANATIC("Chaos Fanatic"), CHAOS_FANATIC("Chaos Fanatic", BOSS),
COMMANDER_ZILYANA("Commander Zilyana"), COMMANDER_ZILYANA("Commander Zilyana", BOSS),
CORPOREAL_BEAST("Corporeal Beast"), CORPOREAL_BEAST("Corporeal Beast", BOSS),
CRAZY_ARCHAEOLOGIST("Crazy Archaeologist"), CRAZY_ARCHAEOLOGIST("Crazy Archaeologist", BOSS),
DAGANNOTH_PRIME("Dagannoth Prime"), DAGANNOTH_PRIME("Dagannoth Prime", BOSS),
DAGANNOTH_REX("Dagannoth Rex"), DAGANNOTH_REX("Dagannoth Rex", BOSS),
DAGANNOTH_SUPREME("Dagannoth Supreme"), DAGANNOTH_SUPREME("Dagannoth Supreme", BOSS),
DERANGED_ARCHAEOLOGIST("Deranged Archaeologist"), DERANGED_ARCHAEOLOGIST("Deranged Archaeologist", BOSS),
GENERAL_GRAARDOR("General Graardor"), GENERAL_GRAARDOR("General Graardor", BOSS),
GIANT_MOLE("Giant Mole"), GIANT_MOLE("Giant Mole", BOSS),
GROTESQUE_GUARDIANS("Grotesque Guardians"), GROTESQUE_GUARDIANS("Grotesque Guardians", BOSS),
HESPORI("Hespori"), HESPORI("Hespori", BOSS),
KALPHITE_QUEEN("Kalphite Queen"), KALPHITE_QUEEN("Kalphite Queen", BOSS),
KING_BLACK_DRAGON("King Black Dragon"), KING_BLACK_DRAGON("King Black Dragon", BOSS),
KRAKEN("Kraken"), KRAKEN("Kraken", BOSS),
KREEARRA("Kree'Arra"), KREEARRA("Kree'Arra", BOSS),
KRIL_TSUTSAROTH("K'ril Tsutsaroth"), KRIL_TSUTSAROTH("K'ril Tsutsaroth", BOSS),
MIMIC("Mimic"), MIMIC("Mimic", BOSS),
OBOR("Obor"), OBOR("Obor", BOSS),
SARACHNIS("Sarachnis"), SARACHNIS("Sarachnis", BOSS),
SCORPIA("Scorpia"), SCORPIA("Scorpia", BOSS),
SKOTIZO("Skotizo"), SKOTIZO("Skotizo", BOSS),
THE_GAUNTLET("The Gauntlet"), THE_GAUNTLET("The Gauntlet", BOSS),
THE_CORRUPTED_GAUNTLET("The Corrupted Gauntlet"), THE_CORRUPTED_GAUNTLET("The Corrupted Gauntlet", BOSS),
THEATRE_OF_BLOOD("Theatre of Blood"), THEATRE_OF_BLOOD("Theatre of Blood", BOSS),
THERMONUCLEAR_SMOKE_DEVIL("Thermonuclear Smoke Devil"), THERMONUCLEAR_SMOKE_DEVIL("Thermonuclear Smoke Devil", BOSS),
TZKAL_ZUK("TzKal-Zuk"), TZKAL_ZUK("TzKal-Zuk", BOSS),
TZTOK_JAD("TzTok-Jad"), TZTOK_JAD("TzTok-Jad", BOSS),
VENENATIS("Venenatis"), VENENATIS("Venenatis", BOSS),
VETION("Vet'ion"), VETION("Vet'ion", BOSS),
VORKATH("Vorkath"), VORKATH("Vorkath", BOSS),
WINTERTODT("Wintertodt"), WINTERTODT("Wintertodt", BOSS),
ZALCANO("Zalcano"), ZALCANO("Zalcano", BOSS),
ZULRAH("Zulrah"); ZULRAH("Zulrah", BOSS);
private final String name; 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) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Psikoi <https://github.com/psikoi> * Copyright (c) 2018, Psikoi <https://github.com/psikoi>
* Copyright (c) 2019, Bram91 <https://github.com/bram91>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -25,6 +26,7 @@
*/ */
package net.runelite.client.plugins.hiscore; package net.runelite.client.plugins.hiscore;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.awt.Dimension; import java.awt.Dimension;
@@ -37,9 +39,10 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Inject; 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.HiscoreEndpoint;
import net.runelite.http.api.hiscore.HiscoreResult; import net.runelite.http.api.hiscore.HiscoreResult;
import net.runelite.http.api.hiscore.HiscoreSkill; import net.runelite.http.api.hiscore.HiscoreSkill;
import static net.runelite.http.api.hiscore.HiscoreSkill.AGILITY; import static net.runelite.http.api.hiscore.HiscoreSkill.*;
import static net.runelite.http.api.hiscore.HiscoreSkill.ATTACK; import net.runelite.http.api.hiscore.HiscoreSkillType;
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 net.runelite.http.api.hiscore.Skill; import net.runelite.http.api.hiscore.Skill;
import org.apache.commons.lang3.StringUtils;
@Slf4j @Slf4j
public class HiscorePanel extends PluginPanel public class HiscorePanel extends PluginPanel
@@ -115,6 +92,27 @@ public class HiscorePanel extends PluginPanel
CONSTRUCTION, HUNTER 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 @Inject
ScheduledExecutorService executor; ScheduledExecutorService executor;
@@ -126,9 +124,8 @@ public class HiscorePanel extends PluginPanel
private final IconTextField searchBar; private final IconTextField searchBar;
private final List<JLabel> skillLabels = new ArrayList<>(); // Not an enummap because we need null keys for combat
private final Map<HiscoreSkill, JLabel> skillLabels = new HashMap<>();
private final JPanel statsPanel = new JPanel();
/* Container of all the selectable endpoints (ironman, deadman, etc) */ /* Container of all the selectable endpoints (ironman, deadman, etc) */
private final MaterialTabGroup tabGroup; private final MaterialTabGroup tabGroup;
@@ -245,15 +242,15 @@ public class HiscorePanel extends PluginPanel
c.gridy++; c.gridy++;
// Panel that holds skill icons // Panel that holds skill icons
GridLayout stats = new GridLayout(8, 3); JPanel statsPanel = new JPanel();
statsPanel.setLayout(stats); statsPanel.setLayout(new GridLayout(8, 3));
statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
statsPanel.setBorder(new EmptyBorder(5, 0, 5, 0)); 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 each skill on the ingame skill panel, create a Label and add it to the UI
for (HiscoreSkill skill : SKILLS) for (HiscoreSkill skill : SKILLS)
{ {
JPanel panel = makeSkillPanel(skill); JPanel panel = makeHiscorePanel(skill);
statsPanel.add(panel); statsPanel.add(panel);
} }
@@ -261,11 +258,11 @@ public class HiscorePanel extends PluginPanel
c.gridy++; c.gridy++;
JPanel totalPanel = new JPanel(); JPanel totalPanel = new JPanel();
totalPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
totalPanel.setLayout(new GridLayout(1, 2)); 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(makeHiscorePanel(null)); //combat has no hiscore skill, referred to as null
totalPanel.add(makeSkillPanel(OVERALL)); totalPanel.add(makeHiscorePanel(OVERALL));
add(totalPanel, c); add(totalPanel, c);
c.gridy++; c.gridy++;
@@ -276,14 +273,28 @@ public class HiscorePanel extends PluginPanel
minigamePanel.setLayout(new GridLayout(2, 3)); minigamePanel.setLayout(new GridLayout(2, 3));
minigamePanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); minigamePanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
minigamePanel.add(makeSkillPanel(CLUE_SCROLL_ALL)); minigamePanel.add(makeHiscorePanel(CLUE_SCROLL_ALL));
minigamePanel.add(makeSkillPanel(LEAGUE_POINTS)); minigamePanel.add(makeHiscorePanel(LEAGUE_POINTS));
minigamePanel.add(makeSkillPanel(LAST_MAN_STANDING)); minigamePanel.add(makeHiscorePanel(LAST_MAN_STANDING));
minigamePanel.add(makeSkillPanel(BOUNTY_HUNTER_ROGUE)); minigamePanel.add(makeHiscorePanel(BOUNTY_HUNTER_ROGUE));
minigamePanel.add(makeSkillPanel(BOUNTY_HUNTER_HUNTER)); minigamePanel.add(makeHiscorePanel(BOUNTY_HUNTER_HUNTER));
add(minigamePanel, c); add(minigamePanel, c);
c.gridy++; 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 @Override
@@ -294,24 +305,29 @@ public class HiscorePanel extends PluginPanel
} }
/* Builds a JPanel displaying an icon and level/number associated with it */ /* 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(); JLabel label = new JLabel();
label.setFont(FontManager.getRunescapeSmallFont()); label.setFont(FontManager.getRunescapeSmallFont());
label.setText("--"); label.setText(pad("--", skillType));
String skillName = (skill == null ? "combat" : skill.getName().toLowerCase()); String directory;
String directory = "/skill_icons"; if (skill == null || skill == OVERALL)
if (skillName.equals("combat") || skillName.equals("overall"))
{ {
// Cannot use SpriteManager as HiscorePlugin loads before a Client is available directory = "/skill_icons/";
directory += "/"; }
else if (skill.getType() == HiscoreSkillType.BOSS)
{
directory = "bosses/";
} }
else else
{ {
directory += "_small/"; directory = "/skill_icons_small/";
} }
String skillName = (skill == null ? "combat" : skill.name().toLowerCase());
String skillIcon = directory + skillName + ".png"; String skillIcon = directory + skillName + ".png";
log.debug("Loading skill icon from {}", skillIcon); log.debug("Loading skill icon from {}", skillIcon);
@@ -323,8 +339,8 @@ public class HiscorePanel extends PluginPanel
JPanel skillPanel = new JPanel(); JPanel skillPanel = new JPanel();
skillPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); skillPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
skillPanel.setBorder(new EmptyBorder(2, 0, 2, 0)); skillPanel.setBorder(new EmptyBorder(2, 0, 2, 0));
skillLabels.add(label); skillLabels.put(skill, label);
skillPanel.add(skillLabels.get(skillLabels.size() - 1)); skillPanel.add(label);
return skillPanel; return skillPanel;
} }
@@ -359,9 +375,13 @@ public class HiscorePanel extends PluginPanel
searchBar.setIcon(IconTextField.Icon.LOADING_DARKER); searchBar.setIcon(IconTextField.Icon.LOADING_DARKER);
loading = true; 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); label.setToolTipText(null);
} }
@@ -398,10 +418,10 @@ public class HiscorePanel extends PluginPanel
searchBar.setEditable(true); searchBar.setEditable(true);
loading = false; loading = false;
int index = 0; for (Map.Entry<HiscoreSkill, JLabel> entry : skillLabels.entrySet())
for (JLabel label : skillLabels)
{ {
HiscoreSkill skill = find(index); HiscoreSkill skill = entry.getKey();
JLabel label = entry.getValue();
Skill s; Skill s;
if (skill == null) if (skill == null)
@@ -423,7 +443,7 @@ public class HiscorePanel extends PluginPanel
else if ((s = result.getSkill(skill)) != null) else if ((s = result.getSkill(skill)) != null)
{ {
final long exp = s.getExperience(); final long exp = s.getExperience();
final boolean isSkill = SKILLS.contains(skill); final boolean isSkill = skill.getType() == HiscoreSkillType.SKILL;
int level = -1; int level = -1;
if (config.virtualLevels() && isSkill && exp > -1L) if (config.virtualLevels() && isSkill && exp > -1L)
{ {
@@ -438,12 +458,11 @@ public class HiscorePanel extends PluginPanel
if (level != -1) if (level != -1)
{ {
label.setText(Integer.toString(level)); label.setText(pad(formatLevel(level), skill.getType()));
} }
} }
label.setToolTipText(detailsHtml(result, skill)); label.setToolTipText(detailsHtml(result, skill));
index++;
} }
} }
@@ -457,37 +476,6 @@ public class HiscorePanel extends PluginPanel
this.searchBar.removeKeyListener(l); 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). Builds a html string to display on tooltip (when hovering a skill).
*/ */
@@ -584,36 +572,50 @@ public class HiscorePanel extends PluginPanel
} }
default: default:
{ {
Skill requestedSkill = result.getSkill(skill); if (skill.getType() == HiscoreSkillType.BOSS)
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"; 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 else
{ {
int currentLevel = Experience.getLevelForXp((int) experience); Skill requestedSkill = result.getSkill(skill);
remainingXp = (currentLevel + 1 <= Experience.MAX_VIRT_LEVEL) ? QuantityFormatter.formatNumber(Experience.getXpForLevel(currentLevel + 1) - experience) : "0"; 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; break;
} }
} }
} }
/** // Add a html progress bar to the hover information
* Adds a html progress bar to the hover information if (skill != null && skill.getType() == HiscoreSkillType.SKILL)
*/
if (SKILLS.contains(skill))
{ {
long experience = result.getSkill(skill).getExperience(); long experience = result.getSkill(skill).getExperience();
if (experience >= 0) if (experience >= 0)
@@ -668,4 +670,24 @@ public class HiscorePanel extends PluginPanel
} }
return HiscoreEndpoint.NORMAL; 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)); return ImageIO.read(c.getResourceAsStream(path));
} }
} }
catch (IllegalArgumentException e)
{
throw new IllegalArgumentException(path, e);
}
catch (IOException 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; 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; import org.junit.Test;
public class HiscorePanelTest 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));
}
} }