using System; using System.Collections.Generic; using System.Text; using UnityEngine; using UnityEngine.UIElements; namespace io.github.hatayama.uLoopMCP { /// /// UI section for tool permissions and a virtualized per-tool enable list. /// The expensive list is allowed to stay unloaded while the foldout is collapsed. /// public class ToolSettingsSection { private const int ToolListRowHeight = 24; private const int InlineToolRowLimit = 40; private readonly Foldout _foldout; private readonly Toggle _allowThirdPartyToggle; private readonly Label _allowThirdPartyLabel; private readonly Button _securityLevelRestrictedButton; private readonly Button _securityLevelFullAccessButton; private readonly Label _securityLevelDescription; private readonly VisualElement _toolSettingsInfoContainer; private readonly VisualElement _toolListContainer; private readonly Label _toolListStatusLabel; private readonly ListView _toolListView; private readonly List _toolListRows = new(); private readonly Dictionary _togglesByToolName = new(); private bool _allowThirdPartyTools = true; private bool _isRegistryAvailable; private bool _isUnavailableStateShown; private bool _isLoadingStateShown; private string _layoutSignature = string.Empty; public event Action OnFoldoutChanged; public event Action OnToolToggled; public event Action OnAllowThirdPartyChanged; public event Action OnSecurityLevelChanged; public ToolSettingsSection(VisualElement root) { _foldout = root.Q("tool-settings-foldout"); _allowThirdPartyToggle = root.Q("allow-third-party-toggle"); _allowThirdPartyLabel = root.Q