private void lbStashHistory_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { Point locate = new Point(((Control)sender).Location.X + e.Location.X, ((Control)sender).Location.Y + e.Location.Y); ContextMenuStrip columnsMenu = new ContextMenuStrip(); ((ToolStripMenuItem)columnsMenu.Items.Add("Open Selected Item in Blast Editor", null, new EventHandler((ob, ev) => { if (S.GET <RTC_NewBlastEditor_Form>() != null) { StashKey sk = StockpileManager_UISide.StashHistory[lbStashHistory.SelectedIndex]; RTC_NewBlastEditor_Form.OpenBlastEditor(sk); } }))).Enabled = lbStashHistory.SelectedIndex != -1; ((ToolStripMenuItem)columnsMenu.Items.Add("Sanitize", null, new EventHandler((ob, ev) => { if (S.GET <RTC_NewBlastEditor_Form>() != null) { StashKey sk = StockpileManager_UISide.StashHistory[lbStashHistory.SelectedIndex]; RTC_NewBlastEditor_Form.OpenBlastEditor(sk, true); S.GET <RTC_NewBlastEditor_Form>().btnSanitizeTool_Click(null, null); } }))).Enabled = lbStashHistory.SelectedIndex != -1; columnsMenu.Items.Add(new ToolStripSeparator()); ((ToolStripMenuItem)columnsMenu.Items.Add("Rename selected item", null, new EventHandler((ob, ev) => { StashKey sk = StockpileManager_UISide.StashHistory[lbStashHistory.SelectedIndex]; S.GET <RTC_StockpileManager_Form>().RenameStashKey(sk); RefreshStashHistory(); }))).Enabled = lbStashHistory.SelectedIndex != -1; ((ToolStripMenuItem)columnsMenu.Items.Add("Generate VMD from Selected Item", null, new EventHandler((ob, ev) => { StashKey sk = StockpileManager_UISide.StashHistory[lbStashHistory.SelectedIndex]; sk.BlastLayer.RasterizeVMDs(); MemoryDomains.GenerateVmdFromStashkey(sk); S.GET <RTC_VmdPool_Form>().RefreshVMDs(); }))).Enabled = lbStashHistory.SelectedIndex != -1; columnsMenu.Items.Add(new ToolStripSeparator()); ((ToolStripMenuItem)columnsMenu.Items.Add("Merge Selected Stashkeys", null, new EventHandler((ob, ev) => { List <StashKey> sks = new List <StashKey>(); foreach (StashKey sk in lbStashHistory.SelectedItems) { sks.Add(sk); } StockpileManager_UISide.MergeStashkeys(sks); RefreshStashHistory(); }))).Enabled = (lbStashHistory.SelectedIndex != -1 && lbStashHistory.SelectedItems.Count > 1); /* * if (!RTC_NetcoreImplementation.isStandaloneUI) * { * columnsMenu.Items.Add(new ToolStripSeparator()); * ((ToolStripMenuItem)columnsMenu.Items.Add("[Multiplayer] Pull State from peer", null, new EventHandler((ob, ev) => * { * S.GET<RTC_Multiplayer_Form>().cbPullStateToGlitchHarvester.Checked = true; * RTC_NetcoreImplementation.Multiplayer.SendCommand(new RTC_Command(CommandType.PULLSTATE), false); * }))).Enabled = RTC_NetcoreImplementation.Multiplayer != null && RTC_NetcoreImplementation.Multiplayer.side != NetworkSide.DISCONNECTED; * }*/ columnsMenu.Show(this, locate); } }
private void dgvStockpile_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } try { S.GET <RTC_StashHistory_Form>().btnAddStashToStockpile.Enabled = false; dgvStockpile.Enabled = false; btnStockpileUP.Enabled = false; btnStockpileDOWN.Enabled = false; // Stockpile Note handling if (e != null) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { StashKey sk = (StashKey)senderGrid.Rows[e.RowIndex].Cells["Item"].Value; S.SET(new RTC_NoteEditor_Form(sk, senderGrid.Rows[e.RowIndex].Cells["Note"])); S.GET <RTC_NoteEditor_Form>().Show(); return; } } S.GET <RTC_StashHistory_Form>().lbStashHistory.ClearSelected(); S.GET <RTC_StockpilePlayer_Form>().dgvStockpile.ClearSelection(); S.GET <RTC_GlitchHarvesterBlast_Form>().RedrawActionUI(); if (dgvStockpile.SelectedRows.Count == 0) { return; } StockpileManager_UISide.CurrentStashkey = (dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey); List <StashKey> keys = dgvStockpile.Rows.Cast <DataGridViewRow>().Select(x => (StashKey)x.Cells[0].Value).ToList(); if (!StockpileManager_UISide.CheckAndFixMissingReference(StockpileManager_UISide.CurrentStashkey, false, keys)) { return; } if (!S.GET <RTC_GlitchHarvesterBlast_Form>().LoadOnSelect) { return; } // Merge Execution if (dgvStockpile.SelectedRows.Count > 1) { List <StashKey> sks = new List <StashKey>(); foreach (DataGridViewRow row in dgvStockpile.SelectedRows) { sks.Add((StashKey)row.Cells[0].Value); } //dgv is stupid since it selects rows backwards sks.Reverse(); StockpileManager_UISide.MergeStashkeys(sks); if (Render.RenderAtLoad && S.GET <RTC_GlitchHarvesterBlast_Form>().loadBeforeOperation) { Render.StartRender(); } S.GET <RTC_StashHistory_Form>().RefreshStashHistory(); return; } S.GET <RTC_GlitchHarvesterBlast_Form>().OneTimeExecute(); } finally { S.GET <RTC_StashHistory_Form>().btnAddStashToStockpile.Enabled = true; dgvStockpile.Enabled = true; btnStockpileUP.Enabled = true; btnStockpileDOWN.Enabled = true; } S.GET <RTC_GlitchHarvesterBlast_Form>().RedrawActionUI(); }
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); } }
private void dgvStockpile_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { Point locate = new Point((sender as Control).Location.X + e.Location.X, (sender as Control).Location.Y + e.Location.Y); ContextMenuStrip columnsMenu = new ContextMenuStrip(); (columnsMenu.Items.Add("Show Item Name", null, (ob, ev) => { dgvStockpile.Columns["Item"].Visible ^= true; }) as ToolStripMenuItem).Checked = dgvStockpile.Columns["Item"].Visible; (columnsMenu.Items.Add("Show Game Name", null, (ob, ev) => { dgvStockpile.Columns["GameName"].Visible ^= true; }) as ToolStripMenuItem) .Checked = dgvStockpile.Columns["GameName"].Visible; (columnsMenu.Items.Add("Show System Name", null, (ob, ev) => { dgvStockpile.Columns["SystemName"].Visible ^= true; }) as ToolStripMenuItem) .Checked = dgvStockpile.Columns["SystemName"].Visible; (columnsMenu.Items.Add("Show System Core", null, (ob, ev) => { dgvStockpile.Columns["SystemCore"].Visible ^= true; }) as ToolStripMenuItem) .Checked = dgvStockpile.Columns["SystemCore"].Visible; (columnsMenu.Items.Add("Show Note", null, (ob, ev) => { dgvStockpile.Columns["Note"].Visible ^= true; }) as ToolStripMenuItem).Checked = dgvStockpile.Columns["Note"].Visible; columnsMenu.Items.Add(new ToolStripSeparator()); ((ToolStripMenuItem)columnsMenu.Items.Add("Open Selected Item in Blast Editor", null, new EventHandler((ob, ev) => { if (S.GET <RTC_NewBlastEditor_Form>() != null) { var sk = (dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey); RTC_NewBlastEditor_Form.OpenBlastEditor(sk); } }))).Enabled = (dgvStockpile.SelectedRows.Count == 1); ((ToolStripMenuItem)columnsMenu.Items.Add("Manual Inject", null, new EventHandler((ob, ev) => { var sk = (dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey); StashKey newSk = (StashKey)sk.Clone(); S.GET <RTC_GlitchHarvesterBlast_Form>().IsCorruptionApplied = StockpileManager_UISide.ApplyStashkey(newSk, false); }))).Enabled = (dgvStockpile.SelectedRows.Count == 1); columnsMenu.Items.Add(new ToolStripSeparator()); ((ToolStripMenuItem)columnsMenu.Items.Add("Generate VMD from Selected Item", null, new EventHandler((ob, ev) => { var sk = (dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey); MemoryDomains.GenerateVmdFromStashkey(sk); S.GET <RTC_VmdPool_Form>().RefreshVMDs(); }))).Enabled = (dgvStockpile.SelectedRows.Count == 1); ((ToolStripMenuItem)columnsMenu.Items.Add("Merge Selected Stashkeys", null, new EventHandler((ob, ev) => { List <StashKey> sks = new List <StashKey>(); foreach (DataGridViewRow row in dgvStockpile.SelectedRows) { sks.Add((StashKey)row.Cells[0].Value); } StockpileManager_UISide.MergeStashkeys(sks); S.GET <RTC_StashHistory_Form>().RefreshStashHistory(); }))).Enabled = (dgvStockpile.SelectedRows.Count > 1); ((ToolStripMenuItem)columnsMenu.Items.Add("Replace associated ROM", null, new EventHandler((ob, ev) => { List <StashKey> sks = new List <StashKey>(); foreach (DataGridViewRow row in dgvStockpile.SelectedRows) { sks.Add((StashKey)row.Cells[0].Value); } OpenFileDialog ofd = new OpenFileDialog { DefaultExt = "*", Title = "Select Replacement File", Filter = "Any file|*.*", RestoreDirectory = true }; if (ofd.ShowDialog() == DialogResult.OK) { string filename = ofd.FileName.ToString(); string oldFilename = sks.First().RomFilename; foreach (var sk in sks.Where(x => x.RomFilename == oldFilename)) { sk.RomFilename = filename; sk.RomShortFilename = Path.GetFileName(sk.RomFilename); } } }))).Enabled = (dgvStockpile.SelectedRows.Count >= 1); /* * if (!RTC_NetcoreImplementation.isStandaloneUI) * { * ((ToolStripMenuItem)columnsMenu.Items.Add("[Multiplayer] Send Selected Item as a Blast", null, new EventHandler((ob, ev) => { RTC_NetcoreImplementation.Multiplayer?.SendBlastlayer(); }))).Enabled = RTC_NetcoreImplementation.Multiplayer != null && RTC_NetcoreImplementation.Multiplayer.side != NetworkSide.DISCONNECTED; * ((ToolStripMenuItem)columnsMenu.Items.Add("[Multiplayer] Send Selected Item as a Game State", null, new EventHandler((ob, ev) => { RTC_NetcoreImplementation.Multiplayer?.SendStashkey(); }))).Enabled = RTC_NetcoreImplementation.Multiplayer != null && RTC_NetcoreImplementation.Multiplayer.side != NetworkSide.DISCONNECTED; * }*/ columnsMenu.Show(this, locate); } }