mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-01 04:19:07 +01:00
Show bare keys in settings, fix the depot detail tabs
Drops the vehicle counter from the General tab, and the texture tab stops gluing "label: value" into single lines and uses the same rows as General.
This commit is contained in:
@@ -164,7 +164,7 @@
|
||||
</TabItem>
|
||||
<TabItem Header="{Binding [AboutTexture], Source={x:Static starterNg:App.Loc}}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Name="consistTexturePanel" Margin="4" Spacing="3" />
|
||||
<StackPanel Name="consistTexturePanel" Margin="4" Grid.IsSharedSizeScope="True" />
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
@@ -17,6 +17,7 @@ using StarterNG.Domain;
|
||||
using StarterNG.Domain.Sceneries;
|
||||
using StarterNG.Domain.Vehicles;
|
||||
using StarterNG.Application;
|
||||
using StarterNG.Controls;
|
||||
|
||||
namespace StarterNG.Views;
|
||||
|
||||
@@ -411,37 +412,44 @@ public sealed class VehicleBrowser
|
||||
return menu;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills a detail panel with what is known about a livery: the skin itself,
|
||||
/// then whatever its credit line carries.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Built from the same <see cref="DetailRows"/> as the general tab, so the
|
||||
/// labels line up in a column instead of each line being its own sentence.
|
||||
/// Fields the credit line leaves out are dropped rather than shown as
|
||||
/// blanks - most liveries fill in only a few.
|
||||
/// </remarks>
|
||||
public void ShowTextureInfo(VehicleTexture texture, StackPanel target)
|
||||
{
|
||||
target.Children.Clear();
|
||||
|
||||
var full = new List<string>();
|
||||
void Row(string label, string? value)
|
||||
var tooltip = new List<string>();
|
||||
|
||||
void Reading(string label, string? value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)) return;
|
||||
string line = $"{label}: {value}";
|
||||
full.Add(line);
|
||||
target.Children.Add(new TextBlock
|
||||
{
|
||||
Text = line,
|
||||
FontSize = 12,
|
||||
Opacity = 0.85,
|
||||
TextTrimming = TextTrimming.CharacterEllipsis
|
||||
});
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return;
|
||||
|
||||
target.Children.Add(DetailRows.Reading(label, value));
|
||||
tooltip.Add($"{label}: {value}");
|
||||
}
|
||||
|
||||
Row(App.Loc["TextureInfo"], Consist.Base(texture.Skinfile));
|
||||
var meta = texture.Meta;
|
||||
if (meta != null)
|
||||
Reading(App.Loc["TextureInfo"], Consist.Base(texture.Skinfile));
|
||||
|
||||
if (texture.Meta is { } meta)
|
||||
{
|
||||
Row(App.Loc["TexOperator"], meta.Operator);
|
||||
Row(App.Loc["TexStation"], meta.Depot);
|
||||
Row(App.Loc["TexRevision"], meta.RevisionDate);
|
||||
Row(App.Loc["TexWorks"], meta.RevisionPlace);
|
||||
Row(App.Loc["TexAuthor"], meta.TextureAuthor);
|
||||
Row(App.Loc["TexPhoto"], meta.PhotoAuthor);
|
||||
Reading(App.Loc["TexOperator"], meta.Operator);
|
||||
Reading(App.Loc["TexStation"], meta.Depot);
|
||||
Reading(App.Loc["TexRevision"], meta.RevisionDate);
|
||||
Reading(App.Loc["TexWorks"], meta.RevisionPlace);
|
||||
Reading(App.Loc["TexAuthor"], meta.TextureAuthor);
|
||||
Reading(App.Loc["TexPhoto"], meta.PhotoAuthor);
|
||||
}
|
||||
ToolTip.SetTip(target, string.Join("\n", full));
|
||||
|
||||
ToolTip.SetTip(target, string.Join("\n", tooltip));
|
||||
}
|
||||
|
||||
public List<VehicleTexture> CurrentTextures()
|
||||
|
||||
@@ -147,10 +147,6 @@ public sealed class VehicleDetails
|
||||
generalPanel.Children.Add(Reading($"{App.Loc["VMax"]} [km/h]",
|
||||
vmax?.ToString("0", inv)));
|
||||
|
||||
if (unit)
|
||||
generalPanel.Children.Add(Reading(App.Loc["VehicleCount"],
|
||||
item.Cars.Count.ToString(inv)));
|
||||
|
||||
generalPanel.Children.Add(Reading(App.Loc["Model"], car.MmdFile));
|
||||
generalPanel.Children.Add(Reading(App.Loc["Texture"], car.SkinFile));
|
||||
}
|
||||
@@ -347,39 +343,12 @@ public sealed class VehicleDetails
|
||||
.Any(s => s.Equals("passengers", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The one row shape every detail tab uses. The label column negotiates its width
|
||||
/// through the shared-size group on the host panel, so all rows in a panel line up
|
||||
/// without anyone naming a pixel count - see the Compact styles in Settings.axaml.
|
||||
/// Omitting <paramref name="content"/> makes it a read-only line; omitting
|
||||
/// <paramref name="label"/> indents a bare widget to the control column.
|
||||
/// </summary>
|
||||
private static SettingRow Row(string? label = null, Control? content = null,
|
||||
string? value = null, string? description = null,
|
||||
string? tip = null)
|
||||
{
|
||||
var row = new SettingRow
|
||||
{
|
||||
Label = label,
|
||||
Description = description,
|
||||
ValueText = value,
|
||||
Content = content
|
||||
};
|
||||
row.Classes.Add("Compact");
|
||||
if (!string.IsNullOrWhiteSpace(tip))
|
||||
ToolTip.SetTip(row, tip);
|
||||
return row;
|
||||
}
|
||||
string? tip = null) =>
|
||||
DetailRows.Row(label, content, value, description, tip);
|
||||
|
||||
/// <summary>
|
||||
/// A read-only label/value line. The dash keeps the row from collapsing when a
|
||||
/// vehicle has no reading for the field.
|
||||
/// </summary>
|
||||
private static SettingRow Reading(string label, string? value)
|
||||
{
|
||||
bool empty = string.IsNullOrWhiteSpace(value);
|
||||
return Row(label, value: empty ? "\u2013" : value, tip: empty ? null : value);
|
||||
}
|
||||
private static SettingRow Reading(string label, string? value) => DetailRows.Reading(label, value);
|
||||
|
||||
private static SettingsSection Section(string header, Control content, Control? meta = null)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,6 @@ using Avalonia.Markup.Xaml.Styling;
|
||||
using Avalonia.Media;
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Controls;
|
||||
using StarterNG.Infrastructure.Settings;
|
||||
using StarterNG.Infrastructure;
|
||||
using StarterNG.Services;
|
||||
|
||||
@@ -65,7 +64,6 @@ public partial class Settings : UserControl, ISettingsCapture
|
||||
|
||||
AppServices.Current.SettingsStore.RegisterCapture(this);
|
||||
|
||||
AnnotateConfigKeys();
|
||||
PopulateProfileCombo();
|
||||
ApplyToUi();
|
||||
|
||||
@@ -162,19 +160,6 @@ public partial class Settings : UserControl, ISettingsCapture
|
||||
|
||||
public void ReloadFromSettings() => ApplyToUi();
|
||||
|
||||
/// <summary>
|
||||
/// Expands each row's eu07.ini key into "key = default (range)", so the line
|
||||
/// under a setting says what the file holds rather than paraphrasing what the
|
||||
/// setting does.
|
||||
/// </summary>
|
||||
private void AnnotateConfigKeys()
|
||||
{
|
||||
// Logical, not visual: the rows exist as soon as the XAML is loaded,
|
||||
// while categories that are not on screen yet have no visual tree.
|
||||
foreach (var row in this.GetLogicalDescendants().OfType<SettingRow>())
|
||||
row.ConfigKey = SettingKeyCatalog.Annotate(row.ConfigKey);
|
||||
}
|
||||
|
||||
private void ApplyToUi()
|
||||
{
|
||||
var s = AppServices.Current.Settings;
|
||||
|
||||
Reference in New Issue
Block a user