Наследование: SearchableScrollWindow
Пример #1
0
    public static ItemSelectionWindow OpenSelectionWindow <T>(ItemSelectionType selectionType, Action <List <ItemWithAmount> > confirm, string title = null, string confirmDialog = null,
                                                              int?typeLimit = null, int?amountLimit = null, Predicate <ItemSlotBase> selectCondition = null, Action cancel = null, params object[] args) where T : InventoryWindow
    {
        var window = WindowsManager.FindWindow <T>();

        if (window)
        {
            bool openBef = window.IsOpen, hiddenBef = window.IsHidden;
            if (window.IsHidden)
            {
                WindowsManager.HideWindow <T>(false);
            }
            if (!window.IsOpen)
            {
                window.Open(args);
            }
            var selection = ItemSelectionWindow.StartSelection(selectionType, window.grid as ISlotContainer, window.Handler, confirm, title, confirmDialog, typeLimit, amountLimit, selectCondition, cancel);
            selection.onClose += () =>
            {
                if (!openBef)
                {
                    window.Close(typeof(ItemSelectionWindow));
                }
                else if (hiddenBef)
                {
                    WindowsManager.HideWindow <T>(true);
                }
            };
            return(selection);
        }
        return(null);
    }
Пример #2
0
 public void InitItemWindow <TItem>(IEnumerable <TItem> items, Action <TItem> action, bool allowNone = false)
     where TItem : IItem
 {
     ItemSelectionWindow.Init("Select Item", items.Cast <IItem>(), (item) =>
     {
         InvertApplication.Execute(() =>
         {
             action((TItem)item);
         });
     }, allowNone);
 }