F3: client Godot minimo, replay dei comandi e collaudi automatici
- Client Godot 4.7 .NET (Godot.NET.Sdk 4.7.2): menu, collegamento, partita locale con server figlio; mappa con terreno (fasce, ombreggiatura, rive curve con shader, curve di livello), opere, entità, alberi, treni interpolati con fumo; strumenti binari con profilo, stazione, deposito, segnali, demolizione; pannelli treni, linee, mercato, finanze, schede; barra superiore, minimappa, notiziario; italiano e inglese. - Pilota automatico del client e scripts/client-autopilot.sh: partita locale, linea con ponte, treni in moto e schermate (docs/screenshots). - Registro dei comandi del server (--record) e viaferrea-tools replay. - PROTOCOL.md normativo, ADR 0009, ARCHITECTURE, STATE e README aggiornati. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0191R7vXgtbAvSV4V8tj8uzL
This commit is contained in:
97 files changed
+5151
-96
No files matched your search
@@ -0,0 +1,151 @@
|
||||
using Godot;
|
||||
using ViaFerrea.Client.App;
|
||||
using ViaFerrea.Client.Net;
|
||||
using ViaFerrea.Core.Common;
|
||||
using ViaFerrea.Core.Rail;
|
||||
using static ViaFerrea.Client.App.Localization;
|
||||
|
||||
namespace ViaFerrea.Client.Panels;
|
||||
|
||||
/// <summary>Scheda dell'entità selezionata (treno, stazione, industria, città) come nel pannello destro dell'immagine 01.</summary>
|
||||
public partial class InfoPanel : VBoxContainer
|
||||
{
|
||||
public enum Kind { None, Train, Station, Industry, Town }
|
||||
|
||||
private readonly GameSession _session;
|
||||
private Kind _kind;
|
||||
private int _id = -1;
|
||||
private double _refresh;
|
||||
|
||||
public InfoPanel(GameSession session)
|
||||
{
|
||||
_session = session;
|
||||
AddThemeConstantOverride("separation", 10);
|
||||
Select(Kind.None, -1);
|
||||
}
|
||||
|
||||
public void Select(Kind kind, int id)
|
||||
{
|
||||
_kind = kind;
|
||||
_id = id;
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
_refresh += delta;
|
||||
if (_refresh < 0.5) return;
|
||||
_refresh = 0;
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
private void Rebuild()
|
||||
{
|
||||
foreach (var c in GetChildren()) c.QueueFree();
|
||||
var w = _session.World;
|
||||
switch (_kind)
|
||||
{
|
||||
case Kind.Train when w.Trains.TryGetValue(_id, out var t):
|
||||
{
|
||||
var head = PanelKit.Row();
|
||||
var title = UiTheme.TitleLabel(t.Name, 38);
|
||||
title.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
head.AddChild(title);
|
||||
if (t.Line >= 0 && w.Lines.TryGetValue(t.Line, out var line))
|
||||
{
|
||||
var badge = new CenterContainer();
|
||||
var b = UiTheme.LineBadge(line.Name);
|
||||
badge.AddChild(b);
|
||||
head.AddChild(badge);
|
||||
AddChild(head);
|
||||
string route = string.Join(" → ", line.Stops.Select(s => w.Stations.TryGetValue(s.Station.Value, out var st) ? st.Name : "?"));
|
||||
AddChild(UiTheme.Text(route, 17, bold: true));
|
||||
}
|
||||
else
|
||||
{
|
||||
AddChild(head);
|
||||
}
|
||||
var loco = t.Vehicles.Select(v => w.Vehicles.GetValueOrDefault(v)).FirstOrDefault(v => v is not null && w.Data.Vehicles.Any(d => d.Id == v.Type && d.Kind == Core.Data.VehicleKind.Locomotive));
|
||||
var locoDef = loco is null ? null : w.Data.Vehicles.First(d => d.Id == loco.Type);
|
||||
AddChild(UiTheme.Text($"{T("Locomotiva")} {locoDef?.NameIt ?? "—"} · {TrainsPanel.StateName((TrainState)t.State)}", 14, Palette.TextSecondary));
|
||||
var stats = PanelKit.Row();
|
||||
double speed = w.Motions.TryGetValue(t.Id, out var m) ? m.Speed * 3.6 : 0;
|
||||
double condition = w.Motions.TryGetValue(t.Id, out var m2) ? m2.Condition : t.Vehicles.Select(v => w.Vehicles.GetValueOrDefault(v)?.Condition ?? 100).DefaultIfEmpty(100).Min();
|
||||
stats.AddChild(PanelKit.Stat(T("Velocità"), PanelKit.Value($"{speed:0} km/h")));
|
||||
stats.AddChild(PanelKit.Stat(T("Condizione"), PanelKit.Value($"{condition:0}%")));
|
||||
stats.AddChild(PanelKit.Stat(T("Veicoli"), PanelKit.Value($"{t.Vehicles.Length}")));
|
||||
AddChild(stats);
|
||||
AddChild(PanelKit.Pair(T("Carico"), PanelKit.Value($"{t.Load} / {t.Capacity}")));
|
||||
var bar = new ProgressBar { MaxValue = Math.Max(1, t.Capacity), Value = t.Load, ShowPercentage = false, CustomMinimumSize = new Vector2(0, 10) };
|
||||
bar.AddThemeStyleboxOverride("fill", UiTheme.Box(Palette.Amber, Palette.Amber, 4, 0));
|
||||
AddChild(bar);
|
||||
if (t.Line >= 0 && w.Lines.TryGetValue(t.Line, out var l2))
|
||||
{
|
||||
for (int i = 0; i < l2.Stops.Length; i++)
|
||||
{
|
||||
var s = l2.Stops[i];
|
||||
string name = w.Stations.TryGetValue(s.Station.Value, out var st) ? st.Name : "?";
|
||||
string orders = (s.Load ? T("carica") : "") + (s.Unload ? (s.Load ? ", " : "") + T("scarica") : "")
|
||||
+ (s.WaitFull ? $", {T("attendi il pieno")} (max {s.MaxWaitDays} {T("giorni")})" : "");
|
||||
var row = PanelKit.Row();
|
||||
row.AddChild(UiTheme.Text($"{i + 1}", 14, Palette.TextSecondary, bold: true));
|
||||
var col = PanelKit.Column(0);
|
||||
col.AddChild(UiTheme.Text(name, 15, bold: true));
|
||||
col.AddChild(UiTheme.Text(orders, 13, Palette.TextSecondary));
|
||||
row.AddChild(col);
|
||||
AddChild(row);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Kind.Station when w.Stations.TryGetValue(_id, out var s):
|
||||
{
|
||||
AddChild(UiTheme.TitleLabel(s.Name, 38));
|
||||
AddChild(PanelKit.Pair(T("Binari di stazione"), PanelKit.Value($"{s.Platforms}")));
|
||||
AddChild(PanelKit.Pair(T("Merci e passeggeri in attesa"), PanelKit.Value($"{s.WaitingUnits}")));
|
||||
AddChild(UiTheme.Text(T("Nel bacino"), 14, bold: true));
|
||||
foreach (int i in s.Industries)
|
||||
if (w.Industries.TryGetValue(i, out var ind)) AddChild(UiTheme.Text($"• {ind.Name}", 13));
|
||||
foreach (int i in s.Towns)
|
||||
if (w.Towns.TryGetValue(i, out var town)) AddChild(UiTheme.Text($"• {town.Name}", 13));
|
||||
break;
|
||||
}
|
||||
case Kind.Industry when w.Industries.TryGetValue(_id, out var ind):
|
||||
{
|
||||
AddChild(UiTheme.TitleLabel(ind.Name, 38));
|
||||
var def = w.Data.Industries.FirstOrDefault(d => d.Id == ind.Type);
|
||||
AddChild(UiTheme.Text(def?.NameIt ?? ind.Type, 14, Palette.TextSecondary));
|
||||
var stats = PanelKit.Row();
|
||||
stats.AddChild(PanelKit.Stat(T("Livello"), PanelKit.Value($"{ind.Level}")));
|
||||
stats.AddChild(PanelKit.Stat(T("Efficienza"), PanelKit.Value($"{ind.Efficiency * 100:0}%")));
|
||||
stats.AddChild(PanelKit.Stat(T("Impianti"), PanelKit.Value($"{ind.Condition:0}%")));
|
||||
AddChild(stats);
|
||||
if (def is not null)
|
||||
{
|
||||
string inputs = string.Join(", ", def.Recipe.Inputs.Select(i => w.Data.Goods.First(g => g.Id == i.Good).NameIt));
|
||||
string outputs = string.Join(", ", def.Recipe.Outputs.Select(o => w.Data.Goods.First(g => g.Id == o.Good).NameIt));
|
||||
if (inputs.Length > 0) AddChild(PanelKit.Pair(T("Consuma"), PanelKit.Value(inputs)));
|
||||
AddChild(PanelKit.Pair(T("Produce"), PanelKit.Value(outputs)));
|
||||
}
|
||||
if (ind.Closed) AddChild(UiTheme.Notice(T("Chiusa")));
|
||||
break;
|
||||
}
|
||||
case Kind.Town when w.Towns.TryGetValue(_id, out var town):
|
||||
{
|
||||
AddChild(UiTheme.TitleLabel(town.Name, 38));
|
||||
AddChild(PanelKit.Pair(T("Abitanti"), PanelKit.Value(Money.GroupThousands((ulong)town.Population))));
|
||||
AddChild(PanelKit.Pair(T("Soddisfazione"), PanelKit.Value($"{town.Satisfaction * 100:0}%")));
|
||||
AddChild(PanelKit.Pair(T("Servizi"), PanelKit.Value($"{town.Services}")));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
AddChild(UiTheme.TitleLabel(T("Via Ferrea"), 38));
|
||||
var help = UiTheme.Text(T("Scegli uno strumento a sinistra oppure fai clic su un treno, una stazione, un'industria o una città per vederne la scheda."), 14, Palette.TextSecondary);
|
||||
help.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
AddChild(help);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b48ikeoeho1rb
|
||||
@@ -0,0 +1,117 @@
|
||||
using Godot;
|
||||
using ViaFerrea.Client.App;
|
||||
using ViaFerrea.Client.Net;
|
||||
using ViaFerrea.Core.Commands;
|
||||
using ViaFerrea.Core.Common;
|
||||
using ViaFerrea.Core.Rail;
|
||||
using static ViaFerrea.Client.App.Localization;
|
||||
|
||||
namespace ViaFerrea.Client.Panels;
|
||||
|
||||
/// <summary>Linee: fermate scelte con un clic sulle stazioni, nome e colore, attesa del pieno alla prima fermata.</summary>
|
||||
public partial class LinesPanel : VBoxContainer
|
||||
{
|
||||
private static readonly (string Name, string Hex)[] Colors =
|
||||
[
|
||||
("Ambra", "#e0a526"), ("Blu", "#3f86d1"), ("Rosso coppo", "#b3573e"), ("Verde", "#5fc39b"), ("Celeste", "#9cc9f2"), ("Grano", "#d9c26a"),
|
||||
];
|
||||
|
||||
private readonly GameSession _session;
|
||||
private readonly ItemList _stopsList = new() { CustomMinimumSize = new Vector2(0, 110) };
|
||||
private readonly LineEdit _name = new() { PlaceholderText = T("Nome della linea") };
|
||||
private readonly OptionButton _color = new();
|
||||
private readonly CheckBox _waitFull = new() { Text = T("Attendi il pieno alla prima fermata (max 2 giorni)") };
|
||||
private readonly ItemList _lines = new() { CustomMinimumSize = new Vector2(0, 120) };
|
||||
private readonly Label _status = UiTheme.Text("", 13, Palette.TextSecondary);
|
||||
private int _version = -1;
|
||||
|
||||
public List<int> Stops { get; } = [];
|
||||
|
||||
public event Action? StopsChanged;
|
||||
|
||||
public LinesPanel(GameSession session)
|
||||
{
|
||||
_session = session;
|
||||
AddThemeConstantOverride("separation", 8);
|
||||
AddChild(UiTheme.TitleLabel(T("Linee"), 34));
|
||||
var help = UiTheme.Text(T("Clic sulle stazioni della mappa per aggiungere le fermate in ordine; la linea torna alla prima."), 13, Palette.TextSecondary);
|
||||
help.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
AddChild(help);
|
||||
AddChild(_stopsList);
|
||||
foreach (var (name, _) in Colors) _color.AddItem(T(name));
|
||||
_color.Selected = 0;
|
||||
AddChild(_name);
|
||||
AddChild(_color);
|
||||
AddChild(_waitFull);
|
||||
var row = PanelKit.Row();
|
||||
var create = UiTheme.Primary(T("Crea linea"));
|
||||
create.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
create.Pressed += Create;
|
||||
var clear = new Button { Text = T("Svuota") };
|
||||
clear.Pressed += () =>
|
||||
{
|
||||
Stops.Clear();
|
||||
RefreshStops();
|
||||
};
|
||||
row.AddChild(create);
|
||||
row.AddChild(clear);
|
||||
AddChild(row);
|
||||
_status.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
AddChild(_status);
|
||||
AddChild(PanelKit.Separator());
|
||||
AddChild(UiTheme.Text(T("Linee della compagnia"), 14, bold: true));
|
||||
AddChild(_lines);
|
||||
}
|
||||
|
||||
public void AddStop(int station)
|
||||
{
|
||||
if (Stops.Count > 0 && Stops[^1] == station) return;
|
||||
Stops.Add(station);
|
||||
RefreshStops();
|
||||
}
|
||||
|
||||
private void RefreshStops()
|
||||
{
|
||||
_stopsList.Clear();
|
||||
for (int i = 0; i < Stops.Count; i++)
|
||||
{
|
||||
string name = _session.World.Stations.TryGetValue(Stops[i], out var s) ? s.Name : $"#{Stops[i]}";
|
||||
_stopsList.AddItem($"{i + 1}. {name}");
|
||||
}
|
||||
StopsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
var w = _session.World;
|
||||
if (w.EntityVersion == _version) return;
|
||||
_version = w.EntityVersion;
|
||||
_lines.Clear();
|
||||
int company = w.Summary?.CompanyId ?? 0;
|
||||
foreach (var l in w.Lines.Values.Where(l => l.Owner == company).OrderBy(l => l.Id))
|
||||
{
|
||||
int trains = w.Trains.Values.Count(t => t.Line == l.Id);
|
||||
string stops = string.Join(" → ", l.Stops.Select(s => w.Stations.TryGetValue(s.Station.Value, out var st) ? st.Name : "?"));
|
||||
_lines.AddItem($"{l.Name} ({trains} {T("treni")}): {stops}");
|
||||
}
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
if (Stops.Count < 2)
|
||||
{
|
||||
_status.Text = T("Servono almeno due fermate");
|
||||
return;
|
||||
}
|
||||
var stops = Stops.Select((s, i) => new LineStop(new StationId(s), WaitFull: i == 0 && _waitFull.ButtonPressed, MaxWaitDays: i == 0 && _waitFull.ButtonPressed ? 2 : 0)).ToList();
|
||||
string name = string.IsNullOrWhiteSpace(_name.Text) ? $"{T("Linea")} {_session.World.Lines.Count + 1}" : _name.Text.Trim();
|
||||
_session.Command(new CreateLineCommand(name, Colors[Math.Max(0, _color.Selected)].Hex, stops), r =>
|
||||
{
|
||||
_status.Text = r.Message;
|
||||
if (!r.Ok) return;
|
||||
Stops.Clear();
|
||||
_name.Text = "";
|
||||
RefreshStops();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c5bnynb60j4xs
|
||||
@@ -0,0 +1,56 @@
|
||||
using Godot;
|
||||
using ViaFerrea.Client.App;
|
||||
|
||||
namespace ViaFerrea.Client.Panels;
|
||||
|
||||
/// <summary>Mattoni comuni dei pannelli laterali.</summary>
|
||||
public static class PanelKit
|
||||
{
|
||||
public static VBoxContainer Column(int separation = 10)
|
||||
{
|
||||
var v = new VBoxContainer { SizeFlagsHorizontal = Control.SizeFlags.ExpandFill };
|
||||
v.AddThemeConstantOverride("separation", separation);
|
||||
return v;
|
||||
}
|
||||
|
||||
public static HBoxContainer Row(int separation = 10)
|
||||
{
|
||||
var h = new HBoxContainer { SizeFlagsHorizontal = Control.SizeFlags.ExpandFill };
|
||||
h.AddThemeConstantOverride("separation", separation);
|
||||
return h;
|
||||
}
|
||||
|
||||
/// <summary>Riga etichetta : valore.</summary>
|
||||
public static HBoxContainer Pair(string caption, Label value)
|
||||
{
|
||||
var row = Row();
|
||||
var c = UiTheme.Text(caption, 14, Palette.TextSecondary);
|
||||
c.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill;
|
||||
value.HorizontalAlignment = HorizontalAlignment.Right;
|
||||
row.AddChild(c);
|
||||
row.AddChild(value);
|
||||
return row;
|
||||
}
|
||||
|
||||
/// <summary>Riquadro statistico (velocità, affidabilità, età…) come nell'immagine 01.</summary>
|
||||
public static PanelContainer Stat(string caption, Label value)
|
||||
{
|
||||
var p = new PanelContainer { SizeFlagsHorizontal = Control.SizeFlags.ExpandFill };
|
||||
p.AddThemeStyleboxOverride("panel", UiTheme.Box(Palette.Inner, Palette.Inner, 8, 12));
|
||||
var v = Column(2);
|
||||
v.AddChild(UiTheme.Text(caption, 12, Palette.TextSecondary));
|
||||
value.AddThemeFontSizeOverride("font_size", 20);
|
||||
v.AddChild(value);
|
||||
p.AddChild(v);
|
||||
return p;
|
||||
}
|
||||
|
||||
public static Label Value(string text = "") => UiTheme.Text(text, 14, bold: true);
|
||||
|
||||
public static HSeparator Separator()
|
||||
{
|
||||
var s = new HSeparator();
|
||||
s.AddThemeStyleboxOverride("separator", UiTheme.Box(Palette.Border, Palette.Border, 0, 0));
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://lo82o2847rj3
|
||||
@@ -0,0 +1,53 @@
|
||||
using Godot;
|
||||
using ViaFerrea.Client.App;
|
||||
using ViaFerrea.Client.Map;
|
||||
using ViaFerrea.Core.Rail;
|
||||
|
||||
namespace ViaFerrea.Client.Panels;
|
||||
|
||||
/// <summary>Grafico altimetrico del tracciato: terreno, quota del binario e opere colorate (pannello TrackProfile).</summary>
|
||||
public partial class ProfileChart : Control
|
||||
{
|
||||
private TrackPlan? _plan;
|
||||
|
||||
public ProfileChart() => CustomMinimumSize = new Vector2(0, 140);
|
||||
|
||||
public void Show(TrackPlan? plan)
|
||||
{
|
||||
_plan = plan;
|
||||
QueueRedraw();
|
||||
}
|
||||
|
||||
public override void _Draw()
|
||||
{
|
||||
DrawStyleBox(UiTheme.Box(Palette.Inner, Palette.Border, 8, 0), new Rect2(Vector2.Zero, Size));
|
||||
if (_plan is not { Samples.Count: > 1 } plan) return;
|
||||
var samples = plan.Samples;
|
||||
double minH = samples.Min(s => Math.Min(s.TerrainM, s.TrackM)), maxH = samples.Max(s => Math.Max(s.TerrainM, s.TrackM));
|
||||
if (maxH - minH < 10) maxH = minH + 10;
|
||||
double length = Math.Max(1, samples[^1].S);
|
||||
var area = new Rect2(10, 10, Size.X - 20, Size.Y - 40);
|
||||
Vector2 P(double s, double h) => new(area.Position.X + (float)(s / length) * area.Size.X, area.End.Y - (float)((h - minH) / (maxH - minH)) * area.Size.Y);
|
||||
|
||||
// terreno pieno
|
||||
var ground = new List<Vector2> { new(area.Position.X, area.End.Y) };
|
||||
foreach (var s in samples) ground.Add(P(s.S, s.TerrainM));
|
||||
ground.Add(new Vector2(area.End.X, area.End.Y));
|
||||
DrawColoredPolygon(ground.ToArray(), Palette.WithAlpha(Palette.Hill, 0.55f));
|
||||
// opere sotto la linea del binario
|
||||
for (int i = 0; i < samples.Count - 1; i++)
|
||||
{
|
||||
var a = samples[i];
|
||||
var b = samples[i + 1];
|
||||
var color = ToolOverlay.WorkColor(a.Kind);
|
||||
if (a.Kind == WorkKind.Natural) continue;
|
||||
DrawRect(new Rect2(P(a.S, minH).X, area.End.Y + 6, Math.Max(1, P(b.S, minH).X - P(a.S, minH).X), 8), color);
|
||||
if (a.Kind == WorkKind.Bridge) DrawLine(P(a.S, a.TrackM), P(a.S, a.TerrainM), Palette.WithAlpha(color, 0.6f), 1.5f);
|
||||
}
|
||||
var track = samples.Select(s => P(s.S, s.TrackM)).ToArray();
|
||||
DrawPolyline(track, plan.Valid ? Palette.Amber : Palette.Danger, 2.5f, true);
|
||||
DrawString(UiTheme.Body, new Vector2(area.Position.X + 4, area.Position.Y + 12), $"{maxH:0} m", HorizontalAlignment.Left, -1, 11, Palette.TextSecondary);
|
||||
DrawString(UiTheme.Body, new Vector2(area.Position.X + 4, area.End.Y - 4), $"{minH:0} m", HorizontalAlignment.Left, -1, 11, Palette.TextSecondary);
|
||||
DrawString(UiTheme.Body, new Vector2(area.End.X - 60, Size.Y - 6), $"{length / 1000:0.0} km", HorizontalAlignment.Left, -1, 11, Palette.TextSecondary);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://d1kct34qv0wvl
|
||||
@@ -0,0 +1,150 @@
|
||||
using Godot;
|
||||
using ViaFerrea.Client.App;
|
||||
using ViaFerrea.Client.Net;
|
||||
using ViaFerrea.Core.Commands;
|
||||
using ViaFerrea.Core.Common;
|
||||
using static ViaFerrea.Client.App.Localization;
|
||||
|
||||
namespace ViaFerrea.Client.Panels;
|
||||
|
||||
/// <summary>Strumento stazione: numero di binari, nome facoltativo, costo stimato; clic sulla mappa per posarla.</summary>
|
||||
public partial class StationPanel : VBoxContainer
|
||||
{
|
||||
public SpinBox Platforms { get; } = new() { MinValue = 1, Value = 2, SizeFlagsHorizontal = SizeFlags.ExpandFill };
|
||||
public LineEdit StationName { get; } = new() { PlaceholderText = T("Nome automatico") };
|
||||
private readonly Label _cost = PanelKit.Value();
|
||||
private readonly GameSession _session;
|
||||
|
||||
public StationPanel(GameSession session)
|
||||
{
|
||||
_session = session;
|
||||
var data = session.World.Data;
|
||||
Platforms.MaxValue = data.Construction.Stations.MaxPlatforms;
|
||||
AddThemeConstantOverride("separation", 10);
|
||||
AddChild(UiTheme.TitleLabel(T("Stazione"), 34));
|
||||
AddChild(UiTheme.Text(T("Clic sulla mappa: la stazione si aggancia al binario vicino o nasce come capolinea. Il cerchio è il bacino di utenza."), 13, Palette.TextSecondary));
|
||||
AddChild(PanelKit.Pair(T("Binari di stazione"), new Label()));
|
||||
AddChild(Platforms);
|
||||
AddChild(StationName);
|
||||
AddChild(PanelKit.Pair(T("Costo"), _cost));
|
||||
Platforms.ValueChanged += _ => UpdateCost();
|
||||
UpdateCost();
|
||||
foreach (var l in GetChildren().OfType<Label>()) l.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
}
|
||||
|
||||
private void UpdateCost()
|
||||
{
|
||||
var c = _session.World.Data.Construction.Costs;
|
||||
double mult = _session.World.Summary?.CostMultiplier ?? 1;
|
||||
_cost.Text = (new Money(c.StationBase + c.StationPerPlatform * (long)Platforms.Value) * mult).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Strumento deposito: dimensione e costo; clic sulla mappa per posarlo.</summary>
|
||||
public partial class DepotPanel : VBoxContainer
|
||||
{
|
||||
public OptionButton SizeChoice { get; } = new();
|
||||
private readonly List<string> _sizes;
|
||||
|
||||
public DepotPanel(GameSession session)
|
||||
{
|
||||
var data = session.World.Data;
|
||||
_sizes = data.Construction.Costs.DepotBySize.Keys.OrderBy(k => data.Construction.Costs.DepotBySize[k]).ToList();
|
||||
double mult = session.World.Summary?.CostMultiplier ?? 1;
|
||||
foreach (string s in _sizes)
|
||||
SizeChoice.AddItem($"{T(s)} — {new Money(data.Construction.Costs.DepotBySize[s]) * mult}");
|
||||
SizeChoice.Selected = 0;
|
||||
AddThemeConstantOverride("separation", 10);
|
||||
AddChild(UiTheme.TitleLabel(T("Deposito"), 34));
|
||||
var help = UiTheme.Text(T("Clic sulla mappa vicino a un binario, poi raccordalo con lo strumento Binari. Nel deposito si comprano i veicoli e si compongono i treni."), 13, Palette.TextSecondary);
|
||||
help.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
AddChild(help);
|
||||
AddChild(SizeChoice);
|
||||
}
|
||||
|
||||
public string SelectedSize => _sizes[Math.Max(0, SizeChoice.Selected)];
|
||||
}
|
||||
|
||||
/// <summary>Testo d'aiuto per gli strumenti senza opzioni (segnali, demolizione).</summary>
|
||||
public partial class HelpPanel : VBoxContainer
|
||||
{
|
||||
public HelpPanel(string title, string help)
|
||||
{
|
||||
AddThemeConstantOverride("separation", 10);
|
||||
AddChild(UiTheme.TitleLabel(title, 34));
|
||||
var l = UiTheme.Text(help, 13, Palette.TextSecondary);
|
||||
l.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
AddChild(l);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Prezzi globali del giorno (resoconto giornaliero).</summary>
|
||||
public partial class MarketPanel : VBoxContainer
|
||||
{
|
||||
private readonly GameSession _session;
|
||||
private readonly VBoxContainer _rows = PanelKit.Column(4);
|
||||
private long _day = -1;
|
||||
|
||||
public MarketPanel(GameSession session)
|
||||
{
|
||||
_session = session;
|
||||
AddThemeConstantOverride("separation", 10);
|
||||
AddChild(UiTheme.TitleLabel(T("Mercato"), 34));
|
||||
AddChild(UiTheme.Text(T("Prezzi globali di oggi (la borsa arriva in seguito)."), 13, Palette.TextSecondary));
|
||||
AddChild(_rows);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
var digest = _session.World.LastDigest;
|
||||
if (digest is null || digest.Day == _day) return;
|
||||
_day = digest.Day;
|
||||
foreach (var c in _rows.GetChildren()) c.QueueFree();
|
||||
var goods = _session.World.Data.Goods;
|
||||
for (int g = 0; g < Math.Min(goods.Count, digest.Prices.Count); g++)
|
||||
{
|
||||
var ratio = digest.Prices[g].Cents / (double)Math.Max(1, goods[g].BasePrice);
|
||||
var value = PanelKit.Value($"{digest.Prices[g]} / {goods[g].Unit}");
|
||||
value.AddThemeColorOverride("font_color", ratio > 1.15 ? Palette.AmberLight : ratio < 0.85 ? Palette.Staff : Palette.Text);
|
||||
_rows.AddChild(PanelKit.Pair(goods[g].NameIt, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Conti della compagnia e prestiti.</summary>
|
||||
public partial class FinancePanel : VBoxContainer
|
||||
{
|
||||
private readonly GameSession _session;
|
||||
private readonly Label _cash = PanelKit.Value();
|
||||
private readonly Label _worth = PanelKit.Value();
|
||||
private readonly Label _rating = PanelKit.Value();
|
||||
private readonly SpinBox _loan = new() { MinValue = 10_000, MaxValue = 10_000_000, Step = 10_000, Value = 100_000, Prefix = "₤", SizeFlagsHorizontal = SizeFlags.ExpandFill };
|
||||
private readonly Label _status = UiTheme.Text("", 13, Palette.TextSecondary);
|
||||
|
||||
public FinancePanel(GameSession session)
|
||||
{
|
||||
_session = session;
|
||||
AddThemeConstantOverride("separation", 10);
|
||||
AddChild(UiTheme.TitleLabel(T("Finanze"), 34));
|
||||
AddChild(PanelKit.Pair(T("Cassa"), _cash));
|
||||
AddChild(PanelKit.Pair(T("Patrimonio netto"), _worth));
|
||||
AddChild(PanelKit.Pair(T("Rating"), _rating));
|
||||
AddChild(PanelKit.Separator());
|
||||
AddChild(UiTheme.Text(T("Prestito"), 14, bold: true));
|
||||
AddChild(_loan);
|
||||
var take = UiTheme.Primary(T("Chiedi il prestito"));
|
||||
take.Pressed += () => _session.Command(new TakeLoanCommand(Money.FromLire((long)_loan.Value)), r => _status.Text = r.Message);
|
||||
AddChild(take);
|
||||
_status.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
AddChild(_status);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
var w = _session.World;
|
||||
var me = w.Summary is null ? null : w.Companies.GetValueOrDefault(w.Summary.CompanyId);
|
||||
_cash.Text = (w.LastDigest?.Cash ?? me?.Cash ?? default).ToString();
|
||||
_worth.Text = (w.LastDigest?.NetWorth ?? me?.NetWorth ?? default).ToString();
|
||||
_rating.Text = w.LastDigest?.Rating ?? me?.Rating ?? "—";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bnvriayoaoihl
|
||||
@@ -0,0 +1,124 @@
|
||||
using Godot;
|
||||
using ViaFerrea.Client.App;
|
||||
using ViaFerrea.Core.Data;
|
||||
using ViaFerrea.Core.Rail;
|
||||
using ViaFerrea.Protocol.Client;
|
||||
using static ViaFerrea.Client.App.Localization;
|
||||
|
||||
namespace ViaFerrea.Client.Panels;
|
||||
|
||||
/// <summary>
|
||||
/// Strumento binari: classe, ponti, gallerie, doppio binario, elettrificazione e quota; anteprima
|
||||
/// del profilo con opere, costo e giorni (calcolata con Core come farà il server).
|
||||
/// </summary>
|
||||
public partial class TrackPanel : VBoxContainer
|
||||
{
|
||||
private readonly ClientWorld _world;
|
||||
private readonly OptionButton _class = new();
|
||||
private readonly CheckBox _bridges = new() { Text = T("Ponti"), ButtonPressed = true };
|
||||
private readonly CheckBox _tunnels = new() { Text = T("Gallerie"), ButtonPressed = true };
|
||||
private readonly CheckBox _double = new() { Text = T("Doppio binario") };
|
||||
private readonly CheckBox _electric = new() { Text = T("Elettrificato") };
|
||||
private readonly HSlider _height = new() { SizeFlagsHorizontal = SizeFlags.ExpandFill, Step = 0.5 };
|
||||
private readonly Label _heightValue = PanelKit.Value("0 m");
|
||||
private readonly ProfileChart _chart = new();
|
||||
private readonly VBoxContainer _summary = PanelKit.Column(4);
|
||||
private readonly Label _status = UiTheme.Text("", 13, Palette.TextSecondary);
|
||||
public Button Build { get; } = UiTheme.Primary(T("Costruisci"));
|
||||
public Button Cancel { get; } = new() { Text = T("Annulla") };
|
||||
|
||||
public event Action? OptionsChanged;
|
||||
|
||||
public TrackPanel(ClientWorld world)
|
||||
{
|
||||
_world = world;
|
||||
AddThemeConstantOverride("separation", 10);
|
||||
AddChild(UiTheme.TitleLabel(T("Binari"), 34));
|
||||
AddChild(UiTheme.Text(T("Clic sulla mappa per i punti del tracciato (Maiusc: senza scatto a 45°), Invio per costruire, tasto destro per annullare."), 13, Palette.TextSecondary));
|
||||
foreach (var cls in world.Data.Eras.TrackClasses)
|
||||
{
|
||||
_class.AddItem($"{cls.NameIt}", cls.Index);
|
||||
_class.SetItemDisabled(_class.ItemCount - 1, cls.From > world.Year);
|
||||
}
|
||||
_class.Selected = 0;
|
||||
AddChild(PanelKit.Pair(T("Classe"), new Label()));
|
||||
AddChild(_class);
|
||||
var flags = new GridContainer { Columns = 2 };
|
||||
flags.AddChild(_bridges);
|
||||
flags.AddChild(_tunnels);
|
||||
flags.AddChild(_double);
|
||||
flags.AddChild(_electric);
|
||||
AddChild(flags);
|
||||
double range = world.Data.Construction.Profile.HeightOffsetRangeM;
|
||||
_height.MinValue = -range;
|
||||
_height.MaxValue = range;
|
||||
AddChild(PanelKit.Pair(T("Quota rispetto al terreno"), _heightValue));
|
||||
AddChild(_height);
|
||||
var buttons = PanelKit.Row();
|
||||
Build.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
Cancel.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
buttons.AddChild(Build);
|
||||
buttons.AddChild(Cancel);
|
||||
AddChild(buttons);
|
||||
_status.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
AddChild(_status);
|
||||
AddChild(_chart);
|
||||
AddChild(_summary);
|
||||
|
||||
_class.ItemSelected += _ => OptionsChanged?.Invoke();
|
||||
foreach (var c in new[] { _bridges, _tunnels, _double, _electric }) c.Toggled += _ => OptionsChanged?.Invoke();
|
||||
_height.ValueChanged += v =>
|
||||
{
|
||||
_heightValue.Text = $"{v:+0.0;-0.0;0} m";
|
||||
OptionsChanged?.Invoke();
|
||||
};
|
||||
Show(null);
|
||||
}
|
||||
|
||||
public string TrackClass => _world.Data.Eras.TrackClasses[Math.Max(0, _class.Selected)].Id;
|
||||
public bool AllowBridges => _bridges.ButtonPressed;
|
||||
public bool AllowTunnels => _tunnels.ButtonPressed;
|
||||
public bool DoubleTrack => _double.ButtonPressed;
|
||||
public bool Electrified => _electric.ButtonPressed;
|
||||
public double HeightOffset => _height.Value;
|
||||
|
||||
public void SetStatus(string text, bool error = false)
|
||||
{
|
||||
_status.Text = text;
|
||||
_status.AddThemeColorOverride("font_color", error ? Palette.Danger : Palette.TextSecondary);
|
||||
}
|
||||
|
||||
public void Show(TrackPlan? plan)
|
||||
{
|
||||
_chart.Show(plan);
|
||||
foreach (var child in _summary.GetChildren()) child.QueueFree();
|
||||
Build.Disabled = plan is not { Valid: true };
|
||||
if (plan is null)
|
||||
{
|
||||
_summary.AddChild(UiTheme.Text(T("Nessun tracciato"), 13, Palette.TextSecondary));
|
||||
return;
|
||||
}
|
||||
_summary.AddChild(PanelKit.Pair(T("Lunghezza"), PanelKit.Value($"{plan.LengthM / 1000:0.00} km")));
|
||||
_summary.AddChild(PanelKit.Pair(T("Pendenza massima"), PanelKit.Value($"{plan.MaxGradient * 100:0.0} % / {plan.GradientLimit * 100:0.0} %")));
|
||||
_summary.AddChild(PanelKit.Pair(T("Raggio minimo"), PanelKit.Value(double.IsInfinity(plan.MinRadiusM) ? "—" : $"{plan.MinRadiusM:0} m")));
|
||||
foreach (var kind in new[] { WorkKind.Embankment, WorkKind.Cutting, WorkKind.Bridge, WorkKind.Tunnel })
|
||||
{
|
||||
double len = plan.LengthOf(kind);
|
||||
if (len <= 0) continue;
|
||||
string name = kind switch
|
||||
{
|
||||
WorkKind.Embankment => T("Rilevato"),
|
||||
WorkKind.Cutting => T("Trincea"),
|
||||
WorkKind.Bridge => T("Ponte") + (plan.BridgeType is { } b ? $" ({b})" : ""),
|
||||
_ => T("Galleria"),
|
||||
};
|
||||
_summary.AddChild(PanelKit.Pair(name, PanelKit.Value($"{len:0} m")));
|
||||
}
|
||||
var cost = PanelKit.Value(plan.TotalCost.ToString());
|
||||
cost.AddThemeColorOverride("font_color", Palette.AmberLight);
|
||||
_summary.AddChild(PanelKit.Pair(T("Costo"), cost));
|
||||
_summary.AddChild(PanelKit.Pair(T("Cantiere"), PanelKit.Value($"{plan.Days} {T("giorni")}")));
|
||||
foreach (var e in plan.Errors.Take(3)) _summary.AddChild(UiTheme.Notice(e.Message));
|
||||
foreach (var e in plan.Warnings.Take(2)) _summary.AddChild(UiTheme.Text(e.Message, 12, Palette.AmberLight));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://x2netu5v1ewj
|
||||
@@ -0,0 +1,195 @@
|
||||
using Godot;
|
||||
using ViaFerrea.Client.App;
|
||||
using ViaFerrea.Client.Net;
|
||||
using ViaFerrea.Core.Commands;
|
||||
using ViaFerrea.Core.Common;
|
||||
using ViaFerrea.Core.Data;
|
||||
using ViaFerrea.Core.Rail;
|
||||
using ViaFerrea.Protocol.Messages;
|
||||
using static ViaFerrea.Client.App.Localization;
|
||||
|
||||
namespace ViaFerrea.Client.Panels;
|
||||
|
||||
/// <summary>
|
||||
/// Treni: acquisto dei veicoli in un deposito, composizione, assegnazione alle linee, rientro.
|
||||
/// Ogni azione è un comando; la lista si aggiorna con i delta del server.
|
||||
/// </summary>
|
||||
public partial class TrainsPanel : VBoxContainer
|
||||
{
|
||||
private readonly GameSession _session;
|
||||
private readonly OptionButton _depot = new();
|
||||
private readonly OptionButton _vehicle = new();
|
||||
private readonly SpinBox _count = new() { MinValue = 1, MaxValue = 12, Value = 1 };
|
||||
private readonly ItemList _inDepot = new() { SelectMode = ItemList.SelectModeEnum.Multi, CustomMinimumSize = new Vector2(0, 120) };
|
||||
private readonly LineEdit _name = new() { PlaceholderText = T("Nome del treno") };
|
||||
private readonly ItemList _trains = new() { CustomMinimumSize = new Vector2(0, 140) };
|
||||
private readonly OptionButton _line = new();
|
||||
private readonly Label _status = UiTheme.Text("", 13, Palette.TextSecondary);
|
||||
private readonly List<int> _depotIds = [];
|
||||
private readonly List<VehicleDef> _catalog = [];
|
||||
private readonly List<int> _vehicleIds = [];
|
||||
private readonly List<int> _trainIds = [];
|
||||
private readonly List<int> _lineIds = [];
|
||||
private int _version = -1;
|
||||
|
||||
public event Action<int>? TrainSelected;
|
||||
|
||||
public TrainsPanel(GameSession session)
|
||||
{
|
||||
_session = session;
|
||||
AddThemeConstantOverride("separation", 8);
|
||||
AddChild(UiTheme.TitleLabel(T("Treni"), 34));
|
||||
AddChild(PanelKit.Pair(T("Deposito"), new Label()));
|
||||
AddChild(_depot);
|
||||
var buy = PanelKit.Row();
|
||||
_vehicle.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
buy.AddChild(_vehicle);
|
||||
buy.AddChild(_count);
|
||||
AddChild(buy);
|
||||
var buyButton = UiTheme.Primary(T("Compra veicoli"));
|
||||
buyButton.Pressed += Buy;
|
||||
AddChild(buyButton);
|
||||
AddChild(UiTheme.Text(T("Veicoli liberi nel deposito (selezione multipla, in ordine)"), 13, Palette.TextSecondary));
|
||||
AddChild(_inDepot);
|
||||
var compose = PanelKit.Row();
|
||||
_name.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
compose.AddChild(_name);
|
||||
var composeButton = new Button { Text = T("Componi") };
|
||||
composeButton.Pressed += Compose;
|
||||
compose.AddChild(composeButton);
|
||||
AddChild(compose);
|
||||
AddChild(PanelKit.Separator());
|
||||
AddChild(UiTheme.Text(T("Treni della compagnia"), 14, bold: true));
|
||||
AddChild(_trains);
|
||||
var assign = PanelKit.Row();
|
||||
_line.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
assign.AddChild(_line);
|
||||
var assignButton = new Button { Text = T("Assegna") };
|
||||
assignButton.Pressed += Assign;
|
||||
assign.AddChild(assignButton);
|
||||
AddChild(assign);
|
||||
var home = new Button { Text = T("Manda al deposito") };
|
||||
home.Pressed += SendHome;
|
||||
AddChild(home);
|
||||
_status.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
AddChild(_status);
|
||||
_depot.ItemSelected += _ => Refresh(force: true);
|
||||
_trains.ItemSelected += i => TrainSelected?.Invoke(_trainIds[(int)i]);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_session.World.EntityVersion != _version) Refresh(force: false);
|
||||
}
|
||||
|
||||
private int Company => _session.World.Summary?.CompanyId ?? 0;
|
||||
|
||||
private void Refresh(bool force)
|
||||
{
|
||||
var w = _session.World;
|
||||
_version = w.EntityVersion;
|
||||
int selectedDepot = _depot.Selected >= 0 && _depot.Selected < _depotIds.Count ? _depotIds[_depot.Selected] : -1;
|
||||
_depotIds.Clear();
|
||||
_depot.Clear();
|
||||
foreach (var d in w.Depots.Values.Where(d => d.Owner == Company).OrderBy(d => d.Id))
|
||||
{
|
||||
_depotIds.Add(d.Id);
|
||||
_depot.AddItem(d.Name);
|
||||
}
|
||||
int di = _depotIds.IndexOf(selectedDepot);
|
||||
_depot.Selected = di >= 0 ? di : _depotIds.Count > 0 ? 0 : -1;
|
||||
|
||||
if (_catalog.Count == 0 || force)
|
||||
{
|
||||
int keep = _vehicle.Selected;
|
||||
_catalog.Clear();
|
||||
_vehicle.Clear();
|
||||
foreach (var def in w.Data.Vehicles.Where(v => v.EraFrom <= w.Year && (v.EraTo is null || v.EraTo >= w.Year)))
|
||||
{
|
||||
_catalog.Add(def);
|
||||
_vehicle.AddItem($"{def.NameIt} — {new Money(def.Price)}");
|
||||
}
|
||||
_vehicle.Selected = keep >= 0 && keep < _catalog.Count ? keep : 0;
|
||||
}
|
||||
|
||||
int depot = _depot.Selected >= 0 ? _depotIds[_depot.Selected] : -1;
|
||||
_vehicleIds.Clear();
|
||||
_inDepot.Clear();
|
||||
foreach (var v in w.Vehicles.Values.Where(v => v.Owner == Company && v.Depot == depot && v.Train < 0).OrderBy(v => v.Id))
|
||||
{
|
||||
_vehicleIds.Add(v.Id);
|
||||
var def = w.Data.Vehicles.FirstOrDefault(d => d.Id == v.Type);
|
||||
_inDepot.AddItem($"{def?.NameIt ?? v.Type} #{v.Id}");
|
||||
}
|
||||
|
||||
var selectedTrain = _trains.GetSelectedItems() is { Length: > 0 } sel ? _trainIds[sel[0]] : -1;
|
||||
_trainIds.Clear();
|
||||
_trains.Clear();
|
||||
foreach (var t in w.Trains.Values.Where(t => t.Owner == Company).OrderBy(t => t.Id))
|
||||
{
|
||||
_trainIds.Add(t.Id);
|
||||
string line = t.Line >= 0 && w.Lines.TryGetValue(t.Line, out var l) ? l.Name : T("senza linea");
|
||||
_trains.AddItem($"{t.Name} · {StateName((TrainState)t.State)} · {line}");
|
||||
}
|
||||
int ti = _trainIds.IndexOf(selectedTrain);
|
||||
if (ti >= 0) _trains.Select(ti);
|
||||
|
||||
int selectedLine = _line.Selected >= 0 && _line.Selected < _lineIds.Count ? _lineIds[_line.Selected] : -1;
|
||||
_lineIds.Clear();
|
||||
_line.Clear();
|
||||
_lineIds.Add(-1);
|
||||
_line.AddItem(T("Nessuna linea"));
|
||||
foreach (var l in w.Lines.Values.Where(l => l.Owner == Company).OrderBy(l => l.Id))
|
||||
{
|
||||
_lineIds.Add(l.Id);
|
||||
_line.AddItem(l.Name);
|
||||
}
|
||||
int li = _lineIds.IndexOf(selectedLine);
|
||||
_line.Selected = li >= 0 ? li : Math.Min(1, _lineIds.Count - 1);
|
||||
}
|
||||
|
||||
public static string StateName(TrainState s) => s switch
|
||||
{
|
||||
TrainState.InDepot => T("in deposito"),
|
||||
TrainState.Moving => T("in marcia"),
|
||||
TrainState.Waiting => T("in attesa di via libera"),
|
||||
TrainState.Loading => T("in stazione"),
|
||||
TrainState.Stalled => T("fermo in salita"),
|
||||
TrainState.Broken => T("guasto"),
|
||||
TrainState.NoRoute => T("senza percorso"),
|
||||
_ => s.ToString(),
|
||||
};
|
||||
|
||||
private void Result(CommandResultMessage r) => _status.Text = r.Message;
|
||||
|
||||
private void Buy()
|
||||
{
|
||||
if (_depot.Selected < 0 || _vehicle.Selected < 0) { _status.Text = T("Serve un deposito"); return; }
|
||||
_session.Command(new BuyVehicleCommand(_catalog[_vehicle.Selected].Id, new DepotId(_depotIds[_depot.Selected]), (int)_count.Value), Result);
|
||||
}
|
||||
|
||||
private void Compose()
|
||||
{
|
||||
if (_depot.Selected < 0) return;
|
||||
var selected = _inDepot.GetSelectedItems().OrderBy(i => i).Select(i => new VehicleId(_vehicleIds[i])).ToList();
|
||||
if (selected.Count == 0) { _status.Text = T("Seleziona i veicoli da comporre"); return; }
|
||||
string? name = string.IsNullOrWhiteSpace(_name.Text) ? null : _name.Text.Trim();
|
||||
_session.Command(new ComposeTrainCommand(new DepotId(_depotIds[_depot.Selected]), selected, name), Result);
|
||||
}
|
||||
|
||||
private int SelectedTrain => _trains.GetSelectedItems() is { Length: > 0 } sel ? _trainIds[sel[0]] : -1;
|
||||
|
||||
private void Assign()
|
||||
{
|
||||
int train = SelectedTrain;
|
||||
if (train < 0 || _line.Selected < 0) { _status.Text = T("Seleziona un treno"); return; }
|
||||
_session.Command(new AssignTrainCommand(new TrainId(train), new LineId(_lineIds[_line.Selected])), Result);
|
||||
}
|
||||
|
||||
private void SendHome()
|
||||
{
|
||||
int train = SelectedTrain;
|
||||
if (train < 0 || _depot.Selected < 0) { _status.Text = T("Seleziona un treno e un deposito"); return; }
|
||||
_session.Command(new SendToDepotCommand(new TrainId(train), new DepotId(_depotIds[_depot.Selected])), Result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://s6uq2ln014q2
|
||||
Reference in new issue
Block a user