resolve and suppress warnings

This commit is contained in:
Az committed 2026-10-14 00:48:08 -04:00
1 parent 9da879fd61
commit 50312e31c2
17 files changed
+106 -106

No files matched your search

+12
View File
@@ -86,3 +86,15 @@ dotnet_diagnostic.SA1133.severity = none
# IDE0001: Simplify Names # IDE0001: Simplify Names
dotnet_diagnostic.IDE0001.severity = warning dotnet_diagnostic.IDE0001.severity = warning
# IDE0079: Remove unnecessary suppression
dotnet_diagnostic.IDE0079.severity = none
# S3903: Types should be defined in named namespaces
dotnet_diagnostic.S3903.severity = none
# IDE0045: Convert to conditional expression
dotnet_diagnostic.IDE0045.severity = none
# IDE0046: Convert to conditional expression
dotnet_diagnostic.IDE0046.severity = none
+4
View File
@@ -0,0 +1,4 @@
[*.{cs,vb}]
# SA1602: Enumeration items should be documented.
dotnet_diagnostic.SA1602.severity = none
+6 -6
View File
@@ -16,11 +16,11 @@
Your votes have double the power.</string> Your votes have double the power.</string>
<string name="ApiExample.Role.Crewmate.Mayor.TabDescription">You get one extra vote in the meeting!</string> <string name="ApiExample.Role.Crewmate.Mayor.TabDescription">You get one extra vote in the meeting!</string>
<string name="ApiExample.Role.Crewmate.Mayor.WikiDescription">The Mayor is a Crewmate role that gets two votes in the meeting, instead of the singular vote other Crewmates get.</string> <string name="ApiExample.Role.Crewmate.Mayor.WikiDescription">The Mayor is a Crewmate role that gets two votes in the meeting, instead of the singular vote other Crewmates get.</string>
<string name="ApiExample.Role.Crewmate.Chamelon">Chamelon</string> <string name="ApiExample.Role.Crewmate.Chameleon">Chameleon</string>
<string name="ApiExample.Role.Crewmate.Chamelon.IntroBlurb">Become one with the environment.</string> <string name="ApiExample.Role.Crewmate.Chameleon.IntroBlurb">Become one with the environment.</string>
<string name="ApiExample.Role.Crewmate.Chamelon.MedDescription">Fade out of everyone's vision by not moving.</string> <string name="ApiExample.Role.Crewmate.Chameleon.MedDescription">Fade out of everyone's vision by not moving.</string>
<string name="ApiExample.Role.Crewmate.Chamelon.TabDescription">Stay invisible while not moving.</string> <string name="ApiExample.Role.Crewmate.Chameleon.TabDescription">Stay invisible while not moving.</string>
<string name="ApiExample.Role.Crewmate.Chamelon.WikiDescription">The Chamelon is a Crewmate role that slowly becomes invisible while standing still.</string> <string name="ApiExample.Role.Crewmate.Chameleon.WikiDescription">The Chameleon is a Crewmate role that slowly becomes invisible while standing still.</string>
<string name="ApiExample.Role.Outcast.OutcastKiller">Outcast Killer</string> <string name="ApiExample.Role.Outcast.OutcastKiller">Outcast Killer</string>
<string name="ApiExample.Role.Outcast.OutcastKiller.IntroBlurb">Kill everyone else.</string> <string name="ApiExample.Role.Outcast.OutcastKiller.IntroBlurb">Kill everyone else.</string>
<string name="ApiExample.Role.Outcast.OutcastKiller.MedDescription">Be the last outcast standing. <string name="ApiExample.Role.Outcast.OutcastKiller.MedDescription">Be the last outcast standing.
@@ -73,7 +73,7 @@ Eliminate every other faction.</string>
<string name="settings.miraExample.exampleBool2">Example Bool 2</string> <string name="settings.miraExample.exampleBool2">Example Bool 2</string>
<string name="settings.miraExample.slider">Slider</string> <string name="settings.miraExample.slider">Slider</string>
<string name="settings.miraExample.exampleNumber">Example Number</string> <string name="settings.miraExample.exampleNumber">Example Number</string>
<string name="settings.miraExample.exampleMultiplier">Example Multplier</string> <string name="settings.miraExample.exampleMultiplier">Example Multiplier</string>
<string name="settings.miraExample.exampleEnum">Example Enum</string> <string name="settings.miraExample.exampleEnum">Example Enum</string>
<string name="settings.miraExample.button.exampleButton">Example Button</string> <string name="settings.miraExample.button.exampleButton">Example Button</string>
<string name="gameover.outcastKiller.win">Outcast Killer Wins!</string> <string name="gameover.outcastKiller.win">Outcast Killer Wins!</string>
-2
View File
@@ -1,7 +1,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using AmongUs.Data; using AmongUs.Data;
@@ -462,7 +461,6 @@ public class HideAndSeekMode : AbstractGameMode
} }
/// <inheritdoc/> /// <inheritdoc/>
[SuppressMessage("Style", "IDE0046:Convert to conditional expression", Justification = "Warning cascades into forcing the entire tree to be ternary operators.")]
public override PlayerBodyTypes GetBodyType(PlayerControl player) public override PlayerBodyTypes GetBodyType(PlayerControl player)
{ {
if (player == null || player.Data == null || player.Data.Role == null) if (player == null || player.Data == null || player.Data.Role == null)
@@ -43,7 +43,7 @@ public class ModdedPlayerOption : ModdedOption<int>
data.Title = StringName; data.Title = StringName;
data.Type = global::OptionTypes.Player; data.Type = global::OptionTypes.Player;
Values = new(); Values = [];
AllowNone = allowNone; AllowNone = allowNone;
Value = DefaultValue; Value = DefaultValue;
} }
-1
View File
@@ -100,7 +100,6 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu<CustomPaginableMenu.
: text.Trim().ToLowerInvariant(); : text.Trim().ToLowerInvariant();
} }
[SuppressMessage("Style", "IDE0046:Convert to conditional expression", Justification = "Creates a rather large ternary operation.")]
private List<MenuEntry> GetFilteredEntries() private List<MenuEntry> GetFilteredEntries()
{ {
var query = NormalizeForSearch(searchText); var query = NormalizeForSearch(searchText);
+3 -5
View File
@@ -64,11 +64,9 @@ public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
private static MiraPluginManager? PluginManager { get; set; } private static MiraPluginManager? PluginManager { get; set; }
internal Harmony Harmony { get; } = new(Id); internal Harmony Harmony { get; } = new(Id);
public static ConfigEntry<SortingGroups> WikiSortingGroup { get; private set; } internal static ConfigEntry<SortingGroups> WikiSortingGroup { get; private set; }
internal static ConfigEntry<SortingMethod> WikiSortingMethod { get; private set; }
public static ConfigEntry<SortingMethod> WikiSortingMethod { get; private set; } internal static ConfigEntry<SortingFilter> WikiSortingFilter { get; private set; }
public static ConfigEntry<SortingFilter> WikiSortingFilter { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public override void Load() public override void Load()
+2 -2
View File
@@ -12,5 +12,5 @@ dotnet_diagnostic.SA1611.severity = none
# SA1615: Element return value should be documented. # SA1615: Element return value should be documented.
dotnet_diagnostic.SA1615.severity = none dotnet_diagnostic.SA1615.severity = none
# S125: Sections of code should not be commented out. # SA1602: Enumeration items should be documented.
dotnet_diagnostic.S125.severity = none dotnet_diagnostic.SA1602.severity = none
@@ -25,9 +25,9 @@ namespace MiraAPI.Patches.Options;
[HarmonyPatch(typeof(GameOptionsMenu))] [HarmonyPatch(typeof(GameOptionsMenu))]
internal static class GameOptionsMenuPatch internal static class GameOptionsMenuPatch
{ {
private static readonly List<CategoryHeaderMasked> VanillaHeaders = new(); private static readonly List<CategoryHeaderMasked> VanillaHeaders = [];
private static readonly List<OptionBehaviour> VanillaOptions = new(); private static readonly List<OptionBehaviour> VanillaOptions = [];
private static readonly List<OptionBehaviour> MainOptions = new(); private static readonly List<OptionBehaviour> MainOptions = [];
private static readonly Dictionary<AbstractGameMode, List<AbstractOptionGroup>> GameModeGroups = []; private static readonly Dictionary<AbstractGameMode, List<AbstractOptionGroup>> GameModeGroups = [];
private static readonly Dictionary<AbstractGameMode, List<OptionBehaviour>> GameModeOptions = []; private static readonly Dictionary<AbstractGameMode, List<OptionBehaviour>> GameModeOptions = [];
private static readonly Dictionary<AbstractGameMode, List<CategoryHeaderMasked>> GameModeHeaders = []; private static readonly Dictionary<AbstractGameMode, List<CategoryHeaderMasked>> GameModeHeaders = [];
+1 -3
View File
@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis; using System.Globalization;
using System.Globalization;
using System.Linq; using System.Linq;
using HarmonyLib; using HarmonyLib;
using MiraAPI.GameOptions; using MiraAPI.GameOptions;
@@ -24,7 +23,6 @@ public static class SettingPatches
/// <returns><see langword="false"/> to skip original method.</returns> /// <returns><see langword="false"/> to skip original method.</returns>
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(FloatGameSetting), nameof(FloatGameSetting.GetValueString))] [HarmonyPatch(typeof(FloatGameSetting), nameof(FloatGameSetting.GetValueString))]
[SuppressMessage("Style", "IDE0045:Convert to conditional expression", Justification = "Warning cascades into forcing the entire tree to be ternary operators.")]
public static bool ValueStringPatch( public static bool ValueStringPatch(
FloatGameSetting __instance, FloatGameSetting __instance,
ref string __result, ref string __result,
+51 -75
View File
@@ -33,20 +33,13 @@ public static class RoleGuidePatches
private static readonly List<DetailedPanel> RoleEntries = []; private static readonly List<DetailedPanel> RoleEntries = [];
private static readonly List<DetailedPanel> ModifierEntries = []; private static readonly List<DetailedPanel> ModifierEntries = [];
public static GameObject SearchComponentContainer; private static GameObject searchComponentContainer;
public static PassiveButton SearchIconButton;
private static SpriteRenderer _searchIconIdle; private static SpriteRenderer _searchIconIdle;
private static SpriteRenderer _searchIconHover; private static SpriteRenderer _searchIconHover;
public static TextMeshPro OrderSortingTmp;
public static PassiveButton SearchSortingOrderButton;
private static SpriteRenderer _searchSortingOrderIdle; private static SpriteRenderer _searchSortingOrderIdle;
private static SpriteRenderer _searchSortingOrderHover; private static SpriteRenderer _searchSortingOrderHover;
public static TextMeshPro GroupSortingTmp;
public static PassiveButton SearchSortingGroupButton;
private static SpriteRenderer _searchSortingGroupIdle; private static SpriteRenderer _searchSortingGroupIdle;
private static SpriteRenderer _searchSortingGroupHover; private static SpriteRenderer _searchSortingGroupHover;
public static TextMeshPro FilterSortingTmp;
public static PassiveButton SearchSortingFilterButton;
private static SpriteRenderer _searchSortingFilterIdle; private static SpriteRenderer _searchSortingFilterIdle;
private static SpriteRenderer _searchSortingFilterHover; private static SpriteRenderer _searchSortingFilterHover;
private static Scroller _rolesScroller; private static Scroller _rolesScroller;
@@ -153,10 +146,6 @@ public static class RoleGuidePatches
_advancedInfoTabScroller = null!; _advancedInfoTabScroller = null!;
_currentAdvancedTabObject = null!; _currentAdvancedTabObject = null!;
_loadingSpinner = null; _loadingSpinner = null;
SearchIconButton = null!;
SearchSortingOrderButton = null!;
SearchSortingGroupButton = null!;
SearchSortingFilterButton = null!;
_searchIconIdle = null!; _searchIconIdle = null!;
_searchIconHover = null!; _searchIconHover = null!;
_searchSortingOrderIdle = null!; _searchSortingOrderIdle = null!;
@@ -260,6 +249,7 @@ public static class RoleGuidePatches
_titleText.transform.GetComponent<TextTranslatorTMP>().Destroy(); _titleText.transform.GetComponent<TextTranslatorTMP>().Destroy();
} }
} }
if (!_titleIcon) if (!_titleIcon)
{ {
var titleIconObj = new GameObject("TitleIcon"); var titleIconObj = new GameObject("TitleIcon");
@@ -369,18 +359,18 @@ public static class RoleGuidePatches
_guide = instance; _guide = instance;
_loading = false; _loading = false;
SearchComponentContainer = new GameObject(); searchComponentContainer = new GameObject();
SearchComponentContainer.transform.SetParent(instance.MatchInfoParent.transform); searchComponentContainer.transform.SetParent(instance.MatchInfoParent.transform);
SearchComponentContainer.transform.localPosition = Vector3.zero; searchComponentContainer.transform.localPosition = Vector3.zero;
instance.MatchInfoParent.transform.GetChild(1).transform.SetParent(SearchComponentContainer.transform); instance.MatchInfoParent.transform.GetChild(1).transform.SetParent(searchComponentContainer.transform);
var sortingOrderButton = Object.Instantiate( var sortingOrderButton = Object.Instantiate(
HudManager.Instance.SettingsButton, HudManager.Instance.SettingsButton,
SearchComponentContainer.transform); searchComponentContainer.transform);
sortingOrderButton.gameObject.SetActive(true); sortingOrderButton.gameObject.SetActive(true);
SearchSortingOrderButton = sortingOrderButton.GetComponent<PassiveButton>(); var searchSortingOrderButton = sortingOrderButton.GetComponent<PassiveButton>();
SetupSearchButton( SetupSearchButton(
SearchSortingOrderButton, searchSortingOrderButton,
"SearchSortingOrderButton", "SearchSortingOrderButton",
SwitchMethod, SwitchMethod,
GetSortMethodSprite(_sortMethod, false), GetSortMethodSprite(_sortMethod, false),
@@ -391,11 +381,11 @@ public static class RoleGuidePatches
var sortingGroupButton = Object.Instantiate( var sortingGroupButton = Object.Instantiate(
sortingOrderButton, sortingOrderButton,
SearchComponentContainer.transform); searchComponentContainer.transform);
sortingGroupButton.gameObject.SetActive(true); sortingGroupButton.gameObject.SetActive(true);
SearchSortingGroupButton = sortingGroupButton.GetComponent<PassiveButton>(); var searchSortingGroupButton = sortingGroupButton.GetComponent<PassiveButton>();
SetupSearchButton( SetupSearchButton(
SearchSortingGroupButton, searchSortingGroupButton,
"SearchSortingGroupButton", "SearchSortingGroupButton",
SwitchGrouping, SwitchGrouping,
GetSortGroupSprite(_sortGrouping, false), GetSortGroupSprite(_sortGrouping, false),
@@ -406,11 +396,11 @@ public static class RoleGuidePatches
var sortingFilterButton = Object.Instantiate( var sortingFilterButton = Object.Instantiate(
sortingOrderButton, sortingOrderButton,
SearchComponentContainer.transform); searchComponentContainer.transform);
sortingFilterButton.gameObject.SetActive(true); sortingFilterButton.gameObject.SetActive(true);
SearchSortingFilterButton = sortingFilterButton.GetComponent<PassiveButton>(); var searchSortingFilterButton = sortingFilterButton.GetComponent<PassiveButton>();
SetupSearchButton( SetupSearchButton(
SearchSortingFilterButton, searchSortingFilterButton,
"SearchSortingFilterButton", "SearchSortingFilterButton",
SwitchFilter, SwitchFilter,
GetSortFilterSprite(_sortFilter, false), GetSortFilterSprite(_sortFilter, false),
@@ -463,9 +453,8 @@ public static class RoleGuidePatches
sortingOrderButton, sortingOrderButton,
sortingOrderButton.transform.parent); sortingOrderButton.transform.parent);
searchIconButton.gameObject.SetActive(true); searchIconButton.gameObject.SetActive(true);
SearchIconButton = searchIconButton.GetComponent<PassiveButton>();
SetupSearchButton( SetupSearchButton(
SearchIconButton, searchIconButton.GetComponent<PassiveButton>(),
"SearchIconButton", "SearchIconButton",
ClearSearchText, ClearSearchText,
MiraAssets.SearchIconIdleSprite, MiraAssets.SearchIconIdleSprite,
@@ -476,7 +465,7 @@ public static class RoleGuidePatches
var searchBox = Object.Instantiate( var searchBox = Object.Instantiate(
instance.TabButtons[2].gameObject, instance.TabButtons[2].gameObject,
SearchComponentContainer.transform); searchComponentContainer.transform);
var searchButton = searchBox.GetComponent<MatchInfoGuideTabButton>(); var searchButton = searchBox.GetComponent<MatchInfoGuideTabButton>();
var tmpText = searchButton.transform.GetChild(0).GetComponent<TextMeshPro>(); var tmpText = searchButton.transform.GetChild(0).GetComponent<TextMeshPro>();
tmpText.GetComponent<TextTranslatorTMP>().Destroy(); tmpText.GetComponent<TextTranslatorTMP>().Destroy();
@@ -621,26 +610,26 @@ public static class RoleGuidePatches
modifiersButton.OnClick.AddListener((Action)(() => OpenModifiersTab())); modifiersButton.OnClick.AddListener((Action)(() => OpenModifiersTab()));
instance.TabButtons.Add(modifiersButton); instance.TabButtons.Add(modifiersButton);
OrderSortingTmp = Object.Instantiate( var orderSortingTmp = Object.Instantiate(
_titleText, _titleText,
sortingOrderButton.transform); sortingOrderButton.transform);
OrderSortingTmp.text = MiraLocaleManager.Get("MiraApi.Wiki.OrderLabel"); orderSortingTmp.text = MiraLocaleManager.Get("MiraApi.Wiki.OrderLabel");
OrderSortingTmp.fontSize = OrderSortingTmp.fontSizeMax = 3f; orderSortingTmp.fontSize = orderSortingTmp.fontSizeMax = 3f;
OrderSortingTmp.alignment = TextAlignmentOptions.Center; orderSortingTmp.alignment = TextAlignmentOptions.Center;
OrderSortingTmp.horizontalAlignment = HorizontalAlignmentOptions.Center; orderSortingTmp.horizontalAlignment = HorizontalAlignmentOptions.Center;
OrderSortingTmp.transform.localPosition = new Vector3(-0.65f, 0.4f, 0); orderSortingTmp.transform.localPosition = new Vector3(-0.65f, 0.4f, 0);
GroupSortingTmp = Object.Instantiate( var groupSortingTmp = Object.Instantiate(
OrderSortingTmp, orderSortingTmp,
sortingGroupButton.transform); sortingGroupButton.transform);
OrderSortingTmp.text = MiraLocaleManager.Get("MiraApi.Wiki.GroupingLabel"); orderSortingTmp.text = MiraLocaleManager.Get("MiraApi.Wiki.GroupingLabel");
GroupSortingTmp.transform.localPosition = new Vector3(-0.65f, 0.4f, 0); groupSortingTmp.transform.localPosition = new Vector3(-0.65f, 0.4f, 0);
FilterSortingTmp = Object.Instantiate( var filterSortingTmp = Object.Instantiate(
OrderSortingTmp, orderSortingTmp,
sortingFilterButton.transform); sortingFilterButton.transform);
FilterSortingTmp.text = MiraLocaleManager.Get("MiraApi.Wiki.FilterLabel"); filterSortingTmp.text = MiraLocaleManager.Get("MiraApi.Wiki.FilterLabel");
FilterSortingTmp.transform.localPosition = new Vector3(-0.65f, 0.4f, 0); filterSortingTmp.transform.localPosition = new Vector3(-0.65f, 0.4f, 0);
playerButton.transform.localPosition = new Vector3(-3.6f, 0.656f, -0.2f); playerButton.transform.localPosition = new Vector3(-3.6f, 0.656f, -0.2f);
settingButton.transform.localPosition = new Vector3(-3.6f, 0.056f, -0.2f); settingButton.transform.localPosition = new Vector3(-3.6f, 0.056f, -0.2f);
@@ -731,11 +720,17 @@ public static class RoleGuidePatches
} }
} }
public static void OpenModifiersTab() => OpenTab(ModifiersTabIndex); public static void OpenModifiersTab()
{
OpenTab(ModifiersTabIndex);
}
public static void OpenRolesTab() => OpenTab(RolesTabIndex); public static void OpenRolesTab()
{
OpenTab(RolesTabIndex);
}
public sealed class DetailedPanel(string title, string category, string modId, RoleBehaviour? role, GameModifier? modifier) private sealed class DetailedPanel(string title, string category, string modId, RoleBehaviour? role, GameModifier? modifier)
{ {
public MatchInfoRolePanel? Panel { get; set; } public MatchInfoRolePanel? Panel { get; set; }
public string Title { get; } = title; public string Title { get; } = title;
@@ -803,14 +798,7 @@ public static class RoleGuidePatches
private static IEnumerator CoPopulate(float delay) private static IEnumerator CoPopulate(float delay)
{ {
if (delay > 0f) yield return delay > 0f ? new WaitForSeconds(delay) : null;
{
yield return new WaitForSeconds(delay);
}
else
{
yield return null;
}
if (!_guide) if (!_guide)
{ {
@@ -1048,14 +1036,8 @@ public static class RoleGuidePatches
public static void SwitchFilter() public static void SwitchFilter()
{ {
var stepUp = (SortingFilter)((int)_sortFilter + 1); var stepUp = (SortingFilter)((int)_sortFilter + 1);
if (Enum.IsDefined(stepUp))
{ _sortFilter = Enum.IsDefined(stepUp) ? stepUp : SortingFilter.EnabledOnly;
_sortFilter = stepUp;
}
else
{
_sortFilter = SortingFilter.EnabledOnly;
}
MiraApiPlugin.WikiSortingFilter.Value = _sortFilter; MiraApiPlugin.WikiSortingFilter.Value = _sortFilter;
@@ -1094,14 +1076,8 @@ public static class RoleGuidePatches
public static void SwitchMethod() public static void SwitchMethod()
{ {
var stepUp = (SortingMethod)((int)_sortMethod + 1); var stepUp = (SortingMethod)((int)_sortMethod + 1);
if (Enum.IsDefined(stepUp))
{ _sortMethod = Enum.IsDefined(stepUp) ? stepUp : SortingMethod.Alphabetical;
_sortMethod = stepUp;
}
else
{
_sortMethod = SortingMethod.Alphabetical;
}
MiraApiPlugin.WikiSortingMethod.Value = _sortMethod; MiraApiPlugin.WikiSortingMethod.Value = _sortMethod;
@@ -1288,7 +1264,7 @@ public static class RoleGuidePatches
} }
_advancedInfoTabScroller?.gameObject.SetActive(false); _advancedInfoTabScroller?.gameObject.SetActive(false);
SearchComponentContainer?.SetActive(true); searchComponentContainer?.SetActive(true);
UpdateSpinner(); UpdateSpinner();
} }
@@ -1341,9 +1317,9 @@ public static class RoleGuidePatches
_currentAdvancedTabObject.Destroy(); _currentAdvancedTabObject.Destroy();
} }
if (SearchComponentContainer) if (searchComponentContainer)
{ {
SearchComponentContainer.SetActive(false); searchComponentContainer.SetActive(false);
} }
if (_advancedInfoTabScroller == null) if (_advancedInfoTabScroller == null)
@@ -1543,20 +1519,20 @@ public static class RoleGuidePatches
} }
} }
public enum SortingGroups internal enum SortingGroups
{ {
Ungrouped, Ungrouped,
Faction, Faction,
AmountChance, AmountChance,
} }
public enum SortingMethod internal enum SortingMethod
{ {
Alphabetical, Alphabetical,
AlphabeticalDescending, AlphabeticalDescending,
} }
public enum SortingFilter internal enum SortingFilter
{ {
EnabledOnly, EnabledOnly,
DisabledOnly, DisabledOnly,
+2 -2
View File
@@ -39,10 +39,10 @@ public static class RoleBehaviourStubs
} }
/// <summary> /// <summary>
/// Stub method for <see cref="RoleBehaviour.AppendTaskHint(StringBuilder)"/>. /// Stub method for <see cref="RoleBehaviour.AppendTaskHint(Il2CppSystem.Text.StringBuilder)"/>.
/// </summary> /// </summary>
/// <param name="instance">The <see cref="RoleBehaviour"/> object.</param> /// <param name="instance">The <see cref="RoleBehaviour"/> object.</param>
/// <param name="taskStringBuilder">The <see cref="StringBuilder"/> to append the task hint to.</param> /// <param name="taskStringBuilder">The <see cref="Il2CppSystem.Text.StringBuilder"/> to append the task hint to.</param>
[HarmonyReversePatch] [HarmonyReversePatch]
[HarmonyPatch(typeof(RoleBehaviour), nameof(RoleBehaviour.AppendTaskHint), typeof(Il2CppSystem.Text.StringBuilder))] [HarmonyPatch(typeof(RoleBehaviour), nameof(RoleBehaviour.AppendTaskHint), typeof(Il2CppSystem.Text.StringBuilder))]
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
+1
View File
@@ -16,6 +16,7 @@ namespace MiraAPI.Presets;
[RegisterInIl2Cpp] [RegisterInIl2Cpp]
[SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Unity convention.")] [SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Unity convention.")]
[SuppressMessage("Design", "CA1050:Declare types in namespaces", Justification = "Unity script.")]
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member (Justification: Unity fields; ignore.) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member (Justification: Unity fields; ignore.)
public class SavePresetPopup(nint cppPtr) : Minigame(cppPtr) public class SavePresetPopup(nint cppPtr) : Minigame(cppPtr)
{ {
+8 -1
View File
@@ -345,7 +345,14 @@ public interface ICustomRole : IOptionable
/// Gets the list of abilities or other similar information to display below the text of a role's wiki page. /// Gets the list of abilities or other similar information to display below the text of a role's wiki page.
/// </summary> /// </summary>
[HideFromIl2Cpp] [HideFromIl2Cpp]
public List<AdvancedWikiAbilityDescription> WikiAbilities => []; List<AdvancedWikiAbilityDescription> WikiAbilities => [];
} }
/// <summary>
/// A data holder of an ability's wiki entry.
/// </summary>
/// <param name="Name">The name of the ability.</param>
/// <param name="AbilityType">The type of the ability.</param>
/// <param name="Description">The description of the ability.</param>
/// <param name="Icon">The icon sprite of the ability.</param>
public record struct AdvancedWikiAbilityDescription(string Name, string AbilityType, string Description, LoadableAsset<Sprite> Icon); public record struct AdvancedWikiAbilityDescription(string Name, string AbilityType, string Description, LoadableAsset<Sprite> Icon);
-2
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@@ -162,7 +161,6 @@ public static class MiraLocaleManager
/// <param name="key">The string id to find.</param> /// <param name="key">The string id to find.</param>
/// <param name="fallback">Fallback string to use if no translation is found.</param> /// <param name="fallback">Fallback string to use if no translation is found.</param>
/// <returns>A <see cref="string"/> based on the key provided.</returns> /// <returns>A <see cref="string"/> based on the key provided.</returns>
[SuppressMessage("Style", "IDE0046:Convert to conditional expression", Justification = "Warning cascades into forcing the entire tree to be ternary operators.")]
public static string Get(MiraLanguage language, string key, string fallback = "") public static string Get(MiraLanguage language, string key, string fallback = "")
{ {
if (Locale.TryGetValue(language, out var translations) && if (Locale.TryGetValue(language, out var translations) &&
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
namespace MiraAPI.Utilities; namespace MiraAPI.Utilities;
@@ -9,7 +8,6 @@ internal sealed class ControllableComparer<T>(T[] forcedToBottom, T[] forcedToTo
where T : IComparable where T : IComparable
{ {
/// <inheritdoc/> /// <inheritdoc/>
[SuppressMessage("Style", "IDE0046:Convert to conditional expression", Justification = "Warning cascades into forcing the entire tree to be ternary operators.")]
public int Compare(T? x, T? y) public int Compare(T? x, T? y)
{ {
if ((forcedToBottom.Contains(x) && forcedToBottom.Contains(y)) || (forcedToTop.Contains(x) && forcedToTop.Contains(y))) if ((forcedToBottom.Contains(x) && forcedToBottom.Contains(y)) || (forcedToTop.Contains(x) && forcedToTop.Contains(y)))
+12 -1
View File
@@ -32,6 +32,11 @@ public static class Helpers
{ {
private static readonly Regex TrailingZeroRegex = new(@"\.0+(?!\d)", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100)); private static readonly Regex TrailingZeroRegex = new(@"\.0+(?!\d)", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100));
/// <summary>
/// Gets all of the options stored within the provided type.
/// </summary>
/// <param name="classType">The type to get the options of.</param>
/// <returns>A readonly list of options from the provided type.</returns>
public static ReadOnlyCollection<IModdedOption>? GetModdedOptionsForType(Type classType) public static ReadOnlyCollection<IModdedOption>? GetModdedOptionsForType(Type classType)
{ {
var group = ModdedOptionsManager.Groups.FirstOrDefault(x => x.OptionableType == classType); var group = ModdedOptionsManager.Groups.FirstOrDefault(x => x.OptionableType == classType);
@@ -39,6 +44,11 @@ public static class Helpers
return group?.Children; return group?.Children;
} }
/// <summary>
/// Gets the option text of the provided type.
/// </summary>
/// <param name="classType">The type to get the text for.</param>
/// <returns>The options text of the provided type.</returns>
public static string GetOptionsText(Type classType) public static string GetOptionsText(Type classType)
{ {
var group = ModdedOptionsManager.Groups.FirstOrDefault(x => x.OptionableType == classType); var group = ModdedOptionsManager.Groups.FirstOrDefault(x => x.OptionableType == classType);
@@ -836,7 +846,7 @@ public static class Helpers
obj.transform.SetParent(parent.Inner.transform); obj.transform.SetParent(parent.Inner.transform);
obj.transform.localPosition = new Vector3(0f, 0.5f, 0f); obj.transform.localPosition = new Vector3(0f, 0.5f, 0f);
var scrollHeight = variableTextSizing var scrollHeight = variableTextSizing
? (desc.textBounds.size.y - 2.5f) + maxTextSize + 0.475f ? desc.textBounds.size.y - 2.5f + maxTextSize + 0.475f
: desc.textBounds.size.y - 2.5f + Mathf.Ceil(num / 2f) * 1.45f; : desc.textBounds.size.y - 2.5f + Mathf.Ceil(num / 2f) * 1.45f;
parent.SetYBoundsMax(Mathf.Clamp(scrollHeight, 0f, 999f)); parent.SetYBoundsMax(Mathf.Clamp(scrollHeight, 0f, 999f));
return obj; return obj;
@@ -857,6 +867,7 @@ public static class Helpers
panel.roleDescription.fontSizeMin = 1.5f; panel.roleDescription.fontSizeMin = 1.5f;
panel.roleDescription.ForceMeshUpdate(); panel.roleDescription.ForceMeshUpdate();
} }
panel.roleIcon.sprite = ability.Icon.LoadAsset(); panel.roleIcon.sprite = ability.Icon.LoadAsset();
panel.roleIcon.SetSizeLimit(0.13f); panel.roleIcon.SetSizeLimit(0.13f);