#nullable enable
using System;
using System.Collections.Generic;
using RosettaUI.UIToolkit.NestedDropdownMenuSystem;
using UnityEngine;
using UnityEngine.UIElements;
namespace RosettaUI.UIToolkit
{
///
/// DropdownMenu that supports hierarchical submenus based on GenericDropdownMenu.
///
public class NestedDropdownMenu
{
private readonly Dictionary _menuTable = new();
private SingleMenu RootMenu
{
get
{
if (!_menuTable.TryGetValue(string.Empty, out var menu))
{
menu = new SingleMenu();
_menuTable[string.Empty] = menu;
}
return menu;
}
}
public IEnumerable SingleMenus => _menuTable.Values;
#region IGenericMenu like methods
public void AddItem(string? itemName, bool isChecked, Action? action)
{
var (menu, label) = GetMenuAndLabel(itemName);
menu.AddItem(label, isChecked, action);
}
public void AddItem(string? itemName, bool isChecked, Action