diff --git a/StarterNG/App.axaml.cs b/StarterNG/App.axaml.cs index 3e3c9ba..f28ab44 100644 --- a/StarterNG/App.axaml.cs +++ b/StarterNG/App.axaml.cs @@ -1,14 +1,42 @@ +using System; +using System.Linq; using Avalonia; +using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; +using Avalonia.Markup.Xaml.Styling; +using StarterNG.Services; namespace StarterNG; public partial class App : Application { + + public static LocalizationService Loc { get; } = new(); + public override void Initialize() { AvaloniaXamlLoader.Load(this); + + var langDict = new ResourceInclude(new Uri("avares://StarterNG/")) + { + Source = new Uri("Assets/Langs/English.axaml", UriKind.Relative) + }; + + var resources = Current!.Resources; + + var languageDictionaries = resources.MergedDictionaries + .OfType() + .Where(d => d.Source != null && d.Source.OriginalString.Contains("Langs/")) + .ToList(); + + foreach (var dict in languageDictionaries) + { + resources.MergedDictionaries.Remove(dict); + } + + resources.MergedDictionaries.Add(langDict); + Loc.SetLanguage(langDict); } public override void OnFrameworkInitializationCompleted() diff --git a/StarterNG/Assets/Langs/English.axaml b/StarterNG/Assets/Langs/English.axaml new file mode 100644 index 0000000..a100797 --- /dev/null +++ b/StarterNG/Assets/Langs/English.axaml @@ -0,0 +1,111 @@ + + + General + + Language + Fullscreen + Pause simulation when window is inactive + Pause on start + Cursor sensitivity: + Invert mouse horizontally + Invert mouse vertically + + Communication + + + Ignore gamepad input + + Feedback + Off + Caps: CA/SHP; ScrollLock: starting resistances + Caps: CA; ScrollLock: SHP + LPT + PoKeys55 + Serial port (COM) + + + Other + Select exe: + Select automatically + Debug mode (test mode) + Virtual shunting + + + Graphics + Render engine + Full + Old + Simplified shader + Simplified + Disable visual layer + Experimental + + Resolution: + Buffer resolution: + Maximum texture resolution: + Maximum cabin texture resolution: + Texture filtering quality: + Multisampling: + Rendering range: + VSync + Smoke display + Smoke particles multiplier + + Post-processing + Reinhard + ACES + + Chromatic aberration + Motion blur + Additional shader effects + Reflections as cubemap + Render VBO + Render shadows + Reflections refresh rate + Shadows resolution + Reflections refresh rate + Cabin shadow sources range + + Display shadows + Only important + Limited + All + + Reflections detail level + Terrain geometry only + Terrain geometry and static models + Terrain geometry, static models and vehicles + + Cabin shadow sources range + Render onboard computer screens + Render screens in a separate thread + Onboard screens refresh rate + + Physics + + Track curves quality + Increased physics accuracy + Possibility of pantograph breaking + Powered only under overhead line + Save speedometer tapes + Save simulation log + Keep previous logs + Display simulation + Collision damage + + Sound + Enable sound + Volume + Radio volume + Vehicles volume + Positional sounds volume + Ambient volume + Volume during pause + + Starter + Automatically close starter + Large thumbnails + Automatically expand scenery tree + + diff --git a/StarterNG/Assets/Langs/Polski.axaml b/StarterNG/Assets/Langs/Polski.axaml new file mode 100644 index 0000000..7344d5f --- /dev/null +++ b/StarterNG/Assets/Langs/Polski.axaml @@ -0,0 +1,114 @@ + + + Ogólne + + Język + Tryb pełnoekranowy + Wstrzymaj symulację, gdy okno nie jest aktywne + Pauza po uruchomieniu + Czułość kursora: + Inwersja myszy w poziomie + Inwersja myszy w pionie + + Komunikacja + + + Ignoruj sygnały z gamepada + + Informacja zwrotna + Wyłączona + Caps: CA/SHP; ScrollLock: opory rozr. + Caps: CA; Scrollock: SHP + LPT + PoKeys55 + Serialport (COM) + + + Inne + Wybór exe: + Wybierz automatycznie + Tryb testowy (debugmode) + Wirtualny manewrowy + + + Grafika + Silnik renderowania + Pełny + Stary + Uproszczony shaderowy + Uproszczony + Wyłącz warstwę wizualną + Eksperymentalny + + Rozdzielczość: + Rozdzielczość bufora: + Maksymalna rozdzielczość tekstur: + Maksymalna rozdzielczość tekstur kabiny: + Jakość filtrowania tekstur: + Multisampling: + Zasięg renderowania: + VSync + Wyświetlanie dymu + Mnożnik ilości cząsteczek dymu + + Postprocessing + Reinhard + ACES + + Aberracja chromatyczna + Rozmycie podczas ruchu + Dodatkowe efekty shaderów + Odbicia jako cubemapa + Renderowanie VBO + Renderowanie cieni + Odświeżanie odbić + Rozdzielczość cieni + Odświeżanie odbić + Zasięg źródeł cieni w kabinie + + Wyświetlanie cieni + Tylko ważne + Ograniczone + Wszystkie + + Szczegółowość odbić + Tylko geometria terenu + Geometria terenu i modele statyczne + Geometria terenu, modele statyczne i pojazdy + + Zasięg źródeł cieni w kabinie + Renderowanie ekranów komputerów pokładowych + Renderowanie ekranów w osobnym wątku + Częstotliwość odświeżania ekranów komputerów pokładowych + + Fizyka + + Jakość łuków torów + Zwiększona dokładność fizyki + Możliwość złamania pantografu + Zasilanie tylko pod siecią trakcyjna + Zapisuj taśmy z prędkościomierza + Zapisuj log z symulacji + Zachowuj poprzednie logi + Wyświetlaj symulację + Uszkodzenia przy zderzeniu + + Dżwięk + Włącz dźwięk + Głośność + Głośność radiotelefonu + Głośność pojazdów + Głośność dżwięków pozycjonowanych + Głośność otoczenia + Głośność podczas pauzy + + Starter + Zamknij starter automatycznie + Duże miniaturki + Automatycznie rozwijanie drzewka scenerii + + + + + diff --git a/StarterNG/MainWindow.axaml b/StarterNG/MainWindow.axaml index 03ef0cc..0f52b74 100644 --- a/StarterNG/MainWindow.axaml +++ b/StarterNG/MainWindow.axaml @@ -8,7 +8,7 @@ xmlns:svg="clr-namespace:Avalonia.Svg;assembly=Avalonia.Svg" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:views="clr-namespace:StarterNG.Views" BackgroundStyle="Bubble" - Title="MaSzyna - Symulator pojazdów szynowych" Height="800" Width="1000"> + Title="MaSzyna - Symulator pojazdów szynowych" Height="800" Width="1000" WindowStartupLocation="CenterScreen"> diff --git a/StarterNG/Services/LocalizationService.cs b/StarterNG/Services/LocalizationService.cs new file mode 100644 index 0000000..084e381 --- /dev/null +++ b/StarterNG/Services/LocalizationService.cs @@ -0,0 +1,33 @@ +using System.ComponentModel; +using Avalonia.Controls; +using Avalonia.Styling; + +namespace StarterNG.Services; + +public class LocalizationService : INotifyPropertyChanged +{ + private IResourceProvider _currentProvider = new ResourceDictionary(); + + public event PropertyChangedEventHandler? PropertyChanged; + + + public string this[string key] + { + get + { + if (_currentProvider.TryGetResource(key, null, out var value)) + { + return value?.ToString() ?? key; + } + return key; + } + } + + public void SetLanguage(IResourceProvider provider) + { + _currentProvider = provider; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Item")); + } + + +} \ No newline at end of file diff --git a/StarterNG/StarterNG.csproj b/StarterNG/StarterNG.csproj index 109fb63..e86cfd5 100644 --- a/StarterNG/StarterNG.csproj +++ b/StarterNG/StarterNG.csproj @@ -6,7 +6,6 @@ true app.manifest true - AnyCPU;x64 x64 @@ -31,6 +30,10 @@ + + + + diff --git a/StarterNG/Views/Settings.axaml b/StarterNG/Views/Settings.axaml index 58586c5..8f10973 100644 --- a/StarterNG/Views/Settings.axaml +++ b/StarterNG/Views/Settings.axaml @@ -4,46 +4,57 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:suki="clr-namespace:SukiUI.Controls;assembly=SukiUI" 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"> - + + + - Tryb pełnoekranowy + + + + - Wstrzymaj symulację, gdy okno nie jest aktywne + - Pauza po uruchomieniu + - + - Inwersja myszy w poziomie - Inwersja myszy w pionie + + - + - Ignoruj sygnały z gamepada + - + @@ -51,46 +62,46 @@ - + - + - Tryb testowy (debugmode) + - Wirtualny manewrowy + - + - + - + - Rozdzielczość bufora: + @@ -99,7 +110,7 @@ - Maksymalna rozdzielczość tekstur: + - Maksymalna rozdzielczość tekstur kabiny: + - Jakość filtrowania tekstur + - Multisampling + - Zasięg renderowania + - VSync + - Wyświetlanie dymu + - Mnożnik ilości cząsteczek dymu + - Postprocessing + - Reinhard - ACES + + - Aberracja chromatyczna + - Rozmycie podczas ruchu + - Dodatkowe efekty shaderów + - Odbicia jako cubemapa + - Renderowanie VBO + - Renderowanie cieni + - Odświeżanie odbić + - Rozdzielczość cieni + - Odświeżanie odbić + - Zasięg źródeł cieni w kabinie + - Wyświetlanie cieni + - Tylko ważne - Ograniczone - Wszystkie + + + - Szczegółowość odbić + - Tylko geometria terenu - Geometria terenu i modele statyczne - Geometria terenu, modele statyczne i pojazdy + + + - Zasięg źródeł cieni w kabinie + - Renderowanie ekranów komputerów pokładowych - Renderowanie ekranów w osobnym wątku + + - Częstotliwość odświeżania ekranów komputerów pokładowych + - + - Jakość łuków torów + - Zwiększona dokładność fizyki + - Możliwość złamania pantografu + - Zasilanie tylko pod siecią trakcyjna + - Zapisuj taśmy z prędkościomierza + - Zapisuj log z symulacji + - Zachowuj poprzednie logi + - Wyświetlaj symulację + - Uszkodzenia przy zderzeniu + - + - Włącz dźwięk + - Głośność + - Głośność radiotelefonu + - Głośność pojazdów + - Głośność dżwięków pozycjonowanych + - Głośność otoczenia + - Głośność podczas pauzy + - + - Zamknij starter automatycznie - Duże miniaturki - Automatycznie rozwijanie drzewka scenerii + + + diff --git a/StarterNG/Views/Settings.axaml.cs b/StarterNG/Views/Settings.axaml.cs index c4fd91b..6b62f7b 100644 --- a/StarterNG/Views/Settings.axaml.cs +++ b/StarterNG/Views/Settings.axaml.cs @@ -1,8 +1,10 @@ using System; +using System.Linq; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Markup.Xaml; +using Avalonia.Markup.Xaml.Styling; namespace StarterNG.Views; @@ -45,4 +47,28 @@ public partial class Settings : UserControl int resolution = 1 << (int)shaderResolutionSlider.Value; shaderResolution.Text = $"{resolution} px"; } + + private void LanguageComboBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) + { + if (sender is not ComboBox { SelectedItem: ComboBoxItem item }) return; + 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() + .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); + } } \ No newline at end of file