mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Add icons to all menus
This commit is contained in:
1 parent
5d354eff5e
commit
7349a259a1
11 files changed
+114
-9
No files matched your search
@@ -107,17 +107,20 @@ public abstract class BaseModifier : IOptionable
|
||||
/// </summary>
|
||||
/// <param name="guide">The guide object.</param>
|
||||
/// <param name="titleText">The title text object.</param>
|
||||
/// <param name="titleIcon">The title's icon.</param>
|
||||
/// <param name="parent">The scroller parent.</param>
|
||||
/// <returns>The <see cref="GameObject"/> of the wiki.</returns>
|
||||
public virtual GameObject GetAdvancedWiki(MatchInfoGuide guide, TextMeshPro titleText, Scroller parent)
|
||||
public virtual GameObject GetAdvancedWiki(MatchInfoGuide guide, TextMeshPro titleText, SpriteRenderer titleIcon, Scroller parent)
|
||||
{
|
||||
var abilities = WikiAbilities;
|
||||
return Helpers.CreateAdvancedWikiPage(
|
||||
guide,
|
||||
titleText,
|
||||
titleIcon,
|
||||
parent,
|
||||
ModifierNameLocale,
|
||||
$"{this.GetTmpIcon()} {ModifierName} ({ModifierCategoryTitle})".TrimStart(),
|
||||
$"{ModifierName} ({ModifierCategoryTitle})".TrimStart(),
|
||||
ModifierIcon ?? MiraAssets.IconNeutral.LoadAsset(),
|
||||
ModifierWikiDescription,
|
||||
abilities);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public static class RoleGuidePatches
|
||||
private static TextBoxTMP _searchBoxTmp;
|
||||
private static GameObject _currentAdvancedTabObject;
|
||||
private static TextMeshPro _titleText;
|
||||
private static SpriteRenderer _titleIcon;
|
||||
private static bool _suppressSearchRefresh;
|
||||
private static IEnumerator? _searchDebounce;
|
||||
private static string _appliedSearch = string.Empty;
|
||||
@@ -145,6 +146,7 @@ public static class RoleGuidePatches
|
||||
_appliedSearch = string.Empty;
|
||||
_suppressSearchRefresh = false;
|
||||
_titleText = null!;
|
||||
_titleIcon = null!;
|
||||
_searchBoxTmp = null!;
|
||||
_rolesScroller = null!;
|
||||
_modifiersScroller = null!;
|
||||
@@ -254,9 +256,18 @@ public static class RoleGuidePatches
|
||||
_titleText = __instance.transitionOpen.transform.FindChild("Text_Title")?.GetComponent<TextMeshPro>()!;
|
||||
if (_titleText)
|
||||
{
|
||||
_titleText.transform.localPosition += new Vector3(0.5f, 0);
|
||||
_titleText.transform.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
}
|
||||
}
|
||||
if (!_titleIcon)
|
||||
{
|
||||
var titleIconObj = new GameObject("TitleIcon");
|
||||
_titleIcon = titleIconObj.AddComponent<SpriteRenderer>();
|
||||
_titleIcon.transform.SetParent(_titleText.transform.parent);
|
||||
_titleIcon.transform.localPosition = new Vector3(-2.75f, 1.4f, 0);
|
||||
titleIconObj.layer = _titleText.gameObject.layer;
|
||||
}
|
||||
|
||||
if (_titleText)
|
||||
{
|
||||
@@ -1247,26 +1258,33 @@ public static class RoleGuidePatches
|
||||
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.SetActiveTab))]
|
||||
private static void SetActiveTab(int tabIndex)
|
||||
{
|
||||
if (_titleText)
|
||||
if (_titleText && _titleIcon)
|
||||
{
|
||||
switch (tabIndex)
|
||||
{
|
||||
case 0:
|
||||
_titleText.text = MiraLocaleManager.Get("MiraApi.Wiki.PlayersTab");
|
||||
_titleIcon.sprite = MiraAssets.IconPlayerList.LoadAsset();
|
||||
break;
|
||||
case 1:
|
||||
_titleText.text = MiraLocaleManager.Get("MiraApi.Wiki.SettingsTab");
|
||||
_titleIcon.sprite = MiraAssets.IconSettings.LoadAsset();
|
||||
break;
|
||||
case RolesTabIndex:
|
||||
_titleText.text = MiraLocaleManager.Get("Roles");
|
||||
_titleIcon.sprite = GetRandomRoleIcon();
|
||||
break;
|
||||
case ModifiersTabIndex:
|
||||
_titleText.text = MiraLocaleManager.Get("Modifiers");
|
||||
_titleIcon.sprite = GetRandomModifierIcon();
|
||||
break;
|
||||
default:
|
||||
_titleText.text = TranslationController.Instance.GetString(StringNames.MatchInfoGuideTitle);
|
||||
_titleIcon.sprite = MiraAssets.IconPlayerList.LoadAsset();
|
||||
break;
|
||||
}
|
||||
|
||||
_titleIcon.SetSizeLimit(0.55f);
|
||||
}
|
||||
|
||||
_advancedInfoTabScroller?.gameObject.SetActive(false);
|
||||
@@ -1274,6 +1292,45 @@ public static class RoleGuidePatches
|
||||
UpdateSpinner();
|
||||
}
|
||||
|
||||
public static Sprite GetRandomModifierIcon()
|
||||
{
|
||||
var activeMods = PlayerControl.LocalPlayer.GetModifiers<GameModifier>()
|
||||
.Where(x => !x.HideOnUi && x.ModifierIcon != null).ToList();
|
||||
if (activeMods.Count > 0)
|
||||
{
|
||||
return activeMods.Random()!.ModifierIcon!.LoadAsset();
|
||||
}
|
||||
|
||||
return GetRandomFactionIcon();
|
||||
}
|
||||
|
||||
public static Sprite GetRandomRoleIcon()
|
||||
{
|
||||
var aliveRole = PlayerControl.LocalPlayer.Data?.Role;
|
||||
if (aliveRole != null && aliveRole.RoleIconSolid != null)
|
||||
{
|
||||
return aliveRole.RoleIconSolid;
|
||||
}
|
||||
|
||||
return GetRandomFactionIcon();
|
||||
}
|
||||
|
||||
public static Sprite GetRandomFactionIcon()
|
||||
{
|
||||
var random = UnityEngine.Random.Range(1, 4);
|
||||
if (random == 1)
|
||||
{
|
||||
return MiraAssets.IconCrewmate.LoadAsset();
|
||||
}
|
||||
|
||||
if (random == 2)
|
||||
{
|
||||
return MiraAssets.IconImpostor.LoadAsset();
|
||||
}
|
||||
|
||||
return MiraAssets.IconNeutral.LoadAsset();
|
||||
}
|
||||
|
||||
private static bool TryPrepareAdvancedWiki(MatchInfoGuide instance)
|
||||
{
|
||||
instance.settingsTabs[RolesTabIndex].SetActive(false);
|
||||
@@ -1325,7 +1382,7 @@ public static class RoleGuidePatches
|
||||
return;
|
||||
}
|
||||
|
||||
_currentAdvancedTabObject = modifier.GetAdvancedWiki(instance, _titleText, _advancedInfoTabScroller);
|
||||
_currentAdvancedTabObject = modifier.GetAdvancedWiki(instance, _titleText, _titleIcon, _advancedInfoTabScroller);
|
||||
}
|
||||
|
||||
public static void DisplayAdvancedWiki(MatchInfoGuide instance, RoleBehaviour role)
|
||||
@@ -1345,11 +1402,11 @@ public static class RoleGuidePatches
|
||||
|
||||
if (role is ICustomRole custom)
|
||||
{
|
||||
_currentAdvancedTabObject = custom.GetAdvancedWiki(instance, _titleText, _advancedInfoTabScroller);
|
||||
_currentAdvancedTabObject = custom.GetAdvancedWiki(instance, _titleText, _titleIcon, _advancedInfoTabScroller);
|
||||
}
|
||||
else
|
||||
{
|
||||
var titleTxt = $"{role.GetTmpIcon()} {role.GetRoleName()}" +
|
||||
var titleTxt = $"{role.GetRoleName()}" +
|
||||
$" ({TranslationController.Instance.GetString(role.TeamType is RoleTeamTypes.Crewmate ? StringNames.Crewmate : StringNames.Impostor)})";
|
||||
var description = TranslationController.Instance.GetString(role.BlurbNameLong);
|
||||
if (description.Contains("STRMISS"))
|
||||
@@ -1364,9 +1421,11 @@ public static class RoleGuidePatches
|
||||
_currentAdvancedTabObject = Helpers.CreateAdvancedWikiPage(
|
||||
instance,
|
||||
_titleText,
|
||||
_titleIcon,
|
||||
_advancedInfoTabScroller,
|
||||
role.Role.ToString(),
|
||||
titleTxt,
|
||||
role.RoleIconColor,
|
||||
description,
|
||||
[]);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -318,17 +318,20 @@ public interface ICustomRole : IOptionable
|
||||
/// </summary>
|
||||
/// <param name="guide">The guide object.</param>
|
||||
/// <param name="titleText">The title text object.</param>
|
||||
/// <param name="titleIcon">The title's icon.</param>
|
||||
/// <param name="parent">The scroller parent.</param>
|
||||
/// <returns>The <see cref="GameObject"/> of the wiki.</returns>
|
||||
GameObject GetAdvancedWiki(MatchInfoGuide guide, TextMeshPro titleText, Scroller parent)
|
||||
GameObject GetAdvancedWiki(MatchInfoGuide guide, TextMeshPro titleText, SpriteRenderer titleIcon, Scroller parent)
|
||||
{
|
||||
var abilities = WikiAbilities;
|
||||
return Helpers.CreateAdvancedWikiPage(
|
||||
guide,
|
||||
titleText,
|
||||
titleIcon,
|
||||
parent,
|
||||
RoleNameLocale,
|
||||
$"{this.GetTmpIcon()} {RoleName} ({RoleFactionTitle})",
|
||||
$"{RoleName} ({RoleFactionTitle})",
|
||||
Configuration.Icon ?? MiraAssets.IconNeutral.LoadAsset(),
|
||||
RoleWikiDescription,
|
||||
abilities);
|
||||
}
|
||||
|
||||
@@ -305,5 +305,35 @@ public static class MiraAssets
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset VisibleOnIdleSprite { get; } = new("MiraAPI.Resources.Wiki.VisibleOnIdle.png");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite used for crewmates.
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset IconCrewmate { get; } = new("MiraAPI.Resources.Wiki.IconCrewmate.png");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite used for impostors.
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset IconImpostor { get; } = new("MiraAPI.Resources.Wiki.IconImpostor.png");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite used for neutrals.
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset IconNeutral { get; } = new("MiraAPI.Resources.Wiki.IconNeutral.png");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite used for the player list.
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset IconPlayerList { get; } = new("MiraAPI.Resources.Wiki.IconPlayerList.png");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite used for settings.
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset IconSettings { get; } = new("MiraAPI.Resources.Wiki.IconSettings.png");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite used for terminology.
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset IconTerminology { get; } = new("MiraAPI.Resources.Wiki.IconTerminology.png");
|
||||
|
||||
internal static LoadableResourceAsset BlankSprite { get; } = new("MiraAPI.Resources.BlankSprite.png");
|
||||
}
|
||||
@@ -741,15 +741,19 @@ public static class Helpers
|
||||
/// <param name="guide">The guide panel to attach the tab to.</param>
|
||||
/// <param name="objName">The name of the tab.</param>
|
||||
/// <param name="title">The title of the tab.</param>
|
||||
/// <param name="icon">The icon of the page.</param>
|
||||
/// <param name="description">The description of the tab.</param>
|
||||
/// <param name="titleTmp">The <see cref="TextMeshPro"/> instance of the title.</param>
|
||||
/// <param name="titleIcon">The <see cref="SpriteRenderer"/> instance for the title.</param>
|
||||
/// <param name="descriptionTmp">The <see cref="TextMeshPro"/> instance of the description.</param>
|
||||
/// <returns>The <see cref="GameObject"/> of the tab.</returns>
|
||||
public static GameObject CreateAdvancedWikiTab(MatchInfoGuide guide, string objName, string title, string description, TextMeshPro titleTmp, out TextMeshPro descriptionTmp)
|
||||
public static GameObject CreateAdvancedWikiTab(MatchInfoGuide guide, string objName, string title, Sprite icon, string description, TextMeshPro titleTmp, SpriteRenderer titleIcon, out TextMeshPro descriptionTmp)
|
||||
{
|
||||
var obj = new GameObject(objName);
|
||||
titleTmp.richText = true;
|
||||
titleTmp.text = title;
|
||||
titleIcon.sprite = icon;
|
||||
titleIcon.SetSizeLimit(0.55f);
|
||||
descriptionTmp = Object.Instantiate(guide.MatchInfoRolePanelPrefab.roleCount, obj.transform);
|
||||
descriptionTmp.fontSizeMin = descriptionTmp.fontSizeMax = descriptionTmp.fontSize = 2f;
|
||||
var sourceTmp = HudManager.Instance.TaskPanel.taskText;
|
||||
@@ -769,9 +773,11 @@ public static class Helpers
|
||||
/// </summary>
|
||||
/// <param name="guide">The guide object.</param>
|
||||
/// <param name="titleTmp">The <see cref="TextMeshPro"/> instance of the title.</param>
|
||||
/// <param name="titleIcon">The <see cref="SpriteRenderer"/> instance for the title.</param>
|
||||
/// <param name="parent">The <see cref="Scroller"/> the page should be parented to.</param>
|
||||
/// <param name="objName">The name of the page object.</param>
|
||||
/// <param name="title">The title of the page.</param>
|
||||
/// <param name="icon">The icon of the page.</param>
|
||||
/// <param name="description">The description of the page.</param>
|
||||
/// <param name="abilities">The abilities to display in a grid below the description.</param>
|
||||
/// <param name="variableTextSizing">Whether to use variable text sizing for ability descriptions (allows different heights).</param>
|
||||
@@ -779,9 +785,11 @@ public static class Helpers
|
||||
public static GameObject CreateAdvancedWikiPage(
|
||||
MatchInfoGuide guide,
|
||||
TextMeshPro titleTmp,
|
||||
SpriteRenderer titleIcon,
|
||||
Scroller parent,
|
||||
string objName,
|
||||
string title,
|
||||
Sprite icon,
|
||||
string description,
|
||||
IReadOnlyCollection<AdvancedWikiAbilityDescription> abilities,
|
||||
bool variableTextSizing = false)
|
||||
@@ -791,8 +799,10 @@ public static class Helpers
|
||||
guide,
|
||||
objName,
|
||||
title,
|
||||
icon,
|
||||
description,
|
||||
titleTmp,
|
||||
titleIcon,
|
||||
out var desc);
|
||||
var num = 0;
|
||||
var maxTextSize = 0f;
|
||||
|
||||
Reference in new issue
Block a user