using Content.Shared._NF.BountyContracts; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Prototypes; namespace Content.Client._NF.BountyContracts.UI; [GenerateTypedNameReferences] public sealed partial class BountyContractUiFragmentTabSet : TabContainer { [Dependency] private readonly IPrototypeManager _proto = default!; public event Action>? OnSelectCollection; private Dictionary> _tabsToCollections; public BountyContractUiFragmentTabSet() { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); _tabsToCollections = new(); OnTabChanged += TabChanged; } // Note: no safety checks on tabIndex range. public bool SetTabCollection(int tabIndex, ProtoId collection) { if (_proto.TryIndex(collection, out var collectionProto)) SetTabTitle(tabIndex, Loc.GetString(collectionProto.Name)); return _tabsToCollections.TryAdd(tabIndex, collection); } public void TabChanged(int tabIndex) { if (_tabsToCollections.ContainsKey(tabIndex)) OnSelectCollection?.Invoke(_tabsToCollections[tabIndex]); } }