skill calculator: lombok some of UIActionSlot

This commit is contained in:
Adam
2018-05-27 16:36:17 -04:00
parent 21a9bd45f7
commit 4f129da698
2 changed files with 40 additions and 16 deletions

View File

@@ -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);
}
}

View File

@@ -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