Exemplo n.º 1
0
        private void Start()
        {
            if (ActionBarButtons.Count <= 0)
            {
                throw new InvalidOperationException($"Cannot have actionbar row with 0 actionbar buttons.");
            }

            if ((int)_endIndex < (int)_startIndex)
            {
                throw new InvalidOperationException($"Cannot have {nameof(ActionBarIndex)} end lower than start.");
            }

            ActionBarIndex index = (ActionBarIndex)(StartIndex);

            foreach (var barButton in ActionBarButtons)
            {
                //For copying, static analysis warning.
                var index1 = index;

                barButton.ActionBarButton.AddOnClickListener(() => PressPublisher.PublishEvent(this, new ActionBarButtonPressedEventArgs(index1)));
                ActionBarCollection.Add(index, barButton);

                index += 1;
            }
        }
Exemplo n.º 2
0
        public ActionBarButtonPressedEventArgs(ActionBarIndex index)
        {
            if (!Enum.IsDefined(typeof(ActionBarIndex), index))
            {
                throw new InvalidEnumArgumentException(nameof(index), (int)index, typeof(ActionBarIndex));
            }

            Index = index;
        }
Exemplo n.º 3
0
        public ActionBarButtonStateChangedEventArgs(ActionBarIndex index)
        {
            if (!Enum.IsDefined(typeof(ActionBarIndex), index))
            {
                throw new InvalidEnumArgumentException(nameof(index), (int)index, typeof(ActionBarIndex));
            }

            ActionType = ActionBarIndexType.Empty;
            Index      = index;
        }
Exemplo n.º 4
0
 public bool IsSet(ActionBarIndex index)
 {
     if (BackingCollection.ContainsKey(index))
     {
         return(BackingCollection[index].Type != ActionBarIndexType.Empty);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 5
0
        public static CharacterActionBarInstanceModel CreateSpellAction(ActionBarIndex barIndex, int actionId)
        {
            if (!Enum.IsDefined(typeof(ActionBarIndex), barIndex))
            {
                throw new InvalidEnumArgumentException(nameof(barIndex), (int)barIndex, typeof(ActionBarIndex));
            }
            if (actionId < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(actionId));
            }

            return(new CharacterActionBarInstanceModel(barIndex, ActionBarIndexType.Spell, actionId));
        }
Exemplo n.º 6
0
        public ActionBarButtonStateChangedEventArgs(ActionBarIndex index, ActionBarIndexType actionType, int actionId)
        {
            if (!Enum.IsDefined(typeof(ActionBarIndex), index))
            {
                throw new InvalidEnumArgumentException(nameof(index), (int)index, typeof(ActionBarIndex));
            }
            if (actionId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(actionId));
            }

            Index      = index;
            ActionType = actionType;
            ActionId   = actionId;
        }
Exemplo n.º 7
0
        public CharacterDefaultActionBarEntry(EntityPlayerClassType classType, ActionBarIndex barIndex, int linkedSpellId)
        {
            if (!Enum.IsDefined(typeof(ActionBarIndex), barIndex))
            {
                throw new InvalidEnumArgumentException(nameof(barIndex), (int)barIndex, typeof(ActionBarIndex));
            }
            if (linkedSpellId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(linkedSpellId));
            }
            if (!Enum.IsDefined(typeof(EntityPlayerClassType), classType))
            {
                throw new InvalidEnumArgumentException(nameof(classType), (int)classType, typeof(EntityPlayerClassType));
            }

            BarIndex      = barIndex;
            LinkedSpellId = linkedSpellId;
        }
Exemplo n.º 8
0
        public CharacterActionBarEntry(int characterId, ActionBarIndex barIndex, int linkedSpellId)
        {
            if (characterId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(characterId));
            }
            if (!Enum.IsDefined(typeof(ActionBarIndex), barIndex))
            {
                throw new InvalidEnumArgumentException(nameof(barIndex), (int)barIndex, typeof(ActionBarIndex));
            }
            if (linkedSpellId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(linkedSpellId));
            }

            CharacterId   = characterId;
            BarIndex      = barIndex;
            LinkedSpellId = linkedSpellId;
        }
Exemplo n.º 9
0
        public CharacterActionBarInstanceModel(ActionBarIndex barIndex, ActionBarIndexType type, int actionId)
        {
            if (!Enum.IsDefined(typeof(ActionBarIndex), barIndex))
            {
                throw new InvalidEnumArgumentException(nameof(barIndex), (int)barIndex, typeof(ActionBarIndex));
            }
            if (!Enum.IsDefined(typeof(ActionBarIndexType), type))
            {
                throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(ActionBarIndexType));
            }
            if (actionId < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(actionId));
            }

            BarIndex = barIndex;
            Type     = type;
            ActionId = actionId;
        }
Exemplo n.º 10
0
        protected override void OnActionBarButtonPressed(ActionBarIndex index)
        {
            //If we have a set index then we can just send the request to interact/cast
            if (ActionBarCollection.IsSet(index))
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug($"Action bar Index: {index} pressed.");
                }

                if (ActionBarCollection[index].Type == ActionBarIndexType.Spell)
                {
                    SendService.SendMessage(new SpellCastRequestPayload(ActionBarCollection[index].ActionId));
                }
            }
            else
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug($"Action bar Index: {index} pressed but no associated action.");
                }
            }
        }
Exemplo n.º 11
0
 public IUIActionBarButton this[ActionBarIndex key] => ActionBarCollection[key];
Exemplo n.º 12
0
 public bool TryGetValue(ActionBarIndex key, out IUIActionBarButton value)
 {
     return(ActionBarCollection.TryGetValue(key, out value));
 }
Exemplo n.º 13
0
 public bool ContainsKey(ActionBarIndex key)
 {
     return(ActionBarCollection.ContainsKey(key));
 }
Exemplo n.º 14
0
 protected abstract void OnActionBarButtonPressed(ActionBarIndex index);
Exemplo n.º 15
0
 public CharacterActionBarInstanceModel this[ActionBarIndex index] => IsSet(index) ? BackingCollection[index] : new CharacterActionBarInstanceModel(index, ActionBarIndexType.Empty, 0);