コード例 #1
0
        public override void OnEnter()
        {
            if (SuppressEnter)
            {
                SuppressEnter = false;
                return;
            }

            DwarfGame.GumInputMapper.GetInputQueue();

            #region Setup GUI
            GuiRoot = new Gui.Root(DwarfGame.GuiSkin);
            GuiRoot.MousePointer = new MousePointer("mouse", 15.0f, 16, 17, 18, 19, 20, 21, 22, 23);

            MainPanel = GuiRoot.RootItem.AddChild(new Gui.Widget
            {
                Rect           = GuiRoot.RenderData.VirtualScreen,
                Border         = "border-fancy",
                Text           = Settings.Name,
                Font           = "font16",
                TextColor      = new Vector4(0, 0, 0, 1),
                Padding        = new Margin(4, 4, 4, 4),
                InteriorMargin = new Margin(24, 0, 0, 0)
            });

            var rightPanel = MainPanel.AddChild(new Widget
            {
                MinimumSize = new Point(256, 0),
                Padding     = new Margin(2, 2, 2, 2),
                AutoLayout  = AutoLayout.DockRight
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Back",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    GameStateManager.PopState();
                }
            });

            rightPanel.AddChild(new Widget
            {
                Text               = "Factions",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    SuppressEnter = true;
                    GameStateManager.PushState(new FactionViewState(GameState.Game, Settings));
                }
            });

            switch (PanelState)
            {
            case PanelStates.Generate:
                RightPanel = rightPanel.AddChild(new GenerationPanel(Game, Settings)
                {
                    RestartGeneration = () => RestartGeneration(),
                    GetGenerator      = () => Generator,
                    OnVerified        = () =>
                    {
                        SwitchToLaunchPanel();
                    },
                    AutoLayout = Gui.AutoLayout.DockFill,
                });
                break;

            case PanelStates.Launch:
                RightPanel = rightPanel.AddChild(new LaunchPanel(Game, Generator, Settings, this)
                {
                    AutoLayout = AutoLayout.DockFill,
                });

                break;
            }

            GenerationProgress = MainPanel.AddChild(new Gui.Widgets.ProgressBar
            {
                AutoLayout          = Gui.AutoLayout.DockBottom,
                TextHorizontalAlign = Gui.HorizontalAlign.Center,
                TextVerticalAlign   = Gui.VerticalAlign.Center,
                Font      = "font10",
                TextColor = new Vector4(1, 1, 1, 1)
            }) as Gui.Widgets.ProgressBar;

            PoliticsToggle = MainPanel.AddChild(new Gui.Widgets.CheckBox
            {
                Text     = "Show Political Boundaries",
                Hidden   = true,
                OnLayout = (sender) =>
                {
                    sender.Rect = GenerationProgress.Rect;
                },
                OnCheckStateChange = (sender) =>
                {
                    Preview.ShowPolitics = (sender as Gui.Widgets.CheckBox).CheckState;
                }
            }) as Gui.Widgets.CheckBox;

            Preview = MainPanel.AddChild(new WorldGeneratorPreview(Game.GraphicsDevice)
            {
                Border     = "border-thin",
                AutoLayout = Gui.AutoLayout.DockFill,
                Overworld  = Settings,
                Hidden     = true,
                OnLayout   = (sender) =>
                {
                    //sender.Rect = new Rectangle(sender.Rect.X, sender.Rect.Y, sender.Rect.Width, GenerationProgress.Rect.Bottom - sender.Rect.Y);
                },
                OnCellSelectionMade = () =>
                {
                    if (RightPanel is LaunchPanel launch)
                    {
                        launch.UpdateCellInfo();
                    }
                }
            }) as WorldGeneratorPreview;
コード例 #2
0
ファイル: GuiDebugState.cs プロジェクト: Rod995/dwarfcorp
        public override void OnEnter()
        {
            // Clear the input queue... cause other states aren't using it and it's been filling up.
            DwarfGame.GumInputMapper.GetInputQueue();

            GuiRoot = new Gui.Root(DwarfGame.GuiSkin);
            GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0);
            MakeMenu();

            Progress = GuiRoot.RootItem.AddChild(new Gui.Widgets.ProgressBar
            {
                Rect = new Rectangle(0, 0, GuiRoot.RenderData.VirtualScreen.Width, 32)
            }) as Gui.Widgets.ProgressBar;

            Dictionary <GameMaster.ToolMode, Gui.Widget> ToolbarItems = new Dictionary <GameMaster.ToolMode, Gui.Widget>();

            //ToolbarItems[GameMaster.ToolMode.SelectUnits] = CreateIcon(5, GameMaster.ToolMode.SelectUnits);
            //    ToolbarItems[GameMaster.ToolMode.Dig] = CreateIcon(0, GameMaster.ToolMode.Dig);
            //    ToolbarItems[GameMaster.ToolMode.Build] = CreateIcon(2, GameMaster.ToolMode.Build);
            //    ToolbarItems[GameMaster.ToolMode.Cook] = CreateIcon(3, GameMaster.ToolMode.Cook);
            //    ToolbarItems[GameMaster.ToolMode.Farm] = CreateIcon(5, GameMaster.ToolMode.Farm);
            //    ToolbarItems[GameMaster.ToolMode.Magic] = CreateIcon(6, GameMaster.ToolMode.Magic);
            //    ToolbarItems[GameMaster.ToolMode.Gather] = CreateIcon(6, GameMaster.ToolMode.Gather);
            //    ToolbarItems[GameMaster.ToolMode.Chop] = CreateIcon(1, GameMaster.ToolMode.Chop);
            //    ToolbarItems[GameMaster.ToolMode.Guard] = CreateIcon(4, GameMaster.ToolMode.Guard);
            //    ToolbarItems[GameMaster.ToolMode.Attack] = CreateIcon(3, GameMaster.ToolMode.Attack);

            var Tilesheet = AssetManager.GetContentTexture(ContentPaths.Terrain.terrain_tiles);

            VoxelLibrary.InitializeDefaultLibrary(Game.GraphicsDevice);

            var bottomRightTray = GuiRoot.RootItem.AddChild(new Gui.Widgets.ToolTray.Tray
            {
                IsRootTray = true,
                Corners    = Gui.Scale9Corners.Left | Gui.Scale9Corners.Top,
                AutoLayout = Gui.AutoLayout.FloatBottom,
                ItemSource = new Gui.Widget[]
                {
                    new Gui.Widgets.ToolTray.Icon
                    {
                        Icon             = new TileReference("tool-icons", 5),
                        KeepChildVisible = true,
                        ExpansionChild   = new Gui.Widgets.ToolTray.Tray
                        {
                            ItemSource = RoomLibrary.GetRoomTypes().Select(name => RoomLibrary.GetData(name))
                                         .Select(data => new Gui.Widgets.ToolTray.Icon
                            {
                                Icon           = data.NewIcon,
                                ExpansionChild = new Gui.Widgets.BuildRoomInfo
                                {
                                    Data = data,
                                    Rect = new Rectangle(0, 0, 256, 128)
                                },
                                OnClick = (sender, args) =>
                                {
                                    (sender as Gui.Widgets.FramedIcon).Enabled = false;
                                }
                            })
                        }
                    },
                    new Gui.Widgets.ToolTray.Icon
                    {
                        Icon             = new TileReference("tool-icons", 6),
                        KeepChildVisible = true,
                        ExpansionChild   = new Gui.Widgets.ToolTray.Tray
                        {
                            ItemSource = VoxelLibrary.GetTypes().Where(voxel => voxel.IsBuildable)
                                         .Select(data => new Gui.Widgets.ToolTray.Icon
                            {
                                Icon           = new TileReference("rooms", 0),
                                ExpansionChild = new Gui.Widgets.BuildWallInfo
                                {
                                    Data = data,
                                    Rect = new Rectangle(0, 0, 256, 128)
                                }
                            })
                        }
                    }
                }
            });

            bottomRightTray.Hidden = false;
            GuiRoot.RootItem.Layout();

            IsInitialized = true;

            base.OnEnter();
        }
コード例 #3
0
        public override void OnEnter()
        {
            // Clear the input queue... cause other states aren't using it and it's been filling up.
            DwarfGame.GumInputMapper.GetInputQueue();

            GuiRoot = new Gui.Root(DwarfGame.GuiSkin);
            GuiRoot.MousePointer = new MousePointer("mouse", 15.0f, 16, 17, 18, 19, 20, 21, 22, 23);

            var mainPanel = GuiRoot.RootItem.AddChild(new Gui.Widget
            {
                Rect           = GuiRoot.RenderData.VirtualScreen,
                Border         = "border-fancy",
                Text           = Settings.Name,
                Font           = "font16",
                TextColor      = new Vector4(0, 0, 0, 1),
                Padding        = new Gui.Margin(4, 4, 4, 4),
                InteriorMargin = new Gui.Margin(24, 0, 0, 0),
            });

            var rightPanel = mainPanel.AddChild(new Gui.Widget
            {
                AutoLayout  = Gui.AutoLayout.DockRight,
                MinimumSize = new Point(256, 0),
                Padding     = new Gui.Margin(2, 2, 2, 2)
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Regenerate",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) => { Settings = new WorldGenerationSettings();  RestartGeneration(); }
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Save World",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    if (Generator.CurrentState != WorldGenerator.GenerationState.Finished)
                    {
                        GuiRoot.ShowTooltip(GuiRoot.MousePosition, "Generator is not finished.");
                    }
                    else
                    {
                        System.IO.DirectoryInfo worldDirectory = System.IO.Directory.CreateDirectory(DwarfGame.GetWorldDirectory() + System.IO.Path.DirectorySeparatorChar + Settings.Name);
                        NewOverworldFile file = new NewOverworldFile(Game.GraphicsDevice, Overworld.Map, Settings.Name, Settings.SeaLevel);
                        file.WriteFile(worldDirectory.FullName);
                        file.SaveScreenshot(worldDirectory.FullName + System.IO.Path.DirectorySeparatorChar + "screenshot.png");
                        GuiRoot.ShowModalPopup(GuiRoot.ConstructWidget(new Gui.Widgets.Popup
                        {
                            Text = "File saved."
                        }));
                    }
                }
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Advanced",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    var advancedSettingsEditor = GuiRoot.ConstructWidget(new Gui.Widgets.WorldGenerationSettingsDialog
                    {
                        Settings = Settings,
                        OnClose  = (s) =>
                        {
                            if ((s as Gui.Widgets.WorldGenerationSettingsDialog).Result == Gui.Widgets.WorldGenerationSettingsDialog.DialogResult.Okay)
                            {
                                RestartGeneration();
                            }
                        }
                    });

                    GuiRoot.ShowModalPopup(advancedSettingsEditor);
                }
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Back",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    Generator.Abort();
                    StateManager.PopState();
                }
            });

            StartButton = rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Start Game",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockBottom,
                OnClick            = (sender, args) =>
                {
                    if (Generator.CurrentState != WorldGenerator.GenerationState.Finished)
                    {
                        GuiRoot.ShowTooltip(GuiRoot.MousePosition, "World generation is not finished.");
                    }
                    else
                    {
                        Overworld.Name        = Settings.Name;
                        Settings.ExistingFile = null;
                        Settings.WorldOrigin  = Settings.WorldGenerationOrigin;
                        Settings.SpawnRect    = Generator.GetSpawnRectangle();
                        if (Settings.Natives == null || Settings.Natives.Count == 0)
                        {
                            Settings.Natives = Generator.NativeCivilizations;
                        }
                        //Settings.StartUnderground = StartUnderground.CheckState;
                        //Settings.RevealSurface = RevealSurface.CheckState;

                        foreach (var faction in Settings.Natives)
                        {
                            Vector2 center            = new Vector2(faction.Center.X, faction.Center.Y);
                            Vector2 spawn             = new Vector2(Generator.GetSpawnRectangle().Center.X, Generator.GetSpawnRectangle().Center.Y);
                            faction.DistanceToCapital = (center - spawn).Length();
                            faction.ClaimsColony      = false;
                        }

                        foreach (var faction in Generator.GetFactionsInSpawn())
                        {
                            faction.ClaimsColony = true;
                        }

                        StateManager.ClearState();
                        StateManager.PushState(new LoadState(Game, StateManager, Settings));
                    }
                }
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text       = "Territory size",
                AutoLayout = Gui.AutoLayout.DockTop,
                Font       = "font8",
                TextColor  = new Vector4(0, 0, 0, 1),
            });

            var colonySizeCombo = rightPanel.AddChild(new Gui.Widgets.ComboBox
            {
                AutoLayout             = Gui.AutoLayout.DockTop,
                Items                  = new List <string>(new string[] { "Small", "Medium", "Large" }),
                Font                   = "font8",
                TextColor              = new Vector4(0, 0, 0, 1),
                OnSelectedIndexChanged = (sender) =>
                {
                    switch ((sender as Gui.Widgets.ComboBox).SelectedItem)
                    {
                    case "Small": Settings.ColonySize = new Point3(4, 1, 4); break;

                    case "Medium": Settings.ColonySize = new Point3(8, 1, 8); break;

                    case "Large": Settings.ColonySize = new Point3(10, 1, 10); break;
                    }

                    var worldSize = Settings.ColonySize.ToVector3() * VoxelConstants.ChunkSizeX / Settings.WorldScale;

                    float w = worldSize.X;
                    float h = worldSize.Z;

                    float clickX = System.Math.Max(System.Math.Min(Settings.WorldGenerationOrigin.X, Settings.Width - w), 0);
                    float clickY = System.Math.Max(System.Math.Min(Settings.WorldGenerationOrigin.Y, Settings.Height - h), 0);

                    Settings.WorldGenerationOrigin = new Vector2((int)(clickX), (int)(clickY));
                }
            }) as Gui.Widgets.ComboBox;

            rightPanel.AddChild(new Gui.Widget
            {
                Text       = "Difficulty",
                AutoLayout = Gui.AutoLayout.DockTop,
                Font       = "font8",
                TextColor  = new Vector4(0, 0, 0, 1)
            });

            var difficultySelectorCombo = rightPanel.AddChild(new Gui.Widgets.ComboBox
            {
                AutoLayout             = Gui.AutoLayout.DockTop,
                Items                  = EmbarkmentLibrary.Embarkments.Select(e => e.Key).ToList(),
                TextColor              = new Vector4(0, 0, 0, 1),
                Font                   = "font8",
                OnSelectedIndexChanged = (sender) =>
                {
                    Settings.InitalEmbarkment = EmbarkmentLibrary.Embarkments[(sender as Gui.Widgets.ComboBox).SelectedItem];
                }
            }) as Gui.Widgets.ComboBox;

            /*
             * StartUnderground = rightPanel.AddChild(new Gui.Widgets.CheckBox
             * {
             *  AutoLayout = Gui.AutoLayout.DockTop,
             *  Font = "font8",
             *  Text = "@world-generation-start-underground"
             * }) as Gui.Widgets.CheckBox;
             *
             * RevealSurface = rightPanel.AddChild(new Gui.Widgets.CheckBox
             * {
             *  AutoLayout = Gui.AutoLayout.DockTop,
             *  Font = "font8",
             *  Text = "@world-generation-reveal-surface",
             *  CheckState = true
             * }) as Gui.Widgets.CheckBox;
             */

            rightPanel.AddChild(new Gui.Widget
            {
                Text       = "Cave Layers",
                AutoLayout = Gui.AutoLayout.DockTop,
                Font       = "font8",
                TextColor  = new Vector4(0, 0, 0, 1),
            });

            var layerSetting = rightPanel.AddChild(new Gui.Widgets.ComboBox
            {
                AutoLayout             = AutoLayout.DockTop,
                Items                  = new List <string>(new string[] { "Barely any", "Few", "Normal", "Lots", "Way too many" }),
                Font                   = "font8",
                TextColor              = new Vector4(0, 0, 0, 1),
                OnSelectedIndexChanged = (sender) =>
                {
                    switch ((sender as Gui.Widgets.ComboBox).SelectedItem)
                    {
                    case "Barely any": Settings.NumCaveLayers = 2; break;

                    case "Few": Settings.NumCaveLayers = 3; break;

                    case "Normal": Settings.NumCaveLayers = 4; break;

                    case "Lots": Settings.NumCaveLayers = 6; break;

                    case "Way too many": Settings.NumCaveLayers = 9; break;
                    }
                }
            }) as Gui.Widgets.ComboBox;

            ZoomedPreview = rightPanel.AddChild(new Gui.Widget
            {
                AutoLayout = Gui.AutoLayout.DockBottom,
                OnLayout   = (sender) =>
                {
                    var space = System.Math.Min(
                        layerSetting.Rect.Width, StartButton.Rect.Top - layerSetting.Rect.Bottom - 4);
                    sender.Rect.Height = space;
                    sender.Rect.Width  = space;
                    sender.Rect.Y      = layerSetting.Rect.Bottom + 2;
                    sender.Rect.X      = layerSetting.Rect.X +
                                         ((layerSetting.Rect.Width - space) / 2);
                }
            });

            GenerationProgress = mainPanel.AddChild(new Gui.Widgets.ProgressBar
            {
                AutoLayout          = Gui.AutoLayout.DockBottom,
                TextHorizontalAlign = Gui.HorizontalAlign.Center,
                TextVerticalAlign   = Gui.VerticalAlign.Center,
                Font      = "font10",
                TextColor = new Vector4(1, 1, 1, 1)
            }) as Gui.Widgets.ProgressBar;

            Preview = mainPanel.AddChild(new WorldGeneratorPreview(Game.GraphicsDevice)
            {
                Border     = "border-thin",
                AutoLayout = Gui.AutoLayout.DockFill
            }) as WorldGeneratorPreview;

            GuiRoot.RootItem.Layout();

            difficultySelectorCombo.SelectedIndex = difficultySelectorCombo.Items.IndexOf("Normal");
            colonySizeCombo.SelectedIndex         = colonySizeCombo.Items.IndexOf("Medium");
            layerSetting.SelectedIndex            = layerSetting.Items.IndexOf("Normal");

            IsInitialized = true;

            if (AutoGenerate)
            {
                RestartGeneration();
            }
            else // Setup a dummy generator for now.
            {
                Generator = new WorldGenerator(Settings);
                Generator.LoadDummy(
                    new Color[Overworld.Map.GetLength(0) * Overworld.Map.GetLength(1)],
                    Game.GraphicsDevice);
                Preview.SetGenerator(Generator);
            }

            base.OnEnter();
        }
コード例 #4
0
        public override void OnEnter()
        {
            // Clear the input queue... cause other states aren't using it and it's been filling up.
            DwarfGame.GumInputMapper.GetInputQueue();

            GuiRoot = new Gui.Root(DwarfGame.GumSkin);
            GuiRoot.MousePointer = new MousePointer("mouse", 15.0f, 16, 17, 18, 19, 20, 21, 22, 23);

            var mainPanel = GuiRoot.RootItem.AddChild(new Gui.Widget
            {
                Rect           = GuiRoot.RenderData.VirtualScreen,
                Border         = "border-fancy",
                Text           = Settings.Name,
                Font           = "font16",
                TextColor      = new Vector4(0, 0, 0, 1),
                Padding        = new Gui.Margin(4, 4, 4, 4),
                InteriorMargin = new Gui.Margin(24, 0, 0, 0),
            });

            var rightPanel = mainPanel.AddChild(new Gui.Widget
            {
                AutoLayout  = Gui.AutoLayout.DockRight,
                MinimumSize = new Point(256, 0),
                Padding     = new Gui.Margin(2, 2, 2, 2)
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Regenerate",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) => { Settings = new WorldGenerationSettings();  RestartGeneration(); }
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Save World",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    if (Generator.CurrentState != WorldGenerator.GenerationState.Finished)
                    {
                        GuiRoot.ShowTooltip(GuiRoot.MousePosition, "Generator is not finished.");
                    }
                    else
                    {
                        System.IO.DirectoryInfo worldDirectory = System.IO.Directory.CreateDirectory(DwarfGame.GetWorldDirectory() + ProgramData.DirChar + Settings.Name);
                        NewOverworldFile file = new NewOverworldFile(Game.GraphicsDevice, Overworld.Map, Settings.Name, Settings.SeaLevel);
                        file.WriteFile(worldDirectory.FullName);
                        file.SaveScreenshot(worldDirectory.FullName + ProgramData.DirChar + "screenshot.png");
                        GuiRoot.ShowModalPopup(GuiRoot.ConstructWidget(new Gui.Widgets.Popup
                        {
                            Text = "File saved."
                        }));
                    }
                }
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Advanced",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    var advancedSettingsEditor = GuiRoot.ConstructWidget(new Gui.Widgets.WorldGenerationSettingsDialog
                    {
                        Settings = Settings,
                        OnClose  = (s) => RestartGeneration()
                    });

                    GuiRoot.ShowModalPopup(advancedSettingsEditor);
                }
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Back",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    Generator.Abort();
                    StateManager.PopState();
                }
            });

            StartButton = rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Start Game",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockBottom,
                OnClick            = (sender, args) =>
                {
                    if (Generator.CurrentState != WorldGenerator.GenerationState.Finished)
                    {
                        GuiRoot.ShowTooltip(GuiRoot.MousePosition, "World generation is not finished.");
                    }
                    else
                    {
                        Overworld.Name        = Settings.Name;
                        Settings.ExistingFile = null;
                        Settings.WorldOrigin  = Settings.WorldGenerationOrigin;
                        if (Settings.Natives == null || Settings.Natives.Count == 0)
                        {
                            Settings.Natives = Generator.NativeCivilizations;
                        }

                        StateManager.ClearState();
                        StateManager.PushState(new LoadState(Game, StateManager, Settings));
                    }
                }
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text       = "Colony size",
                AutoLayout = Gui.AutoLayout.DockTop,
                Font       = "font8",
                TextColor  = new Vector4(0, 0, 0, 1)
            });

            var colonySizeCombo = rightPanel.AddChild(new Gui.Widgets.ComboBox
            {
                AutoLayout             = Gui.AutoLayout.DockTop,
                Items                  = new List <string>(new string[] { "Small", "Medium", "Large" }),
                Font                   = "font8",
                TextColor              = new Vector4(0, 0, 0, 1),
                OnSelectedIndexChanged = (sender) =>
                {
                    switch ((sender as Gui.Widgets.ComboBox).SelectedItem)
                    {
                    case "Small": Settings.ColonySize = new Point3(4, 1, 4); break;

                    case "Medium": Settings.ColonySize = new Point3(8, 1, 8); break;

                    case "Large": Settings.ColonySize = new Point3(10, 1, 10); break;
                    }

                    var worldSize = Settings.ColonySize.ToVector3() * VoxelConstants.ChunkSizeX / Settings.WorldScale;

                    float w = worldSize.X / 2;
                    float h = worldSize.Z / 2;

                    float clickX = System.Math.Max(System.Math.Min(Settings.WorldGenerationOrigin.X, Settings.Width - w), w);
                    float clickY = System.Math.Max(System.Math.Min(Settings.WorldGenerationOrigin.Y, Settings.Height - h), h);

                    Settings.WorldGenerationOrigin = new Vector2((int)(clickX), (int)(clickY));
                }
            }) as Gui.Widgets.ComboBox;

            rightPanel.AddChild(new Gui.Widget
            {
                Text       = "Difficulty",
                AutoLayout = Gui.AutoLayout.DockTop,
                Font       = "font8",
                TextColor  = new Vector4(0, 0, 0, 1)
            });

            var difficultySelectorCombo = rightPanel.AddChild(new Gui.Widgets.ComboBox
            {
                AutoLayout             = Gui.AutoLayout.DockTop,
                Items                  = Embarkment.EmbarkmentLibrary.Select(e => e.Key).ToList(),
                TextColor              = new Vector4(0, 0, 0, 1),
                Font                   = "font8",
                OnSelectedIndexChanged = (sender) =>
                {
                    Settings.InitalEmbarkment = Embarkment.EmbarkmentLibrary[(sender as Gui.Widgets.ComboBox).SelectedItem];
                }
            }) as Gui.Widgets.ComboBox;

            ZoomedPreview = rightPanel.AddChild(new Gui.Widget
            {
                AutoLayout = Gui.AutoLayout.DockBottom,
                OnLayout   = (sender) =>
                {
                    var space = System.Math.Min(
                        difficultySelectorCombo.Rect.Width, StartButton.Rect.Top - difficultySelectorCombo.Rect.Bottom - 4);
                    sender.Rect.Height = space;
                    sender.Rect.Width  = space;
                    sender.Rect.Y      = difficultySelectorCombo.Rect.Bottom + 2;
                    sender.Rect.X      = difficultySelectorCombo.Rect.X +
                                         ((difficultySelectorCombo.Rect.Width - space) / 2);
                }
            });


            StatsLabel = rightPanel.AddChild(new Gui.Widget()
            {
                AutoLayout          = Gui.AutoLayout.DockBottom,
                Font                = "font8",
                TextColor           = new Vector4(1, 1, 1, 1),
                Background          = new TileReference("sbasic", 0),
                BackgroundColor     = new Vector4(0.0f, 0.0f, 0.0f, 0.2f),
                TextHorizontalAlign = HorizontalAlign.Left,
                MinimumSize         = new Point(128, 64),
                WrapText            = true,
                Padding             = new Margin(10, 10, 10, 0)
            });

            GenerationProgress = mainPanel.AddChild(new Gui.Widgets.ProgressBar
            {
                AutoLayout          = Gui.AutoLayout.DockBottom,
                TextHorizontalAlign = Gui.HorizontalAlign.Center,
                TextVerticalAlign   = Gui.VerticalAlign.Center,
                Font      = "font10",
                TextColor = new Vector4(1, 1, 1, 1)
            }) as Gui.Widgets.ProgressBar;

            Preview = mainPanel.AddChild(new WorldGeneratorPreview(Game.GraphicsDevice)
            {
                Border     = "border-thin",
                AutoLayout = Gui.AutoLayout.DockFill
            }) as WorldGeneratorPreview;

            GuiRoot.RootItem.Layout();
            Preview.PreviewPanel.OnClick += (widget, args) =>
            {
                StatsLabel.Text = Generator.GetSpawnStats();

                StatsLabel.Invalidate();
            };

            difficultySelectorCombo.SelectedIndex = difficultySelectorCombo.Items.IndexOf("Normal");
            colonySizeCombo.SelectedIndex         = colonySizeCombo.Items.IndexOf("Medium");

            IsInitialized = true;

            if (AutoGenerate)
            {
                RestartGeneration();
            }
            else // Setup a dummy generator for now.
            {
                Generator = new WorldGenerator(Settings);
                Generator.LoadDummy(
                    new Color[Overworld.Map.GetLength(0) * Overworld.Map.GetLength(1)],
                    Game.GraphicsDevice);
                Preview.SetGenerator(Generator);
            }

            base.OnEnter();
        }