mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-05 05:24:26 +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:
@@ -3,6 +3,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:starterNg="clr-namespace:StarterNG"
|
||||
xmlns:infra="clr-namespace:StarterNG.Infrastructure"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="StarterNG.Views.Scenarios"
|
||||
x:CompileBindings="True">
|
||||
@@ -28,7 +29,7 @@
|
||||
OnContent="{Binding [ShowArchival], Source={x:Static starterNg:App.Loc}}"
|
||||
OffContent="{Binding [ShowArchival], Source={x:Static starterNg:App.Loc}}" />
|
||||
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Spacing="8" Margin="2,4,0,0">
|
||||
<Button Classes="Flat" FontSize="11" Padding="8,2" Cursor="Hand"
|
||||
<Button x:Name="reloadButton" Classes="Flat" FontSize="11" Padding="8,2" Cursor="Hand"
|
||||
Click="ReloadSceneries_OnClick"
|
||||
Content="{Binding [ReloadSceneries], Source={x:Static starterNg:App.Loc}}" />
|
||||
<Button Classes="Flat" FontSize="11" Padding="8,2" Cursor="Hand"
|
||||
@@ -158,15 +159,16 @@
|
||||
</TabItem>
|
||||
<TabItem Header="{Binding [Timetable], Source={x:Static starterNg:App.Loc}}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
||||
<TextBlock Name="timetableContent" Margin="4" FontFamily="Consolas, monospace"
|
||||
FontSize="12" />
|
||||
<TextBlock Name="timetableContent" Margin="4"
|
||||
FontFamily="{x:Static infra:MonoFont.Family}"
|
||||
FontSize="12" TextWrapping="NoWrap" />
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Name="infoTab" Header="{Binding [TabInfo], Source={x:Static starterNg:App.Loc}}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<TextBox Name="faultListBox" Margin="4" IsReadOnly="True"
|
||||
AcceptsReturn="True" TextWrapping="Wrap"
|
||||
FontFamily="Consolas, monospace" FontSize="12" />
|
||||
FontFamily="{x:Static infra:MonoFont.Family}" FontSize="12" />
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
@@ -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