Check GitHub for a newer starter once a day, with a button to check now

The stable channel compares versions; the testing channel offers the staging
build of another commit. The channel switch is the starter's only, not the
simulator's.
This commit is contained in:
maj00r
2026-10-04 13:26:49 +02:00
parent a7a1e34239
commit 2b3c46938c
19 changed files with 777 additions and 1 deletions

View File

@@ -206,6 +206,8 @@ public partial class Settings : UserControl, ISettingsCapture
VirtualShuntingCb.IsChecked = s.VirtualShunting;
LogMissingVehicleFilesCb.IsChecked = s.LogMissingVehicleFiles;
DeveloperToolsCb.IsChecked = s.DeveloperTools;
CheckUpdatesCb.IsChecked = s.CheckForUpdates;
UpdateChannelCb.SelectedIndex = s.UpdateChannel == UpdateChannel.Staging ? 1 : 0;
RenderEngineCb.SelectedIndex = s.RenderEngine;
SelectResolution(s.Width, s.Height);
@@ -305,6 +307,8 @@ public partial class Settings : UserControl, ISettingsCapture
s.VirtualShunting = IsChecked(VirtualShuntingCb);
s.LogMissingVehicleFiles = IsChecked(LogMissingVehicleFilesCb);
s.DeveloperTools = IsChecked(DeveloperToolsCb);
s.CheckForUpdates = IsChecked(CheckUpdatesCb);
s.UpdateChannel = SelectedChannel();
s.RenderEngine = Math.Max(0, RenderEngineCb.SelectedIndex);
ReadResolution(s);
@@ -388,6 +392,36 @@ public partial class Settings : UserControl, ISettingsCapture
SaveStatus.Text = App.Loc["SettingsSaved"];
}
private UpdateChannel SelectedChannel() =>
UpdateChannelCb.SelectedIndex == 1 ? UpdateChannel.Staging : UpdateChannel.Stable;
private void UpdateChannelCb_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
if (UpdateChannelWarning is not null)
UpdateChannelWarning.IsVisible = SelectedChannel() == UpdateChannel.Staging;
}
/// <summary>Checks the channel picked in the list, saved or not, so it can be tried first.</summary>
private async void CheckUpdatesNowButton_OnClick(object? sender, RoutedEventArgs e)
{
var updates = AppServices.Current.Updates;
CheckUpdatesNowButton.IsEnabled = false;
CheckUpdatesStatus.Text = App.Loc["UpdateChecking"];
try
{
CheckUpdatesStatus.Text = await updates.CheckNowAsync(SelectedChannel()) switch
{
UpdateCheckOutcome.UpdateAvailable => string.Format(App.Loc["UpdateFound"], updates.Available!.Label),
UpdateCheckOutcome.UpToDate => string.Format(App.Loc["UpdateUpToDate"], updates.Current),
_ => App.Loc["UpdateCheckFailed"]
};
}
finally
{
CheckUpdatesNowButton.IsEnabled = true;
}
}
private void RedrawNavIfNeeded()
{
bool developer = AppServices.Current.Settings.DeveloperTools;