forked from unom/punktfunk
Ship the Android client's 3-tier stats-overlay semantics in every other client (design/stats-unification.md vocabulary): Off → Compact (one line: fps · e2e ms · Mb/s + loss flag) → Normal (mode + e2e p50/p95 + loss counters) → Detailed (decoder path, HDR tag, per-stage latency equation). Apple: new StatsVerbosity in PunktfunkKit persisted under punktfunk.statsVerbosity (migrates the legacy hudEnabled bool: explicit off → Off, else Normal). The existing three-finger tap (TouchMouse, trackpad/pointer modes only — touch passthrough untouched) now cycles the tiers instead of toggling, matching Android; ⌃⌥⇧S (menu + captured-state monitor) cycles the same ladder. Tiered StreamHUDView (compact glass pill / headline HUD / full equation HUD); the iOS corner disconnect also shows in Compact (the pill carries no button). Tier pickers on iOS, macOS, tvOS and the gamepad settings UI. Session stack (Linux + Windows + Deck share punktfunk-session): shared pf_client_core::trust::StatsVerbosity; Settings grows stats_verbosity with a show_stats fallback, and writes keep the legacy bool in sync so pre-tier binaries reading the same JSON agree on off vs on. Ctrl+Alt+Shift+S cycles the tier and re-renders the OSD immediately from the last stats window; the stdout stats: line always carries the full Detailed text so the shell status card and scripts keep a stable shape; --stats bumps Off → Normal without demoting a richer tier. Tier pickers in the GTK dialog, the WinUI settings page and the console-UI settings row; shortcut copy updated (GTK shortcuts window, Windows help, session README). The Windows legacy builtin path keeps its bool HUD. Tests: tier migration/round-trip in trust.rs, tiered stats_text output in pf-presenter. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
59 lines
2.5 KiB
Swift
59 lines
2.5 KiB
Swift
// The stats overlay's verbosity tier — a port of the Android client's 3-tier overlay semantics
|
|
// so the two clients feel identical: Off → Compact (one-line pill) → Normal (headline stats) →
|
|
// Detailed (plus the latency stage equation). Persisted under `DefaultsKey.statsVerbosity`;
|
|
// the in-stream cycle surfaces (⌃⌥⇧S, the three-finger tap) advance it with
|
|
// `store(current.next())`, and every UI reader observes the same default via @AppStorage.
|
|
//
|
|
// Lives in PunktfunkKit (not the app) because the kit's input paths (TouchMouse's three-finger
|
|
// tap, InputCapture's captured-state ⌃⌥⇧S) cycle it directly.
|
|
|
|
import Foundation
|
|
|
|
/// How much of the streaming statistics overlay to show. The raw values are stable on disk —
|
|
/// rename the cases freely, never the strings.
|
|
public enum StatsVerbosity: String, CaseIterable, Sendable {
|
|
case off, compact, normal, detailed
|
|
|
|
/// User-facing tier label (Settings pickers, the gamepad settings row).
|
|
public var label: String {
|
|
switch self {
|
|
case .off: return "Off"
|
|
case .compact: return "Compact"
|
|
case .normal: return "Normal"
|
|
case .detailed: return "Detailed"
|
|
}
|
|
}
|
|
|
|
/// The next tier in the cycle: off → compact → normal → detailed → off (wrapping) —
|
|
/// the ⌃⌥⇧S / three-finger-tap order, same as Android.
|
|
public func next() -> StatsVerbosity {
|
|
switch self {
|
|
case .off: return .compact
|
|
case .compact: return .normal
|
|
case .normal: return .detailed
|
|
case .detailed: return .off
|
|
}
|
|
}
|
|
|
|
/// The persisted tier. When `statsVerbosity` has never been written, migrates from the
|
|
/// legacy `hudEnabled` bool the pre-tiered clients stored: absent-or-true → `.normal`
|
|
/// (the old "on" look minus the equation lines), explicit false → `.off`.
|
|
public static var current: StatsVerbosity {
|
|
let defaults = UserDefaults.standard
|
|
if let raw = defaults.string(forKey: DefaultsKey.statsVerbosity),
|
|
let tier = StatsVerbosity(rawValue: raw) {
|
|
return tier
|
|
}
|
|
if let legacy = defaults.object(forKey: DefaultsKey.hudEnabled) as? Bool, !legacy {
|
|
return .off
|
|
}
|
|
return .normal
|
|
}
|
|
|
|
/// Persist a tier (the cycle surfaces write through here; the Settings pickers write the
|
|
/// same key via @AppStorage).
|
|
public static func store(_ tier: StatsVerbosity) {
|
|
UserDefaults.standard.set(tier.rawValue, forKey: DefaultsKey.statsVerbosity)
|
|
}
|
|
}
|