From 8356290c3f51d134700ce38556af0679a83da1bb Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Wed, 21 Apr 2021 22:58:45 +1200 Subject: [PATCH] [WIP] Part way through alt game exe Have updated the loading and storing of the alternative game exe monitoring and created the user interface for it. Need to next: - create a file selection dialog - have the file selected result in the name being extracted into the text file - actually set up the RunShortcut to use the alternative monitoring if set --- DisplayMagician/ShortcutItem.cs | 39 +++++ .../UIForms/ShortcutForm.Designer.cs | 144 +++++++++++------- DisplayMagician/UIForms/ShortcutForm.cs | 43 +++++- 3 files changed, 171 insertions(+), 55 deletions(-) diff --git a/DisplayMagician/ShortcutItem.cs b/DisplayMagician/ShortcutItem.cs index 06140c7..5238611 100644 --- a/DisplayMagician/ShortcutItem.cs +++ b/DisplayMagician/ShortcutItem.cs @@ -67,6 +67,8 @@ namespace DisplayMagician public int StartTimeout; public string GameArguments; public bool GameArgumentsRequired; + public string DifferentGameExeToMonitor; + public bool MonitorDifferentGameExe; } public struct ShortcutError @@ -95,6 +97,8 @@ namespace DisplayMagician private int _startTimeout = 20; private string _gameArguments; private bool _gameArgumentsRequired; + private string _differentGameExeToMonitor; + private bool _monitorDifferentGameExe = false; private string _audioDevice; private bool _changeAudioDevice; private bool _setAudioVolume = false; @@ -286,6 +290,8 @@ namespace DisplayMagician int gameTimeout, string gameArguments, bool gameArgumentsRequired, + string differentGameExeToMonitor, + bool monitorDifferentGameExe, ShortcutPermanence displayPermanence, ShortcutPermanence audioPermanence, ShortcutPermanence capturePermanence, @@ -314,6 +320,8 @@ namespace DisplayMagician _startTimeout = gameTimeout; _gameArguments = gameArguments; _gameArgumentsRequired = gameArgumentsRequired; + _differentGameExeToMonitor = differentGameExeToMonitor; + _monitorDifferentGameExe = monitorDifferentGameExe; _changeAudioDevice = changeAudioDevice; _audioDevice = audioDevice; _setAudioVolume = setAudioVolume; @@ -379,6 +387,8 @@ namespace DisplayMagician _startTimeout = game.StartTimeout; _gameArguments = game.GameArguments; _gameArgumentsRequired = game.GameArgumentsRequired; + _differentGameExeToMonitor = game.DifferentGameExeToMonitor; + _monitorDifferentGameExe = game.MonitorDifferentGameExe; _changeAudioDevice = changeAudioDevice; _audioDevice = audioDevice; _setAudioVolume = setAudioVolume; @@ -442,6 +452,8 @@ namespace DisplayMagician _startTimeout = game.StartTimeout; _gameArguments = game.GameArguments; _gameArgumentsRequired = game.GameArgumentsRequired; + _differentGameExeToMonitor = game.DifferentGameExeToMonitor; + _monitorDifferentGameExe = game.MonitorDifferentGameExe; _gameArgumentsRequired = false; _changeAudioDevice = changeAudioDevice; _audioDevice = audioDevice; @@ -991,6 +1003,33 @@ namespace DisplayMagician } } + public string DifferentGameExeToMonitor + { + get + { + return _differentGameExeToMonitor; + } + + set + { + _differentGameExeToMonitor = value; + } + } + + public bool MonitorDifferentGameExe + { + get + { + return _monitorDifferentGameExe; + } + + set + { + _monitorDifferentGameExe = value; + } + } + + public string AudioDevice { get diff --git a/DisplayMagician/UIForms/ShortcutForm.Designer.cs b/DisplayMagician/UIForms/ShortcutForm.Designer.cs index 3116524..52629f9 100644 --- a/DisplayMagician/UIForms/ShortcutForm.Designer.cs +++ b/DisplayMagician/UIForms/ShortcutForm.Designer.cs @@ -44,6 +44,9 @@ namespace DisplayMagician.UIForms this.ilv_saved_profiles = new Manina.Windows.Forms.ImageListView(); this.dv_profile = new DisplayMagicianShared.UserControls.DisplayView(); this.tabp_audio = new System.Windows.Forms.TabPage(); + this.lbl_no_active_capture_devices = new System.Windows.Forms.Label(); + this.lbl_no_active_audio_devices = new System.Windows.Forms.Label(); + this.lbl_disabled_shortcut_audio_chipset = new System.Windows.Forms.Label(); this.gb_capture_settings = new System.Windows.Forms.GroupBox(); this.gb_capture_volume = new System.Windows.Forms.GroupBox(); this.rb_set_capture_volume = new System.Windows.Forms.RadioButton(); @@ -118,6 +121,8 @@ namespace DisplayMagician.UIForms this.rb_standalone = new System.Windows.Forms.RadioButton(); this.rb_no_game = new System.Windows.Forms.RadioButton(); this.p_game = new System.Windows.Forms.Panel(); + this.btn_choose_alternative_game = new System.Windows.Forms.Button(); + this.txt_alternative_game = new System.Windows.Forms.TextBox(); this.txt_game_launcher = new System.Windows.Forms.TextBox(); this.txt_game_name = new System.Windows.Forms.TextBox(); this.lbl_game_library = new System.Windows.Forms.Label(); @@ -146,9 +151,7 @@ namespace DisplayMagician.UIForms this.lbl_title = new System.Windows.Forms.Label(); this.lbl_shortcut_name = new System.Windows.Forms.Label(); this.cb_autosuggest = new System.Windows.Forms.CheckBox(); - this.lbl_disabled_shortcut_audio_chipset = new System.Windows.Forms.Label(); - this.lbl_no_active_audio_devices = new System.Windows.Forms.Label(); - this.lbl_no_active_capture_devices = new System.Windows.Forms.Label(); + this.cb_wait_alternative_game = new System.Windows.Forms.CheckBox(); this.tabc_shortcut.SuspendLayout(); this.tabp_display.SuspendLayout(); this.tabp_audio.SuspendLayout(); @@ -336,6 +339,56 @@ namespace DisplayMagician.UIForms this.tabp_audio.TabIndex = 4; this.tabp_audio.Text = "2. Choose Audio"; // + // lbl_no_active_capture_devices + // + this.lbl_no_active_capture_devices.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.lbl_no_active_capture_devices.AutoSize = true; + this.lbl_no_active_capture_devices.BackColor = System.Drawing.Color.Brown; + this.lbl_no_active_capture_devices.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lbl_no_active_capture_devices.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); + this.lbl_no_active_capture_devices.ForeColor = System.Drawing.Color.White; + this.lbl_no_active_capture_devices.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.lbl_no_active_capture_devices.Location = new System.Drawing.Point(126, 433); + this.lbl_no_active_capture_devices.Name = "lbl_no_active_capture_devices"; + this.lbl_no_active_capture_devices.Size = new System.Drawing.Size(831, 22); + this.lbl_no_active_capture_devices.TabIndex = 36; + this.lbl_no_active_capture_devices.Text = "No active microphone inputs found. Please connect or enable at least one micropho" + + "ne if you want to use this feature."; + this.lbl_no_active_capture_devices.Visible = false; + // + // lbl_no_active_audio_devices + // + this.lbl_no_active_audio_devices.Anchor = System.Windows.Forms.AnchorStyles.None; + this.lbl_no_active_audio_devices.AutoSize = true; + this.lbl_no_active_audio_devices.BackColor = System.Drawing.Color.Brown; + this.lbl_no_active_audio_devices.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lbl_no_active_audio_devices.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); + this.lbl_no_active_audio_devices.ForeColor = System.Drawing.Color.White; + this.lbl_no_active_audio_devices.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.lbl_no_active_audio_devices.Location = new System.Drawing.Point(131, 151); + this.lbl_no_active_audio_devices.Name = "lbl_no_active_audio_devices"; + this.lbl_no_active_audio_devices.Size = new System.Drawing.Size(804, 22); + this.lbl_no_active_audio_devices.TabIndex = 35; + this.lbl_no_active_audio_devices.Text = "No active audio outputs found. Please connect or enable at least one audio output" + + " if you want to use this feature."; + this.lbl_no_active_audio_devices.Visible = false; + // + // lbl_disabled_shortcut_audio_chipset + // + this.lbl_disabled_shortcut_audio_chipset.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.lbl_disabled_shortcut_audio_chipset.AutoSize = true; + this.lbl_disabled_shortcut_audio_chipset.BackColor = System.Drawing.Color.Brown; + this.lbl_disabled_shortcut_audio_chipset.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lbl_disabled_shortcut_audio_chipset.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); + this.lbl_disabled_shortcut_audio_chipset.ForeColor = System.Drawing.Color.White; + this.lbl_disabled_shortcut_audio_chipset.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.lbl_disabled_shortcut_audio_chipset.Location = new System.Drawing.Point(326, 298); + this.lbl_disabled_shortcut_audio_chipset.Name = "lbl_disabled_shortcut_audio_chipset"; + this.lbl_disabled_shortcut_audio_chipset.Size = new System.Drawing.Size(430, 22); + this.lbl_disabled_shortcut_audio_chipset.TabIndex = 34; + this.lbl_disabled_shortcut_audio_chipset.Text = "Unsupported Audio Chipset. Setting audio isn\'t supported :("; + this.lbl_disabled_shortcut_audio_chipset.Visible = false; + // // gb_capture_settings // this.gb_capture_settings.Controls.Add(this.gb_capture_volume); @@ -1236,6 +1289,9 @@ namespace DisplayMagician.UIForms // // p_game // + this.p_game.Controls.Add(this.cb_wait_alternative_game); + this.p_game.Controls.Add(this.btn_choose_alternative_game); + this.p_game.Controls.Add(this.txt_alternative_game); this.p_game.Controls.Add(this.txt_game_launcher); this.p_game.Controls.Add(this.txt_game_name); this.p_game.Controls.Add(this.lbl_game_library); @@ -1252,6 +1308,26 @@ namespace DisplayMagician.UIForms this.p_game.Size = new System.Drawing.Size(1006, 278); this.p_game.TabIndex = 7; // + // btn_choose_alternative_game + // + this.btn_choose_alternative_game.Enabled = false; + this.btn_choose_alternative_game.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_choose_alternative_game.ForeColor = System.Drawing.Color.White; + this.btn_choose_alternative_game.Location = new System.Drawing.Point(878, 224); + this.btn_choose_alternative_game.Name = "btn_choose_alternative_game"; + this.btn_choose_alternative_game.Size = new System.Drawing.Size(85, 27); + this.btn_choose_alternative_game.TabIndex = 26; + this.btn_choose_alternative_game.Text = "Choose"; + this.btn_choose_alternative_game.UseVisualStyleBackColor = true; + // + // txt_alternative_game + // + this.txt_alternative_game.Enabled = false; + this.txt_alternative_game.Location = new System.Drawing.Point(667, 225); + this.txt_alternative_game.Name = "txt_alternative_game"; + this.txt_alternative_game.Size = new System.Drawing.Size(205, 26); + this.txt_alternative_game.TabIndex = 24; + // // txt_game_launcher // this.txt_game_launcher.Location = new System.Drawing.Point(605, 76); @@ -1378,7 +1454,7 @@ namespace DisplayMagician.UIForms this.lv_games.LargeImageList = this.il_games; this.lv_games.Location = new System.Drawing.Point(23, 30); this.lv_games.Name = "lv_games"; - this.lv_games.Size = new System.Drawing.Size(338, 217); + this.lv_games.Size = new System.Drawing.Size(338, 221); this.lv_games.SmallImageList = this.il_games; this.lv_games.TabIndex = 22; this.lv_games.UseCompatibleStateImageBehavior = false; @@ -1583,55 +1659,16 @@ namespace DisplayMagician.UIForms this.cb_autosuggest.UseVisualStyleBackColor = true; this.cb_autosuggest.CheckedChanged += new System.EventHandler(this.cb_autosuggest_CheckedChanged); // - // lbl_disabled_shortcut_audio_chipset + // cb_wait_alternative_game // - this.lbl_disabled_shortcut_audio_chipset.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.lbl_disabled_shortcut_audio_chipset.AutoSize = true; - this.lbl_disabled_shortcut_audio_chipset.BackColor = System.Drawing.Color.Brown; - this.lbl_disabled_shortcut_audio_chipset.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.lbl_disabled_shortcut_audio_chipset.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); - this.lbl_disabled_shortcut_audio_chipset.ForeColor = System.Drawing.Color.White; - this.lbl_disabled_shortcut_audio_chipset.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.lbl_disabled_shortcut_audio_chipset.Location = new System.Drawing.Point(326, 298); - this.lbl_disabled_shortcut_audio_chipset.Name = "lbl_disabled_shortcut_audio_chipset"; - this.lbl_disabled_shortcut_audio_chipset.Size = new System.Drawing.Size(430, 22); - this.lbl_disabled_shortcut_audio_chipset.TabIndex = 34; - this.lbl_disabled_shortcut_audio_chipset.Text = "Unsupported Audio Chipset. Setting audio isn\'t supported :("; - this.lbl_disabled_shortcut_audio_chipset.Visible = false; - // - // lbl_no_active_audio_devices - // - this.lbl_no_active_audio_devices.Anchor = System.Windows.Forms.AnchorStyles.None; - this.lbl_no_active_audio_devices.AutoSize = true; - this.lbl_no_active_audio_devices.BackColor = System.Drawing.Color.Brown; - this.lbl_no_active_audio_devices.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.lbl_no_active_audio_devices.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); - this.lbl_no_active_audio_devices.ForeColor = System.Drawing.Color.White; - this.lbl_no_active_audio_devices.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.lbl_no_active_audio_devices.Location = new System.Drawing.Point(131, 151); - this.lbl_no_active_audio_devices.Name = "lbl_no_active_audio_devices"; - this.lbl_no_active_audio_devices.Size = new System.Drawing.Size(804, 22); - this.lbl_no_active_audio_devices.TabIndex = 35; - this.lbl_no_active_audio_devices.Text = "No active audio outputs found. Please connect or enable at least one audio output" + - " if you want to use this feature."; - this.lbl_no_active_audio_devices.Visible = false; - // - // lbl_no_active_capture_devices - // - this.lbl_no_active_capture_devices.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.lbl_no_active_capture_devices.AutoSize = true; - this.lbl_no_active_capture_devices.BackColor = System.Drawing.Color.Brown; - this.lbl_no_active_capture_devices.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.lbl_no_active_capture_devices.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); - this.lbl_no_active_capture_devices.ForeColor = System.Drawing.Color.White; - this.lbl_no_active_capture_devices.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.lbl_no_active_capture_devices.Location = new System.Drawing.Point(126, 433); - this.lbl_no_active_capture_devices.Name = "lbl_no_active_capture_devices"; - this.lbl_no_active_capture_devices.Size = new System.Drawing.Size(831, 22); - this.lbl_no_active_capture_devices.TabIndex = 36; - this.lbl_no_active_capture_devices.Text = "No active microphone inputs found. Please connect or enable at least one micropho" + - "ne if you want to use this feature."; - this.lbl_no_active_capture_devices.Visible = false; + this.cb_wait_alternative_game.AutoSize = true; + this.cb_wait_alternative_game.Location = new System.Drawing.Point(451, 214); + this.cb_wait_alternative_game.Name = "cb_wait_alternative_game"; + this.cb_wait_alternative_game.Size = new System.Drawing.Size(220, 44); + this.cb_wait_alternative_game.TabIndex = 27; + this.cb_wait_alternative_game.Text = "Wait until this executable \r\nis closed before continuing:"; + this.cb_wait_alternative_game.UseVisualStyleBackColor = true; + this.cb_wait_alternative_game.CheckedChanged += new System.EventHandler(this.cb_wait_alternative_game_CheckedChanged); // // ShortcutForm // @@ -1819,5 +1856,8 @@ namespace DisplayMagician.UIForms private System.Windows.Forms.Label lbl_disabled_shortcut_audio_chipset; private System.Windows.Forms.Label lbl_no_active_audio_devices; private System.Windows.Forms.Label lbl_no_active_capture_devices; + private System.Windows.Forms.Button btn_choose_alternative_game; + private System.Windows.Forms.TextBox txt_alternative_game; + private System.Windows.Forms.CheckBox cb_wait_alternative_game; } } \ No newline at end of file diff --git a/DisplayMagician/UIForms/ShortcutForm.cs b/DisplayMagician/UIForms/ShortcutForm.cs index 8aa47c0..fc51aae 100644 --- a/DisplayMagician/UIForms/ShortcutForm.cs +++ b/DisplayMagician/UIForms/ShortcutForm.cs @@ -493,7 +493,9 @@ namespace DisplayMagician.UIForms GameToPlay = (from steamGame in SteamLibrary.GetLibrary().AllInstalledGames where steamGame.Id == _gameId select steamGame).First(), StartTimeout = Convert.ToInt32(nud_timeout_game.Value), GameArguments = txt_args_game.Text, - GameArgumentsRequired = cb_args_game.Checked + GameArgumentsRequired = cb_args_game.Checked, + DifferentGameExeToMonitor = txt_alternative_game.Text, + MonitorDifferentGameExe = cb_wait_alternative_game.Checked }; _shortcutToEdit.UpdateGameShortcut( @@ -528,7 +530,9 @@ namespace DisplayMagician.UIForms GameToPlay = (from uplayGame in UplayLibrary.GetLibrary().AllInstalledGames where uplayGame.Id == _gameId select uplayGame).First(), StartTimeout = Convert.ToInt32(nud_timeout_game.Value), GameArguments = txt_args_game.Text, - GameArgumentsRequired = cb_args_game.Checked + GameArgumentsRequired = cb_args_game.Checked, + DifferentGameExeToMonitor = txt_alternative_game.Text, + MonitorDifferentGameExe = cb_wait_alternative_game.Checked }; _shortcutToEdit.UpdateGameShortcut( @@ -562,7 +566,9 @@ namespace DisplayMagician.UIForms GameToPlay = (from originGame in OriginLibrary.GetLibrary().AllInstalledGames where originGame.Id == _gameId select originGame).First(), StartTimeout = Convert.ToInt32(nud_timeout_game.Value), GameArguments = txt_args_game.Text, - GameArgumentsRequired = cb_args_game.Checked + GameArgumentsRequired = cb_args_game.Checked, + DifferentGameExeToMonitor = txt_alternative_game.Text, + MonitorDifferentGameExe = cb_wait_alternative_game.Checked }; _shortcutToEdit.UpdateGameShortcut( @@ -1082,6 +1088,21 @@ namespace DisplayMagician.UIForms break; } + // Monitor the alternative game exe if we have it + if (_shortcutToEdit.MonitorDifferentGameExe) + { + cb_wait_alternative_game.Checked = true; + if (!String.IsNullOrWhiteSpace(_shortcutToEdit.DifferentGameExeToMonitor)) + { + txt_alternative_game.Text = _shortcutToEdit.DifferentGameExeToMonitor; + } + } + else + { + cb_wait_alternative_game.Checked = false; + } + + // Set the launcher items if we have them if (_shortcutToEdit.GameLibrary.Equals(SupportedGameLibraryType.Unknown)) { @@ -2202,5 +2223,21 @@ namespace DisplayMagician.UIForms else cb_start_program4.CheckState = CheckState.Unchecked; } + + private void cb_wait_alternative_game_CheckedChanged(object sender, EventArgs e) + { + if (_loadedShortcut) + _isUnsaved = true; + if (cb_wait_alternative_game.Checked) + { + txt_alternative_game.Enabled = true; + btn_choose_alternative_game.Enabled = true; + } + else + { + txt_alternative_game.Enabled = false; + btn_choose_alternative_game.Enabled = false; + } + } } } \ No newline at end of file