public override ActionBase GetAction() { if (this.XSplitTypeComboBox.SelectedIndex >= 0) { if (this.XSplitSceneGrid.Visibility == Visibility.Visible && !string.IsNullOrEmpty(this.XSplitSceneNameTextBox.Text)) { return(new XSplitAction(this.XSplitSceneNameTextBox.Text)); } else if (this.XSplitSourceGrid.Visibility == Visibility.Visible && !string.IsNullOrEmpty(this.XSplitSourceNameTextBox.Text)) { if (this.XSplitSourceTextGrid.Visibility == Visibility.Visible) { if (!string.IsNullOrEmpty(this.XSplitSourceTextTextBox.Text)) { XSplitAction action = new XSplitAction(this.XSplitSourceNameTextBox.Text, this.XSplitSourceVisibleCheckBox.IsChecked.GetValueOrDefault(), this.XSplitSourceTextTextBox.Text); action.UpdateReferenceTextFile(); return(action); } } else if (this.XSplitSourceWebBrowserGrid.Visibility == Visibility.Visible) { if (!string.IsNullOrEmpty(this.XSplitSourceWebPageTextBox.Text)) { return(new XSplitAction(this.XSplitSourceNameTextBox.Text, this.XSplitSourceVisibleCheckBox.IsChecked.GetValueOrDefault(), null, this.XSplitSourceWebPageTextBox.Text)); } } else { XSplitAction action = new XSplitAction(this.XSplitSourceNameTextBox.Text, this.XSplitSourceVisibleCheckBox.IsChecked.GetValueOrDefault()); action.UpdateReferenceTextFile(); return(action); } } } return(null); }
private static async Task Version16Upgrade(int version, string filePath) { if (version < 16) { string data = File.ReadAllText(filePath); DesktopChannelSettings settings = SerializerHelper.DeserializeFromString <DesktopChannelSettings>(data); await ChannelSession.Services.Settings.Initialize(settings); List <CommandBase> commands = new List <CommandBase>(); commands.AddRange(settings.ChatCommands); commands.AddRange(settings.EventCommands); commands.AddRange(settings.InteractiveCommands); commands.AddRange(settings.TimerCommands); commands.AddRange(settings.ActionGroupCommands); commands.AddRange(settings.GameCommands); foreach (CommandBase command in commands) { for (int i = 0; i < command.Actions.Count; i++) { ActionBase action = command.Actions[i]; #pragma warning disable CS0612 // Type or member is obsolete if (action is OBSStudioAction || action is XSplitAction || action is StreamlabsOBSAction) { StreamingSoftwareTypeEnum type = StreamingSoftwareTypeEnum.OBSStudio; string scene = null; string source = null; bool visible = false; string text = null; string textPath = null; string url = null; StreamingSourceDimensions dimensions = null; if (action is OBSStudioAction) { type = StreamingSoftwareTypeEnum.OBSStudio; OBSStudioAction obsAction = (OBSStudioAction)action; scene = obsAction.SceneName; source = obsAction.SourceName; visible = obsAction.SourceVisible; text = obsAction.SourceText; url = obsAction.SourceURL; dimensions = obsAction.SourceDimensions; if (!string.IsNullOrEmpty(source)) { textPath = GetDefaultReferenceFilePath(OBSStudioReferenceTextFilesDirectory, source); } } else if (action is XSplitAction) { type = StreamingSoftwareTypeEnum.XSplit; XSplitAction xsplitAction = (XSplitAction)action; scene = xsplitAction.SceneName; source = xsplitAction.SourceName; visible = xsplitAction.SourceVisible; text = xsplitAction.SourceText; url = xsplitAction.SourceURL; if (!string.IsNullOrEmpty(source)) { textPath = GetDefaultReferenceFilePath(XSplitReferenceTextFilesDirectory, source); } } else if (action is StreamlabsOBSAction) { type = StreamingSoftwareTypeEnum.StreamlabsOBS; StreamlabsOBSAction slobsAction = (StreamlabsOBSAction)action; scene = slobsAction.SceneName; source = slobsAction.SourceName; visible = slobsAction.SourceVisible; text = slobsAction.SourceText; if (!string.IsNullOrEmpty(source)) { textPath = GetDefaultReferenceFilePath(StreamlabsOBSStudioReferenceTextFilesDirectory, source); } } #pragma warning restore CS0612 // Type or member is obsolete StreamingSoftwareAction sAction = null; if (!string.IsNullOrEmpty(scene)) { sAction = StreamingSoftwareAction.CreateSceneAction(type, scene); } else if (!string.IsNullOrEmpty(text)) { sAction = StreamingSoftwareAction.CreateTextSourceAction(type, source, visible, text, textPath); } else if (!string.IsNullOrEmpty(url)) { sAction = StreamingSoftwareAction.CreateWebBrowserSourceAction(type, source, visible, url); } else if (dimensions != null) { sAction = StreamingSoftwareAction.CreateSourceDimensionsAction(type, source, visible, dimensions); } else { sAction = StreamingSoftwareAction.CreateSourceVisibilityAction(type, source, visible); } command.Actions[i] = sAction; } } } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version2Upgrade(int version, string filePath) { if (version < 2) { string data = File.ReadAllText(filePath); data = data.Replace("interactiveControlsInternal", "interactiveCommandsInternal"); data = data.Replace("CapsBlockCount", "ModerationCapsBlockCount"); data = data.Replace("PunctuationBlockCount", "ModerationPunctuationBlockCount"); data = data.Replace("EmoteBlockCount", "ModerationEmoteBlockCount"); data = data.Replace("BlockLinks", "ModerationBlockLinks"); data = data.Replace("Timeout1MinuteOffenseCount", "ModerationTimeout1MinuteOffenseCount"); data = data.Replace("Timeout5MinuteOffenseCount", "ModerationTimeout5MinuteOffenseCount"); File.WriteAllText(filePath, data); DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); List <CommandBase> commands = new List <CommandBase>(); commands.AddRange(settings.ChatCommands); commands.AddRange(settings.InteractiveCommands); commands.AddRange(settings.EventCommands); commands.AddRange(settings.TimerCommands); foreach (CommandBase command in commands) { foreach (ActionBase action in command.Actions) { if (action is ChatAction) { ChatAction nAction = (ChatAction)action; nAction.ChatText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.ChatText); } else if (action is CurrencyAction) { CurrencyAction nAction = (CurrencyAction)action; nAction.ChatText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.ChatText); } else if (action is OBSStudioAction) { OBSStudioAction nAction = (OBSStudioAction)action; nAction.SourceText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.SourceText); } else if (action is OverlayAction) { OverlayAction nAction = (OverlayAction)action; nAction.ImagePath = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.ImagePath); nAction.Text = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.Text); } else if (action is TextToSpeechAction) { TextToSpeechAction nAction = (TextToSpeechAction)action; nAction.SpeechText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.SpeechText); } else if (action is XSplitAction) { XSplitAction nAction = (XSplitAction)action; nAction.SourceText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion2(nAction.SourceText); } } } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version5Upgrade(int version, string filePath) { if (version < 5) { LegacyDesktopChannelSettings legacySettings = await SerializerHelper.DeserializeFromFile <LegacyDesktopChannelSettings>(filePath); DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); foreach (string quote in legacySettings.quotesInternal) { settings.UserQuotes.Add(new UserQuoteViewModel(quote)); } List <CommandBase> commands = new List <CommandBase>(); commands.AddRange(settings.ChatCommands); commands.AddRange(settings.InteractiveCommands); commands.AddRange(settings.EventCommands); commands.AddRange(settings.TimerCommands); UserCurrencyViewModel currency = settings.Currencies.Values.FirstOrDefault(c => !c.IsRank); if (currency == null) { currency = settings.Currencies.Values.FirstOrDefault(); } foreach (CommandBase command in commands) { foreach (ActionBase action in command.Actions) { if (action is InteractiveAction) { InteractiveAction nAction = (InteractiveAction)action; #pragma warning disable CS0612 // Type or member is obsolete if (nAction.AddUserToGroup) { nAction.InteractiveType = InteractiveActionTypeEnum.MoveUserToGroup; } else { nAction.InteractiveType = InteractiveActionTypeEnum.MoveGroupToScene; } nAction.SceneID = nAction.MoveGroupToScene; #pragma warning restore CS0612 // Type or member is obsolete } if (currency != null) { if (action is ChatAction) { ChatAction nAction = (ChatAction)action; nAction.ChatText = nAction.ChatText.Replace("$usercurrencyname", currency.Name); } else if (action is CurrencyAction) { CurrencyAction nAction = (CurrencyAction)action; nAction.ChatText = nAction.ChatText.Replace("$usercurrencyname", currency.Name); } else if (action is OBSStudioAction) { OBSStudioAction nAction = (OBSStudioAction)action; if (!string.IsNullOrEmpty(nAction.SourceText)) { nAction.SourceText = nAction.SourceText.Replace("$usercurrencyname", currency.Name); } } else if (action is OverlayAction) { OverlayAction nAction = (OverlayAction)action; if (!string.IsNullOrEmpty(nAction.Text)) { nAction.Text = nAction.Text.Replace("$usercurrencyname", currency.Name); } } else if (action is TextToSpeechAction) { TextToSpeechAction nAction = (TextToSpeechAction)action; nAction.SpeechText = nAction.SpeechText.Replace("$usercurrencyname", currency.Name); } else if (action is XSplitAction) { XSplitAction nAction = (XSplitAction)action; if (!string.IsNullOrEmpty(nAction.SourceText)) { nAction.SourceText = nAction.SourceText.Replace("$usercurrencyname", currency.Name); } } } } } foreach (GameCommandBase game in settings.GameCommands) { if (game is IndividualProbabilityGameCommand) { IndividualProbabilityGameCommand individualGame = (IndividualProbabilityGameCommand)game; DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(individualGame.UserJoinedCommand); DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(individualGame.LoseLeftoverCommand); foreach (GameOutcome outcome in individualGame.Outcomes) { DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(outcome.ResultCommand); } } else if (game is OnlyOneWinnerGameCommand) { OnlyOneWinnerGameCommand oneWinnerGame = (OnlyOneWinnerGameCommand)game; DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(oneWinnerGame.UserJoinedCommand); } } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version4Upgrade(int version, string filePath) { if (version < 4) { string data = File.ReadAllText(filePath); data = data.Replace("MixItUp.Base.Actions.RankAction", "MixItUp.Base.Actions.CurrencyAction"); data = data.Replace("\"Type\": 13\n", "\"Type\": 1\n"); File.WriteAllText(filePath, data); LegacyDesktopChannelSettings legacySettings = await SerializerHelper.DeserializeFromFile <LegacyDesktopChannelSettings>(filePath); legacySettings.InitializeDB = false; List <LegacyUserDataViewModel> legacyUsers = new List <LegacyUserDataViewModel>(); if (legacySettings.IsStreamer) { string dbPath = ((DesktopSettingsService)ChannelSession.Services.Settings).GetDatabaseFilePath(legacySettings); SQLiteDatabaseWrapper databaseWrapper = new SQLiteDatabaseWrapper(dbPath); await databaseWrapper.RunReadCommand("SELECT * FROM Users", (SQLiteDataReader dataReader) => { LegacyUserDataViewModel userData = new LegacyUserDataViewModel(dataReader); legacyUsers.Add(userData); }); File.Copy(DesktopSettingsService.SettingsTemplateDatabaseFileName, dbPath, overwrite: true); } await ChannelSession.Services.Settings.Initialize(legacySettings); DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); settings.InitializeDB = false; await ChannelSession.Services.Settings.Initialize(settings); UserCurrencyViewModel currency = null; UserCurrencyViewModel rank = null; if (settings.IsStreamer) { if (!string.IsNullOrEmpty(legacySettings.CurrencyAcquisition.Name)) { currency = legacySettings.CurrencyAcquisition; currency.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(currency.Name); settings.Currencies.Add(legacySettings.CurrencyAcquisition.ID, legacySettings.CurrencyAcquisition); } if (!string.IsNullOrEmpty(legacySettings.RankAcquisition.Name)) { rank = legacySettings.RankAcquisition; rank.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rank.Name); rank.Ranks = legacySettings.Ranks; rank.RankChangedCommand = legacySettings.RankChangedCommand; settings.Currencies.Add(legacySettings.RankAcquisition.ID, legacySettings.RankAcquisition); } foreach (LegacyUserDataViewModel user in legacyUsers) { settings.UserData[user.ID] = user; if (rank != null) { settings.UserData[user.ID].SetCurrencyAmount(rank, user.RankPoints); } if (currency != null) { settings.UserData[user.ID].SetCurrencyAmount(currency, user.CurrencyAmount); } } if (currency != null) { if (legacySettings.GiveawayCurrencyCost > 0) { settings.GiveawayCurrencyRequirement = new UserCurrencyRequirementViewModel(currency, legacySettings.GiveawayCurrencyCost); } if (legacySettings.GameQueueCurrencyCost > 0) { settings.GameQueueCurrencyRequirement = new UserCurrencyRequirementViewModel(currency, legacySettings.GameQueueCurrencyCost); } } if (rank != null) { if (legacySettings.GiveawayUserRank != null && rank.Ranks.Any(r => r.Name.Equals(legacySettings.GiveawayUserRank))) { settings.GiveawayRankRequirement = new UserCurrencyRequirementViewModel(rank, rank.Ranks.FirstOrDefault(r => r.Name.Equals(legacySettings.GiveawayUserRank))); } if (legacySettings.GameQueueMinimumRank != null) { settings.GameQueueRankRequirement = new UserCurrencyRequirementViewModel(rank, legacySettings.GameQueueMinimumRank); } } } List <CommandBase> commands = new List <CommandBase>(); commands.AddRange(settings.ChatCommands); commands.AddRange(settings.InteractiveCommands); commands.AddRange(settings.EventCommands); commands.AddRange(settings.TimerCommands); foreach (CommandBase command in commands) { foreach (ActionBase action in command.Actions) { if (action is ChatAction) { ChatAction nAction = (ChatAction)action; nAction.ChatText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.ChatText, currency, rank); } else if (action is CurrencyAction) { CurrencyAction nAction = (CurrencyAction)action; nAction.ChatText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.ChatText, currency, rank); } else if (action is OBSStudioAction) { OBSStudioAction nAction = (OBSStudioAction)action; nAction.SourceText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.SourceText, currency, rank); } else if (action is OverlayAction) { OverlayAction nAction = (OverlayAction)action; nAction.ImagePath = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.ImagePath, currency, rank); nAction.Text = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.Text, currency, rank); } else if (action is TextToSpeechAction) { TextToSpeechAction nAction = (TextToSpeechAction)action; nAction.SpeechText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.SpeechText, currency, rank); } else if (action is XSplitAction) { XSplitAction nAction = (XSplitAction)action; nAction.SourceText = DesktopSettingsUpgrader.ReplaceSpecialIdentifiersVersion4(nAction.SourceText, currency, rank); } } } if (settings.IsStreamer) { foreach (ChatCommand command in settings.ChatCommands) { #pragma warning disable CS0612 // Type or member is obsolete if (command.CurrencyCost > 0) { command.CurrencyRequirement = new UserCurrencyRequirementViewModel(currency, command.CurrencyCost); } #pragma warning restore CS0612 // Type or member is obsolete } } await ChannelSession.Services.Settings.Save(settings); } }
public XSplitActionControl(ActionContainerControl containerControl, XSplitAction action) : this(containerControl) { this.action = action; }