skillcalculator: Don't clear fields when re-loading current skill

Previously, clicking on the active calculator's skill would reset the
goal level and experience text input fields. This commit prevents that
reset when selecting the already-active skill, and only resets them when
viewing a different skill's calculator.
This commit is contained in:
Daniel
2020-03-17 17:34:46 -04:00
committed by GitHub
parent 9ac4592a63
commit 84a23cb59d

View File

@@ -74,6 +74,7 @@ class SkillCalculator extends JPanel
private final IconTextField searchBar = new IconTextField();
private SkillData skillData;
private Skill currentSkill;
private int currentLevel = 1;
private int currentXP = Experience.getXpForLevel(currentLevel);
private int targetLevel = currentLevel + 1;
@@ -123,15 +124,20 @@ class SkillCalculator extends JPanel
void openCalculator(CalculatorType calculatorType)
{
// Update internal skill/XP values.
currentXP = client.getSkillExperience(calculatorType.getSkill());
currentLevel = Experience.getLevelForXp(currentXP);
if (currentSkill != calculatorType.getSkill())
{
currentSkill = calculatorType.getSkill();
// Load the skill data.
skillData = cacheSkillData.getSkillData(calculatorType.getDataFile());
// Reset the XP factor, removing bonuses.
xpFactor = 1.0f;
// Update internal skill/XP values.
currentXP = client.getSkillExperience(calculatorType.getSkill());
currentLevel = Experience.getLevelForXp(currentXP);
VarPlayer endGoalVarp = endGoalVarpForSkill(calculatorType.getSkill());
int endGoal = client.getVar(endGoalVarp);
if (endGoal != -1)
@@ -165,6 +171,7 @@ class SkillCalculator extends JPanel
// Create action slots for the skill actions.
renderActionSlots();
}
// Update the input fields.
updateInputFields();