mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-16 17:29:37 -06:00
resolve #3 overlapping callout titles with the right floating icons. Switching from SHIFT to LEFT ALT key for hiding car callouts that have no issues.
This commit is contained in:
@@ -62,18 +62,34 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
{
|
{
|
||||||
foreach (Model.Car car in consist)
|
foreach (Model.Car car in consist)
|
||||||
{
|
{
|
||||||
builder.AddObserver(car.KeyValueObject.Observe(PropertyChange.KeyForControl(PropertyChange.Control.Handbrake), delegate (Value value) { builder.Rebuild(); }, false));
|
builder = AddObserver(builder, car, PropertyChange.KeyForControl(PropertyChange.Control.Handbrake));
|
||||||
foreach (LogicalEnd logicalEnd in ends)
|
foreach (LogicalEnd logicalEnd in ends)
|
||||||
{
|
{
|
||||||
builder.AddObserver(car.KeyValueObject.Observe(KeyValueKeyFor(EndGearStateKey.IsCoupled, car.LogicalToEnd(logicalEnd)), delegate (Value value) { builder.Rebuild(); }, false));
|
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.IsCoupled, car.LogicalToEnd(logicalEnd)));
|
||||||
builder.AddObserver(car.KeyValueObject.Observe(KeyValueKeyFor(EndGearStateKey.IsAirConnected, car.LogicalToEnd(logicalEnd)), delegate (Value value) { builder.Rebuild(); }, false));
|
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.IsAirConnected, car.LogicalToEnd(logicalEnd)));
|
||||||
builder.AddObserver(car.KeyValueObject.Observe(KeyValueKeyFor(EndGearStateKey.Anglecock, car.LogicalToEnd(logicalEnd)), delegate (Value value) { builder.Rebuild(); }, false));
|
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.Anglecock, car.LogicalToEnd(logicalEnd)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static UIPanelBuilder AddObserver(UIPanelBuilder builder, Model.Car car, string key)
|
||||||
|
{
|
||||||
|
builder.AddObserver(
|
||||||
|
car.KeyValueObject.Observe(
|
||||||
|
key,
|
||||||
|
delegate (Value value)
|
||||||
|
{
|
||||||
|
builder.Rebuild();
|
||||||
|
},
|
||||||
|
false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
public static void MrocConsistHelper(Model.Car car, MrocHelperType mrocHelperType)
|
public static void MrocConsistHelper(Model.Car car, MrocHelperType mrocHelperType)
|
||||||
{
|
{
|
||||||
IEnumerable<Model.Car> consist = car.EnumerateCoupled(LogicalEnd.A);
|
IEnumerable<Model.Car> consist = car.EnumerateCoupled(LogicalEnd.A);
|
||||||
|
|||||||
@@ -13,42 +13,46 @@ namespace TweaksAndThings.Patches;
|
|||||||
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
public class TagController_UpdateTag_Patch
|
public class TagController_UpdateTag_Patch
|
||||||
{
|
{
|
||||||
|
private const string tagTitleAndIconDelimeter = "\n<width=100%><align=\"right\">";
|
||||||
|
private const string tagTitleFormat = "<align=left><margin-right={0}.5em>{1}</margin><line-height=0>";
|
||||||
|
|
||||||
private static void Postfix(Car car, TagCallout tagCallout)
|
private static void Postfix(Car car, TagCallout tagCallout)
|
||||||
{
|
{
|
||||||
TagController tagController = UnityEngine.Object.FindObjectOfType<TagController>();
|
TagController tagController = UnityEngine.Object.FindObjectOfType<TagController>();
|
||||||
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
|
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
|
||||||
bool concatOnly = car.DisplayName.Length > 6;
|
|
||||||
string delimiter = concatOnly ? " " : "\n<align=\"right\">";
|
|
||||||
|
|
||||||
if (!tweaksAndThings.IsEnabled || !tweaksAndThings.settings.HandBrakeAndAirTagModifiers)
|
if (!tweaksAndThings.IsEnabled || !tweaksAndThings.settings.HandBrakeAndAirTagModifiers)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tagCallout.callout.Title = concatOnly ? $"<align=left>{car.DisplayName} <space=.5em> " : $"<align=left>{car.DisplayName}<line-height=0>";
|
|
||||||
|
ProceedWithPostFix(car, tagCallout, tagController);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ProceedWithPostFix(Car car, TagCallout tagCallout, TagController tagController)
|
||||||
|
{
|
||||||
|
bool isAltDownWithCarIssue = GameInput.IsAltDown && car.CarOrEndGearIssue();
|
||||||
|
tagCallout.callout.Title = string.Format(tagTitleFormat, "{0}", car.DisplayName);
|
||||||
tagCallout.gameObject.SetActive(
|
tagCallout.gameObject.SetActive(
|
||||||
tagCallout.gameObject.activeSelf &&
|
tagCallout.gameObject.activeSelf &&
|
||||||
(!GameInput.IsShiftDown || (GameInput.IsShiftDown && car.CarOrEndGearIssue()))
|
(!GameInput.IsAltDown || isAltDownWithCarIssue)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (tagCallout.gameObject.activeSelf && GameInput.IsShiftDown && car.CarOrEndGearIssue()) {
|
if (tagCallout.gameObject.activeSelf && isAltDownWithCarIssue)
|
||||||
|
{
|
||||||
tagController.ApplyImageColor(tagCallout, Color.black);
|
tagController.ApplyImageColor(tagCallout, Color.black);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (car.CarAndEndGearIssue())
|
tagCallout.callout.Title =
|
||||||
{
|
(car.CarAndEndGearIssue(), car.EndAirSystemIssue(), car.HandbrakeApplied()) switch
|
||||||
tagCallout.callout.Title = $"{tagCallout.callout.Title}{delimiter}{TextSprites.CycleWaybills}{TextSprites.HandbrakeWheel}";
|
{
|
||||||
}
|
(true, _, _) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.CycleWaybills}{TextSprites.HandbrakeWheel}".Replace("{0}", "2"),
|
||||||
else if (car.EndAirSystemIssue())
|
(_, true, _) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.CycleWaybills}".Replace("{0}", "1"),
|
||||||
{
|
(_, _, true) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.HandbrakeWheel}".Replace("{0}", "1"),
|
||||||
tagCallout.callout.Title = $"{tagCallout.callout.Title}{delimiter}{TextSprites.CycleWaybills}";
|
_ => car.DisplayName
|
||||||
|
};
|
||||||
}
|
|
||||||
else if (car.HandbrakeApplied())
|
|
||||||
{
|
|
||||||
tagCallout.callout.Title = $"{tagCallout.callout.Title}{delimiter}{TextSprites.HandbrakeWheel}";
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +71,7 @@ public static class ModelCarExtensions
|
|||||||
|
|
||||||
public static bool CarOrEndGearIssue(this Model.Car car) =>
|
public static bool CarOrEndGearIssue(this Model.Car car) =>
|
||||||
car.EndAirSystemIssue() || car.HandbrakeApplied();
|
car.EndAirSystemIssue() || car.HandbrakeApplied();
|
||||||
|
|
||||||
public static bool CarAndEndGearIssue(this Model.Car car) =>
|
public static bool CarAndEndGearIssue(this Model.Car car) =>
|
||||||
car.EndAirSystemIssue() && car.HandbrakeApplied();
|
car.EndAirSystemIssue() && car.HandbrakeApplied();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace TweaksAndThings
|
|||||||
builder.Rebuild();
|
builder.Rebuild();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
).Tooltip("Enable Tag Updates", $"Will add {TextSprites.CycleWaybills} to the car tag title having Air System issues. Also prepends {TextSprites.HandbrakeWheel} if there is a handbrake set.\n\nHolding Shift while tags are displayed only shows tag titles that have issues.");
|
).Tooltip("Enable Tag Updates", $"Will add {TextSprites.CycleWaybills} to the car tag title having Air System issues. Also prepends {TextSprites.HandbrakeWheel} if there is a handbrake set.\n\nHolding Left Alt while tags are displayed only shows tag titles that have issues.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user