mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-23 08:35:04 +01:00
Load sceneries in parallel and skip the splash on a fast start
Scenery parsing runs on Parallel.ForEach and the reload button does it off the UI thread. The splash window only appears when loading passes 300ms, so a warm start goes straight to the main window. The log button moves into the navigation row, dropping the separate caption strip; timetable and info use the shared MonoFont family instead of a hard-coded Consolas.
This commit is contained in:
@@ -6,6 +6,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
@@ -488,18 +489,26 @@ public partial class Scenarios : UserControl
|
||||
ShowSceneryInfo(AppState.Instance.CurrentScenery);
|
||||
}
|
||||
|
||||
private void ReloadSceneries_OnClick(object? sender, RoutedEventArgs e)
|
||||
private async void ReloadSceneries_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
string? selected = AppState.Instance.CurrentScenery?.Path;
|
||||
GameData.Instance.ReloadSceneries();
|
||||
Sceneries = GameData.Instance.Sceneries;
|
||||
BuildSceneryTree();
|
||||
if (!string.IsNullOrEmpty(selected))
|
||||
reloadButton.IsEnabled = false;
|
||||
try
|
||||
{
|
||||
StarterNG.Classes.Settings.Instance.LastScenery =
|
||||
Path.GetFileNameWithoutExtension(selected);
|
||||
string? selected = AppState.Instance.CurrentScenery?.Path;
|
||||
await Task.Run(() => GameData.Instance.ReloadSceneries());
|
||||
Sceneries = GameData.Instance.Sceneries;
|
||||
BuildSceneryTree();
|
||||
if (!string.IsNullOrEmpty(selected))
|
||||
{
|
||||
StarterNG.Classes.Settings.Instance.LastScenery =
|
||||
Path.GetFileNameWithoutExtension(selected);
|
||||
}
|
||||
RestoreLastScenery();
|
||||
}
|
||||
finally
|
||||
{
|
||||
reloadButton.IsEnabled = true;
|
||||
}
|
||||
RestoreLastScenery();
|
||||
}
|
||||
|
||||
private void OpenSceneryDir_OnClick(object? sender, RoutedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user