F6: tooltip perché sui valori calcolati dal server
Ogni valore importante dei pannelli spiega al passaggio del mouse da dove viene: formula, termini con i valori di oggi e note, calcolati dal Core e mandati dal server, perché il client non deve rifare né ricomporre formule. - Core: modello comune Explanation ed Explanations, pure funzioni che chiamano le stesse funzioni del motore; estratte senza cambiare l'aritmetica (hash invariati) Market.NextPrice e LocalPriceTerms, Tariffs.FreightTerms e PassengerTerms, TownSystem.GrowthOf, Fleet.DailyHazard, GameClock.YearsAt; Industry.LastEfficiency transitorio (né salvato né nell'hash). - Protocollo: RequestDetail kind 11 con un blocco 1 (subject, arg) ed ExplanationReport 137; il server risponde sempre, anche con available falso. Nessun campo nei delta, formato dei salvataggi invariato. - Client: WhyTooltip comune (palette 05, apertura dopo 0,45 s, «in arrivo…» finché la spiegazione manca) su barra superiore, Mercato, Scalata, Finanze, scheda industria, Treni e Officine; testi in strings.csv. - ADR 0024, PROTOCOL.md, ARCHITECTURE.md, STATE.md; 10 test nuovi in Economy/ExplanationTests.cs con uguaglianza esatta ai valori del motore. Refs #44. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
767661957b
commit
19a3dd3af1
33 files changed
+2089
-64
No files matched your search
@@ -825,3 +825,229 @@ Interfaccia,,Interface
|
||||
Muto,,Mute
|
||||
Il tasto M attiva e toglie il muto durante la partita.,,The M key toggles mute during the game.
|
||||
Audio (M: muto),,Audio (M: mute)
|
||||
Perché questo valore,,Why this value
|
||||
in arrivo…,,on its way…
|
||||
aggiornamento in arrivo…,,update on its way…
|
||||
motore,,engine
|
||||
freni,,brakes
|
||||
cassa,,body
|
||||
Valore non disponibile.,,Value not available.
|
||||
Avanzamento del livello,,Level progress
|
||||
Prezzo globale,,Global price
|
||||
Prezzo base,,Base price
|
||||
Prezzo iniziale: il prezzo base del bene.,,Starting price: the good's base price.
|
||||
Bene non ancora in commercio: il prezzo resta quello di partenza.,,Good not yet on the market: the price stays at its starting value.
|
||||
Prezzo di ieri,,Yesterday's price
|
||||
Domanda della regione (finestra),,Regional demand (window)
|
||||
Offerta della regione (finestra),,Regional supply (window)
|
||||
Prezzo mondiale,,World price
|
||||
Scambi con il resto del mondo,,Trade with the rest of the world
|
||||
Rapporto domanda / offerta (con il mondo),,Demand / supply ratio (with the world)
|
||||
Sensibilità al rapporto,,Sensitivity to the ratio
|
||||
Prezzo minimo,,Minimum price
|
||||
Prezzo massimo,,Maximum price
|
||||
Prezzo obiettivo,,Target price
|
||||
Peso del giorno,,Weight of the day
|
||||
"D e S comprendono gli scambi con il resto del mondo al prezzo mondiale, che segue il ciclo economico e gli shock.",,"D and S include trade with the rest of the world at the world price, which follows the business cycle and shocks."
|
||||
Il prezzo è cambiato dopo l'ultimo passo del mercato.,,The price changed after the last market step.
|
||||
Prezzo locale,,Local price
|
||||
"Prezzo a cui l'industria compra la prossima unità: Dl è la scorta desiderata dell'ingresso, Sl la scorta.",,"Price at which the industry buys the next unit: Dl is the desired input stock, Sl the stock."
|
||||
"Prezzo a cui l'industria vende la prossima unità: Dl è lo spazio libero del magazzino, Sl la giacenza.",,"Price at which the industry sells the next unit: Dl is the free warehouse space, Sl the stock on hand."
|
||||
Domanda locale,,Local demand
|
||||
Offerta locale,,Local supply
|
||||
Peso dello squilibrio,,Weight of the imbalance
|
||||
Correzione per scorte nulle,,Correction for empty stock
|
||||
Scarto massimo dal prezzo globale,,Maximum deviation from the global price
|
||||
Squilibrio locale,,Local imbalance
|
||||
Fattore locale,,Local factor
|
||||
Tariffa merci,,Freight fare
|
||||
Tariffa di una unità consegnata nel tempo atteso; tf scende dopo la soglia di ritardo fino al minimo.,,Fare for one unit delivered in the expected time; tf falls after the lateness threshold down to the minimum.
|
||||
Nessun treno della linea collega la tratta con questo bene: il tempo atteso non è noto e tf vale 1.,,No train on the line links the stretch with this good: the expected time is unknown and tf is 1.
|
||||
tariffa = u × Tb × (a + b·Pg/Pb) × km^e × tf × d,,fare = u × Tb × (a + b·Pg/Pb) × km^e × tf × d
|
||||
Unità,,Units
|
||||
Tariffa base,,Base fare
|
||||
Quota fissa,,Fixed part
|
||||
Quota legata al prezzo,,Price-linked part
|
||||
Fattore del prezzo,,Price factor
|
||||
Distanza in linea d'aria,,Straight-line distance
|
||||
Esponente della distanza,,Distance exponent
|
||||
Fattore della distanza,,Distance factor
|
||||
Puntualità,,Punctuality
|
||||
Moltiplicatore della difficoltà,,Difficulty multiplier
|
||||
Tempo atteso,,Expected time
|
||||
soglia,,threshold
|
||||
Soglia di ritardo (volte il tempo atteso),,Lateness threshold (times the expected time)
|
||||
Puntualità minima,,Minimum punctuality
|
||||
Puntualità a due volte il tempo atteso,,Punctuality at twice the expected time
|
||||
tariffa 2×,,fare 2×
|
||||
Tariffa a due volte il tempo atteso,,Fare at twice the expected time
|
||||
Tariffa passeggeri,,Passenger fare
|
||||
Tariffa di un posto consegnato nel tempo atteso; tf scende dopo la soglia di ritardo fino al minimo.,,Fare for one seat delivered in the expected time; tf falls after the lateness threshold down to the minimum.
|
||||
Nessun treno sulla linea: il comfort delle carrozze vale 1.,,No train on the line: carriage comfort is 1.
|
||||
Nessun treno della linea collega la tratta per questa classe: il tempo atteso non è noto e tf vale 1.,,No train on the line links the stretch for this class: the expected time is unknown and tf is 1.
|
||||
Tariffa del personale,,Staff fare
|
||||
Tariffa dei lavoratori,,Workers' fare
|
||||
tariffa = p × Tp × km^e × classe × tf × d × comfort,,fare = p × Tp × km^e × class × tf × d × comfort
|
||||
Posti,,Seats
|
||||
Tariffa base per posto,,Base fare per seat
|
||||
classe,,class
|
||||
Moltiplicatore della classe,,Class multiplier
|
||||
Comfort delle carrozze,,Carriage comfort
|
||||
senza comfort,,no comfort
|
||||
Tariffa prima del comfort,,Fare before comfort
|
||||
Industria chiusa.,,Industry closed.
|
||||
I termini arrivano con la prossima produzione giornaliera (dopo un caricamento non sono salvati).,,"The terms arrive with the next daily production (they are not saved, so they are missing after a load)."
|
||||
Copertura dei lavoratori (media mobile),,Worker coverage (moving average)
|
||||
Copertura del personale (media mobile),,Staff coverage (moving average)
|
||||
Fattore di profitto,,Profit factor
|
||||
lavoro,,work
|
||||
Ritmo del lavoro,,Work pace
|
||||
Copertura degli ingressi di oggi,,Today's input coverage
|
||||
Giacimento,,Deposit
|
||||
margine,,margin
|
||||
Margine (media mobile),,Margin (moving average)
|
||||
condizione,,condition
|
||||
Condizione degli impianti (0–100),,Plant condition (0–100)
|
||||
"Industria ferma (guasto, incidente, revisione o ammodernamento): il ritmo del lavoro è zero.",,"Industry stopped (failure, accident, overhaul or upgrade): the work pace is zero."
|
||||
Livello 0: l'industria è inattiva.,,Level 0: the industry is inactive.
|
||||
Sopra la soglia di crescita per i trimestri richiesti il livello sale; sotto la soglia di calo scende.,,Above the growth threshold for the required quarters the level rises; below the decline threshold it falls.
|
||||
Non servita da un vettore nel trimestre: il livello non cambia.,,Not served by a carrier this quarter: the level does not change.
|
||||
punteggio = ws·quota + wc·copertura + wr·redditività,,score = ws·share + wc·coverage + wr·profitability
|
||||
quota,,share
|
||||
Quota trasportata,,Share carried
|
||||
spedite,,shipped
|
||||
Unità spedite nel trimestre,,Units shipped in the quarter
|
||||
prodotte,,produced
|
||||
Unità prodotte nel trimestre,,Units produced in the quarter
|
||||
Copertura media,,Average coverage
|
||||
Giorni del trimestre,,Days in the quarter
|
||||
redditività,,profitability
|
||||
Redditività (margine + 1)/2,,Profitability (margin + 1)/2
|
||||
Peso della quota,,Weight of the share
|
||||
Peso della copertura,,Weight of the coverage
|
||||
Peso della redditività,,Weight of the profitability
|
||||
soglia su,,threshold up
|
||||
Soglia di crescita,,Growth threshold
|
||||
soglia giù,,threshold down
|
||||
Soglia di calo,,Decline threshold
|
||||
trimestri,,quarters
|
||||
Trimestri sopra soglia,,Quarters above threshold
|
||||
richiesti,,required
|
||||
Trimestri richiesti,,Quarters required
|
||||
Crescita della città,,Town growth
|
||||
"g = g₀ + ws·(s − s₀) + wo·(o − o₀), limitata a ±gmax",,"g = g₀ + ws·(s − s₀) + wo·(o − o₀), capped at ±gmax"
|
||||
Crescita di base,,Base growth
|
||||
Soddisfazione neutra,,Neutral satisfaction
|
||||
Peso della soddisfazione,,Weight of satisfaction
|
||||
Occupati per abitante,,Employed per inhabitant
|
||||
Occupazione neutra,,Neutral employment
|
||||
Peso dell'occupazione,,Weight of employment
|
||||
g grezza,,raw g
|
||||
Crescita prima del limite,,Growth before the cap
|
||||
Crescita massima al mese,,Maximum growth per month
|
||||
dopo,,after
|
||||
Abitanti dopo il mese,,Population after the month
|
||||
ultimo mese,,last month
|
||||
Crescita dell'ultimo mese,,Last month's growth
|
||||
Stima con lo stato di oggi: la crescita si applica all'inizio del mese.,,Estimate from today's state: growth is applied at the start of the month.
|
||||
Condizione del treno,,Train condition
|
||||
Componente più debole,,Weakest component
|
||||
veicolo,,vehicle
|
||||
Veicolo,,Vehicle
|
||||
Usura al giorno (media mobile),,Wear per day (moving average)
|
||||
c rischio,,c risk
|
||||
Componente più a rischio,,Component most at risk
|
||||
Rischio di base al giorno,,Base risk per day
|
||||
Condizione di soglia,,Threshold condition
|
||||
Pendenza del rischio,,Risk slope
|
||||
Scala della condizione,,Condition scale
|
||||
Riduzione sopra soglia,,Reduction above threshold
|
||||
ispezione,,inspection
|
||||
Fattore dopo un'ispezione,,Factor after an inspection
|
||||
Rischio di guasto al giorno,,Failure risk per day
|
||||
Giorni attesi al prossimo guasto,,Expected days to the next failure
|
||||
Condizione obiettivo del pianificatore,,Planner's target condition
|
||||
Margine del pianificatore,,Planner's margin
|
||||
stima,,estimate
|
||||
Giorni all'intervento sulla condizione,,Days to condition-based maintenance
|
||||
Nessuna stima del pianificatore: i componenti non si sono ancora consumati.,,No planner estimate: the components have not worn yet.
|
||||
Il guasto è estratto ogni giorno con il rischio h: 1/h è il numero medio di giorni prima del prossimo.,,A failure is drawn every day with risk h: 1/h is the average number of days before the next one.
|
||||
"c = min(componenti); h = h₀·exp(k·(c₀ − c)/σ) sotto c₀, altrimenti h₀/div; stima = (c − obiettivo)/usura − margine",,"c = min(components); h = h₀·exp(k·(c₀ − c)/σ) below c₀, otherwise h₀/div; estimate = (c − target)/wear − margin"
|
||||
Valore del veicolo,,Vehicle value
|
||||
prezzo,,price
|
||||
Prezzo di listino,,List price
|
||||
età,,age
|
||||
Età,,Age
|
||||
vita,,life
|
||||
Vita utile,,Useful life
|
||||
Superato dal,,Superseded since
|
||||
anni superato,,years superseded
|
||||
Anni da superato,,Years since superseded
|
||||
perdita,,loss
|
||||
Perdita immediata,,Immediate loss
|
||||
velocità,,speed
|
||||
Ammortamento più rapido,,Faster depreciation
|
||||
successore,,successor
|
||||
Successore consigliato,,Recommended successor
|
||||
"r = max(rmin, (1 − perdita)·(1 − (età + (velocità − 1)·anni superato)/vita)); valore = prezzo·r; rivendita = prezzo·r·condizione",,"r = max(rmin, (1 − loss)·(1 − (age + (speed − 1)·years superseded)/life)); value = price·r; resale = price·r·condition"
|
||||
Modello superato: perde subito una quota del valore e si ammortizza più in fretta.,,Superseded model: it loses part of its value at once and depreciates faster.
|
||||
"r = max(rmin, 1 − età/vita); valore = prezzo·r; rivendita = prezzo·r·condizione",,"r = max(rmin, 1 − age/life); value = price·r; resale = price·r·condition"
|
||||
Valore minimo,,Minimum value
|
||||
Quota residua del valore,,Remaining share of value
|
||||
Condizione media dei componenti,,Average component condition
|
||||
rivendita,,resale
|
||||
Rivendita,,Resale
|
||||
"Margine (utile operativo / ricavi, 12 mesi)",,"Margin (operating profit / revenue, 12 months)"
|
||||
Componente del margine,,Margin component
|
||||
leva,,leverage
|
||||
Debiti / patrimonio netto,,Debt / net worth
|
||||
Componente della leva,,Leverage component
|
||||
Peso del margine,,Weight of the margin
|
||||
Peso della leva,,Weight of the leverage
|
||||
"Rating iniziale: le misure sono quelle di oggi, il primo calcolo è a inizio mese.",,"Initial rating: the measures are today's, the first calculation is at the start of the month."
|
||||
Margine neutro finché la finestra non ha abbastanza mesi con ricavi.,,Neutral margin until the window has enough months with revenue.
|
||||
Compagnia in bancarotta: il rating è D.,,Company bankrupt: the rating is D.
|
||||
gradino,,step
|
||||
Gradino sopra,,Next step up
|
||||
Punteggio del gradino sopra,,Score of the next step up
|
||||
Il punteggio vale già il gradino sopra: il rating cambia al prossimo calcolo mensile.,,The score already earns the next step up: the rating changes at the next monthly calculation.
|
||||
margine necessario,,margin needed
|
||||
"Margine che basta, a leva invariata",,"Margin that is enough, with leverage unchanged"
|
||||
leva massima,,max leverage
|
||||
"Leva che basta, a margine invariato",,"Leverage that is enough, with margin unchanged"
|
||||
rimborso,,repayment
|
||||
Debito da rimborsare per la leva che basta,,Debt to repay to reach that leverage
|
||||
Rating più alto.,,Highest rating.
|
||||
"punteggio = pm·clamp(0,5 + margine, 0, 1) + pl·1/(1 + leva)",,"score = pm·clamp(0.5 + margin, 0, 1) + pl·1/(1 + leverage)"
|
||||
Livello più alto.,,Highest level.
|
||||
Finché un requisito manca l'avanzamento resta sotto il 100%.,,"While a requirement is missing, progress stays below 100%."
|
||||
"avanzamento = (fP + fC + fR)/3; fP = min(1, patrimonio/soglia); fC = min(1, città/richieste); fR = 1 − gradini mancanti/n",,"progress = (fP + fC + fR)/3; fP = min(1, net worth/threshold); fC = min(1, cities/wanted); fR = 1 − missing steps/n"
|
||||
Patrimonio richiesto,,Net worth required
|
||||
Frazione del patrimonio,,Net worth fraction
|
||||
città,,cities
|
||||
Città collegate,,Towns connected
|
||||
Città richieste,,Towns required
|
||||
Abitanti minimi per città,,Minimum population per town
|
||||
Frazione delle città,,Towns fraction
|
||||
rating richiesto,,rating required
|
||||
Rating richiesto,,Rating required
|
||||
Gradini per lo zero,,Steps to zero
|
||||
Frazione del rating,,Rating fraction
|
||||
tetto,,cap
|
||||
Tetto con un requisito mancante,,Cap with a requirement missing
|
||||
Le voci del mese sono nel pannello «Finanze».,,The month's items are in the «Finances» panel.
|
||||
inizio,,start
|
||||
Cassa a inizio mese,,Cash at the start of the month
|
||||
ricavi,,revenue
|
||||
Ricavi del mese,,Revenue this month
|
||||
costi,,costs
|
||||
Costi del mese,,Costs this month
|
||||
capitale,,capital
|
||||
Investimenti e finanziamenti del mese,,Investment and financing this month
|
||||
flusso,,flow
|
||||
Flusso di cassa del mese,,Cash flow this month
|
||||
Giorni di cassa negativa,,Days of negative cash
|
||||
limite,,limit
|
||||
Giorni che portano alla bancarotta,,Days that lead to bankruptcy
|
||||
Con la cassa negativa per troppi giorni di fila la compagnia fallisce.,,With negative cash for too many days in a row the company goes bankrupt.
|
||||
cassa = cassa a inizio mese + ricavi + costi + investimenti e finanziamenti,,cash = cash at start of month + revenue + costs + investment and financing
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
using RailEnterprise.Client.App;
|
||||
using RailEnterprise.Client.Net;
|
||||
using RailEnterprise.Client.Panels;
|
||||
using RailEnterprise.Core.Economy;
|
||||
using RailEnterprise.Protocol.Messages;
|
||||
using static RailEnterprise.Client.App.Localization;
|
||||
|
||||
@@ -26,7 +27,6 @@ public partial class TopBar : PanelContainer
|
||||
private readonly Label _server = UiTheme.Text("", 14);
|
||||
private readonly ColorRect _serverDot = new() { CustomMinimumSize = new Vector2(10, 10) };
|
||||
private readonly List<Button> _speeds = [];
|
||||
private VBoxContainer? _tierBox;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -52,7 +52,6 @@ public partial class TopBar : PanelContainer
|
||||
_tier.MouseFilter = MouseFilterEnum.Pass;
|
||||
_climb.MouseFilter = MouseFilterEnum.Pass;
|
||||
row.AddChild(tierBox);
|
||||
_tierBox = tierBox;
|
||||
row.AddChild(new Control { SizeFlagsHorizontal = SizeFlags.ExpandFill });
|
||||
row.AddChild(_date);
|
||||
var speeds = new HBoxContainer();
|
||||
@@ -70,6 +69,10 @@ public partial class TopBar : PanelContainer
|
||||
row.AddChild(Stat(T("Cassa"), _cash));
|
||||
row.AddChild(Stat(T("Patrimonio netto"), _worth));
|
||||
row.AddChild(Stat(T("Rating"), _rating));
|
||||
// tooltip «perché» (ADR 0024): cassa con i movimenti del mese, rating, avanzamento del livello
|
||||
WhyTooltip.Attach(_cash, () => new ExplainTarget(ExplainSubject.Cash));
|
||||
WhyTooltip.Attach(_rating, () => new ExplainTarget(ExplainSubject.Rating));
|
||||
WhyTooltip.Attach(tierBox, () => new ExplainTarget(ExplainSubject.TierProgress), T("Clic per aprire «La tua scalata»"));
|
||||
var chip = new PanelContainer();
|
||||
chip.AddThemeStyleboxOverride("panel", UiTheme.Box(Palette.Inner, Palette.Border, 16, 12));
|
||||
var chipRow = new HBoxContainer();
|
||||
@@ -124,8 +127,6 @@ public partial class TopBar : PanelContainer
|
||||
_climb.Text = top ? T("livello più alto")
|
||||
: climb is not null && climb.Tier == tier ? $"{Fmt.Progress(climb.Progress)} {T("verso")} {Fmt.Tier(w, tier + 1)}"
|
||||
: $"{T("prossimo")}: {Fmt.Tier(w, tier + 1)}";
|
||||
if (_tierBox is not null)
|
||||
_tierBox.TooltipText = $"{T("Livello")} {tier} {T("di")} {w.Data.Tiers.Tiers.Count}. {T("Clic per aprire «La tua scalata»")}";
|
||||
_date.Text = w.LastDigest?.Date ?? w.Summary.Date;
|
||||
_cash.Text = (w.LastDigest?.Cash ?? me?.Cash ?? default).ToString();
|
||||
_worth.Text = (w.LastDigest?.NetWorth ?? me?.NetWorth ?? default).ToString("short");
|
||||
|
||||
@@ -6,6 +6,8 @@ using RailEnterprise.Core.Common;
|
||||
using RailEnterprise.Protocol.Client;
|
||||
using RailEnterprise.Protocol.Messages;
|
||||
using static RailEnterprise.Client.App.Localization;
|
||||
using ExplainSubject = RailEnterprise.Core.Economy.ExplainSubject;
|
||||
using ExplainTarget = RailEnterprise.Core.Economy.ExplainTarget;
|
||||
|
||||
namespace RailEnterprise.Client.Panels;
|
||||
|
||||
@@ -70,6 +72,9 @@ public partial class ClimbPanel : VBoxContainer
|
||||
var trackCard = Card();
|
||||
var trackCol = (VBoxContainer)trackCard.GetChild(0);
|
||||
trackCol.AddChild(_track);
|
||||
// tooltip «perché» dell'avanzamento verso il prossimo livello (ADR 0024)
|
||||
WhyTooltip.Attach(_track, () => new ExplainTarget(ExplainSubject.TierProgress));
|
||||
WhyTooltip.Attach(_nextTitle, () => new ExplainTarget(ExplainSubject.TierProgress));
|
||||
trackCol.AddChild(_stations);
|
||||
AddChild(trackCard);
|
||||
|
||||
@@ -279,6 +284,7 @@ public partial class ClimbPanel : VBoxContainer
|
||||
bar.AddThemeStyleboxOverride("fill", UiTheme.Box(color, color, 4, 0));
|
||||
col.AddChild(bar);
|
||||
col.AddChild(UiTheme.Text((met ? "✓ " : "") + value, 13, met ? Palette.Ok : Palette.TextSecondary));
|
||||
WhyTooltip.Attach(col, () => new ExplainTarget(ExplainSubject.TierProgress));
|
||||
return col;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public partial class FinancePanel : VBoxContainer
|
||||
_cash.HorizontalAlignment = HorizontalAlignment.Right;
|
||||
cash.AddChild(cashCaption);
|
||||
cash.AddChild(_cash);
|
||||
WhyTooltip.Attach(_cash, () => new ExplainTarget(ExplainSubject.Cash));
|
||||
header.AddChild(cash);
|
||||
var close = new Button { Text = T("Torna alla mappa"), SizeFlagsVertical = SizeFlags.ShrinkCenter, CustomMinimumSize = new Vector2(170, 48) };
|
||||
close.Pressed += () => CloseRequested?.Invoke();
|
||||
@@ -116,6 +117,7 @@ public partial class FinancePanel : VBoxContainer
|
||||
right.AddChild(UiTheme.Text(T("Rating creditizio"), 20, bold: true));
|
||||
var ratingRow = PanelKit.Row(16);
|
||||
ratingRow.AddChild(_rating);
|
||||
WhyTooltip.Attach(_rating, () => new ExplainTarget(ExplainSubject.Rating));
|
||||
_ratingCaption.SizeFlagsVertical = SizeFlags.ShrinkCenter;
|
||||
_ratingCaption.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
_ratingCaption.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
|
||||
@@ -95,6 +95,8 @@ public partial class IndustryPanel : VBoxContainer
|
||||
header.AddChild(value);
|
||||
var ring = PanelKit.Column(2);
|
||||
ring.AddChild(_ring);
|
||||
// tooltip «perché» dell'efficienza con i termini dell'ultima produzione (ADR 0024)
|
||||
WhyTooltip.Attach(_ring, () => _industry >= 0 ? new ExplainTarget(ExplainSubject.IndustryEfficiency, _industry) : null);
|
||||
_limit.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
_limit.CustomMinimumSize = new Vector2(150, 0);
|
||||
_limit.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
@@ -336,7 +338,7 @@ public partial class IndustryPanel : VBoxContainer
|
||||
_inputs.AddChild(Bar(f.FullMonth <= 0 ? 0 : f.CurrentMonth / f.FullMonth, f.Limiting ? Palette.Danger : Palette.Amber));
|
||||
string days = f.Days < 0 ? "" : $" · {T("bastano per")} {Fmt.Number(f.Days, 0)} {T("giorni")}";
|
||||
_inputs.AddChild(Wrapped($"{T("scorta")} {f.Stock} / {f.Storage} {unit}{days}", 12, f.Limiting ? Palette.Danger : Palette.TextSecondary));
|
||||
foreach (var p in f.Partners) _inputs.AddChild(PartnerLine(w, p, unit, supplier: true));
|
||||
foreach (var p in f.Partners) _inputs.AddChild(PartnerLine(w, p, f.Good, unit, supplier: true));
|
||||
if (f.Partners.Count == 0) _inputs.AddChild(UiTheme.Text(T("Nessun fornitore nella regione"), 12, Palette.TextSecondary));
|
||||
_inputs.AddChild(PanelKit.Separator());
|
||||
}
|
||||
@@ -396,13 +398,20 @@ public partial class IndustryPanel : VBoxContainer
|
||||
_production.AddChild(Bar(f.FullMonth <= 0 ? 0 : f.CurrentMonth / f.FullMonth, Palette.Amber));
|
||||
string full = f.Days < 0 ? "" : f.Days <= 0 ? " · " + T("magazzino pieno") : $" · {T("pieno tra")} {Fmt.Number(f.Days, 0)} {T("giorni")}";
|
||||
_production.AddChild(Wrapped($"{T("magazzino")} {f.Stock} / {f.Storage} {unit}{full}", 12, f.Days == 0 ? Palette.Danger : Palette.TextSecondary));
|
||||
foreach (var p in f.Partners) _production.AddChild(PartnerLine(w, p, unit, supplier: false));
|
||||
foreach (var p in f.Partners) _production.AddChild(PartnerLine(w, p, f.Good, unit, supplier: false));
|
||||
if (f.Partners.Count == 0) _production.AddChild(UiTheme.Text(T("Nessun cliente nella regione"), 12, Palette.TextSecondary));
|
||||
_production.AddChild(PanelKit.Separator());
|
||||
}
|
||||
if (s.Outputs.Count == 0) _production.AddChild(UiTheme.Text(T("Nessuna produzione"), 13, Palette.TextSecondary));
|
||||
_production.AddChild(PanelKit.Pair(T("Magazzino"), PanelKit.Value($"{s.StorageDays} {T("giorni di produzione")}")));
|
||||
_production.AddChild(PanelKit.Pair(T("Prezzo di vendita"), PanelKit.Value(s.SalePrice < 0 ? "—" : Fmt.PricePrecise(s.SalePrice))));
|
||||
var sale = PanelKit.Pair(T("Prezzo di vendita"), PanelKit.Value(s.SalePrice < 0 ? "—" : Fmt.PricePrecise(s.SalePrice)));
|
||||
// le industrie vendono al prezzo globale del giorno (ADR 0004): si spiega quello
|
||||
if (s.SalePrice >= 0 && s.Outputs.Count == 1)
|
||||
{
|
||||
int good = s.Outputs[0].Good;
|
||||
WhyTooltip.Attach(sale, () => new ExplainTarget(ExplainSubject.GlobalPrice, good));
|
||||
}
|
||||
_production.AddChild(sale);
|
||||
_production.AddChild(PanelKit.Pair(T("Utile annuo stimato"), ColoredValue(s.AnnualProfit.ToString(), s.AnnualProfit.Cents < 0 ? Palette.Danger : Palette.Text)));
|
||||
_production.AddChild(PanelKit.Pair(T("Margine"), ColoredValue(Fmt.Pct(card.Margin, 0), card.Margin < 0 ? Palette.Danger : Palette.Text)));
|
||||
}
|
||||
@@ -478,9 +487,13 @@ public partial class IndustryPanel : VBoxContainer
|
||||
|
||||
// crescita trimestrale: punteggio in corso, soglie, componenti
|
||||
_plants.AddChild(PanelKit.Separator());
|
||||
_plants.AddChild(FlowHeader(T("Punteggio di crescita"), $"{Fmt.Number(s.Score, 2)} · {T("giorno")} {s.QuarterDay} {T("di")} {s.QuarterDays}"));
|
||||
var scoreHeader = FlowHeader(T("Punteggio di crescita"), $"{Fmt.Number(s.Score, 2)} · {T("giorno")} {s.QuarterDay} {T("di")} {s.QuarterDays}");
|
||||
_plants.AddChild(scoreHeader);
|
||||
var bar = new ScoreBar();
|
||||
bar.Set(s.Score, s.LastScore, s.DowngradeThreshold, s.UpgradeThreshold);
|
||||
int scored = _industry;
|
||||
WhyTooltip.Attach(scoreHeader, () => new ExplainTarget(ExplainSubject.IndustryGrowth, scored));
|
||||
WhyTooltip.Attach(bar, () => new ExplainTarget(ExplainSubject.IndustryGrowth, scored));
|
||||
_plants.AddChild(bar);
|
||||
_plants.AddChild(Wrapped($"{T("sotto")} {Fmt.Number(s.DowngradeThreshold, 2)} {T("perde un livello")} · {T("sopra")} {Fmt.Number(s.UpgradeThreshold, 2)} {T("per")} {s.UpgradeQuarters} {T("trimestri sale")} ({s.QuartersAbove}/{s.UpgradeQuarters})", 12, Palette.TextSecondary));
|
||||
var g = w.Data.Balance.Growth;
|
||||
@@ -615,14 +628,21 @@ public partial class IndustryPanel : VBoxContainer
|
||||
return bar;
|
||||
}
|
||||
|
||||
private static Control PartnerLine(ClientWorld w, ChainPartnerInfo p, string unit, bool supplier)
|
||||
private static Control PartnerLine(ClientWorld w, ChainPartnerInfo p, int good, string unit, bool supplier)
|
||||
{
|
||||
string link = p.Line >= 0 && w.Lines.TryGetValue(p.Line, out var line)
|
||||
? $"{T("linea")} {line.Name}"
|
||||
: $"{T("non collegata")} · {Fmt.Number(p.DistanceKm, 1)} km";
|
||||
string amount = (ChainPartnerKind)p.Kind == ChainPartnerKind.Hub ? "" : $" · {Fmt.Number(p.MonthlyUnits, 0)} {unit}/{T("mese")}";
|
||||
string text = $"{(supplier ? "←" : "→")} {PartnerName(w, p)}{amount} · {Fmt.PricePrecise(p.Price)} · {link}";
|
||||
return Wrapped(text, 12, p.Line >= 0 ? Palette.AmberLight : Palette.TextSecondary);
|
||||
var label = Wrapped(text, 12, p.Line >= 0 ? Palette.AmberLight : Palette.TextSecondary);
|
||||
// prezzo del partner spiegato dal server: locale per le industrie che comprano, globale per chi vende e per
|
||||
// le città; quello degli hub è il prezzo mondiale con il dazio, senza spiegazione
|
||||
var kind = (ChainPartnerKind)p.Kind;
|
||||
int target = p.Target;
|
||||
if (kind == ChainPartnerKind.Industry && !supplier) WhyTooltip.Attach(label, () => new ExplainTarget(ExplainSubject.LocalPrice, good, target));
|
||||
else if (kind != ChainPartnerKind.Hub) WhyTooltip.Attach(label, () => new ExplainTarget(ExplainSubject.GlobalPrice, good));
|
||||
return label;
|
||||
}
|
||||
|
||||
private static string PartnerName(ClientWorld w, ChainPartnerInfo p) => (ChainPartnerKind)p.Kind switch
|
||||
|
||||
@@ -6,6 +6,8 @@ using RailEnterprise.Core.Common;
|
||||
using RailEnterprise.Core.Data;
|
||||
using RailEnterprise.Protocol.Messages;
|
||||
using static RailEnterprise.Client.App.Localization;
|
||||
using ExplainSubject = RailEnterprise.Core.Economy.ExplainSubject;
|
||||
using ExplainTarget = RailEnterprise.Core.Economy.ExplainTarget;
|
||||
|
||||
namespace RailEnterprise.Client.Panels;
|
||||
|
||||
@@ -210,7 +212,10 @@ public partial class MaintenancePanel : VBoxContainer
|
||||
_card.AddChild(UiTheme.TitleLabel(T("Cartella di manutenzione") + " · " + t.Name, 22));
|
||||
var card = w.Cards.GetValueOrDefault(_train);
|
||||
var stats = PanelKit.Row();
|
||||
stats.AddChild(PanelKit.Stat(T("Condizione"), PanelKit.Value($"{Math.Floor(card?.Condition ?? t.Condition):0}%")));
|
||||
var condition = PanelKit.Stat(T("Condizione"), PanelKit.Value($"{Math.Floor(card?.Condition ?? t.Condition):0}%"));
|
||||
int trainId = _train;
|
||||
WhyTooltip.Attach(condition, () => new ExplainTarget(ExplainSubject.TrainCondition, trainId));
|
||||
stats.AddChild(condition);
|
||||
stats.AddChild(PanelKit.Stat(T("Guasti nell'anno"), PanelKit.Value($"{card?.FailuresThisYear ?? 0}")));
|
||||
stats.AddChild(PanelKit.Stat(T("Costi dell'anno"), PanelKit.Value((card?.CostThisYear ?? Money.Zero).ToString())));
|
||||
_card.AddChild(stats);
|
||||
|
||||
@@ -5,6 +5,8 @@ using RailEnterprise.Core.Common;
|
||||
using RailEnterprise.Protocol.Client;
|
||||
using RailEnterprise.Protocol.Messages;
|
||||
using static RailEnterprise.Client.App.Localization;
|
||||
using ExplainSubject = RailEnterprise.Core.Economy.ExplainSubject;
|
||||
using ExplainTarget = RailEnterprise.Core.Economy.ExplainTarget;
|
||||
|
||||
namespace RailEnterprise.Client.Panels;
|
||||
|
||||
@@ -102,6 +104,8 @@ public partial class MarketPanel : VBoxContainer
|
||||
_goodChange.HorizontalAlignment = HorizontalAlignment.Right;
|
||||
price.AddChild(_goodPrice);
|
||||
price.AddChild(_goodChange);
|
||||
// tooltip «perché» del prezzo globale del bene scelto (ADR 0024)
|
||||
WhyTooltip.Attach(_goodPrice, () => _selected >= 0 ? new ExplainTarget(ExplainSubject.GlobalPrice, _selected) : null);
|
||||
top.AddChild(price);
|
||||
center.AddChild(top);
|
||||
center.AddChild(_chart);
|
||||
@@ -424,6 +428,12 @@ public partial class MarketPanel : VBoxContainer
|
||||
var price = UiTheme.Text(PerUnit(w, g.Good, p.Price), 14, bold: true);
|
||||
price.CustomMinimumSize = new Vector2(110, 0);
|
||||
row.AddChild(price);
|
||||
// prezzo locale dell'industria spiegato dal server; gli hub comprano al prezzo mondiale meno il dazio
|
||||
if (p.Kind != SellPlaceInfo.Hub)
|
||||
{
|
||||
int good = g.Good, target = p.Target;
|
||||
WhyTooltip.Attach(price, () => new ExplainTarget(ExplainSubject.LocalPrice, good, target));
|
||||
}
|
||||
var line = UiTheme.Text(p.Line >= 0 ? LineName(w, p.Line) : T("non collegato"), 14, p.Line >= 0 ? Palette.TextSecondary : Palette.Amber);
|
||||
line.CustomMinimumSize = new Vector2(130, 0);
|
||||
line.ClipText = true;
|
||||
|
||||
@@ -7,6 +7,8 @@ using RailEnterprise.Core.Data;
|
||||
using RailEnterprise.Core.Rail;
|
||||
using RailEnterprise.Protocol.Messages;
|
||||
using static RailEnterprise.Client.App.Localization;
|
||||
using ExplainSubject = RailEnterprise.Core.Economy.ExplainSubject;
|
||||
using ExplainTarget = RailEnterprise.Core.Economy.ExplainTarget;
|
||||
|
||||
namespace RailEnterprise.Client.Panels;
|
||||
|
||||
@@ -61,6 +63,10 @@ public partial class TrainsPanel : VBoxContainer
|
||||
AddChild(buyButton);
|
||||
AddChild(UiTheme.Text(T("Veicoli liberi nel deposito (selezione multipla, in ordine)"), 13, Palette.TextSecondary));
|
||||
AddChild(_inDepot);
|
||||
// «perché»: valore del veicolo sotto il puntatore (residuo, valore contabile, rivendita)
|
||||
WhyTooltip.Attach(_inDepot, () => HoveredId(_inDepot, _vehicleIds) is int v and >= 0
|
||||
? new ExplainTarget(ExplainSubject.VehicleValue, v)
|
||||
: null);
|
||||
var compose = PanelKit.Row();
|
||||
_name.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
compose.AddChild(_name);
|
||||
@@ -74,6 +80,9 @@ public partial class TrainsPanel : VBoxContainer
|
||||
AddChild(PanelKit.Separator());
|
||||
AddChild(UiTheme.Text(T("Treni della compagnia"), 14, bold: true));
|
||||
AddChild(_trains);
|
||||
WhyTooltip.Attach(_trains, () => HoveredId(_trains, _trainIds) is int t and >= 0
|
||||
? new ExplainTarget(ExplainSubject.TrainCondition, t)
|
||||
: null);
|
||||
var assign = PanelKit.Row();
|
||||
_line.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
assign.AddChild(_line);
|
||||
@@ -285,6 +294,13 @@ public partial class TrainsPanel : VBoxContainer
|
||||
foreach (int id in selected) _session.Command(new SellVehicleCommand(new VehicleId(id)), Result);
|
||||
}
|
||||
|
||||
/// <summary>Identificativo della voce sotto il puntatore, -1 se il puntatore non è su una voce.</summary>
|
||||
private static int HoveredId(ItemList list, List<int> ids)
|
||||
{
|
||||
int i = list.GetItemAtPosition(list.GetLocalMousePosition(), true);
|
||||
return i >= 0 && i < ids.Count ? ids[i] : -1;
|
||||
}
|
||||
|
||||
private int SelectedTrain => _trains.GetSelectedItems() is { Length: > 0 } sel && sel[0] < _trainIds.Count ? _trainIds[sel[0]] : -1;
|
||||
|
||||
private void Assign()
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
using Godot;
|
||||
using RailEnterprise.Client.App;
|
||||
using RailEnterprise.Client.Net;
|
||||
using RailEnterprise.Core.Common;
|
||||
using RailEnterprise.Core.Economy;
|
||||
using RailEnterprise.Protocol.Messages;
|
||||
using static RailEnterprise.Client.App.Localization;
|
||||
|
||||
namespace RailEnterprise.Client.Panels;
|
||||
|
||||
/// <summary>
|
||||
/// Tooltip «perché» comune (F6, ADR 0024): sopra un valore dei pannelli, dopo un breve ritardo, mostra la
|
||||
/// spiegazione calcolata dal server (titolo, valore, formula, termini con i valori di oggi, note) nello stile
|
||||
/// della palette 05. Il client non calcola nulla: se la spiegazione manca o è di un giorno passato la chiede
|
||||
/// (RequestDetail con DetailKind.Explain) e intanto mostra «in arrivo…». Un solo tooltip per schermata, su
|
||||
/// un suo CanvasLayer sopra l'interfaccia; i pannelli lo agganciano con <see cref="Attach"/>.
|
||||
/// </summary>
|
||||
public partial class WhyTooltip : PanelContainer
|
||||
{
|
||||
/// <summary>Tooltip della schermata di gioco (null fuori partita: gli agganci restano muti).</summary>
|
||||
public static WhyTooltip? Instance { get; private set; }
|
||||
|
||||
/// <summary>Ritardo prima dell'apertura (secondi).</summary>
|
||||
private const double OpenDelay = 0.45;
|
||||
/// <summary>Intervallo minimo tra due richieste della stessa spiegazione (secondi).</summary>
|
||||
private const double RequestInterval = 1.0;
|
||||
private const float MaxWidth = 440;
|
||||
|
||||
private readonly GameSession _session;
|
||||
private readonly VBoxContainer _body = new();
|
||||
private Control? _hover;
|
||||
private Func<ExplainTarget?>? _target;
|
||||
private string _hint = "";
|
||||
private (byte Subject, int Target, int Arg) _key;
|
||||
private double _wait;
|
||||
private double _sinceRequest = double.MaxValue;
|
||||
private int _shownVersion = -1;
|
||||
private ExplanationReport? _shown;
|
||||
|
||||
public WhyTooltip(GameSession session)
|
||||
{
|
||||
_session = session;
|
||||
Visible = false;
|
||||
MouseFilter = MouseFilterEnum.Ignore;
|
||||
TopLevel = true;
|
||||
AddThemeStyleboxOverride("panel", UiTheme.Box(Palette.Panel, Palette.Amber, 8, 14));
|
||||
_body.AddThemeConstantOverride("separation", 6);
|
||||
_body.MouseFilter = MouseFilterEnum.Ignore;
|
||||
AddChild(_body);
|
||||
}
|
||||
|
||||
public override void _EnterTree() => Instance = this;
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
if (Instance == this) Instance = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggancia il tooltip a un controllo: al passaggio del mouse chiede a <paramref name="target"/> quale valore
|
||||
/// spiegare (null: nessuna spiegazione per ora). Il controllo riceve il mouse senza fermare i clic dei genitori.
|
||||
/// <paramref name="hint"/> (già tradotto) compare in fondo, per esempio che un clic apre un pannello.
|
||||
/// </summary>
|
||||
public static void Attach(Control control, Func<ExplainTarget?> target, string hint = "")
|
||||
{
|
||||
if (control.MouseFilter == MouseFilterEnum.Ignore) control.MouseFilter = MouseFilterEnum.Pass;
|
||||
control.MouseEntered += () => Instance?.Enter(control, target, hint);
|
||||
control.MouseExited += () => Instance?.Leave(control);
|
||||
}
|
||||
|
||||
private void Enter(Control control, Func<ExplainTarget?> target, string hint)
|
||||
{
|
||||
_hover = control;
|
||||
_target = target;
|
||||
_hint = hint;
|
||||
_wait = 0;
|
||||
_shown = null;
|
||||
_shownVersion = -1;
|
||||
Visible = false;
|
||||
}
|
||||
|
||||
private void Leave(Control control)
|
||||
{
|
||||
if (_hover != control) return;
|
||||
_hover = null;
|
||||
_target = null;
|
||||
Visible = false;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_hover is null || _target is null) return;
|
||||
if (!IsInstanceValid(_hover) || !_hover.IsVisibleInTree())
|
||||
{
|
||||
Leave(_hover);
|
||||
return;
|
||||
}
|
||||
_wait += delta;
|
||||
_sinceRequest += delta;
|
||||
if (_wait < OpenDelay) return;
|
||||
if (_target() is not { Subject: not ExplainSubject.None } t)
|
||||
{
|
||||
Visible = false;
|
||||
return;
|
||||
}
|
||||
var key = ((byte)t.Subject, t.A, t.B);
|
||||
var w = _session.World;
|
||||
if (key != _key)
|
||||
{
|
||||
_key = key;
|
||||
_sinceRequest = double.MaxValue;
|
||||
_shown = null;
|
||||
_shownVersion = -1;
|
||||
}
|
||||
var e = w.Explanations.GetValueOrDefault(key);
|
||||
// una spiegazione di un giorno passato si mostra finché arriva quella di oggi
|
||||
bool stale = e is null || e.Day < Fmt.Today(w);
|
||||
if (stale && _sinceRequest >= RequestInterval && _session.IsOpen)
|
||||
{
|
||||
_sinceRequest = 0;
|
||||
_session.Send(new RequestDetail { Kind = DetailKind.Explain, Target = t.A, Subject = (byte)t.Subject, Arg = t.B });
|
||||
}
|
||||
if (!ReferenceEquals(e, _shown) || _shownVersion < 0)
|
||||
{
|
||||
_shown = e;
|
||||
_shownVersion = w.ExplanationVersion;
|
||||
Rebuild(w, e, t);
|
||||
}
|
||||
Visible = true;
|
||||
Place();
|
||||
}
|
||||
|
||||
/// <summary>Vicino al puntatore, in basso a destra, dentro la finestra.</summary>
|
||||
private void Place()
|
||||
{
|
||||
var view = GetViewportRect().Size;
|
||||
var mouse = GetViewport().GetMousePosition();
|
||||
var size = GetCombinedMinimumSize();
|
||||
Size = size;
|
||||
float x = mouse.X + 18, y = mouse.Y + 22;
|
||||
if (x + size.X > view.X - 8) x = Math.Max(8, mouse.X - size.X - 12);
|
||||
if (y + size.Y > view.Y - 8) y = Math.Max(8, mouse.Y - size.Y - 12);
|
||||
Position = new Vector2(x, y);
|
||||
}
|
||||
|
||||
private void Rebuild(Protocol.Client.ClientWorld w, ExplanationReport? e, ExplainTarget t)
|
||||
{
|
||||
foreach (var child in _body.GetChildren()) child.QueueFree();
|
||||
Content(w, e, t);
|
||||
if (_hint.Length > 0) _body.AddChild(UiTheme.Text(_hint, 12, Palette.Amber));
|
||||
}
|
||||
|
||||
private void Content(Protocol.Client.ClientWorld w, ExplanationReport? e, ExplainTarget t)
|
||||
{
|
||||
if (e is null)
|
||||
{
|
||||
_body.AddChild(UiTheme.Text(T("Perché questo valore"), 13, Palette.TextSecondary, bold: true));
|
||||
_body.AddChild(UiTheme.Text(T("in arrivo…"), 14, Palette.TextSecondary));
|
||||
return;
|
||||
}
|
||||
var head = UiTheme.Text(e.Title.Length > 0 ? T(e.Title) : T("Perché questo valore"), 15, Palette.AmberLight, bold: true);
|
||||
_body.AddChild(head);
|
||||
string name = SubjectName(w, e, t);
|
||||
if (name.Length > 0) _body.AddChild(Wrapped(name, 13, Palette.TextSecondary));
|
||||
if (!e.Available)
|
||||
{
|
||||
foreach (var n in e.Notes) _body.AddChild(Wrapped(T(n), 13, Palette.TextSecondary));
|
||||
return;
|
||||
}
|
||||
string value = Format(e.Value, e.Unit, (ExplainSubject)e.Subject);
|
||||
_body.AddChild(UiTheme.TitleLabel(e.ValueText.Length > 0 ? $"{e.ValueText} ({value})" : value, 28, Palette.Text));
|
||||
if (e.Formula.Length > 0)
|
||||
{
|
||||
var box = new PanelContainer { MouseFilter = MouseFilterEnum.Ignore };
|
||||
box.AddThemeStyleboxOverride("panel", UiTheme.Box(Palette.Inner, Palette.Border, 6, 10));
|
||||
box.AddChild(Wrapped(T(e.Formula), 13, Palette.Text));
|
||||
_body.AddChild(box);
|
||||
}
|
||||
if (e.Terms.Count > 0)
|
||||
{
|
||||
var grid = new GridContainer { Columns = 3, MouseFilter = MouseFilterEnum.Ignore };
|
||||
grid.AddThemeConstantOverride("h_separation", 10);
|
||||
grid.AddThemeConstantOverride("v_separation", 3);
|
||||
foreach (var term in e.Terms)
|
||||
{
|
||||
// i simboli che sono parole (soglia, quota, prezzo…) si traducono, le lettere restano come nella formula
|
||||
var symbol = UiTheme.Text(term.Symbol.Length >= 3 ? T(term.Symbol) : term.Symbol, 13, Palette.Amber, bold: true);
|
||||
var label = UiTheme.Text(T(term.Label), 13, Palette.TextSecondary);
|
||||
label.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
var v = UiTheme.Text(term.Unit == (byte)ExplainUnit.Text ? Translated(term.Text) : Format(term.Value, term.Unit, (ExplainSubject)e.Subject), 13, bold: true);
|
||||
v.HorizontalAlignment = HorizontalAlignment.Right;
|
||||
foreach (var l in new[] { symbol, label, v }) l.MouseFilter = MouseFilterEnum.Ignore;
|
||||
grid.AddChild(symbol);
|
||||
grid.AddChild(label);
|
||||
grid.AddChild(v);
|
||||
}
|
||||
_body.AddChild(grid);
|
||||
}
|
||||
foreach (var n in e.Notes) _body.AddChild(Wrapped(T(n), 12, Palette.TextSecondary));
|
||||
if (e.Day < Fmt.Today(w)) _body.AddChild(UiTheme.Text(T("aggiornamento in arrivo…"), 12, Palette.TextSecondary));
|
||||
}
|
||||
|
||||
/// <summary>Nome dell'oggetto: i beni nella lingua dell'interfaccia, il resto com'è (nomi propri dal server).</summary>
|
||||
private static string SubjectName(Protocol.Client.ClientWorld w, ExplanationReport e, ExplainTarget t)
|
||||
{
|
||||
bool en = TranslationServer.GetLocale().StartsWith("en");
|
||||
string Good(int g) => g >= 0 && g < w.Data.Goods.Count ? (en ? w.Data.Goods[g].NameEn : w.Data.Goods[g].NameIt) : "";
|
||||
return t.Subject switch
|
||||
{
|
||||
ExplainSubject.GlobalPrice => Good(t.A),
|
||||
ExplainSubject.LocalPrice => w.Industries.TryGetValue(t.B, out var ind) ? $"{Good(t.A)} · {ind.Name}" : e.Name,
|
||||
_ => e.Name,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Testi dei valori testuali: componenti dei veicoli tradotti, il resto (rating, nomi, anni) com'è.</summary>
|
||||
private static string Translated(string text) => text switch
|
||||
{
|
||||
"engine" => T("motore"),
|
||||
"brakes" => T("freni"),
|
||||
"body" => T("cassa"),
|
||||
_ => text,
|
||||
};
|
||||
|
||||
/// <summary>Formato del valore secondo l'unità, con gli arrotondamenti dei pannelli.</summary>
|
||||
public static string Format(double v, byte unit, ExplainSubject subject)
|
||||
{
|
||||
if (double.IsPositiveInfinity(v)) return "∞";
|
||||
if (double.IsNegativeInfinity(v)) return "−∞";
|
||||
if (double.IsNaN(v)) return "—";
|
||||
return (ExplainUnit)unit switch
|
||||
{
|
||||
ExplainUnit.Money => new Money((long)Math.Round(v)).ToString(),
|
||||
ExplainUnit.Price => Money.FromCentsRounded(v).ToString(),
|
||||
// l'avanzamento si legge per difetto come nella barra superiore e nella scalata (ADR 0018)
|
||||
ExplainUnit.Percent => subject == ExplainSubject.TierProgress ? Fmt.Progress(v) : Fmt.Pct(v, Math.Abs(v) < 0.01 && v != 0 ? 3 : 1),
|
||||
ExplainUnit.Factor => "× " + Fmt.Number(v, 3),
|
||||
ExplainUnit.Km => Fmt.Number(v, 1) + " km",
|
||||
ExplainUnit.Days => Fmt.Number(v, 1) + " " + T("giorni"),
|
||||
ExplainUnit.Units => Fmt.Number(v, Math.Abs(v - Math.Round(v)) < 1e-9 ? 0 : 1),
|
||||
ExplainUnit.Condition => Fmt.Number(v, 1),
|
||||
ExplainUnit.Years => Fmt.Number(v, 1) + " " + T("anni"),
|
||||
_ => Fmt.Number(v, Math.Abs(v) < 0.01 && v != 0 ? 5 : 3),
|
||||
};
|
||||
}
|
||||
|
||||
private static Label Wrapped(string text, int size, Color color)
|
||||
{
|
||||
var l = UiTheme.Text(text, size, color);
|
||||
l.AutowrapMode = TextServer.AutowrapMode.WordSmart;
|
||||
l.CustomMinimumSize = new Vector2(MaxWidth - 40, 0);
|
||||
l.MouseFilter = MouseFilterEnum.Ignore;
|
||||
return l;
|
||||
}
|
||||
}
|
||||
@@ -246,6 +246,12 @@ public partial class GameScreen : Node
|
||||
|
||||
BuildDisconnectedOverlay(hud);
|
||||
AddChild(_overlay);
|
||||
// tooltip «perché» sopra tutta l'interfaccia (ADR 0024)
|
||||
var why = new CanvasLayer { Layer = 10 };
|
||||
AddChild(why);
|
||||
var whyTooltip = new WhyTooltip(_session);
|
||||
UiTheme.Apply(whyTooltip);
|
||||
why.AddChild(whyTooltip);
|
||||
|
||||
_map.Bind(_session);
|
||||
_minimap.Bind(_session.World, _map);
|
||||
|
||||
Reference in new issue
Block a user