Esempio n. 1
0
        public override void Construct()
        {
            AutoSizeColumns = true;
            IsRootTray      = true;

            ItemSource = new Gui.Widget[]
            {
                new HorizontalMenuTray.MenuItem
                {
                    Text = "CHEAT MODE",
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "DEBUG",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSize   = new Point(200, 20),
                        ItemSource = Debugger.EnumerateSwitches().Select(s =>
                                                                         new HorizontalMenuTray.CheckboxMenuItem
                        {
                            Text         = Debugger.GetNicelyFormattedName(s.Name),
                            InitialState = s.State,
                            SetCallback  = s.Set
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "DEBUG SAVE",
                    OnClick = (sender, args) =>
                    {
                        // Turn off binary compressed saves and save a nice straight json save for debugging purposes.

                        // Todo: Why isn't World managing this paused state itself?
                        bool paused          = Master.World.Paused;
                        var  previousSetting = DwarfGame.COMPRESSED_BINARY_SAVES;
                        DwarfGame.COMPRESSED_BINARY_SAVES = false;
                        Master.World.Save(
                            String.Format("{0}_{1}_DEBUG", Overworld.Name, Master.World.GameID),
                            (success, exception) =>
                        {
                            Master.World.MakeAnnouncement(success ? "Debug save created.": "Debug save failed - " + exception.Message);
                            DwarfGame.COMPRESSED_BINARY_SAVES = previousSetting;
                            Master.World.Paused = paused;
                        });
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "BUILD",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = RoomLibrary.GetRoomTypes().Select(r =>
                                                                       new HorizontalMenuTray.MenuItem
                        {
                            Text    = r,
                            OnClick = (sender, args) => ActivateGodTool("Build/" + r)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "SPAWN",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 5,
                        ItemSource = EntityFactory.EnumerateEntityTypes().Where(s => !s.Contains("Resource") ||
                                                                                !ResourceLibrary.GetResourceByName(s.Substring(0, s.Length - " Resource".Length)).Generated).OrderBy(s => s).Select(s =>
                                                                                                                                                                                                    new HorizontalMenuTray.MenuItem
                        {
                            Text    = s,
                            OnClick = (sender, args) => ActivateGodTool("Spawn/" + s)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "PLACE BLOCK",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 3,
                        ItemSource = VoxelLibrary.GetTypes()
                                     .Where(t => t.Name != "_empty" && t.Name != "water")
                                     .OrderBy(s => s.Name)
                                     .Select(s =>
                                             new HorizontalMenuTray.MenuItem
                        {
                            Text    = s.Name,
                            OnClick = (sender, args) => ActivateGodTool("Place/" + s.Name)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "DELETE BLOCK",
                    OnClick = (sender, args) => ActivateGodTool("Delete Block")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "KILL BLOCK",
                    OnClick = (sender, args) => ActivateGodTool("Kill Block")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "PLACE GRASS",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 3,
                        ItemSource = GrassLibrary.TypeList
                                     .OrderBy(s => s.Name)
                                     .Select(s =>
                                             new HorizontalMenuTray.MenuItem
                        {
                            Text    = s.Name,
                            OnClick = (sender, args) => ActivateGodTool("Grass/" + s.Name)
                        })
                    }
                },

                //new HorizontalMenuTray.MenuItem
                //{
                //    Text = "PLACE DECAL",
                //    ExpansionChild = new HorizontalMenuTray.Tray
                //    {
                //        Columns = 3,
                //        ItemSource = DecalLibrary.TypeList
                //            .OrderBy(s => s.Name)
                //            .Select(s =>
                //                new HorizontalMenuTray.MenuItem
                //                {
                //                    Text = s.Name,
                //                    OnClick = (sender, args) => ActivateGodTool("Decal/" + s.Name)
                //                })
                //    }
                //},

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "PLACE RAIL",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 1,
                        ItemSource = new HorizontalMenuTray.MenuItem[]
                        {
                            new HorizontalMenuTray.MenuItem
                            {
                                Text           = "RAW PIECES",
                                ExpansionChild = new HorizontalMenuTray.Tray
                                {
                                    Columns    = 2,
                                    ItemSize   = new Point(200, 20),
                                    ItemSource = Rail.RailLibrary.EnumeratePieces().Select(p =>
                                                                                           new HorizontalMenuTray.MenuItem
                                    {
                                        Text    = p.Name,
                                        OnClick = (sender, args) => ActivateGodTool("Rail/" + p.Name)
                                    })
                                }
                            },

                            new HorizontalMenuTray.MenuItem
                            {
                                Text           = "USING PATTERNS",
                                ExpansionChild = new HorizontalMenuTray.Tray
                                {
                                    Columns    = 1,
                                    ItemSource = Rail.RailLibrary.EnumeratePatterns().Select(p =>
                                                                                             new HorizontalMenuTray.MenuItem
                                    {
                                        Text    = p.Name,
                                        OnClick = (sender, args) =>
                                        {
                                            var railTool     = Master.Tools[GameMaster.ToolMode.BuildRail] as Rail.BuildRailTool;
                                            railTool.Pattern = p;
                                            Master.ChangeTool(GameMaster.ToolMode.BuildRail);
                                            railTool.GodModeSwitch = true;
                                        }
                                    })
                                }
                            },

                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "PAINT",
                                OnClick = (sender, args) =>
                                {
                                    var railTool = Master.Tools[GameMaster.ToolMode.PaintRail] as Rail.PaintRailTool;
                                    railTool.SelectedResources = new List <ResourceAmount>(new ResourceAmount[] { new ResourceAmount("Rail", 1) });
                                    Master.ChangeTool(GameMaster.ToolMode.PaintRail);
                                    railTool.GodModeSwitch = true;
                                }
                            }
                        }
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "KILL THINGS",
                    OnClick = (sender, args) => ActivateGodTool("Kill Things")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "TRAILER",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = new List <HorizontalMenuTray.MenuItem>()
                        {
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "SPIN +",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, 2.0f, 0.0f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "SPIN -",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, -2.0f, 0.0f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "ZOOM -",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, 0.0f, 2.5f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "ZOOM +",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, 0.0f, -2.5f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "FWD",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Forward * 5, 0.0f, 0.0f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "BACK",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Backward * 5, 0.0f, 0.0f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "LEFT",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Left * 5, 0.0f, 0.0f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "RIGHT",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Right * 5, 0.0f, 0.0f),
                            },
                        }
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "FILL WATER",
                    OnClick = (sender, args) => ActivateGodTool("Fill Water")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "FILL LAVA",
                    OnClick = (sender, args) => ActivateGodTool("Fill Lava")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "TRADE ENVOY",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = Master.World.Factions.Factions.Values.Where(f => f.Race.IsIntelligent && f != Master.Faction).Select(s =>
                        {
                            return(new HorizontalMenuTray.MenuItem
                            {
                                Text = s.Name,
                                OnClick = (sender, args) => Master.World.Diplomacy.SendTradeEnvoy(s, Master.World)
                            });
                        }),
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text           = "EVENT",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = Master.World.GoalManager.EventScheduler.Events.Events.Select(e =>
                        {
                            return(new HorizontalMenuTray.MenuItem
                            {
                                Text = e.Name,
                                OnClick = (sender, args) => Master.World.GoalManager.EventScheduler.ActivateEvent(Master.World, e)
                            });
                        }),
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text           = "WAR PARTY",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = Master.World.Factions.Factions.Values.Where(f => f.Race.IsIntelligent && f != Master.Faction).Select(s =>
                        {
                            return(new HorizontalMenuTray.MenuItem
                            {
                                Text = s.Name,
                                OnClick = (sender, args) => Master.World.Diplomacy.SendWarParty(s)
                            });
                        }),
                    }
                },


                new HorizontalMenuTray.MenuItem
                {
                    Text    = "DWARF BUX",
                    OnClick = (sender, args) => Master.Faction.AddMoney(100m)
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "MINIONS",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = new HorizontalMenuTray.MenuItem[]
                        {
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "PAY",
                                OnClick = (sender, args) => Master.PayEmployees()
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "STARVE",
                                OnClick = (sender, args) =>
                                {
                                    foreach (var minion in Master.Faction.Minions)
                                    {
                                        minion.Status.Hunger.CurrentValue = 0;
                                    }
                                }
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "XP",
                                OnClick = (sender, args) =>
                                {
                                    foreach (var minion in Master.Faction.Minions)
                                    {
                                        minion.AddXP(100);
                                    }
                                }
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "DISEASE",
                                OnClick = (sender, args) => ActivateGodTool("Disease")
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "HAPPY",
                                OnClick = (sender, args) =>
                                {
                                    foreach (var minion in Master.Faction.Minions)
                                    {
                                        var thoughts = minion.GetRoot().GetComponent <DwarfThoughts>();
                                        if (thoughts != null)
                                        {
                                            thoughts.AddThought(Thought.ThoughtType.CheatedHappy);
                                        }
                                    }
                                }
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "PISSED",
                                OnClick = (sender, args) =>
                                {
                                    foreach (var minion in Master.Faction.Minions)
                                    {
                                        var thoughts = minion.GetRoot().GetComponent <DwarfThoughts>();
                                        if (thoughts != null)
                                        {
                                            thoughts.AddThought(Thought.ThoughtType.CheatedPissed);
                                        }
                                    }
                                }
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "GAMBLE",
                                OnClick = (sender, args) =>
                                {
                                    foreach (var employee in Master.Faction.Minions)
                                    {
                                        employee.AssignTask(new Scripting.GambleTask()
                                        {
                                            Priority = Task.PriorityType.High
                                        });
                                    }
                                }
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "PASS OUT",
                                OnClick = (sender, args) =>
                                {
                                    var employee = Datastructures.SelectRandom(Master.Faction.Minions);
                                    if (employee != null)
                                    {
                                        employee.Creature.Heal(-employee.Status.Health.CurrentValue * employee.Creature.MaxHealth + 1);
                                    }
                                }
                            }
                        }
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "SPAWN TEST",
                    OnClick = (sender, args) =>
                    {
                        // Copy is required because spawning some types results in the creation of new types. EG, snakes create snake meat.
                        var     keys       = EntityFactory.EnumerateEntityTypes().ToList();
                        int     num        = keys.Count();
                        float   gridSize   = (float)Math.Ceiling(Math.Sqrt((double)num));
                        Vector3 gridCenter = Master.World.CursorLightPos;
                        int     i          = 0;
                        for (float dx = -gridSize / 2; dx <= gridSize / 2; dx++)
                        {
                            for (float dz = -gridSize / 2; dz <= gridSize / 2; dz++)
                            {
                                if (i >= num)
                                {
                                    continue;
                                }

                                Vector3     pos    = MathFunctions.Clamp(gridCenter + new Vector3(dx, VoxelConstants.ChunkSizeY, dz), Master.World.ChunkManager.Bounds);
                                VoxelHandle handle = VoxelHelpers.FindFirstVisibleVoxelOnRay(Master.World.ChunkManager.ChunkData, pos, pos + Vector3.Down * 100);
                                if (handle.IsValid)
                                {
                                    EntityFactory.CreateEntity <GameComponent>(keys[i], handle.WorldPosition + Vector3.Up);
                                }
                                i++;
                            }
                        }
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "SPAWN CRAFTS",
                    OnClick = (sender, args) =>
                    {
                        // Copy is required because spawning some types results in the creation of new types. EG, snakes create snake meat.
                        var     itemTypes  = CraftLibrary.EnumerateCraftables().Where(craft => craft.Type == CraftItem.CraftType.Object).ToList();
                        int     num        = itemTypes.Count();
                        float   gridSize   = (float)Math.Ceiling(Math.Sqrt((double)num));
                        Vector3 gridCenter = Master.World.CursorLightPos;

                        int i = 0;
                        for (float dx = -gridSize / 2; dx <= gridSize / 2; dx++)
                        {
                            for (float dz = -gridSize / 2; dz <= gridSize / 2; dz++)
                            {
                                if (i < num)
                                {
                                    var item = itemTypes[i];
                                    if (item.Name != "Explosive")
                                    {
                                        Vector3     pos    = MathFunctions.Clamp(gridCenter + new Vector3(dx, VoxelConstants.ChunkSizeY, dz), Master.World.ChunkManager.Bounds);
                                        VoxelHandle handle = VoxelHelpers.FindFirstVisibleVoxelOnRay(Master.World.ChunkManager.ChunkData, pos, pos + Vector3.Down * 100);

                                        if (handle.IsValid)
                                        {
                                            var blackboard = new Blackboard();
                                            List <ResourceAmount> resources = item.RequiredResources.Select(r => new ResourceAmount(ResourceLibrary.GetResourcesByTag(r.ResourceType).First(), r.NumResources)).ToList();
                                            blackboard.SetData <List <ResourceAmount> >("Resources", resources);
                                            blackboard.SetData <string>("CraftType", item.Name);

                                            var entity = EntityFactory.CreateEntity <GameComponent>(item.EntityName, handle.WorldPosition + Vector3.Up + item.SpawnOffset, blackboard);
                                            if (entity != null)
                                            {
                                                if (item.AddToOwnedPool)
                                                {
                                                    Master.Faction.OwnedObjects.Add(entity as Body);
                                                }
                                                if (item.Moveable)
                                                {
                                                    entity.Tags.Add("Moveable");
                                                }
                                                if (item.Deconstructable)
                                                {
                                                    entity.Tags.Add("Deconstructable");
                                                }
                                            }
                                        }
                                    }
                                }
                                i++;
                            }
                        }
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "+1 HOUR",
                    OnClick = (sender, args) =>
                    {
                        Master.World.Time.CurrentDate += new TimeSpan(1, 0, 0);
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "FORCE REBUILD",
                    OnClick = (sender, args) =>
                    {
                        foreach (var chunk in Master.World.ChunkManager.ChunkData.ChunkMap)
                        {
                            for (int Y = 0; Y < VoxelConstants.ChunkSizeY; ++Y)
                            {
                                chunk.InvalidateSlice(Y);
                            }
                        }
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "REPULSE",
                    OnClick = (sender, args) => ActivateGodTool("Repulse")
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "SLOWMO",
                    OnClick = (sender, args) => GameSettings.Default.EnableSlowMotion = !GameSettings.Default.EnableSlowMotion
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "LET IT SNOW",
                    OnClick = (sender, args) =>
                    {
                        var storm = Weather.CreateStorm(Vector3.One, 100.0f, Master.World);
                        storm.TypeofStorm = StormType.SnowStorm;
                        storm.Start();
                    }
                }
            };

            base.Construct();
        }
Esempio n. 2
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 Gui.MousePointer("mouse", 4, 0);

            Rectangle rect = GuiRoot.RenderData.VirtualScreen;

            rect.Inflate(-rect.Width / 3, -rect.Height / 3);
            // CONSTRUCT GUI HERE...
            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());
                    // Todo: Doesn't automatically invalidate when text changed??
                    NameField.Invalidate();
                }
            });

            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();

            // Must be true or Render will not be called.
            IsInitialized = true;

            base.OnEnter();
        }
Esempio n. 3
0
        public override void OnAction(WorldManager world)
        {
            var owner    = world.Factions.Factions[OwnerFaction];
            var dest     = world.Factions.Factions[DestinationFaction];
            var strength = Party.Sum(p => p.Stats.BuffedStr);
            var politics = world.Diplomacy.GetPolitics(owner, dest);
            List <ResourceAmount> destGoods = dest.Race.GenerateResources(world);

            int turns = MathFunctions.RandInt(1, (int)strength);
            List <ResourceAmount> stolenGoods = new List <ResourceAmount>();
            DwarfBux stolenMoney = 0.0m;
            int      numDead     = 0;

            for (int turn = 0; turn < turns; turn++)
            {
                numDead += Party.Count(p => p.Creature.Hp <= 0);
                Party.RemoveAll(p => p.Creature.Hp <= 0);
                if (Party.Count == 0)
                {
                    break;
                }
                var randomCritter = Datastructures.SelectRandom(Party);
                var con           = randomCritter.Stats.BuffedCon;
                var enemyAttack   = MathFunctions.RandInt(1, 20);
                if (enemyAttack - con > 10 || enemyAttack == 20)
                {
                    randomCritter.Creature.Hp -= MathFunctions.RandInt(5, 100);
                    if (randomCritter.Creature.Hp <= 0)
                    {
                        randomCritter.GetRoot().Delete();
                    }
                    var thoughts = randomCritter.Creature.GetComponent <DwarfThoughts>();
                    if (thoughts != null)
                    {
                        thoughts.AddThought(Thought.ThoughtType.TookDamage);
                    }
                }
                else
                {
                    stolenGoods.Add(new ResourceAmount(Datastructures.SelectRandom(destGoods).ResourceType, MathFunctions.RandInt(1, 5)));
                    stolenMoney += (DwarfBux)(decimal)MathFunctions.RandInt(1, 100);
                }
            }

            politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
            {
                Change      = -5,
                Description = "You attacked us!",
                Duration    = new TimeSpan(5, 0, 0, 0, 0),
                Time        = world.Time.CurrentDate
            });

            politics.WasAtWar = true;
            politics.HasMet   = true;

            if (Party.Count == 0)
            {
                LastEvent = "All of the raiding party members died!";
                Resources.Clear();
                Money          = 0.0m;
                AdventureState = State.Done;
                return;
            }

            Resources.AddRange(stolenGoods);
            Money += stolenMoney;

            if (numDead == 0)
            {
                LastEvent      = String.Format("The raiding party is returning home unscathed! They stole {0} goods and {1}.", stolenGoods.Sum(g => g.NumResources), stolenMoney);
                AdventureState = State.ComingBack;
            }
            else
            {
                LastEvent      = String.Format("The raiding party is returning home. They stole {0} goods and {1}, but {2} member(s) died.", stolenGoods.Sum(g => g.NumResources), stolenMoney, numDead);
                AdventureState = State.ComingBack;
            }

            foreach (var creature in Party)
            {
                var thoughts = creature.Creature.GetComponent <DwarfThoughts>();
                if (thoughts != null)
                {
                    thoughts.AddThought(Thought.ThoughtType.KilledThing);
                }
            }
            base.OnAction(world);
        }
Esempio n. 4
0
        public override void OnAction(WorldManager world)
        {
            if (Resources.Count == 0)
            {
                LastEvent = String.Format("The trade party didn't have anything to trade, so they're coming home.");
                return;
            }

            var   owner                      = world.Factions.Factions[OwnerFaction];
            var   dest                       = world.Factions.Factions[DestinationFaction];
            var   charisma                   = Party.Max(p => p.Stats.BuffedChar);
            float tradeGoodness              = charisma - MathFunctions.Rand(0, 10.0f);
            var   politics                   = world.Diplomacy.GetPolitics(owner, dest);
            List <ResourceAmount> destGoods  = dest.Race.GenerateResources(world);
            List <ResourceAmount> tradeGoods = new List <ResourceAmount>();
            bool wasBadTrade                 = false;
            int  randIters                   = 100;

            for (int iter = 0; iter < randIters; iter++)
            {
                var resourceType = Datastructures.SelectRandom(Resources);
                if (resourceType.NumResources == 0)
                {
                    continue;
                }
                var  resource = ResourceLibrary.GetResourceByName(resourceType.ResourceType);
                bool liked    = resource.Tags.Any(t => dest.Race.LikedResources.Contains(t));
                bool hated    = resource.Tags.Any(t => dest.Race.HatedResources.Contains(t));

                if (tradeGoodness < 0 && liked)
                {
                    LastEvent = String.Format("{0} gave the {1} {2}, which made them very angry!",
                                              Datastructures.SelectRandom(Party).Stats.FullName,
                                              dest.Race.Name, resourceType.ResourceType);
                    string badTrade = "You gave us something we hate.";
                    if (!politics.RecentEvents.Any(ev => ev.Description == badTrade))
                    {
                        politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                        {
                            Description = badTrade,
                            Change      = -5,
                            Duration    = new TimeSpan(4, 0, 0, 0),
                            Time        = world.Time.CurrentDate
                        });
                    }
                    wasBadTrade = true;
                    break;
                }
                else if (tradeGoodness > 0 && liked)
                {
                    string goodTrade = "You gave us something we like.";
                    if (!politics.RecentEvents.Any(ev => ev.Description == goodTrade))
                    {
                        politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                        {
                            Description = goodTrade,
                            Change      = 5,
                            Duration    = new TimeSpan(4, 0, 0, 0),
                            Time        = world.Time.CurrentDate
                        });
                    }
                }
                var resourceValue = GetValue(resource, dest);

                // Now find a resource of equal or greater value and trade for it.
                int randIter2 = 0;
                while (randIter2 < 100)
                {
                    var randGood = Datastructures.SelectRandom(destGoods);
                    if (randGood.NumResources == 0)
                    {
                        randIter2++;
                        continue;
                    }

                    var good          = ResourceLibrary.GetResourceByName(randGood.ResourceType);
                    var randGoodValue = GetValue(good, dest);

                    // Trade the most of this resource we possibly can. If we want to
                    // trade an item of lesser value, try to trade 1 good for as much of it as possible.
                    if (randGoodValue <= resourceValue)
                    {
                        int numToTrade = Math.Min((int)(resourceValue / randGoodValue), randGood.NumResources);
                        if (numToTrade * randGoodValue >= 0.75f * resourceValue)
                        {
                            randGood.NumResources -= numToTrade;
                            resourceType.NumResources--;
                            tradeGoods.Add(new ResourceAmount(good, numToTrade));
                            break;
                        }
                    }
                    // If we're trading upwards, try trading as much of our resource as possible for the valuable item.
                    else
                    {
                        int numToTrade = Math.Min((int)(randGoodValue / resourceValue), resourceType.NumResources);
                        if (numToTrade * resourceValue >= 0.75f * randGoodValue)
                        {
                            randGood.NumResources--;
                            resourceType.NumResources -= numToTrade;
                            tradeGoods.Add(new ResourceAmount(good, 1));
                            break;
                        }
                    }

                    randIter2++;
                }

                // We failed to find a good of equal value, so let's just trade money.
                if (randIter2 == 100)
                {
                    resourceType.NumResources--;
                    Money += resourceValue;
                }
            }


            Resources.AddRange(tradeGoods);
            if (!wasBadTrade)
            {
                LastEvent = String.Format("The trade party is returning home with {0} goods, and {1}.", Resources.Sum(r => r.NumResources), Money);
            }

            base.OnAction(world);
        }
Esempio n. 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();
        }