skill calculator: Code cleanup
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2018, Kruithne <kruithne@gmail.com>
|
* Copyright (c) 2018, Kruithne <kruithne@gmail.com>
|
||||||
* Copyright (c) 2018, Psikoi <https://github.com/psikoi>
|
* Copyright (c) 2018, Psikoi <https://github.com/psikoi>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@@ -81,7 +81,7 @@ class SkillCalculator extends JPanel
|
|||||||
private int currentXP = Experience.getXpForLevel(currentLevel);
|
private int currentXP = Experience.getXpForLevel(currentLevel);
|
||||||
private int targetLevel = currentLevel + 1;
|
private int targetLevel = currentLevel + 1;
|
||||||
private int targetXP = Experience.getXpForLevel(targetLevel);
|
private int targetXP = Experience.getXpForLevel(targetLevel);
|
||||||
private float xpFactor = 1.0f;
|
private float xpFactor = 1;
|
||||||
|
|
||||||
SkillCalculator(Client client, UICalculatorInputArea uiInput, SpriteManager spriteManager, ItemManager itemManager)
|
SkillCalculator(Client client, UICalculatorInputArea uiInput, SpriteManager spriteManager, ItemManager itemManager)
|
||||||
{
|
{
|
||||||
@@ -145,7 +145,7 @@ class SkillCalculator extends JPanel
|
|||||||
skillData = cacheSkillData.getSkillData(calculatorType.getDataFile());
|
skillData = cacheSkillData.getSkillData(calculatorType.getDataFile());
|
||||||
|
|
||||||
// Reset the XP factor, removing bonuses.
|
// Reset the XP factor, removing bonuses.
|
||||||
xpFactor = 1.0f;
|
xpFactor = 1;
|
||||||
|
|
||||||
VarPlayer endGoalVarp = endGoalVarpForSkill(calculatorType.getSkill());
|
VarPlayer endGoalVarp = endGoalVarpForSkill(calculatorType.getSkill());
|
||||||
int endGoal = client.getVar(endGoalVarp);
|
int endGoal = client.getVar(endGoalVarp);
|
||||||
@@ -234,15 +234,17 @@ class SkillCalculator extends JPanel
|
|||||||
|
|
||||||
private void renderBonusOptions()
|
private void renderBonusOptions()
|
||||||
{
|
{
|
||||||
if (skillData.getBonuses() != null)
|
if (skillData.getBonuses() == null)
|
||||||
{
|
{
|
||||||
for (SkillDataBonus bonus : skillData.getBonuses())
|
return;
|
||||||
{
|
}
|
||||||
JPanel checkboxPanel = buildCheckboxPanel(bonus);
|
|
||||||
|
|
||||||
add(checkboxPanel);
|
for (SkillDataBonus bonus : skillData.getBonuses())
|
||||||
add(Box.createRigidArea(new Dimension(0, 5)));
|
{
|
||||||
}
|
JPanel checkboxPanel = buildCheckboxPanel(bonus);
|
||||||
|
|
||||||
|
add(checkboxPanel);
|
||||||
|
add(Box.createRigidArea(new Dimension(0, 5)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,7 +365,7 @@ class SkillCalculator extends JPanel
|
|||||||
updateCombinedAction();
|
updateCombinedAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatXPActionString(double xp, int actionCount, String expExpression)
|
private static String formatXPActionString(double xp, int actionCount, String expExpression)
|
||||||
{
|
{
|
||||||
return XP_FORMAT.format(xp) + expExpression + NumberFormat.getIntegerInstance().format(actionCount) + (actionCount > 1 ? " actions" : " action");
|
return XP_FORMAT.format(xp) + expExpression + NumberFormat.getIntegerInstance().format(actionCount) + (actionCount > 1 ? " actions" : " action");
|
||||||
}
|
}
|
||||||
@@ -389,7 +391,7 @@ class SkillCalculator extends JPanel
|
|||||||
|
|
||||||
private void adjustXPBonus(float value)
|
private void adjustXPBonus(float value)
|
||||||
{
|
{
|
||||||
xpFactor = 1f + value;
|
xpFactor = 1 + value;
|
||||||
calculate();
|
calculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,12 +451,12 @@ class SkillCalculator extends JPanel
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean slotContainsText(UIActionSlot slot, String text)
|
private static boolean slotContainsText(UIActionSlot slot, String text)
|
||||||
{
|
{
|
||||||
return slot.getAction().getName().toLowerCase().contains(text.toLowerCase());
|
return slot.getAction().getName().toLowerCase().contains(text.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
private FocusAdapter buildFocusAdapter(Consumer<FocusEvent> focusLostConsumer)
|
private static FocusAdapter buildFocusAdapter(Consumer<FocusEvent> focusLostConsumer)
|
||||||
{
|
{
|
||||||
return new FocusAdapter()
|
return new FocusAdapter()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.runelite.client.plugins.skillcalculator;
|
package net.runelite.client.plugins.skillcalculator;
|
||||||
|
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.runelite.client.plugins.skillcalculator;
|
package net.runelite.client.plugins.skillcalculator;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.runelite.client.plugins.skillcalculator;
|
package net.runelite.client.plugins.skillcalculator;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
@@ -80,7 +79,7 @@ class UIActionSlot extends JPanel
|
|||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
@Setter(AccessLevel.PACKAGE)
|
@Setter(AccessLevel.PACKAGE)
|
||||||
private double value = 0;
|
private double value;
|
||||||
|
|
||||||
UIActionSlot(SkillDataEntry action, JLabel uiIcon)
|
UIActionSlot(SkillDataEntry action, JLabel uiIcon)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.runelite.client.plugins.skillcalculator;
|
package net.runelite.client.plugins.skillcalculator;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
|||||||
Reference in New Issue
Block a user