Skip to content

Commit

Permalink
Disable locked achivements' icons
Browse files Browse the repository at this point in the history
and improve var name in group_achievements method
and fix minor typing issue
  • Loading branch information
Gatsik committed Jan 8, 2025
1 parent ff01216 commit 3dcbe14
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/playercard/achievements.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from PyQt6.QtGui import QPixmap
from PyQt6.QtWidgets import QGridLayout
from PyQt6.QtWidgets import QLabel
from PyQt6.QtWidgets import QLayout
from PyQt6.QtWidgets import QProgressBar
from PyQt6.QtWidgets import QSizePolicy
from PyQt6.QtWidgets import QVBoxLayout
from PyQt6.QtWidgets import QWidget

from src.api.models.Achievement import Achievement
Expand Down Expand Up @@ -80,6 +80,7 @@ def icon(self, icon_name: str = "") -> QPixmap:

def set_icon(self, pixmap: QPixmap) -> None:
self.iconLabel.setPixmap(pixmap)
self.iconLabel.setEnabled(self.player_achievement.current_state == State.UNLOCKED)

def on_icon_downloaded(self, _: str, pixmap: QPixmap) -> None:
self.set_icon(pixmap)
Expand All @@ -89,7 +90,7 @@ def download_icon_if_needed(self, url: str) -> None:


class AchievementsHandler:
def __init__(self, layout: QLayout, player_id: str) -> None:
def __init__(self, layout: QVBoxLayout, player_id: str) -> None:
self.player_id = player_id
self.layout = layout
self.player_achievements_api = PlayerAchievementApiAccessor()
Expand Down Expand Up @@ -156,17 +157,17 @@ def group_achievements(
self,
player_achievements: Iterator[PlayerAchievement],
) -> AchievementGroup:
unlocked, locked, included_ids = [], [], []
unlocked, locked, progressed_any_percent = [], [], []
for player_achievement in player_achievements:
included_ids.append(player_achievement.achievement.xd)
progressed_any_percent.append(player_achievement.achievement.xd)
if player_achievement.current_state == State.UNLOCKED:
unlocked.append(player_achievement)
else:
locked.append(player_achievement)
locked.extend((
self.mock_player_achievement(entry)
for entry in self.all_achievements
if entry.xd not in included_ids
if entry.xd not in progressed_any_percent
))
return AchievementGroup(locked, unlocked)

Expand Down

0 comments on commit 3dcbe14

Please sign in to comment.