Пример #1
0
        public override void Construct()
        {
            Padding = new Margin(2, 2, 2, 2);

            base.Construct();

            var bar = AddChild(new Widget
            {
                MinimumSize = new Point(0, 24),
                Padding     = new Margin(0, 0, 2, 2),
                AutoLayout  = AutoLayout.DockTop
            });

            bar.AddChild(new Widget
            {
                Text       = "Filter:",
                AutoLayout = AutoLayout.DockLeft
            });

            FilterBox = bar.AddChild(new Gui.Widgets.EditableTextField
            {
                AutoLayout   = AutoLayout.DockFill,
                MinimumSize  = new Point(0, 24),
                OnTextChange = (sender) => { Grid.ApplyFilter(FilterBox.Text); }
            }) as Gui.Widgets.EditableTextField;

            SelectedCommandDisplay = AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockBottom,
                MinimumSize = new Point(0, 200)
            });

            Grid = AddChild(new CommandGrid
            {
                AutoLayout       = AutoLayout.DockFill,
                World            = World,
                OnCommandClicked = (command) =>
                {
                    SelectedCommandDisplay.Children.Clear();
                    if (command.HoverWidget != null)
                    {
                        SelectedCommandDisplay.AddChild(command.HoverWidget);
                        command.HoverWidget.AutoLayout = AutoLayout.DockFill;
                        command.HoverWidget.Border     = "";
                    }

                    SelectedCommandDisplay.Layout();

                    command.OnClick?.Invoke(command, null);
                }
            }) as CommandGrid;
        }
Пример #2
0
        public override void Construct()
        {
            AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockLeft,
                Background  = new TileReference("coins", 1),
                MinimumSize = new Point(32, 32),
                MaximumSize = new Point(32, 32),
            });

            AddChild(new Widget()
            {
                AutoLayout          = AutoLayout.DockLeft,
                Font                = "font16",
                Text                = "$",
                TextVerticalAlign   = VerticalAlign.Center,
                TextHorizontalAlign = HorizontalAlign.Right,
                MinimumSize         = new Point(16, 32),
                MaximumSize         = new Point(16, 32)
            });

            var buttons = AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockRight,
                MinimumSize = new Point(16, 32)
            });

            buttons.AddChild(new Gui.Widget
            {
                Background  = new TileReference("round-buttons", 7),
                MinimumSize = new Point(16, 16),
                MaximumSize = new Point(16, 16),
                AutoLayout  = AutoLayout.DockBottom,
                OnClick     = (sender, args) =>
                {
                    if (CurrentValue > 0)
                    {
                        CurrentValue = CurrentValue - 1;
                    }
                },
                OnMouseEnter = (sender, args) =>
                {
                    sender.BackgroundColor = GameSettings.Default.Colors.GetColor("Highlight", Color.DarkRed).ToVector4();
                    sender.Invalidate();
                },
                OnMouseLeave = (sender, args) =>
                {
                    sender.BackgroundColor = Vector4.One;
                    sender.Invalidate();
                }
            });

            buttons.AddChild(new Gui.Widget
            {
                Background  = new TileReference("round-buttons", 3),
                MinimumSize = new Point(16, 16),
                MaximumSize = new Point(16, 16),
                AutoLayout  = AutoLayout.DockTop,
                OnClick     = (sender, args) =>
                {
                    if (CurrentValue < MaximumValue)
                    {
                        CurrentValue = CurrentValue + 1;
                    }
                },
                OnMouseEnter = (sender, args) =>
                {
                    sender.BackgroundColor = GameSettings.Default.Colors.GetColor("Highlight", Color.DarkRed).ToVector4();
                    sender.Invalidate();
                },
                OnMouseLeave = (sender, args) =>
                {
                    sender.BackgroundColor = Vector4.One;
                    sender.Invalidate();
                }
            });

            TextField = AddChild(new Gui.Widgets.EditableTextField
            {
                AutoLayout     = AutoLayout.DockFill,
                Font           = "font16",
                TextColor      = new Vector4(0, 0, 0, 1),
                Text           = "",
                ArrowKeyUpDown = (sender, args) =>
                {
                    CurrentValue = Math.Min(Math.Max(CurrentValue + args, 0), MaximumValue);
                    sender.Invalidate();
                },
                BeforeTextChange = (sender, args) =>
                {
                    if (args.NewText == "")
                    {
                        args.NewText   = "";
                        _currentValue  = 0;
                        args.Cancelled = false;
                        return;
                    }
                    int newValue;
                    if (Int32.TryParse(args.NewText, out newValue))
                    {
                        if (newValue < 0)
                        {
                            newValue = 0;
                        }
                        if (newValue > MaximumValue)
                        {
                            newValue = MaximumValue;
                        }
                        _currentValue = newValue;
                        if (newValue == 0)
                        {
                            args.NewText = "";
                        }
                        else
                        {
                            args.NewText = newValue.ToString();
                        }
                        args.Cancelled = false;
                        return;
                    }
                    args.Cancelled = true;
                },
                OnTextChange = (sender) =>
                {
                    Root.SafeCall(OnValueChanged, this);
                    sender.Invalidate();
                }
            }) as Gui.Widgets.EditableTextField;
        }
Пример #3
0
        public override void Construct()
        {
            AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockLeft,
                Background  = new TileReference("coins", 1),
                MinimumSize = new Point(32, 32),
                MaximumSize = new Point(32, 32),
            });

            AddChild(new Widget()
            {
                AutoLayout          = AutoLayout.DockLeft,
                Font                = "font16",
                Text                = "$",
                TextVerticalAlign   = VerticalAlign.Center,
                TextHorizontalAlign = HorizontalAlign.Right,
                MinimumSize         = new Point(16, 32),
                MaximumSize         = new Point(16, 32)
            });

            var buttons = AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockRight,
                MinimumSize = new Point(16, 32)
            });

            buttons.AddChild(new Gui.Widget
            {
                Background  = new TileReference("round-buttons", 7),
                MinimumSize = new Point(16, 16),
                MaximumSize = new Point(16, 16),
                AutoLayout  = AutoLayout.DockBottom,
                OnClick     = (sender, args) =>
                {
                    if (CurrentValue > 0)
                    {
                        CurrentValue = CurrentValue - 1;
                    }
                },
                OnMouseEnter = (sender, args) =>
                {
                    sender.BackgroundColor = Color.DarkRed.ToVector4();
                    sender.Invalidate();
                },
                OnMouseLeave = (sender, args) =>
                {
                    sender.BackgroundColor = Vector4.One;
                    sender.Invalidate();
                }
            });

            buttons.AddChild(new Gui.Widget
            {
                Background  = new TileReference("round-buttons", 3),
                MinimumSize = new Point(16, 16),
                MaximumSize = new Point(16, 16),
                AutoLayout  = AutoLayout.DockTop,
                OnClick     = (sender, args) =>
                {
                    if (CurrentValue < MaximumValue)
                    {
                        CurrentValue = CurrentValue + 1;
                    }
                },
                OnMouseEnter = (sender, args) =>
                {
                    sender.BackgroundColor = Color.DarkRed.ToVector4();
                    sender.Invalidate();
                },
                OnMouseLeave = (sender, args) =>
                {
                    sender.BackgroundColor = Vector4.One;
                    sender.Invalidate();
                }
            });

            TextField = AddChild(new Gui.Widgets.EditableTextField
            {
                AutoLayout       = AutoLayout.DockFill,
                Font             = "font16",
                TextColor        = new Vector4(0, 0, 0, 1),
                Text             = "0",
                BeforeTextChange = (sender, args) =>
                {
                    Valid = false;

                    int newValue;
                    //if (args.NewText.Length == 0) args.NewText = "0";

                    if (Int32.TryParse(args.NewText, out newValue))
                    {
                        if (newValue < 0)
                        {
                            newValue = 0;
                        }
                        if (newValue > MaximumValue)
                        {
                            newValue = MaximumValue;
                        }
                        _currentValue = newValue;
                        Valid         = true;
                        args.NewText  = newValue.ToString();
                    }
                },
                OnTextChange = (sender) =>
                {
                    Root.SafeCall(OnValueChanged, this);
                    sender.Invalidate();
                }
            }) as Gui.Widgets.EditableTextField;
        }
Пример #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.GuiSkin);
            GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0);

            Rectangle rect = GuiRoot.RenderData.VirtualScreen;

            rect.Inflate(-rect.Width / 3, -rect.Height / 3);
            var mainPanel = GuiRoot.RootItem.AddChild(new Gui.Widget
            {
                Rect           = rect,
                MinimumSize    = new Point(512, 256),
                AutoLayout     = AutoLayout.FloatCenter,
                Border         = "border-fancy",
                Padding        = new Margin(4, 4, 4, 4),
                InteriorMargin = new Margin(2, 0, 0, 0),
                TextSize       = 1,
                Font           = "font10"
            });

            mainPanel.AddChild(new Gui.Widgets.Button
            {
                Text = "Create!",
                Font = "font16",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border  = "border-button",
                OnClick = (sender, args) =>
                {
                    // Grab string values from widgets!
                    CompanyInformation.Name  = NameField.Text;
                    CompanyInformation.Motto = MottoField.Text;

                    // Why are they stored as statics on this class???
                    StateManager.PushState(new NewGameChooseWorldState(Game, Game.StateManager));
                },
                AutoLayout = AutoLayout.FloatBottomRight
            });

            mainPanel.AddChild(new Gui.Widgets.Button
            {
                Text = "< Back",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border  = "border-button",
                Font    = "font16",
                OnClick = (sender, args) =>
                {
                    StateManager.PopState();
                },
                AutoLayout = AutoLayout.FloatBottomLeft,
            });

            #region Name

            mainPanel.AddChild(new Widget()
            {
                Text       = "Create a Company",
                Font       = "font16",
                AutoLayout = AutoLayout.DockTop,
            });

            var nameRow = mainPanel.AddChild(new Widget
            {
                MinimumSize = new Point(0, 24),
                AutoLayout  = AutoLayout.DockTop,
                Padding     = new Margin(0, 0, 2, 2)
            });

            nameRow.AddChild(new Gui.Widget
            {
                MinimumSize         = new Point(64, 0),
                Text                = "Name",
                AutoLayout          = AutoLayout.DockLeft,
                TextHorizontalAlign = HorizontalAlign.Right,
                TextVerticalAlign   = VerticalAlign.Center
            });

            nameRow.AddChild(new Gui.Widgets.Button
            {
                Text       = "Randomize",
                AutoLayout = AutoLayout.DockRight,
                Border     = "border-button",
                OnClick    = (sender, args) =>
                {
                    var templates  = TextGenerator.GetAtoms(ContentPaths.Text.Templates.company_exploration);
                    NameField.Text = TextGenerator.GenerateRandom(Datastructures.SelectRandom(templates).ToArray());
                }
            });

            NameField = nameRow.AddChild(new EditableTextField
            {
                Text       = CompanyInformation.Name,
                AutoLayout = AutoLayout.DockFill
            }) as EditableTextField;
            #endregion

            #region Motto
            var mottoRow = mainPanel.AddChild(new Widget
            {
                MinimumSize = new Point(0, 24),
                AutoLayout  = AutoLayout.DockTop,
                Padding     = new Margin(0, 0, 2, 2)
            });

            mottoRow.AddChild(new Widget
            {
                MinimumSize         = new Point(64, 0),
                Text                = "Motto",
                AutoLayout          = AutoLayout.DockLeft,
                TextHorizontalAlign = HorizontalAlign.Right,
                TextVerticalAlign   = VerticalAlign.Center
            });

            mottoRow.AddChild(new Button
            {
                Text       = "Randomize",
                AutoLayout = AutoLayout.DockRight,
                Border     = "border-button",
                OnClick    = (sender, args) =>
                {
                    var templates   = TextGenerator.GetAtoms(ContentPaths.Text.Templates.mottos);
                    MottoField.Text = TextGenerator.GenerateRandom(Datastructures.SelectRandom(templates).ToArray());
                    // Todo: Doesn't automatically invalidate when text changed??
                    MottoField.Invalidate();
                }
            });

            MottoField = mottoRow.AddChild(new EditableTextField
            {
                Text       = CompanyInformation.Motto,
                AutoLayout = AutoLayout.DockFill
            }) as EditableTextField;
            #endregion

            #region Logo

            var logoRow = mainPanel.AddChild(new Widget
            {
                MinimumSize = new Point(0, 64),
                AutoLayout  = AutoLayout.DockTop,
                Padding     = new Margin(0, 0, 2, 2)
            });

            CompanyLogoDisplay = logoRow.AddChild(new Gui.Widgets.CompanyLogo
            {
                AutoLayout         = AutoLayout.DockLeft,
                MinimumSize        = new Point(64, 64),
                MaximumSize        = new Point(64, 64),
                CompanyInformation = CompanyInformation
            }) as Gui.Widgets.CompanyLogo;

            logoRow.AddChild(new Widget
            {
                Text       = "BG:",
                AutoLayout = AutoLayout.DockLeft
            });

            logoRow.AddChild(new Widget
            {
                Background  = CompanyInformation.LogoBackground,
                MinimumSize = new Point(32, 32),
                MaximumSize = new Point(32, 32),
                AutoLayout  = AutoLayout.DockLeft,
                OnClick     = (sender, args) =>
                {
                    var source  = GuiRoot.GetTileSheet("company-logo-background") as Gui.TileSheet;
                    var chooser = new Gui.Widgets.GridChooser
                    {
                        ItemSource = Enumerable.Range(0, source.Columns * source.Rows)
                                     .Select(i => new Widget {
                            Background = new TileReference("company-logo-background", i)
                        }),
                        OnClose = (s2) =>
                        {
                            var gc = s2 as Gui.Widgets.GridChooser;
                            if (gc.DialogResult == Gui.Widgets.GridChooser.Result.OKAY &&
                                gc.SelectedItem != null)
                            {
                                sender.Background = gc.SelectedItem.Background;
                                sender.Invalidate();
                                CompanyInformation.LogoBackground = gc.SelectedItem.Background;
                                CompanyLogoDisplay.Invalidate();
                            }
                        },
                        PopupDestructionType = PopupDestructionType.DestroyOnOffClick
                    };
                    GuiRoot.ShowModalPopup(chooser);
                }
            });

            logoRow.AddChild(new Widget
            {
                Background      = new TileReference("basic", 1),
                BackgroundColor = CompanyInformation.LogoBackgroundColor,
                MinimumSize     = new Point(32, 32),
                MaximumSize     = new Point(32, 32),
                AutoLayout      = AutoLayout.DockLeft,
                OnClick         = (sender, args) =>
                {
                    var chooser = new Gui.Widgets.GridChooser
                    {
                        ItemSize    = new Point(16, 16),
                        ItemSpacing = new Point(4, 4),
                        ItemSource  = EnumerateDefaultColors()
                                      .Select(c => new Widget
                        {
                            Background      = new TileReference("basic", 1),
                            BackgroundColor = new Vector4(c.ToVector3(), 1),
                        }),
                        OnClose = (s2) =>
                        {
                            var gc = s2 as Gui.Widgets.GridChooser;
                            if (gc.DialogResult == Gui.Widgets.GridChooser.Result.OKAY &&
                                gc.SelectedItem != null)
                            {
                                sender.BackgroundColor = gc.SelectedItem.BackgroundColor;
                                sender.Invalidate();
                                CompanyInformation.LogoBackgroundColor = gc.SelectedItem.BackgroundColor;
                                CompanyLogoDisplay.Invalidate();
                            }
                        },
                        PopupDestructionType = PopupDestructionType.DestroyOnOffClick
                    };
                    GuiRoot.ShowModalPopup(chooser);
                }
            });

            logoRow.AddChild(new Widget
            {
                Text       = "FG:",
                AutoLayout = AutoLayout.DockLeft
            });

            logoRow.AddChild(new Widget
            {
                Background  = CompanyInformation.LogoSymbol,
                MinimumSize = new Point(32, 32),
                MaximumSize = new Point(32, 32),
                AutoLayout  = AutoLayout.DockLeft,
                OnClick     = (sender, args) =>
                {
                    var source  = GuiRoot.GetTileSheet("company-logo-symbol") as Gui.TileSheet;
                    var chooser = new Gui.Widgets.GridChooser
                    {
                        ItemSource = Enumerable.Range(0, source.Columns * source.Rows)
                                     .Select(i => new Widget
                        {
                            Background = new TileReference("company-logo-symbol", i)
                        }),
                        OnClose = (s2) =>
                        {
                            var gc = s2 as Gui.Widgets.GridChooser;
                            if (gc.DialogResult == Gui.Widgets.GridChooser.Result.OKAY &&
                                gc.SelectedItem != null)
                            {
                                sender.Background = gc.SelectedItem.Background;
                                sender.Invalidate();
                                CompanyInformation.LogoSymbol = gc.SelectedItem.Background;
                                CompanyLogoDisplay.Invalidate();
                            }
                        },
                        PopupDestructionType = PopupDestructionType.DestroyOnOffClick
                    };
                    GuiRoot.ShowModalPopup(chooser);
                }
            });

            logoRow.AddChild(new Widget
            {
                Background      = new TileReference("basic", 1),
                BackgroundColor = CompanyInformation.LogoSymbolColor,
                MinimumSize     = new Point(32, 32),
                MaximumSize     = new Point(32, 32),
                AutoLayout      = AutoLayout.DockLeft,
                OnClick         = (sender, args) =>
                {
                    var chooser = new Gui.Widgets.GridChooser
                    {
                        ItemSize    = new Point(16, 16),
                        ItemSpacing = new Point(4, 4),
                        ItemSource  = EnumerateDefaultColors()
                                      .Select(c => new Widget
                        {
                            Background      = new TileReference("basic", 1),
                            BackgroundColor = new Vector4(c.ToVector3(), 1),
                        }),
                        OnClose = (s2) =>
                        {
                            var gc = s2 as Gui.Widgets.GridChooser;
                            if (gc.DialogResult == Gui.Widgets.GridChooser.Result.OKAY &&
                                gc.SelectedItem != null)
                            {
                                sender.BackgroundColor = gc.SelectedItem.BackgroundColor;
                                sender.Invalidate();
                                CompanyInformation.LogoSymbolColor = gc.SelectedItem.BackgroundColor;
                                CompanyLogoDisplay.Invalidate();
                            }
                        },
                        PopupDestructionType = PopupDestructionType.DestroyOnOffClick
                    };
                    GuiRoot.ShowModalPopup(chooser);
                }
            });


            #endregion

            GuiRoot.RootItem.Layout();

            IsInitialized = true;

            base.OnEnter();
        }
Пример #5
0
        public override void Construct()
        {
            Padding = new Margin(2, 2, 0, 0);

            AddChild(new Gui.Widget
            {
                Text               = "Randomize",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) => {
                    DwarfGame.LogSentryBreadcrumb("WorldGenerator", "User is regenerating the world.");
                    Settings.Seed = MathFunctions.RandInt(Int32.MinValue, Int32.MaxValue);
                    Settings.Name = Overworld.GetRandomWorldName();
                    RestartGeneration();
                }
            });

            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) =>
                {
                    DwarfGame.LogSentryBreadcrumb("WorldGenerator", "User is saving the world.");
                    if (Generator.CurrentState != OverworldGenerator.GenerationState.Finished)
                    {
                        Root.ShowTooltip(Root.MousePosition, "Generator is not finished.");
                    }
                    else
                    {
                        global::System.IO.DirectoryInfo worldDirectory = global::System.IO.Directory.CreateDirectory(DwarfGame.GetWorldDirectory() + global::System.IO.Path.DirectorySeparatorChar + Settings.Name);
                        var file = new NewOverworldFile(Game.GraphicsDevice, Settings);
                        file.WriteFile(worldDirectory.FullName);
                        Root.ShowModalPopup(Root.ConstructWidget(new Gui.Widgets.Popup
                        {
                            Text = "File saved."
                        }));
                    }
                }
            });

            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) =>
                {
                    DwarfGame.LogSentryBreadcrumb("WorldGenerator", "User is modifying advanced settings.");
                    var advancedSettingsEditor = Root.ConstructWidget(new Gui.Widgets.WorldGenerationSettingsDialog
                    {
                        Settings = Settings,
                        OnClose  = (s) =>
                        {
                            if ((s as Gui.Widgets.WorldGenerationSettingsDialog).Result == Gui.Widgets.WorldGenerationSettingsDialog.DialogResult.Okay)
                            {
                                RestartGeneration();
                            }
                        }
                    });

                    Root.ShowModalPopup(advancedSettingsEditor);
                }
            });

            StartButton = AddChild(new Gui.Widget
            {
                Text               = "Launch",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockBottom,
                OnClick            = (sender, args) =>
                {
                    Settings.Company.Name  = NameField.Text;
                    Settings.Company.Motto = MottoField.Text;
                    Settings.InstanceSettings.InitalEmbarkment = new Embarkment();
                    Settings.PlayerCorporationFunds            = 1000;
                    Settings.Natives.FirstOrDefault(n => n.Name == "Player").PrimaryColor = new Color(Settings.Company.LogoBackgroundColor);

                    OnVerified?.Invoke();
                }
            });

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

            var difficultySelectorCombo = AddChild(new Gui.Widgets.ComboBox
            {
                AutoLayout             = Gui.AutoLayout.DockTop,
                Items                  = Library.EnumerateDifficulties().Select(e => e.Name).ToList(),
                TextColor              = new Vector4(0, 0, 0, 1),
                Font                   = "font8",
                OnSelectedIndexChanged = (sender) =>
                {
                    Settings.Difficulty = Library.GetDifficulty((sender as Gui.Widgets.ComboBox).SelectedItem);
                }
            }) as Gui.Widgets.ComboBox;

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

            var layerSetting = 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;

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

            var zLevelSetting = AddChild(new Gui.Widgets.ComboBox
            {
                AutoLayout             = AutoLayout.DockTop,
                Items                  = new List <string>(new string[] { "16", "64", "128" }),
                Font                   = "font8",
                TextColor              = new Vector4(0, 0, 0, 1),
                OnSelectedIndexChanged = (sender) =>
                {
                    switch ((sender as Gui.Widgets.ComboBox).SelectedItem)
                    {
                    case "16": Settings.zLevels = 1; break;

                    case "64": Settings.zLevels = 4; break;

                    case "128": Settings.zLevels = 8; break;
                    }
                }
            }) as Gui.Widgets.ComboBox;

            zLevelSetting.SelectedIndex           = 1;
            difficultySelectorCombo.SelectedIndex = difficultySelectorCombo.Items.IndexOf("Normal");
            layerSetting.SelectedIndex            = layerSetting.Items.IndexOf("Normal");

            #region Name

            AddChild(new Gui.Widget
            {
                MinimumSize         = new Point(64, 0),
                Text                = "Company Name",
                Font                = "font8",
                AutoLayout          = AutoLayout.DockTop,
                TextHorizontalAlign = HorizontalAlign.Left,
                TextVerticalAlign   = VerticalAlign.Center
            });

            var nameRow = AddChild(new Widget
            {
                MinimumSize = new Point(0, 32),
                AutoLayout  = AutoLayout.DockTop,
                Padding     = new Margin(0, 0, 2, 2)
            });

            nameRow.AddChild(new Gui.Widgets.Button
            {
                Text       = "?",
                AutoLayout = AutoLayout.DockRight,
                Border     = "border-button",
                OnClick    = (sender, args) =>
                {
                    var templates  = TextGenerator.GetAtoms(ContentPaths.Text.Templates.company);
                    NameField.Text = TextGenerator.GenerateRandom(Datastructures.SelectRandom(templates).ToArray());
                }
            });

            NameField = nameRow.AddChild(new Gui.Widgets.EditableTextField
            {
                Text       = Settings.Company.Name,
                AutoLayout = AutoLayout.DockFill
            }) as Gui.Widgets.EditableTextField;
            #endregion

            #region Motto

            AddChild(new Widget
            {
                MinimumSize         = new Point(64, 0),
                Text                = "Company Motto",
                Font                = "font8",
                AutoLayout          = AutoLayout.DockTop,
                TextHorizontalAlign = HorizontalAlign.Left,
                TextVerticalAlign   = VerticalAlign.Center
            });

            var mottoRow = AddChild(new Widget
            {
                MinimumSize = new Point(0, 32),
                AutoLayout  = AutoLayout.DockTop,
                Padding     = new Margin(0, 0, 2, 2)
            });

            mottoRow.AddChild(new Gui.Widgets.Button
            {
                Text       = "?",
                AutoLayout = AutoLayout.DockRight,
                Border     = "border-button",
                OnClick    = (sender, args) =>
                {
                    var templates   = TextGenerator.GetAtoms(ContentPaths.Text.Templates.mottos);
                    MottoField.Text = TextGenerator.GenerateRandom(Datastructures.SelectRandom(templates).ToArray());
                    // Todo: Doesn't automatically invalidate when text changed??
                    MottoField.Invalidate();
                }
            });

            MottoField = mottoRow.AddChild(new Gui.Widgets.EditableTextField
            {
                Text       = Settings.Company.Motto,
                AutoLayout = AutoLayout.DockFill
            }) as Gui.Widgets.EditableTextField;
            #endregion

            #region Logo

            AddChild(new Widget
            {
                MinimumSize         = new Point(64, 0),
                Text                = "Company Logo",
                Font                = "font8",
                AutoLayout          = AutoLayout.DockTop,
                TextHorizontalAlign = HorizontalAlign.Left,
                TextVerticalAlign   = VerticalAlign.Center
            });

            var logoRow = AddChild(new Widget
            {
                MinimumSize = new Point(0, 64),
                AutoLayout  = AutoLayout.DockTop,
                Padding     = new Margin(0, 0, 2, 2)
            });

            CompanyLogoDisplay = logoRow.AddChild(new Gui.Widgets.CompanyLogo
            {
                AutoLayout         = AutoLayout.DockLeft,
                MinimumSize        = new Point(64, 64),
                MaximumSize        = new Point(64, 64),
                CompanyInformation = Settings.Company
            }) as Gui.Widgets.CompanyLogo;

            var rightBox = logoRow.AddChild(new Widget
            {
                AutoLayout = AutoLayout.DockFill
            });

            var bgBox = rightBox.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(32, 32),
            });

            bgBox.AddChild(new Widget
            {
                Text       = "BG:",
                AutoLayout = AutoLayout.DockLeft
            });

            bgBox.AddChild(new Widget
            {
                Background  = Settings.Company.LogoBackground,
                MinimumSize = new Point(32, 32),
                MaximumSize = new Point(32, 32),
                AutoLayout  = AutoLayout.DockLeft,
                OnClick     = (sender, args) =>
                {
                    var source  = Root.GetTileSheet("company-logo-background") as Gui.TileSheet;
                    var chooser = new Gui.Widgets.GridChooser
                    {
                        ItemSource = Enumerable.Range(0, source.Columns * source.Rows)
                                     .Select(i => new Widget
                        {
                            Background = new TileReference("company-logo-background", i)
                        }),
                        OnClose = (s2) =>
                        {
                            var gc = s2 as Gui.Widgets.GridChooser;
                            if (gc.DialogResult == Gui.Widgets.GridChooser.Result.OKAY &&
                                gc.SelectedItem != null)
                            {
                                sender.Background = gc.SelectedItem.Background;
                                sender.Invalidate();
                                Settings.Company.LogoBackground = gc.SelectedItem.Background;
                                CompanyLogoDisplay.Invalidate();
                            }
                        },
                        PopupDestructionType = PopupDestructionType.DestroyOnOffClick
                    };
                    Root.ShowModalPopup(chooser);
                }
            });

            bgBox.AddChild(new Widget
            {
                Background      = new TileReference("basic", 1),
                BackgroundColor = Settings.Company.LogoBackgroundColor,
                MinimumSize     = new Point(32, 32),
                MaximumSize     = new Point(32, 32),
                AutoLayout      = AutoLayout.DockLeft,
                OnClick         = (sender, args) =>
                {
                    var chooser = new Gui.Widgets.GridChooser
                    {
                        ItemSize    = new Point(16, 16),
                        ItemSpacing = new Point(4, 4),
                        ItemSource  = EnumerateDefaultColors()
                                      .Select(c => new Widget
                        {
                            Background      = new TileReference("basic", 1),
                            BackgroundColor = new Vector4(c.ToVector3(), 1),
                        }),
                        OnClose = (s2) =>
                        {
                            var gc = s2 as Gui.Widgets.GridChooser;
                            if (gc.DialogResult == Gui.Widgets.GridChooser.Result.OKAY &&
                                gc.SelectedItem != null)
                            {
                                sender.BackgroundColor = gc.SelectedItem.BackgroundColor;
                                sender.Invalidate();
                                Settings.Company.LogoBackgroundColor = gc.SelectedItem.BackgroundColor;
                                CompanyLogoDisplay.Invalidate();
                            }
                        },
                        PopupDestructionType = PopupDestructionType.DestroyOnOffClick
                    };
                    Root.ShowModalPopup(chooser);
                }
            });

            var fgBox = rightBox.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockFill,
                MinimumSize = new Point(32, 32),
            });

            fgBox.AddChild(new Widget
            {
                Text       = "FG:",
                AutoLayout = AutoLayout.DockLeft
            });

            fgBox.AddChild(new Widget
            {
                Background  = Settings.Company.LogoSymbol,
                MinimumSize = new Point(32, 32),
                MaximumSize = new Point(32, 32),
                AutoLayout  = AutoLayout.DockLeft,
                OnClick     = (sender, args) =>
                {
                    var source  = Root.GetTileSheet("company-logo-symbol") as Gui.TileSheet;
                    var chooser = new Gui.Widgets.GridChooser
                    {
                        ItemSource = Enumerable.Range(0, source.Columns * source.Rows)
                                     .Select(i => new Widget
                        {
                            Background = new TileReference("company-logo-symbol", i)
                        }),
                        OnClose = (s2) =>
                        {
                            var gc = s2 as Gui.Widgets.GridChooser;
                            if (gc.DialogResult == Gui.Widgets.GridChooser.Result.OKAY &&
                                gc.SelectedItem != null)
                            {
                                sender.Background = gc.SelectedItem.Background;
                                sender.Invalidate();
                                Settings.Company.LogoSymbol = gc.SelectedItem.Background;
                                CompanyLogoDisplay.Invalidate();
                            }
                        },
                        PopupDestructionType = PopupDestructionType.DestroyOnOffClick
                    };
                    Root.ShowModalPopup(chooser);
                }
            });

            fgBox.AddChild(new Widget
            {
                Background      = new TileReference("basic", 1),
                BackgroundColor = Settings.Company.LogoSymbolColor,
                MinimumSize     = new Point(32, 32),
                MaximumSize     = new Point(32, 32),
                AutoLayout      = AutoLayout.DockLeft,
                OnClick         = (sender, args) =>
                {
                    var chooser = new Gui.Widgets.GridChooser
                    {
                        ItemSize    = new Point(16, 16),
                        ItemSpacing = new Point(4, 4),
                        ItemSource  = EnumerateDefaultColors()
                                      .Select(c => new Widget
                        {
                            Background      = new TileReference("basic", 1),
                            BackgroundColor = new Vector4(c.ToVector3(), 1),
                        }),
                        OnClose = (s2) =>
                        {
                            var gc = s2 as Gui.Widgets.GridChooser;
                            if (gc.DialogResult == Gui.Widgets.GridChooser.Result.OKAY &&
                                gc.SelectedItem != null)
                            {
                                sender.BackgroundColor = gc.SelectedItem.BackgroundColor;
                                sender.Invalidate();
                                Settings.Company.LogoSymbolColor = gc.SelectedItem.BackgroundColor;
                                CompanyLogoDisplay.Invalidate();
                            }
                        },
                        PopupDestructionType = PopupDestructionType.DestroyOnOffClick
                    };
                    Root.ShowModalPopup(chooser);
                }
            });


            #endregion


            base.Construct();
        }