mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-27 17:09:37 +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>
113 lines
3.9 KiB
C#
113 lines
3.9 KiB
C#
using System;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.Primitives;
|
|
|
|
namespace StarterNG.Controls;
|
|
|
|
public class SettingsSection : HeaderedContentControl
|
|
{
|
|
/// <summary>Every row of the section is for the advanced mode only.</summary>
|
|
public static readonly StyledProperty<bool> AdvancedProperty =
|
|
AvaloniaProperty.Register<SettingsSection, bool>(nameof(Advanced));
|
|
|
|
public bool Advanced
|
|
{
|
|
get => GetValue(AdvancedProperty);
|
|
set => SetValue(AdvancedProperty, value);
|
|
}
|
|
|
|
public static readonly StyledProperty<object?> ToggleProperty =
|
|
AvaloniaProperty.Register<SettingsSection, object?>(nameof(Toggle));
|
|
|
|
public static readonly StyledProperty<string?> ToggleKeyProperty =
|
|
AvaloniaProperty.Register<SettingsSection, string?>(nameof(ToggleKey));
|
|
|
|
public static readonly StyledProperty<string?> ResetLabelProperty =
|
|
AvaloniaProperty.Register<SettingsSection, string?>(nameof(ResetLabel));
|
|
|
|
public static readonly StyledProperty<object?> LevelProperty =
|
|
AvaloniaProperty.Register<SettingsSection, object?>(nameof(Level));
|
|
|
|
private Button? _reset;
|
|
|
|
/// <summary>The header's choice of a level of detail for this section alone; none where it has no such thing.</summary>
|
|
public object? Level
|
|
{
|
|
get => GetValue(LevelProperty);
|
|
set => SetValue(LevelProperty, value);
|
|
}
|
|
|
|
public object? Toggle
|
|
{
|
|
get => GetValue(ToggleProperty);
|
|
set => SetValue(ToggleProperty, value);
|
|
}
|
|
|
|
/// <summary>The eu07.ini key the header's switch sets.</summary>
|
|
public string? ToggleKey
|
|
{
|
|
get => GetValue(ToggleKeyProperty);
|
|
set => SetValue(ToggleKeyProperty, value);
|
|
}
|
|
|
|
/// <summary>The words on the header's button that puts the section back as the simulator has it; none, no button.</summary>
|
|
public string? ResetLabel
|
|
{
|
|
get => GetValue(ResetLabelProperty);
|
|
set => SetValue(ResetLabelProperty, value);
|
|
}
|
|
|
|
/// <summary>Raised when the header's reset button is pressed.</summary>
|
|
public event Action<SettingsSection>? ResetRequested;
|
|
|
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
|
{
|
|
base.OnApplyTemplate(e);
|
|
if (_reset is not null)
|
|
_reset.Click -= OnResetClick;
|
|
_reset = e.NameScope.Find<Button>("PART_Reset");
|
|
if (_reset is not null)
|
|
_reset.Click += OnResetClick;
|
|
NameReset();
|
|
}
|
|
|
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
|
{
|
|
base.OnPropertyChanged(change);
|
|
if (change.Property == HeaderProperty || change.Property == ResetLabelProperty)
|
|
NameReset();
|
|
if (change.Property == HeaderProperty || change.Property == LevelProperty)
|
|
NameLevel();
|
|
}
|
|
|
|
/// <summary>
|
|
/// The header's list of levels was named by the word it shows with nothing chosen,
|
|
/// "Własne"; it is named as the level of this section.
|
|
/// </summary>
|
|
private void NameLevel()
|
|
{
|
|
if (Level is Control level)
|
|
Avalonia.Automation.AutomationProperties.SetName(level, ScreenReaderNames.PickerText(
|
|
AppLanguage.Text("SectionLevel"), ScreenReaderNames.TextOf(Header)));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Every section has a button with the same words; a reader is told which section
|
|
/// it puts back, as a sighted one sees from where it stands.
|
|
/// </summary>
|
|
private void NameReset()
|
|
{
|
|
if (_reset is null)
|
|
return;
|
|
|
|
string? name = ScreenReaderNames.PickerText(ResetLabel, ScreenReaderNames.TextOf(Header));
|
|
if (string.IsNullOrEmpty(name))
|
|
_reset.ClearValue(Avalonia.Automation.AutomationProperties.NameProperty);
|
|
else
|
|
Avalonia.Automation.AutomationProperties.SetName(_reset, name);
|
|
}
|
|
|
|
private void OnResetClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e) => ResetRequested?.Invoke(this);
|
|
}
|