From 4f129da6987a1a9eb0df45826827ddfbc88263f7 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 27 May 2018 16:36:17 -0400 Subject: [PATCH] skill calculator: lombok some of UIActionSlot --- .../skillcalculator/SkillCalculator.java | 15 +++---- .../plugins/skillcalculator/UIActionSlot.java | 41 +++++++++++++++---- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java index 9042edf13e..8e6a864d14 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java @@ -151,7 +151,7 @@ class SkillCalculator extends JPanel double xp = 0; for (UIActionSlot slot : combinedActionSlots) - xp += slot.value; + xp += slot.getValue(); if (neededXP > 0) actionCount = (int) Math.ceil(neededXP / xp); @@ -216,12 +216,12 @@ class SkillCalculator extends JPanel if (!e.isShiftDown()) clearCombinedSlots(); - if (slot.isSelected) + if (slot.isSelected()) combinedActionSlots.remove(slot); else combinedActionSlots.add(slot); - slot.setSelected(!slot.isSelected); + slot.setSelected(!slot.isSelected()); updateCombinedAction(); } }); @@ -238,14 +238,15 @@ class SkillCalculator extends JPanel { int actionCount = 0; int neededXP = targetXP - currentXP; - double xp = (slot.action.isIgnoreBonus()) ? slot.action.getXp() : slot.action.getXp() * xpFactor; + SkillDataEntry action = slot.getAction(); + double xp = (action.isIgnoreBonus()) ? action.getXp() : action.getXp() * xpFactor; if (neededXP > 0) actionCount = (int) Math.ceil(neededXP / xp); - slot.setText("Lvl. " + slot.action.getLevel() + " (" + formatXPActionString(xp, actionCount, "exp) - ")); - slot.setAvailable(currentLevel >= slot.action.getLevel()); - slot.value = xp; + slot.setText("Lvl. " + action.getLevel() + " (" + formatXPActionString(xp, actionCount, "exp) - ")); + slot.setAvailable(currentLevel >= action.getLevel()); + slot.setValue((int) xp); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java index 640afa5af5..8a33d709cf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java @@ -39,6 +39,9 @@ import javax.swing.JPanel; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; import net.runelite.client.plugins.skillcalculator.beans.SkillDataEntry; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.FontManager; @@ -54,15 +57,27 @@ class UIActionSlot extends JPanel BorderFactory.createMatteBorder(0, 4, 0, 0, (ColorScheme.PROGRESS_ERROR_COLOR).darker()), BorderFactory.createEmptyBorder(7, 12, 7, 7)); - SkillDataEntry action; - private JShadowedLabel uiLabelActions; + private static final Border ORANGE_BORDER = new CompoundBorder( + BorderFactory.createMatteBorder(0, 4, 0, 0, (ColorScheme.PROGRESS_INPROGRESS_COLOR).darker()), + BorderFactory.createEmptyBorder(7, 12, 7, 7)); + private static final Dimension ICON_SIZE = new Dimension(32, 32); + + @Getter(AccessLevel.PACKAGE) + private final SkillDataEntry action; + private final JShadowedLabel uiLabelActions; + private final JPanel uiInfo; - boolean isAvailable = false; - boolean isSelected = false; + @Getter(AccessLevel.PACKAGE) + private boolean isAvailable; - double value = 0; + @Getter(AccessLevel.PACKAGE) + private boolean isSelected; + + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) + private int value = 0; UIActionSlot(SkillDataEntry action) { @@ -128,13 +143,13 @@ class UIActionSlot extends JPanel void setSelected(boolean selected) { isSelected = selected; - updateBackground(); + this.updateBackground(); } void setAvailable(boolean available) { isAvailable = available; - updateBackground(); + this.updateBackground(); } void setText(String text) @@ -144,8 +159,16 @@ class UIActionSlot extends JPanel private void updateBackground() { - setBorder(isAvailable ? GREEN_BORDER : RED_BORDER); - setBackground(isSelected ? ColorScheme.DARKER_GRAY_HOVER_COLOR.brighter() : ColorScheme.DARKER_GRAY_COLOR); + if (isAvailable) + { + this.setBorder(GREEN_BORDER); + } + else + { + this.setBorder(RED_BORDER); + } + + setBackground(this.isSelected() ? ColorScheme.DARKER_GRAY_HOVER_COLOR.brighter() : ColorScheme.DARKER_GRAY_COLOR); } @Override