mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
resolve new warnings
This commit is contained in:
6 files changed
+54
-34
No files matched your search
@@ -83,3 +83,6 @@ dotnet_diagnostic.SA1407.severity = none
|
||||
|
||||
# SA1133: Each attribute should be placed in its own set of square brackets
|
||||
dotnet_diagnostic.SA1133.severity = none
|
||||
|
||||
# IDE0001: Simplify Names
|
||||
dotnet_diagnostic.IDE0001.severity = warning
|
||||
@@ -1,9 +1,9 @@
|
||||
using MiraAPI.Patches.Stubs;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using MiraAPI.Patches.Stubs;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
@@ -16,12 +16,13 @@ namespace MiraAPI.Hud;
|
||||
[SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Unity convention.")]
|
||||
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")]
|
||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Read above.")]
|
||||
public abstract class CustomMultiSelectMenu<TEntry> : CustomPhoneMenu<CustomMultiSelectMenu<TEntry>.MenuEntry> where TEntry : class
|
||||
public abstract class CustomMultiSelectMenu<TEntry> : CustomPhoneMenu<CustomMultiSelectMenu<TEntry>.MenuEntry>
|
||||
where TEntry : class
|
||||
{
|
||||
private readonly List<MenuEntry> selectedEntries = [];
|
||||
private int totalSelections;
|
||||
private bool shouldConfirm;
|
||||
private bool canRepeat;
|
||||
private readonly List<MenuEntry> selectedEntries = [];
|
||||
|
||||
private LoadableAsset<Sprite>? hoverSelectSprite;
|
||||
private LoadableAsset<Sprite>? hoverDeselectSprite;
|
||||
@@ -62,8 +63,8 @@ public abstract class CustomMultiSelectMenu<TEntry> : CustomPhoneMenu<CustomMult
|
||||
LoadableAsset<Sprite>? hoverDeselectSprite = null,
|
||||
Color? hoverDeselectColor = null,
|
||||
PanelButtonOnMouse? onMouseOut = null,
|
||||
PanelButtonOnMouse? onMouseOver = null
|
||||
) where TMenu : CustomMultiSelectMenu<TEntry>, new()
|
||||
PanelButtonOnMouse? onMouseOver = null)
|
||||
where TMenu : CustomMultiSelectMenu<TEntry>, new()
|
||||
{
|
||||
TMenu customMenu = Create<TMenu>(onMouseOut, onMouseOver);
|
||||
|
||||
@@ -118,7 +119,7 @@ public abstract class CustomMultiSelectMenu<TEntry> : CustomPhoneMenu<CustomMult
|
||||
}));
|
||||
|
||||
DebugAnalytics.Instance.Analytics.MinigameOpened(PlayerControl.LocalPlayer.Data, Component.TaskType);
|
||||
var list2 = new Il2CppSystem.Collections.Generic.List<UiElement>();
|
||||
var list2 = new CppCollections.List<UiElement>();
|
||||
RegisterPanels(
|
||||
entries,
|
||||
(shapeshifterPanel, i, entry) =>
|
||||
@@ -160,23 +161,28 @@ public abstract class CustomMultiSelectMenu<TEntry> : CustomPhoneMenu<CustomMult
|
||||
{
|
||||
MenuEntry menuEntry = MenuEntries.First(e => e.Entry == entry);
|
||||
|
||||
if (!canRepeat && selectedEntries.Remove(menuEntry)) // Unselect previous choice
|
||||
// Unselect previous choice
|
||||
if (!canRepeat && selectedEntries.Remove(menuEntry))
|
||||
{
|
||||
// TODO: if confirm button is enabled, disable it
|
||||
SetNameplateAppearance(menuEntry, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedEntries.Count >= totalSelections) // Do not go past total selections.
|
||||
// Do not go past total selections
|
||||
if (selectedEntries.Count >= totalSelections)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
selectedEntries.Add(menuEntry);
|
||||
if (selectedEntries.Count <= totalSelections) // Add choice to list of selections
|
||||
|
||||
// Add choice to list of selections
|
||||
if (selectedEntries.Count <= totalSelections)
|
||||
{
|
||||
SetNameplateAppearance(menuEntry, true);
|
||||
}
|
||||
|
||||
if (selectedEntries.Count < totalSelections)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
using MiraAPI.Patches.Stubs;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using MiraAPI.Patches.Stubs;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
using CppCollections = Il2CppSystem.Collections.Generic;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace MiraAPI.Hud;
|
||||
@@ -24,6 +23,8 @@ namespace MiraAPI.Hud;
|
||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Read above.")]
|
||||
public abstract class CustomPaginableMenu : CustomPhoneMenu<CustomPaginableMenu.MenuEntry>
|
||||
{
|
||||
private const int ItemsPerPage = 15;
|
||||
|
||||
/// <summary>
|
||||
/// Menu Entry used for when multiple pages are needed.
|
||||
/// </summary>
|
||||
@@ -52,8 +53,6 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu<CustomPaginableMenu.
|
||||
private string searchText = string.Empty;
|
||||
private TextMeshPro? noResultsText;
|
||||
|
||||
private const int ItemsPerPage = 15;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <typeparamref name="TMenu"/>.
|
||||
/// </summary>
|
||||
@@ -61,7 +60,8 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu<CustomPaginableMenu.
|
||||
/// <param name="onMouseOut">Function that can optionally be run when the mouse is moved outside a menu panel.</param>
|
||||
/// <param name="onMouseOver">Function that can optionally be run when the mouse is moved over a menu panel.</param>
|
||||
/// <returns>New <typeparamref name="TMenu"/> object.</returns>
|
||||
protected static new TMenu Create<TMenu>(PanelButtonOnMouse? onMouseOut = null, PanelButtonOnMouse? onMouseOver = null) where TMenu : CustomPaginableMenu, new()
|
||||
protected static new TMenu Create<TMenu>(PanelButtonOnMouse? onMouseOut = null, PanelButtonOnMouse? onMouseOver = null)
|
||||
where TMenu : CustomPaginableMenu, new()
|
||||
{
|
||||
TMenu customMenu = CustomPhoneMenu.Create<TMenu>(onMouseOut, onMouseOver);
|
||||
|
||||
@@ -99,6 +99,7 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu<CustomPaginableMenu.
|
||||
: text.Trim().ToLowerInvariant();
|
||||
}
|
||||
|
||||
[SuppressMessage("Style", "IDE0046:Convert to conditional expression", Justification = "Creates a rather large ternary operation.")]
|
||||
private List<MenuEntry> GetFilteredEntries()
|
||||
{
|
||||
var query = NormalizeForSearch(searchText);
|
||||
@@ -252,6 +253,7 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu<CustomPaginableMenu.
|
||||
{
|
||||
searchFocusButton.ClickSound = wikiClickSound;
|
||||
}
|
||||
|
||||
searchFocusButton.OnClick.RemoveAllListeners();
|
||||
searchFocusButton.OnClick.AddListener((UnityAction)(Action)(() =>
|
||||
{
|
||||
@@ -321,6 +323,7 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu<CustomPaginableMenu.
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (wikiClickSound != null)
|
||||
{
|
||||
clearSearchButton.ClickSound = wikiClickSound;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using AmongUs.GameOptions;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using AmongUs.GameOptions;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using Object = UnityEngine.Object;
|
||||
@@ -68,7 +68,8 @@ public interface ICustomMenu
|
||||
/// Must reference the member of the <see cref="CustomPhoneMenu"/> superclass that is being hidden by this one to work.
|
||||
/// </summary>
|
||||
/// <typeparam name="TMenu">The type of menu entry.</typeparam>
|
||||
public interface ICustomMenu<TMenu> : ICustomMenu where TMenu : IMenuEntry
|
||||
public interface ICustomMenu<TMenu> : ICustomMenu
|
||||
where TMenu : IMenuEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all registered <typeparamref name="TMenu"/>s.
|
||||
@@ -133,9 +134,11 @@ public abstract class CustomPhoneMenu : ICustomMenu
|
||||
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member (Justification: Unity convention.)
|
||||
#pragma warning disable S1104 // Fields should not have public accessibility (Justification: Read above.)
|
||||
#pragma warning disable SA1300 // Element should begin with upper-case letter (Justification: Read above.)
|
||||
public Transform transform => Component.transform;
|
||||
public GameObject gameObject => Component.gameObject;
|
||||
public string name => Component.name;
|
||||
#pragma warning restore SA1300 // Element should begin with upper-case letter
|
||||
|
||||
public float xStart = -0.8f;
|
||||
public float yStart = 2.15f;
|
||||
@@ -176,7 +179,8 @@ public abstract class CustomPhoneMenu : ICustomMenu
|
||||
/// <param name="onMouseOut">Function that can optionally be run when the mouse is moved outside a menu panel.</param>
|
||||
/// <param name="onMouseOver">Function that can optionally be run when the mouse is moved over a menu panel.</param>
|
||||
/// <returns>New <typeparamref name="TMenu"/> object.</returns>
|
||||
protected static TMenu Create<TMenu>(PanelButtonOnMouse? onMouseOut = null, PanelButtonOnMouse? onMouseOver = null) where TMenu : CustomPhoneMenu, new()
|
||||
protected static TMenu Create<TMenu>(PanelButtonOnMouse? onMouseOut = null, PanelButtonOnMouse? onMouseOver = null)
|
||||
where TMenu : CustomPhoneMenu, new()
|
||||
{
|
||||
var shapeShifterRole = RoleManager.Instance.GetRole(RoleTypes.Shapeshifter);
|
||||
|
||||
@@ -253,15 +257,14 @@ public abstract class CustomPhoneMenu : ICustomMenu
|
||||
{
|
||||
button.OnMouseOver.RemoveAllListeners();
|
||||
button.OnMouseOver = new UnityEvent();
|
||||
button.OnMouseOver.AddListener((UnityAction)
|
||||
(() => onMouseOverAction(highlight, icon, IsEntrySelected(menuEntry))));
|
||||
button.OnMouseOver.AddListener((UnityAction)(() => onMouseOverAction(highlight, icon, IsEntrySelected(menuEntry))));
|
||||
}
|
||||
|
||||
if (onMouseOutAction != null)
|
||||
{
|
||||
button.OnMouseOut.RemoveAllListeners();
|
||||
button.OnMouseOut = new UnityEvent();
|
||||
button.OnMouseOut.AddListener((UnityAction)
|
||||
(() => onMouseOutAction(highlight, icon, IsEntrySelected(menuEntry))));
|
||||
button.OnMouseOut.AddListener((UnityAction)(() => onMouseOutAction(highlight, icon, IsEntrySelected(menuEntry))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,11 +313,13 @@ public abstract class CustomPhoneMenu : ICustomMenu
|
||||
{
|
||||
icon.sprite = sprite.LoadAsset();
|
||||
}
|
||||
|
||||
var button = nameplate.GetComponent<ButtonRolloverHandler>();
|
||||
if (overColor is { } oColor)
|
||||
{
|
||||
button.OverColor = oColor;
|
||||
}
|
||||
|
||||
if (unselectedColor is { } uColor)
|
||||
{
|
||||
button.UnselectedColor = uColor;
|
||||
@@ -324,7 +329,8 @@ public abstract class CustomPhoneMenu : ICustomMenu
|
||||
|
||||
/// <inheritdoc cref="CustomPhoneMenu"/>
|
||||
/// <typeparam name="TMenu">The type of menu entries.</typeparam>
|
||||
public abstract class CustomPhoneMenu<TMenu> : CustomPhoneMenu, ICustomMenu<TMenu> where TMenu : IMenuEntry
|
||||
public abstract class CustomPhoneMenu<TMenu> : CustomPhoneMenu, ICustomMenu<TMenu>
|
||||
where TMenu : IMenuEntry
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public new List<TMenu> MenuEntries
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
using HarmonyLib;
|
||||
using GameModesEnum = AmongUs.GameOptions.GameModes;
|
||||
|
||||
namespace MiraAPI.Patches.GameModes;
|
||||
|
||||
[HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.SetGameMode))]
|
||||
internal static class CreateOptionsPatch
|
||||
{
|
||||
public static bool Prefix(CreateOptionsPicker __instance, AmongUs.GameOptions.GameModes mode)
|
||||
public static bool Prefix(CreateOptionsPicker __instance, GameModesEnum mode)
|
||||
{
|
||||
if (mode <= AmongUs.GameOptions.GameModes.SeekFools)
|
||||
if (mode <= GameModesEnum.SeekFools)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -383,6 +383,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
private void UpdateUi()
|
||||
{
|
||||
var pageText = "MiraApi.Page".Translate();
|
||||
|
||||
// Update mod text
|
||||
if (CurrentModIdx == 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user