public static bool InjectFromStashkey(StashKey sk, bool _loadBeforeOperation = true)
        {
            string saveStateWord = "Savestate";

            object renameSaveStateWord = AllSpec.VanguardSpec[VSPEC.RENAME_SAVESTATE];

            if (renameSaveStateWord != null && renameSaveStateWord is String s)
            {
                saveStateWord = s;
            }


            PreApplyStashkey();

            StashKey psk = CurrentSavestateStashKey;

            if (psk == null)
            {
                MessageBox.Show($"The Glitch Harvester could not perform the INJECT action\n\nEither no {saveStateWord} Box was selected in the {saveStateWord} Manager\nor the {saveStateWord} Box itself is empty.");
                return(false);
            }

            if (psk.SystemCore != sk.SystemCore && !RtcCore.AllowCrossCoreCorruption)
            {
                MessageBox.Show("Merge attempt failed: Core mismatch\n\n" + $"{psk.GameName} -> {psk.SystemName} -> {psk.SystemCore}\n{sk.GameName} -> {sk.SystemName} -> {sk.SystemCore}");
                return(false);
            }

            CurrentStashkey = new StashKey(RtcCore.GetRandomKey(), psk.ParentKey, sk.BlastLayer)
            {
                RomFilename   = psk.RomFilename,
                SystemName    = psk.SystemName,
                SystemCore    = psk.SystemCore,
                GameName      = psk.GameName,
                SyncSettings  = psk.SyncSettings,
                StateLocation = psk.StateLocation
            };

            if (_loadBeforeOperation)
            {
                if (!LoadState(CurrentStashkey))
                {
                    return(false);
                }
            }
            else
            {
                LocalNetCoreRouter.Route(NetcoreCommands.CORRUPTCORE, NetcoreCommands.APPLYBLASTLAYER, new object[] { CurrentStashkey.BlastLayer, true }, true);
            }

            bool isCorruptionApplied = CurrentStashkey?.BlastLayer?.Layer?.Count > 0;

            if (StashAfterOperation)
            {
                StashHistory.Add(CurrentStashkey);
            }

            PostApplyStashkey();
            return(isCorruptionApplied);
        }
示例#2
0
        public static bool ApplyStashkey(StashKey sk, bool _loadBeforeOperation = true, bool _clearUnitsBeforeApply = true)
        {
            PreApplyStashkey(_clearUnitsBeforeApply);

            bool isCorruptionApplied = sk?.BlastLayer?.Layer?.Count > 0;

            if (_loadBeforeOperation)
            {
                if (!LoadState(sk))
                {
                    return(isCorruptionApplied);
                }
            }
            else
            {
                bool mergeWithCurrent = !_clearUnitsBeforeApply;

                //APPLYBLASTLAYER
                //Param 0 is BlastLayer
                //Param 1 is storeUncorruptBackup
                //Param 2 is MergeWithCurrent (for fixing blast toggle with inject)
                LocalNetCoreRouter.Route(NetcoreCommands.CORRUPTCORE, NetcoreCommands.APPLYBLASTLAYER, new object[] { sk?.BlastLayer, true, mergeWithCurrent }, true);
            }

            PostApplyStashkey();
            return(isCorruptionApplied);
        }
 private void sendCurrentStockpileToSKS()
 {
     foreach (DataGridViewRow dataRow in dgvStockpile.Rows)
     {
         StashKey sk = (StashKey)dataRow.Cells["Item"].Value;
     }
 }
示例#4
0
        public static bool MergeStashkeys(List <StashKey> sks, bool _stashAfterOperation = true)
        {
            if (sks != null && sks.Count > 1)
            {
                BlastLayer bl = new BlastLayer();
                foreach (StashKey item in sks)
                {
                    bl.Layer.AddRange(item.BlastLayer.Layer);
                }

                StashKey newSk = new StashKey(WGH_Core.GetRandomKey(), bl);
                WGH_Core.ghForm.lbStashHistory.Items.Add(newSk);

                WGH_Core.ghForm.RefreshStashHistory();

                WGH_Core.RestoreTarget();
                newSk.Run();
                WGH_Executor.Execute();

                return(true);
            }
            else
            {
                MessageBox.Show("You need 2 or more items for Merging");
                return(false);
            }
        }
示例#5
0
        private void btnInjectSelected_Click(object sender, EventArgs e)
        {
            if (WGH_Core.currentMemoryInterface == null)
            {
                MessageBox.Show("No target is loaded");
                return;
            }

            TerminateIfNeeded();

            StashKey sk = null;

            if (lbStashHistory.SelectedIndex != -1)
            {
                sk = (StashKey)lbStashHistory.SelectedItem;
            }
            else if (lbStockpile.SelectedIndex != -1)
            {
                sk = (StashKey)lbStockpile.SelectedItem;
            }

            if (sk != null)
            {
                WGH_Core.RestoreTarget();

                sk.Run();
                WGH_Executor.Execute();
            }
        }
示例#6
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);
            }
        }
示例#7
0
        public static StashKey SaveStateLess_NET(StashKey _sk = null, bool threadSave = false)
        {
            string Key;
            //string statePath = "";

            StashKey sk;

            if (_sk == null)
            {
                Key = RtcCore.GetRandomKey();
                //statePath = LocalNetCoreRouter.QueryRoute<String>(NetcoreCommands.VANGUARD, NetcoreCommands.SAVESAVESTATE, Key, true);
                sk = new StashKey(Key, Key, null);
            }
            else
            {
                Key = _sk.Key;
                //statePath = _sk.StateFilename;
                sk = _sk;
            }

            //if (string.IsNullOrEmpty(statePath))
            //    return null;

            //sk.StateShortFilename = statePath.Substring(statePath.LastIndexOf(Path.DirectorySeparatorChar) + 1, statePath.Length - (statePath.LastIndexOf(Path.DirectorySeparatorChar) + 1));
            sk.StateShortFilename = "";
            sk.StateFilename      = "";

            return(sk);
        }
示例#8
0
        private void btnLoadCorrupt_Click(object sender, EventArgs e)
        {
            string saveStateWord = "Savestate";

            object renameSaveStateWord = AllSpec.VanguardSpec[VSPEC.RENAME_SAVESTATE];

            if (renameSaveStateWord != null && renameSaveStateWord is string s)
            {
                saveStateWord = s;
            }

            try
            {
                btnLoadCorrupt.Enabled = false;
                btnSendTo.Enabled      = false;
                btnJustCorrupt.Enabled = false;

                StashKey newSk = null;
                if (sk == null)
                {
                    StashKey psk = StockpileManager_UISide.CurrentSavestateStashKey;
                    if (psk == null)
                    {
                        MessageBox.Show(
                            $"Could not perform the CORRUPT action\n\nEither no {saveStateWord} Box was selected in the {saveStateWord} Manager\nor the {saveStateWord} Box itself is empty.");
                        return;
                    }

                    newSk = new StashKey(CorruptCore.RtcCore.GetRandomKey(), psk.ParentKey, null)
                    {
                        RomFilename   = psk.RomFilename,
                        SystemName    = psk.SystemName,
                        SystemCore    = psk.SystemCore,
                        GameName      = psk.GameName,
                        SyncSettings  = psk.SyncSettings,
                        StateLocation = psk.StateLocation
                    };
                }
                else
                {
                    newSk = (StashKey)sk.Clone();
                }

                BlastLayer bl = GenerateBlastLayers(true, true);
                if (bl == null)
                {
                    return;
                }

                newSk.BlastLayer = bl;
            }
            finally
            {
                btnLoadCorrupt.Enabled = true;
                btnSendTo.Enabled      = true;
                btnJustCorrupt.Enabled = true;
            }
        }
示例#9
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;
            }
        }
        public void renameStashKey(StashKey sk)
        {
            string value = "";

            if (GetInputBox("Glitch Harvester", "Enter the new Stash name:", ref value) == DialogResult.OK && !String.IsNullOrWhiteSpace(value))
            {
                sk.Alias = value.Trim();
            }
            else
            {
                return;
            }
        }
示例#11
0
        public static StashKey SaveState(StashKey sk = null, bool threadSave = false)
        {
            bool UseSavestates = (bool)AllSpec.VanguardSpec[VSPEC.SUPPORTS_SAVESTATES];

            if (UseSavestates)
            {
                return(LocalNetCoreRouter.QueryRoute <StashKey>(NetcoreCommands.CORRUPTCORE, NetcoreCommands.REMOTE_SAVESTATE, sk, true));
            }
            else
            {
                return(LocalNetCoreRouter.QueryRoute <StashKey>(NetcoreCommands.CORRUPTCORE, NetcoreCommands.REMOTE_SAVESTATELESS, sk, true));
            }
        }
示例#12
0
 private static void RemoveBackup(StashKey sk)
 {
     try
     {
         if (File.Exists(sk.StateFilename))
         {
             File.Delete(sk.StateFilename);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Unable to remove backup " + sk + " from queue!\n\n" + e.ToString());
     }
 }
示例#13
0
 private static void RemoveBackup(StashKey sk)
 {
     try
     {
         if (File.Exists(sk.StateFilename))
         {
             File.Delete(sk.StateFilename);
         }
     }
     catch (Exception e)
     {
         logger.Error(e, "Unable to remove backup {stashkey} from queue!", sk);
     }
 }
示例#14
0
        public static BlastLayer GetAppliedBackupLayer(BlastLayer bl, StashKey sk)
        {
            //So basically due to how netcore handles synced commands, we can't actually call sk.Run()
            //from within emuhawk or else it'll apply the blastlayer AFTER this code completes
            //So we manually apply the blastlayer
            sk.RunOriginal();
            sk.BlastLayer.Apply(false);

            //Fake advance a frame here to get it processed and the values set
            StepActions.Execute();
            BlastLayer newBlastLayer = bl.GetBackup();

            //Clear it all out
            StepActions.ClearStepBlastUnits();
            return(newBlastLayer);
        }
示例#15
0
 public void SetStashKey(SaveStateKey key, int number)
 {
     ssk = key;
     _sk = key?.StashKey;
     if (key?.Text == null)
     {
         tbSavestate.Visible = false;
     }
     else
     {
         tbSavestate.Text    = key.Text;
         tbSavestate.Visible = true;
     }
     btnSavestate.Text        = number.ToString();
     tbSavestate.TextChanged += TbSavestate_TextChanged;
 }
示例#16
0
        /// <summary>
        /// Takes a stashkey and a list of keys, fixing the path and if a list of keys is provided, it'll look for all shared references and update them
        /// </summary>
        /// <param name="psk"></param>
        /// <param name="keys"></param>
        /// <returns></returns>
        public static bool CheckAndFixMissingReference(StashKey psk, bool force = false, List <StashKey> keys = null, string customTitle = null, string customMessage = null)
        {
            string message = customMessage ?? $"Can't find file {psk.RomFilename}\nGame name: {psk.GameName}\nSystem name: {psk.SystemName}\n\n To continue loading, provide a new file for replacement.";
            string title   = customTitle ?? "Error: File not found";

            if (force || !File.Exists(psk.RomFilename))
            {
                if (DialogResult.OK == MessageBox.Show(message, title, MessageBoxButtons.OKCancel))
                {
                    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 = psk.RomFilename;
                        if (Path.GetFileName(psk.RomFilename) != Path.GetFileName(filename))
                        {
                            if (DialogResult.Cancel == MessageBox.Show($"Selected file {Path.GetFileName(filename)} has a different name than the old file {Path.GetFileName(psk.RomFilename)}.\nIf you know this file is correct, you can ignore this warning.\nContinue?", title,
                                                                       MessageBoxButtons.OKCancel))
                            {
                                return(false);
                            }
                        }

                        foreach (var sk in keys.Where(x => x.RomFilename == oldFilename))
                        {
                            sk.RomFilename      = filename;
                            sk.RomShortFilename = Path.GetFileName(sk.RomFilename);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
示例#17
0
        public void LoadStashkey(StashKey _sk)
        {
            if (_sk == null)
            {
                return;
            }

            //lbBlastLayer.Items.Clear();
            sk = (StashKey)_sk.Clone();

            lbBlastLayer.DataSource = sk.BlastLayer.Layer;

            //foreach (var item in sk.blastlayer.Layer)
            //	lbBlastLayer.Items.Add(item);
            RefreshBlastLayer();
            this.Show();
        }
示例#18
0
        public static void AddBackupState(StashKey sk)
        {
            lock (AllBackupStates)
            {
                if (AllBackupStates.Count > maxStates)
                {
                    var _sk = AllBackupStates.First.Value;
                    AllBackupStates.RemoveFirst();
                    if (_sk != null)
                    {
                        Task.Run(() => RemoveBackup(_sk)); //Do this async to prevent hangs from a slow drive
                    }
                }

                AllBackupStates.AddLast(sk);
            }
        }
示例#19
0
        /*
         * private void btnCorrupt_Click(object sender, EventArgs e)
         * {
         *  BlastLayer bl = new BlastLayer();
         *
         *  foreach (var item in lbBlastLayer.Items)
         *  {
         *      BlastUnit bu = (item as BlastUnit);
         *      if (bu.IsEnabled)
         *          bl.Layer.Add(bu);
         *  }
         *
         *  WGH_Core.RestoreTarget();
         *  bl.Apply();
         * }*/

        private void btnSendToStash_Click(object sender, EventArgs e)
        {
            StashKey newSk = (StashKey)sk.Clone();

            newSk.Key   = WGH_Core.GetRandomKey();
            newSk.Alias = null;

            WGH_Core.ghForm.DontLoadSelectedStash = true;
            WGH_Core.ghForm.lbStashHistory.Items.Add(newSk);
            WGH_Core.ghForm.RefreshStashHistory();
            //  WGH_Core.ghForm.lbStashHistory.Items.Add(WGH_Core.currentStashkey);
            WGH_Core.ghForm.lbStockpile.ClearSelected();
            WGH_Core.ghForm.lbStashHistory.ClearSelected();
            WGH_Core.ghForm.lbStashHistory.SelectedIndex = WGH_Core.ghForm.lbStashHistory.Items.Count - 1;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
示例#20
0
        public static void PopAndRunBackupState()
        {
            StashKey sk = null;

            lock (AllBackupStates)
            {
                if (AllBackupStates.Count > 0)
                {
                    sk = AllBackupStates.Last.Value;
                    AllBackupStates.RemoveLast();
                }
            }
            sk?.Run();
            //Don't delete it if it's also our "current" state
            if (sk != CorruptCore.StockpileManager_UISide.BackupedState)
            {
                Task.Run(() => RemoveBackup(sk)); //Don't wait on the hdd operations
            }
        }
 public void RefreshNoteIcons()
 {
     foreach (DataGridViewRow dataRow in dgvStockpile.Rows)
     {
         StashKey sk = (StashKey)dataRow.Cells["Item"].Value;
         if (sk == null)
         {
             continue;
         }
         if (String.IsNullOrWhiteSpace(sk.Note))
         {
             dataRow.Cells["Note"].Value = "";
         }
         else
         {
             dataRow.Cells["Note"].Value = "📝";
         }
     }
 }
示例#22
0
        public static bool LoadRom_NET(StashKey sk)
        {
            if (sk == null)
            {
                return(false);
            }

            StashKey.SetCore(sk);
            LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_LOADROM, sk.RomFilename, true);

            string ss = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.SYNCSETTINGS];

            //If the syncsettings are different, update them and load it again. Otheriwse, leave as is
            if (sk.SyncSettings != ss && sk.SyncSettings != null)
            {
                LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_KEY_SETSYNCSETTINGS, sk.SyncSettings, true);
                LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_LOADROM, sk.RomFilename, true);
            }
            return(true);
        }
示例#23
0
        public static bool OriginalFromStashkey(StashKey sk)
        {
            PreApplyStashkey();

            if (sk == null)
            {
                MessageBox.Show("No StashKey could be loaded");
                return(false);
            }

            bool isCorruptionApplied = false;

            if (!LoadState(sk, true, false))
            {
                return(isCorruptionApplied);
            }

            PostApplyStashkey();
            return(isCorruptionApplied);
        }
示例#24
0
        private void btnLoadCorrupt_Click(object sender, EventArgs e)
        {
            BlastLayer bl = new BlastLayer();

            foreach (var item in lbBlastLayer.Items)
            {
                BlastUnit bu = (item as BlastUnit);
                if (bu.IsEnabled)
                {
                    bl.Layer.Add(bu);
                }
            }

            StashKey newSk = (StashKey)sk.Clone();

            newSk.BlastLayer = bl;
            WGH_Core.RestoreTarget();
            newSk.Run();
            WGH_Executor.Execute();
        }
示例#25
0
        public static bool LoadState_NET(StashKey sk, bool applyBlastLayer = true)
        {
            if (sk == null)
            {
                return(false);
            }

            bool useStates = (AllSpec.VanguardSpec[VSPEC.SUPPORTS_SAVESTATES] as bool? ?? false);

            if (useStates)
            {
                StashKey.SetCore(sk);
                string gameSystem = sk.SystemName;
                string gameName   = CorruptCore_Extensions.MakeSafeFilename(sk.GameName, '-');
                string key        = sk.ParentKey;
                StashKeySavestateLocation stateLocation = sk.StateLocation;

                string theoreticalSaveStateFilename = Path.Combine(RtcCore.workingDir, stateLocation.ToString(), gameName + "." + key + ".timejump.State");

                if (File.Exists(theoreticalSaveStateFilename))
                {
                    if (!LocalNetCoreRouter.QueryRoute <bool>(NetcoreCommands.VANGUARD, NetcoreCommands.LOADSAVESTATE, new object[] { theoreticalSaveStateFilename, stateLocation }, true))
                    {
                        MessageBox.Show($"Error loading savestate : An internal error has occurred.\n Are you sure your savestate matches the game, your syncsettings match, and the savestate is supported by this version of {RtcCore.VanguardImplementationName}?");
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show($"Error loading savestate : (File {theoreticalSaveStateFilename} not found)");
                    return(false);
                }
            }

            if (applyBlastLayer && sk?.BlastLayer?.Layer?.Count > 0)
            {
                CorruptBL = sk.BlastLayer;
                sk.BlastLayer.Apply(true);
            }
            return(true);
        }
示例#26
0
        public static bool ApplyStashkey(StashKey sk, bool _loadBeforeOperation = true)
        {
            PreApplyStashkey();

            bool isCorruptionApplied = sk?.BlastLayer?.Layer?.Count > 0;

            if (_loadBeforeOperation)
            {
                if (!LoadState(sk))
                {
                    return(isCorruptionApplied);
                }
            }
            else
            {
                LocalNetCoreRouter.Route(NetcoreCommands.CORRUPTCORE, NetcoreCommands.APPLYBLASTLAYER, new object[] { sk?.BlastLayer, true }, true);
            }

            PostApplyStashkey();
            return(isCorruptionApplied);
        }
示例#27
0
        public static void ClearAllBackups()
        {
            StockpileManager_UISide.BackupedState = null;
            StashKey[] states = new StashKey[0];

            //Grab a copy then clear it out
            lock (AllBackupStates)
            {
                states = AllBackupStates?.ToArray();
                AllBackupStates.Clear();
            }

            //Do this async
            Task.Run(() =>
            {
                foreach (var sk in states)
                {
                    RemoveBackup(sk);
                }
            });
        }
        public void btnSendRaw_Click(object sender, EventArgs e)
        {
            if (!btnSendRaw.Visible)
            {
                return;
            }
            try
            {
                SetBlastButtonVisibility(false);

                string romFilename = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.OPENROMFILENAME];
                if (romFilename == null)
                {
                    return;
                }
                if (romFilename.Contains("|"))
                {
                    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;
                }

                StashKey sk = LocalNetCoreRouter.QueryRoute <StashKey>(NetcoreCommands.CORRUPTCORE, NetcoreCommands.REMOTE_KEY_GETRAWBLASTLAYER, true);

                StockpileManager_UISide.CurrentStashkey = sk;
                StockpileManager_UISide.StashHistory.Add(StockpileManager_UISide.CurrentStashkey);


                S.GET <RTC_StashHistory_Form>().DontLoadSelectedStash = true;
                S.GET <RTC_StashHistory_Form>().RefreshStashHistorySelectLast();
                S.GET <RTC_StashHistory_Form>().DontLoadSelectedStash = true;
                S.GET <RTC_StockpileManager_Form>().dgvStockpile.ClearSelection();
                S.GET <RTC_StashHistory_Form>().DontLoadSelectedStash = false;
            }
            finally
            {
                SetBlastButtonVisibility(true);
            }
        }
示例#29
0
        public void LoadStashkey(StashKey _sk)
        {
            if (_sk == null)
            {
                return;
            }

            if (!RefreshDomains())
            {
                return;
            }

            sk            = (StashKey)_sk.Clone();
            sk.BlastLayer = new BlastLayer();

            AddDefaultRow();
            PopulateModeCombobox(dgvBlastGenerator.Rows[0]);
            OpenedFromBlastEditor = true;
            btnSendTo.Text        = "Send to Blast Editor";
            initialized           = true;

            this.Show();
            this.BringToFront();
        }
示例#30
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);
        }