Skip to content

Commit

Permalink
Fix issue when active level was not displayed.
Browse files Browse the repository at this point in the history
This was implemented as in ASkyBlock, but it is not necessary. Better to display active level.
  • Loading branch information
BONNe committed Feb 12, 2019
1 parent 6c3c097 commit 250aea2
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,7 @@ else if (currentIndex < challengesCount)
*/
private void addChallengeLevels(PanelBuilder panelBuilder, int firstItemIndex)
{
// Clone to avoid creating new level on each build.
List<LevelStatus> leftLevels = new ArrayList<>(this.levelStatusList);
leftLevels.remove(this.lastSelectedLevel);

// TODO: Focusing on middle should be awsome.

final int levelCounts = leftLevels.size();
final int levelCounts = this.levelStatusList.size();

if (levelCounts > 9)
{
Expand All @@ -297,13 +291,13 @@ private void addChallengeLevels(PanelBuilder panelBuilder, int firstItemIndex)

while (panelBuilder.nextSlot() != firstItemIndex + 9 && currentIndex < levelCounts)
{
panelBuilder.item(index++, this.getLevelButton(leftLevels.get(currentIndex++)));
panelBuilder.item(index++, this.getLevelButton(this.levelStatusList.get(currentIndex++)));
}

// Check if one challenge is left
if (currentIndex + 1 == levelCounts)
{
panelBuilder.item(index, this.getLevelButton(leftLevels.get(currentIndex)));
panelBuilder.item(index, this.getLevelButton(this.levelStatusList.get(currentIndex)));
}
else if (currentIndex < levelCounts)
{
Expand All @@ -319,7 +313,7 @@ else if (currentIndex < levelCounts)
}
else
{
for (LevelStatus level : leftLevels)
for (LevelStatus level : this.levelStatusList)
{
// there are no limitations. Just bunch insert.
panelBuilder.item(firstItemIndex++, this.getLevelButton(level));
Expand Down Expand Up @@ -380,7 +374,16 @@ private PanelItem getLevelButton(LevelStatus level)
PanelItem.ClickHandler clickHandler;
boolean glow;

if (level.isUnlocked())
if (level == this.lastSelectedLevel)
{
icon = level.getLevel().getIcon();
description = GuiUtils.stringSplit(
this.generateLevelDescription(level.getLevel(), user.getPlayer()),
this.addon.getChallengesSettings().getLoreLineLength());
clickHandler = null;
glow = true;
}
else if (level.isUnlocked())
{
icon = level.getLevel().getIcon();
description = GuiUtils.stringSplit(
Expand All @@ -389,8 +392,7 @@ private PanelItem getLevelButton(LevelStatus level)
clickHandler = (panel, user1, clickType, slot) -> {
this.lastSelectedLevel = level;

// Reset level and page index.
this.levelIndex = 0;
// Reset page index for challenges.
this.pageIndex = 0;

this.build();
Expand Down

0 comments on commit 250aea2

Please sign in to comment.