mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Add wiki abilities as a list for ICustomRole
This commit is contained in:
1 parent
24407580d5
commit
9fd5b488b8
1 file changed
+53
-3
@@ -1,14 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
|
using Il2CppInterop.Runtime.Attributes;
|
||||||
using MiraAPI.GameModes;
|
using MiraAPI.GameModes;
|
||||||
using MiraAPI.GameOptions;
|
using MiraAPI.GameOptions;
|
||||||
using MiraAPI.Modifiers;
|
using MiraAPI.Modifiers;
|
||||||
using MiraAPI.PluginLoading;
|
using MiraAPI.PluginLoading;
|
||||||
using MiraAPI.Translation;
|
using MiraAPI.Translation;
|
||||||
using MiraAPI.Utilities;
|
using MiraAPI.Utilities;
|
||||||
|
using MiraAPI.Utilities.Assets;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace MiraAPI.Roles;
|
namespace MiraAPI.Roles;
|
||||||
|
|
||||||
@@ -68,9 +73,10 @@ public interface ICustomRole : IOptionable
|
|||||||
string RoleLongDescriptionLocale => MiraLocaleManager.BuildTranslationId(IdPrefix, IdPart, "TabDescription");
|
string RoleLongDescriptionLocale => MiraLocaleManager.BuildTranslationId(IdPrefix, IdPart, "TabDescription");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string RoleWikiDescription => MiraLocaleManager.Get(RoleWikiDescriptionLocale, RoleLongDescription);
|
string RoleWikiDescription => MiraLocaleManager.Get(RoleWikiDescriptionLocale, RoleLongDescription) +
|
||||||
|
Helpers.GetModdedOptionsForType(GetType());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the role's wiki description id for localization.
|
/// Gets the role's wiki description id for localization.
|
||||||
@@ -326,9 +332,45 @@ public interface ICustomRole : IOptionable
|
|||||||
RoleWikiDescription,
|
RoleWikiDescription,
|
||||||
titleText,
|
titleText,
|
||||||
out var desc);
|
out var desc);
|
||||||
|
var num = 0;
|
||||||
|
if (WikiAbilities.Count != 0)
|
||||||
|
{
|
||||||
|
var grid = Object.Instantiate(parent.Inner, obj.transform);
|
||||||
|
var layoutGroup = grid.GetComponent<GridLayoutGroup>();
|
||||||
|
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.SetParent(parent.Inner.transform);
|
||||||
obj.transform.localPosition = new Vector3(0f, 0f, 0f);
|
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;
|
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.
|
/// Gets the function that determines whether the role should be toggled on or off in the game settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Func<bool> VisibleInSettings => () => true;
|
Func<bool> VisibleInSettings => () => true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the list of abilities or other similar information to display below the text of a role's wiki page.
|
||||||
|
/// </summary>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
|
public List<AdvancedWikiAbilityDescription> WikiAbilities => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record struct AdvancedWikiAbilityDescription(string Name, string AbilityType, string Description, LoadableAsset<Sprite> Icon);
|
||||||
Reference in new issue
Block a user