Perform LevelStatus improvements in ChallengesGUI.

This commit is contained in:
BONNe 2019-01-22 09:12:12 +02:00
parent 8711d7ad08
commit 20dfc6a760
1 changed files with 58 additions and 47 deletions

View File

@ -48,7 +48,18 @@ public class ChallengesGUI extends CommonGUI
this.challengesManager = this.addon.getChallengesManager();
this.levelStatusList = this.challengesManager.getChallengeLevelStatus(this.user, this.world);
this.lastSelectedLevel = this.levelStatusList.get(0);
for (int i = 0; i < this.levelStatusList.size(); i++)
{
if (this.levelStatusList.get(i).isUnlocked())
{
this.lastSelectedLevel = this.levelStatusList.get(i);
}
else
{
break;
}
}
}
// ---------------------------------------------------------------------
@ -171,6 +182,8 @@ public class ChallengesGUI extends CommonGUI
* @param panelBuilder where last selected level challenges must be added.
*/
private void addChallenges(PanelBuilder panelBuilder)
{
if (this.lastSelectedLevel != null)
{
List<Challenges> challenges = this.challengesManager.getChallenges(this.lastSelectedLevel.getLevel());
final int challengesCount = challenges.size();
@ -224,6 +237,7 @@ public class ChallengesGUI extends CommonGUI
}
}
}
}
/**
@ -497,13 +511,10 @@ public class ChallengesGUI extends CommonGUI
{
icon = new ItemStack(Material.BOOK);
// This should be safe as first level always should be unlocked.
LevelStatus previousLevel = this.levelStatusList.get(this.levelStatusList.indexOf(level) - 1);
description = Collections.singletonList(
this.user.getTranslation("challenges.to-complete",
"[challengesToDo]", Integer.toString(previousLevel.getNumberOfChallengesStillToDo()),
"[thisLevel]", previousLevel.getLevel().getFriendlyName()));
"[challengesToDo]", Integer.toString(level.getNumberOfChallengesStillToDo()),
"[thisLevel]", level.getPreviousLevel().getFriendlyName()));
clickHandler = null;
}