From 9fd5b488b8524cd71400d8a44fb7c559278c964e Mon Sep 17 00:00:00 2001
From: Atony <75191600+AtonyGit@users.noreply.github.com>
Date: Sat, 3 Oct 2026 22:25:37 -0500
Subject: [PATCH] Add wiki abilities as a list for ICustomRole
---
MiraAPI/Roles/ICustomRole.cs | 56 ++++++++++++++++++++++++++++++++++--
1 file changed, 53 insertions(+), 3 deletions(-)
diff --git a/MiraAPI/Roles/ICustomRole.cs b/MiraAPI/Roles/ICustomRole.cs
index 0030024..08e3ee2 100644
--- a/MiraAPI/Roles/ICustomRole.cs
+++ b/MiraAPI/Roles/ICustomRole.cs
@@ -1,14 +1,19 @@
using System;
+using System.Collections.Generic;
using System.Text;
using BepInEx.Configuration;
+using Il2CppInterop.Runtime.Attributes;
using MiraAPI.GameModes;
using MiraAPI.GameOptions;
using MiraAPI.Modifiers;
using MiraAPI.PluginLoading;
using MiraAPI.Translation;
using MiraAPI.Utilities;
+using MiraAPI.Utilities.Assets;
using TMPro;
using UnityEngine;
+using UnityEngine.UI;
+using Object = UnityEngine.Object;
namespace MiraAPI.Roles;
@@ -68,9 +73,10 @@ public interface ICustomRole : IOptionable
string RoleLongDescriptionLocale => MiraLocaleManager.BuildTranslationId(IdPrefix, IdPart, "TabDescription");
///
- /// Gets the wiki description of the role. Used in the wiki, but not currently required.
+ /// Gets the wiki description of the role. Used in the wiki and normally appends the options text as well.
///
- string RoleWikiDescription => MiraLocaleManager.Get(RoleWikiDescriptionLocale, RoleLongDescription);
+ string RoleWikiDescription => MiraLocaleManager.Get(RoleWikiDescriptionLocale, RoleLongDescription) +
+ Helpers.GetModdedOptionsForType(GetType());
///
/// Gets the role's wiki description id for localization.
@@ -326,9 +332,45 @@ public interface ICustomRole : IOptionable
RoleWikiDescription,
titleText,
out var desc);
+ var num = 0;
+ if (WikiAbilities.Count != 0)
+ {
+ var grid = Object.Instantiate(parent.Inner, obj.transform);
+ var layoutGroup = grid.GetComponent();
+ layoutGroup.startAxis = GridLayoutGroup.Axis.Vertical;
+ layoutGroup.constraint = GridLayoutGroup.Constraint.FixedColumnCount;
+ layoutGroup.spacing = new Vector2(0.75f, 0.4f);
+ grid.DestroyChildren();
+ foreach (var ability in WikiAbilities)
+ {
+ num++;
+ var panel = Object.Instantiate(
+ guide.MatchInfoRolePanelPrefab,
+ grid);
+ panel.roleCount.text = ability.AbilityType;
+ panel.roleCount.transform.localPosition += new Vector3(-0.04f, 0);
+ panel.roleName.text = ability.Name;
+ panel.roleName.transform.localPosition += new Vector3(-0.04f, 0);
+ panel.roleDescription.text = ability.Description;
+ panel.roleDescription.rectTransform.sizeDelta = new Vector2(2.601f, 0.8f);
+ panel.roleDescription.transform.localPosition += new Vector3(0, -0.1f);
+ panel.roleIcon.sprite = ability.Icon.LoadAsset();
+ panel.roleIcon.SetSizeLimit(0.13f);
+
+ panel.roleIcon.material.SetInt(PlayerMaterial.MaskLayer, 50);
+ panel.roleName.fontMaterial.SetFloat(panel.STENCIL_NAME, 50f);
+ panel.roleDescription.fontMaterial.SetFloat(panel.STENCIL_NAME, 50f);
+ panel.roleCount.fontMaterial.SetFloat(panel.STENCIL_NAME, 50f);
+ panel.roleIcon.transform.localScale = new Vector3(3.5f, 3.5f, 1f);
+ }
+
+ grid.localPosition = new Vector3(-3.9f, 1.1f - desc.textBounds.size.y, 0f);
+ grid.localScale = new Vector3(1.3f, 1.3f, 1);
+ }
+
obj.transform.SetParent(parent.Inner.transform);
obj.transform.localPosition = new Vector3(0f, 0f, 0f);
- parent.SetYBoundsMax(Mathf.Clamp(desc.textBounds.size.y - 2, 0f, 999f));
+ parent.SetYBoundsMax(Mathf.Clamp((desc.textBounds.size.y - 2) + (Mathf.Ceil(num / 2f) * 1.45f), 0f, 999f));
return obj;
}
@@ -336,4 +378,12 @@ public interface ICustomRole : IOptionable
/// Gets the function that determines whether the role should be toggled on or off in the game settings.
///
Func VisibleInSettings => () => true;
+
+ ///
+ /// Gets the list of abilities or other similar information to display below the text of a role's wiki page.
+ ///
+ [HideFromIl2Cpp]
+ public List WikiAbilities => [];
}
+
+public record struct AdvancedWikiAbilityDescription(string Name, string AbilityType, string Description, LoadableAsset Icon);