Infrastruttura: nome «Rail Enterprise», CI e rilasci su Gitea, documentazione
Il progetto adotta il nome «Rail Enterprise» ovunque (codice RailEnterprise.*, variabili RE_*, intestazioni RESV/RECL, immagine rail-enterprise-server) per allinearsi al repository Gitea. Aggiunge Gitea Actions sul modello di Chronos: CI su PR e main, rilascio da tag con gioco Windows (client Godot + server in server/), server Windows/Linux e immagine Docker nel registro Gitea, nightly. Aggiunge i riferimenti visivi 06–09, i modelli di PR e issue, l'ADR 0014 e aggiorna README (comandi locali), STATE e CLAUDE.md. 120 test verdi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f6c2a17b4d
commit
c1a0049bcf
300 files changed
+1602
-1045
No files matched your search
@@ -0,0 +1,208 @@
|
||||
using Godot;
|
||||
using RailEnterprise.Client.App;
|
||||
using RailEnterprise.Client.Net;
|
||||
using RailEnterprise.Core.Common;
|
||||
using RailEnterprise.Core.Rail;
|
||||
using static RailEnterprise.Client.App.Localization;
|
||||
|
||||
namespace RailEnterprise.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 event Action<int>? MaintenanceRequested;
|
||||
public event Action<int>? IndustryRequested;
|
||||
|
||||
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("Manutenzione"), PanelKit.Value(MaintenancePanel.StatusName(t.Maintenance) +
|
||||
(t.Reserve ? " · " + T("riserva") : ""))));
|
||||
if (t.NextIntervention.Length > 0)
|
||||
{
|
||||
string next = w.Data.Maintenance.Interventions.FirstOrDefault(i => i.Id == t.NextIntervention)?.NameIt ?? t.NextIntervention;
|
||||
AddChild(PanelKit.Pair(T("Prossimo intervento"), PanelKit.Value(t.NextDueDays <= 0 ? $"{next} · {T("scaduto")}" : $"{next} · {T("tra")} {t.NextDueDays} {T("giorni")}")));
|
||||
}
|
||||
int trainId = t.Id;
|
||||
var cardButton = new Button { Text = T("Cartella di manutenzione") };
|
||||
cardButton.Pressed += () => MaintenanceRequested?.Invoke(trainId);
|
||||
AddChild(cardButton);
|
||||
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")));
|
||||
// pannello del proprietario (sezione 11): manutenzione degli impianti o acquisto
|
||||
int me = w.Summary?.CompanyId ?? 0;
|
||||
string owner = ind.Owner == me ? T("La tua compagnia") : ind.Owner < 0 ? T("Proprietari privati") : Fmt.Company(w, ind.Owner);
|
||||
AddChild(PanelKit.Pair(T("Proprietà"), PanelKit.Value(owner)));
|
||||
if (ind.StoppedUntilDay >= Fmt.Today(w))
|
||||
AddChild(UiTheme.Notice($"{IndustryPanel.StopName(ind.StopKind)}: {T("ferma fino al")} {Fmt.Date(w, ind.StoppedUntilDay)}"));
|
||||
int industryId = ind.Id;
|
||||
var ownerButton = new Button { Text = ind.Owner == me ? T("Gestisci l'industria") : T("Scheda del proprietario") };
|
||||
ownerButton.Pressed += () => IndustryRequested?.Invoke(industryId);
|
||||
AddChild(ownerButton);
|
||||
// dal Registro degli impieghi: presenze, posti scoperti e provenienza dei pendolari
|
||||
if (w.Employment?.Rows.FirstOrDefault(r => r.Kind == 0 && r.Industry == ind.Id) is { } row)
|
||||
{
|
||||
AddChild(UiTheme.Text(T("Lavoratori e personale"), 14, bold: true));
|
||||
AddChild(PanelKit.Pair(T("Lavoratori"), PanelKit.Value($"{row.WorkersPresent:0} / {row.JobsWorkers}")));
|
||||
AddChild(PanelKit.Pair(T("Personale"), PanelKit.Value($"{row.StaffPresent:0} / {row.JobsStaff}")));
|
||||
foreach (string reason in new[] { EmploymentPanel.ReasonText(w, row.WorkersReason, row.WorkersReasonLine, false), EmploymentPanel.ReasonText(w, row.StaffReason, row.StaffReasonLine, true) })
|
||||
{
|
||||
if (reason.Length == 0) continue;
|
||||
var l = UiTheme.Text("⚠ " + reason, 13, Palette.Amber);
|
||||
l.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
AddChild(l);
|
||||
}
|
||||
foreach (var src in row.Sources.OrderByDescending(x => x.Headcount).Take(6))
|
||||
{
|
||||
string town = w.Towns.TryGetValue(src.Town, out var tw) ? tw.Name : "?";
|
||||
string via = src.Line >= 0 && w.Lines.TryGetValue(src.Line, out var ln) ? ln.Name : T("a piedi");
|
||||
AddChild(UiTheme.Text($"• {src.Headcount} {T("da")} {town} · {via}", 13, src.Category == 1 ? Palette.Staff : Palette.Workers));
|
||||
}
|
||||
}
|
||||
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}")));
|
||||
// dove lavorano gli abitanti (posti serviti dai tuoi treni)
|
||||
if (w.Employment is { } report)
|
||||
{
|
||||
var jobs = report.Rows
|
||||
.Select(r => (Row: r, Count: r.Sources.Where(x => x.Town == town.Id).Sum(x => x.Headcount)))
|
||||
.Where(x => x.Count > 0).OrderByDescending(x => x.Count).ToList();
|
||||
if (jobs.Count > 0) AddChild(UiTheme.Text(T("Dove lavorano gli abitanti"), 14, bold: true));
|
||||
foreach (var (r, count) in jobs.Take(8))
|
||||
{
|
||||
string where = r.Kind == 1 ? (w.Depots.TryGetValue(r.Industry, out var d) ? d.Name : "?") : (w.Industries.TryGetValue(r.Industry, out var i2) ? i2.Name : "?");
|
||||
AddChild(UiTheme.Text($"• {count} · {where}", 13));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
AddChild(UiTheme.TitleLabel(T("Rail Enterprise"), 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user