public InteractiveCommandDetailsControl(InteractiveCommand command)
        {
            this.command = command;
            this.Control = command.Control;

            InitializeComponent();
        }
        private void CommandButtons_EditClicked(object sender, RoutedEventArgs e)
        {
            CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;
            InteractiveCommand    command = commandButtonsControl.GetCommandFromCommandButtons <InteractiveCommand>(sender);

            if (command != null)
            {
                CommandWindow window = null;
                if (command is InteractiveButtonCommand)
                {
                    window = new CommandWindow(new InteractiveButtonCommandDetailsControl(this.selectedGame, this.selectedGameVersion, (InteractiveButtonCommand)command));
                }
                else if (command is InteractiveJoystickCommand)
                {
                    window = new CommandWindow(new InteractiveJoystickCommandDetailsControl(this.selectedGame, this.selectedGameVersion, (InteractiveJoystickCommand)command));
                }
                else if (command is InteractiveTextBoxCommand)
                {
                    window = new CommandWindow(new InteractiveTextBoxCommandDetailsControl(this.selectedGame, this.selectedGameVersion, (InteractiveTextBoxCommand)command));
                }

                if (window != null)
                {
                    window.Closed += Window_Closed;
                    window.Show();
                }
            }
        }
        private void AddControlItem(string sceneID, InteractiveControlModel control)
        {
            InteractiveCommand command = ChannelSession.Settings.InteractiveCommands.FirstOrDefault(c => c.GameID.Equals(this.selectedGame.id) &&
                                                                                                    c.SceneID.Equals(sceneID) && c.Control.controlID.Equals(control.controlID));

            InteractiveControlCommandItem item = null;

            if (command != null)
            {
                command.UpdateWithLatestControl(control);
                item = new InteractiveControlCommandItem(command);
            }
            else if (control is InteractiveButtonControlModel)
            {
                item = new InteractiveControlCommandItem((InteractiveButtonControlModel)control);
            }
            else if (control is InteractiveJoystickControlModel)
            {
                item = new InteractiveControlCommandItem((InteractiveJoystickControlModel)control);
            }
            else if (control is InteractiveTextBoxControlModel)
            {
                item = new InteractiveControlCommandItem((InteractiveTextBoxControlModel)control);
            }

            if (item != null)
            {
                this.currentSceneControlItems.Add(item);
            }
        }
Example #4
0
        public BasicInteractiveCommandEditorControl(CommandWindow window, InteractiveCommand command)
        {
            this.window  = window;
            this.command = command;

            InitializeComponent();
        }
        private void AddConnectedControl(InteractiveConnectedSceneModel scene, InteractiveControlModel control)
        {
            InteractiveCommand command = this.GetInteractiveCommandForControl(this.Client.InteractiveGame.id, control);

            if (command != null)
            {
                command.UpdateWithLatestControl(control);
                this.Controls.Add(control.controlID, new InteractiveConnectedControlCommand(scene, control, command));
            }
        }
        public Task <Command> ExecuteCommand(Command command)
        {
            if (executingCommands.ContainsKey(command.RawCommand))
            {
                log.LogError($"The command '{command}' is already executing. The second trigger will be ignored.");
                return(null);
            }
            CancellationTokenSource source = new CancellationTokenSource();

            executingCommands.TryAdd(command.RawCommand, source);
            InteractiveCommand           interactiveCommand = new InteractiveCommand(this);
            IDisposableCommandLineParser commandLineParser  = commandLineBuilder.BuildCommandLineInstance(interactiveCommand,
                                                                                                          interactiveCommand,
                                                                                                          interactiveCommand,
                                                                                                          source.Token);

            string[] commandParts = command.RawCommand.SplitCommandLine().ToArray();
            command = command.WithParsedCommand(commandLineParser.GetParseResult(commandParts));
            interactiveCommand.SetCommand(command);

            return(commandLineParser.Parse(commandParts).ContinueWith(task =>
            {
                try
                {
                    int result;
                    if (task.Exception != null)
                    {
                        log.LogError($"Exception while executing command '{command.RawCommand}'.{Environment.NewLine}" +
                                     $"{task.Exception}");
                        result = -1;
                    }
                    else
                    {
                        result = task.Result;
                    }

                    executingCommands.TryRemove(command.RawCommand, out _);
                    if (source.IsCancellationRequested)
                    {
                        command = command.AsCanceled();
                    }

                    if (interactiveCommand.CommandResult != null)
                    {
                        command = command.WithDetailedResult(interactiveCommand.CommandResult);
                    }
                    return command.WithResult(result == 0);
                }
                finally
                {
                    source.Dispose();
                    commandLineParser.Dispose();
                }
            }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.Default));
        }
        private void CommandButtons_EditClicked(object sender, RoutedEventArgs e)
        {
            CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;
            InteractiveCommand    command = commandButtonsControl.GetCommandFromCommandButtons <InteractiveCommand>(sender);

            if (command != null)
            {
                CommandWindow window = new CommandWindow(new InteractiveCommandDetailsControl(command));
                window.Closed += Window_Closed;
                window.Show();
            }
        }
 public InteractiveControlCommandItem(InteractiveCommand command)
 {
     this.Command = command;
     if (command.Control is InteractiveButtonControlModel)
     {
         this.Button = (InteractiveButtonControlModel)command.Control;
     }
     else
     {
         this.Joystick = (InteractiveJoystickControlModel)command.Control;
     }
 }
        public void Execute_WithExitString_ShouldExit()
        {
            // Arrange
            InteractiveCommand command = new InteractiveCommand();

            testConsole.ReadLineText = new string[] { "exit" };

            // Act
            command.Execute(testConsole, testArgumentParser, testCommandExecutor.Object);

            // Assert
            Assert.Pass();
        }
        public void Execute_WithCommandString_ShouldExecuteCommand()
        {
            // Arrange
            InteractiveCommand command = new InteractiveCommand();

            testConsole.ReadLineText = new string[] { "command arg1 arg2", "exit" };

            // Act
            command.Execute(testConsole, testArgumentParser, testCommandExecutor.Object);

            // Assert
            testCommandExecutor.Verify(m => m.Execute(new string[] { "command", "arg1", "arg2" }));
        }
Example #11
0
 public async Task DisableAllControlsWithoutCommands(InteractiveGameVersionModel version)
 {
     // Disable all controls that do not have an associated Interactive Command or the Interactive Command is disabled
     foreach (InteractiveSceneModel scene in version.controls.scenes)
     {
         foreach (InteractiveControlModel control in scene.allControls)
         {
             InteractiveCommand command = this.GetInteractiveCommandForControl(version.gameId, control);
             control.disabled = (command == null || !command.IsEnabled);
         }
     }
     await ChannelSession.Connection.UpdateInteractiveGameVersion(version);
 }
 public InteractiveConnectedControlCommand(InteractiveConnectedSceneModel scene, InteractiveControlModel control, InteractiveCommand command)
 {
     this.Scene   = scene;
     this.Command = command;
     if (control is InteractiveConnectedButtonControlModel)
     {
         this.Button = (InteractiveConnectedButtonControlModel)control;
     }
     else
     {
         this.Joystick = (InteractiveConnectedJoystickControlModel)control;
     }
 }
 private async void CommandButtons_DeleteClicked(object sender, RoutedEventArgs e)
 {
     await this.Window.RunAsyncOperation(async() =>
     {
         CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;
         InteractiveCommand command = commandButtonsControl.GetCommandFromCommandButtons <InteractiveCommand>(sender);
         if (command != null)
         {
             ChannelSession.Settings.InteractiveCommands.Remove(command);
             await ChannelSession.SaveSettings();
             this.RefreshSelectedScene();
         }
     });
 }
        public override async Task <CommandBase> GetNewCommand()
        {
            if (await this.Validate())
            {
                InteractiveButtonCommandTriggerType trigger = EnumHelper.GetEnumValueFromString <InteractiveButtonCommandTriggerType>((string)this.ButtonTriggerComboBox.SelectedItem);
                if (this.command == null)
                {
                    if (this.Control is InteractiveButtonControlModel)
                    {
                        this.command = new InteractiveCommand(this.Game, this.Scene, (InteractiveButtonControlModel)this.Control, trigger);
                    }
                    else
                    {
                        this.command = new InteractiveCommand(this.Game, this.Scene, (InteractiveJoystickControlModel)this.Control);
                    }
                    ChannelSession.Settings.InteractiveCommands.Add(this.command);
                }

                if (this.Control is InteractiveButtonControlModel)
                {
                    this.command.Trigger     = trigger;
                    this.command.Button.cost = int.Parse(this.SparkCostTextBox.Text);
                    if (this.CooldownTypeComboBox.SelectedItem.Equals("Group"))
                    {
                        string cooldownGroup = this.CooldownGroupsComboBox.Text;
                        this.command.CooldownGroup = cooldownGroup;
                        ChannelSession.Settings.InteractiveCooldownGroups[cooldownGroup] = int.Parse(this.CooldownTextBox.Text);

                        this.command.IndividualCooldown = 0;
                    }
                    else
                    {
                        int cooldown = 0;
                        if (!string.IsNullOrEmpty(this.CooldownTextBox.Text))
                        {
                            cooldown = int.Parse(this.CooldownTextBox.Text);
                        }
                        this.command.IndividualCooldown = cooldown;

                        this.command.CooldownGroup = null;
                    }

                    await ChannelSession.Connection.UpdateInteractiveGameVersion(this.Version);
                }
                return(this.command);
            }
            return(null);
        }
        private InteractiveControlCommandItem CreateControlItem(string sceneID, InteractiveControlModel control)
        {
            InteractiveCommand command = ChannelSession.Settings.InteractiveCommands.FirstOrDefault(c => c.GameID.Equals(this.selectedGame.id) &&
                                                                                                    c.SceneID.Equals(sceneID) && c.Control.controlID.Equals(control.controlID));

            if (command != null)
            {
                command.UpdateWithLatestControl(control);
                return(new InteractiveControlCommandItem(command));
            }
            else if (control is InteractiveButtonControlModel)
            {
                return(new InteractiveControlCommandItem((InteractiveButtonControlModel)control));
            }
            else
            {
                return(new InteractiveControlCommandItem((InteractiveJoystickControlModel)control));
            }
        }
Example #16
0
        private void AddConnectedControl(InteractiveConnectedSceneModel scene, InteractiveControlModel control)
        {
            InteractiveCommand command = this.GetInteractiveCommandForControl(this.Client.InteractiveGame.id, control);

            if (command != null)
            {
                command.UpdateWithLatestControl(control);
                if (control is InteractiveConnectedButtonControlModel)
                {
                    this.ControlCommands[control.controlID] = new InteractiveConnectedButtonCommand(scene, (InteractiveConnectedButtonControlModel)control, command);
                }
                else if (control is InteractiveConnectedJoystickControlModel)
                {
                    this.ControlCommands[control.controlID] = new InteractiveConnectedJoystickCommand(scene, (InteractiveConnectedJoystickControlModel)control, command);
                }
                else if (control is InteractiveConnectedTextBoxControlModel)
                {
                    this.ControlCommands[control.controlID] = new InteractiveConnectedTextBoxCommand(scene, (InteractiveConnectedTextBoxControlModel)control, command);
                }
            }
        }
Example #17
0
        //交互
        private CommandReplyType CheckInteractive(InteractiveCommand cmd)
        {
            if (CannotControlSelf())
            {
                return(CommandReplyType.NO);
            }
            if (CurFsmStateType == ActorFsmStateType.FSM_DEAD)
            {
                return(CommandReplyType.NO);
            }
            if (cmd.AnimName == "idle")
            {
                cmd.LastTime = 1;
            }
            else
            {
                cmd.LastTime = m_AnimController.GetAnimLength(cmd.AnimName);
            }

            ChangeState <ActorInteractiveFsm>();
            return(CommandReplyType.YES);
        }
Example #18
0
 public InteractiveConnectedTextBoxCommand(InteractiveConnectedSceneModel scene, InteractiveConnectedTextBoxControlModel textBox, InteractiveCommand command) : base(scene, textBox, command)
 {
 }
        private async void CommandButtons_EditClicked(object sender, RoutedEventArgs e)
        {
            CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;
            InteractiveCommand    command = commandButtonsControl.GetCommandFromCommandButtons <InteractiveCommand>(sender);

            if (command != null)
            {
                if (!this.ValidateCommandMatchesControl(command))
                {
                    string oldControlType = string.Empty;
                    if (command is InteractiveButtonCommand)
                    {
                        oldControlType = "Button";
                    }
                    if (command is InteractiveJoystickCommand)
                    {
                        oldControlType = "Joystick";
                    }
                    if (command is InteractiveTextBoxCommand)
                    {
                        oldControlType = "Text Box";
                    }

                    string newControlType = string.Empty;
                    if (command.Control is InteractiveButtonControlModel)
                    {
                        newControlType = "Button";
                    }
                    if (command.Control is InteractiveJoystickControlModel)
                    {
                        newControlType = "Joystick";
                    }
                    if (command.Control is InteractiveTextBoxControlModel)
                    {
                        newControlType = "Text Box";
                    }

                    await this.Window.RunAsyncOperation(async() =>
                    {
                        await MessageBoxHelper.ShowMessageDialog(string.Format("The control you are trying to edit has been changed from a {0} to a {1} and can not be edited. You must either change this control back to its previous type, change the control ID to something different, or delete the command to start fresh.", oldControlType, newControlType));
                    });

                    return;
                }

                CommandWindow window = null;
                if (command is InteractiveButtonCommand)
                {
                    window = new CommandWindow(new InteractiveButtonCommandDetailsControl(this.selectedGame, this.selectedGameVersion, (InteractiveButtonCommand)command));
                }
                else if (command is InteractiveJoystickCommand)
                {
                    window = new CommandWindow(new InteractiveJoystickCommandDetailsControl(this.selectedGame, this.selectedGameVersion, (InteractiveJoystickCommand)command));
                }
                else if (command is InteractiveTextBoxCommand)
                {
                    window = new CommandWindow(new InteractiveTextBoxCommandDetailsControl(this.selectedGame, this.selectedGameVersion, (InteractiveTextBoxCommand)command));
                }

                if (window != null)
                {
                    window.Closed += Window_Closed;
                    window.Show();
                }
            }
        }
Example #20
0
 public InteractiveConnectedButtonCommand(InteractiveConnectedSceneModel scene, InteractiveConnectedButtonControlModel button, InteractiveCommand command)
     : base(scene, button, command)
 {
     this.ButtonCommand.OnCommandStart += ButtonCommand_OnCommandStart;
 }
Example #21
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            await this.window.RunAsyncOperation(async() =>
            {
                int sparkCost = 0;
                if (!int.TryParse(this.SparkCostTextBox.Text, out sparkCost) || sparkCost < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("Spark cost must be 0 or greater");
                    return;
                }

                if (this.CooldownTypeComboBox.SelectedIndex < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("A cooldown type must be selected");
                    return;
                }

                int cooldown = 0;
                if (!string.IsNullOrEmpty(this.CooldownTextBox.Text))
                {
                    if (!int.TryParse(this.CooldownTextBox.Text, out cooldown) || cooldown < 0)
                    {
                        await MessageBoxHelper.ShowMessageDialog("Cooldown must be 0 or greater");
                        return;
                    }
                }

                ActionBase action = this.actionControl.GetAction();
                if (action == null)
                {
                    if (this.actionControl is ChatActionControl)
                    {
                        await MessageBoxHelper.ShowMessageDialog("The chat message must not be empty");
                    }
                    else if (this.actionControl is SoundActionControl)
                    {
                        await MessageBoxHelper.ShowMessageDialog("The sound file path must not be empty");
                    }
                    return;
                }

                if (this.command == null)
                {
                    this.command = new InteractiveCommand(this.game, this.scene, this.button, InteractiveButtonCommandTriggerType.MouseDown);
                    ChannelSession.Settings.InteractiveCommands.Add(this.command);
                }

                this.command.Button.cost = sparkCost;
                if (this.CooldownTypeComboBox.SelectedIndex == 0)
                {
                    this.command.IndividualCooldown = cooldown;
                }
                else
                {
                    this.command.CooldownGroup = InteractiveCommand.BasicCommandCooldownGroup;
                    ChannelSession.Settings.InteractiveCooldownGroups[InteractiveCommand.BasicCommandCooldownGroup] = cooldown;
                }
                await ChannelSession.Connection.UpdateInteractiveGameVersion(this.version);

                this.command.IsBasic = true;
                this.command.Actions.Clear();
                this.command.Actions.Add(action);

                await ChannelSession.SaveSettings();

                this.window.Close();
            });
        }
Example #22
0
 public InteractiveConnectedControlCommand(InteractiveConnectedSceneModel scene, InteractiveControlModel control, InteractiveCommand command)
 {
     this.Scene   = scene;
     this.Control = control;
     this.Command = command;
 }
        private async Task FinalizeNewUser()
        {
            if (this.scorpBotData != null)
            {
                // Import Ranks
                int    rankEnabled   = int.Parse(this.scorpBotData.GetSettingsValue("currency", "enabled", "0"));
                string rankName      = this.scorpBotData.GetSettingsValue("currency", "name", "Rank");
                int    rankInterval  = int.Parse(this.scorpBotData.GetSettingsValue("currency", "onlinepayinterval", "0"));
                int    rankAmount    = int.Parse(this.scorpBotData.GetSettingsValue("currency", "activeuserbonus", "0"));
                int    rankMaxAmount = int.Parse(this.scorpBotData.GetSettingsValue("currency", "maxlimit", "-1"));
                if (rankMaxAmount <= 0)
                {
                    rankMaxAmount = int.MaxValue;
                }
                int    rankOnFollowBonus    = int.Parse(this.scorpBotData.GetSettingsValue("currency", "onfollowbonus", "0"));
                int    rankOnSubBonus       = int.Parse(this.scorpBotData.GetSettingsValue("currency", "onsubbonus", "0"));
                int    rankSubBonus         = int.Parse(this.scorpBotData.GetSettingsValue("currency", "subbonus", "0"));
                string rankCommand          = this.scorpBotData.GetSettingsValue("currency", "command", "");
                string rankCommandResponse  = this.scorpBotData.GetSettingsValue("currency", "response", "");
                string rankUpCommand        = this.scorpBotData.GetSettingsValue("currency", "Currency1RankUpMsg", "");
                int    rankAccumulationType = int.Parse(this.scorpBotData.GetSettingsValue("currency", "ranksrectype", "0"));

                UserCurrencyViewModel rankCurrency       = null;
                UserCurrencyViewModel rankPointsCurrency = null;
                if (rankEnabled == 1 && !string.IsNullOrEmpty(rankName))
                {
                    if (rankAccumulationType == 1)
                    {
                        rankCurrency = new UserCurrencyViewModel()
                        {
                            Name = rankName.Equals("Points") ? "Hours" : rankName,
                            SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rankName.Equals("Points") ? "Hours" : rankName),
                            AcquireInterval   = 60,
                            AcquireAmount     = 1,
                            MaxAmount         = rankMaxAmount,
                        };

                        if (rankInterval >= 0 && rankAmount >= 0)
                        {
                            rankPointsCurrency = new UserCurrencyViewModel()
                            {
                                Name = "Points",
                                SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("points"),
                                AcquireInterval   = rankInterval,
                                AcquireAmount     = rankAmount,
                                MaxAmount         = rankMaxAmount,
                                OnFollowBonus     = rankOnFollowBonus,
                                OnSubscribeBonus  = rankOnSubBonus,
                                SubscriberBonus   = rankSubBonus
                            };

                            ChannelSession.Settings.Currencies[rankPointsCurrency.ID] = rankPointsCurrency;
                        }
                    }
                    else if (rankInterval >= 0 && rankAmount >= 0)
                    {
                        rankCurrency = new UserCurrencyViewModel()
                        {
                            Name = rankName,
                            SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rankName),
                            AcquireInterval   = rankInterval,
                            AcquireAmount     = rankAmount,
                            MaxAmount         = rankMaxAmount,
                            OnFollowBonus     = rankOnFollowBonus,
                            OnSubscribeBonus  = rankOnSubBonus,
                            SubscriberBonus   = rankSubBonus
                        };
                    }
                }

                // Import Currency
                int    currencyEnabled   = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "enabled", "0"));
                string currencyName      = this.scorpBotData.GetSettingsValue("currency2", "name", "Currency");
                int    currencyInterval  = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "onlinepayinterval", "0"));
                int    currencyAmount    = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "activeuserbonus", "0"));
                int    currencyMaxAmount = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "maxlimit", "-1"));
                if (currencyMaxAmount <= 0)
                {
                    currencyMaxAmount = int.MaxValue;
                }
                int    currencyOnFollowBonus   = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "onfollowbonus", "0"));
                int    currencyOnSubBonus      = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "onsubbonus", "0"));
                int    currencySubBonus        = int.Parse(this.scorpBotData.GetSettingsValue("currency2", "subbonus", "0"));
                string currencyCommand         = this.scorpBotData.GetSettingsValue("currency2", "command", "");
                string currencyCommandResponse = this.scorpBotData.GetSettingsValue("currency2", "response", "");

                UserCurrencyViewModel currency = null;
                if (currencyEnabled == 1 && !string.IsNullOrEmpty(currencyName) && currencyInterval >= 0 && currencyAmount >= 0)
                {
                    currency = new UserCurrencyViewModel()
                    {
                        Name            = currencyName, SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(currencyName), AcquireInterval = currencyInterval,
                        AcquireAmount   = currencyAmount, MaxAmount = currencyMaxAmount, OnFollowBonus = currencyOnFollowBonus, OnSubscribeBonus = currencyOnSubBonus,
                        SubscriberBonus = currencySubBonus
                    };
                    ChannelSession.Settings.Currencies[currency.ID] = currency;

                    if (!string.IsNullOrEmpty(currencyCommand) && !string.IsNullOrEmpty(currencyCommandResponse))
                    {
                        currencyCommandResponse = currencyCommandResponse.Replace("$points2", "$" + currency.UserAmountSpecialIdentifier);
                        currencyCommandResponse = currencyCommandResponse.Replace("$currencyname2", currency.Name);
                        this.scorpBotData.Commands.Add(new ScorpBotCommand(currencyCommand, currencyCommandResponse));
                    }
                }

                foreach (ScorpBotViewer viewer in this.scorpBotData.Viewers)
                {
                    ChannelSession.Settings.UserData[viewer.ID] = new UserDataViewModel(viewer);

                    if (rankPointsCurrency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(rankPointsCurrency, (int)viewer.RankPoints);
                    }

                    if (rankCurrency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(rankCurrency, (rankPointsCurrency != null) ? (int)viewer.Hours : (int)viewer.RankPoints);
                    }

                    if (currency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(currency, (int)viewer.Currency);
                    }
                }

                if (rankCurrency != null)
                {
                    ChannelSession.Settings.Currencies[rankCurrency.ID] = rankCurrency;

                    foreach (ScorpBotRank rank in this.scorpBotData.Ranks)
                    {
                        rankCurrency.Ranks.Add(new UserRankViewModel(rank.Name, rank.Amount));
                    }

                    if (!string.IsNullOrEmpty(rankCommand) && !string.IsNullOrEmpty(rankCommandResponse))
                    {
                        rankCommandResponse = rankCommandResponse.Replace(" / Raids: $raids", "");
                        rankCommandResponse = rankCommandResponse.Replace("$rank", "$" + rankCurrency.UserRankNameSpecialIdentifier);
                        rankCommandResponse = rankCommandResponse.Replace("$points", "$" + rankCurrency.UserAmountSpecialIdentifier);
                        rankCommandResponse = rankCommandResponse.Replace("$currencyname", rankCurrency.Name);
                        this.scorpBotData.Commands.Add(new ScorpBotCommand(rankCommand, rankCommandResponse));
                    }

                    if (!string.IsNullOrEmpty(rankUpCommand))
                    {
                        rankUpCommand = rankUpCommand.Replace("$rank", "$" + rankCurrency.UserRankNameSpecialIdentifier);
                        rankUpCommand = rankUpCommand.Replace("$points", "$" + rankCurrency.UserAmountSpecialIdentifier);
                        rankUpCommand = rankUpCommand.Replace("$currencyname", rankCurrency.Name);

                        ScorpBotCommand scorpCommand = new ScorpBotCommand("rankup", rankUpCommand);
                        ChatCommand     chatCommand  = new ChatCommand(scorpCommand);

                        rankCurrency.RankChangedCommand = new CustomCommand("User Rank Changed");
                        rankCurrency.RankChangedCommand.Actions.AddRange(chatCommand.Actions);
                    }
                }

                foreach (ScorpBotCommand command in this.scorpBotData.Commands)
                {
                    ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));
                }

                foreach (ScorpBotTimer timer in this.scorpBotData.Timers)
                {
                    ChannelSession.Settings.TimerCommands.Add(new TimerCommand(timer));
                }

                foreach (string quote in this.scorpBotData.Quotes)
                {
                    ChannelSession.Settings.UserQuotes.Add(new UserQuoteViewModel(quote));
                }

                if (ChannelSession.Settings.UserQuotes.Count > 0)
                {
                    ChannelSession.Settings.QuotesEnabled = true;
                }

                foreach (string bannedWord in this.scorpBotData.BannedWords)
                {
                    ChannelSession.Settings.BannedWords.Add(bannedWord);
                }
            }

            if (this.soundwaveData != null && this.soundwaveProfiles != null && this.soundwaveProfiles.Count(p => p.AddProfile) > 0)
            {
                if (this.soundwaveData.StaticCooldown)
                {
                    ChannelSession.Settings.InteractiveCooldownGroups.Add(SoundwaveInteractiveCooldownGroupName, this.soundwaveData.StaticCooldownAmount / 1000);
                }

                InteractiveGameListingModel soundwaveGame = this.interactiveGames.FirstOrDefault(g => g.name.Equals(SoundwaveInteractiveGameName));
                if (soundwaveGame != null)
                {
                    InteractiveGameVersionModel soundwaveGameVersion = await ChannelSession.Connection.GetInteractiveGameVersion(soundwaveGame.versions.First());

                    InteractiveSceneModel soundwaveGameScene = soundwaveGameVersion.controls.scenes.First();

                    foreach (string profile in this.soundwaveProfiles.Where(p => p.AddProfile).Select(p => p.Name))
                    {
                        // Add code logic to create Interactive Game on Mixer that is a copy of the Soundwave Interactive game, but with buttons filed in with name and not disabled
                        InteractiveSceneModel       profileScene = InteractiveGameHelper.CreateDefaultScene();
                        InteractiveGameListingModel profileGame  = await ChannelSession.Connection.CreateInteractiveGame(ChannelSession.Channel, ChannelSession.User, profile, profileScene);

                        InteractiveGameVersionModel gameVersion = profileGame.versions.FirstOrDefault();
                        if (gameVersion != null)
                        {
                            InteractiveGameVersionModel profileGameVersion = await ChannelSession.Connection.GetInteractiveGameVersion(gameVersion);

                            if (profileGameVersion != null)
                            {
                                profileScene = profileGameVersion.controls.scenes.First();

                                for (int i = 0; i < this.soundwaveData.Profiles[profile].Count(); i++)
                                {
                                    SoundwaveButton soundwaveButton = this.soundwaveData.Profiles[profile][i];
                                    InteractiveButtonControlModel soundwaveControl = (InteractiveButtonControlModel)soundwaveGameScene.allControls.FirstOrDefault(c => c.controlID.Equals(i.ToString()));

                                    InteractiveButtonControlModel button = InteractiveGameHelper.CreateButton(soundwaveButton.name, soundwaveButton.name, soundwaveButton.sparks);
                                    button.position = soundwaveControl.position;

                                    InteractiveCommand command = new InteractiveCommand(profileGame, profileScene, button, InteractiveButtonCommandTriggerType.MouseDown);
                                    command.IndividualCooldown = soundwaveButton.cooldown;
                                    if (this.soundwaveData.StaticCooldown)
                                    {
                                        command.CooldownGroup = SoundwaveInteractiveCooldownGroupName;
                                    }

                                    SoundAction action = new SoundAction(soundwaveButton.path, soundwaveButton.volume);
                                    command.Actions.Add(action);

                                    ChannelSession.Settings.InteractiveCommands.Add(command);
                                    profileScene.buttons.Add(button);
                                }

                                await ChannelSession.Connection.UpdateInteractiveGameVersion(profileGameVersion);
                            }
                        }
                    }
                }
            }

            await ChannelSession.SaveSettings();
        }
Example #24
0
 public InteractiveConnectedJoystickCommand(InteractiveConnectedSceneModel scene, InteractiveConnectedJoystickControlModel joystick, InteractiveCommand command) : base(scene, joystick, command)
 {
 }
Example #25
0
        private async void PlayButton_Click(object sender, RoutedEventArgs e)
        {
            this.PlayButton.Visibility = Visibility.Collapsed;
            this.StopButton.Visibility = Visibility.Visible;

            this.EditButton.IsEnabled   = false;
            this.DeleteButton.IsEnabled = false;
            this.EnableDisableToggleSwitch.IsEnabled = false;

            CommandBase command = this.GetCommandFromCommandButtons <CommandBase>(this);

            if (command != null)
            {
                UserViewModel currentUser = await ChannelSession.GetCurrentUser();

                Dictionary <string, string> extraSpecialIdentifiers = new Dictionary <string, string>();
                if (command is EventCommand)
                {
                    EventCommand eventCommand = command as EventCommand;
                    switch (eventCommand.EventType)
                    {
                    case Mixer.Base.Clients.ConstellationEventTypeEnum.channel__id__hosted:
                        extraSpecialIdentifiers["hostviewercount"] = "123";
                        break;

                    case Mixer.Base.Clients.ConstellationEventTypeEnum.channel__id__resubscribed:
                        extraSpecialIdentifiers["usersubmonths"] = "5";
                        break;

                    case Mixer.Base.Clients.ConstellationEventTypeEnum.progression__id__levelup:
                        extraSpecialIdentifiers["userfanprogressionnext"]  = "200";
                        extraSpecialIdentifiers["userfanprogressionrank"]  = "10";
                        extraSpecialIdentifiers["userfanprogressioncolor"] = "#c642ea";
                        extraSpecialIdentifiers["userfanprogressionimage"] = "https://static.mixer.com/img/design/ui/fan-progression/v1_badges/purple/large.gif";
                        extraSpecialIdentifiers["userfanprogression"]      = "100";
                        break;
                    }

                    switch (eventCommand.OtherEventType)
                    {
                    case OtherEventTypeEnum.GameWispSubscribed:
                    case OtherEventTypeEnum.GameWispResubscribed:
                        extraSpecialIdentifiers["subscribemonths"] = "999";
                        extraSpecialIdentifiers["subscribetier"]   = "Test Tier";
                        extraSpecialIdentifiers["subscribeamount"] = "$12.34";
                        break;

                    case OtherEventTypeEnum.StreamlabsDonation:
                    case OtherEventTypeEnum.GawkBoxDonation:
                    case OtherEventTypeEnum.TiltifyDonation:
                    case OtherEventTypeEnum.ExtraLifeDonation:
                    case OtherEventTypeEnum.TipeeeStreamDonation:
                    case OtherEventTypeEnum.TreatStreamDonation:
                    case OtherEventTypeEnum.StreamJarDonation:
                        UserDonationModel donation = new UserDonationModel()
                        {
                            Amount    = 12.34,
                            Message   = "Test donation message",
                            ImageLink = currentUser.AvatarLink
                        };

                        switch (eventCommand.OtherEventType)
                        {
                        case OtherEventTypeEnum.StreamlabsDonation: donation.Source = UserDonationSourceEnum.Streamlabs; break;

                        case OtherEventTypeEnum.GawkBoxDonation: donation.Source = UserDonationSourceEnum.GawkBox; break;

                        case OtherEventTypeEnum.TiltifyDonation: donation.Source = UserDonationSourceEnum.Tiltify; break;

                        case OtherEventTypeEnum.ExtraLifeDonation: donation.Source = UserDonationSourceEnum.ExtraLife; break;

                        case OtherEventTypeEnum.TipeeeStreamDonation: donation.Source = UserDonationSourceEnum.TipeeeStream; break;

                        case OtherEventTypeEnum.TreatStreamDonation: donation.Source = UserDonationSourceEnum.TreatStream; break;

                        case OtherEventTypeEnum.StreamJarDonation: donation.Source = UserDonationSourceEnum.StreamJar; break;
                        }

                        foreach (var kvp in donation.GetSpecialIdentifiers())
                        {
                            extraSpecialIdentifiers[kvp.Key] = kvp.Value;
                        }
                        extraSpecialIdentifiers["donationtype"] = "Pizza";
                        break;

                    case OtherEventTypeEnum.PatreonSubscribed:
                        extraSpecialIdentifiers[SpecialIdentifierStringBuilder.PatreonTierNameSpecialIdentifier]   = "Super Tier";
                        extraSpecialIdentifiers[SpecialIdentifierStringBuilder.PatreonTierAmountSpecialIdentifier] = "12.34";
                        extraSpecialIdentifiers[SpecialIdentifierStringBuilder.PatreonTierImageSpecialIdentifier]  = "https://xforgeassets002.xboxlive.com/xuid-2535473787585366-public/b7a1d715-3a9e-4bdd-a030-32f9e2e0f51e/0013_lots-o-stars_256.png";
                        break;

                    case OtherEventTypeEnum.StreamlootsCardRedeemed:
                        extraSpecialIdentifiers["streamlootscardname"]  = "Test Card";
                        extraSpecialIdentifiers["streamlootscardimage"] = "https://res.cloudinary.com/streamloots/image/upload/f_auto,c_scale,w_250,q_90/static/e19c7bf6-ca3e-49a8-807e-b2e9a1a47524/en_dl_character.png";
                        extraSpecialIdentifiers["streamlootscardvideo"] = "https://cdn.streamloots.com/uploads/5c645b78666f31002f2979d1/3a6bf1dc-7d61-4f93-be0a-f5dc1d0d33b6.webm";
                        extraSpecialIdentifiers["streamlootscardsound"] = "https://static.streamloots.com/b355d1ef-d931-4c16-a48f-8bed0076401b/alerts/default.mp3";
                        extraSpecialIdentifiers["streamlootsmessage"]   = "Test Message";
                        break;

                    case OtherEventTypeEnum.StreamlootsPackPurchased:
                    case OtherEventTypeEnum.StreamlootsPackGifted:
                        extraSpecialIdentifiers["streamlootspurchasequantity"] = "1";
                        break;

                    case OtherEventTypeEnum.TwitterStreamTweetRetweet:
                        break;

                    case OtherEventTypeEnum.MixerSkillUsed:
                        extraSpecialIdentifiers["skillname"]     = "Lots of stars";
                        extraSpecialIdentifiers["skilltype"]     = EnumHelper.GetEnumName(SkillTypeEnum.Sticker);
                        extraSpecialIdentifiers["skillcosttype"] = "Embers";
                        extraSpecialIdentifiers["skillcost"]     = "50";
                        extraSpecialIdentifiers["skillimage"]    = "https://xforgeassets002.xboxlive.com/xuid-2535473787585366-public/b7a1d715-3a9e-4bdd-a030-32f9e2e0f51e/0013_lots-o-stars_256.png";
                        extraSpecialIdentifiers["skillissparks"] = false.ToString();
                        extraSpecialIdentifiers["skillisembers"] = true.ToString();
                        extraSpecialIdentifiers["skillmessage"]  = "Hello World!";
                        break;

                    case OtherEventTypeEnum.MixerMilestoneReached:
                        extraSpecialIdentifiers["milestoneamount"]               = "100";
                        extraSpecialIdentifiers["milestoneremainingamount"]      = "100";
                        extraSpecialIdentifiers["milestonereward"]               = "$10.00";
                        extraSpecialIdentifiers["milestonenextamount"]           = "100";
                        extraSpecialIdentifiers["milestonenextremainingamount"]  = "100";
                        extraSpecialIdentifiers["milestonenextreward"]           = "$10.00";
                        extraSpecialIdentifiers["milestonefinalamount"]          = "100";
                        extraSpecialIdentifiers["milestonefinalremainingamount"] = "100";
                        extraSpecialIdentifiers["milestonefinalreward"]          = "$10.00";
                        extraSpecialIdentifiers["milestoneearnedamount"]         = "100";
                        extraSpecialIdentifiers["milestoneearnedreward"]         = "$10.00";
                        break;

                    case OtherEventTypeEnum.MixerSparksUsed:
                        extraSpecialIdentifiers["sparkamount"] = "10";
                        break;

                    case OtherEventTypeEnum.MixerEmbersUsed:
                        extraSpecialIdentifiers["emberamount"] = "10";
                        break;
                    }
                }
                else if (command is InteractiveCommand)
                {
                    InteractiveCommand iCommand = (InteractiveCommand)command;

                    extraSpecialIdentifiers["mixplaycontrolid"]   = iCommand.Name;
                    extraSpecialIdentifiers["mixplaycontrolcost"] = "123";
                    extraSpecialIdentifiers["mixplaycontroltext"] = "Button Name";
                }
                else if (command is CustomCommand)
                {
                    if (command.Name.Equals(InventoryWindow.ItemsBoughtCommandName) || command.Name.Equals(InventoryWindow.ItemsSoldCommandName))
                    {
                        extraSpecialIdentifiers["itemtotal"]    = "5";
                        extraSpecialIdentifiers["itemname"]     = "Chocolate Bars";
                        extraSpecialIdentifiers["itemcost"]     = "500";
                        extraSpecialIdentifiers["currencyname"] = "CURRENCY_NAME";
                    }
                    else if (command.Name.Contains("Moderation Strike"))
                    {
                        extraSpecialIdentifiers[ModerationHelper.ModerationReasonSpecialIdentifier] = "Bad Stuff";
                    }
                    else
                    {
                        extraSpecialIdentifiers["songtitle"]           = "Test Song";
                        extraSpecialIdentifiers["songalbumart"]        = SpotifySongRequestProviderService.SpotifyDefaultAlbumArt;
                        extraSpecialIdentifiers["songusername"]        = currentUser.UserName;
                        extraSpecialIdentifiers["spotifysongtitle"]    = "Test Song";
                        extraSpecialIdentifiers["spotifysongalbumart"] = SpotifySongRequestProviderService.SpotifyDefaultAlbumArt;
                        extraSpecialIdentifiers["queueposition"]       = "1";
                    }
                }

                await command.PerformAndWait(currentUser, new List <string>() { "@" + currentUser.UserName }, extraSpecialIdentifiers);

                if (command is PermissionsCommandBase)
                {
                    PermissionsCommandBase permissionCommand = (PermissionsCommandBase)command;
                    permissionCommand.ResetCooldown(await ChannelSession.GetCurrentUser());
                }
                this.SwitchToPlay();
            }

            this.RaiseEvent(new RoutedEventArgs(CommandButtonsControl.PlayClickedEvent, this));
        }
 private bool ValidateCommandMatchesControl(InteractiveCommand command)
 {
     return((command is InteractiveButtonCommand && command.Control is InteractiveButtonControlModel) ||
            (command is InteractiveJoystickCommand && command.Control is InteractiveJoystickControlModel) ||
            (command is InteractiveTextBoxCommand && command.Control is InteractiveTextBoxControlModel));
 }
Example #27
0
        private async void PlayButton_Click(object sender, RoutedEventArgs e)
        {
            this.PlayButton.Visibility = Visibility.Collapsed;
            this.StopButton.Visibility = Visibility.Visible;

            this.EditButton.IsEnabled   = false;
            this.DeleteButton.IsEnabled = false;
            this.EnableDisableToggleSwitch.IsEnabled = false;

            CommandBase command = this.GetCommandFromCommandButtons <CommandBase>(this);

            if (command != null)
            {
                UserViewModel currentUser = await ChannelSession.GetCurrentUser();

                Dictionary <string, string> extraSpecialIdentifiers = new Dictionary <string, string>();
                if (command is EventCommand)
                {
                    EventCommand eventCommand = command as EventCommand;
                    switch (eventCommand.EventType)
                    {
                    case Mixer.Base.Clients.ConstellationEventTypeEnum.channel__id__hosted:
                        extraSpecialIdentifiers["hostviewercount"] = "123";
                        break;

                    case Mixer.Base.Clients.ConstellationEventTypeEnum.channel__id__resubscribed:
                        extraSpecialIdentifiers["usersubmonths"] = "5";
                        break;
                    }

                    switch (eventCommand.OtherEventType)
                    {
                    case OtherEventTypeEnum.GameWispSubscribed:
                    case OtherEventTypeEnum.GameWispResubscribed:
                        extraSpecialIdentifiers["subscribemonths"] = "999";
                        extraSpecialIdentifiers["subscribetier"]   = "Test Tier";
                        extraSpecialIdentifiers["subscribeamount"] = "$12.34";
                        break;

                    case OtherEventTypeEnum.StreamlabsDonation:
                    case OtherEventTypeEnum.GawkBoxDonation:
                    case OtherEventTypeEnum.TiltifyDonation:
                    case OtherEventTypeEnum.ExtraLifeDonation:
                    case OtherEventTypeEnum.TipeeeStreamDonation:
                    case OtherEventTypeEnum.TreatStreamDonation:
                    case OtherEventTypeEnum.StreamJarDonation:
                        UserDonationModel donation = new UserDonationModel()
                        {
                            Amount    = 12.34,
                            Message   = "Test donation message",
                            ImageLink = currentUser.AvatarLink
                        };

                        switch (eventCommand.OtherEventType)
                        {
                        case OtherEventTypeEnum.StreamlabsDonation: donation.Source = UserDonationSourceEnum.Streamlabs; break;

                        case OtherEventTypeEnum.GawkBoxDonation: donation.Source = UserDonationSourceEnum.GawkBox; break;

                        case OtherEventTypeEnum.TiltifyDonation: donation.Source = UserDonationSourceEnum.Tiltify; break;

                        case OtherEventTypeEnum.ExtraLifeDonation: donation.Source = UserDonationSourceEnum.ExtraLife; break;

                        case OtherEventTypeEnum.TipeeeStreamDonation: donation.Source = UserDonationSourceEnum.TipeeeStream; break;

                        case OtherEventTypeEnum.TreatStreamDonation: donation.Source = UserDonationSourceEnum.TreatStream; break;

                        case OtherEventTypeEnum.StreamJarDonation: donation.Source = UserDonationSourceEnum.StreamJar; break;
                        }

                        foreach (var kvp in donation.GetSpecialIdentifiers())
                        {
                            extraSpecialIdentifiers[kvp.Key] = kvp.Value;
                        }
                        extraSpecialIdentifiers["donationtype"] = "Pizza";
                        break;

                    case OtherEventTypeEnum.PatreonSubscribed:
                        extraSpecialIdentifiers[SpecialIdentifierStringBuilder.PatreonTierNameSpecialIdentifier]   = "Super Tier";
                        extraSpecialIdentifiers[SpecialIdentifierStringBuilder.PatreonTierAmountSpecialIdentifier] = "12.34";
                        extraSpecialIdentifiers[SpecialIdentifierStringBuilder.PatreonTierImageSpecialIdentifier]  = "https://xforgeassets002.xboxlive.com/xuid-2535473787585366-public/b7a1d715-3a9e-4bdd-a030-32f9e2e0f51e/0013_lots-o-stars_256.png";
                        break;

                    case OtherEventTypeEnum.TwitterStreamTweetRetweet:
                        break;

                    case OtherEventTypeEnum.MixerSkillUsed:
                        extraSpecialIdentifiers["skillname"]     = "Lots of stars";
                        extraSpecialIdentifiers["skilltype"]     = EnumHelper.GetEnumName(SkillTypeEnum.Sticker);
                        extraSpecialIdentifiers["skillcosttype"] = "Embers";
                        extraSpecialIdentifiers["skillcost"]     = "50";
                        extraSpecialIdentifiers["skillimage"]    = "https://xforgeassets002.xboxlive.com/xuid-2535473787585366-public/b7a1d715-3a9e-4bdd-a030-32f9e2e0f51e/0013_lots-o-stars_256.png";
                        extraSpecialIdentifiers["skillissparks"] = false.ToString();
                        extraSpecialIdentifiers["skillisembers"] = true.ToString();
                        extraSpecialIdentifiers["skillmessage"]  = "Hello World!";
                        break;

                    case OtherEventTypeEnum.MixerMilestoneReached:
                        extraSpecialIdentifiers["milestoneamount"]               = "100";
                        extraSpecialIdentifiers["milestoneremainingamount"]      = "100";
                        extraSpecialIdentifiers["milestonereward"]               = "$10.00";
                        extraSpecialIdentifiers["milestonenextamount"]           = "100";
                        extraSpecialIdentifiers["milestonenextremainingamount"]  = "100";
                        extraSpecialIdentifiers["milestonenextreward"]           = "$10.00";
                        extraSpecialIdentifiers["milestonefinalamount"]          = "100";
                        extraSpecialIdentifiers["milestonefinalremainingamount"] = "100";
                        extraSpecialIdentifiers["milestonefinalreward"]          = "$10.00";
                        extraSpecialIdentifiers["milestoneearnedamount"]         = "100";
                        extraSpecialIdentifiers["milestoneearnedreward"]         = "$10.00";
                        break;

                    case OtherEventTypeEnum.MixerSparksUsed:
                        extraSpecialIdentifiers["sparkamount"] = "10";
                        break;

                    case OtherEventTypeEnum.MixerEmbersUsed:
                        extraSpecialIdentifiers["emberamount"] = "10";
                        break;
                    }
                }
                else if (command is InteractiveCommand)
                {
                    InteractiveCommand iCommand = (InteractiveCommand)command;

                    extraSpecialIdentifiers["mixplaycontrolid"]   = iCommand.Name;
                    extraSpecialIdentifiers["mixplaycontrolcost"] = "123";
                }
                else if (command is CustomCommand)
                {
                    if (command.Name.Equals(InventoryWindow.ItemsBoughtCommandName) || command.Name.Equals(InventoryWindow.ItemsSoldCommandName))
                    {
                        extraSpecialIdentifiers["itemtotal"]    = "5";
                        extraSpecialIdentifiers["itemname"]     = "Chocolate Bars";
                        extraSpecialIdentifiers["itemcost"]     = "500";
                        extraSpecialIdentifiers["currencyname"] = "CURRENCY_NAME";
                    }
                }

                await command.PerformAndWait(currentUser, new List <string>() { "@" + currentUser.UserName }, extraSpecialIdentifiers);

                if (command is PermissionsCommandBase)
                {
                    PermissionsCommandBase permissionCommand = (PermissionsCommandBase)command;
                    permissionCommand.ResetCooldown(await ChannelSession.GetCurrentUser());
                }
                this.SwitchToPlay();
            }

            this.RaiseEvent(new RoutedEventArgs(CommandButtonsControl.PlayClickedEvent, this));
        }
Example #28
0
 public InteractiveConnectedButtonCommand(InteractiveConnectedSceneModel scene, InteractiveConnectedButtonControlModel button, InteractiveCommand command) : base(scene, button, command)
 {
 }