Skip to content

Commit f4651e8

Browse files
committed
BUGFIX:
- /traps board: overlapping names fixed
1 parent d5fa105 commit f4651e8

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

plugins/greenieboard/reports.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,15 @@ async def render(self, server_name: str, num_rows: int, num_landings: int, squad
344344
return
345345

346346
# Calculate dynamic figure size based on rows and columns
347-
pilot_column_width = max([len(item['name']) for item in rows]) * 0.20
347+
max_len = -1
348+
for item in rows:
349+
member = self.bot.get_member_by_ucid(item['player_ucid'])
350+
if member:
351+
item['name'] = member.display_name
352+
if len(item['name']) > max_len:
353+
max_len = len(item['name'])
354+
355+
pilot_column_width = max_len * 0.20
348356
padding = 1.0 # Padding between columns
349357
fig_width = pilot_column_width + padding + (
350358
num_columns * column_width) + 2 # Additional padding on the sides
@@ -378,12 +386,7 @@ async def render(self, server_name: str, num_rows: int, num_landings: int, squad
378386
self.axes.add_patch(plt.Rectangle((-0.5, y_position - row_height / 2), fig_width, row_height,
379387
color=odd_row_bg_color, zorder=1))
380388

381-
member = self.bot.get_member_by_ucid(row['player_ucid'])
382-
if member:
383-
name = member.display_name
384-
else:
385-
name = row['name']
386-
389+
name = row['name']
387390
self.axes.text(0, y_position, name, va='center', ha='left', fontsize=text_size, color=text_color,
388391
fontweight='bold', fontname=font_name)
389392
self.axes.text(pilot_column_width + padding, y_position, f'{row["points"]:.1f}', va='center',

0 commit comments

Comments
 (0)