using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using TMPro;
using ToggleCardsCategories.Extensions;
using ToggleCardsCategories.ScriptableObjects;
using ToggleCardsCategories.UI;
using UnboundLib;
using UnboundLib.Utils;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ToggleCardsCategories
{
public struct ToggleCardCategoryInfo
{
public string Name;
public int? Priority;
public ToggleCardCategoryInfo(string name, int? priority = null)
{
Name = name;
Priority = priority;
}
}
public interface IToggleCardCategory
{
ToggleCardCategoryInfo GetCardCategoryInfo();
}
public class ToggleCardsCategoriesManager : MonoBehaviour
{
public readonly Dictionary<string, ToggleCardsCategoryMenu> Menus = new Dictionary<string, ToggleCardsCategoryMenu>();
internal readonly Dictionary<string, Dictionary<string, ToggleCardsCategoryMenu>> CardsNameToMenuMapping = new Dictionary<string, Dictionary<string, ToggleCardsCategoryMenu>>();
private List<string> registeredCategories = new List<string>();
public static ToggleCardsCategoriesManager instance { get; internal set; }
public IReadOnlyList<string> RegisteredCategories => registeredCategories.AsReadOnly();
public void RegisterCategories(string category)
{
if (!registeredCategories.Contains(category))
{
registeredCategories.Add(category);
}
}
public ToggleCardsCategoryMenu[] GetCategoriesByMod(string ModPrefix)
{
string modPrefix = ModPrefix.Split(new char[1] { '/' }).First();
return (from menu in Menus
where menu.Key.StartsWith(modPrefix)
select menu into m
select m.Value).ToArray();
}
public ToggleCardsCategoryMenu AddToggleCardToCategory(GameObject parent, GameObject toggleCard, string categoryPath, string modPrefix)
{
if (!Menus.ContainsKey(modPrefix + "/" + categoryPath))
{
CreateToggleCardsCategoryMenu(parent, categoryPath, modPrefix);
}
ToggleCardsCategoryMenu toggleCardsCategoryMenu = Menus[modPrefix + "/" + categoryPath];
toggleCardsCategoryMenu.AddToggleCardToCategory(toggleCard);
if (!CardsNameToMenuMapping.ContainsKey(modPrefix))
{
CardsNameToMenuMapping.Add(modPrefix, new Dictionary<string, ToggleCardsCategoryMenu>());
}
CardsNameToMenuMapping[modPrefix].Add(((Object)toggleCard).name, toggleCardsCategoryMenu);
return toggleCardsCategoryMenu;
}
private void CreateToggleCardsCategoryMenu(GameObject parent, string categoryPath, string modPrefix)
{
string[] array = categoryPath.Split(new char[1] { '/' });
string text = array[0];
GameObject val = parent;
ToggleCardsCategoryMenu toggleCardsCategoryMenu = null;
for (int i = 0; i < array.Length; i++)
{
string text2 = array[i];
if (i > 0)
{
text = text + "/" + text2;
}
if (Menus.ContainsKey(modPrefix + "/" + text))
{
ToggleCardsCategoryMenu toggleCardsCategoryMenu2 = Menus[modPrefix + "/" + text];
val = toggleCardsCategoryMenu2.categoriesContent;
toggleCardsCategoryMenu = toggleCardsCategoryMenu2;
}
else if (!Menus.ContainsKey(modPrefix + "/" + text))
{
GameObject obj = Object.Instantiate<GameObject>(ToggleCardsCategoryMenu.Prefab);
obj.transform.SetParent(val.transform, false);
ToggleCardsCategoryMenu component = obj.GetComponent<ToggleCardsCategoryMenu>();
((TMP_Text)component.categoryText).text = text2;
component.categoryDepth = i;
Menus.Add(modPrefix + "/" + text, component);
if (Object.op_Implicit((Object)(object)toggleCardsCategoryMenu))
{
toggleCardsCategoryMenu.categories.Add(component);
toggleCardsCategoryMenu.categoriesContent.SetActive(true);
component.parentCategory = toggleCardsCategoryMenu;
}
component.viewport.SetActive(false);
((Selectable)component.dropdownButton).image.sprite = component.dropdownCloseImage;
val = component.categoriesContent;
toggleCardsCategoryMenu = component;
}
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.aalund13.rounds.toggle_cards_categories", "ToggleCardsCategories", "1.4.0")]
[BepInProcess("Rounds.exe")]
public class ToggleCardsCategories : BaseUnityPlugin
{
private const string modId = "com.aalund13.rounds.toggle_cards_categories";
private const string modName = "ToggleCardsCategories";
internal static ToggleCardsCategories Instance;
internal static AssetBundle Assets;
private void Awake()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
new Harmony("com.aalund13.rounds.toggle_cards_categories").PatchAll();
Assets = AssetUtils.LoadAssetBundleFromResources("togglecardscategories_assets", typeof(ToggleCardsCategories).Assembly);
ToggleCardsCategoriesManager.instance = ((Component)this).gameObject.AddComponent<ToggleCardsCategoriesManager>();
ToggleCardsCategoryMenu.Prefab = Assets.LoadAsset<GameObject>("CardsCatagory");
Unbound.RegisterClientSideMod("com.aalund13.rounds.toggle_cards_categories");
Debug.Log("ToggleCardsCategories loaded!");
}
private void Start()
{
Debug.Log("ToggleCardsCategories started!");
}
}
}
namespace ToggleCardsCategories.Utils
{
public enum CategorySourceType
{
FromPath,
FromScriptableObject
}
public class AddToToggleCardCategory : MonoBehaviour, IToggleCardCategory
{
[Tooltip("Determines how the category is defined — via a path string or a ScriptableObject reference.")]
[SerializeField]
private CategorySourceType sourceType;
[Tooltip("The path for the category. Example: \"Classes/MyClassHere\" creates 'MyClassHere' under 'Classes'.")]
[FormerlySerializedAs("CategoryPath")]
[SerializeField]
private string categoryPath;
[HideInInspector]
[SerializeField]
private string CategoryPath;
[Tooltip("If SourceType is 'FromScriptableObject', assign a ScriptableObject that defines the category.")]
[SerializeField]
private ToggleCardCategory categoryAsset;
[Tooltip("Sets the position (priority) of the category in the toggle mod category list.")]
public int Priority;
public ToggleCardCategoryInfo GetCardCategoryInfo()
{
OnValidate();
if (sourceType != CategorySourceType.FromScriptableObject)
{
return new ToggleCardCategoryInfo(categoryPath, Priority);
}
return new ToggleCardCategoryInfo(categoryAsset.CategoryPath, categoryAsset.Priority);
}
public void SetCategoryFromPath(string path)
{
sourceType = CategorySourceType.FromPath;
categoryPath = path.Trim();
}
public void SetCategoryFromScriptableObject(ToggleCardCategory category)
{
sourceType = CategorySourceType.FromScriptableObject;
categoryAsset = category;
}
private void OnValidate()
{
if (!string.IsNullOrEmpty(CategoryPath) && string.IsNullOrEmpty(categoryPath))
{
categoryPath = CategoryPath.Trim();
CategoryPath = string.Empty;
Debug.LogWarning((object)("[AddToToggleCardCategory] '" + ((Object)((Component)this).gameObject).name + "' was using legacy field 'CategoryPath'. It has been migrated to 'categoryPath'. Please re-save the prefab or scene."), (Object)(object)this);
}
}
}
}
namespace ToggleCardsCategories.UI
{
public class ToggleCardsCategoryMenu : MonoBehaviour
{
public static GameObject Prefab;
[SerializeField]
private Sprite dropdownOpenImage;
[SerializeField]
internal Sprite dropdownCloseImage;
[SerializeField]
private Toggle toggleCardsButton;
[SerializeField]
internal Button dropdownButton;
[SerializeField]
internal GameObject viewport;
[SerializeField]
internal GameObject cardsContent;
[SerializeField]
internal GameObject categoriesContent;
[SerializeField]
private GameObject darkenEffect;
[SerializeField]
private GridLayoutGroup gridLayoutGroup;
[SerializeField]
internal TextMeshProUGUI categoryText;
internal List<CardInfo> cardsInfo = new List<CardInfo>();
internal List<ToggleCardsCategoryMenu> categories = new List<ToggleCardsCategoryMenu>();
internal ToggleCardsCategoryMenu parentCategory;
internal List<GameObject> categoryContent = new List<GameObject>();
internal List<GameObject> categoryCardsContent = new List<GameObject>();
internal int categoryDepth;
private bool LockIsDropdown;
private bool updateVisualRequest;
public int Priority
{
get
{
return ExtensionMethods.GetOrAddComponent<LayoutElement>(((Component)this).gameObject, false).layoutPriority;
}
set
{
ExtensionMethods.GetOrAddComponent<LayoutElement>(((Component)this).gameObject, false).layoutPriority = value;
}
}
private bool isDisable
{
get
{
bool num = categories.Count == 0 || categories.All((ToggleCardsCategoryMenu c) => c.isDisable);
bool flag = true;
if (cardsInfo.Count > 0)
{
List<string> cardNames = cardsInfo.Select((CardInfo ci) => ((Object)ci).name).ToList();
flag = CardManager.cards.Values.Where((Card c) => ToggleCardsCategoriesManager.instance.RegisteredCategories.Contains(c.category) && cardNames.Contains(((Object)c.cardInfo).name)).All((Card c) => !c.enabled);
}
return num && flag;
}
}
public void DisableCategory()
{
darkenEffect.SetActive(true);
CardManager.DisableCards(cardsInfo.ToArray(), true);
foreach (GameObject item in categoryCardsContent)
{
ToggleCardsMenuHandler.UpdateVisualsCardObj(item, (bool?)null);
}
}
public void EnableCategory()
{
darkenEffect.SetActive(false);
CardManager.EnableCards(cardsInfo.ToArray(), true);
foreach (GameObject item in categoryCardsContent)
{
ToggleCardsMenuHandler.UpdateVisualsCardObj(item, (bool?)null);
}
}
public void CollapseCategory()
{
if (viewport.activeSelf)
{
viewport.SetActive(false);
((Selectable)dropdownButton).image.sprite = dropdownCloseImage;
Debug.Log((object)(((TMP_Text)categoryText).text + " have been collapse"));
}
}
public void ExpandCategory()
{
if (viewport.activeSelf)
{
return;
}
viewport.SetActive(true);
((Selectable)dropdownButton).image.sprite = dropdownOpenImage;
foreach (GameObject item in categoryCardsContent)
{
ToggleCardsMenuHandler.UpdateVisualsCardObj(item, (bool?)null);
}
Debug.Log((object)(((TMP_Text)categoryText).text + " have been expanded"));
}
public void ToggleCategory(bool toggle)
{
darkenEffect.SetActive(!toggle);
if (toggle)
{
CardManager.EnableCards(cardsInfo.ToArray(), true);
}
else
{
CardManager.DisableCards(cardsInfo.ToArray(), true);
}
foreach (GameObject item in categoryCardsContent)
{
ToggleCardsMenuHandler.UpdateVisualsCardObj(item, (bool?)null);
}
foreach (ToggleCardsCategoryMenu category in categories)
{
if (toggle)
{
category.EnableCategory();
}
else
{
category.DisableCategory();
}
}
}
public void ToggleDropdown()
{
if (viewport.activeSelf)
{
CollapseCategory();
}
else
{
ExpandCategory();
}
}
public void RequestUpdateVisual()
{
if (!updateVisualRequest)
{
updateVisualRequest = true;
ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)ToggleCardsCategories.Instance, 1, (Action)delegate
{
updateVisualRequest = false;
UpdateVisual();
});
}
}
public void UpdateVisual()
{
bool flag = isDisable;
((UnityEventBase)toggleCardsButton.onValueChanged).RemoveAllListeners();
toggleCardsButton.isOn = !flag;
((UnityEvent<bool>)(object)toggleCardsButton.onValueChanged).AddListener((UnityAction<bool>)ToggleCategory);
if (flag)
{
darkenEffect.SetActive(true);
}
else
{
darkenEffect.SetActive(false);
}
if ((Object)(object)parentCategory != (Object)null)
{
parentCategory.UpdateVisual();
}
}
public void LockDropdown()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if (!LockIsDropdown)
{
Image image = ((Selectable)dropdownButton).image;
((Graphic)image).color = ((Graphic)image).color / 2f;
}
}
public void UnLockDropdown()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if (LockIsDropdown)
{
Image image = ((Selectable)dropdownButton).image;
((Graphic)image).color = ((Graphic)image).color * 2f;
}
}
internal void AddToggleCardToCategory(GameObject toggleCard)
{
toggleCard.transform.SetParent(cardsContent.transform, false);
categoryContent.Add(toggleCard);
categoryCardsContent.Add(toggleCard);
cardsInfo.Add(CardManager.GetCardInfoWithName(((Object)toggleCard).name));
}
internal void SetGridSize(int amount)
{
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)gridLayoutGroup == (Object)null)
{
return;
}
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(220f, 300f);
float num = 1.5f;
if (amount > 3)
{
switch (amount)
{
case 4:
((Vector2)(ref val))..ctor(170f, 240f);
num = 1.2f;
break;
default:
((Vector2)(ref val))..ctor(136f, 192f);
num = 0.9f;
break;
case 6:
((Vector2)(ref val))..ctor(112f, 158f);
num = 0.75f;
break;
case 7:
((Vector2)(ref val))..ctor(97f, 137f);
num = 0.65f;
break;
case 8:
((Vector2)(ref val))..ctor(85f, 120f);
num = 0.55f;
break;
case 9:
((Vector2)(ref val))..ctor(75f, 106f);
num = 0.45f;
break;
case 10:
((Vector2)(ref val))..ctor(68f, 96f);
num = 0.4f;
break;
}
}
float num2 = Mathf.Clamp01(1f - 0.015f * (float)(categoryDepth + 1));
gridLayoutGroup.cellSize = val * num2;
gridLayoutGroup.constraintCount = amount;
foreach (GameObject item in categoryCardsContent)
{
item.transform.GetChild(2).localScale = num * Vector3.one * 10f * num2;
}
}
}
}
namespace ToggleCardsCategories.ScriptableObjects
{
[CreateAssetMenu(fileName = "ToggleCardCategory", menuName = "ToggleCardsCategories/ToggleCardCategory", order = 1)]
public class ToggleCardCategory : ScriptableObject
{
public string CategoryPath = "None";
public int Priority;
}
}
namespace ToggleCardsCategories.Patches
{
[HarmonyPatch(typeof(ToggleCardsMenuHandler))]
internal class ToggleCardsMenuHandlerPatch
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Func<KeyValuePair<string, ToggleCardsCategoryMenu>, GameObject> <>9__7_0;
public static Func<KeyValuePair<string, ToggleCardsCategoryMenu>, string> <>9__9_0;
public static Action <>9__11_3;
public static UnityAction<string> <>9__11_0;
public static UnityAction <>9__11_1;
public static Func<Transform, GameObject> <>9__11_4;
public static Action <>9__11_2;
public static Func<Transform, RectTransform> <>9__12_0;
internal GameObject <UpdateVisualsCardObjPrefix>b__7_0(KeyValuePair<string, ToggleCardsCategoryMenu> c)
{
return ((Component)c.Value.dropdownButton).gameObject;
}
internal string <ActiveOnSearchPostfix>b__9_0(KeyValuePair<string, ToggleCardsCategoryMenu> c)
{
return ((Object)c.Value.dropdownButton).name;
}
internal void <StartPostfix>b__11_0(string value)
{
Debug.Log((object)"Value Chnage");
DelayActionQueue.Clear();
((MonoBehaviour)ToggleCardsCategoriesManager.instance).StopAllCoroutines();
ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)ToggleCardsCategoriesManager.instance, 1, (Action)delegate
{
Debug.Log((object)"Delay trigger");
while (DelayActionQueue.Count > 0)
{
Debug.Log((object)"Invoke Delay Action");
DelayActionQueue.Dequeue()();
}
foreach (ToggleCardsCategoryMenu item in MenuToCollapses.ToList())
{
if (!ActiveMenus.Contains(item))
{
item.CollapseCategory();
MenuToCollapses.Remove(item);
}
ActiveMenus.Remove(item);
}
});
}
internal void <StartPostfix>b__11_3()
{
Debug.Log((object)"Delay trigger");
while (DelayActionQueue.Count > 0)
{
Debug.Log((object)"Invoke Delay Action");
DelayActionQueue.Dequeue()();
}
foreach (ToggleCardsCategoryMenu item in MenuToCollapses.ToList())
{
if (!ActiveMenus.Contains(item))
{
item.CollapseCategory();
MenuToCollapses.Remove(item);
}
ActiveMenus.Remove(item);
}
}
internal void <StartPostfix>b__11_1()
{
string text = (string)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "currentCategory");
if (ToggleCardsCategoriesManager.instance.RegisteredCategories.Contains(text))
{
ToggleCardsCategoryMenu[] categoriesByMod = ToggleCardsCategoriesManager.instance.GetCategoriesByMod(text);
for (int i = 0; i < categoriesByMod.Length; i++)
{
categoriesByMod[i].ExpandCategory();
}
}
}
internal void <StartPostfix>b__11_2()
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
Dictionary<string, List<GameObject>> dictionary = (Dictionary<string, List<GameObject>>)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "cardObjectsInCategory");
foreach (string registeredCategory in ToggleCardsCategoriesManager.instance.RegisteredCategories)
{
GameObject gameObject = ((Component)dictionary[registeredCategory][0].transform.parent).gameObject;
List<GameObject> list = (from Transform t in (IEnumerable)gameObject.transform
select ((Component)t).gameObject).ToList();
Object.DestroyImmediate((Object)(object)gameObject.GetComponent<GridLayoutGroup>());
gameObject.AddComponent<VerticalLayoutGroup>();
GameObject val = new GameObject("Categories Content", new Type[1] { typeof(VerticalLayoutGroup) });
VerticalLayoutGroup component = val.GetComponent<VerticalLayoutGroup>();
val.transform.SetParent(gameObject.transform, false);
((HorizontalOrVerticalLayoutGroup)component).spacing = 5f;
((LayoutGroup)component).padding = new RectOffset(5, 5, 5, 5);
GameObject val2 = new GameObject("Cards Content", new Type[1] { typeof(GridLayoutGroup) });
GridLayoutGroup component2 = val2.GetComponent<GridLayoutGroup>();
val2.transform.SetParent(gameObject.transform, false);
Groups.Add(component2);
gameObject.GetComponent<ContentSizeFitter>().horizontalFit = (FitMode)0;
gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f);
foreach (GameObject item in list)
{
IToggleCardCategory component3 = ((Component)item.transform.GetChild(2)).GetComponent<IToggleCardCategory>();
if (component3 == null || Utility.IsNullOrWhiteSpace(component3.GetCardCategoryInfo().Name))
{
item.transform.SetParent(val2.transform);
continue;
}
string name = component3.GetCardCategoryInfo().Name;
ToggleCardsCategoryMenu toggleCardsCategoryMenu = ToggleCardsCategoriesManager.instance.AddToggleCardToCategory(val, item, name, registeredCategory);
if (component3 != null && component3.GetCardCategoryInfo().Priority.HasValue)
{
toggleCardsCategoryMenu.Priority = component3.GetCardCategoryInfo().Priority.Value;
}
}
}
}
internal GameObject <StartPostfix>b__11_4(Transform t)
{
return ((Component)t).gameObject;
}
internal RectTransform <SetGridsSize>b__12_0(Transform cardTransform)
{
return ExtensionMethods.GetOrAddComponent<RectTransform>(((Component)cardTransform.GetChild(2)).gameObject, false);
}
}
public static List<GridLayoutGroup> Groups = new List<GridLayoutGroup>();
public static List<ToggleCardsCategoryMenu> MenuToCollapses = new List<ToggleCardsCategoryMenu>();
public static List<ToggleCardsCategoryMenu> ActiveMenus = new List<ToggleCardsCategoryMenu>();
public static Queue<Action> DelayActionQueue = new Queue<Action>();
public static bool AlreadyTrigger = false;
public static GameObject expandAllButton;
[HarmonyPatch("ChangeCardColumnAmountMenus")]
[HarmonyPrefix]
public static void ChangeCardColumnAmountMenusPrefex(int amount)
{
foreach (string registeredCategory in ToggleCardsCategoriesManager.instance.RegisteredCategories)
{
CardManager.categories.Remove(registeredCategory);
}
}
[HarmonyPatch("UpdateVisualsCardObj")]
[HarmonyPrefix]
public static bool UpdateVisualsCardObjPrefix(GameObject cardObject)
{
if (ToggleCardsCategoriesManager.instance.Menus.Select((KeyValuePair<string, ToggleCardsCategoryMenu> c) => ((Component)c.Value.dropdownButton).gameObject).Contains(cardObject))
{
return false;
}
if (ToggleCardsCategoriesManager.instance.CardsNameToMenuMapping.TryGetValue((string)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "currentCategory"), out var value) && value.TryGetValue(((Object)cardObject).name, out var value2))
{
value2.RequestUpdateVisual();
}
return true;
}
[HarmonyPatch("EnableCardsInCategory")]
[HarmonyPrefix]
public static void EnableCardsInCategoryPrefex(string category)
{
if (ToggleCardsCategoriesManager.instance.RegisteredCategories.Contains(category))
{
expandAllButton.SetActive(true);
}
else
{
expandAllButton.SetActive(false);
}
}
[HarmonyPatch("ActiveOnSearch")]
[HarmonyPostfix]
public static void ActiveOnSearchPostfix(string cardName, ref bool __result)
{
string text = (string)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "currentCategory");
string text2 = (string)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "currentSearch");
ToggleCardsCategoryMenu menu = default(ToggleCardsCategoryMenu);
if ((ToggleCardsCategoriesManager.instance.RegisteredCategories.Contains(text) && ToggleCardsCategoriesManager.instance.CardsNameToMenuMapping[text].TryGetValue(cardName, out menu)) & __result)
{
if (text2 != "")
{
DelayActionQueue.Enqueue(delegate
{
if (!menu.viewport.activeSelf)
{
menu.ExpandCategory();
if (!MenuToCollapses.Contains(menu))
{
MenuToCollapses.Add(menu);
}
}
ToggleCardsCategoryMenu parentCategory2 = menu.parentCategory;
while ((Object)(object)parentCategory2 != (Object)null)
{
if (!parentCategory2.viewport.activeSelf)
{
parentCategory2.ExpandCategory();
if (!MenuToCollapses.Contains(parentCategory2))
{
MenuToCollapses.Add(parentCategory2);
}
}
parentCategory2 = parentCategory2.parentCategory;
}
});
if (!ActiveMenus.Contains(menu))
{
ActiveMenus.Add(menu);
}
ToggleCardsCategoryMenu parentCategory = menu.parentCategory;
while ((Object)(object)parentCategory != (Object)null)
{
if (!ActiveMenus.Contains(parentCategory))
{
ActiveMenus.Add(parentCategory);
}
parentCategory = parentCategory.parentCategory;
}
}
else
{
foreach (ToggleCardsCategoryMenu menuToCollapse in MenuToCollapses)
{
if (ActiveMenus.Contains(menuToCollapse))
{
ActiveMenus.Remove(menuToCollapse);
}
}
}
}
if (ToggleCardsCategoriesManager.instance.Menus.Select((KeyValuePair<string, ToggleCardsCategoryMenu> c) => ((Object)c.Value.dropdownButton).name).Contains(cardName))
{
__result = true;
}
}
[HarmonyPatch("ChangeCardColumnAmountMenus")]
[HarmonyPostfix]
public static void ChangeCardColumnAmountMenusPostfix(int amount)
{
foreach (string registeredCategory in ToggleCardsCategoriesManager.instance.RegisteredCategories)
{
CardManager.categories.Add(registeredCategory);
}
foreach (ToggleCardsCategoryMenu value in ToggleCardsCategoriesManager.instance.Menus.Values)
{
value.SetGridSize(amount);
}
SetGridsSize(amount);
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPostfix()
{
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
GameObject gameObject = ((Component)ToggleCardsMenuHandler.cardMenuCanvas.transform.Find("CardMenu/Top/InputField")).gameObject;
GameObject gameObject2 = ((Component)ToggleCardsMenuHandler.cardMenuCanvas.transform.Find("CardMenu/Top/ToggleAll")).gameObject;
((UnityEvent<string>)(object)gameObject.GetComponent<TMP_InputField>().onValueChanged).AddListenerLast<string>(delegate
{
Debug.Log((object)"Value Chnage");
DelayActionQueue.Clear();
((MonoBehaviour)ToggleCardsCategoriesManager.instance).StopAllCoroutines();
ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)ToggleCardsCategoriesManager.instance, 1, (Action)delegate
{
Debug.Log((object)"Delay trigger");
while (DelayActionQueue.Count > 0)
{
Debug.Log((object)"Invoke Delay Action");
DelayActionQueue.Dequeue()();
}
foreach (ToggleCardsCategoryMenu item in MenuToCollapses.ToList())
{
if (!ActiveMenus.Contains(item))
{
item.CollapseCategory();
MenuToCollapses.Remove(item);
}
ActiveMenus.Remove(item);
}
});
});
expandAllButton = Object.Instantiate<GameObject>(gameObject2, gameObject2.transform.parent);
((TMP_Text)expandAllButton.GetComponentInChildren<TextMeshProUGUI>()).text = "Expand All";
((UnityEventBase)expandAllButton.GetComponent<Button>().onClick).RemoveAllListeners();
ButtonClickedEvent onClick = expandAllButton.GetComponent<Button>().onClick;
object obj = <>c.<>9__11_1;
if (obj == null)
{
UnityAction val = delegate
{
string text = (string)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "currentCategory");
if (ToggleCardsCategoriesManager.instance.RegisteredCategories.Contains(text))
{
ToggleCardsCategoryMenu[] categoriesByMod = ToggleCardsCategoriesManager.instance.GetCategoriesByMod(text);
for (int i = 0; i < categoriesByMod.Length; i++)
{
categoriesByMod[i].ExpandCategory();
}
}
};
<>c.<>9__11_1 = val;
obj = (object)val;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
expandAllButton.transform.localPosition = new Vector3(416.6898f, 105.7931f, 0f);
expandAllButton.SetActive(false);
ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)ToggleCardsCategories.Instance, 0.75f, (Action)delegate
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
Dictionary<string, List<GameObject>> dictionary = (Dictionary<string, List<GameObject>>)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "cardObjectsInCategory");
foreach (string registeredCategory in ToggleCardsCategoriesManager.instance.RegisteredCategories)
{
GameObject gameObject3 = ((Component)dictionary[registeredCategory][0].transform.parent).gameObject;
List<GameObject> list = (from Transform t in (IEnumerable)gameObject3.transform
select ((Component)t).gameObject).ToList();
Object.DestroyImmediate((Object)(object)gameObject3.GetComponent<GridLayoutGroup>());
gameObject3.AddComponent<VerticalLayoutGroup>();
GameObject val2 = new GameObject("Categories Content", new Type[1] { typeof(VerticalLayoutGroup) });
VerticalLayoutGroup component = val2.GetComponent<VerticalLayoutGroup>();
val2.transform.SetParent(gameObject3.transform, false);
((HorizontalOrVerticalLayoutGroup)component).spacing = 5f;
((LayoutGroup)component).padding = new RectOffset(5, 5, 5, 5);
GameObject val3 = new GameObject("Cards Content", new Type[1] { typeof(GridLayoutGroup) });
GridLayoutGroup component2 = val3.GetComponent<GridLayoutGroup>();
val3.transform.SetParent(gameObject3.transform, false);
Groups.Add(component2);
gameObject3.GetComponent<ContentSizeFitter>().horizontalFit = (FitMode)0;
gameObject3.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f);
foreach (GameObject item2 in list)
{
IToggleCardCategory component3 = ((Component)item2.transform.GetChild(2)).GetComponent<IToggleCardCategory>();
if (component3 == null || Utility.IsNullOrWhiteSpace(component3.GetCardCategoryInfo().Name))
{
item2.transform.SetParent(val3.transform);
}
else
{
string name = component3.GetCardCategoryInfo().Name;
ToggleCardsCategoryMenu toggleCardsCategoryMenu = ToggleCardsCategoriesManager.instance.AddToggleCardToCategory(val2, item2, name, registeredCategory);
if (component3 != null && component3.GetCardCategoryInfo().Priority.HasValue)
{
toggleCardsCategoryMenu.Priority = component3.GetCardCategoryInfo().Priority.Value;
}
}
}
}
});
}
private static void SetGridsSize(int amount)
{
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
Vector2 cellSize = default(Vector2);
((Vector2)(ref cellSize))..ctor(220f, 300f);
float num = 1.5f;
if (amount > 3)
{
switch (amount)
{
case 4:
((Vector2)(ref cellSize))..ctor(170f, 240f);
num = 1.2f;
break;
default:
((Vector2)(ref cellSize))..ctor(136f, 192f);
num = 0.9f;
break;
case 6:
((Vector2)(ref cellSize))..ctor(112f, 158f);
num = 0.75f;
break;
case 7:
((Vector2)(ref cellSize))..ctor(97f, 137f);
num = 0.65f;
break;
case 8:
((Vector2)(ref cellSize))..ctor(85f, 120f);
num = 0.55f;
break;
case 9:
((Vector2)(ref cellSize))..ctor(75f, 106f);
num = 0.45f;
break;
case 10:
((Vector2)(ref cellSize))..ctor(68f, 96f);
num = 0.4f;
break;
}
}
foreach (GridLayoutGroup group in Groups)
{
group.cellSize = cellSize;
group.constraintCount = amount;
foreach (RectTransform item in from cardTransform in ((IEnumerable)((Component)@group).transform).Cast<Transform>().ToList()
select ExtensionMethods.GetOrAddComponent<RectTransform>(((Component)cardTransform.GetChild(2)).gameObject, false))
{
((Transform)item).localScale = num * Vector3.one * 10f;
}
}
}
}
}
namespace ToggleCardsCategories.Extensions
{
internal static class UnityEventExtensions
{
public static void AddListenerLast<T0>(this UnityEvent<T0> unityEvent, UnityAction<T0> call)
{
object fieldValue = ExtensionMethods.GetFieldValue(ExtensionMethods.GetFieldValue((object)unityEvent, "m_Calls"), "m_RuntimeCalls");
object obj = ExtensionMethods.InvokeMethod((object)unityEvent, "GetDelegate", new Type[1] { typeof(UnityAction<T0>) }, new object[1] { call });
ExtensionMethods.InvokeMethod(fieldValue, "Insert", new object[2] { 0, obj });
}
}
}