UI/UX: Improve visual clarity and consistency
- Align status bars with label padding (HP, Stamina, XP) - Add clear combat turn indicators (YOUR TURN / ENEMY TURN) - Display HP/Stamina bars in inventory menu and usage - Add consistent separators between sections - Improve feedback for item usage with visible stat changes Files modified: - bot/utils.py: Added label_width parameter to format_stat_bar() - bot/combat.py: Turn headers and separators - bot/inventory_handlers.py: HP/Stamina display - bot/action_handlers.py: Separator placement fix See docs/development/UI_UX_IMPROVEMENTS.md for details
This commit is contained in:
11
bot/utils.py
11
bot/utils.py
@@ -43,7 +43,7 @@ def create_progress_bar(current: int, maximum: int, length: int = 10, filled_cha
|
||||
return filled_char * filled_length + empty_char * empty_length
|
||||
|
||||
|
||||
def format_stat_bar(label: str, emoji: str, current: int, maximum: int, bar_length: int = 10) -> str:
|
||||
def format_stat_bar(label: str, emoji: str, current: int, maximum: int, bar_length: int = 10, label_width: int = 7) -> str:
|
||||
"""
|
||||
Format a stat (HP, Stamina, etc.) with visual progress bar.
|
||||
|
||||
@@ -53,20 +53,25 @@ def format_stat_bar(label: str, emoji: str, current: int, maximum: int, bar_leng
|
||||
current: Current value
|
||||
maximum: Maximum value
|
||||
bar_length: Length of the progress bar
|
||||
label_width: Width to pad label to for alignment (default 7)
|
||||
|
||||
Returns:
|
||||
Formatted string with bar and percentage
|
||||
|
||||
Examples:
|
||||
>>> format_stat_bar("HP", "❤️", 75, 100)
|
||||
"❤️ HP: ███████░░░ 75% (75/100)"
|
||||
"❤️ HP: ███████░░░ 75% (75/100)"
|
||||
>>> format_stat_bar("Stamina", "⚡", 50, 100)
|
||||
"⚡ Stamina: █████░░░░░ 50% (50/100)"
|
||||
"""
|
||||
bar = create_progress_bar(current, maximum, bar_length)
|
||||
percentage = int((current / maximum * 100)) if maximum > 0 else 0
|
||||
|
||||
return f"{emoji} {label}: {bar} {percentage}% ({current}/{maximum})"
|
||||
# Pad label for alignment
|
||||
padded_label = f"{label}:".ljust(label_width + 1)
|
||||
|
||||
return f"{emoji} {padded_label} {bar} {percentage}% ({current}/{maximum})"
|
||||
|
||||
|
||||
|
||||
def get_admin_ids():
|
||||
|
||||
Reference in New Issue
Block a user