Update GuildSettings to show economy balance by default and enhance profile card generation in default.py with larger fonts, improved spacing, and adjusted layout for better visual clarity.
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run

This commit is contained in:
Valerie 2025-05-25 22:13:35 -04:00
parent 694b91b69d
commit 196505342a
2 changed files with 23 additions and 23 deletions

View file

@ -271,7 +271,7 @@ class GuildSettings(Base):
levelroles: t.Dict[int, int] = {} # Level: Role_ID
role_groups: t.Dict[int, float] = {} # Role_ID: Exp
use_embeds: bool = True # Use Embeds instead of generated images for leveling
showbal: bool = False # Show economy balance
showbal: bool = True # Show economy balance
autoremove: bool = False # Remove previous role on level up
style_override: t.Union[str, None] = None # Override the profile style for this guild

View file

@ -196,15 +196,15 @@ def generate_default_profile(
if square:
desired_card_size = (450, 450)
else:
# Keep width but adjust height for better spacing
desired_card_size = (1050, 300)
# Slightly increase height to accommodate larger fonts
desired_card_size = (1050, 320)
# Define the stats area with a modern glass effect
stats_area = (
380, # x1 - Start after profile picture (moved left slightly)
380, # x1 - Start after profile picture
15, # y1 - Start near top
1020, # x2 - End near right edge
285 # y2 - Reduced height
305 # y2 - Adjusted height
)
# Create the stats layer with glass effect
@ -248,8 +248,8 @@ def generate_default_profile(
if prestige > 0:
level_text = f"P{prestige}{level_text}"
# Use smaller font for level display to prevent overlap
level_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), 42)
# Use larger font for level display
level_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), 52) # Increased from 42
level_y = stats_area[1] + 10
# Add subtle text shadow for depth
@ -267,35 +267,35 @@ def generate_default_profile(
fill=user_color
)
# Stats section with improved layout
title_font_size = 20 # Reduced font size
value_font_size = 24 # Reduced font size
# Stats section with improved layout and larger fonts
title_font_size = 26 # Increased from 20
value_font_size = 30 # Increased from 24
title_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), title_font_size)
value_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), value_font_size)
spacing = 35 # Reduced spacing between stats
spacing = 42 # Increased from 35
# Starting positions
start_x = stats_area[0] + 15
start_y = level_y + 60 # Reduced gap after level
start_y = level_y + 65 # Adjusted for larger level font
# Helper function for stat rendering with improved spacing
def draw_stat(x_pos, y_pos, icon, title, value, color=stat_color):
# Draw icon
draw.text((x_pos, y_pos + 2), icon, font=value_font, fill=color)
# Draw title
title_x = x_pos + 30
title_x = x_pos + 35 # Increased spacing after icon
draw.text((title_x, y_pos), f"{title}:", font=title_font, fill=(200, 200, 200))
# Calculate value position
title_width = draw.textlength(f"{title}:", font=title_font)
# Draw value with shadow for depth
value_x = title_x + title_width + 5
value_x = title_x + title_width + 8 # Increased spacing between title and value
draw.text((value_x + 1, y_pos + 1), value, font=value_font, fill=(0, 0, 0, 100))
draw.text((value_x, y_pos), value, font=value_font, fill=color)
return spacing
# Draw stats in two columns with better spacing
left_column_x = start_x
right_column_x = stats_area[0] + 300
right_column_x = stats_area[0] + 320 # Adjusted for larger text
current_y = start_y
# Left column stats
@ -310,25 +310,25 @@ def generate_default_profile(
current_y += draw_stat(right_column_x, current_y, "🏆", "Rank", f"#{humanize_number(position)}")
# Progress bar with modern design - moved down
bar_width = stats_area[2] - stats_area[0] - 30 # Slightly narrower
bar_height = 25 # Slightly shorter
bar_y = stats_area[3] - 45 # Move up from bottom
bar_width = stats_area[2] - stats_area[0] - 30
bar_height = 28 # Increased from 25
bar_y = stats_area[3] - 50 # Adjusted position
progress = (current_xp - previous_xp) / (next_xp - previous_xp)
# XP text above progress bar
xp_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), 20) # Smaller font
# XP text above progress bar with larger font
xp_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), 24) # Increased from 20
xp_text = f"EXP: {humanize_number(current_xp)} / {humanize_number(next_xp)}"
xp_x = start_x + (bar_width - draw.textlength(xp_text, font=xp_font)) // 2
# Draw XP text with shadow
draw.text(
(xp_x + 1, bar_y - 25 + 1), # Moved closer to bar
(xp_x + 1, bar_y - 28 + 1), # Adjusted for larger font
xp_text,
font=xp_font,
fill=(0, 0, 0, 100)
)
draw.text(
(xp_x, bar_y - 25), # Moved closer to bar
(xp_x, bar_y - 28), # Adjusted for larger font
xp_text,
font=xp_font,
fill=(255, 255, 255)
@ -369,7 +369,7 @@ def generate_default_profile(
percent_text = f"{int(progress * 100)}%"
percent_x = start_x + (bar_width - draw.textlength(percent_text, font=xp_font)) // 2
draw.text(
(percent_x, bar_y + bar_height + 5),
(percent_x, bar_y + bar_height + 6), # Adjusted spacing
percent_text,
font=xp_font,
fill=stat_color,