rework context menu and add custom sprites, not registered with in game library though :(
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,45 +37,66 @@ internal class CarPickable_HandleShowContextMenu_Patch
|
|||||||
{
|
{
|
||||||
trainController.SelectedCar = ((trainController.SelectedCar == car) ? null : car);
|
trainController.SelectedCar = ((trainController.SelectedCar == car) ? null : car);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!car.EnumerateCoupled().Any(c => !c.SupportsBleed()))
|
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);
|
CarInspector_PopulateCarPanel_Patch.MrocConsistHelper(car, MrocHelperType.BleedAirSystem, buttonsHaveCost);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (car.SupportsBleed())
|
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);
|
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;
|
bool apply = !car.air.handbrakeApplied;
|
||||||
car.SetHandbrake(apply);
|
car.SetHandbrake(apply);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (car.EnumerateCoupled().Any(c => c.EndAirSystemIssue()))
|
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);
|
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);
|
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;
|
||||||
|
|||||||
@@ -55,4 +55,47 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Publicize Include="Assembly-CSharp" />
|
<Publicize Include="Assembly-CSharp" />
|
||||||
</ItemGroup>
|
</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>
|
</Project>
|
||||||
|
|||||||