Starter improvements

- scenery Description
- scenery mini
- extracted translations outside
- autoselect first consist on scenery selection
- autoexpand on group click
This commit is contained in:
2026-06-17 22:00:01 +02:00
parent 9be97c7bda
commit b2f693113d
22 changed files with 776 additions and 634 deletions

View File

@@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:starterNg="clr-namespace:StarterNG"
xmlns:views="clr-namespace:StarterNG.Views"
x:CompileBindings="True"
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="700"
x:Class="StarterNG.Views.Depot">
<Grid Margin="16" ColumnSpacing="16" RowSpacing="16">

View File

@@ -1,15 +1,17 @@
<UserControl xmlns="https://github.com/avaloniaui"
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:sukiUi="clr-namespace:SukiUI.Controls;assembly=SukiUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:starterNg="clr-namespace:StarterNG"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="StarterNG.Views.Scenarios">
x:Class="StarterNG.Views.Scenarios"
x:CompileBindings="True">
<Grid Margin="16" ColumnSpacing="16" RowSpacing="16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition />
<ColumnDefinition Width="280" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
@@ -19,7 +21,7 @@
</Grid.RowDefinitions>
<sukiUi:GroupBox Grid.RowSpan="2" Header="{Binding [Sceneries], Source={x:Static starterNg:App.Loc}}">
<TreeView Name="sceneryList" SelectionChanged="SceneryList_OnSelectionChanged">
</TreeView>
</sukiUi:GroupBox>
<sukiUi:GroupBox Grid.Column="1" Header="{Binding [Vehicles], Source={x:Static starterNg:App.Loc}}">
@@ -34,7 +36,20 @@
</sukiUi:GroupBox>
<sukiUi:GroupBox Header="{Binding [Consist], Source={x:Static starterNg:App.Loc}}" Grid.Row="2" Grid.ColumnSpan="2">
<!-- Scenery image (//$i) shown as a 1:1 square thumbnail -->
<Border Grid.Column="2" Grid.Row="0" ClipToBounds="True" VerticalAlignment="Top"
Height="{Binding $self.Bounds.Width}">
<Image Name="sceneryImage" Stretch="Uniform" />
</Border>
<!-- Scenery description (//$d), distinct from the scenario/consist description -->
<sukiUi:GroupBox Grid.Column="2" Grid.Row="1" Header="{Binding [SceneryDescription], Source={x:Static starterNg:App.Loc}}">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<TextBlock TextWrapping="Wrap" Name="sceneryDescription">
</TextBlock>
</ScrollViewer>
</sukiUi:GroupBox>
<sukiUi:GroupBox Header="{Binding [Consist], Source={x:Static starterNg:App.Loc}}" Grid.Row="2" Grid.ColumnSpan="3">
<ScrollViewer VerticalAlignment="Bottom"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Disabled">
@@ -44,10 +59,10 @@
</sukiUi:GroupBox>
<Button Grid.Column="0" Height="36" Classes="Flat"
VerticalAlignment="Bottom" Grid.Row="3" Grid.ColumnSpan="2"
VerticalAlignment="Bottom" Grid.Row="3" Grid.ColumnSpan="3"
Click="StartButton_OnClick"
Content="{Binding [Start], Source={x:Static starterNg:App.Loc}}">
</Button>
</Grid>
</UserControl>
</UserControl>

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -74,6 +74,9 @@ public partial class Scenarios : UserControl
Scenery selectedScn = Sceneries[tag];
vehicleList.Items.Clear();
// scenery-level info (distinct from the per-consist scenario description)
ShowSceneryInfo(selectedScn);
// add all trainsets to list
for (int i = 0; i < selectedScn.Trainsets.Count; i++)
{
@@ -91,6 +94,29 @@ public partial class Scenarios : UserControl
}
// Shows the selected scenery's description (//$d) and 1:1 image (//$i).
private void ShowSceneryInfo(Scenery scenery)
{
sceneryDescription.Text = scenery.Description;
string? imagePath = scenery.ImagePath;
if (imagePath is not null)
{
try
{
sceneryImage.Source = new Bitmap(imagePath);
}
catch
{
sceneryImage.Source = null; // unreadable / unsupported image
}
}
else
{
sceneryImage.Source = null;
}
}
private void VehicleList_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
// get selected scenery
@@ -190,4 +216,4 @@ public partial class Scenarios : UserControl
// executable not found / not configured yet
}
}
}
}

View File

@@ -6,7 +6,8 @@
xmlns:objectModel="clr-namespace:System.Collections.ObjectModel;assembly=System.ObjectModel"
xmlns:starterNg="clr-namespace:StarterNG"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="StarterNG.Views.Settings">
x:Class="StarterNG.Views.Settings"
x:CompileBindings="True">
<DockPanel>
<!-- Save / reset bar -->
<Border DockPanel.Dock="Bottom" Padding="16,10" Background="#11000000">

View File

@@ -288,22 +288,7 @@ public partial class Settings : UserControl
var lang = item.Content?.ToString();
if (string.IsNullOrEmpty(lang)) return;
var langDict = new ResourceInclude(new Uri("avares://StarterNG/"))
{
Source = new Uri($"Assets/Langs/{lang}.axaml", UriKind.Relative)
};
var currentLangDict = App.Current.Resources.MergedDictionaries
.OfType<ResourceInclude>()
.FirstOrDefault(d => d.Source != null && d.Source.OriginalString.Contains("Langs/"));
if (currentLangDict != null)
{
App.Current.Resources.MergedDictionaries.Remove(currentLangDict);
}
App.Current.Resources.MergedDictionaries.Add(langDict);
App.Loc.SetLanguage(langDict, lang);
App.ApplyLanguage(lang);
}
// ── tiny helpers ──────────────────────────────────────────────────────