Merge pull request #66 from WanderingPix/fix-roleicons

Fix role icons now appearing if there are no settings for the role.
This commit is contained in:
Atony authored and GitHub committed 2025-09-11 05:26:17 -05:00
commit 89eb774501
1 file changed
+12 -12
@@ -532,6 +532,18 @@ public static class RoleSettingMenuPatches
roleOptionSetting.titleText.color = customRole.OptionsMenuColor.FindAlternateColor();
roleOptionSetting.titleText.horizontalAlignment = HorizontalAlignmentOptions.Left;
if (customRole.Configuration.Icon != null)
{
var roleIcon = new GameObject("RoleIcon");
roleIcon.transform.parent = roleOptionSetting.transform;
roleIcon.transform.localScale = new(.25f, .25f, 1);
roleIcon.layer = LayerMask.NameToLayer("UI");
roleIcon.transform.localPosition = new Vector3(-1.3f, -0.3f, -2f);
var rend = roleIcon.AddComponent<SpriteRenderer>();
rend.sprite = customRole.Configuration.Icon.LoadAsset();
rend.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
}
if (GameSettingMenuPatches.SelectedMod is null ||
GameSettingMenuPatches.SelectedMod.InternalOptionGroups
.Exists(x => x.GroupVisible() && x.OptionableType == role.GetType() && x.Options.Any(y => y.Visible())))
@@ -551,18 +563,6 @@ public static class RoleSettingMenuPatches
passiveButton.interactableHoveredColor = Color.white;
passiveButton.OnClick.AddListener((UnityAction)(() => { ChangeTab(role, __instance); }));
if (customRole.Configuration.Icon != null)
{
var roleIcon = new GameObject("RoleIcon");
roleIcon.transform.parent = roleOptionSetting.transform;
roleIcon.transform.localScale = new(.25f, .25f, 1);
roleIcon.layer = LayerMask.NameToLayer("UI");
roleIcon.transform.localPosition = new Vector3(-1.3f, -0.3f, -2f);
var rend = roleIcon.AddComponent<SpriteRenderer>();
rend.sprite = customRole.Configuration.Icon.LoadAsset();
rend.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
}
}
if (customRole.Configuration is { MaxRoleCount: 0 })