using Godot; using RailEnterprise.Client.App; using static RailEnterprise.Client.App.Localization; namespace RailEnterprise.Client.Audio; /// Altoparlante nella barra superiore: apre il pannello «Audio»; barrato quando il muto è attivo. public partial class SpeakerButton : Button { public SpeakerButton() { Flat = true; CustomMinimumSize = new Vector2(40, 40); TooltipText = T("Audio (M: muto)"); Pressed += () => AudioManager.Instance?.ShowSettings(); MouseEntered += QueueRedraw; MouseExited += QueueRedraw; } public override void _EnterTree() { if (AudioManager.Instance is { } audio) audio.SettingsChanged += QueueRedraw; } public override void _ExitTree() { if (AudioManager.Instance is { } audio) audio.SettingsChanged -= QueueRedraw; } public override void _Draw() { bool muted = AudioManager.Instance?.Settings.Muted ?? false; var col = IsHovered() ? Palette.AmberLight : muted ? Palette.TextSecondary : Palette.Text; var c = Size / 2; const float w = 2f; // cassa e cono DrawColoredPolygon([c + new Vector2(-10, -4), c + new Vector2(-5, -4), c + new Vector2(1, -10), c + new Vector2(1, 10), c + new Vector2(-5, 4), c + new Vector2(-10, 4)], col); if (muted) { DrawLine(c + new Vector2(5, -5), c + new Vector2(13, 5), Palette.Danger, w); DrawLine(c + new Vector2(13, -5), c + new Vector2(5, 5), Palette.Danger, w); } else { DrawArc(c + new Vector2(1, 0), 6, -0.9f, 0.9f, 10, col, w); DrawArc(c + new Vector2(1, 0), 11, -0.9f, 0.9f, 14, col, w); } } }