mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-17 01:39:38 -06:00
Compare commits
3 Commits
15-add-loc
...
v0.1.7
| Author | SHA1 | Date | |
|---|---|---|---|
| ec21effd30 | |||
| 2242aaacde | |||
| e26713688b |
@@ -12,7 +12,7 @@
|
||||
<PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''">
|
||||
<MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion>
|
||||
<MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion>
|
||||
<PatchVersion Condition="'$(PatchVersion)' == ''">6</PatchVersion>
|
||||
<PatchVersion Condition="'$(PatchVersion)' == ''">7</PatchVersion>
|
||||
<AssemblyVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</AssemblyVersion>
|
||||
<FileVersion>$(AssemblyVersion)</FileVersion>
|
||||
<ProductVersion>$(AssemblyVersion)</ProductVersion>
|
||||
|
||||
@@ -8,12 +8,14 @@ using Network;
|
||||
using Railloader;
|
||||
using RMROC451.TweaksAndThings.Enums;
|
||||
using RMROC451.TweaksAndThings.Extensions;
|
||||
using RollingStock;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UI.Builder;
|
||||
using UI.CarInspector;
|
||||
using UI.ContextMenu;
|
||||
using UI.Tags;
|
||||
using static Model.Car;
|
||||
|
||||
@@ -70,7 +72,7 @@ internal class CarInspector_PopulateCarPanel_Patch
|
||||
private static UIPanelBuilder AddCarConsistRebuildObservers(UIPanelBuilder builder, IEnumerable<Model.Car> consist)
|
||||
{
|
||||
TagController tagController = UnityEngine.Object.FindFirstObjectByType<TagController>();
|
||||
foreach (Model.Car car in consist)
|
||||
foreach (Model.Car car in consist.Where(c => c.Archetype != Model.Definition.CarArchetype.Tender))
|
||||
{
|
||||
builder = AddObserver(builder, car, PropertyChange.KeyForControl(PropertyChange.Control.Handbrake), tagController);
|
||||
foreach (LogicalEnd logicalEnd in ends)
|
||||
@@ -93,7 +95,8 @@ internal class CarInspector_PopulateCarPanel_Patch
|
||||
{
|
||||
try
|
||||
{
|
||||
tagController.UpdateTag(car, car.TagCallout, OpsController.Shared);
|
||||
if (car.TagCallout != null) tagController.UpdateTag(car, car.TagCallout, OpsController.Shared);
|
||||
if (ContextMenu.IsShown && ContextMenu.Shared.centerLabel.text == car.DisplayName) CarPickable.HandleShowContextMenu(car);
|
||||
builder.Rebuild();
|
||||
}
|
||||
catch(Exception ex)
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
using HarmonyLib;
|
||||
using Model;
|
||||
using Railloader;
|
||||
using RMROC451.TweaksAndThings.Enums;
|
||||
using RMROC451.TweaksAndThings.Extensions;
|
||||
using RollingStock;
|
||||
using System.Linq;
|
||||
using UI;
|
||||
using UI.ContextMenu;
|
||||
using static Model.Car;
|
||||
|
||||
namespace RMROC451.TweaksAndThings.Patches;
|
||||
|
||||
[HarmonyPatch(typeof(CarPickable))]
|
||||
[HarmonyPatch(nameof(CarPickable.HandleShowContextMenu), typeof(Car))]
|
||||
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||
internal class CarPickable_HandleShowContextMenu_Patch
|
||||
{
|
||||
private static void Postfix(Car car)
|
||||
{
|
||||
TweaksAndThingsPlugin tweaksAndThings = SingletonPluginBase<TweaksAndThingsPlugin>.Shared;
|
||||
if (!tweaksAndThings.IsEnabled) return;
|
||||
|
||||
bool buttonsHaveCost = tweaksAndThings?.settings?.EndGearHelpersRequirePayment ?? false;
|
||||
ContextMenu shared = ContextMenu.Shared;
|
||||
var consist = car.EnumerateCoupled(LogicalEnd.A);
|
||||
shared.AddButton(ContextMenuQuadrant.Unused2, $"{(consist.Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} Consist", SpriteName.Handbrake, delegate
|
||||
{
|
||||
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.Handbrake, buttonsHaveCost);
|
||||
});
|
||||
|
||||
if (consist.Any(c => c.EndAirSystemIssue()))
|
||||
{
|
||||
shared.AddButton(ContextMenuQuadrant.Unused2, $"Air Up Consist", SpriteName.Select, delegate
|
||||
{
|
||||
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.GladhandAndAnglecock, buttonsHaveCost);
|
||||
});
|
||||
}
|
||||
|
||||
if (consist.Any(c => c.SupportsBleed()))
|
||||
{
|
||||
shared.AddButton(ContextMenuQuadrant.Unused2, $"Bleed Consist", SpriteName.Bleed, delegate
|
||||
{
|
||||
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.BleedAirSystem, buttonsHaveCost);
|
||||
});
|
||||
}
|
||||
|
||||
shared.BuildItemAngles();
|
||||
shared.StartCoroutine(shared.AnimateButtonsShown());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user