diff --git a/TweaksAndThings/Patches/CarPickable_HandleShowContextMenu_Patch.cs b/TweaksAndThings/Patches/CarPickable_HandleShowContextMenu_Patch.cs index 64b3a74..343e6e1 100644 --- a/TweaksAndThings/Patches/CarPickable_HandleShowContextMenu_Patch.cs +++ b/TweaksAndThings/Patches/CarPickable_HandleShowContextMenu_Patch.cs @@ -38,57 +38,70 @@ internal class CarPickable_HandleShowContextMenu_Patch trainController.SelectedCar = ((trainController.SelectedCar == car) ? null : car); }); - if (!car.EnumerateCoupled().Any(c => !c.SupportsBleed())) + bool shiftPagination = (tweaksAndThings.ShiftForPagination() && GameInput.IsShiftDown) || !tweaksAndThings.ShiftForPagination(); + bool nonShiftShow = (tweaksAndThings.ShiftForPagination() && !GameInput.IsShiftDown) || !tweaksAndThings.ShiftForPagination(); + + if (shiftPagination && car.EnumerateCoupled().Any(c => c.SupportsBleed())) { - Sprite bleedConsist = MapWindow_OnClick_Patch.LoadTexture("BleedConsist.png", "BleedConsist"); + Sprite? bleedConsist = MapWindow_OnClick_Patch.LoadTexture("BleedConsist.png", "BleedConsist"); + if (bleedConsist == null) bleedConsist = SpriteName.Bleed.Sprite(); shared.AddButton(ContextMenuQuadrant.Brakes, $"Bleed Consist", bleedConsist, delegate { CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.BleedAirSystem, buttonsHaveCost); }); } - if (car.SupportsBleed()) + if (nonShiftShow && car.SupportsBleed()) { - Sprite bleedCar = MapWindow_OnClick_Patch.LoadTexture("BleedCar.png", "BleedCar"); + Sprite? bleedCar = MapWindow_OnClick_Patch.LoadTexture("BleedCar.png", "BleedCar"); + if (bleedCar == null) bleedCar = SpriteName.Bleed.Sprite(); shared.AddButton(ContextMenuQuadrant.Brakes, "Bleed", bleedCar, car.SetBleed); } + if (shiftPagination) + { string text = car.EnumerateCoupled().Any(c => c.HandbrakeApplied()) ? "Release " : "Set "; - Sprite consistBrakes = MapWindow_OnClick_Patch.LoadTexture($"Consist{text.Trim()}Brake.png", $"{text.Trim()}Consist"); + Sprite? consistBrakes = MapWindow_OnClick_Patch.LoadTexture($"Consist{text.Trim()}Brake.png", $"{text.Trim()}Consist"); + if (consistBrakes == null) consistBrakes = SpriteName.Handbrake.Sprite(); shared.AddButton(ContextMenuQuadrant.Brakes, $"{text}Consist", consistBrakes, delegate { CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.Handbrake, buttonsHaveCost); }); + } - - + if (nonShiftShow) + { string textCar = car.HandbrakeApplied() ? "Release " : "Set "; - Sprite carBrakes = MapWindow_OnClick_Patch.LoadTexture($"{text.Trim()}Brake.png", $"{text.Trim()}Consist"); + Sprite? carBrakes = MapWindow_OnClick_Patch.LoadTexture($"{textCar.Trim()}Brake.png", $"{textCar.Trim()}Brake"); + if (carBrakes == null) carBrakes = SpriteName.Handbrake.Sprite(); shared.AddButton(ContextMenuQuadrant.Brakes, $"{textCar}Handbrake", carBrakes, delegate { bool apply = !car.air.handbrakeApplied; car.SetHandbrake(apply); }); + } - - if (car.EnumerateCoupled().Any(c => c.EndAirSystemIssue())) + if (shiftPagination && car.EnumerateCoupled().Any(c => c.EndAirSystemIssue())) { - Sprite connectAir = MapWindow_OnClick_Patch.LoadTexture($"ConnectAir.png", "ConnectAir"); + Sprite? connectAir = MapWindow_OnClick_Patch.LoadTexture($"ConnectAir.png", "ConnectAir"); + if (connectAir == null) connectAir = SpriteName.Select.Sprite(); shared.AddButton(ContextMenuQuadrant.General, $"Air Up Consist", connectAir, delegate { CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.GladhandAndAnglecock, buttonsHaveCost); }); } - if (StateManager.IsHost && car.EnumerateCoupled().Any(c => c.NeedsOiling || c.HasHotbox)) + if (StateManager.IsHost && shiftPagination && car.EnumerateCoupled().Any(c => c.NeedsOiling || c.HasHotbox)) { - Sprite oilCan = MapWindow_OnClick_Patch.LoadTexture("OilCan.png", "OilCan"); + Sprite? oilCan = MapWindow_OnClick_Patch.LoadTexture("OilCan.png", "OilCan"); + if (oilCan == null) oilCan = SpriteName.Select.Sprite(); shared.AddButton(ContextMenuQuadrant.General, $"Oil Consist", oilCan, delegate { CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.Oil, buttonsHaveCost); }); } - Sprite follow = MapWindow_OnClick_Patch.LoadTexture($"Follow.png", "ConnectAir"); + Sprite? follow = MapWindow_OnClick_Patch.LoadTexture($"Follow.png", "ConnectAir"); + if (follow == null) follow = SpriteName.Inspect.Sprite(); shared.AddButton(ContextMenuQuadrant.General, $"Follow", follow, delegate { CameraSelector.shared.FollowCar(car); diff --git a/TweaksAndThings/Patches/MapWindow_OnClick_Patch.cs b/TweaksAndThings/Patches/MapWindow_OnClick_Patch.cs index c1aef99..ffa2b4a 100644 --- a/TweaksAndThings/Patches/MapWindow_OnClick_Patch.cs +++ b/TweaksAndThings/Patches/MapWindow_OnClick_Patch.cs @@ -34,6 +34,11 @@ internal class MapWindow_OnClick_Patch public static Sprite? LoadTexture(string fileName, string name) { string path = Path.Combine(SingletonPluginBase.Shared.ModDirectory, fileName); + if (!File.Exists(path)) + { + _log.Debug($"Unable to find {name} icon at {path}!"); + return null; + } Texture2D texture2D = new Texture2D(128, 128, TextureFormat.DXT5, mipChain: false); texture2D.name = name; texture2D.wrapMode = TextureWrapMode.Clamp; diff --git a/TweaksAndThings/RMROC451.TweaksAndThings.csproj b/TweaksAndThings/RMROC451.TweaksAndThings.csproj index 710333b..5b95c8e 100644 --- a/TweaksAndThings/RMROC451.TweaksAndThings.csproj +++ b/TweaksAndThings/RMROC451.TweaksAndThings.csproj @@ -57,45 +57,6 @@ - - - - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - + diff --git a/TweaksAndThings/Settings/Settings.cs b/TweaksAndThings/Settings/Settings.cs index c8e93af..77ecd4f 100644 --- a/TweaksAndThings/Settings/Settings.cs +++ b/TweaksAndThings/Settings/Settings.cs @@ -31,7 +31,8 @@ public class Settings bool safetyFirstClientEnforce, CrewHourLoadMethod loadCrewHoursMethod, float cabeeseSearchRadiusFtInMeters, - bool trainBrakeDisplayShowsColorsInCalloutMode + bool trainBrakeDisplayShowsColorsInCalloutMode, + bool shiftPaginationOnContextMenu ) { WebhookSettingsList = webhookSettingsList; @@ -47,6 +48,7 @@ public class Settings LoadCrewHoursMethod = loadCrewHoursMethod; CabeeseSearchRadiusFtInMeters = cabeeseSearchRadiusFtInMeters; TrainBrakeDisplayShowsColorsInCalloutMode = trainBrakeDisplayShowsColorsInCalloutMode; + ShiftPaginationOnContextMenu = shiftPaginationOnContextMenu; } public readonly UIState _selectedTabState = new UIState(null); @@ -63,6 +65,7 @@ public class Settings public CrewHourLoadMethod LoadCrewHoursMethod; public float CabeeseSearchRadiusFtInMeters; public bool TrainBrakeDisplayShowsColorsInCalloutMode; + public bool ShiftPaginationOnContextMenu; internal void AddAnotherRow() { @@ -145,5 +148,7 @@ public static class SettingsExtensions (input?.settings?.LoadCrewHoursMethod ?? CrewHourLoadMethod.Tracks) == CrewHourLoadMethod.Daily; public static bool TrainBrakeDisplayShowsColorsInCalloutMode(this TweaksAndThingsPlugin input) => input?.settings?.TrainBrakeDisplayShowsColorsInCalloutMode ?? false; + public static bool ShiftForPagination(this TweaksAndThingsPlugin input) => + input?.settings?.ShiftPaginationOnContextMenu ?? false; } \ No newline at end of file diff --git a/TweaksAndThings/TweaksAndThingsPlugin.cs b/TweaksAndThings/TweaksAndThingsPlugin.cs index e7382f5..e92b0e3 100644 --- a/TweaksAndThings/TweaksAndThingsPlugin.cs +++ b/TweaksAndThings/TweaksAndThingsPlugin.cs @@ -262,6 +262,18 @@ AutoHotboxSpotter Update: decrease the random wait from 30 - 300 seconds to 15 - } ).Tooltip("Train Brake Color Mode", $@"When enabled/checked and car tag callout mode is enabled (showing car tags hovering over them), the train brake display of the selected locomotive will change the cars/engines to their destination area's color to help you visualize sets of cars at a glance."); + builder.Spacer(spacing); + builder.AddFieldToggle( + "Context Menu Shift Modifier", + () => this.ShiftForPagination(), + delegate (bool enabled) + { + if (settings == null) settings = new(); + settings.ShiftPaginationOnContextMenu = enabled; + builder.Rebuild(); + } + ).Tooltip("Context Menu Shift Modifier", $@"When enabled/checked, utilizing `SHIFT` while initiating the context menu of a car will show consist level options, and without shows only car level. If this is unchecked, all car/consist options show up in a happy goulash!"); + builder.Spacer(spacing); EngineRosterShowsFuelStatusUISection(builder); }