Compare commits
4 Commits
main
...
documentat
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a21ec2e79 | |||
| 3a04405dad | |||
| ba94d80401 | |||
| d692567d95 |
@@ -2,6 +2,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<MajorVersion>2</MajorVersion>
|
<MajorVersion>2</MajorVersion>
|
||||||
<MinorVersion>1</MinorVersion>
|
<MinorVersion>1</MinorVersion>
|
||||||
<PatchVersion>7</PatchVersion>
|
<PatchVersion>8</PatchVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
BIN
TweaksAndThings/Images/BleedCar.png
Normal file
|
After Width: | Height: | Size: 9.9 KiB |
BIN
TweaksAndThings/Images/BleedConsist.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
TweaksAndThings/Images/ConnectAir.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
TweaksAndThings/Images/ConsistReleaseBrake.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
TweaksAndThings/Images/ConsistSetBrake.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
TweaksAndThings/Images/Follow.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
TweaksAndThings/Images/Hourglass_icon.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
TweaksAndThings/Images/Map_pin_icon.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
TweaksAndThings/Images/OilCan.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
TweaksAndThings/Images/ReleaseBrake.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
TweaksAndThings/Images/SetBrake.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
TweaksAndThings/Images/Thumbs.db
Normal file
@@ -1,4 +1,5 @@
|
|||||||
using HarmonyLib;
|
using Game.State;
|
||||||
|
using HarmonyLib;
|
||||||
using Model;
|
using Model;
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using RMROC451.TweaksAndThings.Enums;
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
@@ -8,6 +9,8 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UI;
|
using UI;
|
||||||
using UI.ContextMenu;
|
using UI.ContextMenu;
|
||||||
|
using UnityEngine;
|
||||||
|
using ContextMenu = UI.ContextMenu.ContextMenu;
|
||||||
|
|
||||||
namespace RMROC451.TweaksAndThings.Patches;
|
namespace RMROC451.TweaksAndThings.Patches;
|
||||||
|
|
||||||
@@ -34,50 +37,79 @@ internal class CarPickable_HandleShowContextMenu_Patch
|
|||||||
{
|
{
|
||||||
trainController.SelectedCar = ((trainController.SelectedCar == car) ? null : car);
|
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);
|
||||||
{
|
|
||||||
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);
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
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()))
|
if (shiftPagination)
|
||||||
{
|
{
|
||||||
shared.AddButton(ContextMenuQuadrant.General, $"Air Up Consist", SpriteName.Select, delegate
|
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);
|
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);
|
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.Oil, buttonsHaveCost);
|
||||||
}
|
|
||||||
shared.AddButton(ContextMenuQuadrant.Brakes, car.air.handbrakeApplied ? "Release Handbrake" : "Apply Handbrake", SpriteName.Handbrake, delegate
|
|
||||||
{
|
|
||||||
bool apply = !car.air.handbrakeApplied;
|
|
||||||
car.SetHandbrake(apply);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
CameraSelector.shared.FollowCar(car);
|
||||||
});
|
});
|
||||||
|
|
||||||
string secondaryLine = car.Waybill.HasValue ? $"{Environment.NewLine}{car.Waybill.Value.Destination.DisplayName}" : string.Empty;
|
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;
|
secondaryLine = secondaryLine.Length > 10 + Environment.NewLine.Length ? $"{secondaryLine.Substring(0, 7 + Environment.NewLine.Length)}..." : secondaryLine;
|
||||||
shared.Show($"{car.DisplayName}{secondaryLine}");
|
shared.Show($"{car.EnumerateCoupled().Count()} Cars{Environment.NewLine}{car.DisplayName}{secondaryLine}");
|
||||||
shared.BuildItemAngles();
|
shared.BuildItemAngles();
|
||||||
shared.StartCoroutine(shared.AnimateButtonsShown());
|
shared.StartCoroutine(shared.AnimateButtonsShown());
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ internal class MapWindow_OnClick_Patch
|
|||||||
public static Sprite? LoadTexture(string fileName, string name)
|
public static Sprite? LoadTexture(string fileName, string name)
|
||||||
{
|
{
|
||||||
string path = Path.Combine(SingletonPluginBase<TweaksAndThingsPlugin>.Shared.ModDirectory, fileName);
|
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 texture2D = new Texture2D(128, 128, TextureFormat.DXT5, mipChain: false);
|
||||||
texture2D.name = name;
|
texture2D.name = name;
|
||||||
texture2D.wrapMode = TextureWrapMode.Clamp;
|
texture2D.wrapMode = TextureWrapMode.Clamp;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,4 +55,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Publicize Include="Assembly-CSharp" />
|
<Publicize Include="Assembly-CSharp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Images\**" CopyToOutputDirectory="Always"/>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ public class Settings
|
|||||||
bool safetyFirstClientEnforce,
|
bool safetyFirstClientEnforce,
|
||||||
CrewHourLoadMethod loadCrewHoursMethod,
|
CrewHourLoadMethod loadCrewHoursMethod,
|
||||||
float cabeeseSearchRadiusFtInMeters,
|
float cabeeseSearchRadiusFtInMeters,
|
||||||
bool trainBrakeDisplayShowsColorsInCalloutMode
|
bool trainBrakeDisplayShowsColorsInCalloutMode,
|
||||||
|
bool shiftPaginationOnContextMenu
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
WebhookSettingsList = webhookSettingsList;
|
WebhookSettingsList = webhookSettingsList;
|
||||||
@@ -47,6 +48,7 @@ public class Settings
|
|||||||
LoadCrewHoursMethod = loadCrewHoursMethod;
|
LoadCrewHoursMethod = loadCrewHoursMethod;
|
||||||
CabeeseSearchRadiusFtInMeters = cabeeseSearchRadiusFtInMeters;
|
CabeeseSearchRadiusFtInMeters = cabeeseSearchRadiusFtInMeters;
|
||||||
TrainBrakeDisplayShowsColorsInCalloutMode = trainBrakeDisplayShowsColorsInCalloutMode;
|
TrainBrakeDisplayShowsColorsInCalloutMode = trainBrakeDisplayShowsColorsInCalloutMode;
|
||||||
|
ShiftPaginationOnContextMenu = shiftPaginationOnContextMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly UIState<string> _selectedTabState = new UIState<string>(null);
|
public readonly UIState<string> _selectedTabState = new UIState<string>(null);
|
||||||
@@ -63,6 +65,7 @@ public class Settings
|
|||||||
public CrewHourLoadMethod LoadCrewHoursMethod;
|
public CrewHourLoadMethod LoadCrewHoursMethod;
|
||||||
public float CabeeseSearchRadiusFtInMeters;
|
public float CabeeseSearchRadiusFtInMeters;
|
||||||
public bool TrainBrakeDisplayShowsColorsInCalloutMode;
|
public bool TrainBrakeDisplayShowsColorsInCalloutMode;
|
||||||
|
public bool ShiftPaginationOnContextMenu;
|
||||||
|
|
||||||
internal void AddAnotherRow()
|
internal void AddAnotherRow()
|
||||||
{
|
{
|
||||||
@@ -145,5 +148,7 @@ public static class SettingsExtensions
|
|||||||
(input?.settings?.LoadCrewHoursMethod ?? CrewHourLoadMethod.Tracks) == CrewHourLoadMethod.Daily;
|
(input?.settings?.LoadCrewHoursMethod ?? CrewHourLoadMethod.Tracks) == CrewHourLoadMethod.Daily;
|
||||||
public static bool TrainBrakeDisplayShowsColorsInCalloutMode(this TweaksAndThingsPlugin input) =>
|
public static bool TrainBrakeDisplayShowsColorsInCalloutMode(this TweaksAndThingsPlugin input) =>
|
||||||
input?.settings?.TrainBrakeDisplayShowsColorsInCalloutMode ?? false;
|
input?.settings?.TrainBrakeDisplayShowsColorsInCalloutMode ?? false;
|
||||||
|
public static bool ShiftForPagination(this TweaksAndThingsPlugin input) =>
|
||||||
|
input?.settings?.ShiftPaginationOnContextMenu ?? false;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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.");
|
).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);
|
builder.Spacer(spacing);
|
||||||
EngineRosterShowsFuelStatusUISection(builder);
|
EngineRosterShowsFuelStatusUISection(builder);
|
||||||
}
|
}
|
||||||
|
|||||||