Compare commits

...

1 Commits

Author SHA1 Message Date
maj00r 9583117eea feat: in the standard mode the crew of the player's consists can be changed
The crew button, the crew menu on a card and the crew list in the vehicle
details now work in the standard mode too, for every consist the player may
start in. The simulator's own consists and the decorations keep the crew the
scenario gave them; the advanced mode changes any crew, as before.
2026-12-02 20:33:50 +01:00
5 changed files with 31 additions and 6 deletions
+14
View File
@@ -79,6 +79,20 @@ public class TrainsetDisplayTests
Assert.True(TrainsetDisplay.StartableIn(decor, Mode(advanced: true)));
}
[Fact]
public void The_standard_mode_changes_the_crew_but_not_in_the_simulators_own_consists()
{
var standard = Mode(advanced: false);
var decor = new Trainset("trainset a tor 0 0 //$decor\nnode -1 0 v1 dynamic d s m 0 headdriver 3 0 enddynamic\nendtrainset");
Assert.True(TrainsetDisplay.CrewEditableIn(Consist(), standard));
Assert.True(TrainsetDisplay.CrewEditableIn(Consist(driver: "nobody"), standard));
Assert.True(TrainsetDisplay.CrewEditableIn(null, standard));
Assert.False(TrainsetDisplay.CrewEditableIn(Consist(description: "-ai"), standard));
Assert.False(TrainsetDisplay.CrewEditableIn(decor, standard));
Assert.True(TrainsetDisplay.CrewEditableIn(Consist(description: "-ai"), Mode(advanced: true)));
}
[Fact]
public void The_filters_work_in_the_advanced_mode()
{
+8
View File
@@ -52,6 +52,14 @@ public static class TrainsetDisplay
public static bool StartableIn(Trainset trainset, SimulatorSettings settings) =>
settings.AdvancedSettings || (!IsAi(trainset) && !trainset.Decor);
/// <summary>
/// Whether the crew of the consist being edited may be changed: in the standard mode
/// only in one the player may start in - the simulator's own consists and the
/// decorations keep the crew the scenario gave them.
/// </summary>
public static bool CrewEditableIn(Trainset? trainset, SimulatorSettings settings) =>
trainset is null || StartableIn(trainset, settings);
/// <summary>The consist's row in those lists: what it is made of, or the track of one with nothing on it.</summary>
public static string ListLabel(Trainset trainset) =>
CompositionText(trainset) ?? string.Format(App.Loc["EmptyTrainset"], trainset.Track ?? "");
+1 -1
View File
@@ -69,7 +69,7 @@ public partial class Depot : UserControl
if (Design.IsDesignMode)
return;
// The standard mode lists other consists and leaves the crew alone.
// The standard mode lists other consists and leaves the crew of the simulator's own alone.
Settings.AdvancedModeChanged += () =>
{
PopulateSceneryConsists();
+6 -3
View File
@@ -49,6 +49,9 @@ public sealed class VehicleCards
public Dynamic? PressedCar { get; set; }
private bool CrewEditable =>
TrainsetDisplay.CrewEditableIn(_consist.EditingTrainset, AppServices.Current.Settings);
public VehicleCards(Panel consistStack, VehicleCatalog db, Consist consist,
Cargo cargo, MiniTextures minis, Cursor hand,
Action redraw, Action refreshDetails, Action<Dynamic> selectInBrowser,
@@ -117,8 +120,8 @@ public sealed class VehicleCards
HorizontalAlignment = HorizontalAlignment.Center,
Margin = new Thickness(0, 1, 0, 2)
};
// Who sits in the cab - the player, the simulator, a passenger or nobody - is for the advanced mode.
if (AppServices.Current.Settings.AdvancedSettings)
// Who sits in the cab; in the standard mode not in the simulator's own consists.
if (CrewEditable)
controls.Children.Add(DriverButton(item));
controls.Children.Add(FlipButton(item));
@@ -695,7 +698,7 @@ public sealed class VehicleCards
else if (_consist.CanJoin(item, index))
menu.AddItem(App.Loc["TipJoin"], () => _consist.Join(item));
if (AppServices.Current.Settings.AdvancedSettings)
if (CrewEditable)
{
var crew = new MenuItem { Header = App.Loc["CrewLabel"] };
foreach (var (type, key) in CrewChoices.All)
+2 -2
View File
@@ -280,8 +280,8 @@ public sealed class VehicleDetails
};
driver.MinWidth = 0;
driver.HorizontalAlignment = HorizontalAlignment.Stretch;
// Shown but not changed in the standard mode: who drives is for the advanced one.
driver.IsEnabled = AppServices.Current.Settings.AdvancedSettings;
// Shown but not changed in the standard mode in the simulator's own consists.
driver.IsEnabled = TrainsetDisplay.CrewEditableIn(_consist.EditingTrainset, AppServices.Current.Settings);
var rows = new StackPanel();
rows.Children.Add(Row(App.Loc["CrewLabel"], driver));