Пример #1
0
        private bool RemoveInternal(Stump.Server.WorldServer.Database.Shortcuts.Shortcut shortcut)
        {
            bool result;

            if (shortcut is SpellShortcut)
            {
                result = this.m_spellShortcuts.Remove(shortcut.Slot);
            }
            else
            {
                result = (shortcut is ItemShortcut && this.m_itemShortcuts.Remove(shortcut.Slot));
            }
            return(result);
        }
Пример #2
0
 private void AddInternal(Stump.Server.WorldServer.Database.Shortcuts.Shortcut shortcut)
 {
     if (shortcut is SpellShortcut)
     {
         this.m_spellShortcuts.Add(shortcut.Slot, (SpellShortcut)shortcut);
     }
     else
     {
         if (shortcut is ItemShortcut)
         {
             this.m_itemShortcuts.Add(shortcut.Slot, (ItemShortcut)shortcut);
         }
     }
 }
Пример #3
0
 private void AddInternal(Shortcut shortcut)
 {
     if (shortcut is SpellShortcut && !m_spellShortcuts.ContainsKey(shortcut.Slot))
     {
         m_spellShortcuts.Add(shortcut.Slot, (SpellShortcut)shortcut);
     }
     else if (shortcut is ItemShortcut && !m_itemShortcuts.ContainsKey(shortcut.Slot))
     {
         m_itemShortcuts.Add(shortcut.Slot, (ItemShortcut)shortcut);
     }
     else if (shortcut is PresetShortcut && !m_presetShortcuts.ContainsKey(shortcut.Slot))
     {
         m_presetShortcuts.Add(shortcut.Slot, (PresetShortcut)shortcut);
     }
 }
Пример #4
0
        public System.Collections.Generic.IEnumerable <Stump.Server.WorldServer.Database.Shortcuts.Shortcut> GetShortcuts(ShortcutBarEnum barType)
        {
            System.Collections.Generic.IEnumerable <Stump.Server.WorldServer.Database.Shortcuts.Shortcut> result;
            switch (barType)
            {
            case ShortcutBarEnum.GENERAL_SHORTCUT_BAR:
                result = this.m_itemShortcuts.Values;
                break;

            case ShortcutBarEnum.SPELL_SHORTCUT_BAR:
                result = this.m_spellShortcuts.Values;
                break;

            default:
                result = new Stump.Server.WorldServer.Database.Shortcuts.Shortcut[0];
                break;
            }
            return(result);
        }
Пример #5
0
 public void RemoveShortcut(ShortcutBarEnum barType, int slot)
 {
     Stump.Server.WorldServer.Database.Shortcuts.Shortcut shortcut = this.GetShortcut(barType, slot);
     if (shortcut != null)
     {
         if (barType == ShortcutBarEnum.SPELL_SHORTCUT_BAR)
         {
             this.m_spellShortcuts.Remove(slot);
         }
         else
         {
             if (barType == ShortcutBarEnum.GENERAL_SHORTCUT_BAR)
             {
                 this.m_itemShortcuts.Remove(slot);
             }
         }
         this.m_shortcutsToDelete.Enqueue(shortcut);
         ShortcutHandler.SendShortcutBarRemovedMessage(this.Owner.Client, barType, slot);
     }
 }
Пример #6
0
        private void RemoveInternal(Shortcut shortcut)
        {
            if (shortcut is SpellShortcut)
            {
                m_spellShortcuts.Remove(shortcut.Slot);
                return;
            }

            if (shortcut is ItemShortcut)
            {
                m_itemShortcuts.Remove(shortcut.Slot);
                return;
            }

            if (shortcut is PresetShortcut)
            {
                m_presetShortcuts.Remove(shortcut.Slot);
                return;
            }
        }
Пример #7
0
 public void SwapShortcuts(ShortcutBarEnum barType, int slot, int newSlot)
 {
     if (!this.IsSlotFree(slot, barType))
     {
         Stump.Server.WorldServer.Database.Shortcuts.Shortcut shortcut  = this.GetShortcut(barType, slot);
         Stump.Server.WorldServer.Database.Shortcuts.Shortcut shortcut2 = this.GetShortcut(barType, newSlot);
         this.RemoveInternal(shortcut);
         this.RemoveInternal(shortcut2);
         if (shortcut2 != null)
         {
             shortcut2.Slot = slot;
             this.AddInternal(shortcut2);
             ShortcutHandler.SendShortcutBarRefreshMessage(this.Owner.Client, barType, shortcut2);
         }
         else
         {
             ShortcutHandler.SendShortcutBarRemovedMessage(this.Owner.Client, barType, slot);
         }
         shortcut.Slot = newSlot;
         this.AddInternal(shortcut);
         ShortcutHandler.SendShortcutBarRefreshMessage(this.Owner.Client, barType, shortcut);
     }
 }
Пример #8
0
        public void Save()
        {
            lock (this.m_locker)
            {
                Stump.ORM.Database database = ServerBase <WorldServer> .Instance.DBAccessor.Database;
                foreach (System.Collections.Generic.KeyValuePair <int, ItemShortcut> current in this.m_itemShortcuts)
                {
                    if (current.Value.IsDirty || current.Value.IsNew)
                    {
                        database.Save(current.Value);
                    }
                }
                using (System.Collections.Generic.Dictionary <int, SpellShortcut> .Enumerator enumerator2 = this.m_spellShortcuts.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        System.Collections.Generic.KeyValuePair <int, SpellShortcut> current2 = enumerator2.Current;
                        if (current2.Value.IsDirty || current2.Value.IsNew)
                        {
                            database.Save(current2.Value);
                        }
                    }
                    goto IL_FD;
                }
IL_E3:
                Stump.Server.WorldServer.Database.Shortcuts.Shortcut shortcut = this.m_shortcutsToDelete.Dequeue();
                if (shortcut != null)
                {
                    database.Delete(shortcut);
                }
IL_FD:
                if (this.m_shortcutsToDelete.Count > 0)
                {
                    goto IL_E3;
                }
            }
        }