Open CzBuCHi opened 2 weeks ago
Orders, I can move them there, I really want it on the loco control panel... but I'm failing hard at understanding how or if that is possible :)
yea ... i was looking at the code too ... IDK how harmony works, but one idea is instead of 'Prefix' (that im assuming is injecting code to start of method) use something that replace that method entirely .... (the you would 'simply' decompile original code and add your own buttons ...)
ok ... i look at harmony and i managed to do this:
i modified your CarInspector_PopulateCarPanel_Patch like this:
[HarmonyPatch(typeof(CarInspector))]
[HarmonyPatch(nameof(CarInspector.PopulateCarPanel), typeof(UIPanelBuilder))]
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
public class CarInspector_PopulateCarPanel_Patch
{
private static IEnumerable<LogicalEnd> ends = Enum.GetValues(typeof(LogicalEnd)).Cast<LogicalEnd>();
private static CarInspector _instance;
private static UIPanelBuilder _builder;
private static void Postfix() {
// only thing that is missing here is that i have no idea how to remove vanilla buttons ....
// this is copy of original code (decompiled from Assembly-CSharp.dll), but i added 'Exterminate!' button to it
_builder.HStack(hstack => {
hstack.AddButton("Select", _instance.SelectConsist).Tooltip("Select Car", "Selected locomotives display HUD controls. Shortcuts allow jumping to the selected car.");
hstack.AddButton("Follow", () => CameraSelector.shared.FollowCar(_instance._car)).Tooltip("Follow Car", "Jump the overhead camera to this car and track it.");
hstack.AddButton("Exterminate!", () => { });
hstack.Spacer();
if (!CarInspector.IsSandbox) {
return;
}
hstack.AddButton("Delete", _instance.DeleteConsist).Tooltip("Delete Car", "Click to delete this car. Shift-Click deletes all coupled cars.");
});
}
private static bool Prefix(CarInspector __instance, UIPanelBuilder builder) {
_instance = __instance;
_builder = builder;
// your original code is here ....
}
so either you need to figure out how to remove vanilla buttons or how to make entire window little bit taller ...
another thingy related to this: can you also add 'bleed all cars' button?
Pretty sure that is there already?
mockup: https://cdn.discordapp.com/attachments/1252003192913530920/1253756751375761458/image.png?ex=66770377&is=6675b1f7&hm=21cf23c08fd5ed3fce8b66fce6230e73d9ed95743dcb6f009425e88c7b8386ff&
PS: wanted to do it myself as PR, but its more complicaetd than expected :( ... looking forward to your solution ..
Edit: and to be honest if you place those buttons in locomotive orders tab you will be king :)