public static string Process(Configuration configuration, int seed, IProgressReporter progressReporter) { var randomizer = new Randomizer(configuration.GameplaySettings, seed); RandomizedResult randomized = null; if (string.IsNullOrWhiteSpace(configuration.OutputSettings.InputPatchFilename)) { try { randomized = randomizer.Randomize(progressReporter); } catch (RandomizationException ex) { string nl = Environment.NewLine; return($"Error randomizing logic: {ex.Message}{nl}{nl}Please try a different seed"); } catch (Exception ex) { return(ex.Message); } if (configuration.OutputSettings.GenerateSpoilerLog && configuration.GameplaySettings.LogicMode != LogicMode.Vanilla) { SpoilerUtils.CreateSpoilerLog(randomized, configuration.GameplaySettings, configuration.OutputSettings); } } if (configuration.OutputSettings.GenerateROM || configuration.OutputSettings.OutputVC || configuration.OutputSettings.GeneratePatch) { if (!RomUtils.ValidateROM(configuration.OutputSettings.InputROMFilename)) { return("Cannot verify input ROM is Majora's Mask (U)."); } var builder = new Builder(randomized, configuration.CosmeticSettings); try { builder.MakeROM(configuration.OutputSettings, progressReporter); } catch (PatchMagicException) { return($"Error applying patch: Not a valid patch file"); } catch (PatchVersionException ex) { return($"Error applying patch: {ex.Message}"); } catch (Exception ex) { string nl = Environment.NewLine; return($"Error building ROM: {ex.Message}{nl}{nl}Please contact the development team and provide them more information"); } } //settings.InputPatchFilename = null; return(null); //return "Generation complete!"; }
/// <summary> /// Try to perform randomization and make rom /// </summary> private void TryRandomize(BackgroundWorker worker, DoWorkEventArgs e) { if (!_settings.GenerateROM && !_settings.GenerateSpoilerLog && !_settings.GeneratePatch) { MessageBox.Show($"No output selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } RandomizedResult randomized; if (string.IsNullOrWhiteSpace(_settings.InputPatchFilename)) { try { randomized = _randomizer.Randomize(worker, e); } catch (InvalidDataException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (Exception ex) { string nl = Environment.NewLine; MessageBox.Show($"Error randomizing logic: {ex.Message}{nl}{nl}Please try a different seed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_settings.GenerateSpoilerLog && _settings.LogicMode != LogicMode.Vanilla) { SpoilerUtils.CreateSpoilerLog(randomized, _settings); } } else { randomized = new RandomizedResult(_settings, null); } if (_settings.GenerateROM || _settings.GeneratePatch) { if (!ValidateInputFile()) { return; } if (!RomUtils.ValidateROM(_settings.InputROMFilename)) { MessageBox.Show("Cannot verify input ROM is Majora's Mask (U).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _builder = new Builder(randomized); try { _builder.MakeROM(_settings.InputROMFilename, _settings.OutputROMFilename, worker); } catch (Exception ex) { string nl = Environment.NewLine; MessageBox.Show($"Error building ROM: {ex.Message}{nl}{nl}Please contact the development team and provide them more information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } _settings.InputPatchFilename = null; MessageBox.Show("Generation complete!", "Success", MessageBoxButtons.OK, MessageBoxIcon.None); }
public static string Process(Configuration configuration, int seed, IProgressReporter progressReporter) { var randomizer = new Randomizer(configuration.GameplaySettings, seed); RandomizedResult randomized = null; if (string.IsNullOrWhiteSpace(configuration.OutputSettings.InputPatchFilename)) { try { randomized = randomizer.Randomize(progressReporter); if ((configuration.OutputSettings.GenerateSpoilerLog || configuration.OutputSettings.GenerateHTMLLog) && configuration.GameplaySettings.LogicMode != LogicMode.Vanilla) { SpoilerUtils.CreateSpoilerLog(randomized, configuration.GameplaySettings, configuration.OutputSettings); } } catch (RandomizationException ex) { string nl = Environment.NewLine; return($"Error randomizing logic: {ex.Message}{nl}{nl}Please try a different seed"); } catch (Exception ex) { return(ex.Message); } } if (configuration.OutputSettings.GenerateROM || configuration.OutputSettings.OutputVC || configuration.OutputSettings.GeneratePatch) { if (!RomUtils.ValidateROM(configuration.OutputSettings.InputROMFilename)) { return("Cannot verify input ROM is Majora's Mask (U)."); } if (configuration.OutputSettings.OutputVC && !Directory.Exists(Values.VCDirectory)) { return("Error: vc folder is missing and WiiVC wad creation was selected.\n\n" + "If you did not extract the whole randomizer, you must extract the vc folder. If this is a beta release, copy the vc folder from the main release."); } var builder = new Builder(randomized, configuration.CosmeticSettings); try { builder.MakeROM(configuration.OutputSettings, progressReporter); } catch (ROMOverflowException ex) { return($"Error: {ex.Message}"); } catch (PatchMagicException) { return($"Error applying patch: Not a valid patch file"); } catch (PatchVersionException ex) { return($"Error applying patch: {ex.Message}"); } catch (IOException ex) { return(ex.Message); } catch (Exception ex) { string nl = Environment.NewLine; return($"Error building ROM: {ex.Message}{nl}{nl}Please contact the development team and provide them more information"); } } //settings.InputPatchFilename = null; return(null); //return "Generation complete!"; }