Skip to content

Commit

Permalink
skill calculator: use accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed May 23, 2018
1 parent 9260def commit a1a1cd2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ private void clearCombinedSlots()

private void renderBonusOptions()
{
if (skillData.bonuses != null)
if (skillData.getBonuses() != null)
{
for (SkillDataBonus bonus : skillData.bonuses)
for (SkillDataBonus bonus : skillData.getBonuses())
{
JPanel uiOption = new JPanel(new BorderLayout());
JLabel uiLabel = new JLabel(bonus.name);
JLabel uiLabel = new JLabel(bonus.getName());
JCheckBox uiCheckbox = new JCheckBox();

uiLabel.setForeground(Color.WHITE);
Expand All @@ -187,7 +187,7 @@ private void renderBonusOptions()
uiOption.setBackground(ColorScheme.DARKER_GRAY_COLOR);

// Adjust XP bonus depending on check-state of the boxes.
uiCheckbox.addActionListener(e -> adjustXPBonus(uiCheckbox.isSelected(), bonus.value));
uiCheckbox.addActionListener(e -> adjustXPBonus(uiCheckbox.isSelected(), bonus.getValue()));
uiCheckbox.setBackground(ColorScheme.MEDIUM_GRAY_COLOR);

uiOption.add(uiLabel, BorderLayout.WEST);
Expand All @@ -205,7 +205,7 @@ private void renderActionSlots()
uiActionSlots.clear();

// Create new components for the action slots.
for (SkillDataEntry action : skillData.actions)
for (SkillDataEntry action : skillData.getActions())
{
UIActionSlot slot = new UIActionSlot(action);
uiActionSlots.add(slot); // Keep our own reference.
Expand Down Expand Up @@ -243,13 +243,13 @@ private void calculate()
{
int actionCount = 0;
int neededXP = targetXP - currentXP;
double xp = slot.action.xp * xpFactor;
double xp = slot.action.getXp() * xpFactor;

if (neededXP > 0)
actionCount = (int) Math.ceil(neededXP / xp);

slot.setText("Lvl. " + slot.action.level + " (" + formatXPActionString(xp, actionCount, "exp) - "));
slot.setAvailable(currentLevel >= slot.action.level);
slot.setText("Lvl. " + slot.action.getLevel() + " (" + formatXPActionString(xp, actionCount, "exp) - "));
slot.setAvailable(currentLevel >= slot.action.getLevel());
slot.value = xp;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public void mouseExited(MouseEvent mouseEvent)

JLabel uiIcon = new JLabel();

if (action.icon != null)
SkillCalculator.itemManager.getImage(action.icon).addTo(uiIcon);
else if (action.sprite != null)
SkillCalculator.spriteManager.addSpriteTo(uiIcon, action.sprite, 0);
if (action.getIcon() != null)
SkillCalculator.itemManager.getImage(action.getIcon()).addTo(uiIcon);
else if (action.getSprite() != null)
SkillCalculator.spriteManager.addSpriteTo(uiIcon, action.getSprite(), 0);

uiIcon.setMinimumSize(ICON_SIZE);
uiIcon.setMaximumSize(ICON_SIZE);
Expand All @@ -111,7 +111,7 @@ else if (action.sprite != null)
uiInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
uiInfo.setBorder(new EmptyBorder(0, 5, 0, 0));

JShadowedLabel uiLabelName = new JShadowedLabel(action.name);
JShadowedLabel uiLabelName = new JShadowedLabel(action.getName());
uiLabelName.setForeground(Color.WHITE);

uiLabelActions = new JShadowedLabel("Unknown");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
*/
package net.runelite.client.plugins.skillcalculator.beans;

import lombok.Getter;

@Getter
public class SkillData
{
public SkillDataEntry[] actions;
public SkillDataBonus[] bonuses;
private SkillDataEntry[] actions;
private SkillDataBonus[] bonuses;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
*/
package net.runelite.client.plugins.skillcalculator.beans;

import lombok.Getter;

@Getter
public class SkillDataBonus
{
public String name;
public float value;
private String name;
private float value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
*/
package net.runelite.client.plugins.skillcalculator.beans;

import lombok.Getter;

@Getter
public class SkillDataEntry
{
public String name;
public int level;
public double xp;
public Integer icon;
public Integer sprite;
private String name;
private int level;
private double xp;
private Integer icon;
private Integer sprite;
}

0 comments on commit a1a1cd2

Please sign in to comment.