コード例 #1
0
ファイル: ShortcutBar.cs プロジェクト: Mixi59/Stump
        public void RemoveShortcut(ShortcutBarEnum barType, int slot)
        {
            var shortcut = GetShortcut(barType, slot);

            if (shortcut == null)
            {
                return;
            }

            switch (barType)
            {
            case ShortcutBarEnum.SPELL_SHORTCUT_BAR:
                m_spellShortcuts.Remove(slot);
                break;

            case ShortcutBarEnum.GENERAL_SHORTCUT_BAR:
            {
                if (shortcut is ItemShortcut)
                {
                    m_itemShortcuts.Remove(slot);
                }
                else if (shortcut is PresetShortcut)
                {
                    m_presetShortcuts.Remove(slot);
                }
            }

            break;
            }
            m_shortcutsToDelete.Enqueue(shortcut);

            ShortcutHandler.SendShortcutBarRemovedMessage(Owner.Client, barType, slot);
        }
コード例 #2
0
ファイル: ShortcutBar.cs プロジェクト: Mixi59/Stump
        public void SwapShortcuts(ShortcutBarEnum barType, int slot, int newSlot)
        {
            if (IsSlotFree(slot, barType))
            {
                return;
            }

            var shortcutToSwitch    = GetShortcut(barType, slot);
            var shortcutDestination = GetShortcut(barType, newSlot);

            RemoveInternal(shortcutToSwitch);
            RemoveInternal(shortcutDestination);

            if (shortcutDestination != null)
            {
                shortcutDestination.Slot = slot;
                AddInternal(shortcutDestination);
                ShortcutHandler.SendShortcutBarRefreshMessage(Owner.Client, barType, shortcutDestination);
            }
            else
            {
                ShortcutHandler.SendShortcutBarRemovedMessage(Owner.Client, barType, slot);
            }

            shortcutToSwitch.Slot = newSlot;
            AddInternal(shortcutToSwitch);
            ShortcutHandler.SendShortcutBarRefreshMessage(Owner.Client, barType, shortcutToSwitch);
        }
コード例 #3
0
ファイル: ShortcutBar.cs プロジェクト: Mixi59/Stump
        public void AddShortcut(ShortcutBarEnum barType, DofusProtocol.Types.Shortcut shortcut)
        {
            // do not ask me why i use a sbyte, they are f*****g idiots
            if (shortcut is ShortcutSpell && barType == ShortcutBarEnum.SPELL_SHORTCUT_BAR)
            {
                AddSpellShortcut(shortcut.slot, ((ShortcutSpell)shortcut).spellId);
            }
            else if (shortcut is ShortcutObjectItem && barType == ShortcutBarEnum.GENERAL_SHORTCUT_BAR)
            {
                var item = Owner.Inventory.TryGetItem(((ShortcutObjectItem)shortcut).itemUID);

                if (item != null)
                {
                    AddItemShortcut(shortcut.slot, item);
                }
                else
                {
                    ShortcutHandler.SendShortcutBarAddErrorMessage(Owner.Client);
                }
            }
            else if (shortcut is ShortcutObjectPreset && barType == ShortcutBarEnum.GENERAL_SHORTCUT_BAR)
            {
                AddPresetShortcut(shortcut.slot, ((ShortcutObjectPreset)shortcut).presetId);
            }
            else
            {
                ShortcutHandler.SendShortcutBarAddErrorMessage(Owner.Client);
            }
        }
コード例 #4
0
ファイル: ShortcutBar.cs プロジェクト: Mixi59/Stump
        public int GetNextFreeSlot(ShortcutBarEnum barType)
        {
            for (var i = 0; i < MaxSlot; i++)
            {
                if (IsSlotFree(i, barType))
                {
                    return(i);
                }
            }

            return(MaxSlot);
        }
コード例 #5
0
ファイル: ShortcutBar.cs プロジェクト: Mixi59/Stump
        public bool IsSlotFree(int slot, ShortcutBarEnum barType)
        {
            switch (barType)
            {
            case ShortcutBarEnum.SPELL_SHORTCUT_BAR:
                return(!m_spellShortcuts.ContainsKey(slot));

            case ShortcutBarEnum.GENERAL_SHORTCUT_BAR:
                return(!m_itemShortcuts.ContainsKey(slot) && !m_presetShortcuts.ContainsKey(slot));
            }

            return(true);
        }
コード例 #6
0
        public bool IsSlotFree(int slot, ShortcutBarEnum barType)
        {
            bool result;

            if (barType == ShortcutBarEnum.SPELL_SHORTCUT_BAR)
            {
                result = !this.m_spellShortcuts.ContainsKey(slot);
            }
            else
            {
                result = (barType != ShortcutBarEnum.GENERAL_SHORTCUT_BAR || !this.m_itemShortcuts.ContainsKey(slot));
            }
            return(result);
        }
コード例 #7
0
ファイル: ShortcutBar.cs プロジェクト: Mixi59/Stump
        public IEnumerable <Shortcut> GetShortcuts(ShortcutBarEnum barType)
        {
            switch (barType)
            {
            case ShortcutBarEnum.SPELL_SHORTCUT_BAR:
                return(m_spellShortcuts.Values);

            case ShortcutBarEnum.GENERAL_SHORTCUT_BAR:
                return(m_itemShortcuts.Values.Concat <Shortcut>(m_presetShortcuts.Values));

            default:
                return(new Shortcut[0]);
            }
        }
コード例 #8
0
        public int GetNextFreeSlot(ShortcutBarEnum barType)
        {
            int result;

            for (int i = 0; i < 40; i++)
            {
                if (this.IsSlotFree(i, barType))
                {
                    result = i;
                    return(result);
                }
            }
            result = 40;
            return(result);
        }
コード例 #9
0
 public void AddShortcut(ShortcutBarEnum barType, Stump.DofusProtocol.Types.Shortcut shortcut)
 {
     if (shortcut is ShortcutSpell && barType == ShortcutBarEnum.SPELL_SHORTCUT_BAR)
     {
         this.AddSpellShortcut(shortcut.slot, (short)(shortcut as ShortcutSpell).spellId);
     }
     else
     {
         if (shortcut is ShortcutObjectItem && barType == ShortcutBarEnum.GENERAL_SHORTCUT_BAR)
         {
             this.AddItemShortcut(shortcut.slot, this.Owner.Inventory.TryGetItem((shortcut as ShortcutObjectItem).itemUID));
         }
         else
         {
             ShortcutHandler.SendShortcutBarAddErrorMessage(this.Owner.Client);
         }
     }
 }
コード例 #10
0
        public Stump.Server.WorldServer.Database.Shortcuts.Shortcut GetShortcut(ShortcutBarEnum barType, int slot)
        {
            Stump.Server.WorldServer.Database.Shortcuts.Shortcut result;
            switch (barType)
            {
            case ShortcutBarEnum.GENERAL_SHORTCUT_BAR:
                result = this.GetItemShortcut(slot);
                break;

            case ShortcutBarEnum.SPELL_SHORTCUT_BAR:
                result = this.GetSpellShortcut(slot);
                break;

            default:
                result = null;
                break;
            }
            return(result);
        }
コード例 #11
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);
     }
 }
コード例 #12
0
ファイル: ShortcutBar.cs プロジェクト: Mixi59/Stump
        public Shortcut GetShortcut(ShortcutBarEnum barType, int slot)
        {
            switch (barType)
            {
            case ShortcutBarEnum.SPELL_SHORTCUT_BAR:
                return(GetSpellShortcut(slot));

            case ShortcutBarEnum.GENERAL_SHORTCUT_BAR:
            {
                var shortcut = GetItemShortcut(slot);
                if (shortcut == null)
                {
                    return(GetPresetShortcut(slot));
                }

                return(shortcut);
            }

            default:
                return(null);
            }
        }
コード例 #13
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);
     }
 }
コード例 #14
0
 public static void SendShortcutBarRefreshMessage(IPacketReceiver client, ShortcutBarEnum barType, Shortcut shortcut)
 {
     client.Send(new ShortcutBarRefreshMessage((sbyte)barType, shortcut.GetNetworkShortcut()));
 }
コード例 #15
0
 public static void SendShortcutBarContentMessage(WorldClient client, ShortcutBarEnum barType)
 {
     client.Send(new ShortcutBarContentMessage((sbyte)barType,
                                               client.Character.Shortcuts.GetShortcuts(barType).Select(entry => entry.GetNetworkShortcut())));
 }
コード例 #16
0
 public static void SendShortcutBarContentMessage(WorldClient client, IEnumerable <DofusProtocol.Types.Shortcut> shortcuts, ShortcutBarEnum barType)
 {
     client.Send(new ShortcutBarContentMessage((sbyte)barType, shortcuts));
 }
コード例 #17
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);
        }
コード例 #18
0
 public static void SendShortcutBarRemovedMessage(IPacketReceiver client, ShortcutBarEnum barType, int slot)
 {
     client.Send(new ShortcutBarRemovedMessage((sbyte)barType, (sbyte)slot));
 }