public void AddItemShortcut(int slot, BasePlayerItem item) { if (!this.IsSlotFree(slot, ShortcutBarEnum.GENERAL_SHORTCUT_BAR)) { this.RemoveShortcut(ShortcutBarEnum.GENERAL_SHORTCUT_BAR, slot); } ItemShortcut itemShortcut = new ItemShortcut(this.Owner.Record, slot, item.Template.Id, item.Guid); this.m_itemShortcuts.Add(slot, itemShortcut); ShortcutHandler.SendShortcutBarRefreshMessage(this.Owner.Client, ShortcutBarEnum.GENERAL_SHORTCUT_BAR, itemShortcut); }
private void AddItemShortcut(IntPtr data, string accelPath, uint accelKey, ModifierType accelMods, bool changed) { long itemId; if (IsKeyForItem(accelPath, out itemId) && accelKey != 0 && accelKey != (uint)Key.VoidSymbol) { ItemShortcut itemShortcut = new ItemShortcut(); if (!itemShortcut.ItemEvaluate(Item.GetById(itemId), PriceGroup.RegularPrice)) { return; } itemShortcut.Shortcut = new AccelKey((Key)accelKey, KeyShortcuts.GetAllowedModifier(accelMods), AccelFlags.Visible); itemShortcuts.Add(itemShortcut); } }
private bool UsedWithAnotherItem(int row) { ItemShortcut itemShortcut = itemShortcuts.Find(i => i.Shortcut.Key == currentKey.Key && i.Shortcut.AccelMods == currentKey.AccelMods); if (itemShortcut != null && itemShortcut != itemShortcuts [row] && currentKey.Key > 0) { string title = Translator.GetString("Warning!"); string translation = Translator.GetString("The selected shortcut is already used for the \"{0}\" quick item. " + "Do you want to remove the shortcut for \"{0}\" and assign it to \"{1}\"?"); string message = string.Format(translation, itemShortcut.ItemName, itemShortcuts [row].ItemName); if (Message.ShowDialog(title, string.Empty, message, "Icons.Question32.png", MessageButtons.YesNo) != ResponseType.Yes) { return(false); } itemShortcut.Shortcut = AccelKey.Zero; } return(true); }
private void ItemColumnChoose(string filter) { if (!grid.EditedCell.IsValid) { return; } int row = itemShortcuts.Count - grid.EditedCell.Row; using (ChooseEditItem dialog = new ChooseEditItem(true, filter)) { if (dialog.Run() == ResponseType.Ok) { for (int i = itemShortcuts.Count - 1; i >= 0; i--) { if (itemShortcuts [i].ItemId == -1) { itemShortcuts.RemoveAt(i); } } List <Item> alreadyAddedItems = new List <Item> (); int currentRow = grid.EditedCell.Row; foreach (Item item in dialog.SelectedItems) { if (IsAlreadyAdded(item)) { alreadyAddedItems.Add(item); continue; } ItemShortcut itemShortcut; if (currentRow >= itemShortcuts.Count) { itemShortcut = new ItemShortcut(); itemShortcuts.Add(itemShortcut); } else { itemShortcut = itemShortcuts [currentRow]; } if (itemShortcut.ItemEvaluate(item, PriceGroup.RegularPrice)) { currentRow++; } } if (alreadyAddedItems.Count == 0) { ItemColumnEditNext(grid.EditedCell.Row, Key.Return); return; } string message; const int maximumItemsToShow = 15; if (alreadyAddedItems.Count > maximumItemsToShow) { message = Translator.GetString("Not all of the selected items can be added. 15 of the items which already have shortcuts are: {0}"); } else { message = Translator.GetString("Not all of the selected items can be added. The items which already have shortcuts are: {0}"); } string itemNames = GetItemNames(alreadyAddedItems, maximumItemsToShow); if (alreadyAddedItems.Count < dialog.SelectedItems.Length) { MessageError.ShowDialog(string.Format(message, itemNames)); return; } if (alreadyAddedItems.Count == dialog.SelectedItems.Length) { message = Translator.GetString("The selected items already have shortcuts!"); MessageError.ShowDialog(message); } } } EditGridCell(itemShortcuts.Count - row, 0); }