mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-24 00:49:11 +01:00
The settings keep only the keys master reads, Vulkan left out. The standard mode is the old starter's panel; the advanced mode opens behind a warning whose yes takes a click only after 20 seconds in front of the player. - Sliders go by fixed steps (SliderRanges), held to the standard ranges there: fpslimit up to 240, sleeperdistance up to 1000 m. - On the first start everyone is moved to the standard mode once: what is outside it goes back to its default, the sliders' values to their ranges, and a copy of eu07.ini is kept as eu07.ini.before-standard. - "Restore defaults" puts every setting back, the language, the simulator, the UART port and the control keys kept. - Monitors and renderers are found anew (Monitors, Renderers), Displays and SettingReach gone. - mousescale writes its second number as the old starter did, 0.5 or -0.5 for an inverted vertical axis; an axis that would not move gets the default. - Depot, in the standard mode: no AI or drivable-only filters, empty consists not listed, the crew shown but not changed. - Randomizing the textures of a whole scenery no longer rebuilds the view per consist, and finds its candidates by mini, so the window keeps answering. - A long operator in the vehicle list is cut short instead of over the name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
115 lines
4.0 KiB
C#
115 lines
4.0 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
|
|
namespace StarterNG.Controls;
|
|
|
|
public class SettingRow : ContentControl
|
|
{
|
|
public static readonly StyledProperty<string?> LabelProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(Label));
|
|
|
|
public static readonly StyledProperty<string?> DescriptionProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(Description));
|
|
|
|
public static readonly StyledProperty<string?> ConfigKeyProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(ConfigKey));
|
|
|
|
public static readonly StyledProperty<string?> ValueTextProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(ValueText));
|
|
|
|
/// <summary>
|
|
/// A setting for those who know what it does: the standard mode leaves it out, as
|
|
/// one a player can break the game with or has no need of.
|
|
/// </summary>
|
|
public static readonly StyledProperty<bool> AdvancedProperty =
|
|
AvaloniaProperty.Register<SettingRow, bool>(nameof(Advanced));
|
|
|
|
public bool Advanced
|
|
{
|
|
get => GetValue(AdvancedProperty);
|
|
set => SetValue(AdvancedProperty, value);
|
|
}
|
|
|
|
/// <summary>The value eu07.ini gives the setting that the starter cannot read, said under it; null when there is none.</summary>
|
|
public static readonly StyledProperty<string?> UnknownValueProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(UnknownValue));
|
|
|
|
public string? UnknownValue
|
|
{
|
|
get => GetValue(UnknownValueProperty);
|
|
set => SetValue(UnknownValueProperty, value);
|
|
}
|
|
|
|
public string? Label
|
|
{
|
|
get => GetValue(LabelProperty);
|
|
set => SetValue(LabelProperty, value);
|
|
}
|
|
|
|
public string? Description
|
|
{
|
|
get => GetValue(DescriptionProperty);
|
|
set => SetValue(DescriptionProperty, value);
|
|
}
|
|
|
|
public string? ConfigKey
|
|
{
|
|
get => GetValue(ConfigKeyProperty);
|
|
set => SetValue(ConfigKeyProperty, value);
|
|
}
|
|
|
|
public string? ValueText
|
|
{
|
|
get => GetValue(ValueTextProperty);
|
|
set => SetValue(ValueTextProperty, value);
|
|
}
|
|
|
|
public SettingRow()
|
|
{
|
|
UpdatePseudoClasses();
|
|
}
|
|
|
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
|
{
|
|
base.OnPropertyChanged(change);
|
|
|
|
if (change.Property == LabelProperty ||
|
|
change.Property == DescriptionProperty ||
|
|
change.Property == ConfigKeyProperty ||
|
|
change.Property == ValueTextProperty ||
|
|
change.Property == UnknownValueProperty ||
|
|
change.Property == ContentProperty)
|
|
UpdatePseudoClasses();
|
|
|
|
if (change.Property == LabelProperty || change.Property == ContentProperty)
|
|
ScreenReaderNames.NameInputs(Content, Label);
|
|
|
|
if (change.Property == ValueTextProperty || change.Property == ContentProperty)
|
|
ScreenReaderNames.TellValue(Content, ValueText);
|
|
|
|
if (change.Property == DescriptionProperty || change.Property == UnknownValueProperty ||
|
|
change.Property == ContentProperty)
|
|
ScreenReaderNames.DescribeInputs(Content, Description, UnknownValue);
|
|
}
|
|
|
|
// Again once in the window: a panel given as content may be filled after it was set.
|
|
protected override void OnLoaded(RoutedEventArgs e)
|
|
{
|
|
base.OnLoaded(e);
|
|
ScreenReaderNames.NameInputs(Content, Label);
|
|
ScreenReaderNames.TellValue(Content, ValueText);
|
|
ScreenReaderNames.DescribeInputs(Content, Description, UnknownValue);
|
|
}
|
|
|
|
private void UpdatePseudoClasses()
|
|
{
|
|
PseudoClasses.Set(":no-label", string.IsNullOrEmpty(Label));
|
|
PseudoClasses.Set(":no-description", string.IsNullOrEmpty(Description));
|
|
PseudoClasses.Set(":no-key", string.IsNullOrEmpty(ConfigKey));
|
|
PseudoClasses.Set(":no-value", string.IsNullOrEmpty(ValueText));
|
|
PseudoClasses.Set(":no-content", Content is null);
|
|
PseudoClasses.Set(":unknown", !string.IsNullOrEmpty(UnknownValue));
|
|
}
|
|
}
|