Change added buttons to have gray background

This commit is contained in:
Tyfon
2024-06-01 16:34:44 -07:00
parent 6149d310a7
commit e562563cc2
2 changed files with 54 additions and 2 deletions

View File

@@ -24,6 +24,8 @@ namespace UIFixes
private const float ButtonPadding = 3f;
public static Image ButtonBackground; // Nice gray background for the new buttons
public static void Enable()
{
new SaveInspectWindowSizePatch().Enable();
@@ -75,7 +77,7 @@ namespace UIFixes
}
[PatchPostfix]
public static void Postfix(ItemSpecificationPanel __instance, LayoutElement ___layoutElement_0)
public static void Postfix(ItemSpecificationPanel __instance, LayoutElement ___layoutElement_0, ItemUiContext ___itemUiContext_0)
{
if (Settings.LockInspectPreviewSize.Value)
{
@@ -86,6 +88,12 @@ namespace UIFixes
}
}
if (ButtonBackground == null)
{
// Steal the background image fom gridwindow sort
ButtonBackground = ___itemUiContext_0.R().GridWindowTemplate.R().GridSortPanel.R().Button.image;
}
Button closeButton = __instance.GetComponentsInChildren<Button>().FirstOrDefault(b => b.name == "Close Button");
if (closeButton != null)
{
@@ -104,6 +112,9 @@ namespace UIFixes
RectTransform restoreRect = (RectTransform)restoreButton.transform;
restoreRect.localPosition = new Vector3(templateRect.localPosition.x - 3 * (templateRect.rect.width + ButtonPadding), templateRect.localPosition.y, templateRect.localPosition.z);
Image background = restoreButton.GetComponent<Image>();
background.sprite = ButtonBackground.sprite;
Image restoreImage = restoreButton.GetComponentsInChildren<Image>().First(i => i.name == "X");
restoreImage.sprite = EFTHardSettings.Instance.StaticIcons.GetAttributeIcon(EItemAttributeId.EffectiveDist);
restoreImage.overrideSprite = null;
@@ -146,6 +157,9 @@ namespace UIFixes
RectTransform leftRect = (RectTransform)leftButton.transform;
leftRect.localPosition = new Vector3(templateRect.localPosition.x - 2 * (templateRect.rect.width + ButtonPadding), templateRect.localPosition.y, templateRect.localPosition.z);
Image background = leftButton.GetComponent<Image>();
background.sprite = ButtonBackground.sprite;
Image leftImage = leftButton.GetComponentsInChildren<Image>().First(i => i.name == "X");
leftImage.sprite = EFTHardSettings.Instance.StaticIcons.GetAttributeIcon(EItemAttributeId.RecoilBack);
leftImage.overrideSprite = null;
@@ -163,6 +177,9 @@ namespace UIFixes
RectTransform rightRect = (RectTransform)rightButton.transform;
rightRect.localPosition = new Vector3(templateRect.localPosition.x - (templateRect.rect.width + ButtonPadding), templateRect.localPosition.y, templateRect.localPosition.z);
Image background = rightButton.GetComponent<Image>();
background.sprite = ButtonBackground.sprite;
Image leftImage = rightButton.GetComponentsInChildren<Image>().First(i => i.name == "X");
leftImage.sprite = EFTHardSettings.Instance.StaticIcons.GetAttributeIcon(EItemAttributeId.RecoilBack);
leftImage.transform.Rotate(0f, 180f, 0f);