public UIWorldLoadSpecial(GenerationProgress progress)
        {
            instance        = this;
            menuTexture     = ModContent.GetTexture("WorldGenPreviewer/menu");
            previousTexture = ModContent.GetTexture("WorldGenPreviewer/previous");
            playTexture     = ModContent.GetTexture("WorldGenPreviewer/play");
            pauseTexture    = ModContent.GetTexture("WorldGenPreviewer/pause");
            nextTexture     = ModContent.GetTexture("WorldGenPreviewer/next");

            menuButton     = new UIImageButton(menuTexture);
            previousButton = new UIImageButton(previousTexture);
            playButton     = new UIImageButton(playTexture);
            pauseButton    = new UIImageButton(pauseTexture);
            nextButton     = new UIImageButton(nextTexture);
            cancelButton   = new UIImageButton(ModContent.GetTexture("WorldGenPreviewer/cancel"));

            passesPanel = new UIPanel();
            passesPanel.SetPadding(3);
            passesPanel.Left.Pixels = listHidden ? panelWidth : 0;
            passesPanel.HAlign      = 1f;
            passesPanel.Top.Set(0f, 0f);
            passesPanel.Width.Set(panelWidth, 0f);
            passesPanel.Height.Set(0f, 1f);
            passesPanel.BackgroundColor = new Color(73, 94, 171);

            passesList = new UIList();
            passesList.Width.Set(0f, 1f);
            passesList.Height.Set(0f, 1f);
            passesList.ListPadding = 12f;
            passesPanel.Append(passesList);

            UIScrollbar passesListScrollbar = new UIScrollbar();

            passesListScrollbar.SetView(100f, 1000f);
            passesListScrollbar.Height.Set(0f, 1f);
            passesListScrollbar.HAlign = 1f;
            passesPanel.Append(passesListScrollbar);
            passesList.SetScrollbar(passesListScrollbar);

            int order = 0;

            for (int i = 0; i < WorldGenPreviewerModWorld.generationPasses.Count; i++)
            {
                GenPass pass = WorldGenPreviewerModWorld.generationPasses[i];
                if (pass.Name != "World Gen Paused")
                {
                    order++;
                    UIPassItem testLabel = new UIPassItem(order, pass, pass.Name, 1f, false);
                    //testLabel.Top.Pixels = y;
                    //y += 10;
                    passesList.Add(testLabel);
                    //passesPanel.Append(testLabel);
                }
            }
            Append(passesPanel);

            buttonPanel = new UIPanel();
            buttonPanel.SetPadding(0);
            //buttonPanel.Left.Set(0f, .5f);
            buttonPanel.HAlign = 0.5f;
            buttonPanel.Top.Set(180f, 0f);
            //buttonPanel.Width.Set(170f, 0f);
            buttonPanel.Height.Set(32 + spacing * 2 + 16, 0f);
            buttonPanel.BackgroundColor = new Color(73, 94, 171);

            float calculatedWidth = spacing;

            buttonPanel.Append(menuButton);
            menuButton.OnClick    += MenuClick;
            menuButton.Left.Pixels = calculatedWidth;
            menuButton.Top.Pixels  = spacing;
            calculatedWidth       += spacing + 32;

            buttonPanel.Append(previousButton);
            previousButton.OnClick    += PreviousClick;
            previousButton.Left.Pixels = calculatedWidth;
            previousButton.Top.Pixels  = spacing;
            calculatedWidth           += spacing + 32;

            buttonPanel.Append(playButton);
            playButton.OnClick    += PlayClick;
            playButton.Left.Pixels = calculatedWidth;
            playButton.Top.Pixels  = spacing;
            calculatedWidth       += spacing + 32;

            buttonPanel.Append(pauseButton);
            pauseButton.OnClick    += PauseClick;
            pauseButton.Left.Pixels = calculatedWidth;
            pauseButton.Top.Pixels  = spacing;
            calculatedWidth        += spacing + 32;

            buttonPanel.Append(nextButton);
            nextButton.OnClick    += NextClick;
            nextButton.Left.Pixels = calculatedWidth;
            nextButton.Top.Pixels  = spacing;
            calculatedWidth       += spacing + 32;

            buttonPanel.Append(cancelButton);
            cancelButton.OnClick    += CancelClick;
            cancelButton.Left.Pixels = calculatedWidth;
            cancelButton.Top.Pixels  = spacing;
            calculatedWidth         += spacing + 32;

            statusLabel        = new UIText("Status: Normal", 1f, false);
            statusLabel.VAlign = 1f;
            statusLabel.HAlign = 0.5f;
            statusLabel.Top.Set(-5f, 0f);
            buttonPanel.Append(statusLabel);

            buttonPanel.Width.Pixels = calculatedWidth;
            Append(buttonPanel);

            this._progressBar.Top.Pixels = 70f;
            this._progressBar.HAlign     = 0.5f;
            this._progressBar.VAlign     = 0f;
            this._progressBar.Recalculate();
            this._progressMessage.CopyStyle(this._progressBar);
            UIHeader expr_78_cp_0 = this._progressMessage;

            expr_78_cp_0.Top.Pixels = expr_78_cp_0.Top.Pixels - 70f;
            this._progressMessage.Recalculate();
            this._progress = progress;
            base.Append(this._progressBar);
            base.Append(this._progressMessage);
        }
        public override void ModifyWorldGenTasks(List <GenPass> tasks, ref float totalWeight)
        {
            generationPasses = tasks;
            // Reset Terrain
            // Reset Special Terrain
            // or after reset
            Main.skipMenu = false;             // Reset skipMenu to false so that worlds can be saved
            int ResetStepIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Reset"));

            if (ResetStepIndex != -1)
            {
                tasks.Insert(ResetStepIndex + 1, new PassLegacy("Special World Gen Progress", delegate(GenerationProgress progress, GameConfiguration config)
                {
                    Main.FixUIScale();
                    progress.Message = "Setting up Special World Gen Progress";
                    Main.refreshMap  = true;
                    var a            = new UIWorldLoadSpecial(progress);

                    Main.MenuUI.SetState(a);

                    Main.updateMap          = false;
                    Main.mapStyle           = 0;
                    Main.mapFullscreen      = true;
                    Main.mapFullscreenScale = Main.screenWidth / (float)Main.maxTilesX * 0.8f;
                    Main.mapMinX            = 0;
                    Main.mapMinY            = 0;
                    Main.mapMaxX            = Main.maxTilesX;
                    Main.mapMaxY            = Main.maxTilesY;
                    Main.mapFullscreenPos   = new Vector2(Main.maxTilesX / 2, Main.maxTilesY / 2);
                    Main.mapReady           = true;
                }));

                // Reset Special Paused Terrain Paused ...
                for (int i = tasks.Count - 1; i >= ResetStepIndex + 2; i--)
                {
                    string  name     = tasks[i - 1].Name;
                    GenPass previous = tasks[i - 1];
                    GenPass next     = tasks[i];
                    tasks.Insert(i, new PassLegacy("World Gen Paused", delegate(GenerationProgress progress, GameConfiguration config)
                    {
                        UIWorldLoadSpecial.BadPass = next.Name == "Expand World";

                        foreach (var item in UIWorldLoadSpecial.instance.passesList._items)
                        {
                            UIPassItem passitem = item as UIPassItem;
                            if (passitem.pass == previous)
                            {
                                passitem.Complete();
                                break;
                            }
                        }
                        if (!continueWorldGen)
                        {
                            progress.Message = "World Gen Paused after " + name;
                            UIWorldLoadSpecial.instance.statusLabel.SetText("Status: Paused");
                        }
                        while (true)
                        {
                            if (repeatPreviousStep)
                            {
                                repeatPreviousStep = false;
                                //string previousStatus = UIWorldLoadSpecial.instance.statusLabel.SetText
                                UIWorldLoadSpecial.instance.statusLabel.SetText("Status: Doing Previous Step Again");
                                previous.Apply(progress, config);
                                //if (continueWorldGen)
                                //{
                                //	UIWorldLoadSpecial.instance.statusLabel.SetText("Status: Normal");
                                //}
                                //else
                                //{
                                UIWorldLoadSpecial.instance.statusLabel.SetText("Status: Paused");
                                //}
                            }
                            if (continueWorldGen)
                            {
                                if (pauseAfterContinue)
                                {
                                    pauseAfterContinue = false;
                                    continueWorldGen   = false;
                                }
                                break;
                            }
                        }
                    }));
                }
            }
            else
            {
                Mod.Logger.Error("WorldGenPreviewer mod unable to do it's thing since someone removed reset step");
            }
        }