rework context menu and add custom sprites, not registered with in game library though :(

This commit is contained in:
2025-09-05 17:07:23 -05:00
parent ba94d80401
commit 3a04405dad
14 changed files with 75 additions and 8 deletions

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,45 +37,66 @@ internal class CarPickable_HandleShowContextMenu_Patch
{
trainController.SelectedCar = ((trainController.SelectedCar == car) ? null : car);
});
if (!car.EnumerateCoupled().Any(c => !c.SupportsBleed()))
{
shared.AddButton(ContextMenuQuadrant.Brakes, $"Bleed Consist", SpriteName.Bleed, delegate
Sprite bleedConsist = MapWindow_OnClick_Patch.LoadTexture("BleedConsist.png", "BleedConsist");
shared.AddButton(ContextMenuQuadrant.Brakes, $"Bleed Consist", bleedConsist, delegate
{
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.BleedAirSystem, buttonsHaveCost);
});
}
if (car.SupportsBleed())
{
shared.AddButton(ContextMenuQuadrant.Brakes, "Bleed", SpriteName.Bleed, car.SetBleed);
Sprite bleedCar = MapWindow_OnClick_Patch.LoadTexture("BleedCar.png", "BleedCar");
shared.AddButton(ContextMenuQuadrant.Brakes, "Bleed", bleedCar, car.SetBleed);
}
shared.AddButton(ContextMenuQuadrant.Brakes, $"{(car.EnumerateCoupled().Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} Consist", SpriteName.Handbrake, 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");
shared.AddButton(ContextMenuQuadrant.Brakes, $"{text}Consist", consistBrakes, delegate
{
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.Handbrake, buttonsHaveCost);
});
shared.AddButton(ContextMenuQuadrant.Brakes, car.air.handbrakeApplied ? "Release Handbrake" : "Apply Handbrake", SpriteName.Handbrake, delegate
string textCar = car.HandbrakeApplied() ? "Release " : "Set ";
Sprite carBrakes = MapWindow_OnClick_Patch.LoadTexture($"{text.Trim()}Brake.png", $"{text.Trim()}Consist");
shared.AddButton(ContextMenuQuadrant.Brakes, $"{textCar}Handbrake", carBrakes, delegate
{
bool apply = !car.air.handbrakeApplied;
car.SetHandbrake(apply);
});
if (car.EnumerateCoupled().Any(c => c.EndAirSystemIssue()))
{
shared.AddButton(ContextMenuQuadrant.General, $"Air Up Consist", SpriteName.Select, delegate
Sprite connectAir = MapWindow_OnClick_Patch.LoadTexture($"ConnectAir.png", "ConnectAir");
shared.AddButton(ContextMenuQuadrant.General, $"Air Up Consist", connectAir, delegate
{
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.GladhandAndAnglecock, buttonsHaveCost);
});
}
shared.AddButton(ContextMenuQuadrant.General, $"Follow", SpriteName.Inspect, delegate
if (StateManager.IsHost && car.EnumerateCoupled().Any(c => c.NeedsOiling || c.HasHotbox))
{
Sprite oilCan = MapWindow_OnClick_Patch.LoadTexture("OilCan.png", "OilCan");
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");
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}");
shared.Show($"{car.EnumerateCoupled().Count()} Cars{Environment.NewLine}{car.DisplayName}{secondaryLine}");
shared.BuildItemAngles();
shared.StartCoroutine(shared.AnimateButtonsShown());
return false;

View File

@@ -55,4 +55,47 @@
<ItemGroup>
<Publicize Include="Assembly-CSharp" />
</ItemGroup>
<ItemGroup>
<Folder Include="Images\" />
</ItemGroup>
<ItemGroup>
<None Update="Images\BleedCar.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\BleedConsist.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\ConnectAir.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\ConsistReleaseBrake.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\ConsistSetBrake.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\Follow.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\Hourglass_icon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\Map_pin_icon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\OilCan.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\ReleaseBrake.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\SetBrake.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Images\Thumbs.db">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>