Ejemplo n.º 1
0
        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);

                ToolStripSeparator stripSeparator = new ToolStripSeparator();
                stripSeparator.Paint += stripSeparator_Paint;

                ContextMenuStrip columnsMenu = new ContextMenuStrip();
                (columnsMenu.Items.Add("Show Item Name", null, new EventHandler((ob, ev) => { dgvStockpile.Columns["Item"].Visible ^= true; })) as ToolStripMenuItem).Checked         = dgvStockpile.Columns["Item"].Visible;
                (columnsMenu.Items.Add("Show Game Name", null, new EventHandler((ob, ev) => { dgvStockpile.Columns["GameName"].Visible ^= true; })) as ToolStripMenuItem).Checked     = dgvStockpile.Columns["GameName"].Visible;
                (columnsMenu.Items.Add("Show System Name", null, new EventHandler((ob, ev) => { dgvStockpile.Columns["SystemName"].Visible ^= true; })) as ToolStripMenuItem).Checked = dgvStockpile.Columns["SystemName"].Visible;
                (columnsMenu.Items.Add("Show System Core", null, new EventHandler((ob, ev) => { dgvStockpile.Columns["SystemCore"].Visible ^= true; })) as ToolStripMenuItem).Checked = dgvStockpile.Columns["SystemCore"].Visible;
                (columnsMenu.Items.Add("Show Note", null, new EventHandler((ob, ev) => { dgvStockpile.Columns["Note"].Visible ^= true; })) as ToolStripMenuItem).Checked = dgvStockpile.Columns["Note"].Visible;
                columnsMenu.Items.Add(stripSeparator);
                (columnsMenu.Items.Add("Load on Select", null, new EventHandler((ob, ev) => { S.GET <RTC_GlitchHarvesterBlast_Form>().LoadOnSelect ^= true; })) as ToolStripMenuItem).Checked = S.GET <RTC_GlitchHarvesterBlast_Form>().LoadOnSelect;
                (columnsMenu.Items.Add("Clear Infinite Units on Rewind", null, new EventHandler((ob, ev) => { S.GET <RTC_CorruptionEngine_Form>().cbClearCheatsOnRewind.Checked ^= true; })) as ToolStripMenuItem).Checked = S.GET <RTC_CorruptionEngine_Form>().cbClearCheatsOnRewind.Checked;

                columnsMenu.Items.Add(stripSeparator);

                ((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.Show(this, locate);
            }
        }
Ejemplo n.º 2
0
        private void btnStockpileMoveSelectedDown_Click(object sender, EventArgs e)
        {
            var selectedRows = dgvStockpile.SelectedRows.Cast <DataGridViewRow>().ToArray();

            foreach (DataGridViewRow row in selectedRows)
            {
                int pos   = row.Index;
                int count = dgvStockpile.Rows.Count;
                dgvStockpile.Rows.RemoveAt(pos);

                if (pos == count - 1)
                {
                    int newpos = 0;
                    dgvStockpile.Rows.Insert(newpos, row);
                }
                else
                {
                    int newpos = pos + 1;
                    dgvStockpile.Rows.Insert(newpos, row);
                }
            }
            dgvStockpile.ClearSelection();
            foreach (DataGridViewRow row in selectedRows) //I don't know. Blame DGV
            {
                row.Selected = true;
            }

            UnsavedEdits = true;

            StockpileManager_UISide.StockpileChanged();
            S.GET <RTC_GlitchHarvesterBlast_Form>().RedrawActionUI();
        }
        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();
            }
        }
Ejemplo n.º 4
0
        private void dgvStockpile_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (currentlyLoading || !S.GET <RTC_GlitchHarvesterBlast_Form>().LoadOnSelect || e?.RowIndex == -1)
            {
                return;
            }

            try
            {
                //dgvStockpile.Enabled = false;
                currentlyLoading = true;

                if (e != null)
                {
                    var senderGrid = (DataGridView)sender;

                    StashKey sk = (StashKey)senderGrid.Rows[e.RowIndex].Cells["Item"].Value;

                    if (sk.Note != null)
                    {
                        tbNoteBox.Text = sk.Note.Replace("\n", Environment.NewLine);
                    }
                    else
                    {
                        tbNoteBox.Text = "";
                    }

                    if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                        e.RowIndex >= 0)
                    {
                        S.SET(new RTC_NoteEditor_Form(sk, senderGrid.Rows[e.RowIndex].Cells["Note"]));
                        S.GET <RTC_NoteEditor_Form>().Show();
                        return;
                    }
                }

                if (dgvStockpile.SelectedRows.Count > 0)
                {
                    //Shut autocorrupt off because people (Vinny) kept turning it on to add to corruptions then forgetting to turn it off
                    S.GET <UI_CoreForm>().AutoCorrupt = false;

                    S.GET <RTC_GlitchHarvesterBlast_Form>().ghMode = GlitchHarvesterMode.CORRUPT;
                    StockpileManager_UISide.CurrentStashkey        = (dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey);
                    StockpileManager_UISide.ApplyStashkey(StockpileManager_UISide.CurrentStashkey);

                    S.GET <RTC_StashHistory_Form>().lbStashHistory.ClearSelected();
                    S.GET <RTC_StockpileManager_Form>().dgvStockpile.ClearSelection();

                    S.GET <RTC_GlitchHarvesterBlast_Form>().IsCorruptionApplied = !(StockpileManager_UISide.CurrentStashkey.BlastLayer == null || StockpileManager_UISide.CurrentStashkey.BlastLayer.Layer.Count == 0);
                }
            }
            finally
            {
                currentlyLoading = false;
                //dgvStockpile.Enabled = true;
            }
        }
Ejemplo n.º 5
0
        public void RemoveFirstStashHistoryItem()
        {
            DontLoadSelectedStash        = true;
            lbStashHistory.DataSource    = null;
            lbStashHistory.SelectedIndex = -1;

            DontLoadSelectedStash = true;
            //lbStashHistory.BeginUpdate();
            StockpileManager_UISide.RemoveFirstStashItem();
            lbStashHistory.DataSource = StockpileManager_UISide.StashHistory;
            DontLoadSelectedStash     = false;
        }
Ejemplo n.º 6
0
        private async void LoadStockpile(string fileName)
        {
            try
            {
                //We do this here and invoke because our unlock runs at the end of the awaited method, but there's a chance an error occurs
                //Thus, we want this to happen within the try block
                UICore.SetHotkeyTimer(false);
                UICore.LockInterface(false, true);
                S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill;
                UI_CoreForm.cfForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>());

                StockpileManager_UISide.ClearCurrentStockpile();

                //Clear out the DGVs
                S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows.Clear(); // Clear the stockpile manager
                dgvStockpile.Rows.Clear();                                     // Clear the stockpile player

                var r = await Task.Run(() => Stockpile.Load(fileName));

                if (r.Failed)
                {
                    MessageBox.Show($"Loading the stockpile failed!\n" +
                                    $"{r.GetErrorsFormatted()}");
                }
                else
                {
                    var sks = r.Result;
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        foreach (StashKey key in sks.StashKeys) //Populate the dgv
                        {
                            dgvStockpile?.Rows.Add(key, key.GameName, key.SystemName, key.SystemCore, key.Note);
                        }
                    });
                }

                List <StashKey> keys = dgvStockpile.Rows.Cast <DataGridViewRow>().Select(x => (StashKey)x.Cells["Item"].Value).ToList();
                foreach (var sk in keys)
                {
                    StockpileManager_UISide.CheckAndFixMissingReference(sk, false, keys);
                }

                dgvStockpile.ClearSelection();
                RefreshNoteIcons();
            }
            finally
            {
                UI_CoreForm.cfForm?.CloseSubForm();
                UICore.UnlockInterface();
                UICore.SetHotkeyTimer(true);
            }
        }
        public void btnRerollSelected_Click(object sender, EventArgs e)
        {
            if (!btnRerollSelected.Visible)
            {
                return;
            }

            try
            {
                SetBlastButtonVisibility(false);


                if (S.GET <RTC_StashHistory_Form>().lbStashHistory.SelectedIndex != -1)
                {
                    StockpileManager_UISide.CurrentStashkey = (StashKey)StockpileManager_UISide.StashHistory[S.GET <RTC_StashHistory_Form>().lbStashHistory.SelectedIndex].Clone();
                }
                else if (S.GET <RTC_StockpileManager_Form>().dgvStockpile.SelectedRows.Count != 0 && S.GET <RTC_StockpileManager_Form>().dgvStockpile.SelectedRows[0].Cells[0].Value != null)
                {
                    StockpileManager_UISide.CurrentStashkey = (StashKey)(S.GET <RTC_StockpileManager_Form>().dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey)?.Clone();
                    //StockpileManager_UISide.unsavedEdits = true;
                }
                else
                {
                    return;
                }

                if (StockpileManager_UISide.CurrentStashkey != null)
                {
                    StockpileManager_UISide.CurrentStashkey.BlastLayer.Reroll();

                    if (StockpileManager_UISide.AddCurrentStashkeyToStash())
                    {
                        S.GET <RTC_StockpileManager_Form>().dgvStockpile.ClearSelection();
                        S.GET <RTC_StashHistory_Form>()
                        .RefreshStashHistory();
                        S.GET <RTC_StashHistory_Form>()
                        .lbStashHistory.ClearSelected();
                        S.GET <RTC_StashHistory_Form>()
                        .DontLoadSelectedStash = true;
                        S.GET <RTC_StashHistory_Form>()
                        .lbStashHistory.SelectedIndex = S.GET <RTC_StashHistory_Form>()
                                                        .lbStashHistory.Items.Count - 1;
                    }

                    StockpileManager_UISide.ApplyStashkey(StockpileManager_UISide.CurrentStashkey);
                }
            }
            finally
            {
                SetBlastButtonVisibility(true);
            }
        }
Ejemplo n.º 8
0
        private async void LoadStockpile(string filename)
        {
            if (UnsavedEdits && MessageBox.Show("You have unsaved edits in the Glitch Harvester Stockpile. \n\n Are you sure you want to load without saving?",
                                                "Unsaved edits in Stockpile", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            var ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester");

            try
            {
                //We do this here and invoke because our unlock runs at the end of the awaited method, but there's a chance an error occurs
                //Thus, we want this to happen within the try block
                SyncObjectSingleton.FormExecute(() =>
                {
                    UICore.LockInterface(false, true);
                    S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill;
                    ghForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>());
                });

                await Task.Run(() =>
                {
                    if (Stockpile.Load(dgvStockpile, filename))
                    {
                        SyncObjectSingleton.FormExecute(() =>
                        {
                            btnSaveStockpile.Enabled = true;
                            RefreshNoteIcons();
                        });
                    }

                    SyncObjectSingleton.FormExecute(() =>
                    {
                        S.GET <RTC_StockpilePlayer_Form>().dgvStockpile.Rows.Clear();

                        dgvStockpile.ClearSelection();
                        StockpileManager_UISide.StockpileChanged();

                        UnsavedEdits = false;
                    });
                });
            }
            finally
            {
                SyncObjectSingleton.FormExecute(() =>
                {
                    ghForm?.CloseSubForm();
                    UICore.UnlockInterface();
                });
            }
        }
Ejemplo n.º 9
0
        public void RemoveSelected(bool force = false)
        {
            if (Control.ModifierKeys == Keys.Control || (dgvStockpile.SelectedRows.Count != 0 && (MessageBox.Show("Are you sure you want to remove the selected stockpile entries?", "Delete Stockpile Entry?", MessageBoxButtons.YesNo) == DialogResult.Yes)))
            {
                foreach (DataGridViewRow row in dgvStockpile.SelectedRows)
                {
                    dgvStockpile.Rows.Remove(row);
                }
            }

            StockpileManager_UISide.StockpileChanged();

            UnsavedEdits = true;

            S.GET <RTC_GlitchHarvesterBlast_Form>().RedrawActionUI();
        }
Ejemplo n.º 10
0
        private async void loadStockpile(string fileName)
        {
            try
            {
                //We do this here and invoke because our unlock runs at the end of the awaited method, but there's a chance an error occurs
                //Thus, we want this to happen within the try block
                SyncObjectSingleton.FormExecute(() =>
                {
                    UICore.LockInterface(false, true);
                    S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill;
                    UI_CoreForm.cfForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>());
                });

                await Task.Run(() =>
                {
                    if (Stockpile.Load(dgvStockpile, fileName))
                    {
                        SyncObjectSingleton.FormExecute(() => S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows.Clear());
                    }

                    SyncObjectSingleton.FormExecute(() =>
                    {
                        List <StashKey> keys = dgvStockpile.Rows.Cast <DataGridViewRow>().Select(x => (StashKey)x.Cells["Item"].Value).ToList();
                        foreach (var sk in keys)
                        {
                            StockpileManager_UISide.CheckAndFixMissingReference(sk, false, keys);
                        }

                        dgvStockpile.ClearSelection();
                        RefreshNoteIcons();
                    });
                });
            }
            finally
            {
                SyncObjectSingleton.FormExecute(() =>
                {
                    UI_CoreForm.cfForm?.CloseSubForm();
                    UICore.UnlockInterface();
                });
            }
        }
Ejemplo n.º 11
0
        private void btnRenameSelected_Click(object sender, EventArgs e)
        {
            if (!btnRenameSelected.Visible)
            {
                return;
            }


            if (dgvStockpile.SelectedRows.Count != 0)
            {
                renameStashKey(dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey);

                dgvStockpile.Refresh();
                //lbStockpile.RefreshItemsReal();
            }

            StockpileManager_UISide.StockpileChanged();

            UnsavedEdits = true;
        }
Ejemplo n.º 12
0
        public void ClearStockpile(bool force = false)
        {
            if (force || MessageBox.Show("Are you sure you want to clear the stockpile?", "Clearing stockpile", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                dgvStockpile.Rows.Clear();

                if (StockpileManager_UISide.CurrentStockpile != null)
                {
                    StockpileManager_UISide.CurrentStockpile.Filename      = null;
                    StockpileManager_UISide.CurrentStockpile.ShortFilename = null;
                }

                btnSaveStockpile.Enabled = false;

                StockpileManager_UISide.StockpileChanged();

                UnsavedEdits = false;

                S.GET <RTC_GlitchHarvesterBlast_Form>().RedrawActionUI();
            }
        }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
        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();
        }
Ejemplo n.º 15
0
        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);
            }
        }
Ejemplo n.º 16
0
        public bool AddStashToStockpile(bool askForName = true)
        {
            if (lbStashHistory.Items.Count == 0 || lbStashHistory.SelectedIndex == -1)
            {
                MessageBox.Show("Can't add the Stash to the Stockpile because none is selected in the Stash History");
                return(false);
            }

            string Name  = "";
            string value = "";

            StashKey sk = (StashKey)lbStashHistory.SelectedItem;

            StockpileManager_UISide.CurrentStashkey = sk;

            //If we don't support mixed stockpiles
            if (!((bool?)AllSpec.VanguardSpec[VSPEC.SUPPORTS_MIXED_STOCKPILE] ?? false))
            {
                if (S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows.Count > 0)
                {
                    string firstGameName = ((StashKey)S.GET <RTC_StockpileManager_Form>().dgvStockpile[0, 0].Value).GameName;
                    if (sk.GameName != firstGameName)
                    {
                        string name = (AllSpec.VanguardSpec[VSPEC.NAME] as string) ?? "Vanguard implementation";
                        MessageBox.Show($"{name} does not support mixed stockpiles.");
                        return(false);
                    }
                }
            }

            if (askForName)
            {
                if (GetInputBox("Glitch Harvester", "Enter the new Stash name:", ref value) == DialogResult.OK)
                {
                    Name = value.Trim();
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                Name = StockpileManager_UISide.CurrentStashkey.Alias;
            }

            if (string.IsNullOrWhiteSpace(Name))
            {
                StockpileManager_UISide.CurrentStashkey.Alias = StockpileManager_UISide.CurrentStashkey.Key;
            }
            else
            {
                StockpileManager_UISide.CurrentStashkey.Alias = Name;
            }

            sk.BlastLayer.RasterizeVMDs();

            DataGridViewRow dataRow = S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows[S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows.Add()];

            dataRow.Cells["Item"].Value       = sk;
            dataRow.Cells["GameName"].Value   = sk.GameName;
            dataRow.Cells["SystemName"].Value = sk.SystemName;
            dataRow.Cells["SystemCore"].Value = sk.SystemCore;

            S.GET <RTC_StockpileManager_Form>().RefreshNoteIcons();

            StockpileManager_UISide.StashHistory.Remove(sk);

            RefreshStashHistory();

            DontLoadSelectedStash = true;
            lbStashHistory.ClearSelected();
            DontLoadSelectedStash = false;

            int nRowIndex = S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows.Count - 1;

            S.GET <RTC_StockpileManager_Form>().dgvStockpile.ClearSelection();
            S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows[nRowIndex].Selected = true;

            StockpileManager_UISide.StockpileChanged();

            S.GET <RTC_StockpileManager_Form>().UnsavedEdits = true;

            return(true);
        }
        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);
            }
        }