diff --git a/Source/Frontend/UI/Components/Blast Editor/SanitizeToolForm.cs b/Source/Frontend/UI/Components/Blast Editor/SanitizeToolForm.cs index f2c9f300..cdc4b91e 100644 --- a/Source/Frontend/UI/Components/Blast Editor/SanitizeToolForm.cs +++ b/Source/Frontend/UI/Components/Blast Editor/SanitizeToolForm.cs @@ -286,7 +286,8 @@ private void AddToStockpile(object sender, EventArgs e) SystemCore = oldSk.SystemCore, GameName = oldSk.GameName, SyncSettings = oldSk.SyncSettings, - StateLocation = oldSk.StateLocation + StateLocation = oldSk.StateLocation, + EmuVer = oldSk.EmuVer }; newSk.BlastLayer = (BlastLayer)oldSk.BlastLayer.Clone(); StockpileManagerUISide.StashHistory.Add(newSk); @@ -323,7 +324,8 @@ private void AddToStash(object sender, EventArgs e) SystemCore = oldSk.SystemCore, GameName = oldSk.GameName, SyncSettings = oldSk.SyncSettings, - StateLocation = oldSk.StateLocation + StateLocation = oldSk.StateLocation, + EmuVer = oldSk.EmuVer }; newSk.BlastLayer = (BlastLayer)oldSk.BlastLayer.Clone(); StockpileManagerUISide.StashHistory.Add(newSk); @@ -390,7 +392,8 @@ public FastSanitizer(StashKey originalStashkey, BlastLayer blClone) SystemCore = originalStashkey.SystemCore, GameName = originalStashkey.GameName, SyncSettings = originalStashkey.SyncSettings, - StateLocation = originalStashkey.StateLocation + StateLocation = originalStashkey.StateLocation, + EmuVer = originalStashkey.EmuVer }; internalSK.BlastLayer = blClone; OriginalLayer = blClone; @@ -522,7 +525,7 @@ internal async Task Disable50() internal async Task LoadCorrupt() { internalSK.BlastLayer = new BlastLayer(shownHalf); - S.GET().IsCorruptionApplied = internalSK.Run(); + S.GET().IsCorruptionApplied = await internalSK.Run(); await Task.Delay(1); } @@ -554,7 +557,7 @@ internal StashKey GetStashKeyMinusChanges() internal async Task Replay() { - S.GET().IsCorruptionApplied = internalSK.Run(); + S.GET().IsCorruptionApplied = await internalSK.Run(); await Task.Delay(1); } diff --git a/Source/Frontend/UI/Components/Controls/SavestateList.cs b/Source/Frontend/UI/Components/Controls/SavestateList.cs index 8ffd6322..762c08ec 100644 --- a/Source/Frontend/UI/Components/Controls/SavestateList.cs +++ b/Source/Frontend/UI/Components/Controls/SavestateList.cs @@ -8,6 +8,7 @@ namespace RTCV.UI.Components.Controls using System.Drawing.Design; using System.IO; using System.Linq; + using System.Threading.Tasks; using System.Windows.Forms; using CorruptCore; using NetCore; @@ -255,7 +256,8 @@ public void BtnSavestate_MouseDown(object sender, MouseEventArgs e) SystemCore = psk.SystemCore, GameName = psk.GameName, SyncSettings = psk.SyncSettings, - StateLocation = psk.StateLocation + StateLocation = psk.StateLocation, + EmuVer = psk.EmuVer }; newStashkey.BlastLayer = new BlastLayer(); @@ -268,7 +270,7 @@ public void BtnSavestate_MouseDown(object sender, MouseEventArgs e) StashKey sk = StockpileManagerUISide.SaveState(); RegisterStashKeyTo(holder, sk); }) - .AddItem("Load this entry", (ob, ev) => + .AddItem("Load this entry", async (ob, ev) => { var holder = (SavestateHolder)((Button)sender).Parent; StashKey psk = holder.sk; @@ -279,7 +281,7 @@ public void BtnSavestate_MouseDown(object sender, MouseEventArgs e) return; } - StockpileManagerUISide.LoadState(psk); + await StockpileManagerUISide.LoadState(psk); } else { @@ -404,7 +406,7 @@ private bool CheckAndFixingMissingStates(StashKey psk) return true; } - public void LoadCurrentState() + public async Task LoadCurrentState() { StashKey psk = SelectedHolder?.sk; if (psk != null) @@ -414,7 +416,7 @@ public void LoadCurrentState() return; } - StockpileManagerUISide.LoadState(psk); + await StockpileManagerUISide.LoadState(psk); } else { @@ -524,7 +526,7 @@ private void btnSaveLoad_MouseDown(object sender, MouseEventArgs e) } } - internal void LoadPreviousSavestateNow() + internal async Task LoadPreviousSavestateNow() { var sk = SelectedHolder?.sk; @@ -549,8 +551,7 @@ internal void LoadPreviousSavestateNow() return; } - - StockpileManagerUISide.LoadState(prevHolder.sk); + await StockpileManagerUISide.LoadState(prevHolder.sk); StockpileManagerUISide.CurrentStashkey = null; S.GET().IsCorruptionApplied = false; LocalNetCoreRouter.Route(NetCore.Endpoints.CorruptCore, NetCore.Commands.Remote.ClearBlastlayerCache, false); diff --git a/Source/Frontend/UI/Components/Engine Config/GeneralParametersForm.cs b/Source/Frontend/UI/Components/Engine Config/GeneralParametersForm.cs index 14ef56e5..f633b813 100644 --- a/Source/Frontend/UI/Components/Engine Config/GeneralParametersForm.cs +++ b/Source/Frontend/UI/Components/Engine Config/GeneralParametersForm.cs @@ -39,14 +39,22 @@ private void UpdateCreateInfiniteUnits(object sender, EventArgs e) RtcCore.CreateInfiniteUnits = cbCreateInfiniteUnits.Checked; } - private void OnFormShown(object sender, EventArgs e) + public void UpdateMaxIntensity() { object paramValue = AllSpec.VanguardSpec[VSPEC.OVERRIDE_DEFAULTMAXINTENSITY]; if (paramValue is int maxIntensity) - { multiTB_Intensity.SetMaximum(maxIntensity, false); - } + else + multiTB_Intensity.SetMaximum(65535, false); + + if (multiTB_Intensity.Value > multiTB_Intensity.Maximum) + multiTB_Intensity.Value = multiTB_Intensity.Maximum; + } + + private void OnFormShown(object sender, EventArgs e) + { + UpdateMaxIntensity(); } } } diff --git a/Source/Frontend/UI/Components/Glitch Harvester/GlitchHarvesterBlastForm.cs b/Source/Frontend/UI/Components/Glitch Harvester/GlitchHarvesterBlastForm.cs index ff9ef56a..1d76019b 100644 --- a/Source/Frontend/UI/Components/Glitch Harvester/GlitchHarvesterBlastForm.cs +++ b/Source/Frontend/UI/Components/Glitch Harvester/GlitchHarvesterBlastForm.cs @@ -11,6 +11,10 @@ namespace RTCV.UI using NetCore; using RTCV.Common; using Modular; + using System.Threading; + using System.Threading.Tasks; + using RTCV.NetCore.Enums; + using System.Timers; public partial class GlitchHarvesterBlastForm : ComponentForm, IBlockable { @@ -95,7 +99,7 @@ private void UpdateBlastToggleColor(bool value) this.updatingBackColor = false; } - private void OnDragDrop(object sender, DragEventArgs e) + private async void OnDragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false); foreach (var f in files) @@ -104,7 +108,7 @@ private void OnDragDrop(object sender, DragEventArgs e) { BlastLayer bl = BlastTools.LoadBlastLayerFromFile(f); var newStashKey = new StashKey(RtcCore.GetRandomKey(), null, bl); - S.GET().IsCorruptionApplied = StockpileManagerUISide.ApplyStashkey(newStashKey, false, false); + S.GET().IsCorruptionApplied = await StockpileManagerUISide.ApplyStashkey(newStashKey, false, false); } } } @@ -114,24 +118,35 @@ private void OnDragEnter(object sender, DragEventArgs e) e.Effect = DragDropEffects.Link; } - public void OneTimeExecute() + + + public async void OneTimeExecute() { logger.Trace("Entering OneTimeExecute()"); //Disable autocorrupt S.GET().AutoCorrupt = false; + bool killswitchWasEnabled = AutoKillSwitch.Enabled; + + // If the stockpile entry is from a different emulator, close the current one and wait until the new one has connected + if (!String.Equals(StockpileManagerUISide.CurrentStashkey.EmuVer, new DirectoryInfo(RtcCore.EmuDir).Name, StringComparison.OrdinalIgnoreCase)) + { + if (!(await VanguardImplementation.SwapImplementation(StockpileManagerUISide.CurrentStashkey.EmuVer))) + return; + } + if (ghMode == GlitchHarvesterMode.CORRUPT) { - IsCorruptionApplied = StockpileManagerUISide.ApplyStashkey(StockpileManagerUISide.CurrentStashkey, loadBeforeOperation); + IsCorruptionApplied = await StockpileManagerUISide.ApplyStashkey(StockpileManagerUISide.CurrentStashkey, loadBeforeOperation); } else if (ghMode == GlitchHarvesterMode.INJECT) { - IsCorruptionApplied = StockpileManagerUISide.InjectFromStashkey(StockpileManagerUISide.CurrentStashkey, loadBeforeOperation); + IsCorruptionApplied = await StockpileManagerUISide.InjectFromStashkey(StockpileManagerUISide.CurrentStashkey, loadBeforeOperation); S.GET().RefreshStashHistory(); } else if (ghMode == GlitchHarvesterMode.ORIGINAL) { - IsCorruptionApplied = StockpileManagerUISide.OriginalFromStashkey(StockpileManagerUISide.CurrentStashkey); + IsCorruptionApplied = await StockpileManagerUISide.OriginalFromStashkey(StockpileManagerUISide.CurrentStashkey); } if (Render.RenderAtLoad && loadBeforeOperation) @@ -142,6 +157,13 @@ public void OneTimeExecute() { Render.StopRender(); } + + logger.Trace("Unlocking Interface"); + UICore.UnlockInterface(); + logger.Trace("Load done"); + + AutoKillSwitch.Enabled = killswitchWasEnabled; + logger.Trace("Exiting OneTimeExecute()"); } @@ -196,7 +218,7 @@ public void refreshRenderOutputButton() } } - public void Corrupt(object sender, EventArgs e) + public async void Corrupt(object sender, EventArgs e) { logger.Trace("btnCorrupt Clicked"); @@ -212,12 +234,6 @@ public void Corrupt(object sender, EventArgs e) { SetBlastButtonVisibility(false); - if (!(AllSpec.UISpec[UISPEC.SELECTEDDOMAINS] is string[] domains) || domains.Length == 0) - { - MessageBox.Show("Can't corrupt with no domains selected."); - return; - } - //Shut off autocorrupt if it's on. //Leave this check here so we don't wastefully update the spec if (S.GET().AutoCorrupt) @@ -238,7 +254,7 @@ public void Corrupt(object sender, EventArgs e) sks.Add((StashKey)row.Cells[0].Value); } - IsCorruptionApplied = StockpileManagerUISide.MergeStashkeys(sks); + IsCorruptionApplied = await StockpileManagerUISide.MergeStashkeys(sks); S.GET().RefreshStashHistorySelectLast(); //lbStashHistory.TopIndex = lbStashHistory.Items.Count - 1; @@ -257,7 +273,7 @@ public void Corrupt(object sender, EventArgs e) } S.GET().DontLoadSelectedStash = true; - IsCorruptionApplied = StockpileManagerUISide.Corrupt(loadBeforeOperation); + IsCorruptionApplied = await StockpileManagerUISide.Corrupt(loadBeforeOperation); S.GET().RefreshStashHistorySelectLast(); } else if (ghMode == GlitchHarvesterMode.INJECT) @@ -278,7 +294,7 @@ public void Corrupt(object sender, EventArgs e) S.GET().DontLoadSelectedStash = true; - IsCorruptionApplied = StockpileManagerUISide.InjectFromStashkey(StockpileManagerUISide.CurrentStashkey, loadBeforeOperation); + IsCorruptionApplied = await StockpileManagerUISide.InjectFromStashkey(StockpileManagerUISide.CurrentStashkey, loadBeforeOperation); S.GET().RefreshStashHistorySelectLast(); } else if (ghMode == GlitchHarvesterMode.ORIGINAL) @@ -296,7 +312,7 @@ public void Corrupt(object sender, EventArgs e) } S.GET().DontLoadSelectedStash = true; - IsCorruptionApplied = StockpileManagerUISide.OriginalFromStashkey(StockpileManagerUISide.CurrentStashkey); + IsCorruptionApplied = await StockpileManagerUISide.OriginalFromStashkey(StockpileManagerUISide.CurrentStashkey); } if (Render.RenderAtLoad && loadBeforeOperation) @@ -330,9 +346,9 @@ public void btnCorrupt_MouseDown(object sender, MouseEventArgs e) new ContextMenuBuilder() .AddItem("Blast + Send RAW To Stash", (ob, ev) => BlastRawStash()) - .AddItem("Corrupt", (ob, ev) => CorruptWithMode(GlitchHarvesterMode.CORRUPT)) - .AddItem("Inject", (ob, ev) => CorruptWithMode(GlitchHarvesterMode.INJECT)) - .AddItem("Original", (ob, ev) => CorruptWithMode(GlitchHarvesterMode.ORIGINAL)) + .AddItem("Corrupt", async (ob, ev) => await Task.Run(() => CorruptWithMode(GlitchHarvesterMode.CORRUPT))) + .AddItem("Inject", async (ob, ev) => await Task.Run(() => CorruptWithMode(GlitchHarvesterMode.INJECT))) + .AddItem("Original", async (ob, ev) => await Task.Run(() => CorruptWithMode(GlitchHarvesterMode.ORIGINAL))) .Build() .Show(this, locate); @@ -428,7 +444,7 @@ private void OnRerollButtonMouseDown(object sender, MouseEventArgs e) } } - public void RerollSelected(object sender, EventArgs e) + public async void RerollSelected(object sender, EventArgs e) { if (!btnRerollSelected.Visible) { @@ -476,7 +492,7 @@ public void RerollSelected(object sender, EventArgs e) .lbStashHistory.Items.Count - 1; } - IsCorruptionApplied = StockpileManagerUISide.ApplyStashkey(StockpileManagerUISide.CurrentStashkey); + IsCorruptionApplied = await StockpileManagerUISide.ApplyStashkey(StockpileManagerUISide.CurrentStashkey); } } finally diff --git a/Source/Frontend/UI/Components/Glitch Harvester/GlitchHarvesterIntensityForm.cs b/Source/Frontend/UI/Components/Glitch Harvester/GlitchHarvesterIntensityForm.cs index 8c40f5e3..ae493feb 100644 --- a/Source/Frontend/UI/Components/Glitch Harvester/GlitchHarvesterIntensityForm.cs +++ b/Source/Frontend/UI/Components/Glitch Harvester/GlitchHarvesterIntensityForm.cs @@ -20,14 +20,22 @@ public GlitchHarvesterIntensityForm() multiTB_Intensity.ValueChanged += (sender, args) => RtcCore.Intensity = multiTB_Intensity.Value; } - private void OnFormShown(object sender, EventArgs e) + public void UpdateMaxIntensity() { object paramValue = AllSpec.VanguardSpec[VSPEC.OVERRIDE_DEFAULTMAXINTENSITY]; - if (paramValue != null && paramValue is int maxintensity) - { - multiTB_Intensity.SetMaximum(maxintensity, false); - } + if (paramValue is int maxIntensity) + multiTB_Intensity.SetMaximum(maxIntensity, false); + else + multiTB_Intensity.SetMaximum(65535, false); + + if (multiTB_Intensity.Value > multiTB_Intensity.Maximum) + multiTB_Intensity.Value = multiTB_Intensity.Maximum; + } + + private void OnFormShown(object sender, EventArgs e) + { + UpdateMaxIntensity(); } } } diff --git a/Source/Frontend/UI/Components/Glitch Harvester/SavestateManagerForm.cs b/Source/Frontend/UI/Components/Glitch Harvester/SavestateManagerForm.cs index d48b7f49..b79a848a 100644 --- a/Source/Frontend/UI/Components/Glitch Harvester/SavestateManagerForm.cs +++ b/Source/Frontend/UI/Components/Glitch Harvester/SavestateManagerForm.cs @@ -130,11 +130,13 @@ private void loadSSK(bool import, string fileName) } var s = (string)AllSpec.VanguardSpec?[VSPEC.NAME] ?? "ERROR"; + /* if (!string.IsNullOrEmpty(ssk.VanguardImplementation) && !ssk.VanguardImplementation.Equals(s, StringComparison.OrdinalIgnoreCase) && ssk.VanguardImplementation != "ERROR") { MessageBox.Show($"The ssk you loaded is for a different Vanguard implementation.\nThe ssk reported {ssk.VanguardImplementation} but you're connected to {s}.\nThis is a fatal error. Aborting load."); return; } + */ if (import) { diff --git a/Source/Frontend/UI/Components/Glitch Harvester/StashHistoryForm.cs b/Source/Frontend/UI/Components/Glitch Harvester/StashHistoryForm.cs index 7720dd5e..83fdf7d4 100644 --- a/Source/Frontend/UI/Components/Glitch Harvester/StashHistoryForm.cs +++ b/Source/Frontend/UI/Components/Glitch Harvester/StashHistoryForm.cs @@ -8,6 +8,8 @@ namespace RTCV.UI using RTCV.NetCore; using RTCV.Common; using RTCV.UI.Modular; + using System.IO; + using System.Threading.Tasks; public partial class StashHistoryForm : ComponentForm, IBlockable { @@ -68,9 +70,13 @@ public bool AddStashToStockpile(bool askForName = true, string itemName = null) string Name = ""; string value = ""; + + StashKey sk = (StashKey)lbStashHistory.SelectedItem; StockpileManagerUISide.CurrentStashkey = sk; + // Disabled with the addition of cross-emulator stockpiles + /* //If we don't support mixed stockpiles if (!((bool?)AllSpec.VanguardSpec[VSPEC.SUPPORTS_MIXED_STOCKPILE] ?? false)) { @@ -85,6 +91,7 @@ public bool AddStashToStockpile(bool askForName = true, string itemName = null) } } } + */ if (askForName) { @@ -131,7 +138,8 @@ public bool AddStashToStockpile(bool askForName = true, string itemName = null) dataRow.Cells["GameName"].Value = sk.GameName; dataRow.Cells["SystemName"].Value = sk.SystemName; dataRow.Cells["SystemCore"].Value = sk.SystemCore; - + dataRow.Cells["EmuVer"].Value = sk.EmuVer; + S.GET().RefreshNoteIcons(); StockpileManagerUISide.StashHistory.Remove(sk); @@ -238,7 +246,7 @@ private void HandleStashHistoryMouseDown(object sender, MouseEventArgs e) S.GET().RefreshVMDs(); }, selectionExists) .AddSeparator() - .AddItem("Merge Selected Stashkeys", (ob, ev) => + .AddItem("Merge Selected Stashkeys", async (ob, ev) => { List sks = new List(); foreach (StashKey sk in lbStashHistory.SelectedItems) @@ -246,7 +254,7 @@ private void HandleStashHistoryMouseDown(object sender, MouseEventArgs e) sks.Add(sk); } - StockpileManagerUISide.MergeStashkeys(sks); + await StockpileManagerUISide.MergeStashkeys(sks); RefreshStashHistorySelectLast(); }, selectionExists && lbStashHistory.SelectedItems.Count > 1) diff --git a/Source/Frontend/UI/Components/Glitch Harvester/StockpileEmuVersionForm.Designer.cs b/Source/Frontend/UI/Components/Glitch Harvester/StockpileEmuVersionForm.Designer.cs new file mode 100644 index 00000000..e13ac87f --- /dev/null +++ b/Source/Frontend/UI/Components/Glitch Harvester/StockpileEmuVersionForm.Designer.cs @@ -0,0 +1,112 @@ +namespace RTCV.UI +{ + partial class StockpileEmuVersionForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.EmuVersionDropDown = new System.Windows.Forms.ComboBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(13, 9); + this.label1.MaximumSize = new System.Drawing.Size(800, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(727, 93); + this.label1.TabIndex = 0; + this.label1.Text = "RTC has detected some stockpile entries do not have an associated emulator system" + + " and version. Please select the system and version this stockpile was created in" + + ".\r\n"; + this.label1.Click += new System.EventHandler(this.label1_Click); + // + // EmuVersionDropDown + // + this.EmuVersionDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.EmuVersionDropDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.EmuVersionDropDown.FormattingEnabled = true; + this.EmuVersionDropDown.Location = new System.Drawing.Point(19, 149); + this.EmuVersionDropDown.MaxDropDownItems = 3; + this.EmuVersionDropDown.Name = "EmuVersionDropDown"; + this.EmuVersionDropDown.Size = new System.Drawing.Size(769, 41); + this.EmuVersionDropDown.TabIndex = 1; + this.EmuVersionDropDown.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // button1 + // + this.button1.AutoSize = true; + this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1.Location = new System.Drawing.Point(219, 255); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(121, 43); + this.button1.TabIndex = 2; + this.button1.Text = "OK"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.AutoSize = true; + this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button2.Location = new System.Drawing.Point(460, 255); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(121, 43); + this.button2.TabIndex = 3; + this.button2.Text = "Cancel"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // StockpileEmuVersionForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 310); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.EmuVersionDropDown); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "StockpileEmuVersionForm"; + this.ShowIcon = false; + this.TopMost = true; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox EmuVersionDropDown; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + } +} \ No newline at end of file diff --git a/Source/Frontend/UI/Components/Glitch Harvester/StockpileEmuVersionForm.cs b/Source/Frontend/UI/Components/Glitch Harvester/StockpileEmuVersionForm.cs new file mode 100644 index 00000000..e7b74e9a --- /dev/null +++ b/Source/Frontend/UI/Components/Glitch Harvester/StockpileEmuVersionForm.cs @@ -0,0 +1,66 @@ +using RTCV.CorruptCore; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Security.Policy; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RTCV.UI +{ + public partial class StockpileEmuVersionForm : Form + { + public string SelectedVersion; + public StockpileEmuVersionForm(bool detected = true) + { + InitializeComponent(); + + string detected_text = "RTC has detected this stockpile does not have an associated emulator system and version. Please select the system and version this stockpile was created in."; + string default_text = "Please select the system and version the selected stockpile items were created in."; + + + label1.Text = detected ? detected_text : default_text; + + var directories = Directory.GetDirectories(new DirectoryInfo(RtcCore.RtcDir).Parent.Parent.FullName); + foreach(var dir in directories) + { + var dirName = new DirectoryInfo(dir).Name; + if (dirName != "Launcher" && dirName != "RTCV") + { + EmuVersionDropDown.Items.Add(dirName); + } + } + } + + private void comboBox1_Click(object sender, EventArgs e) + { + EmuVersionDropDown.DroppedDown = true; + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + SelectedVersion = (string)EmuVersionDropDown.SelectedItem; + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void label1_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/Source/Frontend/UI/Components/Glitch Harvester/StockpileEmuVersionForm.resx b/Source/Frontend/UI/Components/Glitch Harvester/StockpileEmuVersionForm.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/Source/Frontend/UI/Components/Glitch Harvester/StockpileEmuVersionForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.cs b/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.cs index c6b92106..b2a1fc68 100644 --- a/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.cs +++ b/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.cs @@ -51,7 +51,7 @@ public StockpileManagerForm() btnSaveStockpileAs.BackColorChanged += (o, e) => UpdateSaveButtonColor(UnsavedEdits); } - public void HandleCellClick(object sender, DataGridViewCellEventArgs e) + public async void HandleCellClick(object sender, DataGridViewCellEventArgs e) { if (e == null || e.RowIndex == -1) { @@ -123,7 +123,7 @@ public void HandleCellClick(object sender, DataGridViewCellEventArgs e) sks.Reverse(); - StockpileManagerUISide.MergeStashkeys(sks); + await StockpileManagerUISide.MergeStashkeys(sks); if (Render.RenderAtLoad && S.GET().loadBeforeOperation) { @@ -195,12 +195,12 @@ private void HandleStockpileMouseDown(object sender, MouseEventArgs e) } }, rowCount == 1) .AddSeparator() - .AddItem("Manual Inject", (ob, ev) => + .AddItem("Manual Inject", async (ob, ev) => { var sk = this.GetSelectedStashKey(); StashKey newSk = (StashKey)sk.Clone(); - bool isCorrupted = StockpileManagerUISide.ApplyStashkey(newSk, false, false); + bool isCorrupted = await StockpileManagerUISide.ApplyStashkey(newSk, false, false); if (StockpileManagerUISide.CurrentStashkey != null) S.GET().IsCorruptionApplied = isCorrupted; @@ -226,7 +226,7 @@ private void HandleStockpileMouseDown(object sender, MouseEventArgs e) MemoryDomains.GenerateVmdFromStashkey(sk); S.GET().RefreshVMDs(); }, rowCount == 1) - .AddItem("Merge Selected Stashkeys", (ob, ev) => + .AddItem("Merge Selected Stashkeys", async (ob, ev) => { List sks = new List(); foreach (DataGridViewRow row in this.dgvStockpile.SelectedRows) @@ -234,7 +234,7 @@ private void HandleStockpileMouseDown(object sender, MouseEventArgs e) sks.Add((StashKey)row.Cells[0].Value); } - StockpileManagerUISide.MergeStashkeys(sks); + await StockpileManagerUISide.MergeStashkeys(sks); S.GET().RefreshStashHistorySelectLast(); }, rowCount > 1) .AddItem("Replace Associated ROM", (ob, ev) => @@ -396,6 +396,63 @@ public void ClearStockpile(bool force = false) } } + // Check if any emulators in the stockpile are not installed, and prompt the user + // to select an emu version if it's a legacy stockpile. + public bool CheckForEmulators(Stockpile sks) + { + List missingEmulators = new List { }; + bool missingEmuVer = false; + foreach (StashKey key in sks.StashKeys) + { + if (key.EmuVer != "") + { + string emulatorPath = Path.Combine(RtcCore.RtcDir, "..\\..\\", key.EmuVer); + if (!Directory.Exists(emulatorPath) && !missingEmulators.Contains(key.EmuVer)) + missingEmulators.Add(key.EmuVer); + } + // Update stashkey emulator version if it's empty + else + { + missingEmuVer = true; + } + } + + if (missingEmulators.Count > 0) + { + string missingEmulatorsString = ""; + foreach (string emulator in missingEmulators) + { + missingEmulatorsString += emulator + "\n"; + } + string missingEmulatorsMessage = "You are missing the following emulators used in this stockpile: \n\n" + + String.Join(Environment.NewLine, missingEmulatorsString + "\n" + + "Please install these emulators and then load the stockpile again."); + MessageBox.Show(missingEmulatorsMessage, "Operation cancelled", MessageBoxButtons.OK); + return false; + } + else if (missingEmuVer) + { + var form = new StockpileEmuVersionForm(); + + // start/show the control + form.ShowDialog(); + + if (form.SelectedVersion != null) + { + foreach (StashKey key in sks.StashKeys) + { + key.EmuVer = form.SelectedVersion; + } + } + else + { + MessageBox.Show("Emulator system and version selection was cancelled, the stockpile will not be loaded.", "Operation cancelled", MessageBoxButtons.OK); + return false; + } + } + return true; + } + public async void LoadStockpile(string filename) { logger.Trace("Entered LoadStockpile {0}", Thread.CurrentThread.ManagedThreadId); @@ -427,6 +484,7 @@ public async void LoadStockpile(string filename) logger.Trace("Starting Load Task"); var r = await Task.Run(() => Stockpile.Load(filename)); logger.Trace("Load Task Done"); + if (r.Failed) { logger.Trace("Load Task Failed"); @@ -440,10 +498,14 @@ public async void LoadStockpile(string filename) //Update the current stockpile to this one StockpileManagerUISide.SetCurrentStockpile(sks); + + if (!CheckForEmulators(sks)) + return; + logger.Trace("Populating DGV"); foreach (StashKey key in sks.StashKeys) { - dgvStockpile?.Rows.Add(key, key.GameName, key.SystemName, key.SystemCore, key.Note); + dgvStockpile?.Rows.Add(key, key.GameName, key.SystemName, key.SystemCore, key.EmuVer, key.Note); } btnSaveStockpile.Enabled = true; @@ -459,7 +521,7 @@ public async void LoadStockpile(string filename) dgvStockpile.ClearSelection(); StockpileManagerUISide.StockpileChanged(); - UnsavedEdits = false; + UnsavedEdits = true; } finally { @@ -492,9 +554,12 @@ private async void ImportStockpile(string filename) //Populate the dgv RtcCore.OnProgressBarUpdate(sks, new ProgressBarEventArgs($"Populating UI", 95)); + if (!CheckForEmulators(sks)) + return; + foreach (StashKey key in sks.StashKeys) { - dgvStockpile?.Rows.Add(key, key.GameName, key.SystemName, key.SystemCore, key.Note); + dgvStockpile?.Rows.Add(key, key.GameName, key.SystemName, key.SystemCore, key.EmuVer, key.Note); } UnsavedEdits = true; @@ -789,7 +854,7 @@ private void ImportStockpile(object sender, EventArgs e) } } - private void StockpileUp(object sender, EventArgs e) + private async void StockpileUp(object sender, EventArgs e) { if (dgvStockpile.SelectedRows.Count == 0) { @@ -811,11 +876,11 @@ private void StockpileUp(object sender, EventArgs e) if (_loadEntryWhenSelectedWithArrows) { - HandleCellClick(dgvStockpile, new DataGridViewCellEventArgs(0, dgvStockpile.SelectedRows[0].Index)); + await Task.Run(() => HandleCellClick(dgvStockpile, new DataGridViewCellEventArgs(0, dgvStockpile.SelectedRows[0].Index))); } } - private void StockpileDown(object sender, EventArgs e) + private async void StockpileDown(object sender, EventArgs e) { if (dgvStockpile.SelectedRows.Count == 0) { @@ -837,7 +902,7 @@ private void StockpileDown(object sender, EventArgs e) if (_loadEntryWhenSelectedWithArrows) { - HandleCellClick(dgvStockpile, new DataGridViewCellEventArgs(0, dgvStockpile.SelectedRows[0].Index)); + await Task.Run(() => HandleCellClick(dgvStockpile, new DataGridViewCellEventArgs(0, dgvStockpile.SelectedRows[0].Index))); } } @@ -848,6 +913,7 @@ private void OnFormLoad(object sender, EventArgs e) dgvStockpile.DragEnter += HandleDragEnter; } + internal ToolStripButton UpdateEmuVersionButton; private void HandleGlitchHarvesterSettingsMouseDown(object sender, MouseEventArgs e) { Point locate = e.GetMouseLocation(sender); @@ -857,6 +923,7 @@ private void HandleGlitchHarvesterSettingsMouseDown(object sender, MouseEventArg bool gameNameVisible = columns["GameName"]!.Visible; bool systemNameVisible = columns["SystemName"]!.Visible; bool systemCoreVisible = columns["SystemCore"]!.Visible; + bool emuVerVisible = columns["EmuVer"]!.Visible; new ContextMenuBuilder() .AddHeader("Stockpile Manager Settings") @@ -891,9 +958,38 @@ private void HandleGlitchHarvesterSettingsMouseDown(object sender, MouseEventArg .AddItem("Show System Core", (ob, ev) => columns["SystemCore"]!.Visible = !systemCoreVisible, isChecked: systemCoreVisible) + + .AddItem("Show Emulator Version", (ob, ev) + => columns["EmuVer"]!.Visible = !emuVerVisible, + isChecked: emuVerVisible) + + .AddSeparator() + + .AddItem("Update Emulator Version", (ob, ev) + => UpdateEmuVersionButton_Click(ob, ev)) .Build() .Show(this, locate); } + + private void UpdateEmuVersionButton_Click(object sender, EventArgs e) + { + var form = new StockpileEmuVersionForm(false); + + // start/show the control + form.ShowDialog(); + + if (form.SelectedVersion != null) + { + foreach (DataGridViewRow row in dgvStockpile.SelectedRows) + { + ((StashKey)row.Cells[0].Value).EmuVer = form.SelectedVersion; + row.Cells[EmuVer.Index].Value = form.SelectedVersion; + } + + UnsavedEdits = true; + } + } + } } diff --git a/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.designer.cs b/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.designer.cs index eb9d8956..f002fc68 100644 --- a/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.designer.cs +++ b/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.designer.cs @@ -28,17 +28,12 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(StockpileManagerForm)); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.dgvStockpile = new RTCV.UI.Components.DataGridViewDraggable(); - this.Item = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.GameName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SystemName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SystemCore = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Note = new System.Windows.Forms.DataGridViewButtonColumn(); this.btnRenameSelected = new System.Windows.Forms.Button(); this.btnImportStockpile = new System.Windows.Forms.Button(); this.btnStockpileMoveSelectedDown = new System.Windows.Forms.Button(); @@ -51,6 +46,12 @@ private void InitializeComponent() this.btnStockpileUP = new System.Windows.Forms.Button(); this.btnRemoveSelectedStockpile = new System.Windows.Forms.Button(); this.btnGlitchHarvesterSettings = new System.Windows.Forms.Button(); + this.Item = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.GameName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SystemName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SystemCore = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.EmuVer = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Note = new System.Windows.Forms.DataGridViewButtonColumn(); ((System.ComponentModel.ISupportInitialize)(this.dgvStockpile)).BeginInit(); this.SuspendLayout(); // @@ -66,14 +67,14 @@ private void InitializeComponent() this.dgvStockpile.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dgvStockpile.BackgroundColor = System.Drawing.Color.Gray; this.dgvStockpile.BorderStyle = System.Windows.Forms.BorderStyle.None; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle5.Font = new System.Drawing.Font("Segoe UI Symbol", 8F); - dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgvStockpile.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI Symbol", 8F); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgvStockpile.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dgvStockpile.ColumnHeadersHeight = 21; this.dgvStockpile.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dgvStockpile.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { @@ -81,27 +82,28 @@ private void InitializeComponent() this.GameName, this.SystemName, this.SystemCore, + this.EmuVer, this.Note}); - dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle7.Font = new System.Drawing.Font("Segoe UI Symbol", 8F); - dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgvStockpile.DefaultCellStyle = dataGridViewCellStyle7; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle3.Font = new System.Drawing.Font("Segoe UI Symbol", 8F); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvStockpile.DefaultCellStyle = dataGridViewCellStyle3; this.dgvStockpile.GridColor = System.Drawing.Color.Black; this.dgvStockpile.Location = new System.Drawing.Point(12, 47); this.dgvStockpile.Name = "dgvStockpile"; this.dgvStockpile.RightToLeft = System.Windows.Forms.RightToLeft.No; - dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle8.Font = new System.Drawing.Font("Segoe UI Symbol", 8F); - dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgvStockpile.RowHeadersDefaultCellStyle = dataGridViewCellStyle8; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("Segoe UI Symbol", 8F); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgvStockpile.RowHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dgvStockpile.RowHeadersVisible = false; this.dgvStockpile.RowTemplate.Height = 25; this.dgvStockpile.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -111,49 +113,6 @@ private void InitializeComponent() this.dgvStockpile.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.HandleCellClick); this.dgvStockpile.MouseDown += new System.Windows.Forms.MouseEventHandler(this.HandleStockpileMouseDown); // - // Item - // - this.Item.FillWeight = 145F; - this.Item.HeaderText = "Item Name"; - this.Item.Name = "Item"; - this.Item.ReadOnly = true; - // - // GameName - // - this.GameName.FillWeight = 76.73162F; - this.GameName.HeaderText = "Game"; - this.GameName.Name = "GameName"; - this.GameName.ReadOnly = true; - // - // SystemName - // - this.SystemName.FillWeight = 60F; - this.SystemName.HeaderText = "System"; - this.SystemName.Name = "SystemName"; - this.SystemName.ReadOnly = true; - // - // SystemCore - // - this.SystemCore.FillWeight = 60F; - this.SystemCore.HeaderText = "Core"; - this.SystemCore.Name = "SystemCore"; - this.SystemCore.ReadOnly = true; - this.SystemCore.Visible = false; - // - // Note - // - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.Font = new System.Drawing.Font("Segoe UI Symbol", 14.25F); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.Black; - this.Note.DefaultCellStyle = dataGridViewCellStyle6; - this.Note.FillWeight = 23.01949F; - this.Note.HeaderText = "Note"; - this.Note.MinimumWidth = 35; - this.Note.Name = "Note"; - this.Note.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.Note.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; - this.Note.Text = ""; - // // btnRenameSelected // this.btnRenameSelected.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -402,6 +361,55 @@ private void InitializeComponent() this.btnGlitchHarvesterSettings.UseVisualStyleBackColor = false; this.btnGlitchHarvesterSettings.MouseDown += new System.Windows.Forms.MouseEventHandler(this.HandleGlitchHarvesterSettingsMouseDown); // + // Item + // + this.Item.FillWeight = 145F; + this.Item.HeaderText = "Item Name"; + this.Item.Name = "Item"; + this.Item.ReadOnly = true; + // + // GameName + // + this.GameName.FillWeight = 76.73162F; + this.GameName.HeaderText = "Game"; + this.GameName.Name = "GameName"; + this.GameName.ReadOnly = true; + // + // SystemName + // + this.SystemName.FillWeight = 60F; + this.SystemName.HeaderText = "System"; + this.SystemName.Name = "SystemName"; + this.SystemName.ReadOnly = true; + // + // SystemCore + // + this.SystemCore.FillWeight = 60F; + this.SystemCore.HeaderText = "Core"; + this.SystemCore.Name = "SystemCore"; + this.SystemCore.ReadOnly = true; + this.SystemCore.Visible = false; + // + // EmuVer + // + this.EmuVer.HeaderText = "Emu Version"; + this.EmuVer.Name = "EmuVer"; + this.EmuVer.Visible = false; + // + // Note + // + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.Font = new System.Drawing.Font("Segoe UI Symbol", 14.25F); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.Black; + this.Note.DefaultCellStyle = dataGridViewCellStyle2; + this.Note.FillWeight = 23.01949F; + this.Note.HeaderText = "Note"; + this.Note.MinimumWidth = 35; + this.Note.Name = "Note"; + this.Note.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Note.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.Note.Text = ""; + // // StockpileManagerForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -439,11 +447,6 @@ private void InitializeComponent() #endregion public Components.DataGridViewDraggable dgvStockpile; - private System.Windows.Forms.DataGridViewTextBoxColumn Item; - private System.Windows.Forms.DataGridViewTextBoxColumn GameName; - private System.Windows.Forms.DataGridViewTextBoxColumn SystemName; - private System.Windows.Forms.DataGridViewTextBoxColumn SystemCore; - private System.Windows.Forms.DataGridViewButtonColumn Note; public System.Windows.Forms.Button btnRenameSelected; private System.Windows.Forms.Button btnImportStockpile; private System.Windows.Forms.Button btnStockpileMoveSelectedDown; @@ -456,5 +459,11 @@ private void InitializeComponent() public System.Windows.Forms.Button btnStockpileUP; public System.Windows.Forms.Button btnRemoveSelectedStockpile; public System.Windows.Forms.Button btnGlitchHarvesterSettings; + private System.Windows.Forms.DataGridViewTextBoxColumn Item; + private System.Windows.Forms.DataGridViewTextBoxColumn GameName; + private System.Windows.Forms.DataGridViewTextBoxColumn SystemName; + private System.Windows.Forms.DataGridViewTextBoxColumn SystemCore; + private System.Windows.Forms.DataGridViewTextBoxColumn EmuVer; + private System.Windows.Forms.DataGridViewButtonColumn Note; } } diff --git a/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.resx b/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.resx index 777bb5fc..02b5c38d 100644 --- a/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.resx +++ b/Source/Frontend/UI/Components/Glitch Harvester/StockpileManagerForm.resx @@ -126,6 +126,9 @@ True + + True + True @@ -177,10 +180,11 @@ XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxS fNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYKf5X+ tfa5zvMffnP8rX82YnbiBf/Fp99LXsq/PPRq2aueuYC5R69TXy/MF72Rf3P4LeNt37vwd5MLWe+x7ys/ - 6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEQAACxEBf2RfkQAAAKpJREFUOE+dkAENwzAQ - AwuhEAZhUAqhUMZgEAZhEAahEAqhDP4rS/Hk/SdKM0tuo4/PTTq5+9Szmc1mtpmZl/edeykcHWD6YEkC - OvAeSpYEdWDMVi1JYAOmAWPve5IRWE/C9WcUVr+R/xd+kWPB7O7DsBZgeEU/sBYcMVlRgllwK4EtAKoq - zIK1hBZZq5owC3j/RynZr8IsUIDC7BnDNeNBAF/DFfBPUrDlE3aadkXmAozhAAAAAElFTkSuQmCC + 6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEAAACxABrSO9dQAAALRJREFUOE+dkAEVwiAU + RReBCEYwyiIsig2MYAQjGGERFoEG4Ltz3/MFdMN3zv38AZeNDTnnXVJKQcwib+PZ1qrNJYVsRLEe0pQM + bSrlxfUcMjZF0GJLZm5yc/GobCCz9v6SHtnw13j0yp67CP/KN/PsgCC6ZbCGySP5kMGaKPZSyUA5CTJv + YytNGSiTI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AGNJREFUOE9j+Pfv338y - 8fl///4ZMGCRIAW/RzbAAIuC/////wepEUDjN8D4cAOgElgNQJZD59PeAKjzUbxAqgEoGK8BpGDqGQDS - CQUYighguKZhZIABFkW4MEgthgFkAYoNAAAAXJCYTmj9pQAAAABJRU5ErkJggg== + 6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEAAACxABrSO9dQAAAHZJREFUOE+1j4ENgCAM + BB3BURjRDR3FDcBvI59Sog2il1zSwvuRJedcXrrDNFMgHrYgmZkCyaxu3+rOguuCH9pze+f3/wug/H7z + hNGCxseCEb8rwFLpQoEKB+ADkQoH4AORCgfgA5EKB5CgD90pWUWWKSYLSjkBAFyQmOuyT3AAAAAASUVO + RK5CYII= @@ -388,9 +393,10 @@ XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxS fNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYKf5X+ tfa5zvMffnP8rX82YnbiBf/Fp99LXsq/PPRq2aueuYC5R69TXy/MF72Rf3P4LeNt37vwd5MLWe+x7ys/ - 6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEQAACxEBf2RfkQAAAGNJREFUOE9j+Pfv338y - 8fl///4ZMGCRIAW/RzbAAIuC/////wepEUDjN8D4cAOgElgNQJZD59PeAKjzUbxAqgEoGK8BpGDqGQDS - CQUYighguKZhZIABFkW4MEgthgFkAYoNAAAAXJCYTmj9pQAAAABJRU5ErkJggg== + 6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEAAACxABrSO9dQAAAHZJREFUOE+1j4ENgCAM + BB3BURjRDR3FDcBvI59Sog2il1zSwvuRJedcXrrDNFMgHrYgmZkCyaxu3+rOguuCH9pze+f3/wug/H7z + hNGCxseCEb8rwFLpQoEKB+ADkQoH4AORC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zFr6kahsD9Zz9V18iNuDto5I9GcAcw6PPTyJ5wvQjJZ8JZyyR3M5ap7/H - WaKciebinzW17HNTj1XASzUzDkwCas0FmCMBKstOM+Oi0Bm/4d5CtS2qIpmvfiMmxrvOCLLsaiTmlWV8 - S2auLrWe7LkjDB7wRYqc1i1L+Jt1/JpM1Ww8j7BHAbajkq/fOX0p3nW/8x+3oID2q1PHcwAAAABJRU5E - rkJggg== + 6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEAAACxABrSO9dQAAAPpJREFUOE+FkwENwzAM + BAehEAqhEAZlEAqhDAopUAqhDJr9RfnISVfN0qvO2/7YXvbKOTdc1zUJScjCFvitcsSmWNMcoOC7Jhqc + b1ys6QTAkHzDmO+2i6q+ixOFQ9gr8M0vNZfOJhzPHLHGW2rBOuSARGAkS7G+s8DywPwkAukNgyMUn4HH + t0gcZ3N73nSqZ4uyE++l/Kz6euSyN884CpRWZSzMAh6tCMiaAMq2U+ChAHzbE19GGG0X4Enm1k/14Yh1 + Bknbo5HoIovdimXJQT9PZo6G+HhBeUgCNZNviPhnXX53EFCNxvkX12piMWAct9z+ztXHiIXd5NcXt6CA + 9pFX4VEAAAAASUVORK5CYII= diff --git a/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.cs b/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.cs index 3fb01f51..9ad01e3f 100644 --- a/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.cs +++ b/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.cs @@ -50,6 +50,10 @@ public void LoadConfigIntoUI() decimal.TryParse(Params.ReadParam("AUTOSAVE_MAX_SIZE"), out decimal maxSize) ? maxSize : 2.5m; + if (int.TryParse(Params.ReadParam("SWAP_EMU_TIMEOUT"), out int timeoutSeconds)) + nmSwapEmuTimeout.Value = timeoutSeconds; + else + nmSwapEmuTimeout.Value = 20; } private void OpenOnlineWiki(object sender, EventArgs e) @@ -142,6 +146,12 @@ private void MaxAutosaveSizeChanged(object sender, EventArgs e) AutoSave.SetMaxSize(this.nmMaxAutosaveSize.Value); } + private void nmSwapEmuTimeout_ValueChanged(object sender, EventArgs e) + { + Params.SetParam("SWAP_EMU_TIMEOUT", nmSwapEmuTimeout.Value.ToString()); + StockpileManagerUISide.timeout = (int)nmSwapEmuTimeout.Value; + } + //todo - rewrite this? /* private void btnImportKeyBindings_Click(object sender, EventArgs e) diff --git a/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.designer.cs b/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.designer.cs index c14d9650..99fc0b2e 100644 --- a/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.designer.cs +++ b/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.designer.cs @@ -30,6 +30,8 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsGeneralForm)); this.panel1 = new System.Windows.Forms.Panel(); + this.label5 = new System.Windows.Forms.Label(); + this.nmSwapEmuTimeout = new System.Windows.Forms.NumericUpDown(); this.label3 = new System.Windows.Forms.Label(); this.nmMaxAutosaveSize = new System.Windows.Forms.NumericUpDown(); this.label2 = new System.Windows.Forms.Label(); @@ -51,6 +53,7 @@ private void InitializeComponent() this.btnWatchTutorialVideo = new System.Windows.Forms.Button(); this.btnResetRandomSeed = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nmSwapEmuTimeout)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmMaxAutosaveSize)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmAutosaveSeconds)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmAutosaveMinutes)).BeginInit(); @@ -59,6 +62,8 @@ private void InitializeComponent() // panel1 // this.panel1.BackColor = System.Drawing.Color.Gray; + this.panel1.Controls.Add(this.label5); + this.panel1.Controls.Add(this.nmSwapEmuTimeout); this.panel1.Controls.Add(this.label3); this.panel1.Controls.Add(this.nmMaxAutosaveSize); this.panel1.Controls.Add(this.label2); @@ -73,12 +78,47 @@ private void InitializeComponent() this.panel1.Controls.Add(this.cbDontCleanAtQuit); this.panel1.Controls.Add(this.cbAllowCrossCoreCorruption); this.panel1.Controls.Add(this.cbDisableEmulatorOSD); - this.panel1.Location = new System.Drawing.Point(18, 206); + this.panel1.Location = new System.Drawing.Point(18, 197); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(323, 177); + this.panel1.Size = new System.Drawing.Size(323, 196); this.panel1.TabIndex = 138; this.panel1.Tag = "color:normal"; // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("Segoe UI", 8.25F); + this.label5.ForeColor = System.Drawing.Color.White; + this.label5.ImageAlign = System.Drawing.ContentAlignment.TopRight; + this.label5.Location = new System.Drawing.Point(55, 170); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(218, 13); + this.label5.TabIndex = 123; + this.label5.Text = "seconds before swapping emulators fails"; + this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // nmSwapEmuTimeout + // + this.nmSwapEmuTimeout.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.nmSwapEmuTimeout.Font = new System.Drawing.Font("Segoe UI", 8F); + this.nmSwapEmuTimeout.ForeColor = System.Drawing.Color.White; + this.nmSwapEmuTimeout.Location = new System.Drawing.Point(11, 168); + this.nmSwapEmuTimeout.Maximum = new decimal(new int[] { + 59, + 0, + 0, + 0}); + this.nmSwapEmuTimeout.Name = "nmSwapEmuTimeout"; + this.nmSwapEmuTimeout.Size = new System.Drawing.Size(44, 22); + this.nmSwapEmuTimeout.TabIndex = 122; + this.nmSwapEmuTimeout.Tag = "color:dark1"; + this.nmSwapEmuTimeout.Value = new decimal(new int[] { + 20, + 0, + 0, + 0}); + this.nmSwapEmuTimeout.ValueChanged += new System.EventHandler(this.nmSwapEmuTimeout_ValueChanged); + // // label3 // this.label3.AutoSize = true; @@ -87,7 +127,7 @@ private void InitializeComponent() this.label3.ImageAlign = System.Drawing.ContentAlignment.TopRight; this.label3.Location = new System.Drawing.Point(223, 152); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(25, 13); + this.label3.Size = new System.Drawing.Size(24, 13); this.label3.TabIndex = 121; this.label3.Text = "GiB"; this.label3.TextAlign = System.Drawing.ContentAlignment.TopRight; @@ -292,7 +332,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.label4.Font = new System.Drawing.Font("Segoe UI Semibold", 9F); this.label4.ForeColor = System.Drawing.Color.White; - this.label4.Location = new System.Drawing.Point(15, 188); + this.label4.Location = new System.Drawing.Point(15, 179); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(322, 15); this.label4.TabIndex = 139; @@ -416,6 +456,7 @@ private void InitializeComponent() this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.HandleMouseDown); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nmSwapEmuTimeout)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nmMaxAutosaveSize)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nmAutosaveSeconds)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nmAutosaveMinutes)).EndInit(); @@ -445,5 +486,7 @@ private void InitializeComponent() private System.Windows.Forms.Label label2; public System.Windows.Forms.NumericUpDown nmMaxAutosaveSize; private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label5; + public System.Windows.Forms.NumericUpDown nmSwapEmuTimeout; } } diff --git a/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.resx b/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.resx index 3e388d15..a02e1853 100644 --- a/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.resx +++ b/Source/Frontend/UI/Components/Settings/SettingsGeneralForm.resx @@ -122,16 +122,15 @@ iVBOR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Xw8ODAeJgQfDrlbXa43qEDc91f39vgDgEP4as9XqPG07d3d0lQJRMw8Fi + j9N//Dfjzc2Nub29FSXVcLDYk/fTS8Ph6vf7KRCl9A4QrxBdfhJ7tJccfQNRr9cTh1jDhRBLgFV2Nsge + UHhoOEzX19dVIA41TUXdbjfGOvPyJGNOy+hR8/LhHykwqgHJYSzLshhwSBEvgzXQdiNerriJg+p0OgkQ + h7/eOidVynJ+T/iT0G63DZA9ZKA4bl5rrKw2J/xJaLVaKZASMrDzh8zFnNaU9YY/CVdXVwaIgwW/NX1Q + rNUe1yP8BJrNZqXRaBiQ4jrhWlPBYg976UGvUzx+QFH0D+Jws14qr815AAAAAElFTkSuQmCC \ No newline at end of file diff --git a/Source/Frontend/UI/Forms/BlastEditorForm.cs b/Source/Frontend/UI/Forms/BlastEditorForm.cs index 6d1527a0..a52cb675 100644 --- a/Source/Frontend/UI/Forms/BlastEditorForm.cs +++ b/Source/Frontend/UI/Forms/BlastEditorForm.cs @@ -57,8 +57,9 @@ namespace RTCV.UI using RTCV.NetCore; using RTCV.Common; using RTCV.UI.Components; + using System.Threading.Tasks; - #pragma warning disable CA2213 //Component designer classes generate their own Dispose method +#pragma warning disable CA2213 //Component designer classes generate their own Dispose method public partial class BlastEditorForm : Modular.ColorizedForm { private const int buttonFillWeight = 20; @@ -1779,7 +1780,7 @@ public void ReplaceSavestateFromGlitchHarvester(object sender, EventArgs e) originalSK.StateLocation = temp.StateLocation; } - public void ReplaceSavestateFromFileToolStrip(string filename = null) + public async void ReplaceSavestateFromFileToolStrip(string filename = null) { if (filename == null) { @@ -1809,8 +1810,15 @@ public void ReplaceSavestateFromFileToolStrip(string filename = null) //Let's hope the game name is correct! File.Copy(filename, currentSK.GetSavestateFullPath(), true); + if (!String.Equals(currentSK.EmuVer, new DirectoryInfo(RtcCore.EmuDir).Name, StringComparison.OrdinalIgnoreCase)) + { + if (!(await VanguardImplementation.SwapImplementation(currentSK.EmuVer))) + return; + LocalNetCoreRouter.Route(Endpoints.UI, NetCore.Commands.Remote.UnlockInterface, true); + } + //Attempt to load and if it fails, don't let them update it. - if (!StockpileManagerUISide.LoadState(currentSK)) + if (!(await StockpileManagerUISide.LoadState(currentSK))) { currentSK.ParentKey = oldKey; currentSK.SyncSettings = oldSS; @@ -2064,7 +2072,7 @@ public void BakeBlastUnitsToValue(bool bakeSelected = false) } } - public void LoadCorrupt(object sender, EventArgs e) + public async void LoadCorrupt(object sender, EventArgs e) { if (currentSK.ParentKey == null) { @@ -2073,10 +2081,19 @@ public void LoadCorrupt(object sender, EventArgs e) } var newSk = (StashKey)currentSK.Clone(); - S.GET().IsCorruptionApplied = newSk.Run(); + + if (!String.Equals(newSk.EmuVer, new DirectoryInfo(RtcCore.EmuDir).Name, StringComparison.OrdinalIgnoreCase)) + { + + if (!(await VanguardImplementation.SwapImplementation(newSk.EmuVer))) + return; + LocalNetCoreRouter.Route(Endpoints.UI, NetCore.Commands.Remote.UnlockInterface, true); + } + + S.GET().IsCorruptionApplied = await newSk.Run(); } - public void LoadOriginal() + public async void LoadOriginal() { if (currentSK.ParentKey == null) { @@ -2086,13 +2103,13 @@ public void LoadOriginal() var newSk = (StashKey)currentSK.Clone(); newSk.BlastLayer.Layer.Clear(); - newSk.Run(); + await newSk.Run(); } - public void Corrupt(object sender, EventArgs e) + public async void Corrupt(object sender, EventArgs e) { var newSk = (StashKey)currentSK.Clone(); - S.GET().IsCorruptionApplied = StockpileManagerUISide.ApplyStashkey(newSk, false); + S.GET().IsCorruptionApplied = await StockpileManagerUISide.ApplyStashkey(newSk, false); } private void RefreshNoteIcons() diff --git a/Source/Frontend/UI/Forms/BlastGeneratorForm.cs b/Source/Frontend/UI/Forms/BlastGeneratorForm.cs index de5d1695..0d414890 100644 --- a/Source/Frontend/UI/Forms/BlastGeneratorForm.cs +++ b/Source/Frontend/UI/Forms/BlastGeneratorForm.cs @@ -11,6 +11,7 @@ namespace RTCV.UI using RTCV.NetCore; using RTCV.Common; using RTCV.UI.Components; + using System.Threading.Tasks; // 0 dgvBlastProtoReference // 1 dgvRowDirty @@ -31,7 +32,7 @@ namespace RTCV.UI //TYPE = BLASTUNITTYPE //MODE = GENERATIONMODE - #pragma warning disable CA2213 //Component designer classes generate their own Dispose method +#pragma warning disable CA2213 //Component designer classes generate their own Dispose method public partial class BlastGeneratorForm : Form, IColorize { private enum BlastGeneratorColumn @@ -305,7 +306,7 @@ private void ApplyCorruption(object sender, EventArgs e) } } - private void LoadAndCorrupt(object sender, EventArgs e) + private async void LoadAndCorrupt(object sender, EventArgs e) { string saveStateWord = "Savestate"; @@ -339,7 +340,8 @@ private void LoadAndCorrupt(object sender, EventArgs e) SystemCore = psk.SystemCore, GameName = psk.GameName, SyncSettings = psk.SyncSettings, - StateLocation = psk.StateLocation + StateLocation = psk.StateLocation, + EmuVer = psk.EmuVer }; } else @@ -347,6 +349,14 @@ private void LoadAndCorrupt(object sender, EventArgs e) newSk = (StashKey)_sk.Clone(); } + if (!String.Equals(newSk.EmuVer, new DirectoryInfo(RtcCore.EmuDir).Name, StringComparison.OrdinalIgnoreCase)) + { + + if (!(await VanguardImplementation.SwapImplementation(newSk.EmuVer))) + return; + LocalNetCoreRouter.Route(Endpoints.UI, NetCore.Commands.Remote.UnlockInterface, true); + } + BlastLayer bl = GenerateBlastLayers(true, true); if (bl == null) { @@ -394,7 +404,8 @@ private void SendtoStash(object sender, EventArgs e) SystemCore = psk.SystemCore, GameName = psk.GameName, SyncSettings = psk.SyncSettings, - StateLocation = psk.StateLocation + StateLocation = psk.StateLocation, + EmuVer = psk.EmuVer }; } else @@ -518,7 +529,8 @@ public BlastLayer GenerateBlastLayers(bool loadBeforeCorrupt = false, bool apply SystemCore = psk.SystemCore, GameName = psk.GameName, StateLocation = psk.StateLocation, - SyncSettings = psk.SyncSettings + SyncSettings = psk.SyncSettings, + EmuVer = psk.EmuVer }; } else diff --git a/Source/Frontend/UI/Forms/SimpleModeForm.cs b/Source/Frontend/UI/Forms/SimpleModeForm.cs index dae6dfba..ee6cd629 100644 --- a/Source/Frontend/UI/Forms/SimpleModeForm.cs +++ b/Source/Frontend/UI/Forms/SimpleModeForm.cs @@ -9,6 +9,7 @@ namespace RTCV.UI using RTCV.Common; using RTCV.UI.Components.Controls; using RTCV.UI.Modular; + using System.Threading.Tasks; public partial class SimpleModeForm : ComponentForm, IBlockable { @@ -111,14 +112,14 @@ private void CreateGlitchHarvesterSavestate(object sender, EventArgs e) btnCreateGhSavestate.Text = " Update the Glitch Harvester savestate"; } - private void GlitchHarvesterLoadAndCorrupt(object sender, EventArgs e) + private async void GlitchHarvesterLoadAndCorrupt(object sender, EventArgs e) { if (S.GET().lbStashHistory.Items.Count >= 20) { S.GET().RemoveFirstStashHistoryItem(); } - S.GET().Corrupt(null, null); + await Task.Run(() => S.GET().Corrupt(null, null)); } private void SelectClassicPlatforms(object sender, EventArgs e) diff --git a/Source/Frontend/UI/Forms/StockpilePlayerForm.cs b/Source/Frontend/UI/Forms/StockpilePlayerForm.cs index 02024519..fe8f051c 100644 --- a/Source/Frontend/UI/Forms/StockpilePlayerForm.cs +++ b/Source/Frontend/UI/Forms/StockpilePlayerForm.cs @@ -48,7 +48,7 @@ private void OnStockpileDragDrop(object sender, DragEventArgs e) foreach (StashKey key in sks.StashKeys) { - dgvStockpile?.Rows.Add(key, key.GameName, key.SystemName, key.SystemCore, key.Note); + dgvStockpile?.Rows.Add(key, key.GameName, key.SystemName, key.SystemCore, key.EmuVer, key.Note); } } //Check for missing ref files @@ -181,11 +181,11 @@ private void OnStockpileMouseDown(object sender, MouseEventArgs e) .AddItem("Load on Select", (ob, ev) => S.GET().LoadOnSelect = !loadOnSelect, isChecked: loadOnSelect) .AddItem("Clear Infinite Units on Rewind", (ob, ev) => S.GET().cbClearFreezesOnRewind.Checked = !clearInfiniteUnitsOnRewind, isChecked: clearInfiniteUnitsOnRewind) .AddItem(stripSeparator) - .AddItem("Manual Inject", (ob, ev) => + .AddItem("Manual Inject", async (ob, ev) => { var sk = GetSelectedStashKey(); StashKey newSk = (StashKey)sk.Clone(); - bool isCorrupted = StockpileManagerUISide.ApplyStashkey(newSk, false, false); + bool isCorrupted = await StockpileManagerUISide.ApplyStashkey(newSk, false, false); if (StockpileManagerUISide.CurrentStashkey != null) S.GET().IsCorruptionApplied = isCorrupted; }, dgvStockpile.SelectedRows.Count == 1) @@ -205,7 +205,7 @@ private void OnStripSeparatorPaint(object sender, PaintEventArgs e) } } - private async void LoadStockpile(string fileName) + private async Task LoadStockpile(string fileName) { try { @@ -236,7 +236,7 @@ private async void LoadStockpile(string fileName) { foreach (StashKey key in sks.StashKeys) //Populate the dgv { - dgvStockpile?.Rows.Add(key, key.GameName, key.SystemName, key.SystemCore, key.Note); + dgvStockpile?.Rows.Add(key, key.GameName, key.SystemName, key.SystemCore, key.EmuVer, key.Note); } }); } diff --git a/Source/Frontend/UI/Modular/CoreForm.cs b/Source/Frontend/UI/Modular/CoreForm.cs index 5bee1f15..9d6e39d8 100644 --- a/Source/Frontend/UI/Modular/CoreForm.cs +++ b/Source/Frontend/UI/Modular/CoreForm.cs @@ -382,11 +382,11 @@ public void StartAutoCorrupt(object sender, EventArgs e) } } - public void ManualBlast(object sender, EventArgs e) + public async void ManualBlast(object sender, EventArgs e) { if (AllSpec.VanguardSpec[VSPEC.REPLACE_MANUALBLAST_WITH_GHCORRUPT] != null) { - S.GET().Corrupt(sender, e); + await Task.Run(() => S.GET().Corrupt(sender, e)); } else { diff --git a/Source/Frontend/UI/Modular/CoreForm.resx b/Source/Frontend/UI/Modular/CoreForm.resx index 6ed37643..951b8c2b 100644 --- a/Source/Frontend/UI/Modular/CoreForm.resx +++ b/Source/Frontend/UI/Modular/CoreForm.resx @@ -165,12 +165,12 @@ XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxS fNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYK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v4BL6Afdp0aQQn8+3ecHvJXK6Y5HZn/m// + md1MRGLkmR/XJ//y/jhwc6rrBuSaHvfWzv4RwPTmWz6ez2T5MNK1hGCd1hCtgPuLjRTn2+rkCKCV16Js + 1LUCUmEat6d/+t8BWE0uQwsegCBv7bgATsG+JyaAv1z96LcuPAD9e0KLGq4/KaBUa59qrQtgwQ01AG+6 + gbhtgPtgDjwApAVEnHp8SPuDpf4oAMFT/zfE4m7WDaD/tMAGSiF2mbw5cgEIeG0k7e3Ph1+Vszjk9HoP + ZkARdkliNzqqrzdtMQ406KLYAIjsFNzggH3smzvEBhfJdv5cNihqC9s+AAAAAElFTkSuQmCC diff --git a/Source/Frontend/UI/Modular/SaveProgressForm.cs b/Source/Frontend/UI/Modular/SaveProgressForm.cs index 4d2b6600..2841e2d3 100644 --- a/Source/Frontend/UI/Modular/SaveProgressForm.cs +++ b/Source/Frontend/UI/Modular/SaveProgressForm.cs @@ -53,6 +53,8 @@ public void OnShown() logger.Trace("Entering OnShown() {0}\n{1}", System.Threading.Thread.CurrentThread.ManagedThreadId, Environment.StackTrace); lbCurrentAction.Text = "Waiting"; pbSave.Value = 0; + if (!VanguardImplementation.isSwapping) + { try { VanguardImplementation.connector?.netConn?.Spec?.LockStatusEventLockout(); @@ -62,13 +64,17 @@ public void OnShown() { logger.Trace("AbandonedMutexException! Thread id {0} got Mutex... (save)", System.Threading.Thread.CurrentThread.ManagedThreadId); } + } } public void OnHidden() { logger.Trace("Entering OnHidden() {0}\n{1}", System.Threading.Thread.CurrentThread.ManagedThreadId, Environment.StackTrace); + if (!VanguardImplementation.isSwapping) + { VanguardImplementation.connector?.netConn?.Spec?.UnlockLockStatusEventLockout(); logger.Trace("Thread id {0} released Mutex... (save)", System.Threading.Thread.CurrentThread.ManagedThreadId); + } } } } diff --git a/Source/Frontend/UI/UI.csproj b/Source/Frontend/UI/UI.csproj index d9644e1b..07876cc3 100644 --- a/Source/Frontend/UI/UI.csproj +++ b/Source/Frontend/UI/UI.csproj @@ -44,6 +44,9 @@ Form + + Form + Form diff --git a/Source/Frontend/UI/UIConnector.cs b/Source/Frontend/UI/UIConnector.cs index 1acb55fe..9e9a493e 100644 --- a/Source/Frontend/UI/UIConnector.cs +++ b/Source/Frontend/UI/UIConnector.cs @@ -7,6 +7,8 @@ namespace RTCV.UI using RTCV.NetCore.Enums; using RTCV.Common; using RTCV.UI.Modular; + using NLog; + using System.Windows.Forms; public class UIConnector : IRoutable, IDisposable { @@ -47,6 +49,12 @@ private void NetCoreSpec_ServerConnectionLost(object sender, EventArgs e) return; } + if (VanguardImplementation.isSwapping) + { + StockpileManagerUISide.finishedClosing.TrySetResult(true); + return; + } + SyncObjectSingleton.FormExecute(() => { if (S.GET() != null && !S.GET() diff --git a/Source/Frontend/UI/UICore.cs b/Source/Frontend/UI/UICore.cs index c07bb5a8..af615949 100644 --- a/Source/Frontend/UI/UICore.cs +++ b/Source/Frontend/UI/UICore.cs @@ -17,6 +17,7 @@ namespace RTCV.UI using RTCV.UI.Modular; using RTCV.NetCore.Commands; using System.Dynamic; + using System.Threading.Tasks; public static class UICore { @@ -216,6 +217,7 @@ public static void LockInterface(bool focusCoreForm = true, bool blockMainForm = if (focusCoreForm) { + cf.BringToFront(); cf.Focus(); } } @@ -443,21 +445,21 @@ public static bool CheckHotkey(string trigger) break; case "Load and Corrupt": - SyncObjectSingleton.FormExecute(() => + SyncObjectSingleton.FormExecute(async () => { S.GET().loadBeforeOperation = true; - S.GET().Corrupt(null, null); + await Task.Run(() => S.GET().Corrupt(null, null)); }); break; case "Just Corrupt": AllSpec.CorruptCoreSpec.Update(VSPEC.STEP_RUNBEFORE, true); - SyncObjectSingleton.FormExecute(() => + SyncObjectSingleton.FormExecute(async () => { bool isload = S.GET().loadBeforeOperation; S.GET().loadBeforeOperation = false; - S.GET().Corrupt(null, null); + await Task.Run(() => S.GET().Corrupt(null, null)); S.GET().loadBeforeOperation = isload; }); break; @@ -477,11 +479,11 @@ public static bool CheckHotkey(string trigger) // COPY FROM JUST CORRUPT AllSpec.CorruptCoreSpec.Update(VSPEC.STEP_RUNBEFORE, true); - SyncObjectSingleton.FormExecute(() => + SyncObjectSingleton.FormExecute(async () => { bool isload = S.GET().loadBeforeOperation; S.GET().loadBeforeOperation = false; - S.GET().Corrupt(null, null); + await Task.Run(() => S.GET().Corrupt(null, null)); S.GET().loadBeforeOperation = isload; }); //-------------------------------------- @@ -506,7 +508,7 @@ public static bool CheckHotkey(string trigger) case "Reload Corruption": - SyncObjectSingleton.FormExecute(() => + SyncObjectSingleton.FormExecute(async () => { var sh = S.GET(); var sm = S.GET(); @@ -523,7 +525,7 @@ public static bool CheckHotkey(string trigger) if (rows.Count > 1) { - ghb.Corrupt(null, null); + await Task.Run(() => ghb.Corrupt(null, null)); } else { @@ -729,6 +731,9 @@ public static void ConfigureUIFromVanguardSpec() S.GET().btnAutoCorrupt.Visible = false; } + + S.GET().UpdateMaxIntensity(); + S.GET().UpdateMaxIntensity(); } private static void toggleLimiterBoxSource(bool setToBindingSource) diff --git a/Source/Frontend/UI/VanguardImplementation.cs b/Source/Frontend/UI/VanguardImplementation.cs index b5a6959a..ad495f76 100644 --- a/Source/Frontend/UI/VanguardImplementation.cs +++ b/Source/Frontend/UI/VanguardImplementation.cs @@ -12,6 +12,8 @@ namespace RTCV.UI using RTCV.NetCore.Commands; using System.Threading.Tasks; using System.Threading; + using System.Timers; + using System.Collections.Generic; public static class VanguardImplementation { @@ -19,6 +21,9 @@ public static class VanguardImplementation private static string lastVanguardClient = ""; private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + public static bool isSwapping = false; + public static CanvasForm windowSelect = null; + public static void StartServer() { logger.Trace("Starting UI Vanguard Implementation"); @@ -43,7 +48,7 @@ public static void Shutdown() connector?.Kill(); } - private static void OnMessageReceived(object sender, NetCoreEventArgs e) + private static async void OnMessageReceived(object sender, NetCoreEventArgs e) { try { @@ -57,6 +62,8 @@ private static void OnMessageReceived(object sender, NetCoreEventArgs e) break; case Remote.AllSpecSent: AllSpecSent(); + if (isSwapping) + StockpileManagerUISide.finishedSwapping.TrySetResult(true); break; case Remote.PushVanguardSpecUpdate: PushVanguardSpecUpdate(advancedMessage, ref e); @@ -154,6 +161,29 @@ private static void OnMessageReceived(object sender, NetCoreEventArgs e) UICore.CheckHotkey(hotkey); } break; + case Remote.SwapImplementation: + { + var args = (object[])(advancedMessage.objectValue as object[]); + var newEmu = (string)args[0]; + var unlockAfterSwap = false; + if (args.Length > 1) + unlockAfterSwap = (bool)args[1]; + + bool result = await SwapImplementation(newEmu, unlockAfterSwap); + + e.setReturnValue(result); + } + break; + case Remote.UnlockInterface: + { + if (windowSelect != null) + SyncObjectSingleton.FormExecute(() => { windowSelect.CloseSubForm(); }); + + logger.Trace("Unlocking UI"); + SyncObjectSingleton.FormExecute(() => { UICore.UnlockInterface(); }); + logger.Trace("UI Unlocked"); + } + break; } } catch (Exception ex) @@ -167,6 +197,129 @@ private static void OnMessageReceived(object sender, NetCoreEventArgs e) } } + private static void SwapTimeout(CanvasForm form) + { + Task.Run(() => MessageBox.Show($"Failed to swap emulators. Please save your work, then close and reopen RTC. If you are able to reproduce this issue," + + $"poke the RTC devs for help (Discord is in the launcher).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)); + + SyncObjectSingleton.FormExecute(() => { form.CloseSubForm(); }); + logger.Trace("Unlocking Interface"); + SyncObjectSingleton.FormExecute(() => { UICore.UnlockInterface(); }); + logger.Trace("Load cancelled"); + + AutoKillSwitch.Enabled = true; + VanguardImplementation.isSwapping = false; + return; + } + + public static async Task SwapImplementation(string newEmu, bool unlockAfterSwap = false) + { + // Get the currently active form for displaying the loading bar. If there isn't any (a.k.a we're loading an implementation from the launcher), + // then find the first visible CanvasForm and display it on that instead. + var openForms = Application.OpenForms.Cast
(); + var activeForm = openForms.Where(form => form == Form.ActiveForm).FirstOrDefault() as CanvasForm; + windowSelect = activeForm ?? openForms.Where(form => form is CanvasForm && form.Visible).First() as CanvasForm; + + Task completedTask = null; + CancellationTokenSource cts = new CancellationTokenSource(); + if (StockpileManagerUISide.timeoutTask == null || StockpileManagerUISide.timeoutTask.IsCanceled) + { + StockpileManagerUISide.timeoutTask = Task.Delay(TimeSpan.FromSeconds(StockpileManagerUISide.timeout), cts.Token); + } + + isSwapping = true; + StockpileManagerUISide.finishedClosing = new TaskCompletionSource(false); + StockpileManagerUISide.finishedSwapping = new TaskCompletionSource(false); + + logger.Trace("different emulator found, switching"); + + AutoKillSwitch.Enabled = false; + + // If we were focused on anything other than the core form (aka we're swapping emulators from the launcher), don't focus it + logger.Trace("Blocking UI"); + var stayFocusedForms = new List { "Glitch Harvester", "Blast Editor", "Blast Generator" }; + bool focusCoreForm = stayFocusedForms.Contains(windowSelect.Text, StringComparer.OrdinalIgnoreCase) ? false : true; + SyncObjectSingleton.FormExecute(() => { UICore.LockInterface(focusCoreForm, true); }); + logger.Trace("UI Blocked"); + + string oldEmuDir = CorruptCore.RtcCore.EmuDir; + var newEmuDir = Path.Combine(Path.Combine(new DirectoryInfo(RtcCore.RtcDir).Parent.Parent.FullName, newEmu)); + CorruptCore.RtcCore.EmuDir = newEmuDir; + + // Load the progress form + S.GET().Dock = DockStyle.Fill; + SyncObjectSingleton.FormExecute(() => { windowSelect.OpenSubForm(S.GET()); }); + RtcCore.OnProgressBarUpdate(null, new ProgressBarEventArgs($"Switching from " + new DirectoryInfo(oldEmuDir).Name + + " to " + newEmu, 0)); + + LocalNetCoreRouter.Route(NetCore.Endpoints.Vanguard, NetCore.Commands.Remote.EventCloseEmulator); + + // Wait until the UI thread has confirmed the emulator has finished closing + // This will be when RTC has lost the TCP connection with the emulator + completedTask = await Task.WhenAny(StockpileManagerUISide.finishedClosing.Task, StockpileManagerUISide.timeoutTask).ConfigureAwait(false); + if (completedTask == StockpileManagerUISide.timeoutTask && !completedTask.IsCanceled) + { + SwapTimeout(windowSelect); + return false; + } + + // Open the new emulator + var info = new System.Diagnostics.ProcessStartInfo() + { + UseShellExecute = false, + WorkingDirectory = newEmuDir, + FileName = Path.Combine(newEmuDir, "RESTARTDETACHEDRTC.bat"), + }; + + if (!File.Exists(info.FileName)) + { + MessageBox.Show($"Couldn't find {info.FileName}! Killswitch will not work."); + + SyncObjectSingleton.FormExecute(() => { windowSelect.CloseSubForm(); }); + logger.Trace("Unlocking Interface"); + UICore.UnlockInterface(); + logger.Trace("Load cancelled"); + + AutoKillSwitch.Enabled = true; + VanguardImplementation.isSwapping = false; + + return false; + } + + logger.Trace("Starting the new process"); + RtcCore.OnProgressBarUpdate(null, new ProgressBarEventArgs($"Starting " + newEmu, 50)); + + System.Diagnostics.Process.Start(info); + + + // Wait until the UI thread has confirmed the emulator has finished opening + // This will be once AllSpecSent() has finished + completedTask = await Task.WhenAny(StockpileManagerUISide.finishedSwapping.Task, StockpileManagerUISide.timeoutTask).ConfigureAwait(false); + if (completedTask == StockpileManagerUISide.timeoutTask && !completedTask.IsCanceled) + { + SwapTimeout(windowSelect); + return false; + } + + // We need to make sure to send the name to the connection status form again since we couldn't get it before reconnecting + SyncObjectSingleton.FormExecute(() => + { + S.GET().lbConnectionStatus.Text = + $"Connected to {(string)AllSpec.VanguardSpec?[VSPEC.NAME] ?? "Vanguard"}"; + }); + + RtcCore.OnProgressBarUpdate(null, new ProgressBarEventArgs($"Loading game", 100)); + + VanguardImplementation.isSwapping = false; + cts.Cancel(); + + if (unlockAfterSwap) + LocalNetCoreRouter.Route(Endpoints.UI, NetCore.Commands.Remote.UnlockInterface, true); + + return true; + } + private static void PushVanguardSpec(NetCoreAdvancedMessage advancedMessage, ref NetCoreEventArgs e) { if (!RtcCore.Attached) @@ -241,17 +394,37 @@ internal static void AllSpecSent() DefaultGrids.glitchHarvester.LoadToNewWindow("Glitch Harvester", true); } + else if (VanguardImplementation.isSwapping) + { + lastVanguardClient = (string)AllSpec.VanguardSpec?[VSPEC.NAME] ?? "VANGUARD"; + + //Configure the UI based on the vanguard spec + UICore.ConfigureUIFromVanguardSpec(); + + Panel sidebar = coreForm.pnSideBar; + foreach (Control c in sidebar.Controls) + { + if (c is Button b) + { + if (!b.Text.Contains("Test") && b.ForeColor != Color.OrangeRed) + { + b.Visible = true; + } + } + } + } else { LocalNetCoreRouter.Route(Endpoints.CorruptCore, Remote.LoadPlugins, true); //make sure the other side reloads the plugins var clientName = (string)AllSpec.VanguardSpec?[VSPEC.NAME] ?? "VANGUARD"; - if (clientName != lastVanguardClient) + // Disabled with the addition of cross-emulator stockpiles + /*if (clientName != lastVanguardClient) { MessageBox.Show($"Error: Found {clientName} when previously connected to {lastVanguardClient}.\nPlease restart the RTC to swap clients."); return; - } + }*/ //Push the VMDs since we store them out of spec var vmdProtos = MemoryDomains.VmdPool.Values.Select(x => x.Proto).ToArray(); @@ -290,7 +463,7 @@ internal static void AllSpecSent() if (!RtcCore.Attached) { - AutoKillSwitch.Enabled = true; + //AutoKillSwitch.Enabled = true; } //Restart game protection diff --git a/Source/Libraries/CorruptCore/CorruptCoreConnector.cs b/Source/Libraries/CorruptCore/CorruptCoreConnector.cs index 1b2fda17..9f73c0df 100644 --- a/Source/Libraries/CorruptCore/CorruptCoreConnector.cs +++ b/Source/Libraries/CorruptCore/CorruptCoreConnector.cs @@ -195,7 +195,7 @@ void a() case Remote.DomainPeekByte: { - //ObjectValue -­> Object[] -­> string DomainName, long Address + //ObjectValue -�> Object[] -�> string DomainName, long Address //returns: byte Value var obj = advancedMessage.objectValue as object[]; @@ -208,7 +208,7 @@ void a() } case Remote.DomainPokeByte: { - //ObjectValue -­> Object[] -­> string DomainName, long Address, byte Value + //ObjectValue -�> Object[] -�> string DomainName, long Address, byte Value //no return var obj = advancedMessage.objectValue as object[]; @@ -222,7 +222,7 @@ void a() } case Remote.DomainPeekBytes: { - //ObjectValue -­> Object[] -­> string DomainName, long StartAddress, long EndAddress, bool raw + //ObjectValue -�> Object[] -�> string DomainName, long StartAddress, long EndAddress, bool raw //returns: byte[] Value var obj = advancedMessage.objectValue as object[]; @@ -237,7 +237,7 @@ void a() } case Remote.DomainPokeBytes: { - //ObjectValue -­> Object[] -­> string DomainName, long Address, byte[] Value, bool raw + //ObjectValue -�> Object[] -�> string DomainName, long Address, byte[] Value, bool raw //no return var obj = advancedMessage.objectValue as object[]; @@ -253,7 +253,7 @@ void a() case Remote.RerollBlastLayer: { - //ObjectValue -­> Object -­> BlastLayer bl + //ObjectValue -�> Object -�> BlastLayer bl //returns BlastLayer var bl = (BlastLayer)advancedMessage.objectValue; diff --git a/Source/Libraries/CorruptCore/StashKey.cs b/Source/Libraries/CorruptCore/StashKey.cs index 9b6fd011..35104f03 100644 --- a/Source/Libraries/CorruptCore/StashKey.cs +++ b/Source/Libraries/CorruptCore/StashKey.cs @@ -5,6 +5,7 @@ namespace RTCV.CorruptCore using System.Data; using System.IO; using System.Linq; + using System.Threading.Tasks; using System.Windows.Forms; using Ceras; using Newtonsoft.Json; @@ -34,6 +35,7 @@ public class StashKey : ICloneable, INote public string SystemName { get; set; } public string SystemDeepName { get; set; } public string SystemCore { get; set; } + public string EmuVer { get; set; } public List SelectedDomains { get; set; } = new List(); public string GameName { get; set; } public string SyncSettings { get; set; } @@ -55,7 +57,8 @@ public StashKey() var key = RtcCore.GetRandomKey(); string parentkey = null; BlastLayer blastlayer = new BlastLayer(); - StashKeyConstructor(key, parentkey, blastlayer); + bool useEmuVer = false; + StashKeyConstructor(key, parentkey, blastlayer, useEmuVer); } public StashKey(string key, string parentkey, BlastLayer blastlayer) @@ -63,7 +66,7 @@ public StashKey(string key, string parentkey, BlastLayer blastlayer) StashKeyConstructor(key, parentkey, blastlayer); } - private void StashKeyConstructor(string key, string parentkey, BlastLayer blastlayer) + private void StashKeyConstructor(string key, string parentkey, BlastLayer blastlayer, bool useEmuVer = true) { Key = key; ParentKey = parentkey; @@ -75,6 +78,9 @@ private void StashKeyConstructor(string key, string parentkey, BlastLayer blastl GameName = (string)AllSpec.VanguardSpec?[VSPEC.GAMENAME] ?? "ERROR"; SyncSettings = (string)AllSpec.VanguardSpec?[VSPEC.SYNCSETTINGS] ?? ""; + var dirCheck = useEmuVer ? !string.IsNullOrEmpty((string)AllSpec.VanguardSpec?[VSPEC.EMUDIR]) : false; + EmuVer = dirCheck ? new DirectoryInfo((string)AllSpec.VanguardSpec?[VSPEC.EMUDIR]).Name.ToUpper() : ""; + this.SelectedDomains = ((string[])AllSpec.UISpec[UISPEC.SELECTEDDOMAINS]).ToList(); } @@ -104,19 +110,19 @@ public override string ToString() /// /// Can be called from UI Side /// - public bool Run() + public async Task Run() { StockpileManagerUISide.CurrentStashkey = this; - return StockpileManagerUISide.ApplyStashkey(this); + return await StockpileManagerUISide.ApplyStashkey(this); } /// /// Can be called from UI Side /// - public void RunOriginal() + public async Task RunOriginal() { StockpileManagerUISide.CurrentStashkey = this; - StockpileManagerUISide.OriginalFromStashkey(this); + await StockpileManagerUISide.OriginalFromStashkey(this); } public byte[] EmbedState() diff --git a/Source/Libraries/CorruptCore/Stockpile/Stockpile.cs b/Source/Libraries/CorruptCore/Stockpile/Stockpile.cs index d477111d..27238568 100644 --- a/Source/Libraries/CorruptCore/Stockpile/Stockpile.cs +++ b/Source/Libraries/CorruptCore/Stockpile/Stockpile.cs @@ -607,10 +607,12 @@ internal static OperationResults CheckCompatibility(Stockpile sks) var results = new OperationResults(); var s = (string)AllSpec.VanguardSpec?[VSPEC.NAME] ?? "ERROR"; + /* if (!string.IsNullOrEmpty(sks.VanguardImplementation) && !sks.VanguardImplementation.Equals(s, StringComparison.OrdinalIgnoreCase) && sks.VanguardImplementation != "ERROR") { results.AddError($"The stockpile you loaded is for a different Vanguard implementation.\nThe Stockpile reported {sks.VanguardImplementation} but you're connected to {s}.\nThis is a fatal error. Aborting load."); } + */ if (sks.RtcVersion != RtcCore.RtcVersion) { if (sks.RtcVersion == null) diff --git a/Source/Libraries/CorruptCore/Stockpile/StockpileManagerUISide.cs b/Source/Libraries/CorruptCore/Stockpile/StockpileManagerUISide.cs index ca344fa7..31c6ecf7 100644 --- a/Source/Libraries/CorruptCore/Stockpile/StockpileManagerUISide.cs +++ b/Source/Libraries/CorruptCore/Stockpile/StockpileManagerUISide.cs @@ -3,6 +3,8 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using System.Windows.Forms; using RTCV.NetCore; @@ -28,6 +30,12 @@ public static StashKey CurrentStashkey _currentStashKey = value; } } + + public static TaskCompletionSource finishedClosing; + public static TaskCompletionSource finishedSwapping; + public static int timeout = 20; + public static Task timeoutTask; + public static StashKey CurrentSavestateStashKey { get; set; } [SuppressMessage("Microsoft.Design", "CA2211", Justification = "This field cannot be made private or const because it is used by stubs")] @@ -64,7 +72,7 @@ private static void PostApplyStashkey(StashKey sk) }); } - public static bool ApplyStashkey(StashKey sk, bool loadBeforeOperation = true, bool clearUnitsBeforeApply = true) + public static async Task ApplyStashkey(StashKey sk, bool loadBeforeOperation = true, bool clearUnitsBeforeApply = true) { PreApplyStashkey(clearUnitsBeforeApply); @@ -72,7 +80,7 @@ public static bool ApplyStashkey(StashKey sk, bool loadBeforeOperation = true, b if (loadBeforeOperation) { - if (!LoadState(sk)) + if (!(await LoadState(sk))) { return isCorruptionApplied; } @@ -125,7 +133,8 @@ public static void Import(BlastLayer importedBlastLayer,string name = null) SystemCore = psk.SystemCore, GameName = psk.GameName, SyncSettings = psk.SyncSettings, - StateLocation = psk.StateLocation + StateLocation = psk.StateLocation, + EmuVer = psk.EmuVer }; @@ -135,7 +144,7 @@ public static void Import(BlastLayer importedBlastLayer,string name = null) StashHistory.Add(CurrentStashkey); } - public static bool Corrupt(bool loadBeforeOperation = true) + public static async Task Corrupt(bool loadBeforeOperation = true) { string saveStateWord = "Savestate"; @@ -160,6 +169,25 @@ public static bool Corrupt(bool loadBeforeOperation = true) return false; } + if (!String.Equals(psk.EmuVer, new DirectoryInfo(RtcCore.EmuDir).Name, StringComparison.OrdinalIgnoreCase)) + { + CancellationTokenSource cts = new CancellationTokenSource(); + timeoutTask = Task.Delay(TimeSpan.FromSeconds(timeout), cts.Token); + LocalNetCoreRouter.QueryRoute(Endpoints.UI, NetCore.Commands.Remote.SwapImplementation, new object[] { psk.EmuVer }); + + Task completedTask = await Task.WhenAny(StockpileManagerUISide.finishedSwapping.Task, timeoutTask).ConfigureAwait(false); + if (completedTask == timeoutTask) + { + LocalNetCoreRouter.Route(Endpoints.UI, NetCore.Commands.Remote.UnlockInterface, true); + return false; + } + else + { + cts.Cancel(); + } + } + + string currentGame = (string)AllSpec.VanguardSpec[VSPEC.GAMENAME]; string currentCore = (string)AllSpec.VanguardSpec[VSPEC.SYSTEMCORE]; if (UseSavestates && (currentGame == null || psk.GameName != currentGame || psk.SystemCore != currentCore)) @@ -175,7 +203,8 @@ public static bool Corrupt(bool loadBeforeOperation = true) SystemCore = psk.SystemCore, GameName = psk.GameName, SyncSettings = psk.SyncSettings, - StateLocation = psk.StateLocation + StateLocation = psk.StateLocation, + EmuVer = psk.EmuVer }; @@ -197,6 +226,7 @@ public static bool Corrupt(bool loadBeforeOperation = true) } PostApplyStashkey(CurrentStashkey); + LocalNetCoreRouter.Route(Endpoints.UI, NetCore.Commands.Remote.UnlockInterface, true); return isCorruptionApplied; } @@ -205,7 +235,7 @@ public static void RemoveFirstStashItem() StashHistory.RemoveAt(0); } - public static bool InjectFromStashkey(StashKey sk, bool loadBeforeOperation = true) + public static async Task InjectFromStashkey(StashKey sk, bool loadBeforeOperation = true) { string saveStateWord = "Savestate"; @@ -243,12 +273,13 @@ public static bool InjectFromStashkey(StashKey sk, bool loadBeforeOperation = tr SystemCore = psk.SystemCore, GameName = psk.GameName, SyncSettings = psk.SyncSettings, - StateLocation = psk.StateLocation + StateLocation = psk.StateLocation, + EmuVer = psk.EmuVer }; if (loadBeforeOperation) { - if (!LoadState(CurrentStashkey)) + if (!(await LoadState(CurrentStashkey))) { return false; } @@ -269,7 +300,7 @@ public static bool InjectFromStashkey(StashKey sk, bool loadBeforeOperation = tr return isCorruptionApplied; } - public static bool OriginalFromStashkey(StashKey sk) + public static async Task OriginalFromStashkey(StashKey sk) { PreApplyStashkey(); @@ -281,7 +312,7 @@ public static bool OriginalFromStashkey(StashKey sk) bool isCorruptionApplied = false; - if (!LoadState(sk, true, false)) + if (!(await LoadState(sk, true, false))) { return isCorruptionApplied; } @@ -290,7 +321,7 @@ public static bool OriginalFromStashkey(StashKey sk) return isCorruptionApplied; } - public static bool MergeStashkeys(List sks, bool loadBeforeOperation = true) + public async static Task MergeStashkeys(List sks, bool loadBeforeOperation = true) { PreApplyStashkey(); @@ -347,7 +378,8 @@ public static bool MergeStashkeys(List sks, bool loadBeforeOperation = SystemCore = master.SystemCore, GameName = master.GameName, SyncSettings = master.SyncSettings, - StateLocation = master.StateLocation + StateLocation = master.StateLocation, + EmuVer = master.EmuVer }; @@ -355,7 +387,7 @@ public static bool MergeStashkeys(List sks, bool loadBeforeOperation = if (loadBeforeOperation) { - if (!LoadState(CurrentStashkey)) + if (!( await LoadState(CurrentStashkey))) { return isCorruptionApplied; } @@ -379,9 +411,28 @@ public static bool MergeStashkeys(List sks, bool loadBeforeOperation = return false; } - public static bool LoadState(StashKey sk, bool reloadRom = true, bool applyBlastLayer = true) + public static async Task LoadState(StashKey sk, bool reloadRom = true, bool applyBlastLayer = true) { + if (!String.Equals(sk.EmuVer, new DirectoryInfo(RtcCore.EmuDir).Name, StringComparison.OrdinalIgnoreCase)) + { + CancellationTokenSource cts = new CancellationTokenSource(); + timeoutTask = Task.Delay(TimeSpan.FromSeconds(timeout), cts.Token); + LocalNetCoreRouter.QueryRoute(Endpoints.UI, NetCore.Commands.Remote.SwapImplementation, new object[] { sk.EmuVer }); + + Task completedTask = await Task.WhenAny(StockpileManagerUISide.finishedSwapping.Task, timeoutTask).ConfigureAwait(false); + if (completedTask == timeoutTask) + { + LocalNetCoreRouter.Route(Endpoints.UI, NetCore.Commands.Remote.UnlockInterface, true); + return false; + } + else + { + cts.Cancel(); + } + } + bool success = LocalNetCoreRouter.QueryRoute(NetCore.Endpoints.CorruptCore, NetCore.Commands.Remote.LoadState, new object[] { sk, reloadRom, applyBlastLayer }, true); + LocalNetCoreRouter.Route(Endpoints.UI, NetCore.Commands.Remote.UnlockInterface, true); return success; } diff --git a/Source/Libraries/NetCore/NetcoreCommands.cs b/Source/Libraries/NetCore/NetcoreCommands.cs index 81c59318..4e1027b6 100644 --- a/Source/Libraries/NetCore/NetcoreCommands.cs +++ b/Source/Libraries/NetCore/NetcoreCommands.cs @@ -91,6 +91,9 @@ public static class Remote { public const string BlastToolsGetAppliedBackupLayer = nameof(Remote) + "_" + nameof(BlastToolsGetAppliedBackupLayer); public const string KeySetSyncSettings = nameof(Remote) + "_" + nameof(KeySetSyncSettings); public const string KeySetSystemCore = nameof(Remote) + "_" + nameof(KeySetSystemCore); + + public const string SwapImplementation = nameof(Remote) + "_" + nameof(SwapImplementation); + public const string UnlockInterface = nameof(Remote) + "_" + nameof(UnlockInterface); //HOTKEYS public const string HotkeyManualBlast = nameof(Remote) + "_" + nameof(HotkeyManualBlast); diff --git a/Source/Libraries/NetCore/UDPLink.cs b/Source/Libraries/NetCore/UDPLink.cs index 22c9f8f0..f8e64270 100644 --- a/Source/Libraries/NetCore/UDPLink.cs +++ b/Source/Libraries/NetCore/UDPLink.cs @@ -1,10 +1,14 @@ namespace RTCV.NetCore { using System; + using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; + using System.Windows.Forms; + using Newtonsoft.Json; + using Newtonsoft.Json.Linq; using RTCV.NetCore.Enums; public class UDPLink : IDisposable @@ -136,7 +140,20 @@ private void ListenToReader() } if (bytes != null) { - spec.Connector.hub.QueueMessage(new NetCoreSimpleMessage(Encoding.ASCII.GetString(bytes, 0, bytes.Length))); + string byteString = Encoding.UTF8.GetString(bytes, 0, bytes.Length); + + // if there's an objectValue, it's an advanced message + if (byteString.Contains("objectValue")) + { + NetCoreAdvancedMessage message = JsonConvert.DeserializeObject(byteString); + JArray jArray = (JArray)message.objectValue; + message.objectValue = jArray.ToObject>().ToArray(); + spec.Connector.hub.QueueMessage(message); + } + else + { + spec.Connector.hub.QueueMessage(new NetCoreSimpleMessage(byteString)); + } } //Sleep if there's no more data