mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-17 01:39:38 -06:00
Adding consist buttons from inspector to new context menu, and squashing bug that would occur if inspector open but tags weren't active, breaking the ui panel builder reload detection for handbrake/couple/air changes.
final change of Version 0.1.7
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
<PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''">
|
<PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''">
|
||||||
<MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion>
|
<MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion>
|
||||||
<MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion>
|
<MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion>
|
||||||
<PatchVersion Condition="'$(PatchVersion)' == ''">6</PatchVersion>
|
<PatchVersion Condition="'$(PatchVersion)' == ''">7</PatchVersion>
|
||||||
<AssemblyVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</AssemblyVersion>
|
<AssemblyVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</AssemblyVersion>
|
||||||
<FileVersion>$(AssemblyVersion)</FileVersion>
|
<FileVersion>$(AssemblyVersion)</FileVersion>
|
||||||
<ProductVersion>$(AssemblyVersion)</ProductVersion>
|
<ProductVersion>$(AssemblyVersion)</ProductVersion>
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ using Network;
|
|||||||
using Railloader;
|
using Railloader;
|
||||||
using RMROC451.TweaksAndThings.Enums;
|
using RMROC451.TweaksAndThings.Enums;
|
||||||
using RMROC451.TweaksAndThings.Extensions;
|
using RMROC451.TweaksAndThings.Extensions;
|
||||||
|
using RollingStock;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UI.Builder;
|
using UI.Builder;
|
||||||
using UI.CarInspector;
|
using UI.CarInspector;
|
||||||
|
using UI.ContextMenu;
|
||||||
using UI.Tags;
|
using UI.Tags;
|
||||||
using static Model.Car;
|
using static Model.Car;
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ internal class CarInspector_PopulateCarPanel_Patch
|
|||||||
private static UIPanelBuilder AddCarConsistRebuildObservers(UIPanelBuilder builder, IEnumerable<Model.Car> consist)
|
private static UIPanelBuilder AddCarConsistRebuildObservers(UIPanelBuilder builder, IEnumerable<Model.Car> consist)
|
||||||
{
|
{
|
||||||
TagController tagController = UnityEngine.Object.FindFirstObjectByType<TagController>();
|
TagController tagController = UnityEngine.Object.FindFirstObjectByType<TagController>();
|
||||||
foreach (Model.Car car in consist.Where(c => c.TagCallout != null))
|
foreach (Model.Car car in consist.Where(c => c.Archetype != Model.Definition.CarArchetype.Tender))
|
||||||
{
|
{
|
||||||
builder = AddObserver(builder, car, PropertyChange.KeyForControl(PropertyChange.Control.Handbrake), tagController);
|
builder = AddObserver(builder, car, PropertyChange.KeyForControl(PropertyChange.Control.Handbrake), tagController);
|
||||||
foreach (LogicalEnd logicalEnd in ends)
|
foreach (LogicalEnd logicalEnd in ends)
|
||||||
@@ -93,7 +95,8 @@ internal class CarInspector_PopulateCarPanel_Patch
|
|||||||
{
|
{
|
||||||
try
|
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();
|
builder.Rebuild();
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
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