diff --git a/StarterNG.Tests/StartSimulationTests.cs b/StarterNG.Tests/StartSimulationTests.cs
index 744c5f7..9c9d563 100644
--- a/StarterNG.Tests/StartSimulationTests.cs
+++ b/StarterNG.Tests/StartSimulationTests.cs
@@ -95,6 +95,18 @@ public class StartSimulationTests
Assert.Equal(new[] { "second", "third" }, start.SimulatorLogTail(2));
}
+ [Fact]
+ public void The_editor_opens_the_scenery_itself_not_an_export()
+ {
+ var (start, launcher, installation) = Rig(files => files.WithExecutable(Build));
+
+ var result = start.ExecuteEditor();
+
+ Assert.Equal(SimulationStartOutcome.Started, result.Outcome);
+ Assert.Equal(new[] { "-edit", "td.scn" }, launcher.Arguments);
+ Assert.False(installation.Files.FileExists(TestInstallation.At("scenery", "$td.scn")));
+ }
+
[Fact]
public void A_file_that_cannot_be_run_is_not()
{
diff --git a/StarterNG/Application/StartSimulation.cs b/StarterNG/Application/StartSimulation.cs
index b1a25c0..d24d2ac 100644
--- a/StarterNG/Application/StartSimulation.cs
+++ b/StarterNG/Application/StartSimulation.cs
@@ -183,6 +183,27 @@ public sealed class StartSimulation
if (saveSettings)
_settings.CaptureAndSave();
+ string[] arguments = freeFly || string.IsNullOrEmpty(vehicle)
+ ? new[] { "-s", exportName }
+ : new[] { "-s", exportName, "-v", vehicle };
+
+ return Launch(arguments);
+ }
+
+ ///
+ /// Opens the selected scenery in the simulator's editor. The scenery file itself,
+ /// not an export: what the editor saves has to land in the scenery.
+ ///
+ public SimulationStartResult ExecuteEditor()
+ {
+ if (_state.CurrentScenery is not { } scenery)
+ return new SimulationStartResult(SimulationStartOutcome.NothingSelected);
+
+ return Launch(new[] { "-edit", Path.GetFileName(scenery.Path) });
+ }
+
+ private SimulationStartResult Launch(IReadOnlyList arguments)
+ {
string executable = Path.GetFullPath(_settings.ResolveExecutable(out var problem));
// A binary for the other system is let through: on Linux a Windows build
@@ -191,10 +212,6 @@ public sealed class StartSimulation
return new SimulationStartResult(SimulationStartOutcome.ExecutableProblem, ExecutablePath: executable,
Problem: problem);
- string[] arguments = freeFly || string.IsNullOrEmpty(vehicle)
- ? new[] { "-s", exportName }
- : new[] { "-s", exportName, "-v", vehicle };
-
// The installation, not the folder of the binary: a simulator picked from a
// build tree lives beside the data, and the data is what it opens.
var (program, programArguments) = _executables.LaunchCommand(executable, arguments);
diff --git a/StarterNG/MainWindow.axaml.cs b/StarterNG/MainWindow.axaml.cs
index b1ddeec..6bb4895 100644
--- a/StarterNG/MainWindow.axaml.cs
+++ b/StarterNG/MainWindow.axaml.cs
@@ -469,6 +469,15 @@ public partial class MainWindow : Window
freeFly.Click += async (_, _) => await LaunchAsync(saveSettings: true, freeFly: true);
menu.Items.Add(freeFly);
+ menu.Items.Add(new Separator());
+ var editor = new MenuItem
+ {
+ Header = App.Loc["StartEditor"],
+ IsEnabled = AppServices.Current.State.CurrentScenery is not null
+ };
+ editor.Click += async (_, _) => await LaunchEditorAsync();
+ menu.Items.Add(editor);
+
menu.Open(startButton);
}
@@ -490,7 +499,28 @@ public partial class MainWindow : Window
LoadingScreen.Prepare(trainset.Logo, Path.GetFileNameWithoutExtension(scenery.Path));
- var result = AppServices.Current.StartSimulation.Execute(freeFly, saveSettings);
+ await FollowStartAsync(AppServices.Current.StartSimulation.Execute(freeFly, saveSettings));
+ }
+
+ ///
+ /// The scenery editor, which only some simulator builds have - said up front,
+ /// since one without it simply does not open it.
+ ///
+ private async Task LaunchEditorAsync()
+ {
+ if (AppServices.Current.State.CurrentScenery is not { } scenery)
+ return;
+
+ if (!await MessageBox.Show(this, string.Format(App.Loc["StartEditorWarning"], Path.GetFileName(scenery.Path)),
+ App.Loc["StartEditor"], MessageBoxButtons.YesNo))
+ return;
+
+ await FollowStartAsync(AppServices.Current.StartSimulation.ExecuteEditor());
+ }
+
+ /// Reports a start that failed, or steps aside for the simulator that started.
+ private async Task FollowStartAsync(SimulationStartResult result)
+ {
switch (result.Outcome)
{
case SimulationStartOutcome.NothingSelected:
diff --git a/StarterNG/startercfg/lang/cz.xml b/StarterNG/startercfg/lang/cz.xml
index ad89e46..f48abdd 100644
--- a/StarterNG/startercfg/lang/cz.xml
+++ b/StarterNG/startercfg/lang/cz.xml
@@ -557,6 +557,8 @@
Přidat soupravy ze souboru...
Spustit bez uložení nastavení
Spustit bez vozidla
+ Spustit editor scenérie
+ Editor scenérie (eu07 -edit) mají jen některé verze simulátoru. Pokud ho vybraný simulátor nepodporuje, editor se neotevře. Editor pracuje přímo se souborem {0}, ne s kopií od starteru, takže uložené změny se zapíší do scenérie. Spustit?
Hlasitost při pauze
Zobrazovat průběh simulace
Frekvence obnovení doplňkových obrazovek
diff --git a/StarterNG/startercfg/lang/en.xml b/StarterNG/startercfg/lang/en.xml
index 31e184b..2bd4711 100644
--- a/StarterNG/startercfg/lang/en.xml
+++ b/StarterNG/startercfg/lang/en.xml
@@ -592,6 +592,8 @@
Add consists from file...
Start without saving settings
Start with no vehicle
+ Open the scenery editor
+ Only some simulator builds have the scenery editor (eu07 -edit). If the selected simulator does not, the editor will not open. It works on {0} itself, not on the starter's copy, so what you save goes into the scenery. Start it?
Volume while paused
Show log in console
Extra screen update delay
diff --git a/StarterNG/startercfg/lang/hu.xml b/StarterNG/startercfg/lang/hu.xml
index 8895e7c..47e1c75 100644
--- a/StarterNG/startercfg/lang/hu.xml
+++ b/StarterNG/startercfg/lang/hu.xml
@@ -557,6 +557,8 @@
Szerelvények hozzáadása fájlból...
Indítás a beállítások mentése nélkül
Indítás jármű nélkül
+ Pályaszerkesztő indítása
+ A pályaszerkesztő (eu07 -edit) csak a szimulátor egyes verzióiban érhető el. Ha a kiválasztott szimulátor nem támogatja, a szerkesztő nem nyílik meg. Közvetlenül a(z) {0} fájlon dolgozik, nem a starter másolatán, így a mentett változások a pályába kerülnek. Elindítod?
Hangerő szünet alatt
Szimuláció menetének megjelenítése
Kiegészítő képernyők frissítési gyakorisága
diff --git a/StarterNG/startercfg/lang/pl.xml b/StarterNG/startercfg/lang/pl.xml
index 4910aac..5b179bf 100644
--- a/StarterNG/startercfg/lang/pl.xml
+++ b/StarterNG/startercfg/lang/pl.xml
@@ -592,6 +592,8 @@
Dodaj składy z pliku...
Uruchom bez zapisu ustawień
Uruchom bez pojazdu
+ Uruchom edytor scenerii
+ Edytor scenerii (eu07 -edit) mają tylko niektóre wersje symulatora. Jeśli wybrany plik symulatora go nie obsługuje, edytor się nie otworzy. Edytor pracuje na samym pliku {0}, a nie na kopii przygotowanej przez starter, więc zapisane zmiany trafią do scenerii. Uruchomić?
Głośność podczas pauzy
Wyświetlaj log w konsoli
Opóźnienie odświeżania ekranów dodatkowych
diff --git a/StarterNG/startercfg/lang/ru.xml b/StarterNG/startercfg/lang/ru.xml
index d58d62d..f3edf3c 100644
--- a/StarterNG/startercfg/lang/ru.xml
+++ b/StarterNG/startercfg/lang/ru.xml
@@ -557,6 +557,8 @@
Добавить составы из файла...
Запустить без сохранения настроек
Запустить без транспорта
+ Запустить редактор сценария
+ Редактор сценария (eu07 -edit) есть только в некоторых версиях симулятора. Если выбранный симулятор его не поддерживает, редактор не откроется. Он работает с самим файлом {0}, а не с копией стартера, поэтому сохранённые изменения попадут в сценарий. Запустить?
Громкость на паузе
Показывать ход симуляции
Частота обновления дополнительных экранов