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; } }
public ActionBarButtonPressedEventArgs(ActionBarIndex index) { if (!Enum.IsDefined(typeof(ActionBarIndex), index)) { throw new InvalidEnumArgumentException(nameof(index), (int)index, typeof(ActionBarIndex)); } Index = index; }
public ActionBarButtonStateChangedEventArgs(ActionBarIndex index) { if (!Enum.IsDefined(typeof(ActionBarIndex), index)) { throw new InvalidEnumArgumentException(nameof(index), (int)index, typeof(ActionBarIndex)); } ActionType = ActionBarIndexType.Empty; Index = index; }
public bool IsSet(ActionBarIndex index) { if (BackingCollection.ContainsKey(index)) { return(BackingCollection[index].Type != ActionBarIndexType.Empty); } else { return(false); } }
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)); }
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; }
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; }
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; }
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; }
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."); } } }
public IUIActionBarButton this[ActionBarIndex key] => ActionBarCollection[key];
public bool TryGetValue(ActionBarIndex key, out IUIActionBarButton value) { return(ActionBarCollection.TryGetValue(key, out value)); }
public bool ContainsKey(ActionBarIndex key) { return(ActionBarCollection.ContainsKey(key)); }
protected abstract void OnActionBarButtonPressed(ActionBarIndex index);
public CharacterActionBarInstanceModel this[ActionBarIndex index] => IsSet(index) ? BackingCollection[index] : new CharacterActionBarInstanceModel(index, ActionBarIndexType.Empty, 0);