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>
151 lines
6.5 KiB
C#
151 lines
6.5 KiB
C#
using Godot;
|
|
using RailEnterprise.Client.App;
|
|
using RailEnterprise.Client.Net;
|
|
using RailEnterprise.Core.Commands;
|
|
using RailEnterprise.Core.Common;
|
|
using static RailEnterprise.Client.App.Localization;
|
|
|
|
namespace RailEnterprise.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 ?? "—";
|
|
}
|
|
}
|