mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-11-19 23:17:12 +00:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa0c251662 | ||
|
|
90be4ef253 | ||
|
|
3bca3faafb | ||
|
|
1947c536d3 | ||
|
|
28b276b9e2 | ||
|
|
e0e55e065e | ||
|
|
89e8870e35 | ||
|
|
c627c03590 | ||
|
|
29e9f9c8b5 | ||
|
|
af255c3e64 | ||
|
|
7c09dbdaaa | ||
|
|
0596278b78 | ||
|
|
13864b8fd9 | ||
|
|
f8c9045517 | ||
|
|
7632e543c8 | ||
|
|
6deaae350e | ||
|
|
5f6ac17e52 | ||
|
|
16e2c25c2d | ||
|
|
0e02a02156 |
No files matched your search
@@ -105,5 +105,11 @@ dotnet_diagnostic.S1244.severity = none
|
|||||||
# S2325: Methods and properties that don't access instance data should be static
|
# S2325: Methods and properties that don't access instance data should be static
|
||||||
dotnet_diagnostic.S2325.severity = none
|
dotnet_diagnostic.S2325.severity = none
|
||||||
|
|
||||||
|
# CA1710: Identifiers should have correct suffix
|
||||||
|
dotnet_diagnostic.CA1710.severity = silent
|
||||||
|
|
||||||
|
# CA1010: Generic interface should also be implemented
|
||||||
|
dotnet_diagnostic.CA1010.severity = silent
|
||||||
|
|
||||||
# IDE0005: Using directive is unnecessary.
|
# IDE0005: Using directive is unnecessary.
|
||||||
dotnet_diagnostic.IDE0005.severity = warning
|
dotnet_diagnostic.IDE0005.severity = warning
|
||||||
@@ -15,7 +15,7 @@ namespace MiraAPI.GameOptions.Attributes;
|
|||||||
public class ModdedEnumOptionListAttribute(string title, Type enumType, string[]? values = null)
|
public class ModdedEnumOptionListAttribute(string title, Type enumType, string[]? values = null)
|
||||||
: ModdedOptionListAttribute(title)
|
: ModdedOptionListAttribute(title)
|
||||||
{
|
{
|
||||||
internal override IModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
internal override IBaseModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
||||||
{
|
{
|
||||||
var optList = new ModdedOptionList<ModdedEnumOption>(
|
var optList = new ModdedOptionList<ModdedEnumOption>(
|
||||||
value.Count, idx => new(GetFormattedTitle(idx), (int)(value[idx] ?? 0), enumType, values));
|
value.Count, idx => new(GetFormattedTitle(idx), (int)(value[idx] ?? 0), enumType, values));
|
||||||
@@ -25,14 +25,14 @@ public class ModdedEnumOptionListAttribute(string title, Type enumType, string[]
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void SetValue(int idx, object value)
|
public override void SetValue(int idx, object value)
|
||||||
{
|
{
|
||||||
var opt = HolderOptionList?[idx] as ModdedEnumOption;
|
var opt = HolderOptionList?.ElementAt(idx) as ModdedEnumOption;
|
||||||
opt?.SetValue((int)value);
|
opt?.SetValue((int)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override object GetValue(int idx)
|
public override object GetValue(int idx)
|
||||||
{
|
{
|
||||||
return HolderOptionList?[idx] is ModdedEnumOption opt
|
return HolderOptionList?.ElementAt(idx) is ModdedEnumOption opt
|
||||||
? Enum.ToObject(enumType, opt.Value)
|
? Enum.ToObject(enumType, opt.Value)
|
||||||
: throw new InvalidOperationException($"HolderOption for option \"{GetFormattedTitle(idx)}\" with EnumType {enumType.FullName} is not a ModdedEnumOption");
|
: throw new InvalidOperationException($"HolderOption for option \"{GetFormattedTitle(idx)}\" with EnumType {enumType.FullName} is not a ModdedEnumOption");
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ public class ModdedEnumOptionListAttribute<T>(string title, string[]? values = n
|
|||||||
: ModdedOptionListAttribute(title)
|
: ModdedOptionListAttribute(title)
|
||||||
where T : struct, Enum
|
where T : struct, Enum
|
||||||
{
|
{
|
||||||
internal override IModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
internal override IBaseModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
||||||
{
|
{
|
||||||
var optList = new ModdedOptionList<ModdedEnumOption<T>>(
|
var optList = new ModdedOptionList<ModdedEnumOption<T>>(
|
||||||
value.Count, idx => new(GetFormattedTitle(idx), (T)(value[idx] ?? 0), values));
|
value.Count, idx => new(GetFormattedTitle(idx), (T)(value[idx] ?? 0), values));
|
||||||
@@ -59,14 +59,14 @@ public class ModdedEnumOptionListAttribute<T>(string title, string[]? values = n
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void SetValue(int idx, object value)
|
public override void SetValue(int idx, object value)
|
||||||
{
|
{
|
||||||
var opt = HolderOptionList?[idx] as ModdedEnumOption<T>;
|
var opt = HolderOptionList?.ElementAt(idx) as ModdedEnumOption<T>;
|
||||||
opt?.SetValue((T)value);
|
opt?.SetValue((T)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override object GetValue(int idx)
|
public override object GetValue(int idx)
|
||||||
{
|
{
|
||||||
return HolderOptionList?[idx] is ModdedEnumOption<T> opt
|
return HolderOptionList?.ElementAt(idx) is ModdedEnumOption<T> opt
|
||||||
? opt.Value
|
? opt.Value
|
||||||
: throw new InvalidOperationException($"HolderOption for option \"{GetFormattedTitle(idx)}\" with EnumType {typeof(T).FullName} is not a ModdedEnumOption<{typeof(T).FullName}>");
|
: throw new InvalidOperationException($"HolderOption for option \"{GetFormattedTitle(idx)}\" with EnumType {typeof(T).FullName} is not a ModdedEnumOption<{typeof(T).FullName}>");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ModdedNumberOptionListAttribute(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override IModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
internal override IBaseModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
||||||
{
|
{
|
||||||
return new ModdedOptionList<ModdedNumberOption>(value.Count, idx =>
|
return new ModdedOptionList<ModdedNumberOption>(value.Count, idx =>
|
||||||
{
|
{
|
||||||
@@ -81,7 +81,7 @@ public class ModdedNumberOptionListAttribute(
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void SetValue(int idx, object value)
|
public override void SetValue(int idx, object value)
|
||||||
{
|
{
|
||||||
if (HolderOptionList?[idx] is not ModdedNumberOption opt)
|
if (HolderOptionList?.ElementAt(idx) is not ModdedNumberOption opt)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var final = value switch
|
var final = value switch
|
||||||
@@ -95,7 +95,7 @@ public class ModdedNumberOptionListAttribute(
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override object GetValue(int idx)
|
public override object GetValue(int idx)
|
||||||
{
|
{
|
||||||
if (HolderOptionList?[idx] is not ModdedNumberOption opt)
|
if (HolderOptionList?.ElementAt(idx) is not ModdedNumberOption opt)
|
||||||
throw new InvalidOperationException($"HolderOption for option \"{GetFormattedTitle(idx)}\" is not a ModdedNumberOption");
|
throw new InvalidOperationException($"HolderOption for option \"{GetFormattedTitle(idx)}\" is not a ModdedNumberOption");
|
||||||
|
|
||||||
var value = opt.Value;
|
var value = opt.Value;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace MiraAPI.GameOptions.Attributes;
|
|||||||
[AttributeUsage(AttributeTargets.Property)]
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
public abstract class ModdedOptionListAttribute(string title) : PropertyOptionAttribute
|
public abstract class ModdedOptionListAttribute(string title) : PropertyOptionAttribute
|
||||||
{
|
{
|
||||||
internal IModdedOptionList? HolderOptionList { get; set; }
|
internal IBaseModdedOptionList? HolderOptionList { get; set; }
|
||||||
internal IList? Value { get; set; }
|
internal IList? Value { get; set; }
|
||||||
internal Type ValueType { get; set; }
|
internal Type ValueType { get; set; }
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public abstract class ModdedOptionListAttribute(string title) : PropertyOptionAt
|
|||||||
/// <returns>The value of the option as an object.</returns>
|
/// <returns>The value of the option as an object.</returns>
|
||||||
public abstract object GetValue(int idx);
|
public abstract object GetValue(int idx);
|
||||||
|
|
||||||
internal abstract IModdedOptionList? CreateOptionList(IList value, PropertyInfo property);
|
internal abstract IBaseModdedOptionList? CreateOptionList(IList value, PropertyInfo property);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="Title"/> formatted with the option's index.
|
/// Gets the <see cref="Title"/> formatted with the option's index.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class ModdedPlayerOptionListAttribute(
|
|||||||
bool allowNone = true)
|
bool allowNone = true)
|
||||||
: ModdedOptionListAttribute(title)
|
: ModdedOptionListAttribute(title)
|
||||||
{
|
{
|
||||||
internal override IModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
internal override IBaseModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
||||||
{
|
{
|
||||||
return new ModdedOptionList<ModdedPlayerOption>(value.Count, idx =>
|
return new ModdedOptionList<ModdedPlayerOption>(value.Count, idx =>
|
||||||
{
|
{
|
||||||
@@ -27,7 +27,7 @@ public class ModdedPlayerOptionListAttribute(
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void SetValue(int idx, object value)
|
public override void SetValue(int idx, object value)
|
||||||
{
|
{
|
||||||
if (HolderOptionList?[idx] is not ModdedPlayerOption opt)
|
if (HolderOptionList?.ElementAt(idx) is not ModdedPlayerOption opt)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var final = value switch
|
var final = value switch
|
||||||
@@ -41,7 +41,7 @@ public class ModdedPlayerOptionListAttribute(
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override object GetValue(int idx)
|
public override object GetValue(int idx)
|
||||||
{
|
{
|
||||||
if (HolderOptionList?[idx] is not ModdedPlayerOption opt)
|
if (HolderOptionList?.ElementAt(idx) is not ModdedPlayerOption opt)
|
||||||
throw new InvalidOperationException($"HolderOption for option \"{GetFormattedTitle(idx)}\" is not a ModdedPlayerOption");
|
throw new InvalidOperationException($"HolderOption for option \"{GetFormattedTitle(idx)}\" is not a ModdedPlayerOption");
|
||||||
|
|
||||||
if (ValueType == typeof(int))
|
if (ValueType == typeof(int))
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class ModdedStringOptionListAttribute(
|
|||||||
string[] values)
|
string[] values)
|
||||||
: ModdedOptionListAttribute(title)
|
: ModdedOptionListAttribute(title)
|
||||||
{
|
{
|
||||||
internal override IModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
internal override IBaseModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
||||||
{
|
{
|
||||||
return new ModdedOptionList<ModdedStringOption>(value.Count, idx =>
|
return new ModdedOptionList<ModdedStringOption>(value.Count, idx =>
|
||||||
{
|
{
|
||||||
@@ -28,14 +28,14 @@ public class ModdedStringOptionListAttribute(
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void SetValue(int idx, object value)
|
public override void SetValue(int idx, object value)
|
||||||
{
|
{
|
||||||
var opt = HolderOptionList?[idx] as ModdedStringOption;
|
var opt = HolderOptionList?.ElementAt(idx) as ModdedStringOption;
|
||||||
opt?.SetValue((string)value);
|
opt?.SetValue((string)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override object GetValue(int idx)
|
public override object GetValue(int idx)
|
||||||
{
|
{
|
||||||
return HolderOptionList?[idx] is ModdedStringOption opt
|
return HolderOptionList?.ElementAt(idx) is ModdedStringOption opt
|
||||||
? opt.Value
|
? opt.Value
|
||||||
: throw new InvalidOperationException($"HolderOption for option \"{GetFormattedTitle(idx)}\" is not a ModdedStringOption");
|
: throw new InvalidOperationException($"HolderOption for option \"{GetFormattedTitle(idx)}\" is not a ModdedStringOption");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class ModdedToggleOptionListAttribute(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override IModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
internal override IBaseModdedOptionList CreateOptionList(IList value, PropertyInfo property)
|
||||||
{
|
{
|
||||||
var optList = new ModdedOptionList<ModdedToggleOption>(
|
var optList = new ModdedOptionList<ModdedToggleOption>(
|
||||||
value.Count, idx => new(GetFormattedTitle(idx), (bool)(value[idx] ?? false), on, off));
|
value.Count, idx => new(GetFormattedTitle(idx), (bool)(value[idx] ?? false), on, off));
|
||||||
@@ -37,14 +37,14 @@ public class ModdedToggleOptionListAttribute(
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void SetValue(int idx, object value)
|
public override void SetValue(int idx, object value)
|
||||||
{
|
{
|
||||||
var opt = HolderOptionList?[idx] as ModdedToggleOption;
|
var opt = HolderOptionList?.ElementAt(idx) as ModdedToggleOption;
|
||||||
opt?.SetValue((bool)value);
|
opt?.SetValue((bool)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override object GetValue(int idx)
|
public override object GetValue(int idx)
|
||||||
{
|
{
|
||||||
return HolderOptionList?[idx] is ModdedToggleOption opt
|
return HolderOptionList?.ElementAt(idx) is ModdedToggleOption opt
|
||||||
? opt.Value
|
? opt.Value
|
||||||
: throw new InvalidOperationException($"Holder option for {GetFormattedTitle(idx)} is not a ModdedToggleOption.");
|
: throw new InvalidOperationException($"Holder option for {GetFormattedTitle(idx)} is not a ModdedToggleOption.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using MiraAPI.Networking;
|
using MiraAPI.Networking;
|
||||||
@@ -143,9 +144,11 @@ public interface IModdedOption
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface for list of modded options.
|
/// Base interface for list of modded options.
|
||||||
|
/// <para/>
|
||||||
|
/// Do not implement directly, implement <see cref="IModdedOptionList"/> or <see cref="IModdedOptionList{T}"/> instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IModdedOptionList : IReadOnlyList<IModdedOption>
|
public interface IBaseModdedOptionList : IEnumerable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the function to name the keys of the individual options in the configuration file.
|
/// Gets the function to name the keys of the individual options in the configuration file.
|
||||||
@@ -153,18 +156,34 @@ public interface IModdedOptionList : IReadOnlyList<IModdedOption>
|
|||||||
/// Return <see langword="null"/> to use the default of the property's name with its index appended.
|
/// Return <see langword="null"/> to use the default of the property's name with its index appended.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Func<int, string>? ConfigName { get; init; }
|
Func<int, string>? ConfigName { get; init; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IReadOnlyCollection{T}.Count"/>
|
||||||
|
int Count { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="System.Linq.Enumerable.ElementAt{TSource}(IEnumerable{TSource}, int)"/>
|
||||||
|
IModdedOption ElementAt(int index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for list of modded options.
|
||||||
|
/// </summary>
|
||||||
|
public interface IModdedOptionList : IBaseModdedOptionList, IReadOnlyList<IModdedOption>
|
||||||
|
{
|
||||||
|
IModdedOption IBaseModdedOptionList.ElementAt(int index)
|
||||||
|
{
|
||||||
|
return this[index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface for list of <typeparamref name="T"/> options.
|
/// Interface for list of <typeparamref name="T"/> options.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of <see cref="IModdedOption"/>.</typeparam>
|
/// <typeparam name="T">The type of <see cref="IModdedOption"/>.</typeparam>
|
||||||
public interface IModdedOptionList<out T> : IModdedOptionList
|
public interface IModdedOptionList<out T> : IBaseModdedOptionList, IReadOnlyList<T>
|
||||||
where T : IModdedOption
|
where T : IModdedOption
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="IReadOnlyList{T}.this[int]"/>
|
IModdedOption IBaseModdedOptionList.ElementAt(int index)
|
||||||
new T this[int index] { get; }
|
{
|
||||||
|
return this[index];
|
||||||
/// <inheritdoc cref="IEnumerable{T}.GetEnumerator"/>
|
}
|
||||||
new IEnumerator<T> GetEnumerator();
|
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ public static class ModdedOptionsManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property.GetValue(group) is not IModdedOptionList optionList)
|
if (property.GetValue(group) is not IBaseModdedOptionList optionList)
|
||||||
{
|
{
|
||||||
Error($"Failed to get option list for {property.Name}");
|
Error($"Failed to get option list for {property.Name}");
|
||||||
return;
|
return;
|
||||||
@@ -227,7 +227,7 @@ public static class ModdedOptionsManager
|
|||||||
|
|
||||||
for (var i = 0; i < optionList.Count; i++)
|
for (var i = 0; i < optionList.Count; i++)
|
||||||
{
|
{
|
||||||
RegisterOption(optionList[i], group, configName(i), pluginInfo);
|
RegisterOption(optionList.ElementAt(i), group, configName(i), pluginInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ public static class ModdedOptionsManager
|
|||||||
|
|
||||||
for (var i = 0; i < optionList.Count; i++)
|
for (var i = 0; i < optionList.Count; i++)
|
||||||
{
|
{
|
||||||
var option = optionList[i];
|
var option = optionList.ElementAt(i);
|
||||||
|
|
||||||
if (visibilityFactory != null)
|
if (visibilityFactory != null)
|
||||||
option.Visible = (Func<bool>)(visibilityFactory(i) ?? DelegateUtilities.AlwaysTrue);
|
option.Visible = (Func<bool>)(visibilityFactory(i) ?? DelegateUtilities.AlwaysTrue);
|
||||||
|
|||||||
@@ -62,13 +62,4 @@ public class ModdedOptionList<T> : IModdedOptionList<T>
|
|||||||
{
|
{
|
||||||
return Options.GetEnumerator();
|
return Options.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IEnumerable{T}.GetEnumerator"/>
|
|
||||||
IEnumerator<IModdedOption> IEnumerable<IModdedOption>.GetEnumerator()
|
|
||||||
{
|
|
||||||
return ((IEnumerable<IModdedOption>)Options).GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IReadOnlyList{T}.this"/>
|
|
||||||
IModdedOption IReadOnlyList<IModdedOption>.this[int index] => this[index];
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using MiraAPI.Patches.Stubs;
|
using MiraAPI.Patches.Stubs;
|
||||||
|
using MiraAPI.Utilities;
|
||||||
using MiraAPI.Utilities.Assets;
|
using MiraAPI.Utilities.Assets;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
@@ -106,6 +107,7 @@ public abstract class CustomMultiSelectMenu<TEntry> : CustomPhoneMenu<CustomMult
|
|||||||
protected void Begin(IEnumerable<TEntry> entries, Action<List<TEntry>?> onClick, int totalSelections, bool shouldConfirm, bool canRepeat = false)
|
protected void Begin(IEnumerable<TEntry> entries, Action<List<TEntry>?> onClick, int totalSelections, bool shouldConfirm, bool canRepeat = false)
|
||||||
{
|
{
|
||||||
MinigameStubs.Begin(Component, null);
|
MinigameStubs.Begin(Component, null);
|
||||||
|
MeetingVoteAreaVisibility.HideNameplates(Component);
|
||||||
|
|
||||||
this.totalSelections = totalSelections;
|
this.totalSelections = totalSelections;
|
||||||
this.shouldConfirm = shouldConfirm;
|
this.shouldConfirm = shouldConfirm;
|
||||||
@@ -116,6 +118,7 @@ public abstract class CustomMultiSelectMenu<TEntry> : CustomPhoneMenu<CustomMult
|
|||||||
back.OnClick.AddListener((UnityAction)(() =>
|
back.OnClick.AddListener((UnityAction)(() =>
|
||||||
{
|
{
|
||||||
selectedEntries.Clear();
|
selectedEntries.Clear();
|
||||||
|
MeetingVoteAreaVisibility.Restore(Component);
|
||||||
onClick(null);
|
onClick(null);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -177,6 +180,7 @@ public abstract class CustomMultiSelectMenu<TEntry> : CustomPhoneMenu<CustomMult
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedEntries.Add(menuEntry);
|
selectedEntries.Add(menuEntry);
|
||||||
|
MeetingVoteAreaVisibility.Restore(Component);
|
||||||
|
|
||||||
// Add choice to list of selections
|
// Add choice to list of selections
|
||||||
if (selectedEntries.Count <= totalSelections)
|
if (selectedEntries.Count <= totalSelections)
|
||||||
|
|||||||
@@ -387,6 +387,7 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu<CustomPaginableMenu.
|
|||||||
protected void Begin(Action registerEntryPanels)
|
protected void Begin(Action registerEntryPanels)
|
||||||
{
|
{
|
||||||
MinigameStubs.Begin(Component, null);
|
MinigameStubs.Begin(Component, null);
|
||||||
|
MeetingVoteAreaVisibility.HideNameplates(Component);
|
||||||
|
|
||||||
searchText = string.Empty;
|
searchText = string.Empty;
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AmongUs.GameOptions;
|
using AmongUs.GameOptions;
|
||||||
|
using MiraAPI.Utilities;
|
||||||
using MiraAPI.Utilities.Assets;
|
using MiraAPI.Utilities.Assets;
|
||||||
using Reactor.Utilities.Attributes;
|
using Reactor.Utilities.Attributes;
|
||||||
using Reactor.Utilities.Extensions;
|
using Reactor.Utilities.Extensions;
|
||||||
@@ -21,6 +22,7 @@ public class CustomPhoneMenuComponent(IntPtr cppPtr) : Minigame(cppPtr)
|
|||||||
[SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Unity convention.")]
|
[SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Unity convention.")]
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
|
MeetingVoteAreaVisibility.Restore(this);
|
||||||
if (ControllerManager.Instance)
|
if (ControllerManager.Instance)
|
||||||
{
|
{
|
||||||
ControllerManager.Instance.CloseOverlayMenu(name);
|
ControllerManager.Instance.CloseOverlayMenu(name);
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
|||||||
protected int TabIndex => LocalSettingsManager.Tabs.IndexOf(this) + 10;
|
protected int TabIndex => LocalSettingsManager.Tabs.IndexOf(this) + 10;
|
||||||
|
|
||||||
private Scroller? Scroller { get; set; }
|
private Scroller? Scroller { get; set; }
|
||||||
|
private float MaxScroll { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when an option value is changed.
|
/// Invoked when an option value is changed.
|
||||||
@@ -106,6 +107,17 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void RefreshScrollBounds()
|
||||||
|
{
|
||||||
|
if (Scroller == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Scroller.SetBounds(new FloatRange(0, MaxScroll), new FloatRange(0, 0));
|
||||||
|
Scroller.ScrollToTop();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the tab <see cref="GameObject"/> and it's content.
|
/// Creates the tab <see cref="GameObject"/> and it's content.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -118,11 +130,13 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
|||||||
tab.transform.DestroyChildren();
|
tab.transform.DestroyChildren();
|
||||||
tab.gameObject.SetActive(false);
|
tab.gameObject.SetActive(false);
|
||||||
|
|
||||||
if (Scroller == null)
|
if (Scroller == null || Scroller.transform.parent != tab.transform)
|
||||||
{
|
{
|
||||||
Scroller = Helpers.CreateScroller(tab.transform, OptionsMenuPatches.MaskCollider);
|
Scroller = Helpers.CreateScroller(tab.transform, OptionsMenuPatches.MaskCollider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Labels.Clear();
|
||||||
|
|
||||||
if (TabButton != null)
|
if (TabButton != null)
|
||||||
{
|
{
|
||||||
TabButton.Content = tab.gameObject;
|
TabButton.Content = tab.gameObject;
|
||||||
@@ -216,7 +230,11 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
|||||||
contentIndex++;
|
contentIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scroller.SetBounds(new FloatRange(0, (Settings.Count + Buttons.Count) * 0.5f - 5f), new FloatRange(0, 0));
|
const float visibleHeight = 5f;
|
||||||
|
const float extraPadding = 0.25f;
|
||||||
|
var itemRange = (Settings.Count + Buttons.Count) * 0.5f - visibleHeight;
|
||||||
|
var offsetRange = contentOffset - visibleHeight + extraPadding;
|
||||||
|
MaxScroll = Mathf.Max(0f, itemRange, offsetRange);
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using BepInEx.Unity.IL2CPP.Utils.Collections;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||||
using MiraAPI.LocalSettings;
|
using MiraAPI.LocalSettings;
|
||||||
@@ -183,7 +185,9 @@ public static class OptionsMenuPatches
|
|||||||
// Tabs with index 10 and above are the mod settings tabs
|
// Tabs with index 10 and above are the mod settings tabs
|
||||||
if (index >= 10)
|
if (index >= 10)
|
||||||
{
|
{
|
||||||
CustomOpen(LocalSettingsManager.AvailableTabs[index - 10]);
|
var tab = LocalSettingsManager.AvailableTabs[index - 10];
|
||||||
|
CustomOpen(tab);
|
||||||
|
__instance.StartCoroutine(RefreshScrollBoundsAfterOpen(__instance, tab).WrapToIl2Cpp());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,6 +233,16 @@ public static class OptionsMenuPatches
|
|||||||
tab.Open();
|
tab.Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IEnumerator RefreshScrollBoundsAfterOpen(OptionsMenuBehaviour menu, LocalSettingsTab tab)
|
||||||
|
{
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
|
||||||
|
if (menu && tab.TabButton?.Content && tab.TabButton.Content.activeInHierarchy)
|
||||||
|
{
|
||||||
|
tab.RefreshScrollBounds();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void CustomClose(LocalSettingsTab tab)
|
private static void CustomClose(LocalSettingsTab tab)
|
||||||
{
|
{
|
||||||
if (tab.TabButton?.Button)
|
if (tab.TabButton?.Button)
|
||||||
|
|||||||
@@ -362,6 +362,7 @@ public static class RoleSettingMenuPatches
|
|||||||
}
|
}
|
||||||
|
|
||||||
roleMenu.SetScrollBounds();
|
roleMenu.SetScrollBounds();
|
||||||
|
roleMenu.scrollBar.ScrollToTop();
|
||||||
_quotaTabCoroutine = null;
|
_quotaTabCoroutine = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -279,6 +279,8 @@ public static class RoleGuidePatches
|
|||||||
MapBehaviour.Instance.Close();
|
MapBehaviour.Instance.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MeetingVoteAreaVisibility.HideNameplates(__instance);
|
||||||
|
|
||||||
if (HudManager.InstanceExists)
|
if (HudManager.InstanceExists)
|
||||||
{
|
{
|
||||||
ConsoleJoystick.SetMode_MenuAdditive();
|
ConsoleJoystick.SetMode_MenuAdditive();
|
||||||
@@ -390,6 +392,13 @@ public static class RoleGuidePatches
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.Close))]
|
||||||
|
private static void ClosePostfix(MatchInfoGuide __instance)
|
||||||
|
{
|
||||||
|
MeetingVoteAreaVisibility.Restore(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
private static void SetUpTabGrids(MatchInfoTabPos position)
|
private static void SetUpTabGrids(MatchInfoTabPos position)
|
||||||
{
|
{
|
||||||
tabButtonContainer.startCorner = GridLayoutGroup.Corner.UpperLeft;
|
tabButtonContainer.startCorner = GridLayoutGroup.Corner.UpperLeft;
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ internal static class MeetingHudPatches
|
|||||||
[HarmonyPatch(nameof(MeetingHud.OnDestroy))]
|
[HarmonyPatch(nameof(MeetingHud.OnDestroy))]
|
||||||
public static void OnDestroyPatch(MeetingHud __instance)
|
public static void OnDestroyPatch(MeetingHud __instance)
|
||||||
{
|
{
|
||||||
|
MeetingVoteAreaVisibility.RestoreAll();
|
||||||
MiraEventManager.InvokeEvent(new EndMeetingEvent(__instance));
|
MiraEventManager.InvokeEvent(new EndMeetingEvent(__instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +114,7 @@ internal static class MeetingHudPatches
|
|||||||
[HarmonyPatch(nameof(MeetingHud.VotingComplete))]
|
[HarmonyPatch(nameof(MeetingHud.VotingComplete))]
|
||||||
public static void VotingCompletePatch(MeetingHud __instance)
|
public static void VotingCompletePatch(MeetingHud __instance)
|
||||||
{
|
{
|
||||||
|
MeetingVoteAreaVisibility.RestoreAll();
|
||||||
foreach (var meetingAbility in MeetingButtonManager.UntargetedButtons.Where(x => x.Enabled(PlayerControl.LocalPlayer.Data.Role) &&
|
foreach (var meetingAbility in MeetingButtonManager.UntargetedButtons.Where(x => x.Enabled(PlayerControl.LocalPlayer.Data.Role) &&
|
||||||
(x.DisableUponVoting || x.HideUponWrapUp)))
|
(x.DisableUponVoting || x.HideUponWrapUp)))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ public sealed class MiraPluginManager
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property.PropertyType.IsAssignableTo(typeof(IModdedOptionList)))
|
if (property.PropertyType.IsAssignableTo(typeof(IBaseModdedOptionList)))
|
||||||
{
|
{
|
||||||
ModdedOptionsManager.RegisterPropertyOptionList(type, property, pluginInfo);
|
ModdedOptionsManager.RegisterPropertyOptionList(type, property, pluginInfo);
|
||||||
continue;
|
continue;
|
||||||
@@ -259,7 +259,7 @@ public sealed class MiraPluginManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (var field in type.GetFields()
|
foreach (var field in type.GetFields()
|
||||||
.Where(f => f.FieldType.IsAssignableTo(typeof(IModdedOption)) || f.FieldType.IsAssignableTo(typeof(IModdedOptionList))))
|
.Where(f => f.FieldType.IsAssignableTo(typeof(IModdedOption)) || f.FieldType.IsAssignableTo(typeof(IBaseModdedOptionList))))
|
||||||
{
|
{
|
||||||
Error($"{field.Name} is a field, not a property. Use properties for options.");
|
Error($"{field.Name} is a field, not a property. Use properties for options.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -936,7 +936,7 @@ public static class Helpers
|
|||||||
{
|
{
|
||||||
const float contentTop = 0.95f;
|
const float contentTop = 0.95f;
|
||||||
const float horizontalOffset = -0.2f;
|
const float horizontalOffset = -0.2f;
|
||||||
const float headerContentGap = 0.2f;
|
const float groupHeaderContentGap = 0.05f;
|
||||||
const int contentSortingOrder = 151;
|
const int contentSortingOrder = 151;
|
||||||
|
|
||||||
columns = Mathf.Clamp(columns, 1, 6);
|
columns = Mathf.Clamp(columns, 1, 6);
|
||||||
@@ -1024,7 +1024,7 @@ public static class Helpers
|
|||||||
groupColumns[group] = i % columns;
|
groupColumns[group] = i % columns;
|
||||||
bandHeights[band] = Mathf.Max(
|
bandHeights[band] = Mathf.Max(
|
||||||
bandHeights[band],
|
bandHeights[band],
|
||||||
rowPitch * (groupedSettings[i].Count() + 1) + headerContentGap + 0.25f);
|
rowPitch * (groupedSettings[i].Count() + 1) + groupHeaderContentGap + 0.25f);
|
||||||
}
|
}
|
||||||
|
|
||||||
var bandOffset = 0f;
|
var bandOffset = 0f;
|
||||||
@@ -1040,7 +1040,6 @@ public static class Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var contentBottom = float.PositiveInfinity;
|
|
||||||
var previousGroup = (AbstractOptionGroup?)null;
|
var previousGroup = (AbstractOptionGroup?)null;
|
||||||
var rowIndex = 0;
|
var rowIndex = 0;
|
||||||
var column = 0;
|
var column = 0;
|
||||||
@@ -1089,12 +1088,12 @@ public static class Helpers
|
|||||||
|
|
||||||
if (headerSource)
|
if (headerSource)
|
||||||
{
|
{
|
||||||
const float headerScale = 0.46f;
|
const float groupHeaderScale = 0.42f;
|
||||||
var headerWidth = groupsAsColumns
|
var headerWidth = groupsAsColumns
|
||||||
? columnWidth / headerScale
|
? columnWidth / groupHeaderScale
|
||||||
: (columns * columnWidth + (columns - 1) * columnGap) / headerScale;
|
: (columns * columnWidth + (columns - 1) * columnGap) / groupHeaderScale;
|
||||||
var header = Object.Instantiate(headerSource!, page.transform, false);
|
var header = Object.Instantiate(headerSource!, page.transform, false);
|
||||||
header.transform.localScale = Vector3.one * headerScale;
|
header.transform.localScale = Vector3.one * groupHeaderScale;
|
||||||
if (groupsAsColumns)
|
if (groupsAsColumns)
|
||||||
{
|
{
|
||||||
var totalWidth = columns * columnWidth + (columns - 1) * columnGap;
|
var totalWidth = columns * columnWidth + (columns - 1) * columnGap;
|
||||||
@@ -1155,12 +1154,6 @@ public static class Helpers
|
|||||||
renderer.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
|
renderer.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
|
||||||
renderer.material.SetInt(PlayerMaterial.MaskLayer, 50);
|
renderer.material.SetInt(PlayerMaterial.MaskLayer, 50);
|
||||||
renderer.sortingOrder = contentSortingOrder;
|
renderer.sortingOrder = contentSortingOrder;
|
||||||
if (renderer.enabled && renderer.sprite)
|
|
||||||
{
|
|
||||||
contentBottom = Mathf.Min(
|
|
||||||
contentBottom,
|
|
||||||
inner.InverseTransformPoint(renderer.bounds.min).y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var text in header.GetComponentsInChildren<TextMeshPro>(true))
|
foreach (var text in header.GetComponentsInChildren<TextMeshPro>(true))
|
||||||
@@ -1171,9 +1164,6 @@ public static class Helpers
|
|||||||
if (text.enabled)
|
if (text.enabled)
|
||||||
{
|
{
|
||||||
text.ForceMeshUpdate();
|
text.ForceMeshUpdate();
|
||||||
contentBottom = Mathf.Min(
|
|
||||||
contentBottom,
|
|
||||||
inner.InverseTransformPoint(text.bounds.min).y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1191,7 +1181,7 @@ public static class Helpers
|
|||||||
horizontalOffset;
|
horizontalOffset;
|
||||||
var centerY = groupsAsColumns && settings[i].Group is { } rowGroup
|
var centerY = groupsAsColumns && settings[i].Group is { } rowGroup
|
||||||
? contentTop - groupTopOffsets[rowGroup] -
|
? contentTop - groupTopOffsets[rowGroup] -
|
||||||
(rowPitch * (groupRows[rowGroup] + 1)) - headerContentGap - (rowHeight / 2f)
|
(rowPitch * (groupRows[rowGroup] + 1)) - groupHeaderContentGap - (rowHeight / 2f)
|
||||||
: contentTop - (rowHeight / 2f) - (rowIndex * rowPitch) - groupSpacing;
|
: contentTop - (rowHeight / 2f) - (rowIndex * rowPitch) - groupSpacing;
|
||||||
var row = Object.Instantiate(rowPrefab, page.transform);
|
var row = Object.Instantiate(rowPrefab, page.transform);
|
||||||
row.enabled = false;
|
row.enabled = false;
|
||||||
@@ -1238,27 +1228,6 @@ public static class Helpers
|
|||||||
renderer.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
|
renderer.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
|
||||||
renderer.material.SetInt(PlayerMaterial.MaskLayer, 50);
|
renderer.material.SetInt(PlayerMaterial.MaskLayer, 50);
|
||||||
renderer.sortingOrder = contentSortingOrder;
|
renderer.sortingOrder = contentSortingOrder;
|
||||||
if (renderer.enabled &&
|
|
||||||
renderer.sprite &&
|
|
||||||
renderer.transform != row.PlusBtn.transform &&
|
|
||||||
!renderer.transform.IsChildOf(row.PlusBtn.transform) &&
|
|
||||||
renderer.transform != row.MinusBtn.transform &&
|
|
||||||
!renderer.transform.IsChildOf(row.MinusBtn.transform))
|
|
||||||
{
|
|
||||||
contentBottom = Mathf.Min(
|
|
||||||
contentBottom,
|
|
||||||
inner.InverseTransformPoint(renderer.bounds.min).y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var text in row.GetComponentsInChildren<TextMeshPro>(true))
|
|
||||||
{
|
|
||||||
if (text.enabled)
|
|
||||||
{
|
|
||||||
contentBottom = Mathf.Min(
|
|
||||||
contentBottom,
|
|
||||||
inner.InverseTransformPoint(text.bounds.min).y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
row.gameObject.SetActive(true);
|
row.gameObject.SetActive(true);
|
||||||
@@ -1277,6 +1246,26 @@ public static class Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
page.SetActive(true);
|
||||||
|
var contentBottom = float.PositiveInfinity;
|
||||||
|
foreach (var text in page.GetComponentsInChildren<TextMeshPro>(true))
|
||||||
|
{
|
||||||
|
if (text.enabled && text.gameObject.activeInHierarchy)
|
||||||
|
{
|
||||||
|
text.ForceMeshUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var renderer in page.GetComponentsInChildren<Renderer>(true))
|
||||||
|
{
|
||||||
|
if (renderer.enabled && renderer.gameObject.activeInHierarchy)
|
||||||
|
{
|
||||||
|
contentBottom = Mathf.Min(
|
||||||
|
contentBottom,
|
||||||
|
inner.InverseTransformPoint(renderer.bounds.min).y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var maskArea = parent.transform.FindChild("MaskArea")?.GetComponent<SpriteRenderer>();
|
var maskArea = parent.transform.FindChild("MaskArea")?.GetComponent<SpriteRenderer>();
|
||||||
var maskBottom = maskArea
|
var maskBottom = maskArea
|
||||||
? inner.InverseTransformPoint(maskArea!.bounds.min).y
|
? inner.InverseTransformPoint(maskArea!.bounds.min).y
|
||||||
@@ -1288,7 +1277,6 @@ public static class Helpers
|
|||||||
? contentOverflow + 0.05f
|
? contentOverflow + 0.05f
|
||||||
: 0f;
|
: 0f;
|
||||||
parent.SetYBoundsMax(Mathf.Clamp(scrollRange, 0f, 999f));
|
parent.SetYBoundsMax(Mathf.Clamp(scrollRange, 0f, 999f));
|
||||||
page.SetActive(true);
|
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace MiraAPI.Utilities;
|
||||||
|
|
||||||
|
internal static class MeetingVoteAreaVisibility
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<Renderer, bool> originalRendererStates = [];
|
||||||
|
private static readonly HashSet<int> activeOwners = [];
|
||||||
|
|
||||||
|
internal static void HideNameplates(UnityEngine.Object owner)
|
||||||
|
{
|
||||||
|
var meetingHud = MeetingHud.Instance;
|
||||||
|
if (!owner ||
|
||||||
|
!meetingHud ||
|
||||||
|
meetingHud.state is not (MeetingHud.MeetingStates.Discussion or
|
||||||
|
MeetingHud.MeetingStates.NotVoted or
|
||||||
|
MeetingHud.MeetingStates.Voted))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
activeOwners.Add(owner.GetInstanceID());
|
||||||
|
foreach (var playerVoteArea in meetingHud.playerStates)
|
||||||
|
{
|
||||||
|
if (!playerVoteArea)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var buttons = playerVoteArea.Buttons;
|
||||||
|
foreach (var renderer in playerVoteArea.GetComponentsInChildren<Renderer>(true))
|
||||||
|
{
|
||||||
|
if (!renderer ||
|
||||||
|
(buttons &&
|
||||||
|
(renderer.transform == buttons.transform || renderer.transform.IsChildOf(buttons.transform))))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!originalRendererStates.ContainsKey(renderer))
|
||||||
|
{
|
||||||
|
originalRendererStates.Add(renderer, renderer.enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Restore(UnityEngine.Object owner)
|
||||||
|
{
|
||||||
|
if (!owner || !activeOwners.Remove(owner.GetInstanceID()) || activeOwners.Count > 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RestoreAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void RestoreAll()
|
||||||
|
{
|
||||||
|
activeOwners.Clear();
|
||||||
|
foreach (var rendererState in originalRendererStates)
|
||||||
|
{
|
||||||
|
if (rendererState.Key)
|
||||||
|
{
|
||||||
|
rendererState.Key.enabled = rendererState.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
originalRendererStates.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user