Esempio n. 1
0
 public ActionModelBase(ActionTypeEnum type)
 {
     this.ID      = Guid.NewGuid();
     this.Type    = type;
     this.Name    = EnumLocalizationHelper.GetLocalizedName(this.Type);
     this.Enabled = true;
 }
Esempio n. 2
0
        public override Task OnLoaded()
        {
            this.TypeComboBox.ItemsSource = Enum.GetValues(typeof(CommandActionTypeEnum))
                                            .Cast <CommandActionTypeEnum>()
                                            .OrderBy(s => EnumLocalizationHelper.GetLocalizedName(s));

            List <string> types = new List <string>(ChannelSession.AllCommands.Select(c => EnumLocalizationHelper.GetLocalizedName(c.Type)).Distinct());

            types.Add(PreMadeCommandType);
            this.CommandTypeComboBox.ItemsSource = types.OrderBy(s => s);

            this.CommandGroupNameComboBox.ItemsSource = ChannelSession.Settings.CommandGroups.Keys;

            this.CommandNameComboBox.ItemsSource = ChannelSession.AllCommands.OrderBy(c => c.Name);
            if (this.command != null)
            {
                CommandBase chosenCommand = this.command.Command;
                this.TypeComboBox.SelectedItem = this.command.CommandActionType;
                if (chosenCommand != null)
                {
                    string type = EnumLocalizationHelper.GetLocalizedName(chosenCommand.Type);
                    if (chosenCommand is PreMadeChatCommand)
                    {
                        type = PreMadeCommandType;
                    }
                    this.CommandTypeComboBox.SelectedItem = type;
                    this.CommandNameComboBox.SelectedItem = chosenCommand;
                }
                this.CommandGroupNameComboBox.SelectedItem = this.command.GroupName;
                this.CommandArgumentsTextBox.Text          = this.command.CommandArguments;
            }
            return(Task.FromResult(0));
        }
 public override Task OnLoaded()
 {
     this.FileActionTypeComboBox.ItemsSource = Enum.GetValues(typeof(FileActionTypeEnum))
                                               .Cast <FileActionTypeEnum>()
                                               .OrderBy(s => EnumLocalizationHelper.GetLocalizedName(s));
     if (this.action != null)
     {
         this.FileActionTypeComboBox.SelectedItem = this.action.FileActionType;
         if (this.action.FileActionType == FileActionTypeEnum.SaveToFile || this.action.FileActionType == FileActionTypeEnum.AppendToFile)
         {
             this.SaveToFileTextTextBox.Text = this.action.TransferText;
         }
         else if (this.action.FileActionType == FileActionTypeEnum.ReadFromFile || this.action.FileActionType == FileActionTypeEnum.ReadSpecificLineFromFile ||
                  this.action.FileActionType == FileActionTypeEnum.ReadRandomLineFromFile || this.action.FileActionType == FileActionTypeEnum.RemoveSpecificLineFromFile ||
                  this.action.FileActionType == FileActionTypeEnum.RemoveRandomLineFromFile)
         {
             this.SpecialIdentifierNameTextBox.Text = this.action.TransferText;
             if (this.action.FileActionType == FileActionTypeEnum.ReadSpecificLineFromFile || this.action.FileActionType == FileActionTypeEnum.RemoveSpecificLineFromFile)
             {
                 this.SpecificLineTextBox.Text = this.action.LineIndexToRead;
             }
         }
         this.FilePathTextBox.Text = this.action.FilePath;
     }
     return(Task.FromResult(0));
 }
 public async Task SendNotMetWhisper(UserViewModel user)
 {
     if (ChannelSession.Services.Chat != null)
     {
         string role = EnumLocalizationHelper.GetLocalizedName(this.MixerRole);
         if (this.MixerRole == UserRoleEnum.Subscriber && this.SubscriberTier > 0)
         {
             role += " - " + RoleRequirementViewModel.SubTierNames[this.SubscriberTier - 1];
         }
         await ChannelSession.Services.Chat.SendMessage(string.Format(MixItUp.Base.Resources.RoleErrorInsufficientRole, role));
     }
 }
 public override Task OnLoaded()
 {
     this.GameQueueActionTypeComboBox.ItemsSource = Enum.GetValues(typeof(GameQueueActionType))
                                                    .Cast <GameQueueActionType>()
                                                    .OrderBy(s => EnumLocalizationHelper.GetLocalizedName(s));
     if (this.action != null)
     {
         this.GameQueueActionTypeComboBox.SelectedItem = this.action.GameQueueType;
         this.RoleRequirement.SetRoleRequirement(this.action.RoleRequirement);
         this.TargetUsernameTextBox.Text = this.action.TargetUsername;
     }
     return(Task.FromResult(0));
 }
Esempio n. 6
0
        protected override async Task OnLoaded()
        {
            if (!hasLoaded)
            {
                List <ActionTypeEnum> actionTypes = new List <ActionTypeEnum>(EnumHelper.GetEnumList <ActionTypeEnum>());
                actionTypes.Remove(ActionTypeEnum.Custom);
                foreach (ActionTypeEnum hiddenActions in ChannelSession.Settings.ActionsToHide)
                {
                    actionTypes.Remove(hiddenActions);
                }

                this.TypeComboBox.ItemsSource        = actionTypes.OrderBy(at => EnumLocalizationHelper.GetLocalizedName(at));
                this.ActionsItemsControl.ItemsSource = this.actionControls;

                this.CommandDetailsGrid.Visibility = Visibility.Visible;
                this.CommandDetailsGrid.Children.Add(this.commandDetailsControl);
                await this.commandDetailsControl.Initialize();

                List <ActionBase> actions = new List <ActionBase>();

                CommandBase command = this.commandDetailsControl.GetExistingCommand();
                if (command != null && command.Actions.Count > 0)
                {
                    actions.AddRange(command.Actions);
                }
                else if (initialActions != null)
                {
                    actions.AddRange(initialActions);
                }

                // Remove all deprecated actions
                actions.RemoveAll(a => a is SongRequestAction || a is SpotifyAction || a is InteractiveAction || a is MixerClipsAction);

                foreach (ActionBase action in actions)
                {
                    ActionContainerControl actionControl = new ActionContainerControl(this.window, this, action);
                    actionControl.Minimize();
                    this.actionControls.Add(actionControl);
                }
            }

            hasLoaded = true;
            await base.OnLoaded();
        }
Esempio n. 7
0
        public CommandsSettingsControlViewModel()
        {
            this.AllowCommandWhispering = new GenericToggleSettingsOptionControlViewModel(MixItUp.Base.Resources.AllowCommandsToBeWhispered,
                                                                                          ChannelSession.Settings.AllowCommandWhispering, (value) => { ChannelSession.Settings.AllowCommandWhispering = value; });
            this.IgnoreBotAccount = new GenericToggleSettingsOptionControlViewModel(MixItUp.Base.Resources.IgnoreYourBotAccountForCommands,
                                                                                    ChannelSession.Settings.IgnoreBotAccountCommands, (value) => { ChannelSession.Settings.IgnoreBotAccountCommands = value; });
            this.DeleteChatCommandsWhenRun = new GenericToggleSettingsOptionControlViewModel(MixItUp.Base.Resources.DeleteChatCommandsWhenRun,
                                                                                             ChannelSession.Settings.DeleteChatCommandsWhenRun, (value) => { ChannelSession.Settings.DeleteChatCommandsWhenRun = value; });
            this.CommandLockSystem = new GenericComboBoxSettingsOptionControlViewModel <CommandServiceLockTypeEnum>(MixItUp.Base.Resources.CommandLockSystem, EnumHelper.GetEnumList <CommandServiceLockTypeEnum>(),
                                                                                                                    ChannelSession.Settings.CommandServiceLockType, (value) => { ChannelSession.Settings.CommandServiceLockType = value; }, MixItUp.Base.Resources.CommandLockSystemTooltip);

            this.RequirementErrorsCooldownType = new GenericComboBoxSettingsOptionControlViewModel <RequirementErrorCooldownTypeEnum>(MixItUp.Base.Resources.RequirementErrorsCooldownType, EnumHelper.GetEnumList <RequirementErrorCooldownTypeEnum>(),
                                                                                                                                      ChannelSession.Settings.RequirementErrorsCooldownType, (value) => { ChannelSession.Settings.RequirementErrorsCooldownType = value; }, MixItUp.Base.Resources.RequirementErrorsCooldownTypeTooltip);
            this.RequirementErrorsCooldownAmount = new GenericNumberSettingsOptionControlViewModel(MixItUp.Base.Resources.RequirementErrorsCooldownAmount,
                                                                                                   ChannelSession.Settings.RequirementErrorsCooldownAmount, (value) => { ChannelSession.Settings.RequirementErrorsCooldownAmount = value; });
            this.IncludeUsernameWithRequirementErrors = new GenericToggleSettingsOptionControlViewModel(MixItUp.Base.Resources.IncludeUsernameWithRequirementErrors,
                                                                                                        ChannelSession.Settings.IncludeUsernameWithRequirementErrors, (value) => { ChannelSession.Settings.IncludeUsernameWithRequirementErrors = value; });

            this.TwitchMassGiftedSubsFilterAmount = new GenericToggleNumberSettingsOptionControlViewModel(MixItUp.Base.Resources.TwitchMassGiftedSubsFilterAmount, ChannelSession.Settings.TwitchMassGiftedSubsFilterAmount,
                                                                                                          (value) => { ChannelSession.Settings.TwitchMassGiftedSubsFilterAmount = value; }, MixItUp.Base.Resources.TwitchMassGiftedSubsFilterAmountTooltip);
            this.TwitchReplyToCommandChatMessages = new GenericToggleSettingsOptionControlViewModel(MixItUp.Base.Resources.TwitchReplyToCommandChatMessages, ChannelSession.Settings.TwitchReplyToCommandChatMessages,
                                                                                                    (value) => { ChannelSession.Settings.TwitchReplyToCommandChatMessages = value; });

            List <ActionTypeEnum> actions = new List <ActionTypeEnum>(EnumHelper.GetEnumList <ActionTypeEnum>());

            actions.Remove(ActionTypeEnum.Custom);
            foreach (ActionTypeEnum action in actions.OrderBy(at => EnumLocalizationHelper.GetLocalizedName(at)))
            {
                string name = EnumHelper.GetEnumName(action);
                name = MixItUp.Base.Resources.ResourceManager.GetSafeString(name);
                this.HideActionsList.Add(new GenericToggleSettingsOptionControlViewModel(name, ChannelSession.Settings.ActionsToHide.Contains(action),
                                                                                         (value) =>
                {
                    if (value)
                    {
                        ChannelSession.Settings.ActionsToHide.Add(action);
                    }
                    else
                    {
                        ChannelSession.Settings.ActionsToHide.Remove(action);
                    }
                }));
            }
        }
Esempio n. 8
0
 private void CommandTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.CommandTypeComboBox.SelectedIndex >= 0)
     {
         string typeString = (string)this.CommandTypeComboBox.SelectedItem;
         if (typeString.Equals(PreMadeCommandType))
         {
             this.CommandNameComboBox.ItemsSource = ChannelSession.AllCommands.Where(c => c is PreMadeChatCommand && c.Type == CommandTypeEnum.Chat).OrderBy(c => c.Name);
         }
         else if (typeString.Equals(EnumLocalizationHelper.GetLocalizedName(CommandTypeEnum.Chat)))
         {
             this.CommandNameComboBox.ItemsSource = ChannelSession.AllCommands.Where(c => !(c is PreMadeChatCommand) && c.Type == CommandTypeEnum.Chat).OrderBy(c => c.Name);
         }
         else
         {
             this.CommandNameComboBox.ItemsSource = ChannelSession.AllCommands.Where(c => typeString.Equals(EnumLocalizationHelper.GetLocalizedName(c.Type))).OrderBy(c => c.Name);
         }
     }
 }
        private async Task SendErrorMessage()
        {
            string role = EnumLocalizationHelper.GetLocalizedName(this.Role);

            if (this.Role == UserRoleEnum.Subscriber)
            {
                string tierText = string.Empty;
                switch (this.SubscriberTier)
                {
                case 1: tierText = MixItUp.Base.Resources.Tier1; break;

                case 2: tierText = MixItUp.Base.Resources.Tier2; break;

                case 3: tierText = MixItUp.Base.Resources.Tier3; break;
                }
                role = tierText + " " + role;
            }
            await this.SendChatMessage(string.Format(MixItUp.Base.Resources.RoleErrorInsufficientRole, role));
        }
Esempio n. 10
0
        public CommandsSettingsControlViewModel()
        {
            this.AllowCommandWhispering = new GenericToggleSettingsOptionControlViewModel(MixItUp.Base.Resources.AllowCommandsToBeWhispered,
                                                                                          ChannelSession.Settings.AllowCommandWhispering, (value) => { ChannelSession.Settings.AllowCommandWhispering = value; });

            this.IgnoreBotAccount = new GenericToggleSettingsOptionControlViewModel(MixItUp.Base.Resources.IgnoreYourBotAccountForCommands,
                                                                                    ChannelSession.Settings.IgnoreBotAccountCommands, (value) => { ChannelSession.Settings.IgnoreBotAccountCommands = value; });

            this.DeleteChatCommandsWhenRun = new GenericToggleSettingsOptionControlViewModel(MixItUp.Base.Resources.DeleteChatCommandsWhenRun,
                                                                                             ChannelSession.Settings.DeleteChatCommandsWhenRun, (value) => { ChannelSession.Settings.DeleteChatCommandsWhenRun = value; });

            this.UnlockAllCommandTypes = new GenericToggleSettingsOptionControlViewModel(MixItUp.Base.Resources.UnlockAllCommandTypes,
                                                                                         ChannelSession.Settings.UnlockAllCommands, (value) => { ChannelSession.Settings.UnlockAllCommands = value; }, MixItUp.Base.Resources.UnlockAllCommandTypesTooltip);

            this.TwitchMassGiftedSubsFilterAmount = new GenericToggleNumberSettingsOptionControlViewModel(MixItUp.Base.Resources.TwitchMassGiftedSubsFilterAmount, ChannelSession.Settings.TwitchMassGiftedSubsFilterAmount,
                                                                                                          (value) => { ChannelSession.Settings.TwitchMassGiftedSubsFilterAmount = value; }, MixItUp.Base.Resources.TwitchMassGiftedSubsFilterAmountTooltip);

            List <ActionTypeEnum> actions = new List <ActionTypeEnum>(EnumHelper.GetEnumList <ActionTypeEnum>());

            actions.Remove(ActionTypeEnum.Custom);
            foreach (ActionTypeEnum action in actions.OrderBy(at => EnumLocalizationHelper.GetLocalizedName(at)))
            {
                string name = EnumHelper.GetEnumName(action);
                name = MixItUp.Base.Resources.ResourceManager.GetString(name) ?? name;
                this.HideActionsList.Add(new GenericToggleSettingsOptionControlViewModel(name, ChannelSession.Settings.ActionsToHide.Contains(action),
                                                                                         (value) =>
                {
                    if (value)
                    {
                        ChannelSession.Settings.ActionsToHide.Add(action);
                    }
                    else
                    {
                        ChannelSession.Settings.ActionsToHide.Remove(action);
                    }
                }));
            }
        }
        public override Task OnLoaded()
        {
            List <object> currencyInventoryList = new List <object>();

            currencyInventoryList.AddRange(ChannelSession.Settings.Currency.Values);
            currencyInventoryList.AddRange(ChannelSession.Settings.Inventory.Values);
            currencyInventoryList.AddRange(ChannelSession.Settings.StreamPass.Values);
            this.CurrencyTypeComboBox.ItemsSource       = currencyInventoryList;
            this.CurrencyActionTypeComboBox.ItemsSource = Enum.GetValues(typeof(CurrencyActionTypeEnum))
                                                          .Cast <CurrencyActionTypeEnum>()
                                                          .OrderBy(s => EnumLocalizationHelper.GetLocalizedName(s));
            this.CurrencyPermissionsAllowedComboBox.ItemsSource = MixItUp.Base.ViewModel.Requirements.RoleRequirementViewModel.SelectableUserRoles();

            this.CurrencyPermissionsAllowedComboBox.SelectedIndex = 0;

            if (this.action != null)
            {
                if (this.action.CurrencyID != Guid.Empty && ChannelSession.Settings.Currency.ContainsKey(this.action.CurrencyID))
                {
                    this.CurrencyTypeComboBox.SelectedItem = ChannelSession.Settings.Currency[this.action.CurrencyID];
                }
                else if (this.action.InventoryID != Guid.Empty && ChannelSession.Settings.Inventory.ContainsKey(this.action.InventoryID))
                {
                    this.CurrencyTypeComboBox.SelectedItem = ChannelSession.Settings.Inventory[this.action.InventoryID];
                }
                else if (this.action.StreamPassID != Guid.Empty && ChannelSession.Settings.StreamPass.ContainsKey(this.action.StreamPassID))
                {
                    this.CurrencyTypeComboBox.SelectedItem = ChannelSession.Settings.StreamPass[this.action.StreamPassID];
                }
                this.CurrencyActionTypeComboBox.SelectedItem = this.action.CurrencyActionType;
                this.InventoryItemNameComboBox.Text          = this.action.ItemName;
                this.CurrencyAmountTextBox.Text   = this.action.Amount;
                this.CurrencyUsernameTextBox.Text = this.action.Username;
                this.CurrencyPermissionsAllowedComboBox.SelectedItem = this.action.RoleRequirement;
                this.DeductFromUserToggleButton.IsChecked            = this.action.DeductFromUser;
            }
            return(Task.FromResult(0));
        }
Esempio n. 12
0
        private Result CreateErrorMessage(CommandParametersModel parameters)
        {
            string role = EnumLocalizationHelper.GetLocalizedName(this.Role);

            if (this.Role == UserRoleEnum.Subscriber)
            {
                string tierText = string.Empty;
                switch (this.SubscriberTier)
                {
                case 1: tierText = MixItUp.Base.Resources.Tier1; break;

                case 2: tierText = MixItUp.Base.Resources.Tier2; break;

                case 3: tierText = MixItUp.Base.Resources.Tier3; break;
                }
                role = tierText + " " + role;
            }
            else if (this.Role == UserRoleEnum.VIPExclusive)
            {
                role = EnumLocalizationHelper.GetLocalizedName(UserRoleEnum.VIP);
            }
            return(new Result(string.Format(MixItUp.Base.Resources.RoleErrorInsufficientRole, role)));
        }
Esempio n. 13
0
        private string GetRoleName(UserRoleEnum role)
        {
            string roleName = EnumLocalizationHelper.GetLocalizedName(role);

            if (role == UserRoleEnum.Subscriber)
            {
                string tierText = string.Empty;
                switch (this.SubscriberTier)
                {
                case 1: tierText = MixItUp.Base.Resources.Tier1; break;

                case 2: tierText = MixItUp.Base.Resources.Tier2; break;

                case 3: tierText = MixItUp.Base.Resources.Tier3; break;
                }
                roleName = tierText + " " + roleName;
            }
            else if (role == UserRoleEnum.VIPExclusive)
            {
                roleName = EnumLocalizationHelper.GetLocalizedName(UserRoleEnum.VIP);
            }
            return(roleName);
        }
Esempio n. 14
0
#pragma warning disable CS0612 // Type or member is obsolete
        internal static IEnumerable <ActionModelBase> UpgradeAction(Base.Actions.ActionBase action)
        {
            List <ActionModelBase> actions = new List <ActionModelBase>();

            switch (action.Type)
            {
            case Base.Actions.ActionTypeEnum.Chat:
                actions.Add(new ChatActionModel((MixItUp.Base.Actions.ChatAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Clips:
                actions.Add(new TwitchActionModel((MixItUp.Base.Actions.ClipsAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Command:
                actions.Add(new CommandActionModel((MixItUp.Base.Actions.CommandAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Conditional:
                MixItUp.Base.Actions.ConditionalAction conAction = (MixItUp.Base.Actions.ConditionalAction)action;
                ActionModelBase subAction = null;
                if (conAction.CommandID != Guid.Empty)
                {
                    CommandActionModel cmdAction = new CommandActionModel(CommandActionTypeEnum.RunCommand, null);
                    cmdAction.CommandID = conAction.CommandID;
                    subAction           = cmdAction;
                }
                else
                {
                    IEnumerable <ActionModelBase> subActions = ActionModelBase.UpgradeAction(conAction.Action);
                    if (subActions != null && subActions.Count() > 0)
                    {
                        subAction = subActions.ElementAt(0);
                    }
                }
                actions.Add(new ConditionalActionModel(conAction, subAction));
                break;

            case Base.Actions.ActionTypeEnum.Counter:
                actions.Add(new CounterActionModel((MixItUp.Base.Actions.CounterAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Currency:
                actions.Add(new ConsumablesActionModel((MixItUp.Base.Actions.CurrencyAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Discord:
                actions.Add(new DiscordActionModel((MixItUp.Base.Actions.DiscordAction)action));
                break;

            case Base.Actions.ActionTypeEnum.ExternalProgram:
                actions.Add(new ExternalProgramActionModel((MixItUp.Base.Actions.ExternalProgramAction)action));
                break;

            case Base.Actions.ActionTypeEnum.File:
                actions.Add(new FileActionModel((MixItUp.Base.Actions.FileAction)action));
                break;

            case Base.Actions.ActionTypeEnum.GameQueue:
                actions.Add(new GameQueueActionModel((MixItUp.Base.Actions.GameQueueAction)action));
                break;

            case Base.Actions.ActionTypeEnum.IFTTT:
                actions.Add(new IFTTTActionModel((MixItUp.Base.Actions.IFTTTAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Input:
                actions.Add(new InputActionModel((MixItUp.Base.Actions.InputAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Moderation:
                MixItUp.Base.Actions.ModerationAction mAction = (MixItUp.Base.Actions.ModerationAction)action;
                if (mAction.ModerationType == Base.Actions.ModerationActionTypeEnum.VIPUser || mAction.ModerationType == Base.Actions.ModerationActionTypeEnum.UnVIPUser)
                {
                    actions.Add(new TwitchActionModel(mAction));
                }
                else
                {
                    actions.Add(new ModerationActionModel(mAction));
                }
                break;

            case Base.Actions.ActionTypeEnum.Overlay:
                actions.Add(new OverlayActionModel((MixItUp.Base.Actions.OverlayAction)action));
                break;

            case Base.Actions.ActionTypeEnum.OvrStream:
                actions.Add(new OvrStreamActionModel((MixItUp.Base.Actions.OvrStreamAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Serial:
                actions.Add(new SerialActionModel((MixItUp.Base.Actions.SerialAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Sound:
                actions.Add(new SoundActionModel((MixItUp.Base.Actions.SoundAction)action));
                break;

            case Base.Actions.ActionTypeEnum.SpecialIdentifier:
                actions.Add(new SpecialIdentifierActionModel((MixItUp.Base.Actions.SpecialIdentifierAction)action));
                break;

            case Base.Actions.ActionTypeEnum.StreamingPlatform:
                actions.Add(new TwitchActionModel((MixItUp.Base.Actions.StreamingPlatformAction)action));
                break;

            case Base.Actions.ActionTypeEnum.StreamingSoftware:
                actions.Add(new StreamingSoftwareActionModel((MixItUp.Base.Actions.StreamingSoftwareAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Streamlabs:
                actions.Add(new StreamlabsActionModel((MixItUp.Base.Actions.StreamlabsAction)action));
                break;

            case Base.Actions.ActionTypeEnum.TextToSpeech:
                actions.Add(new TextToSpeechActionModel((MixItUp.Base.Actions.TextToSpeechAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Translation:
                // Deprecated
                break;

            case Base.Actions.ActionTypeEnum.Twitter:
                actions.Add(new TwitterActionModel((MixItUp.Base.Actions.TwitterAction)action));
                break;

            case Base.Actions.ActionTypeEnum.Wait:
                actions.Add(new WaitActionModel((MixItUp.Base.Actions.WaitAction)action));
                break;

            case Base.Actions.ActionTypeEnum.WebRequest:
                MixItUp.Base.Actions.WebRequestAction wbAction = (MixItUp.Base.Actions.WebRequestAction)action;
                actions.Add(new WebRequestActionModel(wbAction));
                if (wbAction.ResponseAction == Base.Actions.WebRequestResponseActionTypeEnum.Chat)
                {
                    actions.Add(new ChatActionModel(wbAction.ResponseChatText));
                }
                else if (wbAction.ResponseAction == Base.Actions.WebRequestResponseActionTypeEnum.Command)
                {
                    CommandActionModel cmdAction = new CommandActionModel(CommandActionTypeEnum.RunCommand, null);
                    cmdAction.CommandID = wbAction.ResponseCommandID;
                    cmdAction.Arguments = wbAction.ResponseCommandArgumentsText;
                    actions.Add(cmdAction);
                }
                else if (wbAction.ResponseAction == Base.Actions.WebRequestResponseActionTypeEnum.SpecialIdentifier)
                {
                    actions.Add(new SpecialIdentifierActionModel(wbAction.SpecialIdentifierName, "$" + WebRequestActionModel.ResponseSpecialIdentifier, false, false));
                }
                break;
            }

            if (actions.Count > 0 && !string.Equals(action.Label, EnumLocalizationHelper.GetLocalizedName(action.Type)))
            {
                actions.First().Name = action.Label;
            }

            return(actions);
        }
        protected Result ValidateOutcomes(IEnumerable <GameOutcomeViewModel> outcomes)
        {
            if (outcomes.Count() == 0)
            {
                return(new Result(MixItUp.Base.Resources.GameCommandAtLeast1Outcome));
            }

            Dictionary <UserRoleEnum, int> probabilities = new Dictionary <UserRoleEnum, int>();

            foreach (RoleProbabilityPayoutViewModel rpp in outcomes.First().RoleProbabilityPayouts)
            {
                probabilities[rpp.Role] = 0;
            }

            foreach (GameOutcomeViewModel outcome in outcomes)
            {
                Result result = outcome.Validate();
                if (!result.Success)
                {
                    return(result);
                }

                foreach (RoleProbabilityPayoutViewModel rpp in outcome.RoleProbabilityPayouts)
                {
                    probabilities[rpp.Role] += rpp.Probability;
                }
            }

            foreach (var kvp in probabilities)
            {
                if (kvp.Value != 100)
                {
                    return(new Result(string.Format(MixItUp.Base.Resources.GameCommandRoleProbabilityNotEqualTo100, EnumLocalizationHelper.GetLocalizedName(kvp.Key))));
                }
            }

            return(new Result());
        }
Esempio n. 16
0
 public ActionBase(ActionTypeEnum type)
     : this()
 {
     this.Type  = type;
     this.Label = EnumLocalizationHelper.GetLocalizedName(this.Type);
 }
Esempio n. 17
0
        private void CommandSelectorDialogControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            var types = ChannelSession.AllCommands.Select(c => c.Type).Distinct();

            this.TypeComboBox.ItemsSource = types.OrderBy(s => EnumLocalizationHelper.GetLocalizedName(s));
        }
Esempio n. 18
0
 public EventCommandModel(EventTypeEnum eventType) : base(EnumLocalizationHelper.GetLocalizedName(eventType), CommandTypeEnum.Event)
 {
     this.EventType = eventType;
 }
Esempio n. 19
0
 public EventCommandEditorWindowViewModel(EventCommandModel existingCommand)
     : base(existingCommand)
 {
     this.EventType = existingCommand.EventType;
     this.Name      = EnumLocalizationHelper.GetLocalizedName(this.EventType);
 }
Esempio n. 20
0
 public EventCommandEditorWindowViewModel(EventTypeEnum eventType)
     : base(CommandTypeEnum.Event)
 {
     this.EventType = eventType;
     this.Name      = EnumLocalizationHelper.GetLocalizedName(this.EventType);
 }
 public ActionEditorControlViewModelBase()
 {
     this.Name    = EnumLocalizationHelper.GetLocalizedName(this.Type);
     this.Enabled = true;
 }
Esempio n. 22
0
        private void ActionContainerControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.GroupBoxHeaderTextBlock = (TextBlock)this.GetByUid("GroupBoxHeaderTextBlock");
            this.GroupBoxHeaderTextBox   = (TextBox)this.GetByUid("GroupBoxHeaderTextBox");

            if (this.action != null && !string.IsNullOrEmpty(this.action.Label))
            {
                this.GroupBoxHeaderTextBox.Text = this.GroupBoxHeaderTextBlock.Text = this.action.Label;
            }

            if (string.IsNullOrEmpty(this.GroupBoxHeaderTextBox.Text))
            {
                this.GroupBoxHeaderTextBox.Text = this.GroupBoxHeaderTextBlock.Text = EnumLocalizationHelper.GetLocalizedName(this.type);
            }

            if (this.ActionContainer.IsMinimized)
            {
                this.AccordianGroupBoxControl_Minimized(this, new RoutedEventArgs());
            }
        }