skill calculator: use accessors

This commit is contained in:
Adam
2018-05-23 19:23:11 -04:00
parent 9260deff64
commit a1a1cd2436
5 changed files with 31 additions and 22 deletions

View File

@@ -172,12 +172,12 @@ class SkillCalculator extends JPanel
private void renderBonusOptions() 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()); JPanel uiOption = new JPanel(new BorderLayout());
JLabel uiLabel = new JLabel(bonus.name); JLabel uiLabel = new JLabel(bonus.getName());
JCheckBox uiCheckbox = new JCheckBox(); JCheckBox uiCheckbox = new JCheckBox();
uiLabel.setForeground(Color.WHITE); uiLabel.setForeground(Color.WHITE);
@@ -187,7 +187,7 @@ class SkillCalculator extends JPanel
uiOption.setBackground(ColorScheme.DARKER_GRAY_COLOR); uiOption.setBackground(ColorScheme.DARKER_GRAY_COLOR);
// Adjust XP bonus depending on check-state of the boxes. // 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); uiCheckbox.setBackground(ColorScheme.MEDIUM_GRAY_COLOR);
uiOption.add(uiLabel, BorderLayout.WEST); uiOption.add(uiLabel, BorderLayout.WEST);
@@ -205,7 +205,7 @@ class SkillCalculator extends JPanel
uiActionSlots.clear(); uiActionSlots.clear();
// Create new components for the action slots. // Create new components for the action slots.
for (SkillDataEntry action : skillData.actions) for (SkillDataEntry action : skillData.getActions())
{ {
UIActionSlot slot = new UIActionSlot(action); UIActionSlot slot = new UIActionSlot(action);
uiActionSlots.add(slot); // Keep our own reference. uiActionSlots.add(slot); // Keep our own reference.
@@ -243,13 +243,13 @@ class SkillCalculator extends JPanel
{ {
int actionCount = 0; int actionCount = 0;
int neededXP = targetXP - currentXP; int neededXP = targetXP - currentXP;
double xp = slot.action.xp * xpFactor; double xp = slot.action.getXp() * xpFactor;
if (neededXP > 0) if (neededXP > 0)
actionCount = (int) Math.ceil(neededXP / xp); actionCount = (int) Math.ceil(neededXP / xp);
slot.setText("Lvl. " + slot.action.level + " (" + formatXPActionString(xp, actionCount, "exp) - ")); slot.setText("Lvl. " + slot.action.getLevel() + " (" + formatXPActionString(xp, actionCount, "exp) - "));
slot.setAvailable(currentLevel >= slot.action.level); slot.setAvailable(currentLevel >= slot.action.getLevel());
slot.value = xp; slot.value = xp;
} }
} }

View File

@@ -97,10 +97,10 @@ class UIActionSlot extends JPanel
JLabel uiIcon = new JLabel(); JLabel uiIcon = new JLabel();
if (action.icon != null) if (action.getIcon() != null)
SkillCalculator.itemManager.getImage(action.icon).addTo(uiIcon); SkillCalculator.itemManager.getImage(action.getIcon()).addTo(uiIcon);
else if (action.sprite != null) else if (action.getSprite() != null)
SkillCalculator.spriteManager.addSpriteTo(uiIcon, action.sprite, 0); SkillCalculator.spriteManager.addSpriteTo(uiIcon, action.getSprite(), 0);
uiIcon.setMinimumSize(ICON_SIZE); uiIcon.setMinimumSize(ICON_SIZE);
uiIcon.setMaximumSize(ICON_SIZE); uiIcon.setMaximumSize(ICON_SIZE);
@@ -111,7 +111,7 @@ class UIActionSlot extends JPanel
uiInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR); uiInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
uiInfo.setBorder(new EmptyBorder(0, 5, 0, 0)); uiInfo.setBorder(new EmptyBorder(0, 5, 0, 0));
JShadowedLabel uiLabelName = new JShadowedLabel(action.name); JShadowedLabel uiLabelName = new JShadowedLabel(action.getName());
uiLabelName.setForeground(Color.WHITE); uiLabelName.setForeground(Color.WHITE);
uiLabelActions = new JShadowedLabel("Unknown"); uiLabelActions = new JShadowedLabel("Unknown");

View File

@@ -24,8 +24,11 @@
*/ */
package net.runelite.client.plugins.skillcalculator.beans; package net.runelite.client.plugins.skillcalculator.beans;
import lombok.Getter;
@Getter
public class SkillData public class SkillData
{ {
public SkillDataEntry[] actions; private SkillDataEntry[] actions;
public SkillDataBonus[] bonuses; private SkillDataBonus[] bonuses;
} }

View File

@@ -24,8 +24,11 @@
*/ */
package net.runelite.client.plugins.skillcalculator.beans; package net.runelite.client.plugins.skillcalculator.beans;
import lombok.Getter;
@Getter
public class SkillDataBonus public class SkillDataBonus
{ {
public String name; private String name;
public float value; private float value;
} }

View File

@@ -24,11 +24,14 @@
*/ */
package net.runelite.client.plugins.skillcalculator.beans; package net.runelite.client.plugins.skillcalculator.beans;
import lombok.Getter;
@Getter
public class SkillDataEntry public class SkillDataEntry
{ {
public String name; private String name;
public int level; private int level;
public double xp; private double xp;
public Integer icon; private Integer icon;
public Integer sprite; private Integer sprite;
} }