Il client ora ha l'audio della F6 senza file esterni né download: effetti, anelli d'ambiente e temi musicali si sintetizzano in memoria all'avvio, su un altro thread, con classi senza dipendenze da Godot (Synth, MusicComposer, AudioMix) e semi fissi. - Bus Master, Music, Ambience, Sfx, Ui creati da codice in modo idempotente, limitatore sul Master; volumi per bus e muto in user://settings.cfg; pannello «Audio» dal menu e dall'altoparlante della barra superiore, tasto M. - AudioManager (figlio di Main) reagisce solo a ciò che il client riceve: clic dei pulsanti, esiti dei comandi, notifiche per gravità, cantieri completati dal DailyDigest, fischio o tromba all'arrivo in stazione, fino a 3 treni vicini al centro con rotolamento, motore e sbuffi modulati dalla velocità, ambiente dal terreno visibile e dallo zoom, tema per era con dissolvenza. - Nessuna allocazione nel ciclo per fotogramma; audio spento nel pilota automatico e senza schermo. - ADR 0022, STATE e ARCHITECTURE aggiornati; testi in strings.csv. Non ascoltato: Godot non è eseguibile qui. Funzioni pure provate a parte. Refs #46. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
2.7 KiB
C#
61 lines
2.7 KiB
C#
using Godot;
|
|
using RailEnterprise.Client.App;
|
|
using static RailEnterprise.Client.App.Localization;
|
|
|
|
namespace RailEnterprise.Client.Screens;
|
|
|
|
/// <summary>Menu iniziale: partita locale (server figlio), collegamento a un server, lingua, audio, uscita.</summary>
|
|
public partial class MenuScreen : Control
|
|
{
|
|
public event Action? LocalGame;
|
|
public event Action? ConnectToServer;
|
|
public event Action<string>? LanguageChanged;
|
|
public event Action? AudioRequested;
|
|
private readonly Label _status = UiTheme.Text("", 14, Palette.TextSecondary);
|
|
|
|
public override void _Ready()
|
|
{
|
|
// già nell'albero: ancore e margini insieme, altrimenti la schermata resterebbe grande zero
|
|
SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
|
UiTheme.Apply(this);
|
|
var bg = new ColorRect { Color = Palette.AppBackground };
|
|
bg.SetAnchorsPreset(LayoutPreset.FullRect);
|
|
AddChild(bg);
|
|
var center = new CenterContainer();
|
|
center.SetAnchorsPreset(LayoutPreset.FullRect);
|
|
AddChild(center);
|
|
var col = new VBoxContainer { CustomMinimumSize = new Vector2(440, 0) };
|
|
col.AddThemeConstantOverride("separation", 14);
|
|
center.AddChild(col);
|
|
col.AddChild(UiTheme.TitleLabel("Rail Enterprise", 96));
|
|
col.AddChild(UiTheme.Text(T("Gestionale ferroviario dall'alto"), 18, Palette.TextSecondary));
|
|
col.AddChild(new Control { CustomMinimumSize = new Vector2(0, 20) });
|
|
var local = UiTheme.Primary(T("Partita locale"));
|
|
local.CustomMinimumSize = new Vector2(0, 48);
|
|
local.Pressed += () => LocalGame?.Invoke();
|
|
col.AddChild(local);
|
|
var remote = new Button { Text = T("Collegati a un server"), CustomMinimumSize = new Vector2(0, 48) };
|
|
remote.Pressed += () => ConnectToServer?.Invoke();
|
|
col.AddChild(remote);
|
|
var lang = new HBoxContainer();
|
|
lang.AddThemeConstantOverride("separation", 8);
|
|
foreach (var (code, label) in new[] { ("it", "Italiano"), ("en", "English") })
|
|
{
|
|
var b = new Button { Text = label, ToggleMode = true, ButtonPressed = TranslationServer.GetLocale().StartsWith(code) };
|
|
b.Pressed += () => LanguageChanged?.Invoke(code);
|
|
lang.AddChild(b);
|
|
}
|
|
var audio = new Button { Text = T("Audio"), ToggleMode = false };
|
|
audio.Pressed += () => AudioRequested?.Invoke();
|
|
lang.AddChild(audio);
|
|
col.AddChild(lang);
|
|
var quit = new Button { Text = T("Esci"), CustomMinimumSize = new Vector2(0, 40) };
|
|
quit.Pressed += () => GetTree().Quit();
|
|
col.AddChild(quit);
|
|
_status.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
|
col.AddChild(_status);
|
|
}
|
|
|
|
public void SetStatus(string text) => _status.Text = text;
|
|
}
|