Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tray title fix #490

Merged
merged 4 commits into from
Jun 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,12 +1047,32 @@ def get_title(self, drop: TimedDrop | None) -> str:
if drop is None:
return self.TITLE
campaign = drop.campaign
return (
title = (
f"{self.TITLE}\n"
f"{campaign.game.name}\n"
f"{drop.rewards_text()} "
f"{drop.progress:.1%} ({campaign.claimed_drops}/{campaign.total_drops})"
)
if len(title) > 127: # ValueError: string too long (x, maximum length 128), but it only shows 127
min_length = 30
diff = len(title) - 127
if (len(drop.rewards_text()) - diff) >= min_length + 1: # If we can trim the drop name to 20 chars
new_length = len(drop.rewards_text()) - diff - 1 # Length - Diff - Ellipsis (…)
title = (
f"{self.TITLE}\n"
f"{campaign.game.name}\n"
f"{drop.rewards_text()[:new_length]}… "
f"{drop.progress:.1%} ({campaign.claimed_drops}/{campaign.total_drops})"
)
else: # Trimming both
new_length = len(campaign.game.name) - (diff - len(drop.rewards_text()) + min_length + 1) - 1 # Campaign name - (Remaining diff from trimmed drop name) - Ellipsis
title = (
f"{self.TITLE}\n"
f"{campaign.game.name[:new_length]}…\n"
f"{drop.rewards_text()[:min_length]}… "
f"{drop.progress:.1%} ({campaign.claimed_drops}/{campaign.total_drops})"
)
return title

def _start(self):
loop = asyncio.get_running_loop()
Expand Down