Пример #1
0
        protected virtual void OnClearHistory(GumpButton button)
        {
            if (Selected == null || Selected.Deleted)
            {
                Selected = TrashCollection.EnsureProfile(User);
            }

            if (UseConfirmDialog)
            {
                Send(
                    new ConfirmDialogGump(User, Refresh())
                {
                    Title = "Clear Profile History?",
                    Html  =
                        "All data associated with the profile history will be lost.\n" +
                        "This action can not be reversed!\nDo you want to continue?",
                    AcceptHandler = OnConfirmClearHistory
                });
            }
            else
            {
                Selected.ClearHistory();
                Refresh(true);
            }
        }
Пример #2
0
        protected virtual void OnDeleteProfile(GumpButton button)
        {
            if (Selected == null || Selected.Deleted)
            {
                Selected = TrashCollection.EnsureProfile(User);
            }

            if (UseConfirmDialog)
            {
                Send(
                    new ConfirmDialogGump(User, Refresh())
                {
                    Title = "Delete Profile?",
                    Html  =
                        "All data associated with this profile will be deleted.\n" +
                        "This action can not be reversed!\nDo you want to continue?",
                    AcceptHandler = ConfirmDeleteProfile
                });
            }
            else
            {
                Selected.Delete();
                Close();
            }
        }
Пример #3
0
        private void OnViewHistory(GumpButton button)
        {
            if (Selected == null || Selected.Deleted)
            {
                Selected = TrashCollection.EnsureProfile(User);
            }

            Send(new TrashCollectionProfileHistoryGump(User, Selected, Hide(true), UseConfirmDialog, DateTime.UtcNow));
        }
Пример #4
0
        protected override void Compile()
        {
            base.Compile();

            if (Selected == null || Selected.Deleted)
            {
                Selected = TrashCollection.EnsureProfile(User, true);
            }

            Html  = String.Format("<basefont color=#{0:X6}>", HtmlColor.ToArgb());
            Html += Selected.ToHtmlString(User);
        }
Пример #5
0
        protected override void CompileMenuOptions(MenuGumpOptions list)
        {
            if (Selected == null || Selected.Deleted)
            {
                Selected = TrashCollection.EnsureProfile(User, true);
            }

            if (User.AccessLevel >= TrashCollection.Access)
            {
                list.AppendEntry(new ListGumpEntry("Clear History", OnClearHistory, HighlightHue));
                list.AppendEntry(new ListGumpEntry("Delete Profile", OnDeleteProfile, HighlightHue));
            }

            list.AppendEntry(new ListGumpEntry("View History", OnViewHistory, HighlightHue));

            list.AppendEntry(new ListGumpEntry("Help", ShowHelp));

            base.CompileMenuOptions(list);
        }
Пример #6
0
        public bool Trash(Mobile from, Item trashed, ref int tokens, bool message = true)
        {
            tokens = Math.Max(0, tokens);

            if (!Enabled || from == null || trashed == null || trashed.Deleted)
            {
                return(false);
            }

            if (!CanTrash(from, trashed))
            {
                OnTrashRejected(from, trashed, message);
                return(false);
            }

            bool multiple = false;

            if (trashed is Container)
            {
                bool      trashThis = true;
                Container c         = (Container)trashed;
                var       items     = c.FindItemsByType <Item>(false);

                if (items.Count > 0)
                {
                    multiple = true;
                }

                items.ForEach(
                    ci =>
                {
                    if (ci is Container)
                    {
                        from.SendMessage(0x55, "You cannot trash containers within containers.  Please trash them individually.");
                        trashThis = false;
                    }
                    if (!Trash(from, ci, false))
                    {
                        trashThis = false;
                    }
                });

                if (!trashThis)
                {
                    OnTrashRejected(from, trashed, message);
                    return(false);
                }
            }

            GetTrashTokens(from, trashed, ref tokens);
            OnTrashed(from, trashed, ref tokens, message);

            ItemTrashedEventArgs e = new ItemTrashedEventArgs(this, from, trashed, tokens, message);

            VitaNexCore.TryCatch(e.Invoke, TrashCollection.CMOptions.ToConsole);

            if (tokens != e.Tokens)
            {
                tokens = Math.Max(0, e.Tokens);
            }

            message = e.Message;

            if (!e.HandledTokens)
            {
                TrashCollection.EnsureProfile(from).TransferTokens(from, trashed, tokens, message);
            }

            if (from.Backpack != null && TrashCollection.CMOptions.UseTrashedProps)
            {
                from.Backpack.FindItemsByType(true, (Item i) => (i is ITrashTokenProperties)).ForEach(i => i.InvalidateProperties());
            }

            if (multiple && message)
            {
                from.SendMessage(0x55, "You trashed multiple items, check your profile history for more information.");
            }

            trashed.Delete();
            return(true);
        }
Пример #7
0
 protected override void CompileList(List <TrashProfile> list)
 {
     list.Clear();
     list.AddRange(TrashCollection.GetSortedProfiles(SortByToday));
     base.CompileList(list);
 }
Пример #8
0
 private void OnMyProfile(GumpButton button)
 {
     Send(new TrashCollectionProfileGump(User, TrashCollection.EnsureProfile(User), Hide(true), UseConfirmDialog));
 }
Пример #9
0
        public bool Trash(Mobile from, Item trashed, ref int tokens, bool message = true)
        {
            tokens = Math.Max(0, tokens);

            if (!Enabled || from == null || trashed == null || trashed.Deleted)
            {
                return(false);
            }

            var andThis  = true;
            var multiple = false;

            if (trashed is Container)
            {
                if (trashed.Items.Count > 0)
                {
                    var i = trashed.Items.Count;

                    while (--i >= 0)
                    {
                        if (!trashed.Items.InBounds(i))
                        {
                            continue;
                        }

                        if (Trash(from, trashed.Items[i], ref tokens, false))
                        {
                            multiple = true;
                        }
                        else
                        {
                            andThis = false;
                        }
                    }
                }

                if (trashed.Items.Count > 0)
                {
                    andThis = false;
                }
            }

            if (multiple && message)
            {
                from.SendMessage(0x55, "You trashed multiple items, check your profile history for more information.");
            }

            if (!CanTrash(from, trashed))
            {
                andThis = false;
            }

            if (!andThis)
            {
                OnTrashRejected(from, trashed, message);
                return(false);
            }

            GetTrashTokens(from, trashed, ref tokens);
            OnTrashed(from, trashed, ref tokens, message);

            var e = new ItemTrashedEventArgs(this, from, trashed, tokens, message);

            VitaNexCore.TryCatch(e.Invoke, TrashCollection.CMOptions.ToConsole);

            if (tokens != e.Tokens)
            {
                tokens = Math.Max(0, e.Tokens);
            }

            message = e.Message;

            if (!e.HandledTokens)
            {
                TrashCollection.EnsureProfile(from).TransferTokens(from, trashed, tokens, message);
            }

            if (!multiple && from.Backpack != null && TrashCollection.CMOptions.UseTrashedProps)
            {
                from.Backpack.InvalidateProperties <ITrashTokenProperties>();
            }

            trashed.Delete();
            return(true);
        }