Fix drawing over click to play interface

* fix xp globe drawing on start screen and only draw once actual xp gained not logon events

* only draw fps when we have an x value for the xp orb
This commit is contained in:
Adam
2017-06-24 10:19:12 -04:00
committed by GitHub
7 changed files with 29 additions and 16 deletions

View File

@@ -31,6 +31,7 @@ class WidgetID
static final int PESTRCONTROL_GROUP_ID = 408;
static final int CLAN_CHAT_GROUP_ID = 7;
static final int MINIMAP_GROUP_ID = 160;
static final int LOGIN_CLICK_TO_PLAY_GROUP_ID = 378;
static class PestControl
{

View File

@@ -49,7 +49,9 @@ public enum WidgetInfo
BANK_ITEM_CONTAINER(WidgetID.BANK_GROUP_ID, WidgetID.Bank.ITEM_CONTAINER),
MINIMAP_XP_ORG(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.XP_ORB);
MINIMAP_XP_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.XP_ORB),
LOGIN_CLICK_TO_PLAY_SCREEN(WidgetID.LOGIN_CLICK_TO_PLAY_GROUP_ID, 0);
private final int groupId;

View File

@@ -68,13 +68,17 @@ public class FPSOverlay extends Overlay
FontMetrics fm = graphics.getFontMetrics();
String str = String.valueOf(client.getFPS());
Widget xpOrb = client.getWidget(WidgetInfo.MINIMAP_XP_ORG);
Widget xpOrb = client.getWidget(WidgetInfo.MINIMAP_XP_ORB);
if (xpOrb == null)
{
return null;
}
Rectangle2D bounds = xpOrb.getBounds().getBounds2D();
if (bounds.getX() <= 0)
{
return null;
}
int x = (int) (bounds.getX() + ((bounds.getWidth() / 2) - (fm.stringWidth(str) / 2)));
int y = (int) (bounds.getY() - (fm.getHeight() / 2));

View File

@@ -96,6 +96,12 @@ public class GroundItemsOverlay extends Overlay
return null;
}
//if the player is logged in but viewing the click to play screen exit
if (client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null)
{
return null;
}
//Widget bank = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
//if (bank != null && !bank.isHidden())
//{

View File

@@ -38,13 +38,12 @@ public class XpGlobe
private Instant time;
private double skillProgressRadius;
public XpGlobe(Skill skill, int currentXp, int currentLevel, int goalXp, Instant time)
public XpGlobe(Skill skill, int currentXp, int currentLevel, int goalXp)
{
this.skill = skill;
this.currentXp = currentXp;
this.currentLevel = currentLevel;
this.goalXp = goalXp;
this.time = time;
}
public Skill getSkill()

View File

@@ -105,13 +105,14 @@ public class XpGlobes extends Plugin
cachedGlobe.setGoalXp(goalXp);
cachedGlobe.setTime(Instant.now());
cachedGlobe.setSkillProgressRadius(startingXp, currentXp, goalXp);
this.addXpGlobe(globeCache[skillIdx], MAXIMUM_SHOWN_GLOBES);
}
else
{
globeCache[skillIdx] = new XpGlobe(skill, currentXp, currentLevel, goalXp, Instant.now());
//dont draw non cached globes, this is triggered on login to setup all of the initial values
globeCache[skillIdx] = new XpGlobe(skill, currentXp, currentLevel, goalXp);
}
this.addXpGlobe(globeCache[skillIdx], MAXIMUM_SHOWN_GLOBES);
}
public List<XpGlobe> getXpGlobes()

View File

@@ -84,20 +84,20 @@ public class XpGlobesOverlay extends Overlay
return null;
}
//check the width of the client if we can draw properly
int clientWidth = client.isResized() ? client.getClientWidth() : client.getViewportHeight();
if (clientWidth <= 0)
{
return null;
}
int queueSize = plugin.getXpGlobesSize();
if (queueSize > 0)
{
List<XpGlobe> xpChangedQueue = plugin.getXpGlobes();
int markersLength = (queueSize * (DEFAULT_CIRCLE_WIDTH)) + ((MINIMUM_STEP_WIDTH - DEFAULT_CIRCLE_WIDTH) * (queueSize - 1));
int startDrawX;
if (client.isResized())
{
startDrawX = (client.getClientWidth() - markersLength) / 2;
}
else
{
startDrawX = (client.getViewportHeight() - markersLength) / 2;
}
int startDrawX = (clientWidth - markersLength) / 2;
for (XpGlobe xpGlobe : xpChangedQueue)
{
renderProgressCircle(graphics, xpGlobe, startDrawX, DEFAULT_START_Y);