Exemplo n.º 1
0
        // update menu archive
        private static void MenuOps(int seed, SpoilerFile spoilerFile)
        {
            Debug.WriteLine("menu ops start");
            while (true)
            {
                try
                {
                    CreateOrRestoreArchiveBackup(Globals.MenuPath);
                    var menuSource = new FileSource(Globals.MenuPath);

                    // preset names
                    if (Properties.Settings.Default.NameSet)
                    {
                        PresetNames.Apply(menuSource);
                        menuSource.Encode();
                    }

                    // shop shuffle
                    if (Properties.Settings.Default.ShopShuffle)
                    {
                        var shuffle = ShopShuffle.Randomise(seed);
                        if (Properties.Settings.Default.SpoilerFile)
                        {
                            spoilerFile.AddShops(shuffle);
                        }
                        ShopShuffle.Apply(menuSource, shuffle);
                        menuSource.Encode();
                    }

                    break;
                }
                catch (Exception x)
                {
                    if (x is IOException || x is UnauthorizedAccessException || x is FileNotFoundException)
                    {
                        if (HandleFileException(Globals.MenuPath) == false)
                        {
                            break;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            Debug.WriteLine("menu ops end");
        }
Exemplo n.º 2
0
        // update menu archive
        private static void MenuOps(int seed, SpoilerFile spoilerFile, State settings)
        {
            Debug.WriteLine("menu ops start");
            while (true)
            {
                try
                {
                    CreateOrRestoreArchiveBackup(Globals.MenuPath);
                    var menuSource = new FileSource(Globals.MenuPath);

                    // preset names
                    if (settings.NameEnable)
                    {
                        PresetNames.Apply(menuSource, settings);
                    }

                    // shop shuffle
                    if (settings.ShopEnable)
                    {
                        var shuffle = ShopShuffle.Randomise(seed, settings);
                        if (settings.SpoilerFile)
                        {
                            spoilerFile.AddShops(shuffle);
                        }
                        ShopShuffle.Apply(menuSource, shuffle);
                    }

                    // draw point shuffle
                    if (!Globals.Remastered)
                    {
                        if (settings.DrawPointEnable)
                        {
                            var shuffle = DrawPointShuffle.Randomise(seed, settings);
                            if (settings.SpoilerFile)
                            {
                                spoilerFile.AddDrawPoints(shuffle);
                            }
                            DrawPointShuffle.Apply(menuSource, shuffle);
                        }
                        else
                        {
                            DrawPointShuffle.RemovePatch(Globals.ExePath);
                        }
                    }

                    if (settings.NameEnable || settings.ShopEnable || (settings.DrawPointEnable && !Globals.Remastered))
                    {
                        menuSource.Encode();
                    }

                    break;
                }
                catch (Exception x)
                {
                    if (x is IOException || x is UnauthorizedAccessException || x is FileNotFoundException)
                    {
                        if (HandleFileException(Globals.MenuPath) == false)
                        {
                            break;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            Debug.WriteLine("menu ops end");
        }