Search in sources :

Example 1 with ProgressBarComponent

use of net.runelite.client.ui.overlay.components.ProgressBarComponent in project runelite by runelite.

the class XpGlobesOverlay method drawTooltipIfMouseover.

private void drawTooltipIfMouseover(Graphics2D graphics, XpGlobe mouseOverSkill, Ellipse2D drawnGlobe) {
    Point mouse = client.getMouseCanvasPosition();
    int mouseX = mouse.getX();
    int mouseY = mouse.getY();
    if (!drawnGlobe.contains(mouseX, mouseY)) {
        return;
    }
    // draw tooltip under the globe of the mouse location
    int x = (int) drawnGlobe.getX() - (TOOLTIP_RECT_SIZE_X / 2) + (config.xpOrbSize() / 2);
    int y = (int) drawnGlobe.getY() + config.xpOrbSize() + 10;
    String skillName = mouseOverSkill.getSkillName();
    String skillLevel = Integer.toString(mouseOverSkill.getCurrentLevel());
    DecimalFormat decimalFormat = new DecimalFormat("###,###,###");
    String skillCurrentXp = decimalFormat.format(mouseOverSkill.getCurrentXp());
    PanelComponent xpTooltip = new PanelComponent();
    xpTooltip.setPosition(new java.awt.Point(x, y));
    xpTooltip.setWidth(TOOLTIP_RECT_SIZE_X);
    List<PanelComponent.Line> lines = xpTooltip.getLines();
    lines.add(new PanelComponent.Line(skillName, Color.WHITE, skillLevel, Color.WHITE));
    lines.add(new PanelComponent.Line("Current xp:", Color.ORANGE, skillCurrentXp, Color.WHITE));
    if (mouseOverSkill.getGoalXp() != -1) {
        String skillXpToLvl = decimalFormat.format(mouseOverSkill.getGoalXp() - mouseOverSkill.getCurrentXp());
        lines.add(new PanelComponent.Line("Xp to level:", Color.ORANGE, skillXpToLvl, Color.WHITE));
        // Create progress bar for skill.
        ProgressBarComponent progressBar = new ProgressBarComponent();
        double progress = mouseOverSkill.getSkillProgress(Experience.getXpForLevel(mouseOverSkill.getCurrentLevel()), mouseOverSkill.getCurrentXp(), mouseOverSkill.getGoalXp());
        progressBar.setProgress(progress);
        xpTooltip.setProgressBar(progressBar);
    }
    xpTooltip.render(graphics);
}
Also used : DecimalFormat(java.text.DecimalFormat) PanelComponent(net.runelite.client.ui.overlay.components.PanelComponent) Point(net.runelite.api.Point) Point(net.runelite.api.Point) ProgressBarComponent(net.runelite.client.ui.overlay.components.ProgressBarComponent)

Aggregations

DecimalFormat (java.text.DecimalFormat)1 Point (net.runelite.api.Point)1 PanelComponent (net.runelite.client.ui.overlay.components.PanelComponent)1 ProgressBarComponent (net.runelite.client.ui.overlay.components.ProgressBarComponent)1