From 20a0bbcd759dc3c6838056e371562fc12dc51914 Mon Sep 17 00:00:00 2001 From: m4ko Date: Mon, 31 Aug 2026 17:46:08 +0200 Subject: [PATCH] Removed player counter. --- ptlinux/ui.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/ptlinux/ui.py b/ptlinux/ui.py index 827d96f..a8b144c 100644 --- a/ptlinux/ui.py +++ b/ptlinux/ui.py @@ -94,6 +94,7 @@ DASHBOARD_TRANSITION_STEP_MILLISECONDS = 16 DASHBOARD_TRANSITION_STEPS = 9 DASHBOARD_TRANSITION_MINIMUM_OPACITY = 0.18 PRELOADER_STATUS_CHARACTERS = 64 +SERVER_POPULATION_DEBUG_KEY = "" DASHBOARD_STARTUP_COMPONENTS = frozenset( { "broadcast", @@ -223,13 +224,16 @@ def game_file_progress_status(current_file: str, verb: str) -> str: return f"{verb} {current_file}" -def server_status_presentation(status: RealmServerStatus) -> ServerStatusPresentation: +def server_status_presentation( + status: RealmServerStatus, + *, + show_player_count: bool = False, +) -> ServerStatusPresentation: if status.online is True: - players = ( - f" · {status.players_online} online" - if status.players_online is not None - else " · online" - ) + players = "" + if show_player_count and status.players_online is not None: + label = "player" if status.players_online == 1 else "players" + players = f" · {status.players_online} {label}" return ServerStatusPresentation( text=f"● {status.name}{players}", style="ServerOnline.TLabel", @@ -1395,6 +1399,7 @@ def run_dashboard(paths: AppPaths) -> None: preferred_realm = startup_settings.realm latest_server_statuses: tuple[RealmServerStatus, ...] | None = None server_status_placeholder = "Checking official server status…" + show_server_population = False launcher_update_check: LauncherUpdateCheck | None = None runtime_compatibility: RuntimeCompatibility | None = None compatibility_check_generation = 0 @@ -2225,7 +2230,10 @@ def run_dashboard(paths: AppPaths) -> None: ).pack(side="left", anchor="w") return for index, server in enumerate(visible): - presentation = server_status_presentation(server) + presentation = server_status_presentation( + server, + show_player_count=show_server_population, + ) ttk.Label( server_status_content, text=presentation.text, @@ -2246,6 +2254,18 @@ def run_dashboard(paths: AppPaths) -> None: server_status_placeholder = placeholder render_server_status() + def toggle_server_population_debug(_event: object | None = None) -> str: + nonlocal show_server_population + show_server_population = not show_server_population + render_server_status() + return "break" + + root.bind( + SERVER_POPULATION_DEBUG_KEY, + toggle_server_population_debug, + add="+", + ) + def install_realm_options(snapshot: DepotSnapshot) -> None: nonlocal available_start_options, preferred_realm catalog = launch_catalog_from_snapshot(snapshot)