예제 #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;
            }
        }
예제 #2
0
        public ActionBarButtonPressedEventArgs(ActionBarIndex index)
        {
            if (!Enum.IsDefined(typeof(ActionBarIndex), index))
            {
                throw new InvalidEnumArgumentException(nameof(index), (int)index, typeof(ActionBarIndex));
            }

            Index = index;
        }
예제 #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;
        }
예제 #4
0
 public bool IsSet(ActionBarIndex index)
 {
     if (BackingCollection.ContainsKey(index))
     {
         return(BackingCollection[index].Type != ActionBarIndexType.Empty);
     }
     else
     {
         return(false);
     }
 }
예제 #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));
        }
예제 #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;
        }
예제 #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;
        }
예제 #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;
        }
예제 #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;
        }
예제 #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.");
                }
            }
        }
예제 #11
0
 public IUIActionBarButton this[ActionBarIndex key] => ActionBarCollection[key];
예제 #12
0
 public bool TryGetValue(ActionBarIndex key, out IUIActionBarButton value)
 {
     return(ActionBarCollection.TryGetValue(key, out value));
 }
예제 #13
0
 public bool ContainsKey(ActionBarIndex key)
 {
     return(ActionBarCollection.ContainsKey(key));
 }
예제 #14
0
 protected abstract void OnActionBarButtonPressed(ActionBarIndex index);
예제 #15
0
 public CharacterActionBarInstanceModel this[ActionBarIndex index] => IsSet(index) ? BackingCollection[index] : new CharacterActionBarInstanceModel(index, ActionBarIndexType.Empty, 0);