コード例 #1
0
 protected override bool OnClose(params object[] args)
 {
     if (!IsOpen)
     {
         return(true);
     }
     foreach (var kvp in copySlots)
     {
         caches.Put(kvp.Value);
     }
     copySlots.Clear();
     selectedItems.Clear();
     SourceContainer.DarkIf(null);
     SourceContainer.MarkIf(null);
     SourceContainer = null;
     SourceHandler   = null;
     ZetanUtility.SetActive(tips, true);
     dialog        = string.Empty;
     SelectionType = ItemSelectionType.SelectNum;
     canSelect     = null;
     onConfirm     = null;
     if (!confirm)
     {
         onCancel?.Invoke();
     }
     onCancel = null;
     WindowsManager.CloseWindow <ItemWindow>();
     return(true);
 }
コード例 #2
0
 protected override bool OnOpen(params object[] args)
 {
     if (IsOpen)
     {
         return(true);
     }
     if (args != null && args.Length > 8)
     {
         WindowsManager.CloseWindow <ItemWindow>();
         var par = (selectionType : (ItemSelectionType)args[0], container : (ISlotContainer)args[1], handler : (IInventoryHandler)args[2], confirm : args[3] as Action <List <ItemWithAmount> >,
                    title : args[4] as string, confirmDialog : args[5] as string, typeLimit : (int)args[6], amountLimit : (int)args[7], selectCondition : args[8] as Predicate <ItemSlotBase>, cancel : args[9] as Action);
         SelectionType    = par.selectionType;
         SourceContainer  = par.container;
         SourceHandler    = par.handler;
         windowTitle.text = par.title;
         dialog           = par.confirmDialog;
         typeLimit        = par.typeLimit;
         amountLimit      = par.amountLimit;
         if (par.selectCondition != null)
         {
             canSelect = par.selectCondition;
         }
         else
         {
             canSelect = (a) => { return(true); }
         };
         SourceContainer.DarkIf(x => !canSelect(x));
         onConfirm = par.confirm;
         onCancel  = par.cancel;
         confirm   = false;
         RegisterNotify();
         return(true);
     }
     return(false);
 }
コード例 #3
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);
    }
コード例 #4
0
 public void StartSelection(ItemSelectionType selectionType, Action <List <ItemInfo> > confirmCallback, Action cancelCallback = null)
 {
     if (selectionType == ItemSelectionType.None)
     {
         return;
     }
     SelectionType       = selectionType;
     UI.windowTitle.text = "选择物品";
     onConfirm           = confirmCallback;
     onCancel            = cancelCallback;
     dialog = string.Empty;
     OpenWindow();
     BackpackManager.Instance.EnableHandwork(false);
 }
コード例 #5
0
 public override void CloseWindow()
 {
     base.CloseWindow();
     if (IsUIOpen)
     {
         return;
     }
     foreach (var ia in itemAgents)
     {
         ia.Clear(true);
     }
     itemAgents.Clear();
     ZetanUtility.SetActive(UI.tips, true);
     dialog        = string.Empty;
     SelectionType = ItemSelectionType.None;
     onCancel?.Invoke();
     BackpackManager.Instance.EnableHandwork(true);
 }
コード例 #6
0
 public static ItemSelectionWindow StartSelection(ItemSelectionType selectionType, ISlotContainer container, IInventoryHandler handler, Action <List <ItemWithAmount> > confirm, string title = null, string confirmDialog = null,
                                                  int?typeLimit = null, int?amountLimit = null, Predicate <ItemSlotBase> selectCondition = null, Action cancel = null)
 {
     return(WindowsManager.OpenWindow <ItemSelectionWindow>(selectionType, container, handler, confirm, title, confirmDialog, typeLimit ?? default, amountLimit ?? default, selectCondition, cancel));
 }
コード例 #7
0
 public static T SetItemSelectionType <T>(this T entity, ItemSelectionType value)
     where T : EffectDescription
 {
     entity.SetField("itemSelectionType", value);
     return(entity);
 }