Compare commits

...

4 Commits

19 changed files with 129 additions and 29 deletions

View File

@@ -2,6 +2,6 @@
<PropertyGroup>
<MajorVersion>2</MajorVersion>
<MinorVersion>1</MinorVersion>
<PatchVersion>7</PatchVersion>
<PatchVersion>8</PatchVersion>
</PropertyGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

View File

@@ -1,4 +1,5 @@
using HarmonyLib;
using Game.State;
using HarmonyLib;
using Model;
using Railloader;
using RMROC451.TweaksAndThings.Enums;
@@ -8,6 +9,8 @@ using System;
using System.Linq;
using UI;
using UI.ContextMenu;
using UnityEngine;
using ContextMenu = UI.ContextMenu.ContextMenu;
namespace RMROC451.TweaksAndThings.Patches;
@@ -34,50 +37,79 @@ internal class CarPickable_HandleShowContextMenu_Patch
{
trainController.SelectedCar = ((trainController.SelectedCar == car) ? null : car);
});
if (GameInput.IsShiftDown)
bool shiftPagination = (tweaksAndThings.ShiftForPagination() && GameInput.IsShiftDown) || !tweaksAndThings.ShiftForPagination();
bool nonShiftShow = (tweaksAndThings.ShiftForPagination() && !GameInput.IsShiftDown) || !tweaksAndThings.ShiftForPagination();
if (shiftPagination && car.EnumerateCoupled().Any(c => c.SupportsBleed()))
{
if (!car.EnumerateCoupled().Any(c => !c.SupportsBleed()))
Sprite? bleedConsist = MapWindow_OnClick_Patch.LoadTexture("BleedConsist.png", "BleedConsist");
if (bleedConsist == null) bleedConsist = SpriteName.Bleed.Sprite();
shared.AddButton(ContextMenuQuadrant.Brakes, $"Bleed Consist", bleedConsist, delegate
{
shared.AddButton(ContextMenuQuadrant.Brakes, $"Bleed Consist", SpriteName.Bleed, delegate
{
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.BleedAirSystem, buttonsHaveCost);
});
}
shared.AddButton(ContextMenuQuadrant.Brakes, $"{(car.EnumerateCoupled().Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} Consist", SpriteName.Handbrake, delegate
{
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.Handbrake, buttonsHaveCost);
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.BleedAirSystem, buttonsHaveCost);
});
}
if (nonShiftShow && car.SupportsBleed())
{
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 (car.EnumerateCoupled().Any(c => c.EndAirSystemIssue()))
{
shared.AddButton(ContextMenuQuadrant.General, $"Air Up Consist", SpriteName.Select, delegate
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");
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($"{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 (shiftPagination && car.EnumerateCoupled().Any(c => c.EndAirSystemIssue()))
{
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);
});
}
}
else
if (StateManager.IsHost && shiftPagination && car.EnumerateCoupled().Any(c => c.NeedsOiling || c.HasHotbox))
{
if (car.SupportsBleed())
Sprite? oilCan = MapWindow_OnClick_Patch.LoadTexture("OilCan.png", "OilCan");
if (oilCan == null) oilCan = SpriteName.Select.Sprite();
shared.AddButton(ContextMenuQuadrant.General, $"Oil Consist", oilCan, delegate
{
shared.AddButton(ContextMenuQuadrant.Brakes, "Bleed", SpriteName.Bleed, car.SetBleed);
}
shared.AddButton(ContextMenuQuadrant.Brakes, car.air.handbrakeApplied ? "Release Handbrake" : "Apply Handbrake", SpriteName.Handbrake, delegate
{
bool apply = !car.air.handbrakeApplied;
car.SetHandbrake(apply);
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.Oil, buttonsHaveCost);
});
}
shared.AddButton(ContextMenuQuadrant.General, $"Follow", SpriteName.Inspect, delegate
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);
});
string secondaryLine = car.Waybill.HasValue ? $"{Environment.NewLine}{car.Waybill.Value.Destination.DisplayName}" : string.Empty;
secondaryLine = secondaryLine.Length > 10 + Environment.NewLine.Length ? $"{secondaryLine.Substring(0, 7+ Environment.NewLine.Length)}..." : secondaryLine;
shared.Show($"{car.DisplayName}{secondaryLine}");
secondaryLine = secondaryLine.Length > 10 + Environment.NewLine.Length ? $"{secondaryLine.Substring(0, 7 + Environment.NewLine.Length)}..." : secondaryLine;
shared.Show($"{car.EnumerateCoupled().Count()} Cars{Environment.NewLine}{car.DisplayName}{secondaryLine}");
shared.BuildItemAngles();
shared.StartCoroutine(shared.AnimateButtonsShown());
return false;

View File

@@ -34,6 +34,11 @@ internal class MapWindow_OnClick_Patch
public static Sprite? LoadTexture(string fileName, string name)
{
string path = Path.Combine(SingletonPluginBase<TweaksAndThingsPlugin>.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;

View File

@@ -0,0 +1,42 @@
using HarmonyLib;
using Helpers;
using Model.Database;
using Model.Definition;
using Model.Definition.Data;
using Model.Ops;
using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
namespace RMROC451.TweaksAndThings.Patches;
[HarmonyPatch(typeof(PrefabStoreExtensions))]
[HarmonyPatch(nameof(PrefabStoreExtensions.Random))]
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
internal static class PrefabStoreExtensions_Random_Patch
{
public static bool Prefix(IPrefabStore prefabStore, CarTypeFilter carTypeFilter, IndustryContext.CarSizePreference sizePreference, Random rnd, ref TypedContainerItem<CarDefinition> __result)
{
List<TypedContainerItem<CarDefinition>> list =
(from p in prefabStore.AllCarDefinitionInfos.ToList().FindAll((TypedContainerItem<CarDefinition> p) =>
carTypeFilter.Matches(p.Definition.CarType) && !p.Metadata.Tags.Any(t => t.Equals("deprecated")))
orderby p.Definition.WeightEmpty
select p).ToList();
if (list.Count == 0)
{
Log.Error($"Couldn't find car for condition: {carTypeFilter}");
__result = null;
}
__result = list.RandomElementUsingNormalDistribution(sizePreference switch
{
IndustryContext.CarSizePreference.Small => 0.2f,
IndustryContext.CarSizePreference.Medium => 0.4f,
IndustryContext.CarSizePreference.Large => 0.6f,
IndustryContext.CarSizePreference.ExtraLarge => 0.8f,
_ => 0.5f,
}, rnd);
return false;
}
}

View File

@@ -55,4 +55,8 @@
<ItemGroup>
<Publicize Include="Assembly-CSharp" />
</ItemGroup>
<ItemGroup>
<None Include="Images\**" CopyToOutputDirectory="Always"/>
</ItemGroup>
</Project>

View File

@@ -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<string> _selectedTabState = new UIState<string>(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;
}

View File

@@ -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);
}