public void OneTimeExecute() { //Disable autocorrupt S.GET <UI_CoreForm>().AutoCorrupt = false; if (ghMode == GlitchHarvesterMode.CORRUPT) { IsCorruptionApplied = StockpileManager_UISide.ApplyStashkey(StockpileManager_UISide.CurrentStashkey, loadBeforeOperation); } else if (ghMode == GlitchHarvesterMode.INJECT) { IsCorruptionApplied = StockpileManager_UISide.InjectFromStashkey(StockpileManager_UISide.CurrentStashkey, loadBeforeOperation); S.GET <RTC_StashHistory_Form>().RefreshStashHistory(); } else if (ghMode == GlitchHarvesterMode.ORIGINAL) { IsCorruptionApplied = StockpileManager_UISide.OriginalFromStashkey(StockpileManager_UISide.CurrentStashkey); } if (Render.RenderAtLoad && loadBeforeOperation) { Render.StartRender(); } else { Render.StopRender(); } }
public void btnCorrupt_Click(object sender, EventArgs e) { Console.WriteLine("btnCorrupt Clicked"); if (!(btnCorrupt.Visible || AllSpec.VanguardSpec[VSPEC.REPLACE_MANUALBLAST_WITH_GHCORRUPT] != null && S.GET <UI_CoreForm>().btnManualBlast.Visible)) { return; } try { SetBlastButtonVisibility(false); var domains = RTCV.NetCore.AllSpec.UISpec["SELECTEDDOMAINS"] as string[]; if (domains == null || 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 <UI_CoreForm>().AutoCorrupt) { S.GET <UI_CoreForm>().AutoCorrupt = false; } StashKey psk = StockpileManager_UISide.CurrentSavestateStashKey; if (MergeMode) { List <StashKey> sks = new List <StashKey>(); //Reverse before merging because DataGridView selectedrows is backwards for some odd reason var reversed = S.GET <RTC_StockpileManager_Form>().dgvStockpile.SelectedRows.Cast <DataGridViewRow>().Reverse(); foreach (DataGridViewRow row in reversed) { sks.Add((StashKey)row.Cells[0].Value); } IsCorruptionApplied = StockpileManager_UISide.MergeStashkeys(sks); S.GET <RTC_StashHistory_Form>().RefreshStashHistorySelectLast(); //lbStashHistory.TopIndex = lbStashHistory.Items.Count - 1; return; } if (ghMode == GlitchHarvesterMode.CORRUPT) { string romFilename = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.OPENROMFILENAME]; if (romFilename?.Contains("|") ?? false) { MessageBox.Show($"The Glitch Harvester attempted to corrupt a game bound to the following file:\n{romFilename}\n\nIt cannot be processed because the rom seems to be inside a Zip Archive\n(Bizhawk returned a filename with the chracter | in it)"); return; } S.GET <RTC_StashHistory_Form>().DontLoadSelectedStash = true; IsCorruptionApplied = StockpileManager_UISide.Corrupt(loadBeforeOperation); S.GET <RTC_StashHistory_Form>().RefreshStashHistorySelectLast(); } else if (ghMode == GlitchHarvesterMode.INJECT) { if (StockpileManager_UISide.CurrentStashkey == null) { throw new CustomException("CurrentStashkey in inject was somehow null! Report this to the devs and tell them how you caused this.", Environment.StackTrace); } S.GET <RTC_StashHistory_Form>().DontLoadSelectedStash = true; IsCorruptionApplied = StockpileManager_UISide.InjectFromStashkey(StockpileManager_UISide.CurrentStashkey, loadBeforeOperation); S.GET <RTC_StashHistory_Form>().RefreshStashHistorySelectLast(); } else if (ghMode == GlitchHarvesterMode.ORIGINAL) { if (StockpileManager_UISide.CurrentStashkey == null) { throw new CustomException("CurrentStashkey in original was somehow null! Report this to the devs and tell them how you caused this.", Environment.StackTrace); } S.GET <RTC_StashHistory_Form>().DontLoadSelectedStash = true; IsCorruptionApplied = StockpileManager_UISide.OriginalFromStashkey(StockpileManager_UISide.CurrentStashkey); } if (Render.RenderAtLoad && loadBeforeOperation) { Render.StartRender(); } else { Render.StopRender(); } Console.WriteLine("Blast done"); } finally { SetBlastButtonVisibility(true); } }