From 9e2166065b24d6419e8166b7ee5a6075bf2f24ce Mon Sep 17 00:00:00 2001 From: maj00r Date: Tue, 25 Aug 2026 20:58:25 +0200 Subject: [PATCH] Rework the depot browser layout and confirm a crewless start The vehicle database panel loses its header bar and packs the search box and the archival filter into one line, the class combo takes a full-width line of its own with a miniature (big in the drop-down, one line when closed) and the bulk / texture-base actions move into the Add button's drop-down. The mini preview sits beside the texture data and stays hidden until an entry is picked, so the list keeps the space. Picking a class or a vehicle now fills both combos in, and a class alone is a valid filter (it used to leave the list empty without a category). The combos and the list are rebuilt on the next dispatcher pass, since clearing Items from inside the SelectionChanged that asked for it throws. Vehicle removal becomes a per-card tool next to flip / crew, the scenery and vehicle names move into their panel headers, and the texture randomizer dialog sizes to its content instead of clipping its last button. Start no longer hides behind Ctrl: a consist with no crew and no passenger says so on the button and asks for confirmation before launching. --- StarterNG/MainWindow.axaml.cs | 35 ++- StarterNG/Views/Depot.axaml | 127 ++++++----- StarterNG/Views/Depot.axaml.cs | 359 +++++++++++++++++++++---------- StarterNG/startercfg/lang/cz.xml | 4 +- StarterNG/startercfg/lang/en.xml | 4 +- StarterNG/startercfg/lang/hu.xml | 4 +- StarterNG/startercfg/lang/pl.xml | 4 +- StarterNG/startercfg/lang/ru.xml | 4 +- 8 files changed, 347 insertions(+), 194 deletions(-) diff --git a/StarterNG/MainWindow.axaml.cs b/StarterNG/MainWindow.axaml.cs index 9640373..d2d82c9 100644 --- a/StarterNG/MainWindow.axaml.cs +++ b/StarterNG/MainWindow.axaml.cs @@ -19,8 +19,6 @@ namespace StarterNG; public partial class MainWindow : Window { - // Tracks Ctrl for Start bypass (Pascal btnStart.Tag while Ctrl held). - private KeyModifiers _mods; private DateTime _openedUtc = DateTime.UtcNow; public MainWindow() @@ -48,13 +46,6 @@ public partial class MainWindow : Window UpdateStartButton(); }; Activated += (_, _) => CheckExternalSettings(); - AddHandler(InputElement.KeyDownEvent, (_, e) => { _mods = e.KeyModifiers; UpdateStartButton(); }, handledEventsToo: true); - AddHandler(InputElement.KeyUpEvent, (_, e) => { _mods = e.KeyModifiers; UpdateStartButton(); }, handledEventsToo: true); - AddHandler(InputElement.PointerMovedEvent, (_, e) => - { - var m = e.KeyModifiers; - if (m != _mods) { _mods = m; UpdateStartButton(); } - }, handledEventsToo: true); } // Lets the user drag the window by the top caption strip. @@ -185,15 +176,14 @@ public partial class MainWindow : Window } } - // Pascal actStartUpdate: Start needs scenery + trainset + staffed/passenger - // vehicle. Hold Ctrl to force START (bypass crew check). + // Pascal actStartUpdate: Start needs a scenery and a trainset. A consist with + // nobody aboard still starts, after the confirmation in StartButton_OnClick. private void UpdateStartButton() { if (startButton is null) return; var scenery = AppState.Instance.CurrentScenery; var trainset = AppState.Instance.CurrentTrainset; - bool ctrl = _mods.HasFlag(KeyModifiers.Control); if (scenery is null) { @@ -207,14 +197,11 @@ public partial class MainWindow : Window startButton.IsEnabled = false; return; } - if (!HasStartableVehicle(trainset) && !ctrl) - { - startButton.Content = App.Loc["StartNoStaff"]; - startButton.IsEnabled = false; - return; - } - - startButton.Content = App.Loc["Start"]; + // No driver and no passenger: still startable, but say so on the button + // and ask before launching. + bool staffed = HasStartableVehicle(trainset); + startButton.Content = staffed ? App.Loc["Start"] : App.Loc["StartNoStaff"]; + ToolTip.SetTip(startButton, staffed ? null : App.Loc["StartNoStaffConfirm"]); startButton.IsEnabled = true; } @@ -236,7 +223,7 @@ public partial class MainWindow : Window // ── START: export the (possibly depot-modified) scenery and launch the sim. // Global on the main window, like the original Starter's bottom START button. - private void StartButton_OnClick(object? sender, RoutedEventArgs e) + private async void StartButton_OnClick(object? sender, RoutedEventArgs e) { var scenery = AppState.Instance.CurrentScenery; if (scenery is null) @@ -245,7 +232,11 @@ public partial class MainWindow : Window if (trainset is null) return; - if (!HasStartableVehicle(trainset) && !_mods.HasFlag(KeyModifiers.Control)) + // Launching a consist with no driver and no passenger is legal (a scenery + // can be watched from the outside), so confirm instead of blocking it. + if (!HasStartableVehicle(trainset) && + !await MessageBox.Show(this, App.Loc["StartNoStaffConfirm"], + App.Loc["StartNoStaffTitle"], MessageBoxButtons.YesNo)) return; if (trainset.Vehicles.Count > 0) diff --git a/StarterNG/Views/Depot.axaml b/StarterNG/Views/Depot.axaml index 477b399..5704251 100644 --- a/StarterNG/Views/Depot.axaml +++ b/StarterNG/Views/Depot.axaml @@ -13,97 +13,106 @@ - + - + - + - +